index-Bzc6D_QS.js 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614
  1. function kre(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var mv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function mo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var MA={exports:{}},sx={};var lF;function Pre(){if(lF)return sx;lF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var s=null;if(a!==void 0&&(s=""+a),i.key!==void 0&&(s=""+i.key),"key"in i){a={};for(var o in i)o!=="key"&&(a[o]=i[o])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:s,ref:i!==void 0?i:null,props:a}}return sx.Fragment=e,sx.jsx=n,sx.jsxs=n,sx}var cF;function Rre(){return cF||(cF=1,MA.exports=Pre()),MA.exports}var l=Rre(),EA={exports:{}},en={};var uF;function jre(){if(uF)return en;uF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function p(U){return U===null||typeof U!="object"?null:(U=g&&U[g]||U["@@iterator"],typeof U=="function"?U:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,y={};function b(U,H,ee){this.props=U,this.context=H,this.refs=y,this.updater=ee||x}b.prototype.isReactComponent={},b.prototype.setState=function(U,H){if(typeof U!="object"&&typeof U!="function"&&U!=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,U,H,"setState")},b.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function E(){}E.prototype=b.prototype;function w(U,H,ee){this.props=U,this.context=H,this.refs=y,this.updater=ee||x}var A=w.prototype=new E;A.constructor=w,v(A,b.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function C(){}var k={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function N(U,H,ee){var ie=ee.ref;return{$$typeof:t,type:U,key:H,ref:ie!==void 0?ie:null,props:ee}}function j(U,H){return N(U.type,H,U.props)}function I(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function O(U){var H={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(ee){return H[ee]})}var q=/\/+/g;function R(U,H){return typeof U=="object"&&U!==null&&U.key!=null?O(""+U.key):H.toString(36)}function W(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(C,C):(U.status="pending",U.then(function(H){U.status==="pending"&&(U.status="fulfilled",U.value=H)},function(H){U.status==="pending"&&(U.status="rejected",U.reason=H)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function K(U,H,ee,ie,pe){var ue=typeof U;(ue==="undefined"||ue==="boolean")&&(U=null);var be=!1;if(U===null)be=!0;else switch(ue){case"bigint":case"string":case"number":be=!0;break;case"object":switch(U.$$typeof){case t:case e:be=!0;break;case d:return be=U._init,K(be(U._payload),H,ee,ie,pe)}}if(be)return pe=pe(U),be=ie===""?"."+R(U,0):ie,T(pe)?(ee="",be!=null&&(ee=be.replace(q,"$&/")+"/"),K(pe,H,ee,"",function(_e){return _e})):pe!=null&&(I(pe)&&(pe=j(pe,ee+(pe.key==null||U&&U.key===pe.key?"":(""+pe.key).replace(q,"$&/")+"/")+be)),H.push(pe)),1;be=0;var Re=ie===""?".":ie+":";if(T(U))for(var Z=0;Z<U.length;Z++)ie=U[Z],ue=Re+R(ie,Z),be+=K(ie,H,ee,ue,pe);else if(Z=p(U),typeof Z=="function")for(U=Z.call(U),Z=0;!(ie=U.next()).done;)ie=ie.value,ue=Re+R(ie,Z++),be+=K(ie,H,ee,ue,pe);else if(ue==="object"){if(typeof U.then=="function")return K(W(U),H,ee,ie,pe);throw H=String(U),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return be}function G(U,H,ee){if(U==null)return U;var ie=[],pe=0;return K(U,ie,"","",function(ue){return H.call(ee,ue,pe++)}),ie}function te(U){if(U._status===-1){var H=U._result;H=H(),H.then(function(ee){(U._status===0||U._status===-1)&&(U._status=1,U._result=ee)},function(ee){(U._status===0||U._status===-1)&&(U._status=2,U._result=ee)}),U._status===-1&&(U._status=0,U._result=H)}if(U._status===1)return U._result.default;throw U._result}var Y=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},J={map:G,forEach:function(U,H,ee){G(U,function(){H.apply(this,arguments)},ee)},count:function(U){var H=0;return G(U,function(){H++}),H},toArray:function(U){return G(U,function(H){return H})||[]},only:function(U){if(!I(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return en.Activity=f,en.Children=J,en.Component=b,en.Fragment=n,en.Profiler=i,en.PureComponent=w,en.StrictMode=r,en.Suspense=c,en.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,en.__COMPILER_RUNTIME={__proto__:null,c:function(U){return k.H.useMemoCache(U)}},en.cache=function(U){return function(){return U.apply(null,arguments)}},en.cacheSignal=function(){return null},en.cloneElement=function(U,H,ee){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var ie=v({},U.props),pe=U.key;if(H!=null)for(ue in H.key!==void 0&&(pe=""+H.key),H)!F.call(H,ue)||ue==="key"||ue==="__self"||ue==="__source"||ue==="ref"&&H.ref===void 0||(ie[ue]=H[ue]);var ue=arguments.length-2;if(ue===1)ie.children=ee;else if(1<ue){for(var be=Array(ue),Re=0;Re<ue;Re++)be[Re]=arguments[Re+2];ie.children=be}return N(U.type,pe,ie)},en.createContext=function(U){return U={$$typeof:s,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:a,_context:U},U},en.createElement=function(U,H,ee){var ie,pe={},ue=null;if(H!=null)for(ie in H.key!==void 0&&(ue=""+H.key),H)F.call(H,ie)&&ie!=="key"&&ie!=="__self"&&ie!=="__source"&&(pe[ie]=H[ie]);var be=arguments.length-2;if(be===1)pe.children=ee;else if(1<be){for(var Re=Array(be),Z=0;Z<be;Z++)Re[Z]=arguments[Z+2];pe.children=Re}if(U&&U.defaultProps)for(ie in be=U.defaultProps,be)pe[ie]===void 0&&(pe[ie]=be[ie]);return N(U,ue,pe)},en.createRef=function(){return{current:null}},en.forwardRef=function(U){return{$$typeof:o,render:U}},en.isValidElement=I,en.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:te}},en.memo=function(U,H){return{$$typeof:u,type:U,compare:H===void 0?null:H}},en.startTransition=function(U){var H=k.T,ee={};k.T=ee;try{var ie=U(),pe=k.S;pe!==null&&pe(ee,ie),typeof ie=="object"&&ie!==null&&typeof ie.then=="function"&&ie.then(C,Y)}catch(ue){Y(ue)}finally{H!==null&&ee.types!==null&&(H.types=ee.types),k.T=H}},en.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},en.use=function(U){return k.H.use(U)},en.useActionState=function(U,H,ee){return k.H.useActionState(U,H,ee)},en.useCallback=function(U,H){return k.H.useCallback(U,H)},en.useContext=function(U){return k.H.useContext(U)},en.useDebugValue=function(){},en.useDeferredValue=function(U,H){return k.H.useDeferredValue(U,H)},en.useEffect=function(U,H){return k.H.useEffect(U,H)},en.useEffectEvent=function(U){return k.H.useEffectEvent(U)},en.useId=function(){return k.H.useId()},en.useImperativeHandle=function(U,H,ee){return k.H.useImperativeHandle(U,H,ee)},en.useInsertionEffect=function(U,H){return k.H.useInsertionEffect(U,H)},en.useLayoutEffect=function(U,H){return k.H.useLayoutEffect(U,H)},en.useMemo=function(U,H){return k.H.useMemo(U,H)},en.useOptimistic=function(U,H){return k.H.useOptimistic(U,H)},en.useReducer=function(U,H,ee){return k.H.useReducer(U,H,ee)},en.useRef=function(U){return k.H.useRef(U)},en.useState=function(U){return k.H.useState(U)},en.useSyncExternalStore=function(U,H,ee){return k.H.useSyncExternalStore(U,H,ee)},en.useTransition=function(){return k.H.useTransition()},en.version="19.2.0",en}var dF;function qp(){return dF||(dF=1,EA.exports=jre()),EA.exports}var M=qp();const gr=mo(M),Dre=kre({__proto__:null,default:gr},[M]);var AA={exports:{}},ox={},TA={exports:{}},CA={};var hF;function Ore(){return hF||(hF=1,(function(t){function e(K,G){var te=K.length;K.push(G);e:for(;0<te;){var Y=te-1>>>1,J=K[Y];if(0<i(J,G))K[Y]=G,K[te]=J,te=Y;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],te=K.pop();if(te!==G){K[0]=te;e:for(var Y=0,J=K.length,U=J>>>1;Y<U;){var H=2*(Y+1)-1,ee=K[H],ie=H+1,pe=K[ie];if(0>i(ee,te))ie<J&&0>i(pe,ee)?(K[Y]=pe,K[ie]=te,Y=ie):(K[Y]=ee,K[H]=te,Y=H);else if(ie<J&&0>i(pe,te))K[Y]=pe,K[ie]=te,Y=ie;else break e}}return G}function i(K,G){var te=K.sortIndex-G.sortIndex;return te!==0?te:K.id-G.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var c=[],u=[],d=1,f=null,g=3,p=!1,x=!1,v=!1,y=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=K)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function T(K){if(v=!1,A(K),!x)if(n(c)!==null)x=!0,C||(C=!0,O());else{var G=n(u);G!==null&&W(T,G.startTime-K)}}var C=!1,k=-1,F=5,N=-1;function j(){return y?!0:!(t.unstable_now()-N<F)}function I(){if(y=!1,C){var K=t.unstable_now();N=K;var G=!0;try{e:{x=!1,v&&(v=!1,E(k),k=-1),p=!0;var te=g;try{t:{for(A(K),f=n(c);f!==null&&!(f.expirationTime>K&&j());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,g=f.priorityLevel;var J=Y(f.expirationTime<=K);if(K=t.unstable_now(),typeof J=="function"){f.callback=J,A(K),G=!0;break t}f===n(c)&&r(c),A(K)}else r(c);f=n(c)}if(f!==null)G=!0;else{var U=n(u);U!==null&&W(T,U.startTime-K),G=!1}}break e}finally{f=null,g=te,p=!1}G=void 0}}finally{G?O():C=!1}}}var O;if(typeof w=="function")O=function(){w(I)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=I,O=function(){R.postMessage(null)}}else O=function(){b(I,0)};function W(K,G){k=b(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"):F=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 te=g;g=G;try{return K()}finally{g=te}},t.unstable_requestPaint=function(){y=!0},t.unstable_runWithPriority=function(K,G){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var te=g;g=K;try{return G()}finally{g=te}},t.unstable_scheduleCallback=function(K,G,te){var Y=t.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?Y+te:Y):te=Y,K){case 1:var J=-1;break;case 2:J=250;break;case 5:J=1073741823;break;case 4:J=1e4;break;default:J=5e3}return J=te+J,K={id:d++,callback:G,priorityLevel:K,startTime:te,expirationTime:J,sortIndex:-1},te>Y?(K.sortIndex=te,e(u,K),n(c)===null&&K===n(u)&&(v?(E(k),k=-1):v=!0,W(T,te-Y))):(K.sortIndex=J,e(c,K),x||p||(x=!0,C||(C=!0,O()))),K},t.unstable_shouldYield=j,t.unstable_wrapCallback=function(K){var G=g;return function(){var te=g;g=G;try{return K.apply(this,arguments)}finally{g=te}}}})(CA)),CA}var fF;function Lre(){return fF||(fF=1,TA.exports=Ore()),TA.exports}var NA={exports:{}},ia={};var mF;function Ire(){if(mF)return ia;mF=1;var t=qp();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ia.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ia.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},ia.flushSync=function(c){var u=s.T,d=r.p;try{if(s.T=null,r.p=2,c)return c()}finally{s.T=u,r.p=d,r.d.f()}},ia.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},ia.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ia.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ia.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=o(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},ia.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},ia.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=o(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},ia.requestFormReset=function(c){r.d.r(c)},ia.unstable_batchedUpdates=function(c,u){return c(u)},ia.useFormState=function(c,u,d){return s.H.useFormState(c,u,d)},ia.useFormStatus=function(){return s.H.useHostTransitionStatus()},ia.version="19.2.0",ia}var pF;function C9(){if(pF)return NA.exports;pF=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(),NA.exports=Ire(),NA.exports}var gF;function Fre(){if(gF)return ox;gF=1;var t=Lre(),e=qp(),n=C9();function r(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)m+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var m=h,_=h;if(h.alternate)for(;m.return;)m=m.return;else{h=m;do m=h,(m.flags&4098)!==0&&(_=m.return),h=m.return;while(h)}return m.tag===3?_:null}function s(h){if(h.tag===13){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function o(h){if(h.tag===31){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var m=h.alternate;if(!m){if(m=a(h),m===null)throw Error(r(188));return m!==h?null:h}for(var _=h,S=m;;){var P=_.return;if(P===null)break;var D=P.alternate;if(D===null){if(S=P.return,S!==null){_=S;continue}break}if(P.child===D.child){for(D=P.child;D;){if(D===_)return c(P),h;if(D===S)return c(P),m;D=D.sibling}throw Error(r(188))}if(_.return!==S.return)_=P,S=D;else{for(var X=!1,le=P.child;le;){if(le===_){X=!0,_=P,S=D;break}if(le===S){X=!0,S=P,_=D;break}le=le.sibling}if(!X){for(le=D.child;le;){if(le===_){X=!0,_=D,S=P;break}if(le===S){X=!0,S=D,_=P;break}le=le.sibling}if(!X)throw Error(r(189))}}if(_.alternate!==S)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:m}function d(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h;for(h=h.child;h!==null;){if(m=d(h),m!==null)return m;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),w=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),j=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=I&&h[I]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function R(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case v:return"Fragment";case b:return"Profiler";case y:return"StrictMode";case T:return"Suspense";case C:return"SuspenseList";case N:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case w:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case A:var m=h.render;return h=h.displayName,h||(h=m.displayName||m.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case k:return m=h.displayName||null,m!==null?m:R(h.type)||"Memo";case F:m=h._payload,h=h._init;try{return R(h(m))}catch{}}return null}var W=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},Y=[],J=-1;function U(h){return{current:h}}function H(h){0>J||(h.current=Y[J],Y[J]=null,J--)}function ee(h,m){J++,Y[J]=h.current,h.current=m}var ie=U(null),pe=U(null),ue=U(null),be=U(null);function Re(h,m){switch(ee(ue,m),ee(pe,h),ee(ie,null),m.nodeType){case 9:case 11:h=(h=m.documentElement)&&(h=h.namespaceURI)?P5(h):0;break;default:if(h=m.tagName,m=m.namespaceURI)m=P5(m),h=R5(m,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}H(ie),ee(ie,h)}function Z(){H(ie),H(pe),H(ue)}function _e(h){h.memoizedState!==null&&ee(be,h);var m=ie.current,_=R5(m,h.type);m!==_&&(ee(pe,h),ee(ie,_))}function Le(h){pe.current===h&&(H(ie),H(pe)),be.current===h&&(H(be),nx._currentValue=te)}var ce,Ie;function z(h){if(ce===void 0)try{throw Error()}catch(_){var m=_.stack.trim().match(/\n( *(at )?)/);ce=m&&m[1]||"",Ie=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+ce+h+Ie}var B=!1;function ne(h,m){if(!h||B)return"";B=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(m){var ht=function(){throw Error()};if(Object.defineProperty(ht.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ht,[])}catch(st){var Je=st}Reflect.construct(h,[],ht)}else{try{ht.call()}catch(st){Je=st}h.call(ht.prototype)}}else{try{throw Error()}catch(st){Je=st}(ht=h())&&typeof ht.catch=="function"&&ht.catch(function(){})}}catch(st){if(st&&Je&&typeof st.stack=="string")return[st.stack,Je.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var D=S.DetermineComponentFrameRoot(),X=D[0],le=D[1];if(X&&le){var Te=X.split(`
  4. `),Ze=le.split(`
  5. `);for(P=S=0;S<Te.length&&!Te[S].includes("DetermineComponentFrameRoot");)S++;for(;P<Ze.length&&!Ze[P].includes("DetermineComponentFrameRoot");)P++;if(S===Te.length||P===Ze.length)for(S=Te.length-1,P=Ze.length-1;1<=S&&0<=P&&Te[S]!==Ze[P];)P--;for(;1<=S&&0<=P;S--,P--)if(Te[S]!==Ze[P]){if(S!==1||P!==1)do if(S--,P--,0>P||Te[S]!==Ze[P]){var ct=`
  6. `+Te[S].replace(" at new "," at ");return h.displayName&&ct.includes("<anonymous>")&&(ct=ct.replace("<anonymous>",h.displayName)),ct}while(1<=S&&0<=P);break}}}finally{B=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?z(_):""}function V(h,m){switch(h.tag){case 26:case 27:case 5:return z(h.type);case 16:return z("Lazy");case 13:return h.child!==m&&m!==null?z("Suspense Fallback"):z("Suspense");case 19:return z("SuspenseList");case 0:case 15:return ne(h.type,!1);case 11:return ne(h.type.render,!1);case 1:return ne(h.type,!0);case 31:return z("Activity");default:return""}}function Q(h){try{var m="",_=null;do m+=V(h,_),_=h,h=h.return;while(h);return m}catch(S){return`
  7. Error generating stack: `+S.message+`
  8. `+S.stack}}var se=Object.prototype.hasOwnProperty,Me=t.unstable_scheduleCallback,Ae=t.unstable_cancelCallback,Se=t.unstable_shouldYield,$=t.unstable_requestPaint,L=t.unstable_now,re=t.unstable_getCurrentPriorityLevel,ye=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,xe=t.unstable_NormalPriority,rt=t.unstable_LowPriority,He=t.unstable_IdlePriority,he=t.log,Ge=t.unstable_setDisableYieldValue,Ue=null,oe=null;function tt(h){if(typeof he=="function"&&Ge(h),oe&&typeof oe.setStrictMode=="function")try{oe.setStrictMode(Ue,h)}catch{}}var $e=Math.clz32?Math.clz32:fe,Ye=Math.log,ut=Math.LN2;function fe(h){return h>>>=0,h===0?32:31-(Ye(h)/ut|0)|0}var Qe=256,ge=262144,ze=4194304;function ke(h){var m=h&42;if(m!==0)return m;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function ve(h,m,_){var S=h.pendingLanes;if(S===0)return 0;var P=0,D=h.suspendedLanes,X=h.pingedLanes;h=h.warmLanes;var le=S&134217727;return le!==0?(S=le&~D,S!==0?P=ke(S):(X&=le,X!==0?P=ke(X):_||(_=le&~h,_!==0&&(P=ke(_))))):(le=S&~D,le!==0?P=ke(le):X!==0?P=ke(X):_||(_=S&~h,_!==0&&(P=ke(_)))),P===0?0:m!==0&&m!==P&&(m&D)===0&&(D=P&-P,_=m&-m,D>=_||D===32&&(_&4194048)!==0)?m:P}function de(h,m){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&m)===0}function ot(h,m){switch(h){case 1:case 2:case 4:case 8:case 64:return m+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return m+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function xt(){var h=ze;return ze<<=1,(ze&62914560)===0&&(ze=4194304),h}function Et(h){for(var m=[],_=0;31>_;_++)m.push(h);return m}function Qt(h,m){h.pendingLanes|=m,m!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ot(h,m,_,S,P,D){var X=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var le=h.entanglements,Te=h.expirationTimes,Ze=h.hiddenUpdates;for(_=X&~_;0<_;){var ct=31-$e(_),ht=1<<ct;le[ct]=0,Te[ct]=-1;var Je=Ze[ct];if(Je!==null)for(Ze[ct]=null,ct=0;ct<Je.length;ct++){var st=Je[ct];st!==null&&(st.lane&=-536870913)}_&=~ht}S!==0&&Vt(h,S,0),D!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=D&~(X&~m))}function Vt(h,m,_){h.pendingLanes|=m,h.suspendedLanes&=~m;var S=31-$e(m);h.entangledLanes|=m,h.entanglements[S]=h.entanglements[S]|1073741824|_&261930}function On(h,m){var _=h.entangledLanes|=m;for(h=h.entanglements;_;){var S=31-$e(_),P=1<<S;P&m|h[S]&m&&(h[S]|=m),_&=~P}}function Mi(h,m){var _=m&-m;return _=(_&42)!==0?1:si(_),(_&(h.suspendedLanes|m))!==0?0:_}function si(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Ei(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function zi(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:tF(h.type))}function ra(h,m){var _=G.p;try{return G.p=h,m()}finally{G.p=_}}var Wr=Math.random().toString(36).slice(2),yr="__reactFiber$"+Wr,Lr="__reactProps$"+Wr,go="__reactContainer$"+Wr,Xc="__reactEvents$"+Wr,me="__reactListeners$"+Wr,Ve="__reactHandles$"+Wr,it="__reactResources$"+Wr,at="__reactMarker$"+Wr;function nt(h){delete h[yr],delete h[Lr],delete h[Xc],delete h[me],delete h[Ve]}function At(h){var m=h[yr];if(m)return m;for(var _=h.parentNode;_;){if(m=_[go]||_[yr]){if(_=m.alternate,m.child!==null||_!==null&&_.child!==null)for(h=U5(h);h!==null;){if(_=h[yr])return _;h=U5(h)}return m}h=_,_=h.parentNode}return null}function ae(h){if(h=h[yr]||h[go]){var m=h.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return h}return null}function Ee(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h.stateNode;throw Error(r(33))}function Fe(h){var m=h[it];return m||(m=h[it]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function Oe(h){h[at]=!0}var Ne=new Set,lt={};function ft(h,m){wt(h,m),wt(h+"Capture",m)}function wt(h,m){for(lt[h]=m,h=0;h<m.length;h++)Ne.add(m[h])}var bt=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]*$"),Lt={},Ct={};function pt(h){return se.call(Ct,h)?!0:se.call(Lt,h)?!1:bt.test(h)?Ct[h]=!0:(Lt[h]=!0,!1)}function Xt(h,m,_){if(pt(m))if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(m);return;case"boolean":var S=m.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){h.removeAttribute(m);return}}h.setAttribute(m,""+_)}}function Ut(h,m,_){if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(m);return}h.setAttribute(m,""+_)}}function an(h,m,_,S){if(S===null)h.removeAttribute(_);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(m,_,""+S)}}function hn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function bn(h){var m=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function Ft(h,m,_){var S=Object.getOwnPropertyDescriptor(h.constructor.prototype,m);if(!h.hasOwnProperty(m)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var P=S.get,D=S.set;return Object.defineProperty(h,m,{configurable:!0,get:function(){return P.call(this)},set:function(X){_=""+X,D.call(this,X)}}),Object.defineProperty(h,m,{enumerable:S.enumerable}),{getValue:function(){return _},setValue:function(X){_=""+X},stopTracking:function(){h._valueTracker=null,delete h[m]}}}}function Jt(h){if(!h._valueTracker){var m=bn(h)?"checked":"value";h._valueTracker=Ft(h,m,""+h[m])}}function tn(h){if(!h)return!1;var m=h._valueTracker;if(!m)return!0;var _=m.getValue(),S="";return h&&(S=bn(h)?h.checked?"true":"false":h.value),h=S,h!==_?(m.setValue(h),!0):!1}function Cr(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var Ir=/[\n"\\]/g;function jn(h){return h.replace(Ir,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function xo(h,m,_,S,P,D,X,le){h.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?h.type=X:h.removeAttribute("type"),m!=null?X==="number"?(m===0&&h.value===""||h.value!=m)&&(h.value=""+hn(m)):h.value!==""+hn(m)&&(h.value=""+hn(m)):X!=="submit"&&X!=="reset"||h.removeAttribute("value"),m!=null?Ai(h,X,hn(m)):_!=null?Ai(h,X,hn(_)):S!=null&&h.removeAttribute("value"),P==null&&D!=null&&(h.defaultChecked=!!D),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),le!=null&&typeof le!="function"&&typeof le!="symbol"&&typeof le!="boolean"?h.name=""+hn(le):h.removeAttribute("name")}function Ln(h,m,_,S,P,D,X,le){if(D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"&&(h.type=D),m!=null||_!=null){if(!(D!=="submit"&&D!=="reset"||m!=null)){Jt(h);return}_=_!=null?""+hn(_):"",m=m!=null?""+hn(m):_,le||m===h.value||(h.value=m),h.defaultValue=m}S=S??P,S=typeof S!="function"&&typeof S!="symbol"&&!!S,h.checked=le?h.checked:!!S,h.defaultChecked=!!S,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(h.name=X),Jt(h)}function Ai(h,m,_){m==="number"&&Cr(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function oi(h,m,_,S){if(h=h.options,m){m={};for(var P=0;P<_.length;P++)m["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=m.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&S&&(h[_].defaultSelected=!0)}else{for(_=""+hn(_),m=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,S&&(h[P].defaultSelected=!0);return}m!==null||h[P].disabled||(m=h[P])}m!==null&&(m.selected=!0)}}function Ti(h,m,_){if(m!=null&&(m=""+hn(m),m!==h.value&&(h.value=m),_==null)){h.defaultValue!==m&&(h.defaultValue=m);return}h.defaultValue=_!=null?""+hn(_):""}function Bi(h,m,_,S){if(m==null){if(S!=null){if(_!=null)throw Error(r(92));if(W(S)){if(1<S.length)throw Error(r(93));S=S[0]}_=S}_==null&&(_=""),m=_}_=hn(m),h.defaultValue=_,S=h.textContent,S===_&&S!==""&&S!==null&&(h.value=S),Jt(h)}function Vo(h,m){if(m){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=m;return}}h.textContent=m}var Tl=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function CL(h,m,_){var S=m.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?S?h.setProperty(m,""):m==="float"?h.cssFloat="":h[m]="":S?h.setProperty(m,_):typeof _!="number"||_===0||Tl.has(m)?m==="float"?h.cssFloat=_:h[m]=(""+_).trim():h[m]=_+"px"}function NL(h,m,_){if(m!=null&&typeof m!="object")throw Error(r(62));if(h=h.style,_!=null){for(var S in _)!_.hasOwnProperty(S)||m!=null&&m.hasOwnProperty(S)||(S.indexOf("--")===0?h.setProperty(S,""):S==="float"?h.cssFloat="":h[S]="");for(var P in m)S=m[P],m.hasOwnProperty(P)&&_[P]!==S&&CL(h,P,S)}else for(var D in m)m.hasOwnProperty(D)&&CL(h,D,m[D])}function vE(h){if(h.indexOf("-")===-1)return!1;switch(h){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ate=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"]]),Tte=/^[\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 ay(h){return Tte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Cl(){}var _E=null;function wE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var vf=null,_f=null;function kL(h){var m=ae(h);if(m&&(h=m.stateNode)){var _=h[Lr]||null;e:switch(h=m.stateNode,m.type){case"input":if(xo(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),m=_.name,_.type==="radio"&&m!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+jn(""+m)+'"][type="radio"]'),m=0;m<_.length;m++){var S=_[m];if(S!==h&&S.form===h.form){var P=S[Lr]||null;if(!P)throw Error(r(90));xo(S,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(m=0;m<_.length;m++)S=_[m],S.form===h.form&&tn(S)}break e;case"textarea":Ti(h,_.value,_.defaultValue);break e;case"select":m=_.value,m!=null&&oi(h,!!_.multiple,m,!1)}}}var SE=!1;function PL(h,m,_){if(SE)return h(m,_);SE=!0;try{var S=h(m);return S}finally{if(SE=!1,(vf!==null||_f!==null)&&(Wy(),vf&&(m=vf,h=_f,_f=vf=null,kL(m),h)))for(m=0;m<h.length;m++)kL(h[m])}}function yg(h,m){var _=h.stateNode;if(_===null)return null;var S=_[Lr]||null;if(S===null)return null;_=S[m];e:switch(m){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(h=h.type,S=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!S;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,m,typeof _));return _}var Nl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ME=!1;if(Nl)try{var vg={};Object.defineProperty(vg,"passive",{get:function(){ME=!0}}),window.addEventListener("test",vg,vg),window.removeEventListener("test",vg,vg)}catch{ME=!1}var Yc=null,EE=null,sy=null;function RL(){if(sy)return sy;var h,m=EE,_=m.length,S,P="value"in Yc?Yc.value:Yc.textContent,D=P.length;for(h=0;h<_&&m[h]===P[h];h++);var X=_-h;for(S=1;S<=X&&m[_-S]===P[D-S];S++);return sy=P.slice(h,1<S?1-S:void 0)}function oy(h){var m=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&m===13&&(h=13)):h=m,h===10&&(h=13),32<=h||h===13?h:0}function ly(){return!0}function jL(){return!1}function La(h){function m(_,S,P,D,X){this._reactName=_,this._targetInst=P,this.type=S,this.nativeEvent=D,this.target=X,this.currentTarget=null;for(var le in h)h.hasOwnProperty(le)&&(_=h[le],this[le]=_?_(D):D[le]);return this.isDefaultPrevented=(D.defaultPrevented!=null?D.defaultPrevented:D.returnValue===!1)?ly:jL,this.isPropagationStopped=jL,this}return f(m.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=ly)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=ly)},persist:function(){},isPersistent:ly}),m}var jd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cy=La(jd),_g=f({},jd,{view:0,detail:0}),Cte=La(_g),AE,TE,wg,uy=f({},_g,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:NE,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==wg&&(wg&&h.type==="mousemove"?(AE=h.screenX-wg.screenX,TE=h.screenY-wg.screenY):TE=AE=0,wg=h),AE)},movementY:function(h){return"movementY"in h?h.movementY:TE}}),DL=La(uy),Nte=f({},uy,{dataTransfer:0}),kte=La(Nte),Pte=f({},_g,{relatedTarget:0}),CE=La(Pte),Rte=f({},jd,{animationName:0,elapsedTime:0,pseudoElement:0}),jte=La(Rte),Dte=f({},jd,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Ote=La(Dte),Lte=f({},jd,{data:0}),OL=La(Lte),Ite={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fte={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"},Ute={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zte(h){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(h):(h=Ute[h])?!!m[h]:!1}function NE(){return zte}var Bte=f({},_g,{key:function(h){if(h.key){var m=Ite[h.key]||h.key;if(m!=="Unidentified")return m}return h.type==="keypress"?(h=oy(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Fte[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:NE,charCode:function(h){return h.type==="keypress"?oy(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?oy(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Hte=La(Bte),$te=f({},uy,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),LL=La($te),Vte=f({},_g,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:NE}),Gte=La(Vte),Wte=f({},jd,{propertyName:0,elapsedTime:0,pseudoElement:0}),qte=La(Wte),Kte=f({},uy,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),Xte=La(Kte),Yte=f({},jd,{newState:0,oldState:0}),Zte=La(Yte),Qte=[9,13,27,32],kE=Nl&&"CompositionEvent"in window,Sg=null;Nl&&"documentMode"in document&&(Sg=document.documentMode);var Jte=Nl&&"TextEvent"in window&&!Sg,IL=Nl&&(!kE||Sg&&8<Sg&&11>=Sg),FL=" ",UL=!1;function zL(h,m){switch(h){case"keyup":return Qte.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function BL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var wf=!1;function ene(h,m){switch(h){case"compositionend":return BL(m);case"keypress":return m.which!==32?null:(UL=!0,FL);case"textInput":return h=m.data,h===FL&&UL?null:h;default:return null}}function tne(h,m){if(wf)return h==="compositionend"||!kE&&zL(h,m)?(h=RL(),sy=EE=Yc=null,wf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1<m.char.length)return m.char;if(m.which)return String.fromCharCode(m.which)}return null;case"compositionend":return IL&&m.locale!=="ko"?null:m.data;default:return null}}var nne={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 HL(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m==="input"?!!nne[h.type]:m==="textarea"}function $L(h,m,_,S){vf?_f?_f.push(S):_f=[S]:vf=S,m=Jy(m,"onChange"),0<m.length&&(_=new cy("onChange","change",null,_,S),h.push({event:_,listeners:m}))}var Mg=null,Eg=null;function rne(h){E5(h,0)}function dy(h){var m=Ee(h);if(tn(m))return h}function VL(h,m){if(h==="change")return m}var GL=!1;if(Nl){var PE;if(Nl){var RE="oninput"in document;if(!RE){var WL=document.createElement("div");WL.setAttribute("oninput","return;"),RE=typeof WL.oninput=="function"}PE=RE}else PE=!1;GL=PE&&(!document.documentMode||9<document.documentMode)}function qL(){Mg&&(Mg.detachEvent("onpropertychange",KL),Eg=Mg=null)}function KL(h){if(h.propertyName==="value"&&dy(Eg)){var m=[];$L(m,Eg,h,wE(h)),PL(rne,m)}}function ine(h,m,_){h==="focusin"?(qL(),Mg=m,Eg=_,Mg.attachEvent("onpropertychange",KL)):h==="focusout"&&qL()}function ane(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return dy(Eg)}function sne(h,m){if(h==="click")return dy(m)}function one(h,m){if(h==="input"||h==="change")return dy(m)}function lne(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var ss=typeof Object.is=="function"?Object.is:lne;function Ag(h,m){if(ss(h,m))return!0;if(typeof h!="object"||h===null||typeof m!="object"||m===null)return!1;var _=Object.keys(h),S=Object.keys(m);if(_.length!==S.length)return!1;for(S=0;S<_.length;S++){var P=_[S];if(!se.call(m,P)||!ss(h[P],m[P]))return!1}return!0}function XL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function YL(h,m){var _=XL(h);h=0;for(var S;_;){if(_.nodeType===3){if(S=h+_.textContent.length,h<=m&&S>=m)return{node:_,offset:m-h};h=S}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=XL(_)}}function ZL(h,m){return h&&m?h===m?!0:h&&h.nodeType===3?!1:m&&m.nodeType===3?ZL(h,m.parentNode):"contains"in h?h.contains(m):h.compareDocumentPosition?!!(h.compareDocumentPosition(m)&16):!1:!1}function QL(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var m=Cr(h.document);m instanceof h.HTMLIFrameElement;){try{var _=typeof m.contentWindow.location.href=="string"}catch{_=!1}if(_)h=m.contentWindow;else break;m=Cr(h.document)}return m}function jE(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m&&(m==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||m==="textarea"||h.contentEditable==="true")}var cne=Nl&&"documentMode"in document&&11>=document.documentMode,Sf=null,DE=null,Tg=null,OE=!1;function JL(h,m,_){var S=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;OE||Sf==null||Sf!==Cr(S)||(S=Sf,"selectionStart"in S&&jE(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}),Tg&&Ag(Tg,S)||(Tg=S,S=Jy(DE,"onSelect"),0<S.length&&(m=new cy("onSelect","select",null,m,_),h.push({event:m,listeners:S}),m.target=Sf)))}function Dd(h,m){var _={};return _[h.toLowerCase()]=m.toLowerCase(),_["Webkit"+h]="webkit"+m,_["Moz"+h]="moz"+m,_}var Mf={animationend:Dd("Animation","AnimationEnd"),animationiteration:Dd("Animation","AnimationIteration"),animationstart:Dd("Animation","AnimationStart"),transitionrun:Dd("Transition","TransitionRun"),transitionstart:Dd("Transition","TransitionStart"),transitioncancel:Dd("Transition","TransitionCancel"),transitionend:Dd("Transition","TransitionEnd")},LE={},e4={};Nl&&(e4=document.createElement("div").style,"AnimationEvent"in window||(delete Mf.animationend.animation,delete Mf.animationiteration.animation,delete Mf.animationstart.animation),"TransitionEvent"in window||delete Mf.transitionend.transition);function Od(h){if(LE[h])return LE[h];if(!Mf[h])return h;var m=Mf[h],_;for(_ in m)if(m.hasOwnProperty(_)&&_ in e4)return LE[h]=m[_];return h}var t4=Od("animationend"),n4=Od("animationiteration"),r4=Od("animationstart"),une=Od("transitionrun"),dne=Od("transitionstart"),hne=Od("transitioncancel"),i4=Od("transitionend"),a4=new Map,IE="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(" ");IE.push("scrollEnd");function bo(h,m){a4.set(h,m),ft(m,[h])}var hy=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var m=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(m))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Ps=[],Ef=0,FE=0;function fy(){for(var h=Ef,m=FE=Ef=0;m<h;){var _=Ps[m];Ps[m++]=null;var S=Ps[m];Ps[m++]=null;var P=Ps[m];Ps[m++]=null;var D=Ps[m];if(Ps[m++]=null,S!==null&&P!==null){var X=S.pending;X===null?P.next=P:(P.next=X.next,X.next=P),S.pending=P}D!==0&&s4(_,P,D)}}function my(h,m,_,S){Ps[Ef++]=h,Ps[Ef++]=m,Ps[Ef++]=_,Ps[Ef++]=S,FE|=S,h.lanes|=S,h=h.alternate,h!==null&&(h.lanes|=S)}function UE(h,m,_,S){return my(h,m,_,S),py(h)}function Ld(h,m){return my(h,null,null,m),py(h)}function s4(h,m,_){h.lanes|=_;var S=h.alternate;S!==null&&(S.lanes|=_);for(var P=!1,D=h.return;D!==null;)D.childLanes|=_,S=D.alternate,S!==null&&(S.childLanes|=_),D.tag===22&&(h=D.stateNode,h===null||h._visibility&1||(P=!0)),h=D,D=D.return;return h.tag===3?(D=h.stateNode,P&&m!==null&&(P=31-$e(_),h=D.hiddenUpdates,S=h[P],S===null?h[P]=[m]:S.push(m),m.lane=_|536870912),D):null}function py(h){if(50<Xg)throw Xg=0,K2=null,Error(r(185));for(var m=h.return;m!==null;)h=m,m=h.return;return h.tag===3?h.stateNode:null}var Af={};function fne(h,m,_,S){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ls(h,m,_,S){return new fne(h,m,_,S)}function zE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function kl(h,m){var _=h.alternate;return _===null?(_=ls(h.tag,m,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=m,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,m=h.dependencies,_.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function o4(h,m){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=m,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,m=_.dependencies,h.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext}),h}function gy(h,m,_,S,P,D){var X=0;if(S=h,typeof h=="function")zE(h)&&(X=1);else if(typeof h=="string")X=bre(h,_,ie.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case N:return h=ls(31,_,m,P),h.elementType=N,h.lanes=D,h;case v:return Id(_.children,P,D,m);case y:X=8,P|=24;break;case b:return h=ls(12,_,m,P|2),h.elementType=b,h.lanes=D,h;case T:return h=ls(13,_,m,P),h.elementType=T,h.lanes=D,h;case C:return h=ls(19,_,m,P),h.elementType=C,h.lanes=D,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case w:X=10;break e;case E:X=9;break e;case A:X=11;break e;case k:X=14;break e;case F:X=16,S=null;break e}X=29,_=Error(r(130,h===null?"null":typeof h,"")),S=null}return m=ls(X,_,m,P),m.elementType=h,m.type=S,m.lanes=D,m}function Id(h,m,_,S){return h=ls(7,h,S,m),h.lanes=_,h}function BE(h,m,_){return h=ls(6,h,null,m),h.lanes=_,h}function l4(h){var m=ls(18,null,null,0);return m.stateNode=h,m}function HE(h,m,_){return m=ls(4,h.children!==null?h.children:[],h.key,m),m.lanes=_,m.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},m}var c4=new WeakMap;function Rs(h,m){if(typeof h=="object"&&h!==null){var _=c4.get(h);return _!==void 0?_:(m={value:h,source:m,stack:Q(m)},c4.set(h,m),m)}return{value:h,source:m,stack:Q(m)}}var Tf=[],Cf=0,xy=null,Cg=0,js=[],Ds=0,Zc=null,Go=1,Wo="";function Pl(h,m){Tf[Cf++]=Cg,Tf[Cf++]=xy,xy=h,Cg=m}function u4(h,m,_){js[Ds++]=Go,js[Ds++]=Wo,js[Ds++]=Zc,Zc=h;var S=Go;h=Wo;var P=32-$e(S)-1;S&=~(1<<P),_+=1;var D=32-$e(m)+P;if(30<D){var X=P-P%5;D=(S&(1<<X)-1).toString(32),S>>=X,P-=X,Go=1<<32-$e(m)+P|_<<P|S,Wo=D+h}else Go=1<<D|_<<P|S,Wo=h}function $E(h){h.return!==null&&(Pl(h,1),u4(h,1,0))}function VE(h){for(;h===xy;)xy=Tf[--Cf],Tf[Cf]=null,Cg=Tf[--Cf],Tf[Cf]=null;for(;h===Zc;)Zc=js[--Ds],js[Ds]=null,Wo=js[--Ds],js[Ds]=null,Go=js[--Ds],js[Ds]=null}function d4(h,m){js[Ds++]=Go,js[Ds++]=Wo,js[Ds++]=Zc,Go=m.id,Wo=m.overflow,Zc=h}var Hi=null,lr=null,wn=!1,Qc=null,Os=!1,GE=Error(r(519));function Jc(h){var m=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ng(Rs(m,h)),GE}function h4(h){var m=h.stateNode,_=h.type,S=h.memoizedProps;switch(m[yr]=h,m[Lr]=S,_){case"dialog":pn("cancel",m),pn("close",m);break;case"iframe":case"object":case"embed":pn("load",m);break;case"video":case"audio":for(_=0;_<Zg.length;_++)pn(Zg[_],m);break;case"source":pn("error",m);break;case"img":case"image":case"link":pn("error",m),pn("load",m);break;case"details":pn("toggle",m);break;case"input":pn("invalid",m),Ln(m,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":pn("invalid",m);break;case"textarea":pn("invalid",m),Bi(m,S.value,S.defaultValue,S.children)}_=S.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||m.textContent===""+_||S.suppressHydrationWarning===!0||N5(m.textContent,_)?(S.popover!=null&&(pn("beforetoggle",m),pn("toggle",m)),S.onScroll!=null&&pn("scroll",m),S.onScrollEnd!=null&&pn("scrollend",m),S.onClick!=null&&(m.onclick=Cl),m=!0):m=!1,m||Jc(h,!0)}function f4(h){for(Hi=h.return;Hi;)switch(Hi.tag){case 5:case 31:case 13:Os=!1;return;case 27:case 3:Os=!0;return;default:Hi=Hi.return}}function Nf(h){if(h!==Hi)return!1;if(!wn)return f4(h),wn=!0,!1;var m=h.tag,_;if((_=m!==3&&m!==27)&&((_=m===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||cA(h.type,h.memoizedProps)),_=!_),_&&lr&&Jc(h),f4(h),m===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));lr=F5(h)}else if(m===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));lr=F5(h)}else m===27?(m=lr,fu(h.type)?(h=mA,mA=null,lr=h):lr=m):lr=Hi?Is(h.stateNode.nextSibling):null;return!0}function Fd(){lr=Hi=null,wn=!1}function WE(){var h=Qc;return h!==null&&(za===null?za=h:za.push.apply(za,h),Qc=null),h}function Ng(h){Qc===null?Qc=[h]:Qc.push(h)}var qE=U(null),Ud=null,Rl=null;function eu(h,m,_){ee(qE,m._currentValue),m._currentValue=_}function jl(h){h._currentValue=qE.current,H(qE)}function KE(h,m,_){for(;h!==null;){var S=h.alternate;if((h.childLanes&m)!==m?(h.childLanes|=m,S!==null&&(S.childLanes|=m)):S!==null&&(S.childLanes&m)!==m&&(S.childLanes|=m),h===_)break;h=h.return}}function XE(h,m,_,S){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var D=P.dependencies;if(D!==null){var X=P.child;D=D.firstContext;e:for(;D!==null;){var le=D;D=P;for(var Te=0;Te<m.length;Te++)if(le.context===m[Te]){D.lanes|=_,le=D.alternate,le!==null&&(le.lanes|=_),KE(D.return,_,h),S||(X=null);break e}D=le.next}}else if(P.tag===18){if(X=P.return,X===null)throw Error(r(341));X.lanes|=_,D=X.alternate,D!==null&&(D.lanes|=_),KE(X,_,h),X=null}else X=P.child;if(X!==null)X.return=P;else for(X=P;X!==null;){if(X===h){X=null;break}if(P=X.sibling,P!==null){P.return=X.return,X=P;break}X=X.return}P=X}}function kf(h,m,_,S){h=null;for(var P=m,D=!1;P!==null;){if(!D){if((P.flags&524288)!==0)D=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var X=P.alternate;if(X===null)throw Error(r(387));if(X=X.memoizedProps,X!==null){var le=P.type;ss(P.pendingProps.value,X.value)||(h!==null?h.push(le):h=[le])}}else if(P===be.current){if(X=P.alternate,X===null)throw Error(r(387));X.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(nx):h=[nx])}P=P.return}h!==null&&XE(m,h,_,S),m.flags|=262144}function by(h){for(h=h.firstContext;h!==null;){if(!ss(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function zd(h){Ud=h,Rl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function $i(h){return m4(Ud,h)}function yy(h,m){return Ud===null&&zd(h),m4(h,m)}function m4(h,m){var _=m._currentValue;if(m={context:m,memoizedValue:_,next:null},Rl===null){if(h===null)throw Error(r(308));Rl=m,h.dependencies={lanes:0,firstContext:m},h.flags|=524288}else Rl=Rl.next=m;return _}var mne=typeof AbortController<"u"?AbortController:function(){var h=[],m=this.signal={aborted:!1,addEventListener:function(_,S){h.push(S)}};this.abort=function(){m.aborted=!0,h.forEach(function(_){return _()})}},pne=t.unstable_scheduleCallback,gne=t.unstable_NormalPriority,qr={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function YE(){return{controller:new mne,data:new Map,refCount:0}}function kg(h){h.refCount--,h.refCount===0&&pne(gne,function(){h.controller.abort()})}var Pg=null,ZE=0,Pf=0,Rf=null;function xne(h,m){if(Pg===null){var _=Pg=[];ZE=0,Pf=eA(),Rf={status:"pending",value:void 0,then:function(S){_.push(S)}}}return ZE++,m.then(p4,p4),m}function p4(){if(--ZE===0&&Pg!==null){Rf!==null&&(Rf.status="fulfilled");var h=Pg;Pg=null,Pf=0,Rf=null;for(var m=0;m<h.length;m++)(0,h[m])()}}function bne(h,m){var _=[],S={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){S.status="fulfilled",S.value=m;for(var P=0;P<_.length;P++)(0,_[P])(m)},function(P){for(S.status="rejected",S.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),S}var g4=K.S;K.S=function(h,m){JI=L(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&xne(h,m),g4!==null&&g4(h,m)};var Bd=U(null);function QE(){var h=Bd.current;return h!==null?h:er.pooledCache}function vy(h,m){m===null?ee(Bd,Bd.current):ee(Bd,m.pool)}function x4(){var h=QE();return h===null?null:{parent:qr._currentValue,pool:h}}var jf=Error(r(460)),JE=Error(r(474)),_y=Error(r(542)),wy={then:function(){}};function b4(h){return h=h.status,h==="fulfilled"||h==="rejected"}function y4(h,m,_){switch(_=h[_],_===void 0?h.push(m):_!==m&&(m.then(Cl,Cl),m=_),m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,_4(h),h;default:if(typeof m.status=="string")m.then(Cl,Cl);else{if(h=er,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=m,h.status="pending",h.then(function(S){if(m.status==="pending"){var P=m;P.status="fulfilled",P.value=S}},function(S){if(m.status==="pending"){var P=m;P.status="rejected",P.reason=S}})}switch(m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,_4(h),h}throw $d=m,jf}}function Hd(h){try{var m=h._init;return m(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?($d=_,jf):_}}var $d=null;function v4(){if($d===null)throw Error(r(459));var h=$d;return $d=null,h}function _4(h){if(h===jf||h===_y)throw Error(r(483))}var Df=null,Rg=0;function Sy(h){var m=Rg;return Rg+=1,Df===null&&(Df=[]),y4(Df,h,m)}function jg(h,m){m=m.props.ref,h.ref=m!==void 0?m:null}function My(h,m){throw m.$$typeof===g?Error(r(525)):(h=Object.prototype.toString.call(m),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(m).join(", ")+"}":h)))}function w4(h){function m(Be,je){if(h){var Xe=Be.deletions;Xe===null?(Be.deletions=[je],Be.flags|=16):Xe.push(je)}}function _(Be,je){if(!h)return null;for(;je!==null;)m(Be,je),je=je.sibling;return null}function S(Be){for(var je=new Map;Be!==null;)Be.key!==null?je.set(Be.key,Be):je.set(Be.index,Be),Be=Be.sibling;return je}function P(Be,je){return Be=kl(Be,je),Be.index=0,Be.sibling=null,Be}function D(Be,je,Xe){return Be.index=Xe,h?(Xe=Be.alternate,Xe!==null?(Xe=Xe.index,Xe<je?(Be.flags|=67108866,je):Xe):(Be.flags|=67108866,je)):(Be.flags|=1048576,je)}function X(Be){return h&&Be.alternate===null&&(Be.flags|=67108866),Be}function le(Be,je,Xe,dt){return je===null||je.tag!==6?(je=BE(Xe,Be.mode,dt),je.return=Be,je):(je=P(je,Xe),je.return=Be,je)}function Te(Be,je,Xe,dt){var zt=Xe.type;return zt===v?ct(Be,je,Xe.props.children,dt,Xe.key):je!==null&&(je.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===F&&Hd(zt)===je.type)?(je=P(je,Xe.props),jg(je,Xe),je.return=Be,je):(je=gy(Xe.type,Xe.key,Xe.props,null,Be.mode,dt),jg(je,Xe),je.return=Be,je)}function Ze(Be,je,Xe,dt){return je===null||je.tag!==4||je.stateNode.containerInfo!==Xe.containerInfo||je.stateNode.implementation!==Xe.implementation?(je=HE(Xe,Be.mode,dt),je.return=Be,je):(je=P(je,Xe.children||[]),je.return=Be,je)}function ct(Be,je,Xe,dt,zt){return je===null||je.tag!==7?(je=Id(Xe,Be.mode,dt,zt),je.return=Be,je):(je=P(je,Xe),je.return=Be,je)}function ht(Be,je,Xe){if(typeof je=="string"&&je!==""||typeof je=="number"||typeof je=="bigint")return je=BE(""+je,Be.mode,Xe),je.return=Be,je;if(typeof je=="object"&&je!==null){switch(je.$$typeof){case p:return Xe=gy(je.type,je.key,je.props,null,Be.mode,Xe),jg(Xe,je),Xe.return=Be,Xe;case x:return je=HE(je,Be.mode,Xe),je.return=Be,je;case F:return je=Hd(je),ht(Be,je,Xe)}if(W(je)||O(je))return je=Id(je,Be.mode,Xe,null),je.return=Be,je;if(typeof je.then=="function")return ht(Be,Sy(je),Xe);if(je.$$typeof===w)return ht(Be,yy(Be,je),Xe);My(Be,je)}return null}function Je(Be,je,Xe,dt){var zt=je!==null?je.key:null;if(typeof Xe=="string"&&Xe!==""||typeof Xe=="number"||typeof Xe=="bigint")return zt!==null?null:le(Be,je,""+Xe,dt);if(typeof Xe=="object"&&Xe!==null){switch(Xe.$$typeof){case p:return Xe.key===zt?Te(Be,je,Xe,dt):null;case x:return Xe.key===zt?Ze(Be,je,Xe,dt):null;case F:return Xe=Hd(Xe),Je(Be,je,Xe,dt)}if(W(Xe)||O(Xe))return zt!==null?null:ct(Be,je,Xe,dt,null);if(typeof Xe.then=="function")return Je(Be,je,Sy(Xe),dt);if(Xe.$$typeof===w)return Je(Be,je,yy(Be,Xe),dt);My(Be,Xe)}return null}function st(Be,je,Xe,dt,zt){if(typeof dt=="string"&&dt!==""||typeof dt=="number"||typeof dt=="bigint")return Be=Be.get(Xe)||null,le(je,Be,""+dt,zt);if(typeof dt=="object"&&dt!==null){switch(dt.$$typeof){case p:return Be=Be.get(dt.key===null?Xe:dt.key)||null,Te(je,Be,dt,zt);case x:return Be=Be.get(dt.key===null?Xe:dt.key)||null,Ze(je,Be,dt,zt);case F:return dt=Hd(dt),st(Be,je,Xe,dt,zt)}if(W(dt)||O(dt))return Be=Be.get(Xe)||null,ct(je,Be,dt,zt,null);if(typeof dt.then=="function")return st(Be,je,Xe,Sy(dt),zt);if(dt.$$typeof===w)return st(Be,je,Xe,yy(je,dt),zt);My(je,dt)}return null}function Dt(Be,je,Xe,dt){for(var zt=null,Tn=null,It=je,rn=je=0,vn=null;It!==null&&rn<Xe.length;rn++){It.index>rn?(vn=It,It=null):vn=It.sibling;var Cn=Je(Be,It,Xe[rn],dt);if(Cn===null){It===null&&(It=vn);break}h&&It&&Cn.alternate===null&&m(Be,It),je=D(Cn,je,rn),Tn===null?zt=Cn:Tn.sibling=Cn,Tn=Cn,It=vn}if(rn===Xe.length)return _(Be,It),wn&&Pl(Be,rn),zt;if(It===null){for(;rn<Xe.length;rn++)It=ht(Be,Xe[rn],dt),It!==null&&(je=D(It,je,rn),Tn===null?zt=It:Tn.sibling=It,Tn=It);return wn&&Pl(Be,rn),zt}for(It=S(It);rn<Xe.length;rn++)vn=st(It,Be,rn,Xe[rn],dt),vn!==null&&(h&&vn.alternate!==null&&It.delete(vn.key===null?rn:vn.key),je=D(vn,je,rn),Tn===null?zt=vn:Tn.sibling=vn,Tn=vn);return h&&It.forEach(function(bu){return m(Be,bu)}),wn&&Pl(Be,rn),zt}function Gt(Be,je,Xe,dt){if(Xe==null)throw Error(r(151));for(var zt=null,Tn=null,It=je,rn=je=0,vn=null,Cn=Xe.next();It!==null&&!Cn.done;rn++,Cn=Xe.next()){It.index>rn?(vn=It,It=null):vn=It.sibling;var bu=Je(Be,It,Cn.value,dt);if(bu===null){It===null&&(It=vn);break}h&&It&&bu.alternate===null&&m(Be,It),je=D(bu,je,rn),Tn===null?zt=bu:Tn.sibling=bu,Tn=bu,It=vn}if(Cn.done)return _(Be,It),wn&&Pl(Be,rn),zt;if(It===null){for(;!Cn.done;rn++,Cn=Xe.next())Cn=ht(Be,Cn.value,dt),Cn!==null&&(je=D(Cn,je,rn),Tn===null?zt=Cn:Tn.sibling=Cn,Tn=Cn);return wn&&Pl(Be,rn),zt}for(It=S(It);!Cn.done;rn++,Cn=Xe.next())Cn=st(It,Be,rn,Cn.value,dt),Cn!==null&&(h&&Cn.alternate!==null&&It.delete(Cn.key===null?rn:Cn.key),je=D(Cn,je,rn),Tn===null?zt=Cn:Tn.sibling=Cn,Tn=Cn);return h&&It.forEach(function(Nre){return m(Be,Nre)}),wn&&Pl(Be,rn),zt}function Wn(Be,je,Xe,dt){if(typeof Xe=="object"&&Xe!==null&&Xe.type===v&&Xe.key===null&&(Xe=Xe.props.children),typeof Xe=="object"&&Xe!==null){switch(Xe.$$typeof){case p:e:{for(var zt=Xe.key;je!==null;){if(je.key===zt){if(zt=Xe.type,zt===v){if(je.tag===7){_(Be,je.sibling),dt=P(je,Xe.props.children),dt.return=Be,Be=dt;break e}}else if(je.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===F&&Hd(zt)===je.type){_(Be,je.sibling),dt=P(je,Xe.props),jg(dt,Xe),dt.return=Be,Be=dt;break e}_(Be,je);break}else m(Be,je);je=je.sibling}Xe.type===v?(dt=Id(Xe.props.children,Be.mode,dt,Xe.key),dt.return=Be,Be=dt):(dt=gy(Xe.type,Xe.key,Xe.props,null,Be.mode,dt),jg(dt,Xe),dt.return=Be,Be=dt)}return X(Be);case x:e:{for(zt=Xe.key;je!==null;){if(je.key===zt)if(je.tag===4&&je.stateNode.containerInfo===Xe.containerInfo&&je.stateNode.implementation===Xe.implementation){_(Be,je.sibling),dt=P(je,Xe.children||[]),dt.return=Be,Be=dt;break e}else{_(Be,je);break}else m(Be,je);je=je.sibling}dt=HE(Xe,Be.mode,dt),dt.return=Be,Be=dt}return X(Be);case F:return Xe=Hd(Xe),Wn(Be,je,Xe,dt)}if(W(Xe))return Dt(Be,je,Xe,dt);if(O(Xe)){if(zt=O(Xe),typeof zt!="function")throw Error(r(150));return Xe=zt.call(Xe),Gt(Be,je,Xe,dt)}if(typeof Xe.then=="function")return Wn(Be,je,Sy(Xe),dt);if(Xe.$$typeof===w)return Wn(Be,je,yy(Be,Xe),dt);My(Be,Xe)}return typeof Xe=="string"&&Xe!==""||typeof Xe=="number"||typeof Xe=="bigint"?(Xe=""+Xe,je!==null&&je.tag===6?(_(Be,je.sibling),dt=P(je,Xe),dt.return=Be,Be=dt):(_(Be,je),dt=BE(Xe,Be.mode,dt),dt.return=Be,Be=dt),X(Be)):_(Be,je)}return function(Be,je,Xe,dt){try{Rg=0;var zt=Wn(Be,je,Xe,dt);return Df=null,zt}catch(It){if(It===jf||It===_y)throw It;var Tn=ls(29,It,null,Be.mode);return Tn.lanes=dt,Tn.return=Be,Tn}finally{}}}var Vd=w4(!0),S4=w4(!1),tu=!1;function e2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function t2(h,m){h=h.updateQueue,m.updateQueue===h&&(m.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function nu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function ru(h,m,_){var S=h.updateQueue;if(S===null)return null;if(S=S.shared,(Pn&2)!==0){var P=S.pending;return P===null?m.next=m:(m.next=P.next,P.next=m),S.pending=m,m=py(h),s4(h,null,_),m}return my(h,S,m,_),py(h)}function Dg(h,m,_){if(m=m.updateQueue,m!==null&&(m=m.shared,(_&4194048)!==0)){var S=m.lanes;S&=h.pendingLanes,_|=S,m.lanes=_,On(h,_)}}function n2(h,m){var _=h.updateQueue,S=h.alternate;if(S!==null&&(S=S.updateQueue,_===S)){var P=null,D=null;if(_=_.firstBaseUpdate,_!==null){do{var X={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};D===null?P=D=X:D=D.next=X,_=_.next}while(_!==null);D===null?P=D=m:D=D.next=m}else P=D=m;_={baseState:S.baseState,firstBaseUpdate:P,lastBaseUpdate:D,shared:S.shared,callbacks:S.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=m:h.next=m,_.lastBaseUpdate=m}var r2=!1;function Og(){if(r2){var h=Rf;if(h!==null)throw h}}function Lg(h,m,_,S){r2=!1;var P=h.updateQueue;tu=!1;var D=P.firstBaseUpdate,X=P.lastBaseUpdate,le=P.shared.pending;if(le!==null){P.shared.pending=null;var Te=le,Ze=Te.next;Te.next=null,X===null?D=Ze:X.next=Ze,X=Te;var ct=h.alternate;ct!==null&&(ct=ct.updateQueue,le=ct.lastBaseUpdate,le!==X&&(le===null?ct.firstBaseUpdate=Ze:le.next=Ze,ct.lastBaseUpdate=Te))}if(D!==null){var ht=P.baseState;X=0,ct=Ze=Te=null,le=D;do{var Je=le.lane&-536870913,st=Je!==le.lane;if(st?(yn&Je)===Je:(S&Je)===Je){Je!==0&&Je===Pf&&(r2=!0),ct!==null&&(ct=ct.next={lane:0,tag:le.tag,payload:le.payload,callback:null,next:null});e:{var Dt=h,Gt=le;Je=m;var Wn=_;switch(Gt.tag){case 1:if(Dt=Gt.payload,typeof Dt=="function"){ht=Dt.call(Wn,ht,Je);break e}ht=Dt;break e;case 3:Dt.flags=Dt.flags&-65537|128;case 0:if(Dt=Gt.payload,Je=typeof Dt=="function"?Dt.call(Wn,ht,Je):Dt,Je==null)break e;ht=f({},ht,Je);break e;case 2:tu=!0}}Je=le.callback,Je!==null&&(h.flags|=64,st&&(h.flags|=8192),st=P.callbacks,st===null?P.callbacks=[Je]:st.push(Je))}else st={lane:Je,tag:le.tag,payload:le.payload,callback:le.callback,next:null},ct===null?(Ze=ct=st,Te=ht):ct=ct.next=st,X|=Je;if(le=le.next,le===null){if(le=P.shared.pending,le===null)break;st=le,le=st.next,st.next=null,P.lastBaseUpdate=st,P.shared.pending=null}}while(!0);ct===null&&(Te=ht),P.baseState=Te,P.firstBaseUpdate=Ze,P.lastBaseUpdate=ct,D===null&&(P.shared.lanes=0),lu|=X,h.lanes=X,h.memoizedState=ht}}function M4(h,m){if(typeof h!="function")throw Error(r(191,h));h.call(m)}function E4(h,m){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)M4(_[h],m)}var Of=U(null),Ey=U(0);function A4(h,m){h=Hl,ee(Ey,h),ee(Of,m),Hl=h|m.baseLanes}function i2(){ee(Ey,Hl),ee(Of,Of.current)}function a2(){Hl=Ey.current,H(Of),H(Ey)}var cs=U(null),Ls=null;function iu(h){var m=h.alternate;ee(Fr,Fr.current&1),ee(cs,h),Ls===null&&(m===null||Of.current!==null||m.memoizedState!==null)&&(Ls=h)}function s2(h){ee(Fr,Fr.current),ee(cs,h),Ls===null&&(Ls=h)}function T4(h){h.tag===22?(ee(Fr,Fr.current),ee(cs,h),Ls===null&&(Ls=h)):au()}function au(){ee(Fr,Fr.current),ee(cs,cs.current)}function us(h){H(cs),Ls===h&&(Ls=null),H(Fr)}var Fr=U(0);function Ay(h){for(var m=h;m!==null;){if(m.tag===13){var _=m.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||hA(_)||fA(_)))return m}else if(m.tag===19&&(m.memoizedProps.revealOrder==="forwards"||m.memoizedProps.revealOrder==="backwards"||m.memoizedProps.revealOrder==="unstable_legacy-backwards"||m.memoizedProps.revealOrder==="together")){if((m.flags&128)!==0)return m}else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return null;m=m.return}m.sibling.return=m.return,m=m.sibling}return null}var Dl=0,nn=null,Vn=null,Kr=null,Ty=!1,Lf=!1,Gd=!1,Cy=0,Ig=0,If=null,yne=0;function Nr(){throw Error(r(321))}function o2(h,m){if(m===null)return!1;for(var _=0;_<m.length&&_<h.length;_++)if(!ss(h[_],m[_]))return!1;return!0}function l2(h,m,_,S,P,D){return Dl=D,nn=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,K.H=h===null||h.memoizedState===null?uI:S2,Gd=!1,D=_(S,P),Gd=!1,Lf&&(D=N4(m,_,S,P)),C4(h),D}function C4(h){K.H=zg;var m=Vn!==null&&Vn.next!==null;if(Dl=0,Kr=Vn=nn=null,Ty=!1,Ig=0,If=null,m)throw Error(r(300));h===null||Xr||(h=h.dependencies,h!==null&&by(h)&&(Xr=!0))}function N4(h,m,_,S){nn=h;var P=0;do{if(Lf&&(If=null),Ig=0,Lf=!1,25<=P)throw Error(r(301));if(P+=1,Kr=Vn=null,h.updateQueue!=null){var D=h.updateQueue;D.lastEffect=null,D.events=null,D.stores=null,D.memoCache!=null&&(D.memoCache.index=0)}K.H=dI,D=m(_,S)}while(Lf);return D}function vne(){var h=K.H,m=h.useState()[0];return m=typeof m.then=="function"?Fg(m):m,h=h.useState()[0],(Vn!==null?Vn.memoizedState:null)!==h&&(nn.flags|=1024),m}function c2(){var h=Cy!==0;return Cy=0,h}function u2(h,m,_){m.updateQueue=h.updateQueue,m.flags&=-2053,h.lanes&=~_}function d2(h){if(Ty){for(h=h.memoizedState;h!==null;){var m=h.queue;m!==null&&(m.pending=null),h=h.next}Ty=!1}Dl=0,Kr=Vn=nn=null,Lf=!1,Ig=Cy=0,If=null}function ya(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Kr===null?nn.memoizedState=Kr=h:Kr=Kr.next=h,Kr}function Ur(){if(Vn===null){var h=nn.alternate;h=h!==null?h.memoizedState:null}else h=Vn.next;var m=Kr===null?nn.memoizedState:Kr.next;if(m!==null)Kr=m,Vn=h;else{if(h===null)throw nn.alternate===null?Error(r(467)):Error(r(310));Vn=h,h={memoizedState:Vn.memoizedState,baseState:Vn.baseState,baseQueue:Vn.baseQueue,queue:Vn.queue,next:null},Kr===null?nn.memoizedState=Kr=h:Kr=Kr.next=h}return Kr}function Ny(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Fg(h){var m=Ig;return Ig+=1,If===null&&(If=[]),h=y4(If,h,m),m=nn,(Kr===null?m.memoizedState:Kr.next)===null&&(m=m.alternate,K.H=m===null||m.memoizedState===null?uI:S2),h}function ky(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Fg(h);if(h.$$typeof===w)return $i(h)}throw Error(r(438,String(h)))}function h2(h){var m=null,_=nn.updateQueue;if(_!==null&&(m=_.memoCache),m==null){var S=nn.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(m={data:S.data.map(function(P){return P.slice()}),index:0})))}if(m==null&&(m={data:[],index:0}),_===null&&(_=Ny(),nn.updateQueue=_),_.memoCache=m,_=m.data[m.index],_===void 0)for(_=m.data[m.index]=Array(h),S=0;S<h;S++)_[S]=j;return m.index++,_}function Ol(h,m){return typeof m=="function"?m(h):m}function Py(h){var m=Ur();return f2(m,Vn,h)}function f2(h,m,_){var S=h.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=_;var P=h.baseQueue,D=S.pending;if(D!==null){if(P!==null){var X=P.next;P.next=D.next,D.next=X}m.baseQueue=P=D,S.pending=null}if(D=h.baseState,P===null)h.memoizedState=D;else{m=P.next;var le=X=null,Te=null,Ze=m,ct=!1;do{var ht=Ze.lane&-536870913;if(ht!==Ze.lane?(yn&ht)===ht:(Dl&ht)===ht){var Je=Ze.revertLane;if(Je===0)Te!==null&&(Te=Te.next={lane:0,revertLane:0,gesture:null,action:Ze.action,hasEagerState:Ze.hasEagerState,eagerState:Ze.eagerState,next:null}),ht===Pf&&(ct=!0);else if((Dl&Je)===Je){Ze=Ze.next,Je===Pf&&(ct=!0);continue}else ht={lane:0,revertLane:Ze.revertLane,gesture:null,action:Ze.action,hasEagerState:Ze.hasEagerState,eagerState:Ze.eagerState,next:null},Te===null?(le=Te=ht,X=D):Te=Te.next=ht,nn.lanes|=Je,lu|=Je;ht=Ze.action,Gd&&_(D,ht),D=Ze.hasEagerState?Ze.eagerState:_(D,ht)}else Je={lane:ht,revertLane:Ze.revertLane,gesture:Ze.gesture,action:Ze.action,hasEagerState:Ze.hasEagerState,eagerState:Ze.eagerState,next:null},Te===null?(le=Te=Je,X=D):Te=Te.next=Je,nn.lanes|=ht,lu|=ht;Ze=Ze.next}while(Ze!==null&&Ze!==m);if(Te===null?X=D:Te.next=le,!ss(D,h.memoizedState)&&(Xr=!0,ct&&(_=Rf,_!==null)))throw _;h.memoizedState=D,h.baseState=X,h.baseQueue=Te,S.lastRenderedState=D}return P===null&&(S.lanes=0),[h.memoizedState,S.dispatch]}function m2(h){var m=Ur(),_=m.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var S=_.dispatch,P=_.pending,D=m.memoizedState;if(P!==null){_.pending=null;var X=P=P.next;do D=h(D,X.action),X=X.next;while(X!==P);ss(D,m.memoizedState)||(Xr=!0),m.memoizedState=D,m.baseQueue===null&&(m.baseState=D),_.lastRenderedState=D}return[D,S]}function k4(h,m,_){var S=nn,P=Ur(),D=wn;if(D){if(_===void 0)throw Error(r(407));_=_()}else _=m();var X=!ss((Vn||P).memoizedState,_);if(X&&(P.memoizedState=_,Xr=!0),P=P.queue,x2(j4.bind(null,S,P,h),[h]),P.getSnapshot!==m||X||Kr!==null&&Kr.memoizedState.tag&1){if(S.flags|=2048,Ff(9,{destroy:void 0},R4.bind(null,S,P,_,m),null),er===null)throw Error(r(349));D||(Dl&127)!==0||P4(S,m,_)}return _}function P4(h,m,_){h.flags|=16384,h={getSnapshot:m,value:_},m=nn.updateQueue,m===null?(m=Ny(),nn.updateQueue=m,m.stores=[h]):(_=m.stores,_===null?m.stores=[h]:_.push(h))}function R4(h,m,_,S){m.value=_,m.getSnapshot=S,D4(m)&&O4(h)}function j4(h,m,_){return _(function(){D4(m)&&O4(h)})}function D4(h){var m=h.getSnapshot;h=h.value;try{var _=m();return!ss(h,_)}catch{return!0}}function O4(h){var m=Ld(h,2);m!==null&&Ba(m,h,2)}function p2(h){var m=ya();if(typeof h=="function"){var _=h;if(h=_(),Gd){tt(!0);try{_()}finally{tt(!1)}}}return m.memoizedState=m.baseState=h,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ol,lastRenderedState:h},m}function L4(h,m,_,S){return h.baseState=_,f2(h,Vn,typeof S=="function"?S:Ol)}function _ne(h,m,_,S,P){if(Dy(h))throw Error(r(485));if(h=m.action,h!==null){var D={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(X){D.listeners.push(X)}};K.T!==null?_(!0):D.isTransition=!1,S(D),_=m.pending,_===null?(D.next=m.pending=D,I4(m,D)):(D.next=_.next,m.pending=_.next=D)}}function I4(h,m){var _=m.action,S=m.payload,P=h.state;if(m.isTransition){var D=K.T,X={};K.T=X;try{var le=_(P,S),Te=K.S;Te!==null&&Te(X,le),F4(h,m,le)}catch(Ze){g2(h,m,Ze)}finally{D!==null&&X.types!==null&&(D.types=X.types),K.T=D}}else try{D=_(P,S),F4(h,m,D)}catch(Ze){g2(h,m,Ze)}}function F4(h,m,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(S){U4(h,m,S)},function(S){return g2(h,m,S)}):U4(h,m,_)}function U4(h,m,_){m.status="fulfilled",m.value=_,z4(m),h.state=_,m=h.pending,m!==null&&(_=m.next,_===m?h.pending=null:(_=_.next,m.next=_,I4(h,_)))}function g2(h,m,_){var S=h.pending;if(h.pending=null,S!==null){S=S.next;do m.status="rejected",m.reason=_,z4(m),m=m.next;while(m!==S)}h.action=null}function z4(h){h=h.listeners;for(var m=0;m<h.length;m++)(0,h[m])()}function B4(h,m){return m}function H4(h,m){if(wn){var _=er.formState;if(_!==null){e:{var S=nn;if(wn){if(lr){t:{for(var P=lr,D=Os;P.nodeType!==8;){if(!D){P=null;break t}if(P=Is(P.nextSibling),P===null){P=null;break t}}D=P.data,P=D==="F!"||D==="F"?P:null}if(P){lr=Is(P.nextSibling),S=P.data==="F!";break e}}Jc(S)}S=!1}S&&(m=_[0])}}return _=ya(),_.memoizedState=_.baseState=m,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:B4,lastRenderedState:m},_.queue=S,_=oI.bind(null,nn,S),S.dispatch=_,S=p2(!1),D=w2.bind(null,nn,!1,S.queue),S=ya(),P={state:m,dispatch:null,action:h,pending:null},S.queue=P,_=_ne.bind(null,nn,P,D,_),P.dispatch=_,S.memoizedState=h,[m,_,!1]}function $4(h){var m=Ur();return V4(m,Vn,h)}function V4(h,m,_){if(m=f2(h,m,B4)[0],h=Py(Ol)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var S=Fg(m)}catch(X){throw X===jf?_y:X}else S=m;m=Ur();var P=m.queue,D=P.dispatch;return _!==m.memoizedState&&(nn.flags|=2048,Ff(9,{destroy:void 0},wne.bind(null,P,_),null)),[S,D,h]}function wne(h,m){h.action=m}function G4(h){var m=Ur(),_=Vn;if(_!==null)return V4(m,_,h);Ur(),m=m.memoizedState,_=Ur();var S=_.queue.dispatch;return _.memoizedState=h,[m,S,!1]}function Ff(h,m,_,S){return h={tag:h,create:_,deps:S,inst:m,next:null},m=nn.updateQueue,m===null&&(m=Ny(),nn.updateQueue=m),_=m.lastEffect,_===null?m.lastEffect=h.next=h:(S=_.next,_.next=h,h.next=S,m.lastEffect=h),h}function W4(){return Ur().memoizedState}function Ry(h,m,_,S){var P=ya();nn.flags|=h,P.memoizedState=Ff(1|m,{destroy:void 0},_,S===void 0?null:S)}function jy(h,m,_,S){var P=Ur();S=S===void 0?null:S;var D=P.memoizedState.inst;Vn!==null&&S!==null&&o2(S,Vn.memoizedState.deps)?P.memoizedState=Ff(m,D,_,S):(nn.flags|=h,P.memoizedState=Ff(1|m,D,_,S))}function q4(h,m){Ry(8390656,8,h,m)}function x2(h,m){jy(2048,8,h,m)}function Sne(h){nn.flags|=4;var m=nn.updateQueue;if(m===null)m=Ny(),nn.updateQueue=m,m.events=[h];else{var _=m.events;_===null?m.events=[h]:_.push(h)}}function K4(h){var m=Ur().memoizedState;return Sne({ref:m,nextImpl:h}),function(){if((Pn&2)!==0)throw Error(r(440));return m.impl.apply(void 0,arguments)}}function X4(h,m){return jy(4,2,h,m)}function Y4(h,m){return jy(4,4,h,m)}function Z4(h,m){if(typeof m=="function"){h=h();var _=m(h);return function(){typeof _=="function"?_():m(null)}}if(m!=null)return h=h(),m.current=h,function(){m.current=null}}function Q4(h,m,_){_=_!=null?_.concat([h]):null,jy(4,4,Z4.bind(null,m,h),_)}function b2(){}function J4(h,m){var _=Ur();m=m===void 0?null:m;var S=_.memoizedState;return m!==null&&o2(m,S[1])?S[0]:(_.memoizedState=[h,m],h)}function eI(h,m){var _=Ur();m=m===void 0?null:m;var S=_.memoizedState;if(m!==null&&o2(m,S[1]))return S[0];if(S=h(),Gd){tt(!0);try{h()}finally{tt(!1)}}return _.memoizedState=[S,m],S}function y2(h,m,_){return _===void 0||(Dl&1073741824)!==0&&(yn&261930)===0?h.memoizedState=m:(h.memoizedState=_,h=t5(),nn.lanes|=h,lu|=h,_)}function tI(h,m,_,S){return ss(_,m)?_:Of.current!==null?(h=y2(h,_,S),ss(h,m)||(Xr=!0),h):(Dl&42)===0||(Dl&1073741824)!==0&&(yn&261930)===0?(Xr=!0,h.memoizedState=_):(h=t5(),nn.lanes|=h,lu|=h,m)}function nI(h,m,_,S,P){var D=G.p;G.p=D!==0&&8>D?D:8;var X=K.T,le={};K.T=le,w2(h,!1,m,_);try{var Te=P(),Ze=K.S;if(Ze!==null&&Ze(le,Te),Te!==null&&typeof Te=="object"&&typeof Te.then=="function"){var ct=bne(Te,S);Ug(h,m,ct,fs(h))}else Ug(h,m,S,fs(h))}catch(ht){Ug(h,m,{then:function(){},status:"rejected",reason:ht},fs())}finally{G.p=D,X!==null&&le.types!==null&&(X.types=le.types),K.T=X}}function Mne(){}function v2(h,m,_,S){if(h.tag!==5)throw Error(r(476));var P=rI(h).queue;nI(h,P,m,te,_===null?Mne:function(){return iI(h),_(S)})}function rI(h){var m=h.memoizedState;if(m!==null)return m;m={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ol,lastRenderedState:te},next:null};var _={};return m.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ol,lastRenderedState:_},next:null},h.memoizedState=m,h=h.alternate,h!==null&&(h.memoizedState=m),m}function iI(h){var m=rI(h);m.next===null&&(m=h.alternate.memoizedState),Ug(h,m.next.queue,{},fs())}function _2(){return $i(nx)}function aI(){return Ur().memoizedState}function sI(){return Ur().memoizedState}function Ene(h){for(var m=h.return;m!==null;){switch(m.tag){case 24:case 3:var _=fs();h=nu(_);var S=ru(m,h,_);S!==null&&(Ba(S,m,_),Dg(S,m,_)),m={cache:YE()},h.payload=m;return}m=m.return}}function Ane(h,m,_){var S=fs();_={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Dy(h)?lI(m,_):(_=UE(h,m,_,S),_!==null&&(Ba(_,h,S),cI(_,m,S)))}function oI(h,m,_){var S=fs();Ug(h,m,_,S)}function Ug(h,m,_,S){var P={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Dy(h))lI(m,P);else{var D=h.alternate;if(h.lanes===0&&(D===null||D.lanes===0)&&(D=m.lastRenderedReducer,D!==null))try{var X=m.lastRenderedState,le=D(X,_);if(P.hasEagerState=!0,P.eagerState=le,ss(le,X))return my(h,m,P,0),er===null&&fy(),!1}catch{}finally{}if(_=UE(h,m,P,S),_!==null)return Ba(_,h,S),cI(_,m,S),!0}return!1}function w2(h,m,_,S){if(S={lane:2,revertLane:eA(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Dy(h)){if(m)throw Error(r(479))}else m=UE(h,_,S,2),m!==null&&Ba(m,h,2)}function Dy(h){var m=h.alternate;return h===nn||m!==null&&m===nn}function lI(h,m){Lf=Ty=!0;var _=h.pending;_===null?m.next=m:(m.next=_.next,_.next=m),h.pending=m}function cI(h,m,_){if((_&4194048)!==0){var S=m.lanes;S&=h.pendingLanes,_|=S,m.lanes=_,On(h,_)}}var zg={readContext:$i,use:ky,useCallback:Nr,useContext:Nr,useEffect:Nr,useImperativeHandle:Nr,useLayoutEffect:Nr,useInsertionEffect:Nr,useMemo:Nr,useReducer:Nr,useRef:Nr,useState:Nr,useDebugValue:Nr,useDeferredValue:Nr,useTransition:Nr,useSyncExternalStore:Nr,useId:Nr,useHostTransitionStatus:Nr,useFormState:Nr,useActionState:Nr,useOptimistic:Nr,useMemoCache:Nr,useCacheRefresh:Nr};zg.useEffectEvent=Nr;var uI={readContext:$i,use:ky,useCallback:function(h,m){return ya().memoizedState=[h,m===void 0?null:m],h},useContext:$i,useEffect:q4,useImperativeHandle:function(h,m,_){_=_!=null?_.concat([h]):null,Ry(4194308,4,Z4.bind(null,m,h),_)},useLayoutEffect:function(h,m){return Ry(4194308,4,h,m)},useInsertionEffect:function(h,m){Ry(4,2,h,m)},useMemo:function(h,m){var _=ya();m=m===void 0?null:m;var S=h();if(Gd){tt(!0);try{h()}finally{tt(!1)}}return _.memoizedState=[S,m],S},useReducer:function(h,m,_){var S=ya();if(_!==void 0){var P=_(m);if(Gd){tt(!0);try{_(m)}finally{tt(!1)}}}else P=m;return S.memoizedState=S.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},S.queue=h,h=h.dispatch=Ane.bind(null,nn,h),[S.memoizedState,h]},useRef:function(h){var m=ya();return h={current:h},m.memoizedState=h},useState:function(h){h=p2(h);var m=h.queue,_=oI.bind(null,nn,m);return m.dispatch=_,[h.memoizedState,_]},useDebugValue:b2,useDeferredValue:function(h,m){var _=ya();return y2(_,h,m)},useTransition:function(){var h=p2(!1);return h=nI.bind(null,nn,h.queue,!0,!1),ya().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,m,_){var S=nn,P=ya();if(wn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=m(),er===null)throw Error(r(349));(yn&127)!==0||P4(S,m,_)}P.memoizedState=_;var D={value:_,getSnapshot:m};return P.queue=D,q4(j4.bind(null,S,D,h),[h]),S.flags|=2048,Ff(9,{destroy:void 0},R4.bind(null,S,D,_,m),null),_},useId:function(){var h=ya(),m=er.identifierPrefix;if(wn){var _=Wo,S=Go;_=(S&~(1<<32-$e(S)-1)).toString(32)+_,m="_"+m+"R_"+_,_=Cy++,0<_&&(m+="H"+_.toString(32)),m+="_"}else _=yne++,m="_"+m+"r_"+_.toString(32)+"_";return h.memoizedState=m},useHostTransitionStatus:_2,useFormState:H4,useActionState:H4,useOptimistic:function(h){var m=ya();m.memoizedState=m.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=_,m=w2.bind(null,nn,!0,_),_.dispatch=m,[h,m]},useMemoCache:h2,useCacheRefresh:function(){return ya().memoizedState=Ene.bind(null,nn)},useEffectEvent:function(h){var m=ya(),_={impl:h};return m.memoizedState=_,function(){if((Pn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},S2={readContext:$i,use:ky,useCallback:J4,useContext:$i,useEffect:x2,useImperativeHandle:Q4,useInsertionEffect:X4,useLayoutEffect:Y4,useMemo:eI,useReducer:Py,useRef:W4,useState:function(){return Py(Ol)},useDebugValue:b2,useDeferredValue:function(h,m){var _=Ur();return tI(_,Vn.memoizedState,h,m)},useTransition:function(){var h=Py(Ol)[0],m=Ur().memoizedState;return[typeof h=="boolean"?h:Fg(h),m]},useSyncExternalStore:k4,useId:aI,useHostTransitionStatus:_2,useFormState:$4,useActionState:$4,useOptimistic:function(h,m){var _=Ur();return L4(_,Vn,h,m)},useMemoCache:h2,useCacheRefresh:sI};S2.useEffectEvent=K4;var dI={readContext:$i,use:ky,useCallback:J4,useContext:$i,useEffect:x2,useImperativeHandle:Q4,useInsertionEffect:X4,useLayoutEffect:Y4,useMemo:eI,useReducer:m2,useRef:W4,useState:function(){return m2(Ol)},useDebugValue:b2,useDeferredValue:function(h,m){var _=Ur();return Vn===null?y2(_,h,m):tI(_,Vn.memoizedState,h,m)},useTransition:function(){var h=m2(Ol)[0],m=Ur().memoizedState;return[typeof h=="boolean"?h:Fg(h),m]},useSyncExternalStore:k4,useId:aI,useHostTransitionStatus:_2,useFormState:G4,useActionState:G4,useOptimistic:function(h,m){var _=Ur();return Vn!==null?L4(_,Vn,h,m):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:h2,useCacheRefresh:sI};dI.useEffectEvent=K4;function M2(h,m,_,S){m=h.memoizedState,_=_(S,m),_=_==null?m:f({},m,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var E2={enqueueSetState:function(h,m,_){h=h._reactInternals;var S=fs(),P=nu(S);P.payload=m,_!=null&&(P.callback=_),m=ru(h,P,S),m!==null&&(Ba(m,h,S),Dg(m,h,S))},enqueueReplaceState:function(h,m,_){h=h._reactInternals;var S=fs(),P=nu(S);P.tag=1,P.payload=m,_!=null&&(P.callback=_),m=ru(h,P,S),m!==null&&(Ba(m,h,S),Dg(m,h,S))},enqueueForceUpdate:function(h,m){h=h._reactInternals;var _=fs(),S=nu(_);S.tag=2,m!=null&&(S.callback=m),m=ru(h,S,_),m!==null&&(Ba(m,h,_),Dg(m,h,_))}};function hI(h,m,_,S,P,D,X){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(S,D,X):m.prototype&&m.prototype.isPureReactComponent?!Ag(_,S)||!Ag(P,D):!0}function fI(h,m,_,S){h=m.state,typeof m.componentWillReceiveProps=="function"&&m.componentWillReceiveProps(_,S),typeof m.UNSAFE_componentWillReceiveProps=="function"&&m.UNSAFE_componentWillReceiveProps(_,S),m.state!==h&&E2.enqueueReplaceState(m,m.state,null)}function Wd(h,m){var _=m;if("ref"in m){_={};for(var S in m)S!=="ref"&&(_[S]=m[S])}if(h=h.defaultProps){_===m&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function mI(h){hy(h)}function pI(h){console.error(h)}function gI(h){hy(h)}function Oy(h,m){try{var _=h.onUncaughtError;_(m.value,{componentStack:m.stack})}catch(S){setTimeout(function(){throw S})}}function xI(h,m,_){try{var S=h.onCaughtError;S(_.value,{componentStack:_.stack,errorBoundary:m.tag===1?m.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function A2(h,m,_){return _=nu(_),_.tag=3,_.payload={element:null},_.callback=function(){Oy(h,m)},_}function bI(h){return h=nu(h),h.tag=3,h}function yI(h,m,_,S){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var D=S.value;h.payload=function(){return P(D)},h.callback=function(){xI(m,_,S)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(h.callback=function(){xI(m,_,S),typeof P!="function"&&(cu===null?cu=new Set([this]):cu.add(this));var le=S.stack;this.componentDidCatch(S.value,{componentStack:le!==null?le:""})})}function Tne(h,m,_,S,P){if(_.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(m=_.alternate,m!==null&&kf(m,_,P,!0),_=cs.current,_!==null){switch(_.tag){case 31:case 13:return Ls===null?qy():_.alternate===null&&kr===0&&(kr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,S===wy?_.flags|=16384:(m=_.updateQueue,m===null?_.updateQueue=new Set([S]):m.add(S),Z2(h,S,P)),!1;case 22:return _.flags|=65536,S===wy?_.flags|=16384:(m=_.updateQueue,m===null?(m={transitions:null,markerInstances:null,retryQueue:new Set([S])},_.updateQueue=m):(_=m.retryQueue,_===null?m.retryQueue=new Set([S]):_.add(S)),Z2(h,S,P)),!1}throw Error(r(435,_.tag))}return Z2(h,S,P),qy(),!1}if(wn)return m=cs.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=P,S!==GE&&(h=Error(r(422),{cause:S}),Ng(Rs(h,_)))):(S!==GE&&(m=Error(r(423),{cause:S}),Ng(Rs(m,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,S=Rs(S,_),P=A2(h.stateNode,S,P),n2(h,P),kr!==4&&(kr=2)),!1;var D=Error(r(520),{cause:S});if(D=Rs(D,_),Kg===null?Kg=[D]:Kg.push(D),kr!==4&&(kr=2),m===null)return!0;S=Rs(S,_),_=m;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=A2(_.stateNode,S,h),n2(_,h),!1;case 1:if(m=_.type,D=_.stateNode,(_.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(cu===null||!cu.has(D))))return _.flags|=65536,P&=-P,_.lanes|=P,P=bI(P),yI(P,h,_,S),n2(_,P),!1}_=_.return}while(_!==null);return!1}var T2=Error(r(461)),Xr=!1;function Vi(h,m,_,S){m.child=h===null?S4(m,null,_,S):Vd(m,h.child,_,S)}function vI(h,m,_,S,P){_=_.render;var D=m.ref;if("ref"in S){var X={};for(var le in S)le!=="ref"&&(X[le]=S[le])}else X=S;return zd(m),S=l2(h,m,_,X,D,P),le=c2(),h!==null&&!Xr?(u2(h,m,P),Ll(h,m,P)):(wn&&le&&$E(m),m.flags|=1,Vi(h,m,S,P),m.child)}function _I(h,m,_,S,P){if(h===null){var D=_.type;return typeof D=="function"&&!zE(D)&&D.defaultProps===void 0&&_.compare===null?(m.tag=15,m.type=D,wI(h,m,D,S,P)):(h=gy(_.type,null,S,m,m.mode,P),h.ref=m.ref,h.return=m,m.child=h)}if(D=h.child,!O2(h,P)){var X=D.memoizedProps;if(_=_.compare,_=_!==null?_:Ag,_(X,S)&&h.ref===m.ref)return Ll(h,m,P)}return m.flags|=1,h=kl(D,S),h.ref=m.ref,h.return=m,m.child=h}function wI(h,m,_,S,P){if(h!==null){var D=h.memoizedProps;if(Ag(D,S)&&h.ref===m.ref)if(Xr=!1,m.pendingProps=S=D,O2(h,P))(h.flags&131072)!==0&&(Xr=!0);else return m.lanes=h.lanes,Ll(h,m,P)}return C2(h,m,_,S,P)}function SI(h,m,_,S){var P=S.children,D=h!==null?h.memoizedState:null;if(h===null&&m.stateNode===null&&(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((m.flags&128)!==0){if(D=D!==null?D.baseLanes|_:_,h!==null){for(S=m.child=h.child,P=0;S!==null;)P=P|S.lanes|S.childLanes,S=S.sibling;S=P&~D}else S=0,m.child=null;return MI(h,m,D,_,S)}if((_&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},h!==null&&vy(m,D!==null?D.cachePool:null),D!==null?A4(m,D):i2(),T4(m);else return S=m.lanes=536870912,MI(h,m,D!==null?D.baseLanes|_:_,_,S)}else D!==null?(vy(m,D.cachePool),A4(m,D),au(),m.memoizedState=null):(h!==null&&vy(m,null),i2(),au());return Vi(h,m,P,_),m.child}function Bg(h,m){return h!==null&&h.tag===22||m.stateNode!==null||(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.sibling}function MI(h,m,_,S,P){var D=QE();return D=D===null?null:{parent:qr._currentValue,pool:D},m.memoizedState={baseLanes:_,cachePool:D},h!==null&&vy(m,null),i2(),T4(m),h!==null&&kf(h,m,S,!0),m.childLanes=P,null}function Ly(h,m){return m=Fy({mode:m.mode,children:m.children},h.mode),m.ref=h.ref,h.child=m,m.return=h,m}function EI(h,m,_){return Vd(m,h.child,null,_),h=Ly(m,m.pendingProps),h.flags|=2,us(m),m.memoizedState=null,h}function Cne(h,m,_){var S=m.pendingProps,P=(m.flags&128)!==0;if(m.flags&=-129,h===null){if(wn){if(S.mode==="hidden")return h=Ly(m,S),m.lanes=536870912,Bg(null,h);if(s2(m),(h=lr)?(h=I5(h,Os),h=h!==null&&h.data==="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:Zc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=l4(h),_.return=m,m.child=_,Hi=m,lr=null)):h=null,h===null)throw Jc(m);return m.lanes=536870912,null}return Ly(m,S)}var D=h.memoizedState;if(D!==null){var X=D.dehydrated;if(s2(m),P)if(m.flags&256)m.flags&=-257,m=EI(h,m,_);else if(m.memoizedState!==null)m.child=h.child,m.flags|=128,m=null;else throw Error(r(558));else if(Xr||kf(h,m,_,!1),P=(_&h.childLanes)!==0,Xr||P){if(S=er,S!==null&&(X=Mi(S,_),X!==0&&X!==D.retryLane))throw D.retryLane=X,Ld(h,X),Ba(S,h,X),T2;qy(),m=EI(h,m,_)}else h=D.treeContext,lr=Is(X.nextSibling),Hi=m,wn=!0,Qc=null,Os=!1,h!==null&&d4(m,h),m=Ly(m,S),m.flags|=4096;return m}return h=kl(h.child,{mode:S.mode,children:S.children}),h.ref=m.ref,m.child=h,h.return=m,h}function Iy(h,m){var _=m.ref;if(_===null)h!==null&&h.ref!==null&&(m.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(m.flags|=4194816)}}function C2(h,m,_,S,P){return zd(m),_=l2(h,m,_,S,void 0,P),S=c2(),h!==null&&!Xr?(u2(h,m,P),Ll(h,m,P)):(wn&&S&&$E(m),m.flags|=1,Vi(h,m,_,P),m.child)}function AI(h,m,_,S,P,D){return zd(m),m.updateQueue=null,_=N4(m,S,_,P),C4(h),S=c2(),h!==null&&!Xr?(u2(h,m,D),Ll(h,m,D)):(wn&&S&&$E(m),m.flags|=1,Vi(h,m,_,D),m.child)}function TI(h,m,_,S,P){if(zd(m),m.stateNode===null){var D=Af,X=_.contextType;typeof X=="object"&&X!==null&&(D=$i(X)),D=new _(S,D),m.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,D.updater=E2,m.stateNode=D,D._reactInternals=m,D=m.stateNode,D.props=S,D.state=m.memoizedState,D.refs={},e2(m),X=_.contextType,D.context=typeof X=="object"&&X!==null?$i(X):Af,D.state=m.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(M2(m,_,X,S),D.state=m.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(X=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),X!==D.state&&E2.enqueueReplaceState(D,D.state,null),Lg(m,S,D,P),Og(),D.state=m.memoizedState),typeof D.componentDidMount=="function"&&(m.flags|=4194308),S=!0}else if(h===null){D=m.stateNode;var le=m.memoizedProps,Te=Wd(_,le);D.props=Te;var Ze=D.context,ct=_.contextType;X=Af,typeof ct=="object"&&ct!==null&&(X=$i(ct));var ht=_.getDerivedStateFromProps;ct=typeof ht=="function"||typeof D.getSnapshotBeforeUpdate=="function",le=m.pendingProps!==le,ct||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(le||Ze!==X)&&fI(m,D,S,X),tu=!1;var Je=m.memoizedState;D.state=Je,Lg(m,S,D,P),Og(),Ze=m.memoizedState,le||Je!==Ze||tu?(typeof ht=="function"&&(M2(m,_,ht,S),Ze=m.memoizedState),(Te=tu||hI(m,_,Te,S,Je,Ze,X))?(ct||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount()),typeof D.componentDidMount=="function"&&(m.flags|=4194308)):(typeof D.componentDidMount=="function"&&(m.flags|=4194308),m.memoizedProps=S,m.memoizedState=Ze),D.props=S,D.state=Ze,D.context=X,S=Te):(typeof D.componentDidMount=="function"&&(m.flags|=4194308),S=!1)}else{D=m.stateNode,t2(h,m),X=m.memoizedProps,ct=Wd(_,X),D.props=ct,ht=m.pendingProps,Je=D.context,Ze=_.contextType,Te=Af,typeof Ze=="object"&&Ze!==null&&(Te=$i(Ze)),le=_.getDerivedStateFromProps,(Ze=typeof le=="function"||typeof D.getSnapshotBeforeUpdate=="function")||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(X!==ht||Je!==Te)&&fI(m,D,S,Te),tu=!1,Je=m.memoizedState,D.state=Je,Lg(m,S,D,P),Og();var st=m.memoizedState;X!==ht||Je!==st||tu||h!==null&&h.dependencies!==null&&by(h.dependencies)?(typeof le=="function"&&(M2(m,_,le,S),st=m.memoizedState),(ct=tu||hI(m,_,ct,S,Je,st,Te)||h!==null&&h.dependencies!==null&&by(h.dependencies))?(Ze||typeof D.UNSAFE_componentWillUpdate!="function"&&typeof D.componentWillUpdate!="function"||(typeof D.componentWillUpdate=="function"&&D.componentWillUpdate(S,st,Te),typeof D.UNSAFE_componentWillUpdate=="function"&&D.UNSAFE_componentWillUpdate(S,st,Te)),typeof D.componentDidUpdate=="function"&&(m.flags|=4),typeof D.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof D.componentDidUpdate!="function"||X===h.memoizedProps&&Je===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Je===h.memoizedState||(m.flags|=1024),m.memoizedProps=S,m.memoizedState=st),D.props=S,D.state=st,D.context=Te,S=ct):(typeof D.componentDidUpdate!="function"||X===h.memoizedProps&&Je===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Je===h.memoizedState||(m.flags|=1024),S=!1)}return D=S,Iy(h,m),S=(m.flags&128)!==0,D||S?(D=m.stateNode,_=S&&typeof _.getDerivedStateFromError!="function"?null:D.render(),m.flags|=1,h!==null&&S?(m.child=Vd(m,h.child,null,P),m.child=Vd(m,null,_,P)):Vi(h,m,_,P),m.memoizedState=D.state,h=m.child):h=Ll(h,m,P),h}function CI(h,m,_,S){return Fd(),m.flags|=256,Vi(h,m,_,S),m.child}var N2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function k2(h){return{baseLanes:h,cachePool:x4()}}function P2(h,m,_){return h=h!==null?h.childLanes&~_:0,m&&(h|=hs),h}function NI(h,m,_){var S=m.pendingProps,P=!1,D=(m.flags&128)!==0,X;if((X=D)||(X=h!==null&&h.memoizedState===null?!1:(Fr.current&2)!==0),X&&(P=!0,m.flags&=-129),X=(m.flags&32)!==0,m.flags&=-33,h===null){if(wn){if(P?iu(m):au(),(h=lr)?(h=I5(h,Os),h=h!==null&&h.data!=="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:Zc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=l4(h),_.return=m,m.child=_,Hi=m,lr=null)):h=null,h===null)throw Jc(m);return fA(h)?m.lanes=32:m.lanes=536870912,null}var le=S.children;return S=S.fallback,P?(au(),P=m.mode,le=Fy({mode:"hidden",children:le},P),S=Id(S,P,_,null),le.return=m,S.return=m,le.sibling=S,m.child=le,S=m.child,S.memoizedState=k2(_),S.childLanes=P2(h,X,_),m.memoizedState=N2,Bg(null,S)):(iu(m),R2(m,le))}var Te=h.memoizedState;if(Te!==null&&(le=Te.dehydrated,le!==null)){if(D)m.flags&256?(iu(m),m.flags&=-257,m=j2(h,m,_)):m.memoizedState!==null?(au(),m.child=h.child,m.flags|=128,m=null):(au(),le=S.fallback,P=m.mode,S=Fy({mode:"visible",children:S.children},P),le=Id(le,P,_,null),le.flags|=2,S.return=m,le.return=m,S.sibling=le,m.child=S,Vd(m,h.child,null,_),S=m.child,S.memoizedState=k2(_),S.childLanes=P2(h,X,_),m.memoizedState=N2,m=Bg(null,S));else if(iu(m),fA(le)){if(X=le.nextSibling&&le.nextSibling.dataset,X)var Ze=X.dgst;X=Ze,S=Error(r(419)),S.stack="",S.digest=X,Ng({value:S,source:null,stack:null}),m=j2(h,m,_)}else if(Xr||kf(h,m,_,!1),X=(_&h.childLanes)!==0,Xr||X){if(X=er,X!==null&&(S=Mi(X,_),S!==0&&S!==Te.retryLane))throw Te.retryLane=S,Ld(h,S),Ba(X,h,S),T2;hA(le)||qy(),m=j2(h,m,_)}else hA(le)?(m.flags|=192,m.child=h.child,m=null):(h=Te.treeContext,lr=Is(le.nextSibling),Hi=m,wn=!0,Qc=null,Os=!1,h!==null&&d4(m,h),m=R2(m,S.children),m.flags|=4096);return m}return P?(au(),le=S.fallback,P=m.mode,Te=h.child,Ze=Te.sibling,S=kl(Te,{mode:"hidden",children:S.children}),S.subtreeFlags=Te.subtreeFlags&65011712,Ze!==null?le=kl(Ze,le):(le=Id(le,P,_,null),le.flags|=2),le.return=m,S.return=m,S.sibling=le,m.child=S,Bg(null,S),S=m.child,le=h.child.memoizedState,le===null?le=k2(_):(P=le.cachePool,P!==null?(Te=qr._currentValue,P=P.parent!==Te?{parent:Te,pool:Te}:P):P=x4(),le={baseLanes:le.baseLanes|_,cachePool:P}),S.memoizedState=le,S.childLanes=P2(h,X,_),m.memoizedState=N2,Bg(h.child,S)):(iu(m),_=h.child,h=_.sibling,_=kl(_,{mode:"visible",children:S.children}),_.return=m,_.sibling=null,h!==null&&(X=m.deletions,X===null?(m.deletions=[h],m.flags|=16):X.push(h)),m.child=_,m.memoizedState=null,_)}function R2(h,m){return m=Fy({mode:"visible",children:m},h.mode),m.return=h,h.child=m}function Fy(h,m){return h=ls(22,h,null,m),h.lanes=0,h}function j2(h,m,_){return Vd(m,h.child,null,_),h=R2(m,m.pendingProps.children),h.flags|=2,m.memoizedState=null,h}function kI(h,m,_){h.lanes|=m;var S=h.alternate;S!==null&&(S.lanes|=m),KE(h.return,m,_)}function D2(h,m,_,S,P,D){var X=h.memoizedState;X===null?h.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:S,tail:_,tailMode:P,treeForkCount:D}:(X.isBackwards=m,X.rendering=null,X.renderingStartTime=0,X.last=S,X.tail=_,X.tailMode=P,X.treeForkCount=D)}function PI(h,m,_){var S=m.pendingProps,P=S.revealOrder,D=S.tail;S=S.children;var X=Fr.current,le=(X&2)!==0;if(le?(X=X&1|2,m.flags|=128):X&=1,ee(Fr,X),Vi(h,m,S,_),S=wn?Cg:0,!le&&h!==null&&(h.flags&128)!==0)e:for(h=m.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&kI(h,_,m);else if(h.tag===19)kI(h,_,m);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===m)break e;for(;h.sibling===null;){if(h.return===null||h.return===m)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=m.child,P=null;_!==null;)h=_.alternate,h!==null&&Ay(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=m.child,m.child=null):(P=_.sibling,_.sibling=null),D2(m,!1,P,_,D,S);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=m.child,m.child=null;P!==null;){if(h=P.alternate,h!==null&&Ay(h)===null){m.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}D2(m,!0,_,null,D,S);break;case"together":D2(m,!1,null,null,void 0,S);break;default:m.memoizedState=null}return m.child}function Ll(h,m,_){if(h!==null&&(m.dependencies=h.dependencies),lu|=m.lanes,(_&m.childLanes)===0)if(h!==null){if(kf(h,m,_,!1),(_&m.childLanes)===0)return null}else return null;if(h!==null&&m.child!==h.child)throw Error(r(153));if(m.child!==null){for(h=m.child,_=kl(h,h.pendingProps),m.child=_,_.return=m;h.sibling!==null;)h=h.sibling,_=_.sibling=kl(h,h.pendingProps),_.return=m;_.sibling=null}return m.child}function O2(h,m){return(h.lanes&m)!==0?!0:(h=h.dependencies,!!(h!==null&&by(h)))}function Nne(h,m,_){switch(m.tag){case 3:Re(m,m.stateNode.containerInfo),eu(m,qr,h.memoizedState.cache),Fd();break;case 27:case 5:_e(m);break;case 4:Re(m,m.stateNode.containerInfo);break;case 10:eu(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,s2(m),null;break;case 13:var S=m.memoizedState;if(S!==null)return S.dehydrated!==null?(iu(m),m.flags|=128,null):(_&m.child.childLanes)!==0?NI(h,m,_):(iu(m),h=Ll(h,m,_),h!==null?h.sibling:null);iu(m);break;case 19:var P=(h.flags&128)!==0;if(S=(_&m.childLanes)!==0,S||(kf(h,m,_,!1),S=(_&m.childLanes)!==0),P){if(S)return PI(h,m,_);m.flags|=128}if(P=m.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ee(Fr,Fr.current),S)break;return null;case 22:return m.lanes=0,SI(h,m,_,m.pendingProps);case 24:eu(m,qr,h.memoizedState.cache)}return Ll(h,m,_)}function RI(h,m,_){if(h!==null)if(h.memoizedProps!==m.pendingProps)Xr=!0;else{if(!O2(h,_)&&(m.flags&128)===0)return Xr=!1,Nne(h,m,_);Xr=(h.flags&131072)!==0}else Xr=!1,wn&&(m.flags&1048576)!==0&&u4(m,Cg,m.index);switch(m.lanes=0,m.tag){case 16:e:{var S=m.pendingProps;if(h=Hd(m.elementType),m.type=h,typeof h=="function")zE(h)?(S=Wd(h,S),m.tag=1,m=TI(null,m,h,S,_)):(m.tag=0,m=C2(null,m,h,S,_));else{if(h!=null){var P=h.$$typeof;if(P===A){m.tag=11,m=vI(null,m,h,S,_);break e}else if(P===k){m.tag=14,m=_I(null,m,h,S,_);break e}}throw m=R(h)||h,Error(r(306,m,""))}}return m;case 0:return C2(h,m,m.type,m.pendingProps,_);case 1:return S=m.type,P=Wd(S,m.pendingProps),TI(h,m,S,P,_);case 3:e:{if(Re(m,m.stateNode.containerInfo),h===null)throw Error(r(387));S=m.pendingProps;var D=m.memoizedState;P=D.element,t2(h,m),Lg(m,S,null,_);var X=m.memoizedState;if(S=X.cache,eu(m,qr,S),S!==D.cache&&XE(m,[qr],_,!0),Og(),S=X.element,D.isDehydrated)if(D={element:S,isDehydrated:!1,cache:X.cache},m.updateQueue.baseState=D,m.memoizedState=D,m.flags&256){m=CI(h,m,S,_);break e}else if(S!==P){P=Rs(Error(r(424)),m),Ng(P),m=CI(h,m,S,_);break e}else{switch(h=m.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(lr=Is(h.firstChild),Hi=m,wn=!0,Qc=null,Os=!0,_=S4(m,null,S,_),m.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Fd(),S===P){m=Ll(h,m,_);break e}Vi(h,m,S,_)}m=m.child}return m;case 26:return Iy(h,m),h===null?(_=$5(m.type,null,m.pendingProps,null))?m.memoizedState=_:wn||(_=m.type,h=m.pendingProps,S=ev(ue.current).createElement(_),S[yr]=m,S[Lr]=h,Gi(S,_,h),Oe(S),m.stateNode=S):m.memoizedState=$5(m.type,h.memoizedProps,m.pendingProps,h.memoizedState),null;case 27:return _e(m),h===null&&wn&&(S=m.stateNode=z5(m.type,m.pendingProps,ue.current),Hi=m,Os=!0,P=lr,fu(m.type)?(mA=P,lr=Is(S.firstChild)):lr=P),Vi(h,m,m.pendingProps.children,_),Iy(h,m),h===null&&(m.flags|=4194304),m.child;case 5:return h===null&&wn&&((P=S=lr)&&(S=are(S,m.type,m.pendingProps,Os),S!==null?(m.stateNode=S,Hi=m,lr=Is(S.firstChild),Os=!1,P=!0):P=!1),P||Jc(m)),_e(m),P=m.type,D=m.pendingProps,X=h!==null?h.memoizedProps:null,S=D.children,cA(P,D)?S=null:X!==null&&cA(P,X)&&(m.flags|=32),m.memoizedState!==null&&(P=l2(h,m,vne,null,null,_),nx._currentValue=P),Iy(h,m),Vi(h,m,S,_),m.child;case 6:return h===null&&wn&&((h=_=lr)&&(_=sre(_,m.pendingProps,Os),_!==null?(m.stateNode=_,Hi=m,lr=null,h=!0):h=!1),h||Jc(m)),null;case 13:return NI(h,m,_);case 4:return Re(m,m.stateNode.containerInfo),S=m.pendingProps,h===null?m.child=Vd(m,null,S,_):Vi(h,m,S,_),m.child;case 11:return vI(h,m,m.type,m.pendingProps,_);case 7:return Vi(h,m,m.pendingProps,_),m.child;case 8:return Vi(h,m,m.pendingProps.children,_),m.child;case 12:return Vi(h,m,m.pendingProps.children,_),m.child;case 10:return S=m.pendingProps,eu(m,m.type,S.value),Vi(h,m,S.children,_),m.child;case 9:return P=m.type._context,S=m.pendingProps.children,zd(m),P=$i(P),S=S(P),m.flags|=1,Vi(h,m,S,_),m.child;case 14:return _I(h,m,m.type,m.pendingProps,_);case 15:return wI(h,m,m.type,m.pendingProps,_);case 19:return PI(h,m,_);case 31:return Cne(h,m,_);case 22:return SI(h,m,_,m.pendingProps);case 24:return zd(m),S=$i(qr),h===null?(P=QE(),P===null&&(P=er,D=YE(),P.pooledCache=D,D.refCount++,D!==null&&(P.pooledCacheLanes|=_),P=D),m.memoizedState={parent:S,cache:P},e2(m),eu(m,qr,P)):((h.lanes&_)!==0&&(t2(h,m),Lg(m,null,null,_),Og()),P=h.memoizedState,D=m.memoizedState,P.parent!==S?(P={parent:S,cache:S},m.memoizedState=P,m.lanes===0&&(m.memoizedState=m.updateQueue.baseState=P),eu(m,qr,S)):(S=D.cache,eu(m,qr,S),S!==P.cache&&XE(m,[qr],_,!0))),Vi(h,m,m.pendingProps.children,_),m.child;case 29:throw m.pendingProps}throw Error(r(156,m.tag))}function Il(h){h.flags|=4}function L2(h,m,_,S,P){if((m=(h.mode&32)!==0)&&(m=!1),m){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(a5())h.flags|=8192;else throw $d=wy,JE}else h.flags&=-16777217}function jI(h,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!K5(m))if(a5())h.flags|=8192;else throw $d=wy,JE}function Uy(h,m){m!==null&&(h.flags|=4),h.flags&16384&&(m=h.tag!==22?xt():536870912,h.lanes|=m,Hf|=m)}function Hg(h,m){if(!wn)switch(h.tailMode){case"hidden":m=h.tail;for(var _=null;m!==null;)m.alternate!==null&&(_=m),m=m.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var S=null;_!==null;)_.alternate!==null&&(S=_),_=_.sibling;S===null?m||h.tail===null?h.tail=null:h.tail.sibling=null:S.sibling=null}}function cr(h){var m=h.alternate!==null&&h.alternate.child===h.child,_=0,S=0;if(m)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags&65011712,S|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,S|=P.subtreeFlags,S|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=S,h.childLanes=_,m}function kne(h,m,_){var S=m.pendingProps;switch(VE(m),m.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return cr(m),null;case 1:return cr(m),null;case 3:return _=m.stateNode,S=null,h!==null&&(S=h.memoizedState.cache),m.memoizedState.cache!==S&&(m.flags|=2048),jl(qr),Z(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Nf(m)?Il(m):h===null||h.memoizedState.isDehydrated&&(m.flags&256)===0||(m.flags|=1024,WE())),cr(m),null;case 26:var P=m.type,D=m.memoizedState;return h===null?(Il(m),D!==null?(cr(m),jI(m,D)):(cr(m),L2(m,P,null,S,_))):D?D!==h.memoizedState?(Il(m),cr(m),jI(m,D)):(cr(m),m.flags&=-16777217):(h=h.memoizedProps,h!==S&&Il(m),cr(m),L2(m,P,h,S,_)),null;case 27:if(Le(m),_=ue.current,P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==S&&Il(m);else{if(!S){if(m.stateNode===null)throw Error(r(166));return cr(m),null}h=ie.current,Nf(m)?h4(m):(h=z5(P,S,_),m.stateNode=h,Il(m))}return cr(m),null;case 5:if(Le(m),P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==S&&Il(m);else{if(!S){if(m.stateNode===null)throw Error(r(166));return cr(m),null}if(D=ie.current,Nf(m))h4(m);else{var X=ev(ue.current);switch(D){case 1:D=X.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:D=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":D=X.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":D=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":D=X.createElement("div"),D.innerHTML="<script><\/script>",D=D.removeChild(D.firstChild);break;case"select":D=typeof S.is=="string"?X.createElement("select",{is:S.is}):X.createElement("select"),S.multiple?D.multiple=!0:S.size&&(D.size=S.size);break;default:D=typeof S.is=="string"?X.createElement(P,{is:S.is}):X.createElement(P)}}D[yr]=m,D[Lr]=S;e:for(X=m.child;X!==null;){if(X.tag===5||X.tag===6)D.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===m)break e;for(;X.sibling===null;){if(X.return===null||X.return===m)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}m.stateNode=D;e:switch(Gi(D,P,S),P){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&Il(m)}}return cr(m),L2(m,m.type,h===null?null:h.memoizedProps,m.pendingProps,_),null;case 6:if(h&&m.stateNode!=null)h.memoizedProps!==S&&Il(m);else{if(typeof S!="string"&&m.stateNode===null)throw Error(r(166));if(h=ue.current,Nf(m)){if(h=m.stateNode,_=m.memoizedProps,S=null,P=Hi,P!==null)switch(P.tag){case 27:case 5:S=P.memoizedProps}h[yr]=m,h=!!(h.nodeValue===_||S!==null&&S.suppressHydrationWarning===!0||N5(h.nodeValue,_)),h||Jc(m,!0)}else h=ev(h).createTextNode(S),h[yr]=m,m.stateNode=h}return cr(m),null;case 31:if(_=m.memoizedState,h===null||h.memoizedState!==null){if(S=Nf(m),_!==null){if(h===null){if(!S)throw Error(r(318));if(h=m.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[yr]=m}else Fd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;cr(m),h=!1}else _=WE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return m.flags&256?(us(m),m):(us(m),null);if((m.flags&128)!==0)throw Error(r(558))}return cr(m),null;case 13:if(S=m.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Nf(m),S!==null&&S.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=m.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[yr]=m}else Fd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;cr(m),P=!1}else P=WE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return m.flags&256?(us(m),m):(us(m),null)}return us(m),(m.flags&128)!==0?(m.lanes=_,m):(_=S!==null,h=h!==null&&h.memoizedState!==null,_&&(S=m.child,P=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(P=S.alternate.memoizedState.cachePool.pool),D=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(D=S.memoizedState.cachePool.pool),D!==P&&(S.flags|=2048)),_!==h&&_&&(m.child.flags|=8192),Uy(m,m.updateQueue),cr(m),null);case 4:return Z(),h===null&&iA(m.stateNode.containerInfo),cr(m),null;case 10:return jl(m.type),cr(m),null;case 19:if(H(Fr),S=m.memoizedState,S===null)return cr(m),null;if(P=(m.flags&128)!==0,D=S.rendering,D===null)if(P)Hg(S,!1);else{if(kr!==0||h!==null&&(h.flags&128)!==0)for(h=m.child;h!==null;){if(D=Ay(h),D!==null){for(m.flags|=128,Hg(S,!1),h=D.updateQueue,m.updateQueue=h,Uy(m,h),m.subtreeFlags=0,h=_,_=m.child;_!==null;)o4(_,h),_=_.sibling;return ee(Fr,Fr.current&1|2),wn&&Pl(m,S.treeForkCount),m.child}h=h.sibling}S.tail!==null&&L()>Vy&&(m.flags|=128,P=!0,Hg(S,!1),m.lanes=4194304)}else{if(!P)if(h=Ay(D),h!==null){if(m.flags|=128,P=!0,h=h.updateQueue,m.updateQueue=h,Uy(m,h),Hg(S,!0),S.tail===null&&S.tailMode==="hidden"&&!D.alternate&&!wn)return cr(m),null}else 2*L()-S.renderingStartTime>Vy&&_!==536870912&&(m.flags|=128,P=!0,Hg(S,!1),m.lanes=4194304);S.isBackwards?(D.sibling=m.child,m.child=D):(h=S.last,h!==null?h.sibling=D:m.child=D,S.last=D)}return S.tail!==null?(h=S.tail,S.rendering=h,S.tail=h.sibling,S.renderingStartTime=L(),h.sibling=null,_=Fr.current,ee(Fr,P?_&1|2:_&1),wn&&Pl(m,S.treeForkCount),h):(cr(m),null);case 22:case 23:return us(m),a2(),S=m.memoizedState!==null,h!==null?h.memoizedState!==null!==S&&(m.flags|=8192):S&&(m.flags|=8192),S?(_&536870912)!==0&&(m.flags&128)===0&&(cr(m),m.subtreeFlags&6&&(m.flags|=8192)):cr(m),_=m.updateQueue,_!==null&&Uy(m,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),S=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(S=m.memoizedState.cachePool.pool),S!==_&&(m.flags|=2048),h!==null&&H(Bd),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),jl(qr),cr(m),null;case 25:return null;case 30:return null}throw Error(r(156,m.tag))}function Pne(h,m){switch(VE(m),m.tag){case 1:return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 3:return jl(qr),Z(),h=m.flags,(h&65536)!==0&&(h&128)===0?(m.flags=h&-65537|128,m):null;case 26:case 27:case 5:return Le(m),null;case 31:if(m.memoizedState!==null){if(us(m),m.alternate===null)throw Error(r(340));Fd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 13:if(us(m),h=m.memoizedState,h!==null&&h.dehydrated!==null){if(m.alternate===null)throw Error(r(340));Fd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 19:return H(Fr),null;case 4:return Z(),null;case 10:return jl(m.type),null;case 22:case 23:return us(m),a2(),h!==null&&H(Bd),h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 24:return jl(qr),null;case 25:return null;default:return null}}function DI(h,m){switch(VE(m),m.tag){case 3:jl(qr),Z();break;case 26:case 27:case 5:Le(m);break;case 4:Z();break;case 31:m.memoizedState!==null&&us(m);break;case 13:us(m);break;case 19:H(Fr);break;case 10:jl(m.type);break;case 22:case 23:us(m),a2(),h!==null&&H(Bd);break;case 24:jl(qr)}}function $g(h,m){try{var _=m.updateQueue,S=_!==null?_.lastEffect:null;if(S!==null){var P=S.next;_=P;do{if((_.tag&h)===h){S=void 0;var D=_.create,X=_.inst;S=D(),X.destroy=S}_=_.next}while(_!==P)}}catch(le){Fn(m,m.return,le)}}function su(h,m,_){try{var S=m.updateQueue,P=S!==null?S.lastEffect:null;if(P!==null){var D=P.next;S=D;do{if((S.tag&h)===h){var X=S.inst,le=X.destroy;if(le!==void 0){X.destroy=void 0,P=m;var Te=_,Ze=le;try{Ze()}catch(ct){Fn(P,Te,ct)}}}S=S.next}while(S!==D)}}catch(ct){Fn(m,m.return,ct)}}function OI(h){var m=h.updateQueue;if(m!==null){var _=h.stateNode;try{E4(m,_)}catch(S){Fn(h,h.return,S)}}}function LI(h,m,_){_.props=Wd(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(S){Fn(h,m,S)}}function Vg(h,m){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var S=h.stateNode;break;case 30:S=h.stateNode;break;default:S=h.stateNode}typeof _=="function"?h.refCleanup=_(S):_.current=S}}catch(P){Fn(h,m,P)}}function qo(h,m){var _=h.ref,S=h.refCleanup;if(_!==null)if(typeof S=="function")try{S()}catch(P){Fn(h,m,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Fn(h,m,P)}else _.current=null}function II(h){var m=h.type,_=h.memoizedProps,S=h.stateNode;try{e:switch(m){case"button":case"input":case"select":case"textarea":_.autoFocus&&S.focus();break e;case"img":_.src?S.src=_.src:_.srcSet&&(S.srcset=_.srcSet)}}catch(P){Fn(h,h.return,P)}}function I2(h,m,_){try{var S=h.stateNode;Jne(S,h.type,_,m),S[Lr]=m}catch(P){Fn(h,h.return,P)}}function FI(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&fu(h.type)||h.tag===4}function F2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||FI(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&fu(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function U2(h,m,_){var S=h.tag;if(S===5||S===6)h=h.stateNode,m?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,m):(m=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,m.appendChild(h),_=_._reactRootContainer,_!=null||m.onclick!==null||(m.onclick=Cl));else if(S!==4&&(S===27&&fu(h.type)&&(_=h.stateNode,m=null),h=h.child,h!==null))for(U2(h,m,_),h=h.sibling;h!==null;)U2(h,m,_),h=h.sibling}function zy(h,m,_){var S=h.tag;if(S===5||S===6)h=h.stateNode,m?_.insertBefore(h,m):_.appendChild(h);else if(S!==4&&(S===27&&fu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(zy(h,m,_),h=h.sibling;h!==null;)zy(h,m,_),h=h.sibling}function UI(h){var m=h.stateNode,_=h.memoizedProps;try{for(var S=h.type,P=m.attributes;P.length;)m.removeAttributeNode(P[0]);Gi(m,S,_),m[yr]=h,m[Lr]=_}catch(D){Fn(h,h.return,D)}}var Fl=!1,Yr=!1,z2=!1,zI=typeof WeakSet=="function"?WeakSet:Set,Ci=null;function Rne(h,m){if(h=h.containerInfo,oA=ov,h=QL(h),jE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var S=_.getSelection&&_.getSelection();if(S&&S.rangeCount!==0){_=S.anchorNode;var P=S.anchorOffset,D=S.focusNode;S=S.focusOffset;try{_.nodeType,D.nodeType}catch{_=null;break e}var X=0,le=-1,Te=-1,Ze=0,ct=0,ht=h,Je=null;t:for(;;){for(var st;ht!==_||P!==0&&ht.nodeType!==3||(le=X+P),ht!==D||S!==0&&ht.nodeType!==3||(Te=X+S),ht.nodeType===3&&(X+=ht.nodeValue.length),(st=ht.firstChild)!==null;)Je=ht,ht=st;for(;;){if(ht===h)break t;if(Je===_&&++Ze===P&&(le=X),Je===D&&++ct===S&&(Te=X),(st=ht.nextSibling)!==null)break;ht=Je,Je=ht.parentNode}ht=st}_=le===-1||Te===-1?null:{start:le,end:Te}}else _=null}_=_||{start:0,end:0}}else _=null;for(lA={focusedElem:h,selectionRange:_},ov=!1,Ci=m;Ci!==null;)if(m=Ci,h=m.child,(m.subtreeFlags&1028)!==0&&h!==null)h.return=m,Ci=h;else for(;Ci!==null;){switch(m=Ci,D=m.alternate,h=m.flags,m.tag){case 0:if((h&4)!==0&&(h=m.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&D!==null){h=void 0,_=m,P=D.memoizedProps,D=D.memoizedState,S=_.stateNode;try{var Dt=Wd(_.type,P);h=S.getSnapshotBeforeUpdate(Dt,D),S.__reactInternalSnapshotBeforeUpdate=h}catch(Gt){Fn(_,_.return,Gt)}}break;case 3:if((h&1024)!==0){if(h=m.stateNode.containerInfo,_=h.nodeType,_===9)dA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":dA(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=m.sibling,h!==null){h.return=m.return,Ci=h;break}Ci=m.return}}function BI(h,m,_){var S=_.flags;switch(_.tag){case 0:case 11:case 15:zl(h,_),S&4&&$g(5,_);break;case 1:if(zl(h,_),S&4)if(h=_.stateNode,m===null)try{h.componentDidMount()}catch(X){Fn(_,_.return,X)}else{var P=Wd(_.type,m.memoizedProps);m=m.memoizedState;try{h.componentDidUpdate(P,m,h.__reactInternalSnapshotBeforeUpdate)}catch(X){Fn(_,_.return,X)}}S&64&&OI(_),S&512&&Vg(_,_.return);break;case 3:if(zl(h,_),S&64&&(h=_.updateQueue,h!==null)){if(m=null,_.child!==null)switch(_.child.tag){case 27:case 5:m=_.child.stateNode;break;case 1:m=_.child.stateNode}try{E4(h,m)}catch(X){Fn(_,_.return,X)}}break;case 27:m===null&&S&4&&UI(_);case 26:case 5:zl(h,_),m===null&&S&4&&II(_),S&512&&Vg(_,_.return);break;case 12:zl(h,_);break;case 31:zl(h,_),S&4&&VI(h,_);break;case 13:zl(h,_),S&4&&GI(h,_),S&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Bne.bind(null,_),ore(h,_))));break;case 22:if(S=_.memoizedState!==null||Fl,!S){m=m!==null&&m.memoizedState!==null||Yr,P=Fl;var D=Yr;Fl=S,(Yr=m)&&!D?Bl(h,_,(_.subtreeFlags&8772)!==0):zl(h,_),Fl=P,Yr=D}break;case 30:break;default:zl(h,_)}}function HI(h){var m=h.alternate;m!==null&&(h.alternate=null,HI(m)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(m=h.stateNode,m!==null&&nt(m)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var mr=null,Ia=!1;function Ul(h,m,_){for(_=_.child;_!==null;)$I(h,m,_),_=_.sibling}function $I(h,m,_){if(oe&&typeof oe.onCommitFiberUnmount=="function")try{oe.onCommitFiberUnmount(Ue,_)}catch{}switch(_.tag){case 26:Yr||qo(_,m),Ul(h,m,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Yr||qo(_,m);var S=mr,P=Ia;fu(_.type)&&(mr=_.stateNode,Ia=!1),Ul(h,m,_),Jg(_.stateNode),mr=S,Ia=P;break;case 5:Yr||qo(_,m);case 6:if(S=mr,P=Ia,mr=null,Ul(h,m,_),mr=S,Ia=P,mr!==null)if(Ia)try{(mr.nodeType===9?mr.body:mr.nodeName==="HTML"?mr.ownerDocument.body:mr).removeChild(_.stateNode)}catch(D){Fn(_,m,D)}else try{mr.removeChild(_.stateNode)}catch(D){Fn(_,m,D)}break;case 18:mr!==null&&(Ia?(h=mr,O5(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Yf(h)):O5(mr,_.stateNode));break;case 4:S=mr,P=Ia,mr=_.stateNode.containerInfo,Ia=!0,Ul(h,m,_),mr=S,Ia=P;break;case 0:case 11:case 14:case 15:su(2,_,m),Yr||su(4,_,m),Ul(h,m,_);break;case 1:Yr||(qo(_,m),S=_.stateNode,typeof S.componentWillUnmount=="function"&&LI(_,m,S)),Ul(h,m,_);break;case 21:Ul(h,m,_);break;case 22:Yr=(S=Yr)||_.memoizedState!==null,Ul(h,m,_),Yr=S;break;default:Ul(h,m,_)}}function VI(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Yf(h)}catch(_){Fn(m,m.return,_)}}}function GI(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Yf(h)}catch(_){Fn(m,m.return,_)}}function jne(h){switch(h.tag){case 31:case 13:case 19:var m=h.stateNode;return m===null&&(m=h.stateNode=new zI),m;case 22:return h=h.stateNode,m=h._retryCache,m===null&&(m=h._retryCache=new zI),m;default:throw Error(r(435,h.tag))}}function By(h,m){var _=jne(h);m.forEach(function(S){if(!_.has(S)){_.add(S);var P=Hne.bind(null,h,S);S.then(P,P)}})}function Fa(h,m){var _=m.deletions;if(_!==null)for(var S=0;S<_.length;S++){var P=_[S],D=h,X=m,le=X;e:for(;le!==null;){switch(le.tag){case 27:if(fu(le.type)){mr=le.stateNode,Ia=!1;break e}break;case 5:mr=le.stateNode,Ia=!1;break e;case 3:case 4:mr=le.stateNode.containerInfo,Ia=!0;break e}le=le.return}if(mr===null)throw Error(r(160));$I(D,X,P),mr=null,Ia=!1,D=P.alternate,D!==null&&(D.return=null),P.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)WI(m,h),m=m.sibling}var yo=null;function WI(h,m){var _=h.alternate,S=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Fa(m,h),Ua(h),S&4&&(su(3,h,h.return),$g(3,h),su(5,h,h.return));break;case 1:Fa(m,h),Ua(h),S&512&&(Yr||_===null||qo(_,_.return)),S&64&&Fl&&(h=h.updateQueue,h!==null&&(S=h.callbacks,S!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?S:_.concat(S))));break;case 26:var P=yo;if(Fa(m,h),Ua(h),S&512&&(Yr||_===null||qo(_,_.return)),S&4){var D=_!==null?_.memoizedState:null;if(S=h.memoizedState,_===null)if(S===null)if(h.stateNode===null){e:{S=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(S){case"title":D=P.getElementsByTagName("title")[0],(!D||D[at]||D[yr]||D.namespaceURI==="http://www.w3.org/2000/svg"||D.hasAttribute("itemprop"))&&(D=P.createElement(S),P.head.insertBefore(D,P.querySelector("head > title"))),Gi(D,S,_),D[yr]=h,Oe(D),S=D;break e;case"link":var X=W5("link","href",P).get(S+(_.href||""));if(X){for(var le=0;le<X.length;le++)if(D=X[le],D.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&D.getAttribute("rel")===(_.rel==null?null:_.rel)&&D.getAttribute("title")===(_.title==null?null:_.title)&&D.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){X.splice(le,1);break t}}D=P.createElement(S),Gi(D,S,_),P.head.appendChild(D);break;case"meta":if(X=W5("meta","content",P).get(S+(_.content||""))){for(le=0;le<X.length;le++)if(D=X[le],D.getAttribute("content")===(_.content==null?null:""+_.content)&&D.getAttribute("name")===(_.name==null?null:_.name)&&D.getAttribute("property")===(_.property==null?null:_.property)&&D.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&D.getAttribute("charset")===(_.charSet==null?null:_.charSet)){X.splice(le,1);break t}}D=P.createElement(S),Gi(D,S,_),P.head.appendChild(D);break;default:throw Error(r(468,S))}D[yr]=h,Oe(D),S=D}h.stateNode=S}else q5(P,h.type,h.stateNode);else h.stateNode=G5(P,S,h.memoizedProps);else D!==S?(D===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):D.count--,S===null?q5(P,h.type,h.stateNode):G5(P,S,h.memoizedProps)):S===null&&h.stateNode!==null&&I2(h,h.memoizedProps,_.memoizedProps)}break;case 27:Fa(m,h),Ua(h),S&512&&(Yr||_===null||qo(_,_.return)),_!==null&&S&4&&I2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Fa(m,h),Ua(h),S&512&&(Yr||_===null||qo(_,_.return)),h.flags&32){P=h.stateNode;try{Vo(P,"")}catch(Dt){Fn(h,h.return,Dt)}}S&4&&h.stateNode!=null&&(P=h.memoizedProps,I2(h,P,_!==null?_.memoizedProps:P)),S&1024&&(z2=!0);break;case 6:if(Fa(m,h),Ua(h),S&4){if(h.stateNode===null)throw Error(r(162));S=h.memoizedProps,_=h.stateNode;try{_.nodeValue=S}catch(Dt){Fn(h,h.return,Dt)}}break;case 3:if(rv=null,P=yo,yo=tv(m.containerInfo),Fa(m,h),yo=P,Ua(h),S&4&&_!==null&&_.memoizedState.isDehydrated)try{Yf(m.containerInfo)}catch(Dt){Fn(h,h.return,Dt)}z2&&(z2=!1,qI(h));break;case 4:S=yo,yo=tv(h.stateNode.containerInfo),Fa(m,h),Ua(h),yo=S;break;case 12:Fa(m,h),Ua(h);break;case 31:Fa(m,h),Ua(h),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,By(h,S)));break;case 13:Fa(m,h),Ua(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&($y=L()),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,By(h,S)));break;case 22:P=h.memoizedState!==null;var Te=_!==null&&_.memoizedState!==null,Ze=Fl,ct=Yr;if(Fl=Ze||P,Yr=ct||Te,Fa(m,h),Yr=ct,Fl=Ze,Ua(h),S&8192)e:for(m=h.stateNode,m._visibility=P?m._visibility&-2:m._visibility|1,P&&(_===null||Te||Fl||Yr||qd(h)),_=null,m=h;;){if(m.tag===5||m.tag===26){if(_===null){Te=_=m;try{if(D=Te.stateNode,P)X=D.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{le=Te.stateNode;var ht=Te.memoizedProps.style,Je=ht!=null&&ht.hasOwnProperty("display")?ht.display:null;le.style.display=Je==null||typeof Je=="boolean"?"":(""+Je).trim()}}catch(Dt){Fn(Te,Te.return,Dt)}}}else if(m.tag===6){if(_===null){Te=m;try{Te.stateNode.nodeValue=P?"":Te.memoizedProps}catch(Dt){Fn(Te,Te.return,Dt)}}}else if(m.tag===18){if(_===null){Te=m;try{var st=Te.stateNode;P?L5(st,!0):L5(Te.stateNode,!1)}catch(Dt){Fn(Te,Te.return,Dt)}}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===h)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break e;for(;m.sibling===null;){if(m.return===null||m.return===h)break e;_===m&&(_=null),m=m.return}_===m&&(_=null),m.sibling.return=m.return,m=m.sibling}S&4&&(S=h.updateQueue,S!==null&&(_=S.retryQueue,_!==null&&(S.retryQueue=null,By(h,_))));break;case 19:Fa(m,h),Ua(h),S&4&&(S=h.updateQueue,S!==null&&(h.updateQueue=null,By(h,S)));break;case 30:break;case 21:break;default:Fa(m,h),Ua(h)}}function Ua(h){var m=h.flags;if(m&2){try{for(var _,S=h.return;S!==null;){if(FI(S)){_=S;break}S=S.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,D=F2(h);zy(h,D,P);break;case 5:var X=_.stateNode;_.flags&32&&(Vo(X,""),_.flags&=-33);var le=F2(h);zy(h,le,X);break;case 3:case 4:var Te=_.stateNode.containerInfo,Ze=F2(h);U2(h,Ze,Te);break;default:throw Error(r(161))}}catch(ct){Fn(h,h.return,ct)}h.flags&=-3}m&4096&&(h.flags&=-4097)}function qI(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var m=h;qI(m),m.tag===5&&m.flags&1024&&m.stateNode.reset(),h=h.sibling}}function zl(h,m){if(m.subtreeFlags&8772)for(m=m.child;m!==null;)BI(h,m.alternate,m),m=m.sibling}function qd(h){for(h=h.child;h!==null;){var m=h;switch(m.tag){case 0:case 11:case 14:case 15:su(4,m,m.return),qd(m);break;case 1:qo(m,m.return);var _=m.stateNode;typeof _.componentWillUnmount=="function"&&LI(m,m.return,_),qd(m);break;case 27:Jg(m.stateNode);case 26:case 5:qo(m,m.return),qd(m);break;case 22:m.memoizedState===null&&qd(m);break;case 30:qd(m);break;default:qd(m)}h=h.sibling}}function Bl(h,m,_){for(_=_&&(m.subtreeFlags&8772)!==0,m=m.child;m!==null;){var S=m.alternate,P=h,D=m,X=D.flags;switch(D.tag){case 0:case 11:case 15:Bl(P,D,_),$g(4,D);break;case 1:if(Bl(P,D,_),S=D,P=S.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Ze){Fn(S,S.return,Ze)}if(S=D,P=S.updateQueue,P!==null){var le=S.stateNode;try{var Te=P.shared.hiddenCallbacks;if(Te!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Te.length;P++)M4(Te[P],le)}catch(Ze){Fn(S,S.return,Ze)}}_&&X&64&&OI(D),Vg(D,D.return);break;case 27:UI(D);case 26:case 5:Bl(P,D,_),_&&S===null&&X&4&&II(D),Vg(D,D.return);break;case 12:Bl(P,D,_);break;case 31:Bl(P,D,_),_&&X&4&&VI(P,D);break;case 13:Bl(P,D,_),_&&X&4&&GI(P,D);break;case 22:D.memoizedState===null&&Bl(P,D,_),Vg(D,D.return);break;case 30:break;default:Bl(P,D,_)}m=m.sibling}}function B2(h,m){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(h=m.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&kg(_))}function H2(h,m){h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&kg(h))}function vo(h,m,_,S){if(m.subtreeFlags&10256)for(m=m.child;m!==null;)KI(h,m,_,S),m=m.sibling}function KI(h,m,_,S){var P=m.flags;switch(m.tag){case 0:case 11:case 15:vo(h,m,_,S),P&2048&&$g(9,m);break;case 1:vo(h,m,_,S);break;case 3:vo(h,m,_,S),P&2048&&(h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&kg(h)));break;case 12:if(P&2048){vo(h,m,_,S),h=m.stateNode;try{var D=m.memoizedProps,X=D.id,le=D.onPostCommit;typeof le=="function"&&le(X,m.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Te){Fn(m,m.return,Te)}}else vo(h,m,_,S);break;case 31:vo(h,m,_,S);break;case 13:vo(h,m,_,S);break;case 23:break;case 22:D=m.stateNode,X=m.alternate,m.memoizedState!==null?D._visibility&2?vo(h,m,_,S):Gg(h,m):D._visibility&2?vo(h,m,_,S):(D._visibility|=2,Uf(h,m,_,S,(m.subtreeFlags&10256)!==0||!1)),P&2048&&B2(X,m);break;case 24:vo(h,m,_,S),P&2048&&H2(m.alternate,m);break;default:vo(h,m,_,S)}}function Uf(h,m,_,S,P){for(P=P&&((m.subtreeFlags&10256)!==0||!1),m=m.child;m!==null;){var D=h,X=m,le=_,Te=S,Ze=X.flags;switch(X.tag){case 0:case 11:case 15:Uf(D,X,le,Te,P),$g(8,X);break;case 23:break;case 22:var ct=X.stateNode;X.memoizedState!==null?ct._visibility&2?Uf(D,X,le,Te,P):Gg(D,X):(ct._visibility|=2,Uf(D,X,le,Te,P)),P&&Ze&2048&&B2(X.alternate,X);break;case 24:Uf(D,X,le,Te,P),P&&Ze&2048&&H2(X.alternate,X);break;default:Uf(D,X,le,Te,P)}m=m.sibling}}function Gg(h,m){if(m.subtreeFlags&10256)for(m=m.child;m!==null;){var _=h,S=m,P=S.flags;switch(S.tag){case 22:Gg(_,S),P&2048&&B2(S.alternate,S);break;case 24:Gg(_,S),P&2048&&H2(S.alternate,S);break;default:Gg(_,S)}m=m.sibling}}var Wg=8192;function zf(h,m,_){if(h.subtreeFlags&Wg)for(h=h.child;h!==null;)XI(h,m,_),h=h.sibling}function XI(h,m,_){switch(h.tag){case 26:zf(h,m,_),h.flags&Wg&&h.memoizedState!==null&&yre(_,yo,h.memoizedState,h.memoizedProps);break;case 5:zf(h,m,_);break;case 3:case 4:var S=yo;yo=tv(h.stateNode.containerInfo),zf(h,m,_),yo=S;break;case 22:h.memoizedState===null&&(S=h.alternate,S!==null&&S.memoizedState!==null?(S=Wg,Wg=16777216,zf(h,m,_),Wg=S):zf(h,m,_));break;default:zf(h,m,_)}}function YI(h){var m=h.alternate;if(m!==null&&(h=m.child,h!==null)){m.child=null;do m=h.sibling,h.sibling=null,h=m;while(h!==null)}}function qg(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var S=m[_];Ci=S,QI(S,h)}YI(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)ZI(h),h=h.sibling}function ZI(h){switch(h.tag){case 0:case 11:case 15:qg(h),h.flags&2048&&su(9,h,h.return);break;case 3:qg(h);break;case 12:qg(h);break;case 22:var m=h.stateNode;h.memoizedState!==null&&m._visibility&2&&(h.return===null||h.return.tag!==13)?(m._visibility&=-3,Hy(h)):qg(h);break;default:qg(h)}}function Hy(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var S=m[_];Ci=S,QI(S,h)}YI(h)}for(h=h.child;h!==null;){switch(m=h,m.tag){case 0:case 11:case 15:su(8,m,m.return),Hy(m);break;case 22:_=m.stateNode,_._visibility&2&&(_._visibility&=-3,Hy(m));break;default:Hy(m)}h=h.sibling}}function QI(h,m){for(;Ci!==null;){var _=Ci;switch(_.tag){case 0:case 11:case 15:su(8,_,m);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var S=_.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:kg(_.memoizedState.cache)}if(S=_.child,S!==null)S.return=_,Ci=S;else e:for(_=h;Ci!==null;){S=Ci;var P=S.sibling,D=S.return;if(HI(S),S===_){Ci=null;break e}if(P!==null){P.return=D,Ci=P;break e}Ci=D}}}var Dne={getCacheForType:function(h){var m=$i(qr),_=m.data.get(h);return _===void 0&&(_=h(),m.data.set(h,_)),_},cacheSignal:function(){return $i(qr).controller.signal}},One=typeof WeakMap=="function"?WeakMap:Map,Pn=0,er=null,mn=null,yn=0,In=0,ds=null,ou=!1,Bf=!1,$2=!1,Hl=0,kr=0,lu=0,Kd=0,V2=0,hs=0,Hf=0,Kg=null,za=null,G2=!1,$y=0,JI=0,Vy=1/0,Gy=null,cu=null,li=0,uu=null,$f=null,$l=0,W2=0,q2=null,e5=null,Xg=0,K2=null;function fs(){return(Pn&2)!==0&&yn!==0?yn&-yn:K.T!==null?eA():zi()}function t5(){if(hs===0)if((yn&536870912)===0||wn){var h=ge;ge<<=1,(ge&3932160)===0&&(ge=262144),hs=h}else hs=536870912;return h=cs.current,h!==null&&(h.flags|=32),hs}function Ba(h,m,_){(h===er&&(In===2||In===9)||h.cancelPendingCommit!==null)&&(Vf(h,0),du(h,yn,hs,!1)),Qt(h,_),((Pn&2)===0||h!==er)&&(h===er&&((Pn&2)===0&&(Kd|=_),kr===4&&du(h,yn,hs,!1)),Ko(h))}function n5(h,m,_){if((Pn&6)!==0)throw Error(r(327));var S=!_&&(m&127)===0&&(m&h.expiredLanes)===0||de(h,m),P=S?Fne(h,m):Y2(h,m,!0),D=S;do{if(P===0){Bf&&!S&&du(h,m,0,!1);break}else{if(_=h.current.alternate,D&&!Lne(_)){P=Y2(h,m,!1),D=!1;continue}if(P===2){if(D=m,h.errorRecoveryDisabledLanes&D)var X=0;else X=h.pendingLanes&-536870913,X=X!==0?X:X&536870912?536870912:0;if(X!==0){m=X;e:{var le=h;P=Kg;var Te=le.current.memoizedState.isDehydrated;if(Te&&(Vf(le,X).flags|=256),X=Y2(le,X,!1),X!==2){if($2&&!Te){le.errorRecoveryDisabledLanes|=D,Kd|=D,P=4;break e}D=za,za=P,D!==null&&(za===null?za=D:za.push.apply(za,D))}P=X}if(D=!1,P!==2)continue}}if(P===1){Vf(h,0),du(h,m,0,!0);break}e:{switch(S=h,D=P,D){case 0:case 1:throw Error(r(345));case 4:if((m&4194048)!==m)break;case 6:du(S,m,hs,!ou);break e;case 2:za=null;break;case 3:case 5:break;default:throw Error(r(329))}if((m&62914560)===m&&(P=$y+300-L(),10<P)){if(du(S,m,hs,!ou),ve(S,0,!0)!==0)break e;$l=m,S.timeoutHandle=j5(r5.bind(null,S,_,za,Gy,G2,m,hs,Kd,Hf,ou,D,"Throttled",-0,0),P);break e}r5(S,_,za,Gy,G2,m,hs,Kd,Hf,ou,D,null,-0,0)}}break}while(!0);Ko(h)}function r5(h,m,_,S,P,D,X,le,Te,Ze,ct,ht,Je,st){if(h.timeoutHandle=-1,ht=m.subtreeFlags,ht&8192||(ht&16785408)===16785408){ht={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Cl},XI(m,D,ht);var Dt=(D&62914560)===D?$y-L():(D&4194048)===D?JI-L():0;if(Dt=vre(ht,Dt),Dt!==null){$l=D,h.cancelPendingCommit=Dt(d5.bind(null,h,m,D,_,S,P,X,le,Te,ct,ht,null,Je,st)),du(h,D,X,!Ze);return}}d5(h,m,D,_,S,P,X,le,Te)}function Lne(h){for(var m=h;;){var _=m.tag;if((_===0||_===11||_===15)&&m.flags&16384&&(_=m.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var S=0;S<_.length;S++){var P=_[S],D=P.getSnapshot;P=P.value;try{if(!ss(D(),P))return!1}catch{return!1}}if(_=m.child,m.subtreeFlags&16384&&_!==null)_.return=m,m=_;else{if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return!0;m=m.return}m.sibling.return=m.return,m=m.sibling}}return!0}function du(h,m,_,S){m&=~V2,m&=~Kd,h.suspendedLanes|=m,h.pingedLanes&=~m,S&&(h.warmLanes|=m),S=h.expirationTimes;for(var P=m;0<P;){var D=31-$e(P),X=1<<D;S[D]=-1,P&=~X}_!==0&&Vt(h,_,m)}function Wy(){return(Pn&6)===0?(Yg(0),!1):!0}function X2(){if(mn!==null){if(In===0)var h=mn.return;else h=mn,Rl=Ud=null,d2(h),Df=null,Rg=0,h=mn;for(;h!==null;)DI(h.alternate,h),h=h.return;mn=null}}function Vf(h,m){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,nre(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),$l=0,X2(),er=h,mn=_=kl(h.current,null),yn=m,In=0,ds=null,ou=!1,Bf=de(h,m),$2=!1,Hf=hs=V2=Kd=lu=kr=0,za=Kg=null,G2=!1,(m&8)!==0&&(m|=m&32);var S=h.entangledLanes;if(S!==0)for(h=h.entanglements,S&=m;0<S;){var P=31-$e(S),D=1<<P;m|=h[P],S&=~D}return Hl=m,fy(),_}function i5(h,m){nn=null,K.H=zg,m===jf||m===_y?(m=v4(),In=3):m===JE?(m=v4(),In=4):In=m===T2?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,ds=m,mn===null&&(kr=1,Oy(h,Rs(m,h.current)))}function a5(){var h=cs.current;return h===null?!0:(yn&4194048)===yn?Ls===null:(yn&62914560)===yn||(yn&536870912)!==0?h===Ls:!1}function s5(){var h=K.H;return K.H=zg,h===null?zg:h}function o5(){var h=K.A;return K.A=Dne,h}function qy(){kr=4,ou||(yn&4194048)!==yn&&cs.current!==null||(Bf=!0),(lu&134217727)===0&&(Kd&134217727)===0||er===null||du(er,yn,hs,!1)}function Y2(h,m,_){var S=Pn;Pn|=2;var P=s5(),D=o5();(er!==h||yn!==m)&&(Gy=null,Vf(h,m)),m=!1;var X=kr;e:do try{if(In!==0&&mn!==null){var le=mn,Te=ds;switch(In){case 8:X2(),X=6;break e;case 3:case 2:case 9:case 6:cs.current===null&&(m=!0);var Ze=In;if(In=0,ds=null,Gf(h,le,Te,Ze),_&&Bf){X=0;break e}break;default:Ze=In,In=0,ds=null,Gf(h,le,Te,Ze)}}Ine(),X=kr;break}catch(ct){i5(h,ct)}while(!0);return m&&h.shellSuspendCounter++,Rl=Ud=null,Pn=S,K.H=P,K.A=D,mn===null&&(er=null,yn=0,fy()),X}function Ine(){for(;mn!==null;)l5(mn)}function Fne(h,m){var _=Pn;Pn|=2;var S=s5(),P=o5();er!==h||yn!==m?(Gy=null,Vy=L()+500,Vf(h,m)):Bf=de(h,m);e:do try{if(In!==0&&mn!==null){m=mn;var D=ds;t:switch(In){case 1:In=0,ds=null,Gf(h,m,D,1);break;case 2:case 9:if(b4(D)){In=0,ds=null,c5(m);break}m=function(){In!==2&&In!==9||er!==h||(In=7),Ko(h)},D.then(m,m);break e;case 3:In=7;break e;case 4:In=5;break e;case 7:b4(D)?(In=0,ds=null,c5(m)):(In=0,ds=null,Gf(h,m,D,7));break;case 5:var X=null;switch(mn.tag){case 26:X=mn.memoizedState;case 5:case 27:var le=mn;if(X?K5(X):le.stateNode.complete){In=0,ds=null;var Te=le.sibling;if(Te!==null)mn=Te;else{var Ze=le.return;Ze!==null?(mn=Ze,Ky(Ze)):mn=null}break t}}In=0,ds=null,Gf(h,m,D,5);break;case 6:In=0,ds=null,Gf(h,m,D,6);break;case 8:X2(),kr=6;break e;default:throw Error(r(462))}}Une();break}catch(ct){i5(h,ct)}while(!0);return Rl=Ud=null,K.H=S,K.A=P,Pn=_,mn!==null?0:(er=null,yn=0,fy(),kr)}function Une(){for(;mn!==null&&!Se();)l5(mn)}function l5(h){var m=RI(h.alternate,h,Hl);h.memoizedProps=h.pendingProps,m===null?Ky(h):mn=m}function c5(h){var m=h,_=m.alternate;switch(m.tag){case 15:case 0:m=AI(_,m,m.pendingProps,m.type,void 0,yn);break;case 11:m=AI(_,m,m.pendingProps,m.type.render,m.ref,yn);break;case 5:d2(m);default:DI(_,m),m=mn=o4(m,Hl),m=RI(_,m,Hl)}h.memoizedProps=h.pendingProps,m===null?Ky(h):mn=m}function Gf(h,m,_,S){Rl=Ud=null,d2(m),Df=null,Rg=0;var P=m.return;try{if(Tne(h,P,m,_,yn)){kr=1,Oy(h,Rs(_,h.current)),mn=null;return}}catch(D){if(P!==null)throw mn=P,D;kr=1,Oy(h,Rs(_,h.current)),mn=null;return}m.flags&32768?(wn||S===1?h=!0:Bf||(yn&536870912)!==0?h=!1:(ou=h=!0,(S===2||S===9||S===3||S===6)&&(S=cs.current,S!==null&&S.tag===13&&(S.flags|=16384))),u5(m,h)):Ky(m)}function Ky(h){var m=h;do{if((m.flags&32768)!==0){u5(m,ou);return}h=m.return;var _=kne(m.alternate,m,Hl);if(_!==null){mn=_;return}if(m=m.sibling,m!==null){mn=m;return}mn=m=h}while(m!==null);kr===0&&(kr=5)}function u5(h,m){do{var _=Pne(h.alternate,h);if(_!==null){_.flags&=32767,mn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!m&&(h=h.sibling,h!==null)){mn=h;return}mn=h=_}while(h!==null);kr=6,mn=null}function d5(h,m,_,S,P,D,X,le,Te){h.cancelPendingCommit=null;do Xy();while(li!==0);if((Pn&6)!==0)throw Error(r(327));if(m!==null){if(m===h.current)throw Error(r(177));if(D=m.lanes|m.childLanes,D|=FE,Ot(h,_,D,X,le,Te),h===er&&(mn=er=null,yn=0),$f=m,uu=h,$l=_,W2=D,q2=P,e5=S,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,$ne(xe,function(){return g5(),null})):(h.callbackNode=null,h.callbackPriority=0),S=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||S){S=K.T,K.T=null,P=G.p,G.p=2,X=Pn,Pn|=4;try{Rne(h,m,_)}finally{Pn=X,G.p=P,K.T=S}}li=1,h5(),f5(),m5()}}function h5(){if(li===1){li=0;var h=uu,m=$f,_=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var S=G.p;G.p=2;var P=Pn;Pn|=4;try{WI(m,h);var D=lA,X=QL(h.containerInfo),le=D.focusedElem,Te=D.selectionRange;if(X!==le&&le&&le.ownerDocument&&ZL(le.ownerDocument.documentElement,le)){if(Te!==null&&jE(le)){var Ze=Te.start,ct=Te.end;if(ct===void 0&&(ct=Ze),"selectionStart"in le)le.selectionStart=Ze,le.selectionEnd=Math.min(ct,le.value.length);else{var ht=le.ownerDocument||document,Je=ht&&ht.defaultView||window;if(Je.getSelection){var st=Je.getSelection(),Dt=le.textContent.length,Gt=Math.min(Te.start,Dt),Wn=Te.end===void 0?Gt:Math.min(Te.end,Dt);!st.extend&&Gt>Wn&&(X=Wn,Wn=Gt,Gt=X);var Be=YL(le,Gt),je=YL(le,Wn);if(Be&&je&&(st.rangeCount!==1||st.anchorNode!==Be.node||st.anchorOffset!==Be.offset||st.focusNode!==je.node||st.focusOffset!==je.offset)){var Xe=ht.createRange();Xe.setStart(Be.node,Be.offset),st.removeAllRanges(),Gt>Wn?(st.addRange(Xe),st.extend(je.node,je.offset)):(Xe.setEnd(je.node,je.offset),st.addRange(Xe))}}}}for(ht=[],st=le;st=st.parentNode;)st.nodeType===1&&ht.push({element:st,left:st.scrollLeft,top:st.scrollTop});for(typeof le.focus=="function"&&le.focus(),le=0;le<ht.length;le++){var dt=ht[le];dt.element.scrollLeft=dt.left,dt.element.scrollTop=dt.top}}ov=!!oA,lA=oA=null}finally{Pn=P,G.p=S,K.T=_}}h.current=m,li=2}}function f5(){if(li===2){li=0;var h=uu,m=$f,_=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var S=G.p;G.p=2;var P=Pn;Pn|=4;try{BI(h,m.alternate,m)}finally{Pn=P,G.p=S,K.T=_}}li=3}}function m5(){if(li===4||li===3){li=0,$();var h=uu,m=$f,_=$l,S=e5;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?li=5:(li=0,$f=uu=null,p5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(cu=null),Ei(_),m=m.stateNode,oe&&typeof oe.onCommitFiberRoot=="function")try{oe.onCommitFiberRoot(Ue,m,void 0,(m.current.flags&128)===128)}catch{}if(S!==null){m=K.T,P=G.p,G.p=2,K.T=null;try{for(var D=h.onRecoverableError,X=0;X<S.length;X++){var le=S[X];D(le.value,{componentStack:le.stack})}}finally{K.T=m,G.p=P}}($l&3)!==0&&Xy(),Ko(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===K2?Xg++:(Xg=0,K2=h):Xg=0,Yg(0)}}function p5(h,m){(h.pooledCacheLanes&=m)===0&&(m=h.pooledCache,m!=null&&(h.pooledCache=null,kg(m)))}function Xy(){return h5(),f5(),m5(),g5()}function g5(){if(li!==5)return!1;var h=uu,m=W2;W2=0;var _=Ei($l),S=K.T,P=G.p;try{G.p=32>_?32:_,K.T=null,_=q2,q2=null;var D=uu,X=$l;if(li=0,$f=uu=null,$l=0,(Pn&6)!==0)throw Error(r(331));var le=Pn;if(Pn|=4,ZI(D.current),KI(D,D.current,X,_),Pn=le,Yg(0,!1),oe&&typeof oe.onPostCommitFiberRoot=="function")try{oe.onPostCommitFiberRoot(Ue,D)}catch{}return!0}finally{G.p=P,K.T=S,p5(h,m)}}function x5(h,m,_){m=Rs(_,m),m=A2(h.stateNode,m,2),h=ru(h,m,2),h!==null&&(Qt(h,2),Ko(h))}function Fn(h,m,_){if(h.tag===3)x5(h,h,_);else for(;m!==null;){if(m.tag===3){x5(m,h,_);break}else if(m.tag===1){var S=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(cu===null||!cu.has(S))){h=Rs(_,h),_=bI(2),S=ru(m,_,2),S!==null&&(yI(_,S,m,h),Qt(S,2),Ko(S));break}}m=m.return}}function Z2(h,m,_){var S=h.pingCache;if(S===null){S=h.pingCache=new One;var P=new Set;S.set(m,P)}else P=S.get(m),P===void 0&&(P=new Set,S.set(m,P));P.has(_)||($2=!0,P.add(_),h=zne.bind(null,h,m,_),m.then(h,h))}function zne(h,m,_){var S=h.pingCache;S!==null&&S.delete(m),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,er===h&&(yn&_)===_&&(kr===4||kr===3&&(yn&62914560)===yn&&300>L()-$y?(Pn&2)===0&&Vf(h,0):V2|=_,Hf===yn&&(Hf=0)),Ko(h)}function b5(h,m){m===0&&(m=xt()),h=Ld(h,m),h!==null&&(Qt(h,m),Ko(h))}function Bne(h){var m=h.memoizedState,_=0;m!==null&&(_=m.retryLane),b5(h,_)}function Hne(h,m){var _=0;switch(h.tag){case 31:case 13:var S=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:S=h.stateNode;break;case 22:S=h.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(m),b5(h,_)}function $ne(h,m){return Me(h,m)}var Yy=null,Wf=null,Q2=!1,Zy=!1,J2=!1,hu=0;function Ko(h){h!==Wf&&h.next===null&&(Wf===null?Yy=Wf=h:Wf=Wf.next=h),Zy=!0,Q2||(Q2=!0,Gne())}function Yg(h,m){if(!J2&&Zy){J2=!0;do for(var _=!1,S=Yy;S!==null;){if(h!==0){var P=S.pendingLanes;if(P===0)var D=0;else{var X=S.suspendedLanes,le=S.pingedLanes;D=(1<<31-$e(42|h)+1)-1,D&=P&~(X&~le),D=D&201326741?D&201326741|1:D?D|2:0}D!==0&&(_=!0,w5(S,D))}else D=yn,D=ve(S,S===er?D:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(D&3)===0||de(S,D)||(_=!0,w5(S,D));S=S.next}while(_);J2=!1}}function Vne(){y5()}function y5(){Zy=Q2=!1;var h=0;hu!==0&&tre()&&(h=hu);for(var m=L(),_=null,S=Yy;S!==null;){var P=S.next,D=v5(S,m);D===0?(S.next=null,_===null?Yy=P:_.next=P,P===null&&(Wf=_)):(_=S,(h!==0||(D&3)!==0)&&(Zy=!0)),S=P}li!==0&&li!==5||Yg(h),hu!==0&&(hu=0)}function v5(h,m){for(var _=h.suspendedLanes,S=h.pingedLanes,P=h.expirationTimes,D=h.pendingLanes&-62914561;0<D;){var X=31-$e(D),le=1<<X,Te=P[X];Te===-1?((le&_)===0||(le&S)!==0)&&(P[X]=ot(le,m)):Te<=m&&(h.expiredLanes|=le),D&=~le}if(m=er,_=yn,_=ve(h,h===m?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),S=h.callbackNode,_===0||h===m&&(In===2||In===9)||h.cancelPendingCommit!==null)return S!==null&&S!==null&&Ae(S),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||de(h,_)){if(m=_&-_,m===h.callbackPriority)return m;switch(S!==null&&Ae(S),Ei(_)){case 2:case 8:_=we;break;case 32:_=xe;break;case 268435456:_=He;break;default:_=xe}return S=_5.bind(null,h),_=Me(_,S),h.callbackPriority=m,h.callbackNode=_,m}return S!==null&&S!==null&&Ae(S),h.callbackPriority=2,h.callbackNode=null,2}function _5(h,m){if(li!==0&&li!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Xy()&&h.callbackNode!==_)return null;var S=yn;return S=ve(h,h===er?S:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),S===0?null:(n5(h,S,m),v5(h,L()),h.callbackNode!=null&&h.callbackNode===_?_5.bind(null,h):null)}function w5(h,m){if(Xy())return null;n5(h,m,!0)}function Gne(){rre(function(){(Pn&6)!==0?Me(ye,Vne):y5()})}function eA(){if(hu===0){var h=Pf;h===0&&(h=Qe,Qe<<=1,(Qe&261888)===0&&(Qe=256)),hu=h}return hu}function S5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:ay(""+h)}function M5(h,m){var _=m.ownerDocument.createElement("input");return _.name=m.name,_.value=m.value,h.id&&_.setAttribute("form",h.id),m.parentNode.insertBefore(_,m),h=new FormData(h),_.parentNode.removeChild(_),h}function Wne(h,m,_,S,P){if(m==="submit"&&_&&_.stateNode===P){var D=S5((P[Lr]||null).action),X=S.submitter;X&&(m=(m=X[Lr]||null)?S5(m.formAction):X.getAttribute("formAction"),m!==null&&(D=m,X=null));var le=new cy("action","action",null,S,P);h.push({event:le,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(hu!==0){var Te=X?M5(P,X):new FormData(P);v2(_,{pending:!0,data:Te,method:P.method,action:D},null,Te)}}else typeof D=="function"&&(le.preventDefault(),Te=X?M5(P,X):new FormData(P),v2(_,{pending:!0,data:Te,method:P.method,action:D},D,Te))},currentTarget:P}]})}}for(var tA=0;tA<IE.length;tA++){var nA=IE[tA],qne=nA.toLowerCase(),Kne=nA[0].toUpperCase()+nA.slice(1);bo(qne,"on"+Kne)}bo(t4,"onAnimationEnd"),bo(n4,"onAnimationIteration"),bo(r4,"onAnimationStart"),bo("dblclick","onDoubleClick"),bo("focusin","onFocus"),bo("focusout","onBlur"),bo(une,"onTransitionRun"),bo(dne,"onTransitionStart"),bo(hne,"onTransitionCancel"),bo(i4,"onTransitionEnd"),wt("onMouseEnter",["mouseout","mouseover"]),wt("onMouseLeave",["mouseout","mouseover"]),wt("onPointerEnter",["pointerout","pointerover"]),wt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zg="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(" "),Xne=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Zg));function E5(h,m){m=(m&4)!==0;for(var _=0;_<h.length;_++){var S=h[_],P=S.event;S=S.listeners;e:{var D=void 0;if(m)for(var X=S.length-1;0<=X;X--){var le=S[X],Te=le.instance,Ze=le.currentTarget;if(le=le.listener,Te!==D&&P.isPropagationStopped())break e;D=le,P.currentTarget=Ze;try{D(P)}catch(ct){hy(ct)}P.currentTarget=null,D=Te}else for(X=0;X<S.length;X++){if(le=S[X],Te=le.instance,Ze=le.currentTarget,le=le.listener,Te!==D&&P.isPropagationStopped())break e;D=le,P.currentTarget=Ze;try{D(P)}catch(ct){hy(ct)}P.currentTarget=null,D=Te}}}}function pn(h,m){var _=m[Xc];_===void 0&&(_=m[Xc]=new Set);var S=h+"__bubble";_.has(S)||(A5(m,h,2,!1),_.add(S))}function rA(h,m,_){var S=0;m&&(S|=4),A5(_,h,S,m)}var Qy="_reactListening"+Math.random().toString(36).slice(2);function iA(h){if(!h[Qy]){h[Qy]=!0,Ne.forEach(function(_){_!=="selectionchange"&&(Xne.has(_)||rA(_,!1,h),rA(_,!0,h))});var m=h.nodeType===9?h:h.ownerDocument;m===null||m[Qy]||(m[Qy]=!0,rA("selectionchange",!1,m))}}function A5(h,m,_,S){switch(tF(m)){case 2:var P=Sre;break;case 8:P=Mre;break;default:P=yA}_=P.bind(null,m,_,h),P=void 0,!ME||m!=="touchstart"&&m!=="touchmove"&&m!=="wheel"||(P=!0),S?P!==void 0?h.addEventListener(m,_,{capture:!0,passive:P}):h.addEventListener(m,_,!0):P!==void 0?h.addEventListener(m,_,{passive:P}):h.addEventListener(m,_,!1)}function aA(h,m,_,S,P){var D=S;if((m&1)===0&&(m&2)===0&&S!==null)e:for(;;){if(S===null)return;var X=S.tag;if(X===3||X===4){var le=S.stateNode.containerInfo;if(le===P)break;if(X===4)for(X=S.return;X!==null;){var Te=X.tag;if((Te===3||Te===4)&&X.stateNode.containerInfo===P)return;X=X.return}for(;le!==null;){if(X=At(le),X===null)return;if(Te=X.tag,Te===5||Te===6||Te===26||Te===27){S=D=X;continue e}le=le.parentNode}}S=S.return}PL(function(){var Ze=D,ct=wE(_),ht=[];e:{var Je=a4.get(h);if(Je!==void 0){var st=cy,Dt=h;switch(h){case"keypress":if(oy(_)===0)break e;case"keydown":case"keyup":st=Hte;break;case"focusin":Dt="focus",st=CE;break;case"focusout":Dt="blur",st=CE;break;case"beforeblur":case"afterblur":st=CE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":st=DL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":st=kte;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":st=Gte;break;case t4:case n4:case r4:st=jte;break;case i4:st=qte;break;case"scroll":case"scrollend":st=Cte;break;case"wheel":st=Xte;break;case"copy":case"cut":case"paste":st=Ote;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":st=LL;break;case"toggle":case"beforetoggle":st=Zte}var Gt=(m&4)!==0,Wn=!Gt&&(h==="scroll"||h==="scrollend"),Be=Gt?Je!==null?Je+"Capture":null:Je;Gt=[];for(var je=Ze,Xe;je!==null;){var dt=je;if(Xe=dt.stateNode,dt=dt.tag,dt!==5&&dt!==26&&dt!==27||Xe===null||Be===null||(dt=yg(je,Be),dt!=null&&Gt.push(Qg(je,dt,Xe))),Wn)break;je=je.return}0<Gt.length&&(Je=new st(Je,Dt,null,_,ct),ht.push({event:Je,listeners:Gt}))}}if((m&7)===0){e:{if(Je=h==="mouseover"||h==="pointerover",st=h==="mouseout"||h==="pointerout",Je&&_!==_E&&(Dt=_.relatedTarget||_.fromElement)&&(At(Dt)||Dt[go]))break e;if((st||Je)&&(Je=ct.window===ct?ct:(Je=ct.ownerDocument)?Je.defaultView||Je.parentWindow:window,st?(Dt=_.relatedTarget||_.toElement,st=Ze,Dt=Dt?At(Dt):null,Dt!==null&&(Wn=a(Dt),Gt=Dt.tag,Dt!==Wn||Gt!==5&&Gt!==27&&Gt!==6)&&(Dt=null)):(st=null,Dt=Ze),st!==Dt)){if(Gt=DL,dt="onMouseLeave",Be="onMouseEnter",je="mouse",(h==="pointerout"||h==="pointerover")&&(Gt=LL,dt="onPointerLeave",Be="onPointerEnter",je="pointer"),Wn=st==null?Je:Ee(st),Xe=Dt==null?Je:Ee(Dt),Je=new Gt(dt,je+"leave",st,_,ct),Je.target=Wn,Je.relatedTarget=Xe,dt=null,At(ct)===Ze&&(Gt=new Gt(Be,je+"enter",Dt,_,ct),Gt.target=Xe,Gt.relatedTarget=Wn,dt=Gt),Wn=dt,st&&Dt)t:{for(Gt=Yne,Be=st,je=Dt,Xe=0,dt=Be;dt;dt=Gt(dt))Xe++;dt=0;for(var zt=je;zt;zt=Gt(zt))dt++;for(;0<Xe-dt;)Be=Gt(Be),Xe--;for(;0<dt-Xe;)je=Gt(je),dt--;for(;Xe--;){if(Be===je||je!==null&&Be===je.alternate){Gt=Be;break t}Be=Gt(Be),je=Gt(je)}Gt=null}else Gt=null;st!==null&&T5(ht,Je,st,Gt,!1),Dt!==null&&Wn!==null&&T5(ht,Wn,Dt,Gt,!0)}}e:{if(Je=Ze?Ee(Ze):window,st=Je.nodeName&&Je.nodeName.toLowerCase(),st==="select"||st==="input"&&Je.type==="file")var Tn=VL;else if(HL(Je))if(GL)Tn=one;else{Tn=ane;var It=ine}else st=Je.nodeName,!st||st.toLowerCase()!=="input"||Je.type!=="checkbox"&&Je.type!=="radio"?Ze&&vE(Ze.elementType)&&(Tn=VL):Tn=sne;if(Tn&&(Tn=Tn(h,Ze))){$L(ht,Tn,_,ct);break e}It&&It(h,Je,Ze),h==="focusout"&&Ze&&Je.type==="number"&&Ze.memoizedProps.value!=null&&Ai(Je,"number",Je.value)}switch(It=Ze?Ee(Ze):window,h){case"focusin":(HL(It)||It.contentEditable==="true")&&(Sf=It,DE=Ze,Tg=null);break;case"focusout":Tg=DE=Sf=null;break;case"mousedown":OE=!0;break;case"contextmenu":case"mouseup":case"dragend":OE=!1,JL(ht,_,ct);break;case"selectionchange":if(cne)break;case"keydown":case"keyup":JL(ht,_,ct)}var rn;if(kE)e:{switch(h){case"compositionstart":var vn="onCompositionStart";break e;case"compositionend":vn="onCompositionEnd";break e;case"compositionupdate":vn="onCompositionUpdate";break e}vn=void 0}else wf?zL(h,_)&&(vn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(IL&&_.locale!=="ko"&&(wf||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&wf&&(rn=RL()):(Yc=ct,EE="value"in Yc?Yc.value:Yc.textContent,wf=!0)),It=Jy(Ze,vn),0<It.length&&(vn=new OL(vn,h,null,_,ct),ht.push({event:vn,listeners:It}),rn?vn.data=rn:(rn=BL(_),rn!==null&&(vn.data=rn)))),(rn=Jte?ene(h,_):tne(h,_))&&(vn=Jy(Ze,"onBeforeInput"),0<vn.length&&(It=new OL("onBeforeInput","beforeinput",null,_,ct),ht.push({event:It,listeners:vn}),It.data=rn)),Wne(ht,h,Ze,_,ct)}E5(ht,m)})}function Qg(h,m,_){return{instance:h,listener:m,currentTarget:_}}function Jy(h,m){for(var _=m+"Capture",S=[];h!==null;){var P=h,D=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||D===null||(P=yg(h,_),P!=null&&S.unshift(Qg(h,P,D)),P=yg(h,m),P!=null&&S.push(Qg(h,P,D))),h.tag===3)return S;h=h.return}return[]}function Yne(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function T5(h,m,_,S,P){for(var D=m._reactName,X=[];_!==null&&_!==S;){var le=_,Te=le.alternate,Ze=le.stateNode;if(le=le.tag,Te!==null&&Te===S)break;le!==5&&le!==26&&le!==27||Ze===null||(Te=Ze,P?(Ze=yg(_,D),Ze!=null&&X.unshift(Qg(_,Ze,Te))):P||(Ze=yg(_,D),Ze!=null&&X.push(Qg(_,Ze,Te)))),_=_.return}X.length!==0&&h.push({event:m,listeners:X})}var Zne=/\r\n?/g,Qne=/\u0000|\uFFFD/g;function C5(h){return(typeof h=="string"?h:""+h).replace(Zne,`
  9. `).replace(Qne,"")}function N5(h,m){return m=C5(m),C5(h)===m}function Gn(h,m,_,S,P,D){switch(_){case"children":typeof S=="string"?m==="body"||m==="textarea"&&S===""||Vo(h,S):(typeof S=="number"||typeof S=="bigint")&&m!=="body"&&Vo(h,""+S);break;case"className":Ut(h,"class",S);break;case"tabIndex":Ut(h,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":Ut(h,_,S);break;case"style":NL(h,S,D);break;case"data":if(m!=="object"){Ut(h,"data",S);break}case"src":case"href":if(S===""&&(m!=="a"||_!=="href")){h.removeAttribute(_);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){h.removeAttribute(_);break}S=ay(""+S),h.setAttribute(_,S);break;case"action":case"formAction":if(typeof S=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof D=="function"&&(_==="formAction"?(m!=="input"&&Gn(h,m,"name",P.name,P,null),Gn(h,m,"formEncType",P.formEncType,P,null),Gn(h,m,"formMethod",P.formMethod,P,null),Gn(h,m,"formTarget",P.formTarget,P,null)):(Gn(h,m,"encType",P.encType,P,null),Gn(h,m,"method",P.method,P,null),Gn(h,m,"target",P.target,P,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){h.removeAttribute(_);break}S=ay(""+S),h.setAttribute(_,S);break;case"onClick":S!=null&&(h.onclick=Cl);break;case"onScroll":S!=null&&pn("scroll",h);break;case"onScrollEnd":S!=null&&pn("scrollend",h);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":h.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"){h.removeAttribute("xlink:href");break}_=ay(""+S),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":S!=null&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,""+S):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":S&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":S===!0?h.setAttribute(_,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?h.setAttribute(_,S):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?h.setAttribute(_,S):h.removeAttribute(_);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?h.removeAttribute(_):h.setAttribute(_,S);break;case"popover":pn("beforetoggle",h),pn("toggle",h),Xt(h,"popover",S);break;case"xlinkActuate":an(h,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":an(h,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":an(h,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":an(h,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":an(h,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":an(h,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":an(h,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":an(h,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":an(h,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":Xt(h,"is",S);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=Ate.get(_)||_,Xt(h,_,S))}}function sA(h,m,_,S,P,D){switch(_){case"style":NL(h,S,D);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof S=="string"?Vo(h,S):(typeof S=="number"||typeof S=="bigint")&&Vo(h,""+S);break;case"onScroll":S!=null&&pn("scroll",h);break;case"onScrollEnd":S!=null&&pn("scrollend",h);break;case"onClick":S!=null&&(h.onclick=Cl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!lt.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),m=_.slice(2,P?_.length-7:void 0),D=h[Lr]||null,D=D!=null?D[_]:null,typeof D=="function"&&h.removeEventListener(m,D,P),typeof S=="function")){typeof D!="function"&&D!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(m,S,P);break e}_ in h?h[_]=S:S===!0?h.setAttribute(_,""):Xt(h,_,S)}}}function Gi(h,m,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":pn("error",h),pn("load",h);var S=!1,P=!1,D;for(D in _)if(_.hasOwnProperty(D)){var X=_[D];if(X!=null)switch(D){case"src":S=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:Gn(h,m,D,X,_,null)}}P&&Gn(h,m,"srcSet",_.srcSet,_,null),S&&Gn(h,m,"src",_.src,_,null);return;case"input":pn("invalid",h);var le=D=X=P=null,Te=null,Ze=null;for(S in _)if(_.hasOwnProperty(S)){var ct=_[S];if(ct!=null)switch(S){case"name":P=ct;break;case"type":X=ct;break;case"checked":Te=ct;break;case"defaultChecked":Ze=ct;break;case"value":D=ct;break;case"defaultValue":le=ct;break;case"children":case"dangerouslySetInnerHTML":if(ct!=null)throw Error(r(137,m));break;default:Gn(h,m,S,ct,_,null)}}Ln(h,D,le,Te,Ze,X,P,!1);return;case"select":pn("invalid",h),S=X=D=null;for(P in _)if(_.hasOwnProperty(P)&&(le=_[P],le!=null))switch(P){case"value":D=le;break;case"defaultValue":X=le;break;case"multiple":S=le;default:Gn(h,m,P,le,_,null)}m=D,_=X,h.multiple=!!S,m!=null?oi(h,!!S,m,!1):_!=null&&oi(h,!!S,_,!0);return;case"textarea":pn("invalid",h),D=P=S=null;for(X in _)if(_.hasOwnProperty(X)&&(le=_[X],le!=null))switch(X){case"value":S=le;break;case"defaultValue":P=le;break;case"children":D=le;break;case"dangerouslySetInnerHTML":if(le!=null)throw Error(r(91));break;default:Gn(h,m,X,le,_,null)}Bi(h,S,P,D);return;case"option":for(Te in _)if(_.hasOwnProperty(Te)&&(S=_[Te],S!=null))switch(Te){case"selected":h.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:Gn(h,m,Te,S,_,null)}return;case"dialog":pn("beforetoggle",h),pn("toggle",h),pn("cancel",h),pn("close",h);break;case"iframe":case"object":pn("load",h);break;case"video":case"audio":for(S=0;S<Zg.length;S++)pn(Zg[S],h);break;case"image":pn("error",h),pn("load",h);break;case"details":pn("toggle",h);break;case"embed":case"source":case"link":pn("error",h),pn("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ze in _)if(_.hasOwnProperty(Ze)&&(S=_[Ze],S!=null))switch(Ze){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:Gn(h,m,Ze,S,_,null)}return;default:if(vE(m)){for(ct in _)_.hasOwnProperty(ct)&&(S=_[ct],S!==void 0&&sA(h,m,ct,S,_,void 0));return}}for(le in _)_.hasOwnProperty(le)&&(S=_[le],S!=null&&Gn(h,m,le,S,_,null))}function Jne(h,m,_,S){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,D=null,X=null,le=null,Te=null,Ze=null,ct=null;for(st in _){var ht=_[st];if(_.hasOwnProperty(st)&&ht!=null)switch(st){case"checked":break;case"value":break;case"defaultValue":Te=ht;default:S.hasOwnProperty(st)||Gn(h,m,st,null,S,ht)}}for(var Je in S){var st=S[Je];if(ht=_[Je],S.hasOwnProperty(Je)&&(st!=null||ht!=null))switch(Je){case"type":D=st;break;case"name":P=st;break;case"checked":Ze=st;break;case"defaultChecked":ct=st;break;case"value":X=st;break;case"defaultValue":le=st;break;case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,m));break;default:st!==ht&&Gn(h,m,Je,st,S,ht)}}xo(h,X,le,Te,Ze,ct,D,P);return;case"select":st=X=le=Je=null;for(D in _)if(Te=_[D],_.hasOwnProperty(D)&&Te!=null)switch(D){case"value":break;case"multiple":st=Te;default:S.hasOwnProperty(D)||Gn(h,m,D,null,S,Te)}for(P in S)if(D=S[P],Te=_[P],S.hasOwnProperty(P)&&(D!=null||Te!=null))switch(P){case"value":Je=D;break;case"defaultValue":le=D;break;case"multiple":X=D;default:D!==Te&&Gn(h,m,P,D,S,Te)}m=le,_=X,S=st,Je!=null?oi(h,!!_,Je,!1):!!S!=!!_&&(m!=null?oi(h,!!_,m,!0):oi(h,!!_,_?[]:"",!1));return;case"textarea":st=Je=null;for(le in _)if(P=_[le],_.hasOwnProperty(le)&&P!=null&&!S.hasOwnProperty(le))switch(le){case"value":break;case"children":break;default:Gn(h,m,le,null,S,P)}for(X in S)if(P=S[X],D=_[X],S.hasOwnProperty(X)&&(P!=null||D!=null))switch(X){case"value":Je=P;break;case"defaultValue":st=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==D&&Gn(h,m,X,P,S,D)}Ti(h,Je,st);return;case"option":for(var Dt in _)if(Je=_[Dt],_.hasOwnProperty(Dt)&&Je!=null&&!S.hasOwnProperty(Dt))switch(Dt){case"selected":h.selected=!1;break;default:Gn(h,m,Dt,null,S,Je)}for(Te in S)if(Je=S[Te],st=_[Te],S.hasOwnProperty(Te)&&Je!==st&&(Je!=null||st!=null))switch(Te){case"selected":h.selected=Je&&typeof Je!="function"&&typeof Je!="symbol";break;default:Gn(h,m,Te,Je,S,st)}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 Gt in _)Je=_[Gt],_.hasOwnProperty(Gt)&&Je!=null&&!S.hasOwnProperty(Gt)&&Gn(h,m,Gt,null,S,Je);for(Ze in S)if(Je=S[Ze],st=_[Ze],S.hasOwnProperty(Ze)&&Je!==st&&(Je!=null||st!=null))switch(Ze){case"children":case"dangerouslySetInnerHTML":if(Je!=null)throw Error(r(137,m));break;default:Gn(h,m,Ze,Je,S,st)}return;default:if(vE(m)){for(var Wn in _)Je=_[Wn],_.hasOwnProperty(Wn)&&Je!==void 0&&!S.hasOwnProperty(Wn)&&sA(h,m,Wn,void 0,S,Je);for(ct in S)Je=S[ct],st=_[ct],!S.hasOwnProperty(ct)||Je===st||Je===void 0&&st===void 0||sA(h,m,ct,Je,S,st);return}}for(var Be in _)Je=_[Be],_.hasOwnProperty(Be)&&Je!=null&&!S.hasOwnProperty(Be)&&Gn(h,m,Be,null,S,Je);for(ht in S)Je=S[ht],st=_[ht],!S.hasOwnProperty(ht)||Je===st||Je==null&&st==null||Gn(h,m,ht,Je,S,st)}function k5(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ere(){if(typeof performance.getEntriesByType=="function"){for(var h=0,m=0,_=performance.getEntriesByType("resource"),S=0;S<_.length;S++){var P=_[S],D=P.transferSize,X=P.initiatorType,le=P.duration;if(D&&le&&k5(X)){for(X=0,le=P.responseEnd,S+=1;S<_.length;S++){var Te=_[S],Ze=Te.startTime;if(Ze>le)break;var ct=Te.transferSize,ht=Te.initiatorType;ct&&k5(ht)&&(Te=Te.responseEnd,X+=ct*(Te<le?1:(le-Ze)/(Te-Ze)))}if(--S,m+=8*(D+X)/(P.duration/1e3),h++,10<h)break}}if(0<h)return m/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var oA=null,lA=null;function ev(h){return h.nodeType===9?h:h.ownerDocument}function P5(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function R5(h,m){if(h===0)switch(m){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&m==="foreignObject"?0:h}function cA(h,m){return h==="textarea"||h==="noscript"||typeof m.children=="string"||typeof m.children=="number"||typeof m.children=="bigint"||typeof m.dangerouslySetInnerHTML=="object"&&m.dangerouslySetInnerHTML!==null&&m.dangerouslySetInnerHTML.__html!=null}var uA=null;function tre(){var h=window.event;return h&&h.type==="popstate"?h===uA?!1:(uA=h,!0):(uA=null,!1)}var j5=typeof setTimeout=="function"?setTimeout:void 0,nre=typeof clearTimeout=="function"?clearTimeout:void 0,D5=typeof Promise=="function"?Promise:void 0,rre=typeof queueMicrotask=="function"?queueMicrotask:typeof D5<"u"?function(h){return D5.resolve(null).then(h).catch(ire)}:j5;function ire(h){setTimeout(function(){throw h})}function fu(h){return h==="head"}function O5(h,m){var _=m,S=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(S===0){h.removeChild(P),Yf(m);return}S--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")S++;else if(_==="html")Jg(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Jg(_);for(var D=_.firstChild;D;){var X=D.nextSibling,le=D.nodeName;D[at]||le==="SCRIPT"||le==="STYLE"||le==="LINK"&&D.rel.toLowerCase()==="stylesheet"||_.removeChild(D),D=X}}else _==="body"&&Jg(h.ownerDocument.body);_=P}while(_);Yf(m)}function L5(h,m){var _=h;h=0;do{var S=_.nextSibling;if(_.nodeType===1?m?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(m?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),S&&S.nodeType===8)if(_=S.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=S}while(_)}function dA(h){var m=h.firstChild;for(m&&m.nodeType===10&&(m=m.nextSibling);m;){var _=m;switch(m=m.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":dA(_),nt(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function are(h,m,_,S){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==m.toLowerCase()){if(!S&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(S){if(!h[at])switch(m){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(D=h.getAttribute("rel"),D==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(D!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(D=h.getAttribute("src"),(D!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&D&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(m==="input"&&h.type==="hidden"){var D=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===D)return h}else return h;if(h=Is(h.nextSibling),h===null)break}return null}function sre(h,m,_){if(m==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Is(h.nextSibling),h===null))return null;return h}function I5(h,m){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!m||(h=Is(h.nextSibling),h===null))return null;return h}function hA(h){return h.data==="$?"||h.data==="$~"}function fA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function ore(h,m){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=m;else if(h.data!=="$?"||_.readyState!=="loading")m();else{var S=function(){m(),_.removeEventListener("DOMContentLoaded",S)};_.addEventListener("DOMContentLoaded",S),h._reactRetry=S}}function Is(h){for(;h!=null;h=h.nextSibling){var m=h.nodeType;if(m===1||m===3)break;if(m===8){if(m=h.data,m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"||m==="F!"||m==="F")break;if(m==="/$"||m==="/&")return null}}return h}var mA=null;function F5(h){h=h.nextSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(m===0)return Is(h.nextSibling);m--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||m++}h=h.nextSibling}return null}function U5(h){h=h.previousSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(m===0)return h;m--}else _!=="/$"&&_!=="/&"||m++}h=h.previousSibling}return null}function z5(h,m,_){switch(m=ev(_),h){case"html":if(h=m.documentElement,!h)throw Error(r(452));return h;case"head":if(h=m.head,!h)throw Error(r(453));return h;case"body":if(h=m.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Jg(h){for(var m=h.attributes;m.length;)h.removeAttributeNode(m[0]);nt(h)}var Fs=new Map,B5=new Set;function tv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Vl=G.d;G.d={f:lre,r:cre,D:ure,C:dre,L:hre,m:fre,X:pre,S:mre,M:gre};function lre(){var h=Vl.f(),m=Wy();return h||m}function cre(h){var m=ae(h);m!==null&&m.tag===5&&m.type==="form"?iI(m):Vl.r(h)}var qf=typeof document>"u"?null:document;function H5(h,m,_){var S=qf;if(S&&typeof m=="string"&&m){var P=jn(m);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),B5.has(P)||(B5.add(P),h={rel:h,crossOrigin:_,href:m},S.querySelector(P)===null&&(m=S.createElement("link"),Gi(m,"link",h),Oe(m),S.head.appendChild(m)))}}function ure(h){Vl.D(h),H5("dns-prefetch",h,null)}function dre(h,m){Vl.C(h,m),H5("preconnect",h,m)}function hre(h,m,_){Vl.L(h,m,_);var S=qf;if(S&&h&&m){var P='link[rel="preload"][as="'+jn(m)+'"]';m==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+jn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+jn(_.imageSizes)+'"]')):P+='[href="'+jn(h)+'"]';var D=P;switch(m){case"style":D=Kf(h);break;case"script":D=Xf(h)}Fs.has(D)||(h=f({rel:"preload",href:m==="image"&&_&&_.imageSrcSet?void 0:h,as:m},_),Fs.set(D,h),S.querySelector(P)!==null||m==="style"&&S.querySelector(ex(D))||m==="script"&&S.querySelector(tx(D))||(m=S.createElement("link"),Gi(m,"link",h),Oe(m),S.head.appendChild(m)))}}function fre(h,m){Vl.m(h,m);var _=qf;if(_&&h){var S=m&&typeof m.as=="string"?m.as:"script",P='link[rel="modulepreload"][as="'+jn(S)+'"][href="'+jn(h)+'"]',D=P;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":D=Xf(h)}if(!Fs.has(D)&&(h=f({rel:"modulepreload",href:h},m),Fs.set(D,h),_.querySelector(P)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(tx(D)))return}S=_.createElement("link"),Gi(S,"link",h),Oe(S),_.head.appendChild(S)}}}function mre(h,m,_){Vl.S(h,m,_);var S=qf;if(S&&h){var P=Fe(S).hoistableStyles,D=Kf(h);m=m||"default";var X=P.get(D);if(!X){var le={loading:0,preload:null};if(X=S.querySelector(ex(D)))le.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":m},_),(_=Fs.get(D))&&pA(h,_);var Te=X=S.createElement("link");Oe(Te),Gi(Te,"link",h),Te._p=new Promise(function(Ze,ct){Te.onload=Ze,Te.onerror=ct}),Te.addEventListener("load",function(){le.loading|=1}),Te.addEventListener("error",function(){le.loading|=2}),le.loading|=4,nv(X,m,S)}X={type:"stylesheet",instance:X,count:1,state:le},P.set(D,X)}}}function pre(h,m){Vl.X(h,m);var _=qf;if(_&&h){var S=Fe(_).hoistableScripts,P=Xf(h),D=S.get(P);D||(D=_.querySelector(tx(P)),D||(h=f({src:h,async:!0},m),(m=Fs.get(P))&&gA(h,m),D=_.createElement("script"),Oe(D),Gi(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(P,D))}}function gre(h,m){Vl.M(h,m);var _=qf;if(_&&h){var S=Fe(_).hoistableScripts,P=Xf(h),D=S.get(P);D||(D=_.querySelector(tx(P)),D||(h=f({src:h,async:!0,type:"module"},m),(m=Fs.get(P))&&gA(h,m),D=_.createElement("script"),Oe(D),Gi(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(P,D))}}function $5(h,m,_,S){var P=(P=ue.current)?tv(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(m=Kf(_.href),_=Fe(P).hoistableStyles,S=_.get(m),S||(S={type:"style",instance:null,count:0,state:null},_.set(m,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Kf(_.href);var D=Fe(P).hoistableStyles,X=D.get(h);if(X||(P=P.ownerDocument||P,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},D.set(h,X),(D=P.querySelector(ex(h)))&&!D._p&&(X.instance=D,X.state.loading=5),Fs.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Fs.set(h,_),D||xre(P,h,_,X.state))),m&&S===null)throw Error(r(528,""));return X}if(m&&S!==null)throw Error(r(529,""));return null;case"script":return m=_.async,_=_.src,typeof _=="string"&&m&&typeof m!="function"&&typeof m!="symbol"?(m=Xf(_),_=Fe(P).hoistableScripts,S=_.get(m),S||(S={type:"script",instance:null,count:0,state:null},_.set(m,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Kf(h){return'href="'+jn(h)+'"'}function ex(h){return'link[rel="stylesheet"]['+h+"]"}function V5(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function xre(h,m,_,S){h.querySelector('link[rel="preload"][as="style"]['+m+"]")?S.loading=1:(m=h.createElement("link"),S.preload=m,m.addEventListener("load",function(){return S.loading|=1}),m.addEventListener("error",function(){return S.loading|=2}),Gi(m,"link",_),Oe(m),h.head.appendChild(m))}function Xf(h){return'[src="'+jn(h)+'"]'}function tx(h){return"script[async]"+h}function G5(h,m,_){if(m.count++,m.instance===null)switch(m.type){case"style":var S=h.querySelector('style[data-href~="'+jn(_.href)+'"]');if(S)return m.instance=S,Oe(S),S;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return S=(h.ownerDocument||h).createElement("style"),Oe(S),Gi(S,"style",P),nv(S,_.precedence,h),m.instance=S;case"stylesheet":P=Kf(_.href);var D=h.querySelector(ex(P));if(D)return m.state.loading|=4,m.instance=D,Oe(D),D;S=V5(_),(P=Fs.get(P))&&pA(S,P),D=(h.ownerDocument||h).createElement("link"),Oe(D);var X=D;return X._p=new Promise(function(le,Te){X.onload=le,X.onerror=Te}),Gi(D,"link",S),m.state.loading|=4,nv(D,_.precedence,h),m.instance=D;case"script":return D=Xf(_.src),(P=h.querySelector(tx(D)))?(m.instance=P,Oe(P),P):(S=_,(P=Fs.get(D))&&(S=f({},_),gA(S,P)),h=h.ownerDocument||h,P=h.createElement("script"),Oe(P),Gi(P,"link",S),h.head.appendChild(P),m.instance=P);case"void":return null;default:throw Error(r(443,m.type))}else m.type==="stylesheet"&&(m.state.loading&4)===0&&(S=m.instance,m.state.loading|=4,nv(S,_.precedence,h));return m.instance}function nv(h,m,_){for(var S=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=S.length?S[S.length-1]:null,D=P,X=0;X<S.length;X++){var le=S[X];if(le.dataset.precedence===m)D=le;else if(D!==P)break}D?D.parentNode.insertBefore(h,D.nextSibling):(m=_.nodeType===9?_.head:_,m.insertBefore(h,m.firstChild))}function pA(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.title==null&&(h.title=m.title)}function gA(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.integrity==null&&(h.integrity=m.integrity)}var rv=null;function W5(h,m,_){if(rv===null){var S=new Map,P=rv=new Map;P.set(_,S)}else P=rv,S=P.get(_),S||(S=new Map,P.set(_,S));if(S.has(h))return S;for(S.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var D=_[P];if(!(D[at]||D[yr]||h==="link"&&D.getAttribute("rel")==="stylesheet")&&D.namespaceURI!=="http://www.w3.org/2000/svg"){var X=D.getAttribute(m)||"";X=h+X;var le=S.get(X);le?le.push(D):S.set(X,[D])}}return S}function q5(h,m,_){h=h.ownerDocument||h,h.head.insertBefore(_,m==="title"?h.querySelector("head > title"):null)}function bre(h,m,_){if(_===1||m.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof m.precedence!="string"||typeof m.href!="string"||m.href==="")break;return!0;case"link":if(typeof m.rel!="string"||typeof m.href!="string"||m.href===""||m.onLoad||m.onError)break;switch(m.rel){case"stylesheet":return h=m.disabled,typeof m.precedence=="string"&&h==null;default:return!0}case"script":if(m.async&&typeof m.async!="function"&&typeof m.async!="symbol"&&!m.onLoad&&!m.onError&&m.src&&typeof m.src=="string")return!0}return!1}function K5(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function yre(h,m,_,S){if(_.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Kf(S.href),D=m.querySelector(ex(P));if(D){m=D._p,m!==null&&typeof m=="object"&&typeof m.then=="function"&&(h.count++,h=iv.bind(h),m.then(h,h)),_.state.loading|=4,_.instance=D,Oe(D);return}D=m.ownerDocument||m,S=V5(S),(P=Fs.get(P))&&pA(S,P),D=D.createElement("link"),Oe(D);var X=D;X._p=new Promise(function(le,Te){X.onload=le,X.onerror=Te}),Gi(D,"link",S),_.instance=D}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,m),(m=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=iv.bind(h),m.addEventListener("load",_),m.addEventListener("error",_))}}var xA=0;function vre(h,m){return h.stylesheets&&h.count===0&&sv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var S=setTimeout(function(){if(h.stylesheets&&sv(h,h.stylesheets),h.unsuspend){var D=h.unsuspend;h.unsuspend=null,D()}},6e4+m);0<h.imgBytes&&xA===0&&(xA=62500*ere());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&sv(h,h.stylesheets),h.unsuspend)){var D=h.unsuspend;h.unsuspend=null,D()}},(h.imgBytes>xA?50:800)+m);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(S),clearTimeout(P)}}:null}function iv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)sv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var av=null;function sv(h,m){h.stylesheets=null,h.unsuspend!==null&&(h.count++,av=new Map,m.forEach(_re,h),av=null,iv.call(h))}function _re(h,m){if(!(m.state.loading&4)){var _=av.get(h);if(_)var S=_.get(null);else{_=new Map,av.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),D=0;D<P.length;D++){var X=P[D];(X.nodeName==="LINK"||X.getAttribute("media")!=="not all")&&(_.set(X.dataset.precedence,X),S=X)}S&&_.set(null,S)}P=m.instance,X=P.getAttribute("data-precedence"),D=_.get(X)||S,D===S&&_.set(null,P),_.set(X,P),this.count++,S=iv.bind(this),P.addEventListener("load",S),P.addEventListener("error",S),D?D.parentNode.insertBefore(P,D.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),m.state.loading|=4}}var nx={$$typeof:w,Provider:null,Consumer:null,_currentValue:te,_currentValue2:te,_threadCount:0};function wre(h,m,_,S,P,D,X,le,Te){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Et(0),this.hiddenUpdates=Et(null),this.identifierPrefix=S,this.onUncaughtError=P,this.onCaughtError=D,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Te,this.incompleteTransitions=new Map}function X5(h,m,_,S,P,D,X,le,Te,Ze,ct,ht){return h=new wre(h,m,_,X,Te,Ze,ct,ht,le),m=1,D===!0&&(m|=24),D=ls(3,null,null,m),h.current=D,D.stateNode=h,m=YE(),m.refCount++,h.pooledCache=m,m.refCount++,D.memoizedState={element:S,isDehydrated:_,cache:m},e2(D),h}function Y5(h){return h?(h=Af,h):Af}function Z5(h,m,_,S,P,D){P=Y5(P),S.context===null?S.context=P:S.pendingContext=P,S=nu(m),S.payload={element:_},D=D===void 0?null:D,D!==null&&(S.callback=D),_=ru(h,S,m),_!==null&&(Ba(_,h,m),Dg(_,h,m))}function Q5(h,m){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<m?_:m}}function bA(h,m){Q5(h,m),(h=h.alternate)&&Q5(h,m)}function J5(h){if(h.tag===13||h.tag===31){var m=Ld(h,67108864);m!==null&&Ba(m,h,67108864),bA(h,67108864)}}function eF(h){if(h.tag===13||h.tag===31){var m=fs();m=si(m);var _=Ld(h,m);_!==null&&Ba(_,h,m),bA(h,m)}}var ov=!0;function Sre(h,m,_,S){var P=K.T;K.T=null;var D=G.p;try{G.p=2,yA(h,m,_,S)}finally{G.p=D,K.T=P}}function Mre(h,m,_,S){var P=K.T;K.T=null;var D=G.p;try{G.p=8,yA(h,m,_,S)}finally{G.p=D,K.T=P}}function yA(h,m,_,S){if(ov){var P=vA(S);if(P===null)aA(h,m,S,lv,_),nF(h,S);else if(Are(P,h,m,_,S))S.stopPropagation();else if(nF(h,S),m&4&&-1<Ere.indexOf(h)){for(;P!==null;){var D=ae(P);if(D!==null)switch(D.tag){case 3:if(D=D.stateNode,D.current.memoizedState.isDehydrated){var X=ke(D.pendingLanes);if(X!==0){var le=D;for(le.pendingLanes|=2,le.entangledLanes|=2;X;){var Te=1<<31-$e(X);le.entanglements[1]|=Te,X&=~Te}Ko(D),(Pn&6)===0&&(Vy=L()+500,Yg(0))}}break;case 31:case 13:le=Ld(D,2),le!==null&&Ba(le,D,2),Wy(),bA(D,2)}if(D=vA(S),D===null&&aA(h,m,S,lv,_),D===P)break;P=D}P!==null&&S.stopPropagation()}else aA(h,m,S,null,_)}}function vA(h){return h=wE(h),_A(h)}var lv=null;function _A(h){if(lv=null,h=At(h),h!==null){var m=a(h);if(m===null)h=null;else{var _=m.tag;if(_===13){if(h=s(m),h!==null)return h;h=null}else if(_===31){if(h=o(m),h!==null)return h;h=null}else if(_===3){if(m.stateNode.current.memoizedState.isDehydrated)return m.tag===3?m.stateNode.containerInfo:null;h=null}else m!==h&&(h=null)}}return lv=h,null}function tF(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(re()){case ye:return 2;case we:return 8;case xe:case rt:return 32;case He:return 268435456;default:return 32}default:return 32}}var wA=!1,mu=null,pu=null,gu=null,rx=new Map,ix=new Map,xu=[],Ere="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 nF(h,m){switch(h){case"focusin":case"focusout":mu=null;break;case"dragenter":case"dragleave":pu=null;break;case"mouseover":case"mouseout":gu=null;break;case"pointerover":case"pointerout":rx.delete(m.pointerId);break;case"gotpointercapture":case"lostpointercapture":ix.delete(m.pointerId)}}function ax(h,m,_,S,P,D){return h===null||h.nativeEvent!==D?(h={blockedOn:m,domEventName:_,eventSystemFlags:S,nativeEvent:D,targetContainers:[P]},m!==null&&(m=ae(m),m!==null&&J5(m)),h):(h.eventSystemFlags|=S,m=h.targetContainers,P!==null&&m.indexOf(P)===-1&&m.push(P),h)}function Are(h,m,_,S,P){switch(m){case"focusin":return mu=ax(mu,h,m,_,S,P),!0;case"dragenter":return pu=ax(pu,h,m,_,S,P),!0;case"mouseover":return gu=ax(gu,h,m,_,S,P),!0;case"pointerover":var D=P.pointerId;return rx.set(D,ax(rx.get(D)||null,h,m,_,S,P)),!0;case"gotpointercapture":return D=P.pointerId,ix.set(D,ax(ix.get(D)||null,h,m,_,S,P)),!0}return!1}function rF(h){var m=At(h.target);if(m!==null){var _=a(m);if(_!==null){if(m=_.tag,m===13){if(m=s(_),m!==null){h.blockedOn=m,ra(h.priority,function(){eF(_)});return}}else if(m===31){if(m=o(_),m!==null){h.blockedOn=m,ra(h.priority,function(){eF(_)});return}}else if(m===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function cv(h){if(h.blockedOn!==null)return!1;for(var m=h.targetContainers;0<m.length;){var _=vA(h.nativeEvent);if(_===null){_=h.nativeEvent;var S=new _.constructor(_.type,_);_E=S,_.target.dispatchEvent(S),_E=null}else return m=ae(_),m!==null&&J5(m),h.blockedOn=_,!1;m.shift()}return!0}function iF(h,m,_){cv(h)&&_.delete(m)}function Tre(){wA=!1,mu!==null&&cv(mu)&&(mu=null),pu!==null&&cv(pu)&&(pu=null),gu!==null&&cv(gu)&&(gu=null),rx.forEach(iF),ix.forEach(iF)}function uv(h,m){h.blockedOn===m&&(h.blockedOn=null,wA||(wA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Tre)))}var dv=null;function aF(h){dv!==h&&(dv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){dv===h&&(dv=null);for(var m=0;m<h.length;m+=3){var _=h[m],S=h[m+1],P=h[m+2];if(typeof S!="function"){if(_A(S||_)===null)continue;break}var D=ae(_);D!==null&&(h.splice(m,3),m-=3,v2(D,{pending:!0,data:P,method:_.method,action:S},S,P))}}))}function Yf(h){function m(Te){return uv(Te,h)}mu!==null&&uv(mu,h),pu!==null&&uv(pu,h),gu!==null&&uv(gu,h),rx.forEach(m),ix.forEach(m);for(var _=0;_<xu.length;_++){var S=xu[_];S.blockedOn===h&&(S.blockedOn=null)}for(;0<xu.length&&(_=xu[0],_.blockedOn===null);)rF(_),_.blockedOn===null&&xu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(S=0;S<_.length;S+=3){var P=_[S],D=_[S+1],X=P[Lr]||null;if(typeof D=="function")X||aF(_);else if(X){var le=null;if(D&&D.hasAttribute("formAction")){if(P=D,X=D[Lr]||null)le=X.formAction;else if(_A(P)!==null)continue}else le=X.action;typeof le=="function"?_[S+1]=le:(_.splice(S,3),S-=3),aF(_)}}}function sF(){function h(D){D.canIntercept&&D.info==="react-transition"&&D.intercept({handler:function(){return new Promise(function(X){return P=X})},focusReset:"manual",scroll:"manual"})}function m(){P!==null&&(P(),P=null),S||setTimeout(_,20)}function _(){if(!S&&!navigation.transition){var D=navigation.currentEntry;D&&D.url!=null&&navigation.navigate(D.url,{state:D.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",m),navigation.addEventListener("navigateerror",m),setTimeout(_,100),function(){S=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",m),navigation.removeEventListener("navigateerror",m),P!==null&&(P(),P=null)}}}function SA(h){this._internalRoot=h}hv.prototype.render=SA.prototype.render=function(h){var m=this._internalRoot;if(m===null)throw Error(r(409));var _=m.current,S=fs();Z5(_,S,h,m,null,null)},hv.prototype.unmount=SA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var m=h.containerInfo;Z5(h.current,2,null,h,null,null),Wy(),m[go]=null}};function hv(h){this._internalRoot=h}hv.prototype.unstable_scheduleHydration=function(h){if(h){var m=zi();h={blockedOn:null,target:h,priority:m};for(var _=0;_<xu.length&&m!==0&&m<xu[_].priority;_++);xu.splice(_,0,h),_===0&&rF(h)}};var oF=e.version;if(oF!=="19.2.0")throw Error(r(527,oF,"19.2.0"));G.findDOMNode=function(h){var m=h._reactInternals;if(m===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(m),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Cre={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var fv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!fv.isDisabled&&fv.supportsFiber)try{Ue=fv.inject(Cre),oe=fv}catch{}}return ox.createRoot=function(h,m){if(!i(h))throw Error(r(299));var _=!1,S="",P=mI,D=pI,X=gI;return m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(S=m.identifierPrefix),m.onUncaughtError!==void 0&&(P=m.onUncaughtError),m.onCaughtError!==void 0&&(D=m.onCaughtError),m.onRecoverableError!==void 0&&(X=m.onRecoverableError)),m=X5(h,1,!1,null,null,_,S,null,P,D,X,sF),h[go]=m.current,iA(h),new SA(m)},ox.hydrateRoot=function(h,m,_){if(!i(h))throw Error(r(299));var S=!1,P="",D=mI,X=pI,le=gI,Te=null;return _!=null&&(_.unstable_strictMode===!0&&(S=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(D=_.onUncaughtError),_.onCaughtError!==void 0&&(X=_.onCaughtError),_.onRecoverableError!==void 0&&(le=_.onRecoverableError),_.formState!==void 0&&(Te=_.formState)),m=X5(h,1,!0,m,_??null,S,P,Te,D,X,le,sF),m.context=Y5(null),_=m.current,S=fs(),S=si(S),P=nu(S),P.callback=null,ru(_,P,S),_=S,m.current.lanes=_,Qt(m,_),Ko(m),h[go]=m.current,iA(h),new hv(m)},ox.version="19.2.0",ox}var xF;function Ure(){if(xF)return AA.exports;xF=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),AA.exports=Fre(),AA.exports}var zre=Ure();const qt=t=>typeof t=="string",lx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},bF=t=>t==null?"":""+t,Bre=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Hre=/###/g,yF=t=>t&&t.indexOf("###")>-1?t.replace(Hre,"."):t,vF=t=>!t||qt(t),Xx=(t,e,n)=>{const r=qt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(vF(t))return{};const a=yF(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return vF(t)?{}:{obj:t,k:yF(r[i])}},_F=(t,e,n)=>{const{obj:r,k:i}=Xx(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],s=e.slice(0,e.length-1),o=Xx(t,s,Object);for(;o.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),o=Xx(t,s,Object),o?.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=n},$re=(t,e,n,r)=>{const{obj:i,k:a}=Xx(t,e,Object);i[a]=i[a]||[],i[a].push(n)},M1=(t,e)=>{const{obj:n,k:r}=Xx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Vre=(t,e,n)=>{const r=M1(t,n);return r!==void 0?r:M1(e,n)},N9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?qt(t[r])||t[r]instanceof String||qt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):N9(t[r],e[r],n):t[r]=e[r]);return t},Zf=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Gre={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Wre=t=>qt(t)?t.replace(/[&<>"'\/]/g,e=>Gre[e]):t;class qre{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 Kre=[" ",",","?","!",";"],Xre=new qre(20),Yre=(t,e,n)=>{e=e||"",n=n||"";const r=Kre.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=Xre.getRegExp(`(${r.map(s=>s==="?"?"\\?":s).join("|")})`);let a=!i.test(t);if(!a){const s=t.indexOf(n);s>0&&!i.test(t.substring(0,s))&&(a=!0)}return a},wk=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let s,o="";for(let c=a;c<r.length;++c)if(c!==a&&(o+=n),o+=r[c],s=i[o],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=s}return i},b0=t=>t?.replace("_","-"),Zre={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 E1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Zre,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:(qt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new E1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new E1(this.logger,e)}}var al=new E1;let US=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i.apply(i,[e,...n])})}};class wF extends US{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],r&&(Array.isArray(r)?o.push(...r):qt(r)&&a?o.push(...r.split(a)):o.push(r)));const c=M1(this.data,o);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),c||!s||!qt(r)?c:wk(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),_F(this.data,o,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(qt(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,s={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let c=M1(this.data,o)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?N9(c,r,a):c={...c,...r},_F(this.data,o,c),s.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var k9={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const P9=Symbol("i18next/PATH_KEY");function Qre(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===P9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Sk(t,e){const{[P9]:n}=t(Qre());return n.join(e?.keySeparator??".")}const SF={},kA=t=>!qt(t)&&typeof t!="boolean"&&typeof t!="number";class A1 extends US{constructor(e,n={}){super(),Bre(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=al.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=kA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const s=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Yre(e,r,i);if(s&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:qt(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:qt(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=Sk(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${u}${d}${o}`,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${o}`:a?{res:o,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const p=this.resolve(e,i);let x=p?.res;const v=p?.usedKey||o,y=p?.exactUsedKey||o,b=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!qt(i.count),T=A1.hasDefaultValue(i),C=A?this.pluralResolver.getSuffix(f,i.count,i):"",k=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",F=A&&!i.ordinal&&i.count===0,N=F&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${k}`]||i.defaultValue;let j=x;w&&!x&&T&&(j=N);const I=kA(j),O=Object.prototype.toString.apply(j);if(w&&j&&I&&b.indexOf(O)<0&&!(qt(E)&&Array.isArray(j))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,j,{...i,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return a?(p.res=q,p.usedParams=this.getUsedParamsDetails(i),p):q}if(s){const q=Array.isArray(j),R=q?[]:{},W=q?y:v;for(const K in j)if(Object.prototype.hasOwnProperty.call(j,K)){const G=`${W}${s}${K}`;T&&!x?R[K]=this.translate(G,{...i,defaultValue:kA(N)?N[K]:void 0,joinArrays:!1,ns:c}):R[K]=this.translate(G,{...i,joinArrays:!1,ns:c}),R[K]===G&&(R[K]=j[K])}x=R}}else if(w&&qt(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(x)&&T&&(q=!0,x=N),this.isValidLookup(x)||(R=!0,x=o);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:x,G=T&&N!==x&&this.options.updateMissing;if(R||q||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,o,G?N:x),s){const U=this.resolve(o,{...i,keySeparator:!1});U&&U.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 te=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let U=0;U<Y.length;U++)te.push(Y[U]);else this.options.saveMissingTo==="all"?te=this.languageUtils.toResolveHierarchy(i.lng||this.language):te.push(i.lng||this.language);const J=(U,H,ee)=>{const ie=T&&ee!==x?ee:K;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,H,ie,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,H,ie,G,i),this.emit("missingKey",U,u,H,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?te.forEach(U=>{const H=this.pluralResolver.getSuffixes(U,i);F&&i[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(ee=>{J([U],o+ee,i[`defaultValue${ee}`]||N)})}):J(te,o,N))}x=this.extendTranslation(x,e,i,p,r),R&&x===o&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${o}`),(R||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${o}`:o,q?x:void 0,i))}return a?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=qt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!qt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const s=r.postProcess||this.options.postProcess,o=qt(s)?[s]:s;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=k9.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,s,o;return qt(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!qt(n.count),p=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(qt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(y=>{this.isValidLookup(r)||(o=y,!SF[`${v[0]}-${y}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(SF[`${v[0]}-${y}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(b=>{if(this.isValidLookup(r))return;s=b;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,b,y,n);else{let A;g&&(A=this.pluralResolver.getSuffix(b,n.count,n));const T=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&A.indexOf(C)===0&&E.push(d+A.replace(C,this.options.pluralSeparator)),E.push(d+A),p&&E.push(d+T)),x){const k=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(k),g&&(n.ordinal&&A.indexOf(C)===0&&E.push(k+A.replace(C,this.options.pluralSeparator)),E.push(k+A),p&&E.push(k+T))}}let w;for(;w=E.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(b,y,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:s,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!qt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class MF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=al.create("languageUtils")}getScriptPartFromCode(e){if(e=b0(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=b0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(qt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),qt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],a=s=>{s&&(this.isSupportedCode(s)?i.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return qt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):qt(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const EF={zero:0,one:1,two:2,few:3,many:4,other:5},AF={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Jre{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=al.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=b0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let s;try{s=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),AF;if(!e.match(/-|_/))return AF;const c=this.languageUtils.getLanguagePartFromCode(e);s=this.getRule(c,n)}return this.pluralRulesCache[a]=s,s}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,a)=>EF[i]-EF[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const TF=(t,e,n,r=".",i=!0)=>{let a=Vre(t,e,n);return!a&&i&&qt(n)&&(a=wk(t,n,r),a===void 0&&(a=wk(e,n,r))),a},PA=t=>t.replace(/\$/g,"$$$$");class eie{constructor(e={}){this.logger=al.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:s,suffix:o,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:v,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:Wre,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Zf(a):s||"{{",this.suffix=o?Zf(o):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?Zf(g):p||Zf("$t("),this.nestingSuffix=x?Zf(x):v||Zf(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=E!==void 0?E:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,s,o;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const b=TF(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(b,void 0,r,{...i,...n,interpolationkey:p}):b}const x=p.split(this.formatSeparator),v=x.shift().trim(),y=x.join(this.formatSeparator).trim();return this.format(TF(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>PA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?PA(this.escape(p)):PA(p)}].forEach(p=>{for(o=0;a=p.regex.exec(e);){const x=a[1].trim();if(s=u(x),s===void 0)if(typeof d=="function"){const y=d(e,a,i);s=qt(y)?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),s="";else!qt(s)&&!this.useRawValueToEscape&&(s=bF(s));const v=p.safeValue(s);if(e=e.replace(a[0],v),f?(p.regex.lastIndex+=s.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,s;const o=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;c=f[0],g=this.interpolate(g,s);const p=g.match(/'/g),x=g.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{s=JSON.parse(g),u&&(s={...u,...s})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${g}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];s={...r},s=s.replace&&!qt(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),a=n(o.call(this,i[1].trim(),s),s),a&&i[0]===e&&!qt(a))return a;qt(a)||(a=bF(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const tie=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(s=>{if(s){const[o,...c]=s.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=o.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},CF=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const s=r+JSON.stringify(a);let o=e[s];return o||(o=t(b0(r),i),e[s]=o),o(n)}},nie=t=>(e,n,r)=>t(b0(n),r)(e);class rie{constructor(e={}){this.logger=al.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?CF:nie;this.formats={number:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a});return o=>s.format(o)}),currency:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a,style:"currency"});return o=>s.format(o)}),datetime:r((i,a)=>{const s=new Intl.DateTimeFormat(i,{...a});return o=>s.format(o)}),relativetime:r((i,a)=>{const s=new Intl.RelativeTimeFormat(i,{...a});return o=>s.format(o,a.range||"day")}),list:r((i,a)=>{const s=new Intl.ListFormat(i,{...a});return o=>s.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=CF(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(o=>o.indexOf(")")>-1)){const o=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,c)=>{const{formatName:u,formatOptions:d}=tie(c);if(this.formats[u]){let f=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},p=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[u](o,p,{...d,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const iie=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class aie extends US{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=al.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},s={},o={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?s[g]===void 0&&(s[g]=!0):(this.state[g]=1,d=!1,s[g]===void 0&&(s[g]=!0),a[g]===void 0&&(a[g]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(o[u]=!0)}),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],s=i[1];n&&this.emit("failedLoading",a,s,n),!n&&r&&this.store.addResourceBundle(a,s,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const o={};this.queue.forEach(c=>{$re(c.loaded,[a],s),iie(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{o[u]||(o[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{o[u][f]===void 0&&(o[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,s){if(!e.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:s});return}this.readingCalls++;const o=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,s)},a);return}s(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}return}return c(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();qt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),qt(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(s=>{this.loadOne(s)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(s,o)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,s),!s&&o&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,o),this.loaded(e,s,o)})}saveMissing(e,n,r,i,a,s={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...s,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>o(null,f)).catch(o):o(null,d)}catch(d){o(d)}else u(e,n,r,i,o,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const NF=()=>({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]),qt(t[1])&&(e.defaultValue=t[1]),qt(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}),kF=t=>(qt(t.ns)&&(t.ns=[t.ns]),qt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),qt(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),pv=()=>{},sie=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Yx extends US{constructor(e={},n){if(super(),this.options=kF(e),this.services={},this.logger=al,this.modules={external:[]},sie(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&&(qt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=NF();this.options={...r,...this.options,...kF(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?al.init(i(this.modules.logger),this.options):al.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=rie;const d=new MF(this.options);this.store=new wF(this.options.resources,this.options);const f=this.services;f.logger=al,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Jre(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new eie(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new aie(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new A1(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=pv),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const o=lx(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),o}loadResources(e,n=pv){let r=n;const i=qt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],s=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>s(c)),this.options.preload?.forEach?.(o=>s(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=lx();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=pv),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&k9.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=lx();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},a=(o,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(o,(...u)=>this.t(...u))},s=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const c=qt(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(qt(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),r}getFixedT(e,n,r){const i=(a,s,...o)=>{let c;typeof s!="object"?c=this.options.overloadTranslationOptionHandler([a,s].concat(o)):c={...s},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(a)?d=a.map(f=>(typeof f=="function"&&(f=Sk(f,{...this.options,...s})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Sk(a,{...this.options,...s})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return qt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const s=(o,c)=>{const u=this.services.backendConnector.state[`${o}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const o=n.precheck(this,s);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,e)&&(!i||s(a,e)))}loadNamespaces(e,n){const r=lx();return this.options.ns?(qt(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=lx();qt(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(s=>i.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return a.length?(this.options.preload=i.concat(a),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new MF(NF());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 Yx(e,n);return r.createInstance=Yx.createInstance,r}cloneInstance(e={},n=pv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new Yx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const o=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new wF(o,i),a.services.resourceStore=a.store}return a.translator=new A1(a.services,i),a.translator.on("*",(o,...c)=>{a.emit(o,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Oa=Yx.createInstance();Oa.createInstance;Oa.dir;Oa.init;Oa.loadResources;Oa.reloadResources;Oa.use;Oa.changeLanguage;Oa.getFixedT;Oa.t;Oa.exists;Oa.setDefaultNamespace;Oa.hasLoadedNamespace;Oa.loadNamespaces;Oa.loadLanguages;const oie=(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);Hh(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},PF={},R9=(t,e,n,r)=>{Hh(n)&&PF[n]||(Hh(n)&&(PF[n]=new Date),oie(t,e,n,r))},j9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Mk=(t,e,n)=>{t.loadNamespaces(e,j9(t,n))},RF=(t,e,n,r)=>{if(Hh(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Mk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,j9(t,r))},lie=(t,e,n={})=>!e.languages||!e.languages.length?(R9(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}}),Hh=t=>typeof t=="string",cie=t=>typeof t=="object"&&t!==null,uie=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,die={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},hie=t=>die[t],fie=t=>t.replace(uie,hie);let Ek={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:fie};const mie=(t={})=>{Ek={...Ek,...t}},pie=()=>Ek;let D9;const gie=t=>{D9=t},xie=()=>D9,bie={type:"3rdParty",init(t){mie(t.options.react),gie(t)}},yie=M.createContext();class vie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var RA={exports:{}},jA={};var jF;function _ie(){if(jF)return jA;jF=1;var t=qp();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function o(f,g){var p=g(),x=r({inst:{value:p,getSnapshot:g}}),v=x[0].inst,y=x[1];return a(function(){v.value=p,v.getSnapshot=g,c(v)&&y({inst:v})},[f,p,g]),i(function(){return c(v)&&y({inst:v}),f(function(){c(v)&&y({inst:v})})},[f]),s(p),p}function c(f){var g=f.getSnapshot;f=f.value;try{var p=g();return!n(f,p)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:o;return jA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,jA}var DF;function O9(){return DF||(DF=1,RA.exports=_ie()),RA.exports}var jR=O9();const wie=(t,e)=>Hh(e)?e:cie(e)&&Hh(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Sie={t:wie,ready:!1},Mie=()=>()=>{},Kp=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=M.useContext(yie)||{},a=n||r||xie();a&&!a.reportNamespaces&&(a.reportNamespaces=new vie),a||R9(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=M.useMemo(()=>({...pie(),...a?.options?.react,...e}),[a,e]),{useSuspense:o,keyPrefix:c}=s,u=i||a?.options?.defaultNS,d=Hh(u)?[u]:u||["translation"],f=M.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const g=M.useRef(0),p=M.useCallback(N=>{if(!a)return Mie;const{bindI18n:j,bindI18nStore:I}=s,O=()=>{g.current+=1,N()};return j&&a.on(j,O),I&&a.store.on(I,O),()=>{j&&j.split(" ").forEach(q=>a.off(q,O)),I&&I.split(" ").forEach(q=>a.store.off(q,O))}},[a,s]),x=M.useRef(),v=M.useCallback(()=>{if(!a)return Sie;const N=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>lie(W,a,s)),j=e.lng||a.language,I=g.current,O=x.current;if(O&&O.ready===N&&O.lng===j&&O.keyPrefix===c&&O.revision===I)return O;const R={t:a.getFixedT(j,s.nsMode==="fallback"?f:f[0],c),ready:N,lng:j,keyPrefix:c,revision:I};return x.current=R,R},[a,f,c,s,e.lng]),[y,b]=M.useState(0),{t:E,ready:w}=jR.useSyncExternalStore(p,v,v);M.useEffect(()=>{if(a&&!w&&!o){const N=()=>b(j=>j+1);e.lng?RF(a,e.lng,f,N):Mk(a,f,N)}},[a,e.lng,f,w,o,y]);const A=a||{},T=M.useRef(null),C=M.useRef(),k=N=>{const j=Object.getOwnPropertyDescriptors(N);j.__original&&delete j.__original;const I=Object.create(Object.getPrototypeOf(N),j);if(!Object.prototype.hasOwnProperty.call(I,"__original"))try{Object.defineProperty(I,"__original",{value:N,writable:!1,enumerable:!1,configurable:!1})}catch{}return I},F=M.useMemo(()=>{const N=A,j=N?.language;let I=N;N&&(T.current&&T.current.__original===N?C.current!==j?(I=k(N),T.current=I,C.current=j):I=T.current:(I=k(N),T.current=I,C.current=j));const O=[E,I,w];return O.t=E,O.i18n=I,O.ready=w,O},[E,A,w,A.resolvedLanguage,A.language,A.languages]);if(a&&o&&!w)throw new Promise(N=>{const j=()=>N();e.lng?RF(a,e.lng,f,j):Mk(a,f,j)});return F},{slice:Eie,forEach:Aie}=[];function Tie(t){return Aie.call(Eie.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Cie(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 OF=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Nie=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const s=r.maxAge-0;if(Number.isNaN(s))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(s)}`}if(r.domain){if(!OF.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!OF.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},LF={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=Nie(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 kie={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return LF.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&LF.create(n,t,r,i,a)}},Pie={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let s=0;s<a.length;s++){const o=a[s].indexOf("=");o>0&&a[s].substring(0,o)===e&&(n=a[s].substring(o+1))}}return n}},Rie={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const s=a.split("&");for(let o=0;o<s.length;o++){const c=s[o].indexOf("=");c>0&&s[o].substring(0,c)===e&&(r=s[o].substring(c+1))}}if(r)return r;if(!r&&n>-1){const s=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(s)?s[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let Qf=null;const IF=()=>{if(Qf!==null)return Qf;try{if(Qf=typeof window<"u"&&window.localStorage!==null,!Qf)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Qf=!1}return Qf};var jie={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&IF())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&IF()&&window.localStorage.setItem(n,t)}};let Jf=null;const FF=()=>{if(Jf!==null)return Jf;try{if(Jf=typeof window<"u"&&window.sessionStorage!==null,!Jf)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Jf=!1}return Jf};var Die={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&FF())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&FF()&&window.sessionStorage.setItem(n,t)}},Oie={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Lie={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}},Iie={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}},Fie={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 L9=!1;try{document.cookie,L9=!0}catch{}const I9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];L9||I9.splice(1,1);const Uie=()=>({order:I9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class F9{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=Tie(n,this.options||{},Uie()),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(kie),this.addDetector(Pie),this.addDetector(jie),this.addDetector(Die),this.addDetector(Oie),this.addDetector(Lie),this.addDetector(Iie),this.addDetector(Fie),this.addDetector(Rie)}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&&!Cie(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)}))}}F9.type="languageDetector";const zie={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app and which versions are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"IP addresses or location data",telemetryInfoNotItem2:"Printer names, serial numbers, or any printer data",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Bie={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},Hie={en:{translation:zie},de:{translation:Bie}};Oa.use(F9).use(bie).init({resources:Hie,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const UF=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var zF="popstate";function $ie(t={}){function e(r,i){let{pathname:a,search:s,hash:o}=r.location;return Ak("",{pathname:a,search:s,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:y0(i)}return Gie(e,n,null,t)}function wr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Fo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Vie(){return Math.random().toString(36).substring(2,10)}function BF(t,e){return{usr:t.state,key:t.key,idx:e}}function Ak(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Xp(e):e,state:n,key:e&&e.key||r||Vie()}}function y0({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 Xp(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 Gie(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,s=i.history,o="POP",c=null,u=d();u==null&&(u=0,s.replaceState({...s.state,idx:u},""));function d(){return(s.state||{idx:null}).idx}function f(){o="POP";let y=d(),b=y==null?null:y-u;u=y,c&&c({action:o,location:v.location,delta:b})}function g(y,b){o="PUSH";let E=Ak(v.location,y,b);u=d()+1;let w=BF(E,u),A=v.createHref(E);try{s.pushState(w,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}a&&c&&c({action:o,location:v.location,delta:1})}function p(y,b){o="REPLACE";let E=Ak(v.location,y,b);u=d();let w=BF(E,u),A=v.createHref(E);s.replaceState(w,"",A),a&&c&&c({action:o,location:v.location,delta:0})}function x(y){return Wie(y)}let v={get action(){return o},get location(){return t(i,s)},listen(y){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(zF,f),c=y,()=>{i.removeEventListener(zF,f),c=null}},createHref(y){return e(i,y)},createURL:x,encodeLocation(y){let b=x(y);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:g,replace:p,go(y){return s.go(y)}};return v}function Wie(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),wr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:y0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function U9(t,e,n="/"){return qie(t,e,n,!1)}function qie(t,e,n,r){let i=typeof e=="string"?Xp(e):e,a=kc(i.pathname||"/",n);if(a==null)return null;let s=z9(t);Kie(s);let o=null;for(let c=0;o==null&&c<s.length;++c){let u=aae(a);o=rae(s[c],u,r)}return o}function z9(t,e=[],n=[],r="",i=!1){let a=(s,o,c=i,u)=>{let d={relativePath:u===void 0?s.path||"":u,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;wr(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=_c([r,d.relativePath]),g=n.concat(d);s.children&&s.children.length>0&&(wr(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),z9(s.children,e,g,f,c)),!(s.path==null&&!s.index)&&e.push({path:f,score:tae(f,s.index),routesMeta:g})};return t.forEach((s,o)=>{if(s.path===""||!s.path?.includes("?"))a(s,o);else for(let c of B9(s.path))a(s,o,!0,c)}),e}function B9(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let s=B9(r.join("/")),o=[];return o.push(...s.map(c=>c===""?a:[a,c].join("/"))),i&&o.push(...s),o.map(c=>t.startsWith("/")&&c===""?"/":c)}function Kie(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:nae(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Xie=/^:[\w-]+$/,Yie=3,Zie=2,Qie=1,Jie=10,eae=-2,HF=t=>t==="*";function tae(t,e){let n=t.split("/"),r=n.length;return n.some(HF)&&(r+=eae),e&&(r+=Zie),n.filter(i=>!HF(i)).reduce((i,a)=>i+(Xie.test(a)?Yie:a===""?Qie:Jie),r)}function nae(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 rae(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",s=[];for(let o=0;o<r.length;++o){let c=r[o],u=o===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=T1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=T1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),s.push({params:i,pathname:_c([a,f.pathname]),pathnameBase:uae(_c([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=_c([a,f.pathnameBase]))}return s}function T1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=iae(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],s=a.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=o[g]||"";s=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=o[g];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:s,pattern:t}}function iae(t,e=!1,n=!0){Fo(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function aae(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Fo(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function kc(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}var sae=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,oae=t=>sae.test(t);function lae(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Xp(t):t,a;if(n)if(oae(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Fo(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=$F(n.substring(1),"/"):a=$F(n,e)}else a=e;return{pathname:a,search:dae(r),hash:hae(i)}}function $F(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 DA(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 cae(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function H9(t){let e=cae(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function $9(t,e,n,r=!1){let i;typeof t=="string"?i=Xp(t):(i={...t},wr(!i.pathname||!i.pathname.includes("?"),DA("?","pathname","search",i)),wr(!i.pathname||!i.pathname.includes("#"),DA("#","pathname","hash",i)),wr(!i.search||!i.search.includes("#"),DA("#","search","hash",i)));let a=t===""||i.pathname==="",s=a?"/":i.pathname,o;if(s==null)o=n;else{let f=e.length-1;if(!r&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}o=f>=0?e[f]:"/"}let c=lae(i,o),u=s&&s!=="/"&&s.endsWith("/"),d=(a||s===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var _c=t=>t.join("/").replace(/\/\/+/g,"/"),uae=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),dae=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,hae=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function fae(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 V9=["POST","PUT","PATCH","DELETE"];new Set(V9);var mae=["GET",...V9];new Set(mae);var Yp=M.createContext(null);Yp.displayName="DataRouter";var zS=M.createContext(null);zS.displayName="DataRouterState";M.createContext(!1);var G9=M.createContext({isTransitioning:!1});G9.displayName="ViewTransition";var pae=M.createContext(new Map);pae.displayName="Fetchers";var gae=M.createContext(null);gae.displayName="Await";var wl=M.createContext(null);wl.displayName="Navigation";var mb=M.createContext(null);mb.displayName="Location";var Bo=M.createContext({outlet:null,matches:[],isDataRoute:!1});Bo.displayName="Route";var DR=M.createContext(null);DR.displayName="RouteError";function xae(t,{relative:e}={}){wr(pb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=M.useContext(wl),{hash:i,pathname:a,search:s}=xb(t,{relative:e}),o=a;return n!=="/"&&(o=a==="/"?n:_c([n,a])),r.createHref({pathname:o,search:s,hash:i})}function pb(){return M.useContext(mb)!=null}function Md(){return wr(pb(),"useLocation() may be used only in the context of a <Router> component."),M.useContext(mb).location}var W9="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function q9(t){M.useContext(wl).static||M.useLayoutEffect(t)}function gb(){let{isDataRoute:t}=M.useContext(Bo);return t?Rae():bae()}function bae(){wr(pb(),"useNavigate() may be used only in the context of a <Router> component.");let t=M.useContext(Yp),{basename:e,navigator:n}=M.useContext(wl),{matches:r}=M.useContext(Bo),{pathname:i}=Md(),a=JSON.stringify(H9(r)),s=M.useRef(!1);return q9(()=>{s.current=!0}),M.useCallback((c,u={})=>{if(Fo(s.current,W9),!s.current)return;if(typeof c=="number"){n.go(c);return}let d=$9(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:_c([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var yae=M.createContext(null);function vae(t){let e=M.useContext(Bo).outlet;return M.useMemo(()=>e&&M.createElement(yae.Provider,{value:t},e),[e,t])}function OR(){let{matches:t}=M.useContext(Bo),e=t[t.length-1];return e?e.params:{}}function xb(t,{relative:e}={}){let{matches:n}=M.useContext(Bo),{pathname:r}=Md(),i=JSON.stringify(H9(n));return M.useMemo(()=>$9(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function _ae(t,e){return K9(t,e)}function K9(t,e,n,r,i){wr(pb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=M.useContext(wl),{matches:s}=M.useContext(Bo),o=s[s.length-1],c=o?o.params:{},u=o?o.pathname:"/",d=o?o.pathnameBase:"/",f=o&&o.route;{let E=f&&f.path||"";X9(u,!f||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  10. Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let g=Md(),p;if(e){let E=typeof e=="string"?Xp(e):e;wr(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),p=E}else p=g;let x=p.pathname||"/",v=x;if(d!=="/"){let E=d.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let y=U9(t,{pathname:v});Fo(f||y!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Fo(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=Aae(y&&y.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:_c([d,a.encodeLocation?a.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:_c([d,a.encodeLocation?a.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),s,n,r,i);return e&&b?M.createElement(mb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},b):b}function wae(){let t=Pae(),e=fae(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},s=null;return console.error("Error handled by React Router default ErrorBoundary:",t),s=M.createElement(M.Fragment,null,M.createElement("p",null,"💿 Hey developer 👋"),M.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",M.createElement("code",{style:a},"ErrorBoundary")," or"," ",M.createElement("code",{style:a},"errorElement")," prop on your route.")),M.createElement(M.Fragment,null,M.createElement("h2",null,"Unexpected Application Error!"),M.createElement("h3",{style:{fontStyle:"italic"}},e),n?M.createElement("pre",{style:i},n):null,s)}var Sae=M.createElement(wae,null),Mae=class extends M.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?M.createElement(Bo.Provider,{value:this.props.routeContext},M.createElement(DR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Eae({routeContext:t,match:e,children:n}){let r=M.useContext(Yp);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),M.createElement(Bo.Provider,{value:t},n)}function Aae(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,s=n?.errors;if(s!=null){let d=a.findIndex(f=>f.route.id&&s?.[f.route.id]!==void 0);wr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:g,errors:p}=n,x=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||x){o=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,g)=>{let p,x=!1,v=null,y=null;n&&(p=s&&f.route.id?s[f.route.id]:void 0,v=f.route.errorElement||Sae,o&&(c<0&&g===0?(X9("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,y=null):c===g&&(x=!0,y=f.route.hydrateFallbackElement||null)));let b=e.concat(a.slice(0,g+1)),E=()=>{let w;return p?w=v:x?w=y:f.route.Component?w=M.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,M.createElement(Eae,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?M.createElement(Mae,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:E(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):E()},null)}function LR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Tae(t){let e=M.useContext(Yp);return wr(e,LR(t)),e}function Cae(t){let e=M.useContext(zS);return wr(e,LR(t)),e}function Nae(t){let e=M.useContext(Bo);return wr(e,LR(t)),e}function IR(t){let e=Nae(t),n=e.matches[e.matches.length-1];return wr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function kae(){return IR("useRouteId")}function Pae(){let t=M.useContext(DR),e=Cae("useRouteError"),n=IR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Rae(){let{router:t}=Tae("useNavigate"),e=IR("useNavigate"),n=M.useRef(!1);return q9(()=>{n.current=!0}),M.useCallback(async(i,a={})=>{Fo(n.current,W9),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var VF={};function X9(t,e,n){!e&&!VF[t]&&(VF[t]=!0,Fo(!1,n))}M.memo(jae);function jae({routes:t,future:e,state:n,unstable_onError:r}){return K9(t,void 0,n,r,e)}function Dae(t){return vae(t.context)}function Va(t){wr(!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 Oae({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){wr(!pb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),o=M.useMemo(()=>({basename:s,navigator:i,static:a,future:{}}),[s,i,a]);typeof n=="string"&&(n=Xp(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,p=M.useMemo(()=>{let x=kc(c,s);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[s,c,u,d,f,g,r]);return Fo(p!=null,`<Router basename="${s}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:M.createElement(wl.Provider,{value:o},M.createElement(mb.Provider,{children:e,value:p}))}function Lae({children:t,location:e}){return _ae(Tk(t),e)}function Tk(t,e=[]){let n=[];return M.Children.forEach(t,(r,i)=>{if(!M.isValidElement(r))return;let a=[...e,i];if(r.type===M.Fragment){n.push.apply(n,Tk(r.props.children,a));return}wr(r.type===Va,`[${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>`),wr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(s.children=Tk(r.props.children,a)),n.push(s)}),n}var e1="get",t1="application/x-www-form-urlencoded";function BS(t){return t!=null&&typeof t.tagName=="string"}function Iae(t){return BS(t)&&t.tagName.toLowerCase()==="button"}function Fae(t){return BS(t)&&t.tagName.toLowerCase()==="form"}function Uae(t){return BS(t)&&t.tagName.toLowerCase()==="input"}function zae(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Bae(t,e){return t.button===0&&(!e||e==="_self")&&!zae(t)}var gv=null;function Hae(){if(gv===null)try{new FormData(document.createElement("form"),0),gv=!1}catch{gv=!0}return gv}var $ae=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function OA(t){return t!=null&&!$ae.has(t)?(Fo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${t1}"`),null):t}function Vae(t,e){let n,r,i,a,s;if(Fae(t)){let o=t.getAttribute("action");r=o?kc(o,e):null,n=t.getAttribute("method")||e1,i=OA(t.getAttribute("enctype"))||t1,a=new FormData(t)}else if(Iae(t)||Uae(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 c=t.getAttribute("formaction")||o.getAttribute("action");if(r=c?kc(c,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||e1,i=OA(t.getAttribute("formenctype"))||OA(o.getAttribute("enctype"))||t1,a=new FormData(o,t),!Hae()){let{name:u,type:d,value:f}=t;if(d==="image"){let g=u?`${u}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else u&&a.append(u,f)}}else{if(BS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=e1,r=null,i=t1,s=t}return a&&i==="text/plain"&&(s=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function FR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Gae(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&kc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Wae(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 qae(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 Kae(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await Wae(a,n);return s.links?s.links():[]}return[]}));return Qae(r.flat(1).filter(qae).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function GF(t,e,n,r,i,a){let s=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,o=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>s(c,u)||o(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(s(c,u)||o(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Xae(t,e,{includeHydrateFallback:n}={}){return Yae(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function Yae(t){return[...new Set(t)]}function Zae(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Qae(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Zae(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function Y9(){let t=M.useContext(Yp);return FR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Jae(){let t=M.useContext(zS);return FR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var UR=M.createContext(void 0);UR.displayName="FrameworkContext";function Z9(){let t=M.useContext(UR);return FR(t,"You must render this element inside a <HydratedRouter> element"),t}function ese(t,e){let n=M.useContext(UR),[r,i]=M.useState(!1),[a,s]=M.useState(!1),{onFocus:o,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=M.useRef(null);M.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let v=b=>{b.forEach(E=>{s(E.isIntersecting)})},y=new IntersectionObserver(v,{threshold:.5});return g.current&&y.observe(g.current),()=>{y.disconnect()}}},[t]),M.useEffect(()=>{if(r){let v=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(v)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:cx(o,p),onBlur:cx(c,x),onMouseEnter:cx(u,p),onMouseLeave:cx(d,x),onTouchStart:cx(f,p)}]:[!1,g,{}]}function cx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function tse({page:t,...e}){let{router:n}=Y9(),r=M.useMemo(()=>U9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?M.createElement(rse,{page:t,matches:r,...e}):null}function nse(t){let{manifest:e,routeModules:n}=Z9(),[r,i]=M.useState([]);return M.useEffect(()=>{let a=!1;return Kae(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function rse({page:t,matches:e,...n}){let r=Md(),{manifest:i,routeModules:a}=Z9(),{basename:s}=Y9(),{loaderData:o,matches:c}=Jae(),u=M.useMemo(()=>GF(t,e,c,i,r,"data"),[t,e,c,i,r]),d=M.useMemo(()=>GF(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=M.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,v=!1;if(e.forEach(b=>{let E=i.routes[b.route.id];!E||!E.hasLoader||(!u.some(w=>w.route.id===b.route.id)&&b.route.id in o&&a[b.route.id]?.shouldRevalidate||E.hasClientLoader?v=!0:x.add(b.route.id))}),x.size===0)return[];let y=Gae(t,s,"data");return v&&x.size>0&&y.searchParams.set("_routes",e.filter(b=>x.has(b.route.id)).map(b=>b.route.id).join(",")),[y.pathname+y.search]},[s,o,r,i,u,e,t,a]),g=M.useMemo(()=>Xae(d,i),[d,i]),p=nse(d);return M.createElement(M.Fragment,null,f.map(x=>M.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>M.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),p.map(({key:x,link:v})=>M.createElement("link",{key:x,nonce:n.nonce,...v})))}function ise(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var Q9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Q9&&(window.__reactRouterVersion="7.9.6")}catch{}function ase({basename:t,children:e,window:n}){let r=M.useRef();r.current==null&&(r.current=$ie({window:n,v5Compat:!0}));let i=r.current,[a,s]=M.useState({action:i.action,location:i.location}),o=M.useCallback(c=>{M.startTransition(()=>s(c))},[s]);return M.useLayoutEffect(()=>i.listen(o),[i,o]),M.createElement(Oae,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var J9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,fc=M.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:s,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},p){let{basename:x}=M.useContext(wl),v=typeof u=="string"&&J9.test(u),y,b=!1;if(typeof u=="string"&&v&&(y=u,Q9))try{let N=new URL(window.location.href),j=u.startsWith("//")?new URL(N.protocol+u):new URL(u),I=kc(j.pathname,x);j.origin===N.origin&&I!=null?u=I+j.search+j.hash:b=!0}catch{Fo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=xae(u,{relative:i}),[w,A,T]=ese(r,g),C=lse(u,{replace:s,state:o,target:c,preventScrollReset:d,relative:i,viewTransition:f});function k(N){e&&e(N),N.defaultPrevented||C(N)}let F=M.createElement("a",{...g,...T,href:y||E,onClick:b||a?e:k,ref:ise(p,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return w&&!v?M.createElement(M.Fragment,null,F,M.createElement(tse,{page:E})):F});fc.displayName="Link";var Lx=M.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:s,viewTransition:o,children:c,...u},d){let f=xb(s,{relative:u.relative}),g=Md(),p=M.useContext(zS),{navigator:x,basename:v}=M.useContext(wl),y=p!=null&&fse(f)&&o===!0,b=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(E=E.toLowerCase(),w=w?w.toLowerCase():null,b=b.toLowerCase()),w&&v&&(w=kc(w,v)||w);const A=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let T=E===b||!i&&E.startsWith(b)&&E.charAt(A)==="/",C=w!=null&&(w===b||!i&&w.startsWith(b)&&w.charAt(b.length)==="/"),k={isActive:T,isPending:C,isTransitioning:y},F=T?e:void 0,N;typeof r=="function"?N=r(k):N=[r,T?"active":null,C?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let j=typeof a=="function"?a(k):a;return M.createElement(fc,{...u,"aria-current":F,className:N,ref:d,style:j,to:s,viewTransition:o},typeof c=="function"?c(k):c)});Lx.displayName="NavLink";var sse=M.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:s=e1,action:o,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},p)=>{let x=dse(),v=hse(o,{relative:u}),y=s.toLowerCase()==="get"?"get":"post",b=typeof o=="string"&&J9.test(o),E=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,T=A?.getAttribute("formmethod")||s;x(A||w.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return M.createElement("form",{ref:p,method:y,action:v,onSubmit:r?c:E,...g,"data-discover":!b&&t==="render"?"true":void 0})});sse.displayName="Form";function ose(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function eG(t){let e=M.useContext(Yp);return wr(e,ose(t)),e}function lse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let o=gb(),c=Md(),u=xb(t,{relative:a});return M.useCallback(d=>{if(Bae(d,e)){d.preventDefault();let f=n!==void 0?n:y0(c)===y0(u);o(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:s})}},[c,o,u,n,r,e,t,i,a,s])}var cse=0,use=()=>`__${String(++cse)}__`;function dse(){let{router:t}=eG("useSubmit"),{basename:e}=M.useContext(wl),n=kae();return M.useCallback(async(r,i={})=>{let{action:a,method:s,encType:o,formData:c,body:u}=Vae(r,e);if(i.navigate===!1){let d=i.fetcherKey||use();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function hse(t,{relative:e}={}){let{basename:n}=M.useContext(wl),r=M.useContext(Bo);wr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...xb(t||".",{relative:e})},s=Md();if(t==null){a.search=s.search;let o=new URLSearchParams(a.search),c=o.getAll("index");if(c.some(d=>d==="")){o.delete("index"),c.filter(f=>f).forEach(f=>o.append("index",f));let d=o.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:_c([n,a.pathname])),y0(a)}function fse(t,{relative:e}={}){let n=M.useContext(G9);wr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=eG("useViewTransitionState"),i=xb(t,{relative:e});if(!n.isTransitioning)return!1;let a=kc(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=kc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return T1(i.pathname,s)!=null||T1(i.pathname,a)!=null}var mc=C9();const mse=mo(mc);var Zp=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(){}},pse={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},gse=class{#e=pse;#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)}},yh=new gse;function xse(t){setTimeout(t,0)}var $h=typeof window>"u"||"Deno"in globalThis;function Sa(){}function bse(t,e){return typeof t=="function"?t(e):t}function Ck(t){return typeof t=="number"&&t>=0&&t!==1/0}function tG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Ju(t,e){return typeof t=="function"?t(e):t}function qs(t,e){return typeof t=="function"?t(e):t}function WF(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:o}=t;if(s){if(r){if(e.queryHash!==zR(s,e.options))return!1}else if(!v0(e.queryKey,s))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||a&&!a(e))}function qF(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Vh(e.options.mutationKey)!==Vh(a))return!1}else if(!v0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function zR(t,e){return(e?.queryKeyHashFn||Vh)(t)}function Vh(t){return JSON.stringify(t,(e,n)=>Nk(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function v0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>v0(t[n],e[n])):!1}var yse=Object.prototype.hasOwnProperty;function nG(t,e){if(t===e)return t;const n=KF(t)&&KF(e);if(!n&&!(Nk(t)&&Nk(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,o=n?new Array(s):{};let c=0;for(let u=0;u<s;u++){const d=n?u:a[u],f=t[d],g=e[d];if(f===g){o[d]=f,(n?u<i:yse.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[d]=g;continue}const p=nG(f,g);o[d]=p,p===f&&c++}return i===s&&c===i?t:o}function C1(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 KF(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Nk(t){if(!XF(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!XF(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function XF(t){return Object.prototype.toString.call(t)==="[object Object]"}function vse(t){return new Promise(e=>{yh.setTimeout(e,t)})}function kk(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?nG(t,e):e}function _se(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function wse(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var BR=Symbol();function rG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===BR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function iG(t,e){return typeof t=="function"?t(...e):!!t}var Sse=class extends Zp{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!$h&&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"}},HR=new Sse;function Pk(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var Mse=xse;function Ese(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=Mse;const a=o=>{e?t.push(o):i(()=>{n(o)})},s=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;e++;try{c=o()}finally{e--,e||s()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var hi=Ese(),Ase=class extends Zp{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!$h&&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}},N1=new Ase;function Tse(t){return Math.min(1e3*2**t,3e4)}function aG(t){return(t??"online")==="online"?N1.isOnline():!0}var Rk=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function sG(t){let e=!1,n=0,r;const i=Pk(),a=()=>i.status!=="pending",s=v=>{if(!a()){const y=new Rk(v);g(y),t.onCancel?.(y)}},o=()=>{e=!0},c=()=>{e=!1},u=()=>HR.isFocused()&&(t.networkMode==="always"||N1.isOnline())&&t.canRun(),d=()=>aG(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},g=v=>{a()||(r?.(),i.reject(v))},p=()=>new Promise(v=>{r=y=>{(a()||u())&&v(y)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let v;const y=n===0?t.initialPromise:void 0;try{v=y??t.fn()}catch(b){v=Promise.reject(b)}Promise.resolve(v).then(f).catch(b=>{if(a())return;const E=t.retry??($h?0:3),w=t.retryDelay??Tse,A=typeof w=="function"?w(n,b):w,T=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(e||!T){g(b);return}n++,t.onFail?.(n,b),vse(A).then(()=>u()?void 0:p()).then(()=>{e?g(b):x()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var oG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ck(this.gcTime)&&(this.#e=yh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??($h?1/0:300*1e3))}clearGcTimeout(){this.#e&&(yh.clearTimeout(this.#e),this.#e=void 0)}},Cse=class extends oG{#e;#t;#n;#i;#r;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=ZF(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=ZF(this.options);e.data!==void 0&&(this.setState(YF(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=kk(this.state.data,t,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#a({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Sa).catch(Sa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>qs(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===BR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Ju(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!tG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(c=>c.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=rG(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,u,this):o(u)},s=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#a({type:"fetch",meta:s.fetchOptions?.meta}),this.#r=sG({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:o=>{o instanceof Rk&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,c)=>{this.#a({type:"failed",failureCount:o,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const o=await this.#r.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof Rk){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#a({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...lG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...YF(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),hi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function lG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:aG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function YF(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ZF(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 Nse=class extends Zp{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=Pk(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),QF(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return jk(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return jk(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof qs(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),e._defaulted&&!C1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&JF(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||qs(this.options.enabled,this.#t)!==qs(e.enabled,this.#t)||Ju(this.options.staleTime,this.#t)!==Ju(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||qs(this.options.enabled,this.#t)!==qs(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 Pse(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Sa)),e}#g(){this.#v();const t=Ju(this.options.staleTime,this.#t);if($h||this.#i.isStale||!Ck(t))return;const n=tG(this.#i.dataUpdatedAt,t)+1;this.#c=yh.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,!($h||qs(this.options.enabled,this.#t)===!1||!Ck(this.#l)||this.#l===0)&&(this.#u=yh.setInterval(()=>{(this.options.refetchIntervalInBackground||HR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(yh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(yh.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,a=this.#r,s=this.#s,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const F=this.hasListeners(),N=!F&&QF(t,e),j=F&&JF(t,n,e,r);(N||j)&&(d={...d,...lG(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:v}=d;g=d.data;let y=!1;if(e.placeholderData!==void 0&&g===void 0&&v==="pending"){let F;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(F=i.data,y=!0):F=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,F!==void 0&&(v="success",g=kk(i?.data,F,e),f=!0)}if(e.select&&g!==void 0&&!y)if(i&&g===a?.data&&e.select===this.#p)g=this.#h;else try{this.#p=e.select,g=e.select(g),g=kk(i?.data,g,e),this.#h=g,this.#a=null}catch(F){this.#a=F}this.#a&&(p=this.#a,g=this.#h,x=Date.now(),v="error");const b=d.fetchStatus==="fetching",E=v==="pending",w=v==="error",A=E&&b,T=g!==void 0,k={status:v,fetchStatus:d.fetchStatus,isPending:E,isSuccess:v==="success",isError:w,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!E,isLoadingError:w&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&T,isStale:$R(t,e),refetch:this.refetch,promise:this.#o,isEnabled:qs(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const F=I=>{k.status==="error"?I.reject(k.error):k.data!==void 0&&I.resolve(k.data)},N=()=>{const I=this.#o=k.promise=Pk();F(I)},j=this.#o;switch(j.status){case"pending":t.queryHash===n.queryHash&&F(j);break;case"fulfilled":(k.status==="error"||k.data!==j.value)&&N();break;case"rejected":(k.status!=="error"||k.error!==j.reason)&&N();break}}return k}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#s=this.options,this.#r.data!==void 0&&(this.#f=this.#t),C1(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const a=new Set(i??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(s=>{const o=s;return this.#i[o]!==t[o]&&a.has(o)})};this.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){hi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function kse(t,e){return qs(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function QF(t,e){return kse(t,e)||t.state.data!==void 0&&jk(t,e,e.refetchOnMount)}function jk(t,e,n){if(qs(e.enabled,t)!==!1&&Ju(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&$R(t,e)}return!1}function JF(t,e,n,r){return(t!==e||qs(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&$R(t,n)}function $R(t,e){return qs(e.enabled,t)!==!1&&t.isStaleByTime(Ju(e.staleTime,t))}function Pse(t,e){return!C1(t.getCurrentResult(),e)}function eU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=rG(e.options,e.fetchOptions),p=async(x,v,y)=>{if(d)return Promise.reject();if(v==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:v,direction:y?"backward":"forward",meta:e.options.meta};return f(C),C})(),w=await g(E),{maxPages:A}=e.options,T=y?wse:_se;return{pages:T(x.pages,w,A),pageParams:T(x.pageParams,v,A)}};if(i&&a.length){const x=i==="backward",v=x?Rse:tU,y={pages:a,pageParams:s},b=v(r,y);o=await p(y,b,x)}else{const x=t??a.length;do{const v=c===0?s[0]??r.initialPageParam:tU(r,o);if(c>0&&v==null)break;o=await p(o,v),c++}while(c<x)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function tU(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 Rse(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var jse=class extends oG{#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||cG(),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=sG({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,s)=>{this.#r({type:"failed",failureCount:a,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const s=await this.options.onMutate?.(t,n);s!==this.state.context&&this.#r({type:"pending",context:s,variables:t,isPaused:i})}const a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),hi.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function cG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Dse=class extends Zp{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 jse({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=xv(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=xv(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=xv(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=xv(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){hi.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=>qF(e,n))}findAll(t={}){return this.getAll().filter(e=>qF(t,e))}notify(t){hi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return hi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Sa))))}};function xv(t){return t.options.scope?.id}var Ose=class extends Zp{#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),C1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Vh(n.mutationKey)!==Vh(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#s()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??cG();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){hi.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)})})}},Lse=class extends Zp{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??zR(r,e);let a=this.get(i);return a||(a=new Cse({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){hi.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=>WF(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>WF(t,n)):e}notify(t){hi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){hi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){hi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ise=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new Lse,this.#t=t.mutationCache||new Dse,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=HR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=N1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Ju(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#e.get(r.queryHash)?.state.data,s=bse(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return hi.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;hi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return hi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=hi.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Sa).catch(Sa)}invalidateQueries(t,e={}){return hi.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=hi.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Sa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Sa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Ju(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Sa).catch(Sa)}fetchInfiniteQuery(t){return t.behavior=eU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Sa).catch(Sa)}ensureInfiniteQueryData(t){return t.behavior=eU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return N1.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(Vh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{v0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Vh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{v0(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=zR(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===BR&&(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()}},uG=M.createContext(void 0),Mn=t=>{const e=M.useContext(uG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Fse=({client:t,children:e})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(uG.Provider,{value:t,children:e})),dG=M.createContext(!1),Use=()=>M.useContext(dG);dG.Provider;function zse(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Bse=M.createContext(zse()),Hse=()=>M.useContext(Bse),$se=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Vse=t=>{M.useEffect(()=>{t.clearReset()},[t])},Gse=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||iG(n,[t.error,r])),Wse=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))}},qse=(t,e)=>t.isLoading&&t.isFetching&&!e,Kse=(t,e)=>t?.suspense&&e.isPending,nU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Xse(t,e,n){const r=Use(),i=Hse(),a=Mn(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",Wse(s),$se(s,i),Vse(i);const o=!a.getQueryCache().get(s.queryHash),[c]=M.useState(()=>new e(a,s)),u=c.getOptimisticResult(s),d=!r&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(f=>{const g=d?c.subscribe(hi.batchCalls(f)):Sa;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setOptions(s)},[s,c]),Kse(s,u))throw nU(s,c,i);if(Gse({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(s,u),s.experimental_prefetchInRender&&!$h&&qse(u,r)&&(o?nU(s,c,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(Sa).finally(()=>{c.updateResult()}),s.notifyOnChangeProps?u:c.trackResult(u)}function yt(t,e){return Xse(t,Nse)}function vt(t,e){const n=Mn(),[r]=M.useState(()=>new Ose(n,t));M.useEffect(()=>{r.setOptions(t)},[r,t]);const i=M.useSyncExternalStore(M.useCallback(s=>r.subscribe(hi.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((s,o)=>{r.mutate(s,o).catch(Sa)},[r]);if(i.error&&iG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Yse=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Zse=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),rU=t=>{const e=Zse(t);return e.charAt(0).toUpperCase()+e.slice(1)},hG=(...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 Jse={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 eoe=M.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:s,...o},c)=>M.createElement("svg",{ref:c,...Jse,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:hG("lucide",i),...!a&&!Qse(o)&&{"aria-hidden":"true"},...o},[...s.map(([u,d])=>M.createElement(u,d)),...Array.isArray(a)?a:[a]]));const We=(t,e)=>{const n=M.forwardRef(({className:r,...i},a)=>M.createElement(eoe,{ref:a,iconNode:e,className:hG(`lucide-${Yse(rU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=rU(t),n};const toe=[["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"}]],wc=We("archive",toe);const noe=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],_0=We("arrow-down",noe);const roe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ioe=We("arrow-left",roe);const aoe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Dk=We("arrow-right",aoe);const soe=[["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"}]],ooe=We("arrow-up-down",soe);const loe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],mp=We("arrow-up",loe);const coe=[["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"}]],Ch=We("bell",coe);const uoe=[["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"}]],doe=We("bold",uoe);const hoe=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],foe=We("book",hoe);const moe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],poe=We("bookmark",moe);const goe=[["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"}]],pp=We("box",goe);const xoe=[["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"}]],boe=We("cable",xoe);const yoe=[["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"}]],voe=We("calendar-days",yoe);const _oe=[["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"}]],$r=We("calendar",_oe);const woe=[["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"}]],w0=We("camera",woe);const Soe=[["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"}]],Moe=We("chart-column",Soe);const Eoe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Gh=We("check",Eoe);const Aoe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Hc=We("chevron-down",Aoe);const Toe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$c=We("chevron-right",Toe);const Coe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wh=We("chevron-left",Coe);const Noe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],HS=We("chevron-up",Noe);const koe=[["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"}]],co=We("circle-alert",koe);const Poe=[["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"}]],LA=We("circle-arrow-up",Poe);const Roe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],_r=We("circle-check-big",Roe);const joe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],VR=We("circle-check",joe);const Doe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Ooe=We("circle-dot",Doe);const Loe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Ioe=We("circle-stop",Loe);const Foe=[["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"}]],Ea=We("circle-x",Foe);const Uoe=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],zoe=We("clipboard-list",Uoe);const Boe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],sr=We("clock",Boe);const Hoe=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],$S=We("cloud",Hoe);const $oe=[["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"}]],Voe=We("code-xml",$oe);const Goe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],fG=We("code",Goe);const Woe=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],qoe=We("coffee",Woe);const Koe=[["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"}]],Xoe=We("cog",Koe);const Yoe=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Zoe=We("compass",Yoe);const Qoe=[["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"}]],cd=We("copy",Qoe);const Joe=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],bv=We("cpu",Joe);const ele=[["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"}]],gp=We("database",ele);const tle=[["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"}]],k1=We("dollar-sign",tle);const nle=[["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"}]],ts=We("download",nle);const rle=[["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"}]],GR=We("droplet",rle);const ile=[["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"}]],mG=We("droplets",ile);const ale=[["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"}]],WR=We("ellipsis-vertical",ale);const sle=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],IA=We("equal",sle);const ole=[["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"}]],Cs=We("external-link",ole);const lle=[["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"}]],qR=We("eye-off",lle);const cle=[["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"}]],xp=We("eye",cle);const ule=[["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"}]],dle=We("fan",ule);const hle=[["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"}]],fle=We("file-box",hle);const mle=[["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"}]],iU=We("file-code",mle);const ple=[["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"}]],gle=We("file-exclamation-point",ple);const xle=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],P1=We("file-spreadsheet",xle);const ble=[["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"}]],ws=We("file-text",ble);const yle=[["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"}]],KR=We("file",yle);const vle=[["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"}]],Jm=We("film",vle);const _le=[["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"}]],wle=We("flame",_le);const Sle=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],cl=We("folder-kanban",Sle);const Mle=[["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"}]],Ele=We("folder-open",Mle);const Ale=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Tle=We("folder-tree",Ale);const Cle=[["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"}]],pG=We("folder",Cle);const Nle=[["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"}]],XR=We("funnel",Nle);const kle=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],YR=We("gauge",kle);const Ple=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],Rle=We("gift",Ple);const jle=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],ep=We("git-compare",jle);const Dle=[["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"}]],aU=We("github",Dle);const Ole=[["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"}]],S0=We("globe",Ole);const Lle=[["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"}]],M0=We("grip-vertical",Lle);const Ile=[["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"}]],ZR=We("hard-drive",Ile);const Fle=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],Ule=We("heart",Fle);const zle=[["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"}]],R1=We("history",zle);const Ble=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Hle=We("house",Ble);const $le=[["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"}]],bb=We("image",$le);const Vle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],E0=We("info",Vle);const Gle=[["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"}]],Wle=We("italic",Gle);const qle=[["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"}]],Wm=We("key",qle);const Kle=[["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"}]],Ok=We("keyboard",Kle);const Xle=[["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"}]],ud=We("layers",Xle);const Yle=[["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"}]],gG=We("layout-grid",Yle);const Zle=[["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"}]],Qle=We("layout-list",Zle);const Jle=[["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"}]],ece=We("link-2-off",Jle);const tce=[["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"}]],Lk=We("link-2",tce);const nce=[["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"}]],VS=We("link",nce);const rce=[["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"}]],xG=We("list-ordered",rce);const ice=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Ik=We("list-todo",ice);const ace=[["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"}]],QR=We("list",ace);const sce=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],_t=We("loader-circle",sce);const oce=[["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"}]],sU=We("log-in",oce);const lce=[["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"}]],cce=We("log-out",lce);const uce=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],dce=We("mail",uce);const hce=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],fce=We("map",hce);const mce=[["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"}]],pce=We("maximize-2",mce);const gce=[["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"}]],xce=We("maximize",gce);const bce=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],yce=We("memory-stick",bce);const vce=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],_ce=We("menu",vce);const wce=[["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"}]],Sce=We("minimize-2",wce);const Mce=[["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"}]],Ece=We("minimize",Mce);const Ace=[["path",{d:"M5 12h14",key:"1ays0h"}]],Fk=We("minus",Ace);const Tce=[["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"}]],j1=We("moon",Tce);const Cce=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Nce=We("music",Cce);const kce=[["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"}]],Pc=We("package",kce);const Pce=[["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"}]],bG=We("palette",Pce);const Rce=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],jce=We("paperclip",Rce);const Dce=[["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"}]],Oce=We("pause",Dce);const Lce=[["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"}]],qh=We("pen-line",Lce);const Ice=[["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"}]],JR=We("pen",Ice);const Fce=[["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"}]],dd=We("pencil",Fce);const Uce=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],zce=We("phone",Uce);const Bce=[["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"}]],GS=We("play",Bce);const Hce=[["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"}]],tp=We("plug",Hce);const $ce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],tr=We("plus",$ce);const Vce=[["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"}]],ej=We("power-off",Vce);const Gce=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Ed=We("power",Gce);const Wce=[["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"}]],pa=We("printer",Wce);const qce=[["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"}]],Kce=We("qr-code",qce);const Xce=[["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"}]],Na=We("refresh-cw",Xce);const Yce=[["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"}]],Qp=We("rotate-ccw",Yce);const Zce=[["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"}]],Qce=We("ruler",Zce);const Jce=[["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"}]],no=We("save",Jce);const eue=[["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"}]],tue=We("scan-search",eue);const nue=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Rc=We("search",nue);const rue=[["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"}]],tj=We("send",rue);const iue=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],lh=We("server",iue);const aue=[["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"}]],WS=We("settings-2",aue);const sue=[["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"}]],nj=We("settings",sue);const oue=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],lue=We("shield",oue);const cue=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],uue=We("shopping-cart",cue);const due=[["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"}]],hue=We("signal",due);const fue=[["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"}]],mue=We("skip-back",fue);const pue=[["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"}]],D1=We("skip-forward",pue);const gue=[["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"}]],oU=We("sliders-vertical",gue);const xue=[["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"}]],A0=We("sparkles",xue);const bue=[["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"}]],Kh=We("square-check-big",bue);const yue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],bp=We("square",yue);const vue=[["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"}]],yp=We("star",vue);const _ue=[["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"}]],yG=We("sticky-note",_ue);const wue=[["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"}]],lU=We("sun",wue);const Sue=[["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"}]],vp=We("tag",Sue);const Mue=[["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"}]],vG=We("target",Mue);const Eue=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],_G=We("terminal",Eue);const Aue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Tue=We("text-align-center",Aue);const Cue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Nue=We("text-align-end",Cue);const kue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Pue=We("text-align-start",kue);const Rue=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],qS=We("thermometer",Rue);const jue=[["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"}]],Wu=We("timer",jue);const Due=[["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"}]],An=We("trash-2",Due);const Oue=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],wG=We("trending-down",Oue);const Lue=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],SG=We("trending-up",Lue);const Iue=[["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"}]],Sr=We("triangle-alert",Iue);const Fue=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Uue=We("underline",Fue);const zue=[["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"}]],MG=We("unlink",zue);const Bue=[["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"}]],Ya=We("upload",Bue);const Hue=[["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"}]],Uk=We("user",Hue);const $ue=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Vue=We("users",$ue);const Gue=[["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"}]],EG=We("video",Gue);const Wue=[["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"}]],rj=We("wifi-off",Wue);const que=[["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"}]],AG=We("wifi",que);const Kue=[["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"}]],Xue=We("wind",Kue);const Yue=[["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"}]],hd=We("wrench",Yue);const Zue=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=We("x",Zue);const Que=[["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"}]],Jue=We("zoom-in",Que);const ede=[["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"}]],_p=We("zap",ede);const tde=[["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"}]],nde=We("zoom-out",tde),TG=M.createContext(void 0);function rde({children:t}){const[e,n]=M.useState(()=>{const a=localStorage.getItem("theme");return a||"dark"});M.useEffect(()=>{const a=document.documentElement;e==="dark"?a.classList.add("dark"):a.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(a=>a==="dark"?"light":"dark")},i=a=>{n(a)};return l.jsx(TG.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function yb(){const t=M.useContext(TG);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Mt({children:t,className:e="",onClick:n,onContextMenu:r}){return l.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function Ga({children:t,className:e=""}){return l.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Nt({children:t,className:e=""}){return l.jsx("div",{className:`p-6 ${e}`,children:t})}function ide(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function cU({children:t}){return l.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 ade({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Kp(),i=ide(n,e,r);return M.useEffect(()=>{const a=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:l.jsx(Mt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:l.jsxs(Nt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ok,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),l.jsx("div",{className:"space-y-2",children:a.items.map(s=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[s.description,s.isExternal&&l.jsx(Cs,{className:"w-3 h-3 text-bambu-gray"})]}),l.jsx("div",{className:"flex gap-1",children:s.keys.map(o=>l.jsx(cU,{children:o},o))})]},s.description))})]},a.category))}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",l.jsx(cU,{children:"Esc"})," or click outside to close"]})})]})})})}const Un="/api/v1";async function qe(t,e={}){const n=await fetch(`${Un}${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 Ce={getPrinters:()=>qe("/printers/"),getPrinter:t=>qe(`/printers/${t}`),createPrinter:t=>qe("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>qe(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>qe(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>qe(`/printers/${t}/status`),connectPrinter:t=>qe(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>qe(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>qe(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>qe(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>qe(`/printers/${t}/logging`),clearMQTTLogs:t=>qe(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>qe(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Un}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>qe(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>qe(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),qe(`/archives/?${i}`)},getArchive:t=>qe(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),qe(`/archives/search?${n}`)},rebuildSearchIndex:()=>qe("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>qe(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>qe(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>qe(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>qe("/archives/stats"),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),qe(`/archives/analysis/failures?${e}`)},compareArchives:t=>qe(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>qe(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${Un}/archives/export?${e}`);if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const s=r.match(/filename="?([^"]+)"?/);s&&(i=s[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${Un}/archives/stats/export?${e}`);if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const s=r.match(/filename="?([^"]+)"?/);s&&(i=s[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>qe(`/archives/${t}/duplicates`),backfillContentHashes:()=>qe("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Un}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${Un}/archives/${t}/download`,getArchiveGcode:t=>`${Un}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${Un}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>qe(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>qe(`/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(`${Un}/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)=>`${Un}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Un}/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)=>qe(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Un}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Un}/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(`${Un}/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=>qe(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Un}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>qe(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>qe(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>qe(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Un}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Un}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>qe(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${Un}/archives/upload?printer_id=${e}`:`${Un}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const r=e?`${Un}/archives/upload-bulk?printer_id=${e}`:`${Un}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>qe("/settings/"),updateSettings:t=>qe("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>qe("/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=`${Un}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n),i=r.headers.get("Content-Disposition");let a="bambuddy-backup.json";if(i){const o=i.match(/filename=([^;]+)/);o&&(a=o[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${Un}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>qe("/settings/check-ffmpeg"),getCloudStatus:()=>qe("/cloud/status"),cloudLogin:(t,e,n="global")=>qe("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>qe("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>qe("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>qe("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>qe(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>qe(`/cloud/settings/${t}`),createCloudSetting:t=>qe("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>qe(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>qe(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>qe("/cloud/devices"),getCloudFields:t=>qe(`/cloud/fields/${t}`),getAllCloudFields:()=>qe("/cloud/fields"),getSmartPlugs:()=>qe("/smart-plugs/"),getSmartPlug:t=>qe(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>qe(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>qe("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>qe(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>qe(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>qe(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>qe(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>qe("/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),qe(`/queue/?${n}`)},getQueueItem:t=>qe(`/queue/${t}`),addToQueue:t=>qe("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>qe(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>qe(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>qe("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>qe(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>qe(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>qe(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>qe(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>qe(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>qe(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>qe(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>qe(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>qe(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>qe(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>qe(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>qe(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>qe(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>qe("/filaments/"),getFilament:t=>qe(`/filaments/${t}`),getFilamentsByType:t=>qe(`/filaments/by-type/${t}`),getNotificationProviders:()=>qe("/notifications/"),getNotificationProvider:t=>qe(`/notifications/${t}`),createNotificationProvider:t=>qe("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>qe(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>qe(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>qe(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>qe("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>qe("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>qe("/notification-templates"),getNotificationTemplate:t=>qe(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>qe(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>qe(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>qe("/notification-templates/variables"),previewTemplate:t=>qe("/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)),qe(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>qe(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>qe(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>qe("/spoolman/status"),connectSpoolman:()=>qe("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>qe("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>qe(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>qe("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>qe("/spoolman/spools"),getSpoolmanFilaments:()=>qe("/spoolman/filaments"),getVersion:()=>qe("/updates/version"),checkForUpdates:()=>qe("/updates/check"),applyUpdate:()=>qe("/updates/apply",{method:"POST"}),getUpdateStatus:()=>qe("/updates/status"),getMaintenanceTypes:()=>qe("/maintenance/types"),createMaintenanceType:t=>qe("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>qe(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>qe(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>qe("/maintenance/overview"),getPrinterMaintenance:t=>qe(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>qe(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>qe(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>qe(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>qe("/maintenance/summary"),setPrinterHours:(t,e)=>qe(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>qe(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>qe(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${Un}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Un}/printers/${t}/camera/snapshot`,testCameraConnection:t=>qe(`/printers/${t}/camera/test`),getExternalLinks:()=>qe("/external-links/"),getExternalLink:t=>qe(`/external-links/${t}`),createExternalLink:t=>qe("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>qe(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>qe(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>qe("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Un}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>qe(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${Un}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),qe(`/projects/?${e}`)},getProject:t=>qe(`/projects/${t}`),createProject:t=>qe("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>qe(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>qe(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>qe(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>qe(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>qe(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>qe(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Un}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${Un}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>qe(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>qe(`/projects/${t}/bom`),createBOMItem:(t,e)=>qe(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>qe(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>qe(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>qe("/projects/templates/"),createTemplateFromProject:t=>qe(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>qe(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>qe(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>qe("/api-keys/"),createAPIKey:t=>qe("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>qe(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>qe(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>qe(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>qe("/system/info")},ux={getStatus:()=>qe("/discovery/status"),startDiscovery:(t=10)=>qe(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>qe("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>qe("/discovery/printers")},CG=[{name:"globe",icon:S0},{name:"link",icon:VS},{name:"external-link",icon:Cs},{name:"book",icon:foe},{name:"file-text",icon:ws},{name:"home",icon:Hle},{name:"star",icon:yp},{name:"heart",icon:Ule},{name:"bookmark",icon:poe},{name:"shopping-cart",icon:uue},{name:"music",icon:Nce},{name:"video",icon:EG},{name:"image",icon:bb},{name:"camera",icon:w0},{name:"map",icon:fce},{name:"compass",icon:Zoe},{name:"coffee",icon:qoe},{name:"gift",icon:Rle},{name:"wrench",icon:hd},{name:"zap",icon:_p},{name:"cloud",icon:$S},{name:"database",icon:gp},{name:"folder",icon:pG},{name:"mail",icon:dce},{name:"phone",icon:zce},{name:"user",icon:Uk},{name:"users",icon:Vue},{name:"server",icon:lh},{name:"terminal",icon:_G},{name:"code",icon:fG}];function KS(t){return CG.find(n=>n.name===t)?.icon||VS}function sde({value:t,onChange:e}){const[n,r]=M.useState(!1),i=KS(t);return l.jsxs("div",{className:"relative",children:[l.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[l.jsx(i,{className:"w-5 h-5"}),l.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),l.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:l.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:CG.map(({name:a,icon:s})=>l.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:l.jsx(s,{className:"w-5 h-5"})},a))})})]})]})}const uU=768;function NG(){const[t,e]=M.useState(()=>typeof window<"u"?window.innerWidth<uU:!1);return M.useEffect(()=>{const n=window.matchMedia(`(max-width: ${uU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const T0=[{id:"printers",to:"/",icon:pa,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:wc,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:$r,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Moe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:$S,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:hd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:cl,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:nj,labelKey:"nav.settings"}];function ode(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return T0.map(e=>e.id)}return T0.map(e=>e.id)}function lde(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function FA(t){return t.startsWith("ext-")}function kG(){return localStorage.getItem("defaultView")||"/"}function cde(t){localStorage.setItem("defaultView",t)}function ude(){const t=gb(),e=Md(),{theme:n,toggleTheme:r}=yb(),{t:i}=Kp(),a=NG(),[s,o]=M.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=M.useState(!1),[d,f]=M.useState(!1),[g,p]=M.useState(ode),[x,v]=M.useState(null),[y,b]=M.useState(null),E=M.useRef(!1),[w,A]=M.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=yt({queryKey:["version"],queryFn:Ce.getVersion,staleTime:1/0}),{data:C}=yt({queryKey:["settings"],queryFn:Ce.getSettings,staleTime:300*1e3}),{data:k}=yt({queryKey:["updateCheck"],queryFn:Ce.checkForUpdates,enabled:C?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:F}=yt({queryKey:["external-links"],queryFn:Ce.getExternalLinks}),N=new Map(T0.map(J=>[J.id,J])),j=new Map((F||[]).map(J=>[`ext-${J.id}`,J])),I=(()=>{const J=[],U=new Set;for(const H of g)(N.has(H)||j.has(H))&&(J.push(H),U.add(H));for(const H of T0)U.has(H.id)||(J.push(H.id),U.add(H.id));for(const H of F||[]){const ee=`ext-${H.id}`;U.has(ee)||(J.push(ee),U.add(ee))}return J})(),O=(J,U)=>{v(U),J.dataTransfer.effectAllowed="move",J.dataTransfer.setData("text/plain",U)},q=(J,U)=>{J.preventDefault(),J.dataTransfer.dropEffect="move",b(U)},R=()=>{b(null)},W=(J,U)=>{if(J.preventDefault(),x===null||x===U){v(null),b(null);return}const H=[...I],ee=H.indexOf(x),ie=H.indexOf(U);if(ee===-1||ie===-1){v(null),b(null);return}H.splice(ee,1),H.splice(ie,0,x),p(H),lde(H),v(null),b(null)},K=()=>{v(null),b(null)},G=k?.update_available&&k.latest_version&&k.latest_version!==w,te=()=>{k?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",k.latest_version),A(k.latest_version))};M.useEffect(()=>{if(!E.current&&e.pathname==="/"){const J=kG();J!=="/"&&(E.current=!0,t(J,{replace:!0}))}},[e.pathname,t]),M.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]),M.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const Y=M.useCallback(J=>{const U=J.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!J.metaKey&&!J.ctrlKey&&!J.altKey){const H=parseInt(J.key);if(H>=1&&H<=I.length&&H<=9){const ee=I[H-1];if(J.preventDefault(),FA(ee)){const ie=ee.replace("ext-","");t(`/external/${ie}`)}else{const ie=N.get(ee);ie&&t(ie.to)}return}switch(J.key){case"?":J.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,I,N]);return M.useEffect(()=>(document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)),[Y]),l.jsxs("div",{className:"flex min-h-screen",children:[a&&l.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[l.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:l.jsx(_ce,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&c&&l.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),l.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${c?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${s?"w-64":"w-16"}`}`,children:[l.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||s?"p-4":"p-2"}`,children:l.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||s?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),l.jsx("nav",{className:"flex-1 p-2",children:l.jsx("ul",{className:"space-y-2",children:I.map(J=>{if(FA(J)){const H=j.get(J);if(!H)return null;const ee=H.custom_icon?null:KS(H.icon);return l.jsx("li",{draggable:!0,onDragStart:ie=>O(ie,J),onDragOver:ie=>q(ie,J),onDragLeave:R,onDrop:ie=>W(ie,J),onDragEnd:K,className:`relative ${x===J?"opacity-50":""} ${y===J&&x!==J?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Lx,{to:`/external/${H.id}`,className:({isActive:ie})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ie?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?H.name:void 0,children:[s&&!a&&l.jsx(M0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),H.custom_icon?l.jsx("img",{src:`/api/v1/external-links/${H.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):ee&&l.jsx(ee,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&l.jsx("span",{children:H.name})]})},J)}else{const H=N.get(J);if(!H)return null;const{to:ee,icon:ie,labelKey:pe}=H;return l.jsx("li",{draggable:!0,onDragStart:ue=>O(ue,J),onDragOver:ue=>q(ue,J),onDragLeave:R,onDrop:ue=>W(ue,J),onDragEnd:K,className:`relative ${x===J?"opacity-50":""} ${y===J&&x!==J?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Lx,{to:ee,className:({isActive:ue})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ue?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?i(pe):void 0,children:[s&&!a&&l.jsx(M0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),l.jsx(ie,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&l.jsx("span",{children:i(pe)})]})},J)}})})}),!a&&l.jsx("button",{onClick:()=>o(!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?l.jsx(Wh,{className:"w-5 h-5"}):l.jsx($c,{className:"w-5 h-5"})}),l.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||s?l.jsxs("div",{className:"flex items-center justify-between px-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),k?.update_available&&l.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:k.latest_version}),children:[l.jsx(LA,{className:"w-4 h-4"}),l.jsx("span",{children:i("nav.update")})]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Lx,{to:"/system",className:({isActive:J})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${J?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(E0,{className:"w-5 h-5"})}),l.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:l.jsx(aU,{className:"w-5 h-5"})}),l.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:l.jsx(Ok,{className:"w-5 h-5"})}),l.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"?l.jsx(lU,{className:"w-5 h-5"}):l.jsx(j1,{className:"w-5 h-5"})})]})]}):l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[k?.update_available&&l.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:k.latest_version}),children:l.jsx(LA,{className:"w-5 h-5"})}),l.jsx(Lx,{to:"/system",className:({isActive:J})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${J?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(E0,{className:"w-5 h-5"})}),l.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:l.jsx(aU,{className:"w-5 h-5"})}),l.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:l.jsx(Ok,{className:"w-5 h-5"})}),l.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"?l.jsx(lU,{className:"w-5 h-5"}):l.jsx(j1,{className:"w-5 h-5"})})]})})]}),l.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":s?"ml-64":"ml-16"}`,children:[G&&l.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(LA,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{children:i("nav.updateAvailableBanner",{version:k?.latest_version,defaultValue:`Version ${k?.latest_version} is available!`})}),l.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),l.jsx("button",{onClick:te,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsx(Dae,{})]}),d&&l.jsx(ade,{onClose:()=>f(!1),sidebarItems:I.map(J=>{if(FA(J)){const U=j.get(J);return U?{type:"external",label:U.name}:null}else{const U=N.get(J);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)})]})}function Pe({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",s={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return l.jsx("button",{className:`${a} ${s[t]} ${o[e]} ${n}`,...i,children:r})}function fi({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:s}){M.useEffect(()=>{const u=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]);const c={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:l.jsx(Mt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:l.jsxs(Nt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-start gap-4",children:[l.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:l.jsx(Sr,{className:"w-6 h-6"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),l.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),l.jsxs("div",{className:"flex gap-3 mt-6",children:[l.jsx(Pe,{variant:"secondary",onClick:s,className:"flex-1",children:r}),l.jsx(Pe,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}const PG=M.createContext(void 0);function Gr(){const t=M.useContext(PG);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const dde={success:l.jsx(_r,{className:"w-5 h-5 text-green-400"}),error:l.jsx(Ea,{className:"w-5 h-5 text-red-400"}),warning:l.jsx(co,{className:"w-5 h-5 text-yellow-400"}),info:l.jsx(E0,{className:"w-5 h-5 text-blue-400"}),loading:l.jsx(_t,{className:"w-5 h-5 text-bambu-green animate-spin"})},hde={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function fde({children:t}){const[e,n]=M.useState([]),r=M.useCallback((s,o="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:s,type:o}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=M.useCallback((s,o,c="info")=>{n(u=>u.find(f=>f.id===s)?u.map(f=>f.id===s?{...f,message:o,type:c,persistent:!0}:f):[...u,{id:s,message:o,type:c,persistent:!0}])},[]),a=M.useCallback(s=>{n(o=>o.filter(c=>c.id!==s))},[]);return l.jsxs(PG.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,l.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>l.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${hde[s.type]}`,children:[dde[s.type],l.jsx("span",{className:"text-white text-sm",children:s.message}),l.jsx("button",{onClick:()=>a(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]},s.id))})]})}function mde(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 dU(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 pde(t,e){if(e)return pG;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return fle;case"gcode":return ws;case"mp4":case"avi":return Jm;case"png":case"jpg":case"jpeg":return bb;default:return KR}}function gde({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Gr(),i=Mn(),[a,s]=M.useState("/"),[o,c]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(null);M.useEffect(()=>{const k=F=>{F.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]);const{data:p,isLoading:x,refetch:v}=yt({queryKey:["printerFiles",t,a],queryFn:()=>Ce.getPrinterFiles(t,a)}),{data:y}=yt({queryKey:["printerStorage",t],queryFn:()=>Ce.getPrinterStorage(t),staleTime:3e4}),b=vt({mutationFn:k=>Ce.deletePrinterFile(t,k),onSuccess:(k,F)=>{r(`Deleted: ${F.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:k=>{r(`Delete failed: ${k.message}`,"error")}}),E=k=>{s(k),c(null)},w=()=>{if(a==="/")return;const k=a.split("/").filter(Boolean);k.pop(),s(k.length?"/"+k.join("/"):"/"),c(null)},A=k=>{window.open(Ce.getPrinterFileDownloadUrl(t,k),"_blank")},T=k=>{g(k)},C=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[l.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:k=>k.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(ZR,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[y&&(y.used_bytes!=null||y.free_bytes!=null)&&l.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[y.used_bytes!=null&&l.jsxs("span",{children:["Used: ",dU(y.used_bytes)]}),y.used_bytes!=null&&y.free_bytes!=null&&l.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),y.free_bytes!=null&&l.jsxs("span",{children:["Free: ",dU(y.free_bytes)]})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),l.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[C.map(k=>l.jsx("button",{onClick:()=>{E(k.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===k.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:k.label},k.path)),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"relative",children:[l.jsx(Rc,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:k=>d(k.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"})]}),l.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:x,children:l.jsx(Na,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[l.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:l.jsx(Wh,{className:"w-4 h-4"})}),l.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p?.files?.length?l.jsx("div",{className:"space-y-1",children:[...p.files].filter(k=>!u||k.name.toLowerCase().includes(u.toLowerCase())).sort((k,F)=>k.is_directory&&!F.is_directory?-1:!k.is_directory&&F.is_directory?1:k.name.localeCompare(F.name)).map(k=>{const F=pde(k.name,k.is_directory),N=o===k.path;return l.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:()=>{k.is_directory?E(k.path):c(N?null:k.path)},children:[l.jsx(F,{className:`w-5 h-5 flex-shrink-0 ${k.is_directory?"text-bambu-green":"text-bambu-gray"}`}),l.jsx("span",{className:"flex-1 text-white truncate",children:k.name}),!k.is_directory&&l.jsx("span",{className:"text-sm text-bambu-gray",children:mde(k.size)}),k.is_directory&&l.jsx(Wh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},k.path)})}):l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${p?.files?.filter(k=>k.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${p?.files?.length||0} items`:`${p?.files?.length||0} items`}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Pe,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[l.jsx(ts,{className:"w-4 h-4"}),"Download"]}),l.jsxs(Pe,{variant:"secondary",disabled:!o||b.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[b.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&l.jsx(fi,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{b.mutate(f),g(null)},onCancel:()=>g(null)})]})}function xde({printerId:t,printerName:e,onClose:n}){const r=Mn(),[i,a]=M.useState(!0),[s,o]=M.useState(new Set),[c,u]=M.useState(""),[d,f]=M.useState("all"),g=M.useRef(null),{data:p,isLoading:x,refetch:v}=yt({queryKey:["mqtt-logs",t],queryFn:()=>Ce.getMQTTLogs(t),refetchInterval:1e3}),y=vt({mutationFn:()=>Ce.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=vt({mutationFn:()=>Ce.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=vt({mutationFn:()=>Ce.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});M.useEffect(()=>{const N=j=>{j.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]),M.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[p?.logs,i]);const w=N=>{o(j=>{const I=new Set(j);return I.has(N)?I.delete(N):I.add(N),I})},A=N=>new Date(N).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(N,j)=>{if(N==null)return"<empty>";const I=typeof N=="string"?JSON.parse(N):N,O=JSON.stringify(I,null,j?2:0);return!j&&O.length>100?O.substring(0,100)+"...":O},C=p?.logging_enabled??!1,k=p?.logs??[],F=M.useMemo(()=>k.filter(N=>{if(d!=="all"&&N.direction!==d)return!1;if(c.trim()){const j=c.toLowerCase(),I=N.topic.toLowerCase().includes(j),q=JSON.stringify(N.payload).toLowerCase().includes(j);return I||q}return!0}),[k,c,d]);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[C?l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[l.jsx(bp,{className:"w-4 h-4"}),"Stop"]}):l.jsxs(Pe,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[l.jsx(GS,{className:"w-4 h-4"}),"Start Logging"]}),l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||k.length===0,children:[l.jsx(An,{className:"w-4 h-4"}),"Clear"]}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:x,children:l.jsx(Na,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),l.jsx("div",{className:"flex-1"}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:i,onChange:N=>a(N.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:[F.length,"/",k.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(Rc,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:N=>u(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"}),c&&l.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),l.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[l.jsx(_0,{className:"w-3 h-3"}),"In"]}),l.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[l.jsx(mp,{className:"w-3 h-3"}),"Out"]})]})]})]}),l.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:k.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!C&&l.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):F.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages match your filter"}),l.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):l.jsx("div",{className:"space-y-1",children:F.map((N,j)=>{const I=s.has(j),O=N.direction==="in";return l.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${I?"bg-bambu-dark-secondary":""}`,onClick:()=>w(j),children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx("span",{className:"text-bambu-gray shrink-0",children:A(N.timestamp)}),l.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?l.jsx(_0,{className:"w-3 h-3"}):l.jsx(mp,{className:"w-3 h-3"})}),l.jsx("span",{className:"text-purple-400 shrink-0",children:N.topic})]}),I?l.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)}):l.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(N.payload,!1)})]},j)})})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:C?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):l.jsx("span",{children:"Logging stopped"})}),l.jsx(Pe,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const zk={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function bde(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Sr};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Sr};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:co};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:E0}}}function Bk(t,e){const n=t>>16&65535||(t>>8&255)<<8|t&255,r=e&65535;return`${n.toString(16).padStart(4,"0").toUpperCase()}_${r.toString(16).padStart(4,"0").toUpperCase()}`}function yde(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=Bk(e.attr,n);return zk[r]!==void 0})}function vde(){return"https://wiki.bambulab.com/en/hms/home"}function _de({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const a=parseInt(i.code.replace("0x",""),16)||0,s=Bk(i.attr,a);return zk[s]!==void 0});return M.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Sr,{className:"w-5 h-5 text-orange-400"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),l.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(co,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{children:"No errors"})]}):l.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:s,color:o,bgColor:c,Icon:u}=bde(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=Bk(i.attr,d),g=zk[f],p=vde(),x=f.replace("_","-");return l.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(u,{className:`w-5 h-5 ${o} flex-shrink-0 mt-0.5`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsxs("span",{className:`font-mono text-sm ${o}`,children:["[",x,"]"]}),l.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${o}`,children:s})]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g}),l.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[l.jsx(Cs,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function wde(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 Sde({printerId:t}){const{data:e}=yt({queryKey:["queue",t,"pending"],queryFn:()=>Ce.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:l.jsx(fc,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx($r,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),l.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[l.jsx(sr,{className:"w-3 h-3"}),wde(n?.scheduled_time||null)]}),r>1&&l.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),l.jsx($c,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function RG(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=RG(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function En(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=RG(t))&&(r&&(r+=" "),r+=e);return r}var Mde=["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 ij(t){if(typeof t!="string")return!1;var e=Mde;return e.includes(t)}var Ede=["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"],Ade=new Set(Ede);function jG(t){return typeof t!="string"?!1:Ade.has(t)}function DG(t){return typeof t=="string"&&t.startsWith("data-")}function ka(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(jG(n)||DG(n))&&(e[n]=t[n]);return e}function Xh(t){if(t==null)return null;if(M.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return ka(e)}return typeof t=="object"&&!Array.isArray(t)?ka(t):null}function na(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(jG(n)||DG(n)||ij(n))&&(e[n]=t[n]);return e}function Tde(t){return t==null?null:M.isValidElement(t)?na(t.props):typeof t=="object"&&!Array.isArray(t)?na(t):null}var Cde=["children","width","height","viewBox","className","style","title","desc"];function Hk(){return Hk=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},Hk.apply(null,arguments)}function Nde(t,e){if(t==null)return{};var n,r,i=kde(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function kde(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 aj=M.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:o,title:c,desc:u}=t,d=Nde(t,Cde),f=a||{width:r,height:i,x:0,y:0},g=En("recharts-surface",s);return M.createElement("svg",Hk({},na(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),M.createElement("title",null,c),M.createElement("desc",null,u),n)}),Pde=["children","className"];function $k(){return $k=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},$k.apply(null,arguments)}function Rde(t,e){if(t==null)return{};var n,r,i=jde(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jde(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 Mr=M.forwardRef((t,e)=>{var{children:n,className:r}=t,i=Rde(t,Pde),a=En("recharts-layer",r);return M.createElement("g",$k({className:a},na(i),{ref:e}),n)}),OG=M.createContext(null),Dde=()=>M.useContext(OG);function ar(t){return function(){return t}}const LG=Math.cos,O1=Math.sin,Ho=Math.sqrt,L1=Math.PI,XS=2*L1,Vk=Math.PI,Gk=2*Vk,ch=1e-6,Ode=Gk-ch;function IG(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Lde(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return IG;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class Ide{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?IG:Lde(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,s){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let s=this._x1,o=this._y1,c=r-e,u=i-n,d=s-e,f=o-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>ch)if(!(Math.abs(f*c-u*d)>ch)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-s,x=i-o,v=c*c+u*u,y=p*p+x*x,b=Math.sqrt(v),E=Math.sqrt(g),w=a*Math.tan((Vk-Math.acos((v+g-y)/(2*b*E)))/2),A=w/E,T=w/b;Math.abs(A-1)>ch&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*p>d*x)},${this._x1=e+T*c},${this._y1=n+T*u}`}}arc(e,n,r,i,a,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),c=r*Math.sin(i),u=e+o,d=n+c,f=1^s,g=s?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>ch||Math.abs(this._y1-d)>ch)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%Gk+Gk),g>Ode?this._append`A${r},${r},0,1,${f},${e-o},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>ch&&this._append`A${r},${r},0,${+(g>=Vk)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function sj(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 Ide(e)}function oj(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function FG(t){this._context=t}FG.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 YS(t){return new FG(t)}function UG(t){return t[0]}function zG(t){return t[1]}function BG(t,e){var n=ar(!0),r=null,i=YS,a=null,s=sj(o);t=typeof t=="function"?t:t===void 0?UG:ar(t),e=typeof e=="function"?e:e===void 0?zG:ar(e);function o(c){var u,d=(c=oj(c)).length,f,g=!1,p;for(r==null&&(a=i(p=s())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===g&&((g=!g)?a.lineStart():a.lineEnd()),g&&a.point(+t(f,u,c),+e(f,u,c));if(p)return a=null,p+""||null}return o.x=function(c){return arguments.length?(t=typeof c=="function"?c:ar(+c),o):t},o.y=function(c){return arguments.length?(e=typeof c=="function"?c:ar(+c),o):e},o.defined=function(c){return arguments.length?(n=typeof c=="function"?c:ar(!!c),o):n},o.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),o):i},o.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),o):r},o}function yv(t,e,n){var r=null,i=ar(!0),a=null,s=YS,o=null,c=sj(u);t=typeof t=="function"?t:t===void 0?UG:ar(+t),e=typeof e=="function"?e:ar(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?zG:ar(+n);function u(f){var g,p,x,v=(f=oj(f)).length,y,b=!1,E,w=new Array(v),A=new Array(v);for(a==null&&(o=s(E=c())),g=0;g<=v;++g){if(!(g<v&&i(y=f[g],g,f))===b)if(b=!b)p=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),x=g-1;x>=p;--x)o.point(w[x],A[x]);o.lineEnd(),o.areaEnd()}b&&(w[g]=+t(y,g,f),A[g]=+e(y,g,f),o.point(r?+r(y,g,f):w[g],n?+n(y,g,f):A[g]))}if(E)return o=null,E+""||null}function d(){return BG().defined(i).curve(s).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:ar(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:ar(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:ar(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:ar(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:ar(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:ar(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:ar(!!f),u):i},u.curve=function(f){return arguments.length?(s=f,a!=null&&(o=s(a)),u):s},u.context=function(f){return arguments.length?(f==null?a=o=null:o=s(a=f),u):a},u}class HG{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 Fde(t){return new HG(t,!0)}function Ude(t){return new HG(t,!1)}const lj={draw(t,e){const n=Ho(e/L1);t.moveTo(n,0),t.arc(0,0,n,0,XS)}},zde={draw(t,e){const n=Ho(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()}},$G=Ho(1/3),Bde=$G*2,Hde={draw(t,e){const n=Ho(e/Bde),r=n*$G;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},$de={draw(t,e){const n=Ho(e),r=-n/2;t.rect(r,r,n,n)}},Vde=.8908130915292852,VG=O1(L1/10)/O1(7*L1/10),Gde=O1(XS/10)*VG,Wde=-LG(XS/10)*VG,qde={draw(t,e){const n=Ho(e*Vde),r=Gde*n,i=Wde*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=XS*a/5,o=LG(s),c=O1(s);t.lineTo(c*n,-o*n),t.lineTo(o*r-c*i,c*r+o*i)}t.closePath()}},UA=Ho(3),Kde={draw(t,e){const n=-Ho(e/(UA*3));t.moveTo(0,n*2),t.lineTo(-UA*n,-n),t.lineTo(UA*n,-n),t.closePath()}},Us=-.5,zs=Ho(3)/2,Wk=1/Ho(12),Xde=(Wk/2+1)*3,Yde={draw(t,e){const n=Ho(e/Xde),r=n/2,i=n*Wk,a=r,s=n*Wk+n,o=-a,c=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(o,c),t.lineTo(Us*r-zs*i,zs*r+Us*i),t.lineTo(Us*a-zs*s,zs*a+Us*s),t.lineTo(Us*o-zs*c,zs*o+Us*c),t.lineTo(Us*r+zs*i,Us*i-zs*r),t.lineTo(Us*a+zs*s,Us*s-zs*a),t.lineTo(Us*o+zs*c,Us*c-zs*o),t.closePath()}};function Zde(t,e){let n=null,r=sj(i);t=typeof t=="function"?t:ar(t||lj),e=typeof e=="function"?e:ar(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:ar(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:ar(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function I1(){}function F1(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 GG(t){this._context=t}GG.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:F1(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:F1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Qde(t){return new GG(t)}function WG(t){this._context=t}WG.prototype={areaStart:I1,areaEnd:I1,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:F1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Jde(t){return new WG(t)}function qG(t){this._context=t}qG.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:F1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function ehe(t){return new qG(t)}function KG(t){this._context=t}KG.prototype={areaStart:I1,areaEnd:I1,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 the(t){return new KG(t)}function hU(t){return t<0?-1:1}function fU(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),s=(n-t._y1)/(i||r<0&&-0),o=(a*i+s*r)/(r+i);return(hU(a)+hU(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function mU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function zA(t,e,n){var r=t._x0,i=t._y0,a=t._x1,s=t._y1,o=(a-r)/3;t._context.bezierCurveTo(r+o,i+o*e,a-o,s-o*n,a,s)}function U1(t){this._context=t}U1.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:zA(this,this._t0,mU(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,zA(this,mU(this,n=fU(this,t,e)),n);break;default:zA(this,this._t0,n=fU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function XG(t){this._context=new YG(t)}(XG.prototype=Object.create(U1.prototype)).point=function(t,e){U1.prototype.point.call(this,e,t)};function YG(t){this._context=t}YG.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function nhe(t){return new U1(t)}function rhe(t){return new XG(t)}function ZG(t){this._context=t}ZG.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=pU(t),i=pU(e),a=0,s=1;s<n;++a,++s)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[s],e[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function pU(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),s=new Array(n);for(i[0]=0,a[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,s[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,s[e]-=r*s[e-1];for(i[n-1]=s[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(s[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function ihe(t){return new ZG(t)}function ZS(t,e){this._context=t,this._t=e}ZS.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 ahe(t){return new ZS(t,.5)}function she(t){return new ZS(t,0)}function ohe(t){return new ZS(t,1)}function wp(t,e){if((s=t.length)>1)for(var n=1,r,i,a=t[e[0]],s,o=a.length;n<s;++n)for(i=a,a=t[e[n]],r=0;r<o;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function qk(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function lhe(t,e){return t[e]}function che(t){const e=[];return e.key=t,e}function uhe(){var t=ar([]),e=qk,n=wp,r=lhe;function i(a){var s=Array.from(t.apply(this,arguments),che),o,c=s.length,u=-1,d;for(const f of a)for(o=0,++u;o<c;++o)(s[o][u]=[0,+r(f,s[o].key,u,a)]).data=f;for(o=0,d=oj(e(s));o<c;++o)s[d[o]].index=o;return n(s,d),s}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:ar(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:ar(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?qk:typeof a=="function"?a:ar(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??wp,i):n},i}function dhe(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,s;i<a;++i){for(s=n=0;n<r;++n)s+=t[n][i][1]||0;if(s)for(n=0;n<r;++n)t[n][i][1]/=s}wp(t,e)}}function hhe(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var s=0,o=0;s<i;++s)o+=t[s][n][1]||0;r[n][1]+=r[n][0]=-o/2}wp(t,e)}}function fhe(t,e){if(!(!((s=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,s;r<a;++r){for(var o=0,c=0,u=0;o<s;++o){for(var d=t[e[o]],f=d[r][1]||0,g=d[r-1][1]||0,p=(f-g)/2,x=0;x<o;++x){var v=t[e[x]],y=v[r][1]||0,b=v[r-1][1]||0;p+=y-b}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,wp(t,e)}}var BA={},HA={},gU;function mhe(){return gU||(gU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(HA)),HA}var $A={},xU;function QG(){return xU||(xU=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})($A)),$A}var VA={},bU;function cj(){return bU||(bU=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})(VA)),VA}var GA={},WA={},yU;function phe(){return yU||(yU=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})(WA)),WA}var vU;function uj(){return vU||(vU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=phe(),n=cj();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],s=i.length;if(s===0)return a;let o=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),o++);o<s;){const f=i[o];u?f==="\\"&&o+1<s?(o++,c+=i[o]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,o++}return c&&a.push(c),a}t.toPath=r})(GA)),GA}var _U;function dj(){return _U||(_U=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mhe(),n=QG(),r=cj(),i=uj();function a(o,c,u){if(o==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?n.isDeepKey(c)?a(o,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=o[c];return d===void 0?u:d}default:{if(Array.isArray(c))return s(o,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?u:d}}}function s(o,c,u){if(c.length===0)return u;let d=o;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(BA)),BA}var qA,wU;function ghe(){return wU||(wU=1,qA=dj().get),qA}var xhe=ghe();const Yh=mo(xhe);var Li=t=>t===0?0:t>0?1:-1,ns=t=>typeof t=="number"&&t!=+t,jc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Rt=t=>(typeof t=="number"||t instanceof Number)&&!ns(t),uo=t=>Rt(t)||typeof t=="string",bhe=0,C0=t=>{var e=++bhe;return"".concat(t||"").concat(e)},ma=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(!Rt(e)&&typeof e!="string")return r;var a;if(jc(e)){if(n==null)return r;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return ns(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},JG=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 Dn(t,e,n){return Rt(t)&&Rt(e)?t+n*(e-t):e}function eW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Yh(r,e))===n)}var fr=t=>t===null||typeof t>"u",vb=t=>fr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function yhe(t){return t!=null}function _b(){}var vhe=["type","size","sizeType"];function Kk(){return Kk=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},Kk.apply(null,arguments)}function SU(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 MU(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SU(Object(n),!0).forEach(function(r){_he(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _he(t,e,n){return(e=whe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function whe(t){var e=She(t,"string");return typeof e=="symbol"?e:e+""}function She(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 Mhe(t,e){if(t==null)return{};var n,r,i=Ehe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ehe(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 tW={symbolCircle:lj,symbolCross:zde,symbolDiamond:Hde,symbolSquare:$de,symbolStar:qde,symbolTriangle:Kde,symbolWye:Yde},Ahe=Math.PI/180,The=t=>{var e="symbol".concat(vb(t));return tW[e]||lj},Che=(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*Ahe;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}},Nhe=(t,e)=>{tW["symbol".concat(vb(t))]=e},hj=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Mhe(t,vhe),a=MU(MU({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var o=()=>{var g=The(s),p=Zde().type(g).size(Che(n,r,s)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=na(a);return Rt(u)&&Rt(d)&&Rt(n)?M.createElement("path",Kk({},f,{className:En("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:o()})):null};hj.registerSymbol=Nhe;var nW=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,fj=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(M.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{ij(i)&&(r[i]=(a=>n[i](n,a)))}),r},khe=(t,e,n)=>r=>(t(e,n,r),null),wb=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];ij(i)&&typeof a=="function"&&(r||(r={}),r[i]=khe(a,e,n))}),r};function EU(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 Phe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EU(Object(n),!0).forEach(function(r){Rhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):EU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rhe(t,e,n){return(e=jhe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jhe(t){var e=Dhe(t,"string");return typeof e=="symbol"?e:e+""}function Dhe(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 Er(t,e){var n=Phe({},t),r=e,i=Object.keys(e),a=i.reduce((s,o)=>(s[o]===void 0&&r[o]!==void 0&&(s[o]=r[o]),s),n);return a}function z1(){return z1=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},z1.apply(null,arguments)}function AU(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 Ohe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AU(Object(n),!0).forEach(function(r){Lhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lhe(t,e,n){return(e=Ihe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ihe(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 Gs=32,Uhe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function zhe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Gs/2,a=Gs/6,s=Gs/3,o=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return M.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Gs,y2:i,className:"recharts-legend-icon"})}if(c==="line")return M.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(s,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
  12. H`).concat(Gs,"M").concat(2*s,",").concat(i,`
  13. A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return M.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Gs/8,"h").concat(Gs,"v").concat(Gs*3/4,"h").concat(-Gs,"z"),className:"recharts-legend-icon"});if(M.isValidElement(e.legendIcon)){var d=Ohe({},e);return delete d.legendIcon,M.cloneElement(e.legendIcon,d)}return M.createElement(hj,{fill:o,cx:i,cy:i,size:Gs,sizeType:"diameter",type:c})}function Bhe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,o={x:0,y:0,width:Gs,height:Gs},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,p=En({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,v=g?g(d.value,d,f):d.value;return M.createElement("li",z1({className:p,style:c,key:"legend-item-".concat(f)},wb(t,d,f)),M.createElement(aj,{width:n,height:n,viewBox:o,style:u,"aria-label":"".concat(v," legend icon")},M.createElement(zhe,{data:d,iconType:s,inactiveColor:a})),M.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v))})}var Hhe=t=>{var e=Er(t,Uhe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return M.createElement("ul",{className:"recharts-default-legend",style:a},M.createElement(Bhe,z1({},e,{payload:n})))},KA={},XA={},TU;function $he(){return TU||(TU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const s=n[a],o=r(s);i.has(o)||i.set(o,s)}return Array.from(i.values())}t.uniqBy=e})(XA)),XA}var YA={},CU;function rW(){return CU||(CU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(YA)),YA}var ZA={},QA={},JA={},NU;function Vhe(){return NU||(NU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(JA)),JA}var kU;function mj(){return kU||(kU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Vhe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(QA)),QA}var eT={},PU;function Ghe(){return PU||(PU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(eT)),eT}var RU;function Whe(){return RU||(RU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mj(),n=Ghe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(ZA)),ZA}var tT={},nT={},jU;function qhe(){return jU||(jU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dj();function n(r){return function(i){return e.get(i,r)}}t.property=n})(nT)),nT}var rT={},iT={},aT={},sT={},DU;function iW(){return DU||(DU=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})(sT)),sT}var oT={},OU;function aW(){return OU||(OU=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})(oT)),oT}var lT={},LU;function sW(){return LU||(LU=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})(lT)),lT}var IU;function Khe(){return IU||(IU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iW(),n=aW(),r=sW();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function p(x,v,y,b,E,w){const A=g(x,v,y,b,E,w);return A!==void 0?!!A:a(x,v,p,w)},new Map)}function a(d,f,g,p){if(f===d)return!0;switch(typeof f){case"object":return s(d,f,g,p);case"function":return Object.keys(f).length>0?a(d,{...f},g,p):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function s(d,f,g,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,g,p);if(f instanceof Map)return o(d,f,g,p);if(f instanceof Set)return u(d,f,g,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let v=0;v<x.length;v++){const y=x[v];if(!n.isPrimitive(d)&&!(y in d)||f[y]===void 0&&d[y]!==void 0||f[y]===null&&d[y]!==null||!g(d[y],f[y],y,d,f,p))return!1}return!0}finally{p?.delete(f)}}function o(d,f,g,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,v]of f.entries()){const y=d.get(x);if(g(y,v,x,d,f,p)===!1)return!1}return!0}function c(d,f,g,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let v=0;v<f.length;v++){const y=f[v];let b=!1;for(let E=0;E<d.length;E++){if(x.has(E))continue;const w=d[E];let A=!1;if(g(w,y,v,d,f,p)&&(A=!0),A){x.add(E),b=!0;break}}if(!b)return!1}return!0}function u(d,f,g,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],g,p):!1}t.isMatchWith=i,t.isSetMatch=u})(aT)),aT}var FU;function oW(){return FU||(FU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Khe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(iT)),iT}var cT={},uT={},dT={},UU;function Xhe(){return UU||(UU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}t.getSymbols=e})(dT)),dT}var hT={},zU;function lW(){return zU||(zU=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})(hT)),hT}var fT={},BU;function cW(){return BU||(BU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",s="[object Symbol]",o="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",p="[object Object]",x="[object Error]",v="[object DataView]",y="[object Uint8Array]",b="[object Uint8ClampedArray]",E="[object Uint16Array]",w="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",C="[object Int16Array]",k="[object Int32Array]",F="[object BigInt64Array]",N="[object Float32Array]",j="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=F,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,t.dateTag=o,t.errorTag=x,t.float32ArrayTag=N,t.float64ArrayTag=j,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=k,t.int8ArrayTag=T,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=E,t.uint32ArrayTag=w,t.uint8ArrayTag=y,t.uint8ClampedArrayTag=b})(fT)),fT}var mT={},HU;function Yhe(){return HU||(HU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(mT)),mT}var $U;function uW(){return $U||($U=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Xhe(),n=lW(),r=cW(),i=aW(),a=Yhe();function s(d,f){return o(d,void 0,d,new Map,f)}function o(d,f,g,p=new Map,x=void 0){const v=x?.(d,f,g,p);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const y=new Array(d.length);p.set(d,y);for(let b=0;b<d.length;b++)y[b]=o(d[b],b,g,p,x);return Object.hasOwn(d,"index")&&(y.index=d.index),Object.hasOwn(d,"input")&&(y.input=d.input),y}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const y=new RegExp(d.source,d.flags);return y.lastIndex=d.lastIndex,y}if(d instanceof Map){const y=new Map;p.set(d,y);for(const[b,E]of d)y.set(b,o(E,b,g,p,x));return y}if(d instanceof Set){const y=new Set;p.set(d,y);for(const b of d)y.add(o(b,void 0,g,p,x));return y}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const y=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,y);for(let b=0;b<d.length;b++)y[b]=o(d[b],b,g,p,x);return y}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const y=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,y),c(y,d,g,p,x),y}if(typeof File<"u"&&d instanceof File){const y=new File([d],d.name,{type:d.type});return p.set(d,y),c(y,d,g,p,x),y}if(typeof Blob<"u"&&d instanceof Blob){const y=new Blob([d],{type:d.type});return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof Error){const y=new d.constructor;return p.set(d,y),y.message=d.message,y.name=d.name,y.stack=d.stack,y.cause=d.cause,c(y,d,g,p,x),y}if(d instanceof Boolean){const y=new Boolean(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof Number){const y=new Number(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof String){const y=new String(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(typeof d=="object"&&u(d)){const y=Object.create(Object.getPrototypeOf(d));return p.set(d,y),c(y,d,g,p,x),y}return d}function c(d,f,g=d,p,x){const v=[...Object.keys(f),...e.getSymbols(f)];for(let y=0;y<v.length;y++){const b=v[y],E=Object.getOwnPropertyDescriptor(d,b);(E==null||E.writable)&&(d[b]=o(f[b],b,g,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=s,t.cloneDeepWithImpl=o,t.copyProperties=c})(uT)),uT}var VU;function Zhe(){return VU||(VU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(cT)),cT}var GU;function Qhe(){return GU||(GU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oW(),n=Zhe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(rT)),rT}var pT={},gT={},xT={},WU;function Jhe(){return WU||(WU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uW(),n=cW();function r(i,a){return e.cloneDeepWith(i,(s,o,c,u)=>{const d=a?.(s,o,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(xT)),xT}var qU;function efe(){return qU||(qU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jhe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(gT)),gT}var bT={},yT={},KU;function dW(){return KU||(KU=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})(yT)),yT}var vT={},XU;function tfe(){return XU||(XU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(vT)),vT}var YU;function nfe(){return YU||(YU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QG(),n=dW(),r=tfe(),i=uj();function a(s,o){let c;if(Array.isArray(o)?c=o:typeof o=="string"&&e.isDeepKey(o)&&s?.[o]==null?c=i.toPath(o):c=[o],c.length===0)return!1;let u=s;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(bT)),bT}var ZU;function rfe(){return ZU||(ZU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oW(),n=cj(),r=efe(),i=dj(),a=nfe();function s(o,c){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,o);return d===void 0?a.has(u,o):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=s})(pT)),pT}var QU;function ife(){return QU||(QU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rW(),n=qhe(),r=Qhe(),i=rfe();function a(s){if(s==null)return e.identity;switch(typeof s){case"function":return s;case"object":return Array.isArray(s)&&s.length===2?i.matchesProperty(s[0],s[1]):r.matches(s);case"string":case"symbol":case"number":return n.property(s)}}t.iteratee=a})(tT)),tT}var JU;function afe(){return JU||(JU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$he(),n=rW(),r=Whe(),i=ife();function a(s,o=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(o)):[]}t.uniqBy=a})(KA)),KA}var _T,ez;function sfe(){return ez||(ez=1,_T=afe().uniqBy),_T}var ofe=sfe();const tz=mo(ofe);function hW(t,e,n){return e===!0?tz(t,n):typeof e=="function"?tz(t,e):t}var wT={exports:{}},ST={};var nz;function lfe(){if(nz)return ST;nz=1;var t=qp(),e=O9();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,s=t.useEffect,o=t.useMemo,c=t.useDebugValue;return ST.useSyncExternalStoreWithSelector=function(u,d,f,g,p){var x=a(null);if(x.current===null){var v={hasValue:!1,value:null};x.current=v}else v=x.current;x=o(function(){function b(C){if(!E){if(E=!0,w=C,C=g(C),p!==void 0&&v.hasValue){var k=v.value;if(p(k,C))return A=k}return A=C}if(k=A,r(w,C))return k;var F=g(C);return p!==void 0&&p(k,F)?(w=C,k):(w=C,A=F)}var E=!1,w,A,T=f===void 0?null:f;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,f,g,p]);var y=i(u,x[0],x[1]);return s(function(){v.hasValue=!0,v.value=y},[y]),c(y),y},ST}var rz;function cfe(){return rz||(rz=1,wT.exports=lfe()),wT.exports}var fW=cfe(),pj=M.createContext(null),ufe=t=>t,ir=()=>{var t=M.useContext(pj);return t?t.store.dispatch:ufe},n1=()=>{},dfe=()=>n1,hfe=(t,e)=>t===e;function kt(t){var e=M.useContext(pj);return fW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:dfe,e?e.store.getState:n1,e?e.store.getState:n1,e?t:n1,hfe)}function ffe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function mfe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function pfe(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 iz=t=>Array.isArray(t)?t:[t];function gfe(t){const e=Array.isArray(t[0])?t[0]:t;return pfe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function xfe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var bfe=class{constructor(t){this.value=t}deref(){return this.value}},yfe=typeof WeakRef<"u"?WeakRef:bfe,vfe=0,az=1;function vv(){return{s:vfe,v:void 0,o:null,p:null}}function mW(t,e={}){let n=vv();const{resultEqualityCheck:r}=e;let i,a=0;function s(){let o=n;const{length:c}=arguments;for(let f=0,g=c;f<g;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=o.o;x===null&&(o.o=x=new WeakMap);const v=x.get(p);v===void 0?(o=vv(),x.set(p,o)):o=v}else{let x=o.p;x===null&&(o.p=x=new Map);const v=x.get(p);v===void 0?(o=vv(),x.set(p,o)):o=v}}const u=o;let d;if(o.s===az)d=o.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new yfe(d):d}return u.s=az,u.v=d,d}return s.clearCache=()=>{n=vv(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function _fe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,s=0,o,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),ffe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:p=mW,argsMemoizeOptions:x=[]}=d,v=iz(g),y=iz(x),b=gfe(i),E=f(function(){return a++,u.apply(null,arguments)},...v),w=p(function(){s++;const T=xfe(b,arguments);return o=E.apply(null,T),o},...y);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:b,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>o,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var Ke=_fe(mW),wfe=Object.assign((t,e=Ke)=>{mfe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((s,o,c)=>(s[n[c]]=o,s),{}))},{withTypes:()=>wfe}),MT={},ET={},AT={},sz;function Sfe(){return sz||(sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const s=e(r),o=e(i);if(s===o&&s===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?o-s:s-o}return 0};t.compareValues=n})(AT)),AT}var TT={},CT={},oz;function pW(){return oz||(oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(CT)),CT}var lz;function Mfe(){return lz||(lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pW(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,s){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||s!=null&&Object.hasOwn(s,a)}t.isKey=i})(TT)),TT}var cz;function Efe(){return cz||(cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Sfe(),n=Mfe(),r=uj();function i(a,s,o,c){if(a==null)return[];o=c?void 0:o,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(p=>String(p));const u=(p,x)=>{let v=p;for(let y=0;y<x.length&&v!=null;++y)v=v[x[y]];return v},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=s.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let v=0;v<f.length;v++){const y=e.compareValues(p.criteria[v],x.criteria[v],o[v]);if(y!==0)return y}return 0}).map(p=>p.original)}t.orderBy=i})(ET)),ET}var NT={},uz;function Afe(){return uz||(uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),s=(o,c)=>{for(let u=0;u<o.length;u++){const d=o[u];Array.isArray(d)&&c<a?s(d,c+1):i.push(d)}};return s(n,0),i}t.flatten=e})(NT)),NT}var kT={},dz;function gW(){return dz||(dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dW(),n=mj(),r=iW(),i=sW();function a(s,o,c){return r.isObject(c)&&(typeof o=="number"&&n.isArrayLike(c)&&e.isIndex(o)&&o<c.length||typeof o=="string"&&o in c)?i.eq(c[o],s):!1}t.isIterateeCall=a})(kT)),kT}var hz;function Tfe(){return hz||(hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Efe(),n=Afe(),r=gW();function i(a,...s){const o=s.length;return o>1&&r.isIterateeCall(a,s[0],s[1])?s=[]:o>2&&r.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=i})(MT)),MT}var PT,fz;function Cfe(){return fz||(fz=1,PT=Tfe().sortBy),PT}var Nfe=Cfe();const QS=mo(Nfe);var xW=t=>t.legend.settings,kfe=t=>t.legend.size,Pfe=t=>t.legend.payload,Rfe=Ke([Pfe,xW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?QS(r,n):r});function jfe(){return kt(Rfe)}var _v=1;function bW(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=M.useState({height:0,left:0,top:0,width:0}),r=M.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),s={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(s.height-e.height)>_v||Math.abs(s.left-e.left)>_v||Math.abs(s.top-e.top)>_v||Math.abs(s.width-e.width)>_v)&&n({height:s.height,left:s.left,top:s.top,width:s.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function Xi(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 Dfe=typeof Symbol=="function"&&Symbol.observable||"@@observable",mz=Dfe,RT=()=>Math.random().toString(36).substring(7).split("").join("."),Ofe={INIT:`@@redux/INIT${RT()}`,REPLACE:`@@redux/REPLACE${RT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${RT()}`},B1=Ofe;function gj(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 yW(t,e,n){if(typeof t!="function")throw new Error(Xi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Xi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Xi(1));return n(yW)(t,e)}let r=t,i=e,a=new Map,s=a,o=0,c=!1;function u(){s===a&&(s=new Map,a.forEach((y,b)=>{s.set(b,y)}))}function d(){if(c)throw new Error(Xi(3));return i}function f(y){if(typeof y!="function")throw new Error(Xi(4));if(c)throw new Error(Xi(5));let b=!0;u();const E=o++;return s.set(E,y),function(){if(b){if(c)throw new Error(Xi(6));b=!1,u(),s.delete(E),a=null}}}function g(y){if(!gj(y))throw new Error(Xi(7));if(typeof y.type>"u")throw new Error(Xi(8));if(typeof y.type!="string")throw new Error(Xi(17));if(c)throw new Error(Xi(9));try{c=!0,i=r(i,y)}finally{c=!1}return(a=s).forEach(E=>{E()}),y}function p(y){if(typeof y!="function")throw new Error(Xi(10));r=y,g({type:B1.REPLACE})}function x(){const y=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(Xi(11));function E(){const A=b;A.next&&A.next(d())}return E(),{unsubscribe:y(E)}},[mz](){return this}}}return g({type:B1.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:p,[mz]:x}}function Lfe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:B1.INIT})>"u")throw new Error(Xi(12));if(typeof n(void 0,{type:B1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Xi(13))})}function vW(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const s=e[a];typeof t[s]=="function"&&(n[s]=t[s])}const r=Object.keys(n);let i;try{Lfe(n)}catch(a){i=a}return function(s={},o){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],p=s[f],x=g(p,o);if(typeof x>"u")throw o&&o.type,new Error(Xi(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(s).length,c?u:s}}function H1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Ife(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(Xi(15))};const s={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},o=t.map(c=>c(s));return a=H1(...o)(i.dispatch),{...i,dispatch:a}}}function _W(t){return gj(t)&&"type"in t&&typeof t.type=="string"}var wW=Symbol.for("immer-nothing"),pz=Symbol.for("immer-draftable"),Pa=Symbol.for("immer-state");function Co(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Ss=Object,Sp=Ss.getPrototypeOf,$1="constructor",JS="prototype",Xk="configurable",V1="enumerable",r1="writable",N0="value",Dc=t=>!!t&&!!t[Pa];function Uo(t){return t?SW(t)||eM(t)||!!t[pz]||!!t[$1]?.[pz]||tM(t)||nM(t):!1}var Ffe=Ss[JS][$1].toString(),gz=new WeakMap;function SW(t){if(!t||!xj(t))return!1;const e=Sp(t);if(e===null||e===Ss[JS])return!0;const n=Ss.hasOwnProperty.call(e,$1)&&e[$1];if(n===Object)return!0;if(!zm(n))return!1;let r=gz.get(n);return r===void 0&&(r=Function.toString.call(n),gz.set(n,r)),r===Ffe}function Sb(t,e,n=!0){Mb(t)===0?(n?Reflect.ownKeys(t):Ss.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Mb(t){const e=t[Pa];return e?e.type_:eM(t)?1:tM(t)?2:nM(t)?3:0}var xz=(t,e,n=Mb(t))=>n===2?t.has(e):Ss[JS].hasOwnProperty.call(t,e),Yk=(t,e,n=Mb(t))=>n===2?t.get(e):t[e],G1=(t,e,n,r=Mb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Ufe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var eM=Array.isArray,tM=t=>t instanceof Map,nM=t=>t instanceof Set,xj=t=>typeof t=="object",zm=t=>typeof t=="function",jT=t=>typeof t=="boolean",cc=t=>t.copy_||t.base_,bj=t=>t.modified_?t.copy_:t.base_;function Zk(t,e){if(tM(t))return new Map(t);if(nM(t))return new Set(t);if(eM(t))return Array[JS].slice.call(t);const n=SW(t);if(e===!0||e==="class_only"&&!n){const r=Ss.getOwnPropertyDescriptors(t);delete r[Pa];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o[r1]===!1&&(o[r1]=!0,o[Xk]=!0),(o.get||o.set)&&(r[s]={[Xk]:!0,[r1]:!0,[V1]:o[V1],[N0]:t[s]})}return Ss.create(Sp(t),r)}else{const r=Sp(t);if(r!==null&&n)return{...t};const i=Ss.create(r);return Ss.assign(i,t)}}function yj(t,e=!1){return rM(t)||Dc(t)||!Uo(t)||(Mb(t)>1&&Ss.defineProperties(t,{set:wv,add:wv,clear:wv,delete:wv}),Ss.freeze(t),e&&Sb(t,(n,r)=>{yj(r,!0)},!1)),t}function zfe(){Co(2)}var wv={[N0]:zfe};function rM(t){return t===null||!xj(t)?!0:Ss.isFrozen(t)}var W1="MapSet",Qk="Patches",MW={};function Mp(t){const e=MW[t];return e||Co(0,t),e}var Bfe=t=>!!MW[t],k0,EW=()=>k0,Hfe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Bfe(W1)?Mp(W1):void 0});function bz(t,e){e&&(t.patchPlugin_=Mp(Qk),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Jk(t){e3(t),t.drafts_.forEach($fe),t.drafts_=null}function e3(t){t===k0&&(k0=t.parent_)}var yz=t=>k0=Hfe(k0,t);function $fe(t){const e=t[Pa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function vz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Pa].modified_&&(Jk(e),Co(4)),Uo(t)&&(t=_z(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Pa].base_,t,e)}else t=_z(e,n);return Vfe(e,t,!0),Jk(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==wW?t:void 0}function _z(t,e){if(rM(e))return e;const n=e[Pa];if(!n)return vj(e,t.handledSet_,t);if(!iM(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);CW(n,t)}return n.copy_}function Vfe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&yj(e,n)}function AW(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var iM=(t,e)=>t.scope_===e,Gfe=[];function TW(t,e,n,r){const i=cc(t),a=t.type_;if(r!==void 0&&Yk(i,r,a)===e){G1(i,r,n,a);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;Sb(i,(c,u)=>{if(Dc(u)){const d=o.get(u)||[];d.push(c),o.set(u,d)}})}const s=t.draftLocations_.get(e)??Gfe;for(const o of s)G1(i,o,n,a)}function Wfe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!iM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=bj(a);TW(t,a.draft_??a,s,n),CW(a,i)})}function CW(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)}AW(t)}}function qfe(t,e,n){const{scope_:r}=t;if(Dc(n)){const i=n[Pa];iM(i,r)&&i.callbacks_.push(function(){i1(t);const s=bj(i);TW(t,n,s,e)})}else Uo(n)&&t.callbacks_.push(function(){const a=cc(t);Yk(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&vj(Yk(t.copy_,e,t.type_),r.handledSet_,r)})}function vj(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Dc(t)||e.has(t)||!Uo(t)||rM(t)||(e.add(t),Sb(t,(r,i)=>{if(Dc(i)){const a=i[Pa];if(iM(a,n)){const s=bj(a);G1(t,r,s,t.type_),AW(a)}}else Uo(i)&&vj(i,e,n)})),t}function Kfe(t,e){const n=eM(t),r={type_:n?1:0,scope_:e?e.scope_:EW(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=_j;n&&(i=[r],a=P0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,[o,r]}var _j={get(t,e){if(e===Pa)return t;const n=cc(t);if(!xz(n,e,t.type_))return Xfe(t,n,e);const r=n[e];if(t.finalized_||!Uo(r))return r;if(r===DT(t.base_,e)){i1(t);const i=t.type_===1?+e:e,a=n3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in cc(t)},ownKeys(t){return Reflect.ownKeys(cc(t))},set(t,e,n){const r=NW(cc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=DT(cc(t),e),a=i?.[Pa];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Ufe(n,i)&&(n!==void 0||xz(t.base_,e,t.type_)))return!0;i1(t),t3(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),qfe(t,e,n)),!0},deleteProperty(t,e){return i1(t),DT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),t3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=cc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[r1]:!0,[Xk]:t.type_!==1||e!=="length",[V1]:r[V1],[N0]:n[e]}},defineProperty(){Co(11)},getPrototypeOf(t){return Sp(t.base_)},setPrototypeOf(){Co(12)}},P0={};Sb(_j,(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 _j.set.call(this,t[0],e,n,t[0])};function DT(t,e){const n=t[Pa];return(n?cc(n):t)[e]}function Xfe(t,e,n){const r=NW(e,n);return r?N0 in r?r[N0]:r.get?.call(t.draft_):void 0}function NW(t,e){if(!(e in t))return;let n=Sp(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Sp(n)}}function t3(t){t.modified_||(t.modified_=!0,t.parent_&&t3(t.parent_))}function i1(t){t.copy_||(t.assigned_=new Map,t.copy_=Zk(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Yfe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(zm(n)&&!zm(r)){const s=r;r=n;const o=this;return function(u=s,...d){return o.produce(u,f=>r.call(this,f,...d))}}zm(r)||Co(6),i!==void 0&&!zm(i)&&Co(7);let a;if(Uo(n)){const s=yz(this),o=n3(s,n,void 0);let c=!0;try{a=r(o),c=!1}finally{c?Jk(s):e3(s)}return bz(s,i),vz(a,s)}else if(!n||!xj(n)){if(a=r(n),a===void 0&&(a=n),a===wW&&(a=void 0),this.autoFreeze_&&yj(a,!0),i){const s=[],o=[];Mp(Qk).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:o}),i(s,o)}return a}else Co(1,n)},this.produceWithPatches=(n,r)=>{if(zm(n))return(o,...c)=>this.produceWithPatches(o,u=>n(u,...c));let i,a;return[this.produce(n,r,(o,c)=>{i=o,a=c}),i,a]},jT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),jT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),jT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Uo(e)||Co(8),Dc(e)&&(e=Lo(e));const n=yz(this),r=n3(n,e,void 0);return r[Pa].isManual_=!0,e3(n),r}finishDraft(e,n){const r=e&&e[Pa];(!r||!r.isManual_)&&Co(9);const{scope_:i}=r;return bz(i,n),vz(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=Mp(Qk).applyPatches_;return Dc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function n3(t,e,n,r){const[i,a]=tM(e)?Mp(W1).proxyMap_(e,n):nM(e)?Mp(W1).proxySet_(e,n):Kfe(e,n);return(n?.scope_??EW()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Wfe(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Lo(t){return Dc(t)||Co(10,t),kW(t)}function kW(t){if(!Uo(t)||rM(t))return t;const e=t[Pa];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Zk(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=Zk(t,!0);return Sb(n,(i,a)=>{G1(n,i,kW(a))},r),e&&(e.finalized_=!1),n}var Zfe=new Yfe,PW=Zfe.produce;function RW(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Qfe=RW(),Jfe=RW,eme=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?H1:H1.apply(null,arguments)};function ho(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Ms(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>_W(r)&&r.type===t,n}var jW=class Ix extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Ix.prototype)}static get[Symbol.species](){return Ix}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Ix(...e[0].concat(this)):new Ix(...e.concat(this))}};function wz(t){return Uo(t)?PW(t,()=>{}):t}function Sv(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function tme(t){return typeof t=="boolean"}var nme=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new jW;return n&&(tme(n)?s.push(Qfe):s.push(Jfe(n.extraArgument))),s},DW="RTK_autoBatch",pr=()=>t=>({payload:t,meta:{[DW]:!0}}),Sz=t=>e=>{setTimeout(e,t)},OW=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,s=!1;const o=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Sz(10):t.type==="callback"?t.queueNotification:Sz(t.timeout),u=()=>{s=!1,a&&(a=!1,o.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return o.add(d),()=>{g(),o.delete(d)}},dispatch(d){try{return i=!d?.meta?.[DW],a=!i,a&&(s||(s=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},rme=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new jW(t);return r&&i.push(OW(typeof r=="object"?r:void 0)),i};function ime(t){const e=nme(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(gj(n))o=vW(n);else throw new Error(Ms(1));let c;typeof r=="function"?c=r(e):c=e();let u=H1;i&&(u=eme({trace:!1,...typeof i=="object"&&i}));const d=Ife(...c),f=rme(d);let g=typeof s=="function"?s(f):f();const p=u(...g);return yW(o,a,p)}function LW(t){const e={},n=[];let r;const i={addCase(a,s){const o=typeof a=="string"?a:a.type;if(!o)throw new Error(Ms(28));if(o in e)throw new Error(Ms(29));return e[o]=s,i},addAsyncThunk(a,s){return s.pending&&(e[a.pending.type]=s.pending),s.rejected&&(e[a.rejected.type]=s.rejected),s.fulfilled&&(e[a.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:a.settled,reducer:s.settled}),i},addMatcher(a,s){return n.push({matcher:a,reducer:s}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function ame(t){return typeof t=="function"}function sme(t,e){let[n,r,i]=LW(e),a;if(ame(t))a=()=>wz(t());else{const o=wz(t);a=()=>o}function s(o=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Dc(d)){const p=f(d,c);return p===void 0?d:p}else{if(Uo(d))return PW(d,g=>f(g,c));{const g=f(d,c);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 s.getInitialState=a,s}var ome="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",lme=(t=21)=>{let e="",n=t;for(;n--;)e+=ome[Math.random()*64|0];return e},cme=Symbol.for("rtk-slice-createasyncthunk");function ume(t,e){return`${t}/${e}`}function dme({creators:t}={}){const e=t?.asyncThunk?.[cme];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Ms(11));const s=(typeof r.reducers=="function"?r.reducers(fme()):r.reducers)||{},o=Object.keys(s),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,A){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(Ms(12));if(T in c.sliceCaseReducersByType)throw new Error(Ms(13));return c.sliceCaseReducersByType[T]=A,u},addMatcher(w,A){return c.sliceMatchers.push({matcher:w,reducer:A}),u},exposeAction(w,A){return c.actionCreators[w]=A,u},exposeCaseReducer(w,A){return c.sliceCaseReducersByName[w]=A,u}};o.forEach(w=>{const A=s[w],T={reducerName:w,type:ume(i,w),createNotation:typeof r.reducers=="function"};pme(A)?xme(T,A,u,e):mme(T,A,u)});function d(){const[w={},A=[],T=void 0]=typeof r.extraReducers=="function"?LW(r.extraReducers):[r.extraReducers],C={...w,...c.sliceCaseReducersByType};return sme(r.initialState,k=>{for(let F in C)k.addCase(F,C[F]);for(let F of c.sliceMatchers)k.addMatcher(F.matcher,F.reducer);for(let F of A)k.addMatcher(F.matcher,F.reducer);T&&k.addDefaultCase(T)})}const f=w=>w,g=new Map,p=new WeakMap;let x;function v(w,A){return x||(x=d()),x(w,A)}function y(){return x||(x=d()),x.getInitialState()}function b(w,A=!1){function T(k){let F=k[w];return typeof F>"u"&&A&&(F=Sv(p,T,y)),F}function C(k=f){const F=Sv(g,A,()=>new WeakMap);return Sv(F,k,()=>{const N={};for(const[j,I]of Object.entries(r.selectors??{}))N[j]=hme(I,k,()=>Sv(p,k,y),A);return N})}return{reducerPath:w,getSelectors:C,get selectors(){return C(T)},selectSlice:T}}const E={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:y,...b(a),injectInto(w,{reducerPath:A,...T}={}){const C=A??a;return w.inject({reducerPath:C,reducer:v},T),{...E,...b(C,!0)}}};return E}}function hme(t,e,n,r){function i(a,...s){let o=e(a);return typeof o>"u"&&r&&(o=n()),t(o,...s)}return i.unwrapped=t,i}var rs=dme();function fme(){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 mme({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!gme(r))throw new Error(Ms(17));a=r.reducer,s=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?ho(t,s):ho(t))}function pme(t){return t._reducerDefinitionType==="asyncThunk"}function gme(t){return t._reducerDefinitionType==="reducerWithPrepare"}function xme({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Ms(18));const{payloadCreator:a,fulfilled:s,pending:o,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),s&&r.addCase(f.fulfilled,s),o&&r.addCase(f.pending,o),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:s||Mv,pending:o||Mv,rejected:c||Mv,settled:u||Mv})}function Mv(){}var bme="task",IW="listener",FW="completed",wj="cancelled",yme=`task-${wj}`,vme=`task-${FW}`,r3=`${IW}-${wj}`,_me=`${IW}-${FW}`,aM=class{constructor(t){this.code=t,this.message=`${bme} ${wj} (reason: ${t})`}name="TaskAbortError";message},Sj=(t,e)=>{if(typeof t!="function")throw new TypeError(Ms(32))},q1=()=>{},UW=(t,e=q1)=>(t.catch(e),t),zW=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Nh=(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))},kh=t=>{if(t.aborted){const{reason:e}=t;throw new aM(e)}};function BW(t,e){let n=q1;return new Promise((r,i)=>{const a=()=>i(new aM(t.reason));if(t.aborted){a();return}n=zW(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=q1})}var wme=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof aM?"cancelled":"rejected",error:n}}finally{e?.()}},K1=t=>e=>UW(BW(t,e).then(n=>(kh(t),n))),HW=t=>{const e=K1(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:np}=Object,Mz={},sM="listenerMiddleware",Sme=(t,e)=>{const n=r=>zW(t,()=>Nh(r,t.reason));return(r,i)=>{Sj(r);const a=new AbortController;n(a);const s=wme(async()=>{kh(t),kh(a.signal);const o=await r({pause:K1(a.signal),delay:HW(a.signal),signal:a.signal});return kh(a.signal),o},()=>Nh(a,vme));return i?.autoJoin&&e.push(s.catch(q1)),{result:K1(t)(s),cancel(){Nh(a,yme)}}}},Mme=(t,e)=>{const n=async(r,i)=>{kh(e);let a=()=>{};const o=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),c([f,g.getState(),g.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&o.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await BW(e,Promise.race(o));return kh(e),c}finally{a()}};return(r,i)=>UW(n(r,i))},$W=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=ho(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Ms(21));return Sj(a),{predicate:i,type:e,effect:a}},VW=np(t=>{const{type:e,predicate:n,effect:r}=$W(t);return{id:lme(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Ms(22))}}},{withTypes:()=>VW}),Ez=(t,e)=>{const{type:n,effect:r,predicate:i}=$W(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},i3=t=>{t.pending.forEach(e=>{Nh(e,r3)})},Eme=(t,e)=>()=>{for(const n of e.keys())i3(n);t.clear()},Az=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},GW=np(ho(`${sM}/add`),{withTypes:()=>GW}),Ame=ho(`${sM}/removeAll`),WW=np(ho(`${sM}/remove`),{withTypes:()=>WW}),Tme=(...t)=>{console.error(`${sM}/error`,...t)},Eb=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:a,onError:s=Tme}=t;Sj(s);const o=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&i3(p)}),c=p=>{const x=Ez(e,p)??VW(p);return o(x)};np(c,{withTypes:()=>c});const u=p=>{const x=Ez(e,p);return x&&(x.unsubscribe(),p.cancelActive&&i3(x)),!!x};np(u,{withTypes:()=>u});const d=async(p,x,v,y)=>{const b=new AbortController,E=Mme(c,b.signal),w=[];try{p.pending.add(b),r(p),await Promise.resolve(p.effect(x,np({},v,{getOriginalState:y,condition:(A,T)=>E(A,T).then(Boolean),take:E,delay:HW(b.signal),pause:K1(b.signal),extra:a,signal:b.signal,fork:Sme(b.signal,w),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,T,C)=>{A!==b&&(Nh(A,r3),C.delete(A))})},cancel:()=>{Nh(b,r3),p.pending.delete(b)},throwIfCancelled:()=>{kh(b.signal)}})))}catch(A){A instanceof aM||Az(s,A,{raisedBy:"effect"})}finally{await Promise.all(w),Nh(b,_me),i(p),p.pending.delete(b)}},f=Eme(e,n);return{middleware:p=>x=>v=>{if(!_W(v))return x(v);if(GW.match(v))return c(v.payload);if(Ame.match(v)){f();return}if(WW.match(v))return u(v.payload);let y=p.getState();const b=()=>{if(y===Mz)throw new Error(Ms(23));return y};let E;try{if(E=x(v),e.size>0){const w=p.getState(),A=Array.from(e.values());for(const T of A){let C=!1;try{C=T.predicate(v,w,y)}catch(k){C=!1,Az(s,k,{raisedBy:"predicate"})}C&&d(T,v,p,b)}}}finally{y=Mz}return E},startListening:c,stopListening:u,clearListeners:f}};function Ms(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var Cme={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},qW=rs({name:"chartLayout",initialState:Cme,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:Nme,setLayout:kme,setChartSize:Pme,setScale:Rme}=qW.actions,jme=qW.reducer;function KW(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Tz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function qm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Tz(Object(n),!0).forEach(function(r){Dme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Tz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dme(t,e,n){return(e=Ome(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ome(t){var e=Lme(t,"string");return typeof e=="symbol"?e:e+""}function Lme(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 Hn(t,e,n){return fr(t)||fr(e)?n:uo(e)?Yh(t,e,n):typeof e=="function"?e(t):n}var Ime=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:s,layout:o}=e;if((o==="vertical"||o==="horizontal"&&s==="middle")&&a!=="center"&&Rt(t[a]))return qm(qm({},t),{},{[a]:t[a]+(r||0)});if((o==="horizontal"||o==="vertical"&&a==="center")&&s!=="middle"&&Rt(t[s]))return qm(qm({},t),{},{[s]:t[s]+(i||0)})}return t},Sl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",XW=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,a,s=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(a=!0),o.coordinate));return i||s.push(e),a||s.push(n),s},YW=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:s,realScaleType:o,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:p}=t;if(!s)return null;var x=o==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,v=i==="category"&&s.bandwidth?s.bandwidth()/x:0;if(v=p==="angleAxis"&&a&&a.length>=2?Li(a[0]-a[1])*2*v:v,f||g){var y=(f||g||[]).map((b,E)=>{var w=r?r.indexOf(b):b;return{coordinate:s(w)+v,value:b,offset:v,index:E}});return y.filter(b=>!ns(b.coordinate))}return c&&u?u.map((b,E)=>({coordinate:s(b)+v,value:b,index:E,offset:v})):s.ticks&&d!=null?s.ticks(d).map((b,E)=>({coordinate:s(b)+v,value:b,offset:v,index:E})):s.domain().map((b,E)=>({coordinate:s(b)+v,value:r?r[b]:b,index:E,offset:v}))},Cz=1e-4,Fme=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-Cz,a=Math.max(r[0],r[1])+Cz,s=t(e[0]),o=t(e[n-1]);(s<i||s>a||o<i||o>a)&&t.domain([e[0],e[n-1]])}},Ume=(t,e)=>{if(!e||e.length!==2||!Rt(e[0])||!Rt(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(!Rt(t[0])||t[0]<n)&&(i[0]=n),(!Rt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},zme=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,s=0;s<e;++s){var o=ns(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=i,t[s][n][1]=i+o,i=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+o,a=t[s][n][1])}},Bme=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var s=ns(t[a][n][1])?t[a][n][0]:t[a][n][1];s>=0?(t[a][n][0]=i,t[a][n][1]=i+s,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},Hme={sign:zme,expand:dhe,none:wp,silhouette:hhe,wiggle:fhe,positive:Bme},$me=(t,e,n)=>{var r=Hme[n],i=uhe().keys(e).value((a,s)=>Number(Hn(a,s,0))).order(qk).offset(r);return i(t)};function ZW(t){return t==null?void 0:String(t)}function X1(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!fr(i[e.dataKey])){var o=eW(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Hn(i,fr(s)?e.dataKey:s);return fr(c)?null:e.scale(c)}var Nz=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:s}=t;if(e.type==="category")return n[s]?n[s].coordinate+r:null;var o=Hn(a,e.dataKey,e.scale.domain()[s]);return fr(o)?null:e.scale(o)-i/2+r},Vme=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]},Gme=t=>{var e=t.flat(2).filter(Rt);return[Math.min(...e),Math.max(...e)]},Wme=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],qme=(t,e,n)=>{if(t!=null)return Wme(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,o=s.reduce((c,u)=>{var d=KW(u,e,n),f=Gme(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},kz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Pz=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,fd=(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=QS(e,d=>d.coordinate),a=1/0,s=1,o=i.length;s<o;s++){var c=i[s],u=i[s-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function Rz(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return qm(qm({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Ad(t,e){if(t)return String(t);if(typeof e=="string")return e}var Kme=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Xme=(t,e)=>e==="centric"?t.angle:t.radius,Vc=t=>t.layout.width,Gc=t=>t.layout.height,Yme=t=>t.layout.scale,QW=t=>t.layout.margin,oM=Ke(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),lM=Ke(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),JW="data-recharts-item-index",eq="data-recharts-item-data-key",Ab=60;function jz(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 Ev(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jz(Object(n),!0).forEach(function(r){Zme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zme(t,e,n){return(e=Qme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qme(t){var e=Jme(t,"string");return typeof e=="symbol"?e:e+""}function Jme(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 epe=t=>t.brush.height;function tpe(t){var e=lM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Ab;return n+i}return n},0)}function npe(t){var e=lM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Ab;return n+i}return n},0)}function rpe(t){var e=oM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function ipe(t){var e=oM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var bi=Ke([Vc,Gc,QW,epe,tpe,npe,rpe,ipe,xW,kfe],(t,e,n,r,i,a,s,o,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+o},g=Ev(Ev({},f),d),p=g.bottom;g.bottom+=r,g=Ime(g,c,u);var x=t-g.left-g.right,v=e-g.top-g.bottom;return Ev(Ev({brushBottom:p},g),{},{width:Math.max(x,0),height:Math.max(v,0)})}),ape=Ke(bi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),Mj=Ke(Vc,Gc,(t,e)=>({x:0,y:0,width:t,height:e})),spe=M.createContext(null),yi=()=>M.useContext(spe)!=null,cM=t=>t.brush,uM=Ke([cM,bi,QW],(t,e,n)=>({height:t.height,x:Rt(t.x)?t.x:e.left,y:Rt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Rt(t.width)?t.width:e.width})),OT={},LT={},IT={},Dz;function ope(){return Dz||(Dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let s,o=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{o!==null&&(n.apply(s,o),s=void 0,o=null)},f=()=>{u&&d(),v()};let g=null;const p=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},v=()=>{x(),s=void 0,o=null},y=()=>{d()},b=function(...E){if(i?.aborted)return;s=this,o=E;const w=g==null;p(),c&&w&&d()};return b.schedule=p,b.cancel=v,b.flush=y,i?.addEventListener("abort",v,{once:!0}),b}t.debounce=e})(IT)),IT}var Oz;function lpe(){return Oz||(Oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ope();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:o=!0,maxWait:c}=a,u=Array(2);s&&(u[0]="leading"),o&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...v){d=r.apply(this,v),f=null},i,{edges:u}),p=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,v),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,v),d)},x=()=>(g.flush(),d);return p.cancel=g.cancel,p.flush=x,p}t.debounce=n})(LT)),LT}var Lz;function cpe(){return Lz||(Lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lpe();function n(r,i=0,a={}){const{leading:s=!0,trailing:o=!0}=a;return e.debounce(r,i,{leading:s,maxWait:i,trailing:o})}t.throttle=n})(OT)),OT}var FT,Iz;function upe(){return Iz||(Iz=1,FT=cpe().throttle),FT}var dpe=upe();const hpe=mo(dpe);var Y1=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=0;console.warn(n.replace(/%s/g,()=>i[s++]))}},tq=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,o=jc(r)?t:Number(r),c=jc(i)?e:Number(i);return a&&a>0&&(o?c=o/a:c&&(o=c*a),s&&c!=null&&c>s&&(c=s)),{calculatedWidth:o,calculatedHeight:c}},fpe={width:0,height:0,overflow:"visible"},mpe={width:0,overflowX:"visible"},ppe={height:0,overflowY:"visible"},gpe={},xpe=t=>{var{width:e,height:n}=t,r=jc(e),i=jc(n);return r&&i?fpe:r?mpe:i?ppe:gpe};function bpe(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function $n(t){return Number.isFinite(t)}function fl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function a3(){return a3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},a3.apply(null,arguments)}function Fz(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 Uz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Fz(Object(n),!0).forEach(function(r){ype(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Fz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ype(t,e,n){return(e=vpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vpe(t){var e=_pe(t,"string");return typeof e=="symbol"?e:e+""}function _pe(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 nq=M.createContext({width:-1,height:-1});function wpe(t){return fl(t.width)&&fl(t.height)}function rq(t){var{children:e,width:n,height:r}=t,i=M.useMemo(()=>({width:n,height:r}),[n,r]);return wpe(i)?M.createElement(nq.Provider,{value:i},e):null}var Ej=()=>M.useContext(nq),Spe=M.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:s=0,minHeight:o,maxHeight:c,children:u,debounce:d=0,id:f,className:g,onResize:p,style:x={}}=t,v=M.useRef(null),y=M.useRef();y.current=p,M.useImperativeHandle(e,()=>v.current);var[b,E]=M.useState({containerWidth:r.width,containerHeight:r.height}),w=M.useCallback((F,N)=>{E(j=>{var I=Math.round(F),O=Math.round(N);return j.containerWidth===I&&j.containerHeight===O?j:{containerWidth:I,containerHeight:O}})},[]);M.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return _b;var F=O=>{var q,{width:R,height:W}=O[0].contentRect;w(R,W),(q=y.current)===null||q===void 0||q.call(y,R,W)};d>0&&(F=hpe(F,d,{trailing:!0,leading:!1}));var N=new ResizeObserver(F),{width:j,height:I}=v.current.getBoundingClientRect();return w(j,I),N.observe(v.current),()=>{N.disconnect()}},[w,d]);var{containerWidth:A,containerHeight:T}=b;Y1(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:k}=tq(A,T,{width:i,height:a,aspect:n,maxHeight:c});return Y1(C!=null&&C>0||k!=null&&k>0,`The width(%s) and height(%s) of chart should be greater than 0,
  14. please check the style of container, or the props width(%s) and height(%s),
  15. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  16. height and width.`,C,k,i,a,s,o,n),M.createElement("div",{id:f?"".concat(f):void 0,className:En("recharts-responsive-container",g),style:Uz(Uz({},x),{},{width:i,height:a,minWidth:s,minHeight:o,maxHeight:c}),ref:v},M.createElement("div",{style:xpe({width:i,height:a})},M.createElement(rq,{width:C,height:k},u)))}),a1=M.forwardRef((t,e)=>{var n=Ej();if(fl(n.width)&&fl(n.height))return t.children;var{width:r,height:i}=bpe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=tq(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Rt(a)&&Rt(s)?M.createElement(rq,{width:a,height:s},t.children):M.createElement(Spe,a3({},t,{width:r,height:i,ref:e}))});function iq(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 Tb=()=>{var t,e=yi(),n=kt(ape),r=kt(uM),i=(t=kt(cM))===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}},Mpe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},aq=()=>{var t;return(t=kt(bi))!==null&&t!==void 0?t:Mpe},Aj=()=>kt(Vc),Tj=()=>kt(Gc),Epe=()=>kt(t=>t.layout.margin),xn=t=>t.layout.layoutType,mf=()=>kt(xn),Ape=()=>{var t=mf();if(t==="horizontal"||t==="vertical")return t},Tpe=()=>{var t=mf();return t!==void 0},dM=t=>{var e=ir(),n=yi(),{width:r,height:i}=t,a=Ej(),s=r,o=i;return a&&(s=a.width>0?a.width:r,o=a.height>0?a.height:i),M.useEffect(()=>{!n&&fl(s)&&fl(o)&&e(Pme({width:s,height:o}))},[e,n,s,o]),null},sq=Symbol.for("immer-nothing"),zz=Symbol.for("immer-draftable"),Ns=Symbol.for("immer-state");function No(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var R0=Object.getPrototypeOf;function Ep(t){return!!t&&!!t[Ns]}function Zh(t){return t?oq(t)||Array.isArray(t)||!!t[zz]||!!t.constructor?.[zz]||Cb(t)||fM(t):!1}var Cpe=Object.prototype.constructor.toString(),Bz=new WeakMap;function oq(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=Bz.get(n);return r===void 0&&(r=Function.toString.call(n),Bz.set(n,r)),r===Cpe}function Z1(t,e,n=!0){hM(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 hM(t){const e=t[Ns];return e?e.type_:Array.isArray(t)?1:Cb(t)?2:fM(t)?3:0}function s3(t,e){return hM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function lq(t,e,n){const r=hM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Npe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Cb(t){return t instanceof Map}function fM(t){return t instanceof Set}function uh(t){return t.copy_||t.base_}function o3(t,e){if(Cb(t))return new Map(t);if(fM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=oq(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Ns];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],o=r[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[s]})}return Object.create(R0(t),r)}else{const r=R0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function Cj(t,e=!1){return mM(t)||Ep(t)||!Zh(t)||(hM(t)>1&&Object.defineProperties(t,{set:Av,add:Av,clear:Av,delete:Av}),Object.freeze(t),e&&Object.values(t).forEach(n=>Cj(n,!0))),t}function kpe(){No(2)}var Av={value:kpe};function mM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var Ppe={};function Qh(t){const e=Ppe[t];return e||No(0,t),e}var j0;function cq(){return j0}function Rpe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Hz(t,e){e&&(Qh("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function l3(t){c3(t),t.drafts_.forEach(jpe),t.drafts_=null}function c3(t){t===j0&&(j0=t.parent_)}function $z(t){return j0=Rpe(j0,t)}function jpe(t){const e=t[Ns];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Vz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Ns].modified_&&(l3(e),No(4)),Zh(t)&&(t=Q1(e,t),e.parent_||J1(e,t)),e.patches_&&Qh("Patches").generateReplacementPatches_(n[Ns].base_,t,e.patches_,e.inversePatches_)):t=Q1(e,n,[]),l3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==sq?t:void 0}function Q1(t,e,n){if(mM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Ns];if(!i)return Z1(e,(a,s)=>Gz(t,i,e,a,s,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return J1(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let s=a,o=!1;i.type_===3&&(s=new Set(a),a.clear(),o=!0),Z1(s,(c,u)=>Gz(t,i,a,c,u,n,o),r),J1(t,a,!1),n&&t.patches_&&Qh("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function Gz(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const o=mM(i);if(!(o&&!s)){if(Ep(i)){const c=a&&e&&e.type_!==3&&!s3(e.assigned_,r)?a.concat(r):void 0,u=Q1(t,i,c);if(lq(n,r,u),Ep(u))t.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Zh(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;Q1(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Cb(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&J1(t,i)}}}function J1(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Cj(e,n)}function Dpe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:cq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=Nj;n&&(i=[r],a=D0);const{revoke:s,proxy:o}=Proxy.revocable(i,a);return r.draft_=o,r.revoke_=s,o}var Nj={get(t,e){if(e===Ns)return t;const n=uh(t);if(!s3(n,e))return Ope(t,n,e);const r=n[e];return t.finalized_||!Zh(r)?r:r===UT(t.base_,e)?(zT(t),t.copy_[e]=d3(r,t)):r},has(t,e){return e in uh(t)},ownKeys(t){return Reflect.ownKeys(uh(t))},set(t,e,n){const r=uq(uh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=UT(uh(t),e),a=i?.[Ns];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Npe(n,i)&&(n!==void 0||s3(t.base_,e)))return!0;zT(t),u3(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 UT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,zT(t),u3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=uh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){No(11)},getPrototypeOf(t){return R0(t.base_)},setPrototypeOf(){No(12)}},D0={};Z1(Nj,(t,e)=>{D0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});D0.deleteProperty=function(t,e){return D0.set.call(this,t,e,void 0)};D0.set=function(t,e,n){return Nj.set.call(this,t[0],e,n,t[0])};function UT(t,e){const n=t[Ns];return(n?uh(n):t)[e]}function Ope(t,e,n){const r=uq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function uq(t,e){if(!(e in t))return;let n=R0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=R0(n)}}function u3(t){t.modified_||(t.modified_=!0,t.parent_&&u3(t.parent_))}function zT(t){t.copy_||(t.copy_=o3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Lpe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const s=this;return function(c=a,...u){return s.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&No(6),r!==void 0&&typeof r!="function"&&No(7);let i;if(Zh(e)){const a=$z(this),s=d3(e,void 0);let o=!0;try{i=n(s),o=!1}finally{o?l3(a):c3(a)}return Hz(a,r),Vz(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===sq&&(i=void 0),this.autoFreeze_&&Cj(i,!0),r){const a=[],s=[];Qh("Patches").generateReplacementPatches_(e,i,a,s),r(a,s)}return i}else No(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...o)=>this.produceWithPatches(s,c=>e(c,...o));let r,i;return[this.produce(e,n,(s,o)=>{r=s,i=o}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Zh(t)||No(8),Ep(t)&&(t=Ipe(t));const e=$z(this),n=d3(t,void 0);return n[Ns].isManual_=!0,c3(e),n}finishDraft(t,e){const n=t&&t[Ns];(!n||!n.isManual_)&&No(9);const{scope_:r}=n;return Hz(r,e),Vz(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=Qh("Patches").applyPatches_;return Ep(t)?r(t,e):this.produce(t,i=>r(i,e))}};function d3(t,e){const n=Cb(t)?Qh("MapSet").proxyMap_(t,e):fM(t)?Qh("MapSet").proxySet_(t,e):Dpe(t,e);return(e?e.scope_:cq()).drafts_.push(n),n}function Ipe(t){return Ep(t)||No(10,t),dq(t)}function dq(t){if(!Zh(t)||mM(t))return t;const e=t[Ns];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=o3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=o3(t,!0);return Z1(n,(i,a)=>{lq(n,i,dq(a))},r),e&&(e.finalized_=!1),n}var Fpe=new Lpe;Fpe.produce;var Upe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},hq=rs({name:"legend",initialState:Upe,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:pr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:pr()},removeLegendPayload:{reducer(t,e){var n=Lo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:pr()}}}),{setLegendSize:Wz,setLegendSettings:zpe,addLegendPayload:fq,replaceLegendPayload:mq,removeLegendPayload:pq}=hq.actions,Bpe=hq.reducer,Hpe=["contextPayload"];function h3(){return h3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},h3.apply(null,arguments)}function qz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ap(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qz(Object(n),!0).forEach(function(r){$pe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $pe(t,e,n){return(e=Vpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vpe(t){var e=Gpe(t,"string");return typeof e=="symbol"?e:e+""}function Gpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Wpe(t,e){if(t==null)return{};var n,r,i=qpe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function qpe(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 Kpe(t){return t.value}function Xpe(t){var{contextPayload:e}=t,n=Wpe(t,Hpe),r=hW(e,t.payloadUniqBy,Kpe),i=Ap(Ap({},n),{},{payload:r});return M.isValidElement(t.content)?M.cloneElement(t.content,i):typeof t.content=="function"?M.createElement(t.content,i):M.createElement(Hhe,i)}function Ype(t,e,n,r,i,a){var{layout:s,align:o,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&s==="vertical"?u={left:((r||0)-a.width)/2}:u=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))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Ap(Ap({},u),d)}function Zpe(t){var e=ir();return M.useEffect(()=>{e(zpe(t))},[e,t]),null}function Qpe(t){var e=ir();return M.useEffect(()=>(e(Wz(t)),()=>{e(Wz({width:0,height:0}))}),[e,t]),null}function Jpe(t,e,n,r){return t==="vertical"&&Rt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var ege={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function kj(t){var e=Er(t,ege),n=jfe(),r=Dde(),i=Epe(),{width:a,height:s,wrapperStyle:o,portal:c}=e,[u,d]=bW([n]),f=Aj(),g=Tj();if(f==null||g==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=Jpe(e.layout,s,a,p),v=c?o:Ap(Ap({position:"absolute",width:x?.width||a||"auto",height:x?.height||s||"auto"},Ype(o,e,i,f,g,u)),o),y=c??r;if(y==null||n==null)return null;var b=M.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},M.createElement(Zpe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&M.createElement(Qpe,{width:u.width,height:u.height}),M.createElement(Xpe,h3({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return mc.createPortal(b,y)}kj.displayName="Legend";function f3(){return f3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f3.apply(null,arguments)}function Kz(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 BT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Kz(Object(n),!0).forEach(function(r){tge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Kz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tge(t,e,n){return(e=nge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nge(t){var e=rge(t,"string");return typeof e=="symbol"?e:e+""}function rge(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 ige(t){return Array.isArray(t)&&uo(t[0])&&uo(t[1])?t.join(" ~ "):t}var age=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:s,itemSorter:o,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,p=()=>{if(a&&a.length){var T={padding:0,margin:0},C=(o?QS(a,o):a).map((k,F)=>{if(k.type==="none")return null;var N=k.formatter||s||ige,{value:j,name:I}=k,O=j,q=I;if(N){var R=N(j,I,k,F,a);if(Array.isArray(R))[O,q]=R;else if(R!=null)O=R;else return null}var W=BT({display:"block",paddingTop:4,paddingBottom:4,color:k.color||"#000"},r);return M.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(F),style:W},uo(q)?M.createElement("span",{className:"recharts-tooltip-item-name"},q):null,uo(q)?M.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,M.createElement("span",{className:"recharts-tooltip-item-value"},O),M.createElement("span",{className:"recharts-tooltip-item-unit"},k.unit||""))});return M.createElement("ul",{className:"recharts-tooltip-item-list",style:T},C)}return null},x=BT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),v=BT({margin:0},i),y=!fr(d),b=y?d:"",E=En("recharts-default-tooltip",c),w=En("recharts-tooltip-label",u);y&&f&&a!==void 0&&a!==null&&(b=f(d,a));var A=g?{role:"status","aria-live":"assertive"}:{};return M.createElement("div",f3({className:E,style:x},A),M.createElement("p",{className:w,style:v},M.isValidElement(b)?b:"".concat(b)),p())},dx="recharts-tooltip-wrapper",sge={visibility:"hidden"};function oge(t){var{coordinate:e,translateX:n,translateY:r}=t;return En(dx,{["".concat(dx,"-right")]:Rt(n)&&e&&Rt(e.x)&&n>=e.x,["".concat(dx,"-left")]:Rt(n)&&e&&Rt(e.x)&&n<e.x,["".concat(dx,"-bottom")]:Rt(r)&&e&&Rt(e.y)&&r>=e.y,["".concat(dx,"-top")]:Rt(r)&&e&&Rt(e.y)&&r<e.y})}function Xz(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:o,viewBox:c,viewBoxDimension:u}=t;if(a&&Rt(a[r]))return a[r];var d=n[r]-o-(i>0?i:0),f=n[r]+i;if(e[r])return s[r]?d:f;var g=c[r];if(g==null)return 0;if(s[r]){var p=d,x=g;return p<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var v=f+o,y=g+u;return v>y?Math.max(d,g):Math.max(f,g)}function lge(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 cge(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:s,useTranslate3d:o,viewBox:c}=t,u,d,f;return s.height>0&&s.width>0&&n?(d=Xz({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:c,viewBoxDimension:c.width}),f=Xz({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:c,viewBoxDimension:c.height}),u=lge({translateX:d,translateY:f,useTranslate3d:o})):u=sge,{cssProperties:u,cssClasses:oge({translateX:d,translateY:f,coordinate:n})}}function Yz(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 Tv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Yz(Object(n),!0).forEach(function(r){m3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Yz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function m3(t,e,n){return(e=uge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uge(t){var e=dge(t,"string");return typeof e=="symbol"?e:e+""}function dge(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 hge extends M.PureComponent{constructor(){super(...arguments),m3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),m3(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:s,hasPayload:o,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:p,wrapperStyle:x,lastBoundingBox:v,innerRef:y,hasPortalFromProps:b}=this.props,{cssClasses:E,cssProperties:w}=cge({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:g,viewBox:p}),A=b?{}:Tv(Tv({transition:c&&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=Tv(Tv({},A),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},x);return M.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:T,ref:y},a)}}var gq=()=>{var t;return(t=kt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function p3(){return p3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p3.apply(null,arguments)}function Zz(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 Qz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Zz(Object(n),!0).forEach(function(r){fge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Zz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fge(t,e,n){return(e=mge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mge(t){var e=pge(t,"string");return typeof e=="symbol"?e:e+""}function pge(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 Jz={curveBasisClosed:Jde,curveBasisOpen:ehe,curveBasis:Qde,curveBumpX:Fde,curveBumpY:Ude,curveLinearClosed:the,curveLinear:YS,curveMonotoneX:nhe,curveMonotoneY:rhe,curveNatural:ihe,curveStep:ahe,curveStepAfter:ohe,curveStepBefore:she},ew=t=>$n(t.x)&&$n(t.y),e8=t=>t.base!=null&&ew(t.base)&&ew(t),hx=t=>t.x,fx=t=>t.y,gge=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(vb(t));return(n==="curveMonotone"||n==="curveBump")&&e?Jz["".concat(n).concat(e==="vertical"?"Y":"X")]:Jz[n]||YS},xge=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=gge(e,i),o=a?n.filter(ew):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>Qz(Qz({},p),{},{base:r[x]}));i==="vertical"?c=yv().y(fx).x1(hx).x0(p=>p.base.x):c=yv().x(hx).y1(fx).y0(p=>p.base.y);var d=c.defined(e8).curve(s),f=a?u.filter(e8):u;return d(f)}i==="vertical"&&Rt(r)?c=yv().y(fx).x1(hx).x0(r):Rt(r)?c=yv().x(hx).y1(fx).y0(r):c=BG().x(hx).y(fx);var g=c.defined(ew).curve(s);return g(o)},rp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?xge(t):r;return M.createElement("path",p3({},ka(t),fj(t),{className:En("recharts-curve",e),d:a===null?void 0:a,ref:i}))},bge=["x","y","top","left","width","height","className"];function g3(){return g3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},g3.apply(null,arguments)}function t8(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 yge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t8(Object(n),!0).forEach(function(r){vge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vge(t,e,n){return(e=_ge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _ge(t){var e=wge(t,"string");return typeof e=="symbol"?e:e+""}function wge(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 Sge(t,e){if(t==null)return{};var n,r,i=Mge(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Mge(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Ege=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Age=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:o}=t,c=Sge(t,bge),u=yge({x:e,y:n,top:r,left:i,width:a,height:s},c);return!Rt(e)||!Rt(n)||!Rt(a)||!Rt(s)||!Rt(r)||!Rt(i)?null:M.createElement("path",g3({},na(u),{className:En("recharts-cross",o),d:Ege(e,n,a,s,r,i)}))};function Tge(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 n8(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 r8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n8(Object(n),!0).forEach(function(r){Cge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Cge(t,e,n){return(e=Nge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nge(t){var e=kge(t,"string");return typeof e=="symbol"?e:e+""}function kge(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 Pge=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),xq=(t,e,n)=>t.map(r=>"".concat(Pge(r)," ").concat(e,"ms ").concat(n)).join(","),Rge=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),O0=(t,e)=>Object.keys(e).reduce((n,r)=>r8(r8({},n),{},{[r]:t(r,e[r])}),{});function i8(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 ui(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i8(Object(n),!0).forEach(function(r){jge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jge(t,e,n){return(e=Dge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Dge(t){var e=Oge(t,"string");return typeof e=="symbol"?e:e+""}function Oge(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 tw=(t,e,n)=>t+(e-t)*n,x3=t=>{var{from:e,to:n}=t;return e!==n},bq=(t,e,n)=>{var r=O0((i,a)=>{if(x3(a)){var[s,o]=t(a.from,a.to,a.velocity);return ui(ui({},a),{},{from:s,velocity:o})}return a},e);return n<1?O0((i,a)=>x3(a)?ui(ui({},a),{},{velocity:tw(a.velocity,r[i].velocity,n),from:tw(a.from,r[i].from,n)}):a,e):bq(t,r,n-1)};function Lge(t,e,n,r,i,a){var s,o=r.reduce((g,p)=>ui(ui({},g),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>O0((g,p)=>p.from,o),u=()=>!Object.values(o).filter(x3).length,d=null,f=g=>{s||(s=g);var p=g-s,x=p/n.dt;o=bq(n,o,x),i(ui(ui(ui({},t),e),c())),s=g,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function Ige(t,e,n,r,i,a,s){var o=null,c=i.reduce((f,g)=>ui(ui({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,p=O0((v,y)=>tw(...y,n(g)),c);if(a(ui(ui(ui({},t),e),p)),g<1)o=s.setTimeout(d);else{var x=O0((v,y)=>tw(...y,n(1)),c);a(ui(ui(ui({},t),e),x))}};return()=>(o=s.setTimeout(d),()=>{var f;(f=o)===null||f===void 0||f()})}const Fge=(t,e,n,r,i,a)=>{var s=Rge(t,e);return n==null?()=>(i(ui(ui({},t),e)),()=>{}):n.isStepper===!0?Lge(t,e,n,s,i,a):Ige(t,e,n,r,s,i,a)};var nw=1e-4,yq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],vq=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),a8=(t,e)=>n=>{var r=yq(t,e);return vq(r,n)},Uge=(t,e)=>n=>{var r=yq(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return vq(i,n)},zge=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var s=a[1].split(")")[0].split(",").map(o=>parseFloat(o));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},Bge=(t,e,n,r)=>{var i=a8(t,n),a=a8(e,r),s=Uge(t,n),o=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var p=i(f)-d,x=s(f);if(Math.abs(p-d)<nw||x<nw)return a(f);f=o(f-p/x)}return a(f)};return c.isStepper=!1,c},s8=function(){return Bge(...zge(...arguments))},Hge=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(s,o,c)=>{var u=-(s-o)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+s;return Math.abs(g-o)<nw&&Math.abs(f)<nw?[o,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},$ge=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return s8(t);case"spring":return Hge();default:if(t.split("(")[0]==="cubic-bezier")return s8(t)}return typeof t=="function"?t:null};function Vge(t){var e,n=()=>null,r=!1,i=null,a=s=>{if(!r){if(Array.isArray(s)){if(!s.length)return;var o=s,[c,...u]=o;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof s=="string"&&(e=s,n(e)),typeof s=="object"&&(e=s,n(e)),typeof s=="function"&&s()}};return{stop:()=>{r=!0},start:s=>{r=!1,i&&(i(),i=null),a(s)},subscribe:s=>(n=s,()=>{n=()=>null}),getTimeoutController:()=>t}}class Gge{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=s=>{s-r>=n?e(s):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function Wge(){return Vge(new Gge)}var qge=M.createContext(Wge);function Kge(t,e){var n=M.useContext(qge);return M.useMemo(()=>e??n(t),[t,e,n])}var Xge=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Jp={devToolsEnabled:!1,isSsr:Xge()},Yge={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},o8={t:0},HT={t:1};function eg(t){var e=Er(t,Yge),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:o,onAnimationStart:c,children:u}=e,d=n==="auto"?!Jp.isSsr:n,f=Kge(e.animationId,e.animationManager),[g,p]=M.useState(d?o8:HT),x=M.useRef(null);return M.useEffect(()=>{d||p(HT)},[d]),M.useEffect(()=>{if(!d||!r)return _b;var v=Fge(o8,HT,$ge(a),i,p,f.getTimeoutController()),y=()=>{x.current=v()};return f.start([c,s,y,i,o]),()=>{f.stop(),x.current&&x.current(),o()}},[d,r,i,a,s,c,o,f]),u(g.t)}function tg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=M.useRef(C0(e)),r=M.useRef(t);return r.current!==t&&(n.current=C0(e),r.current=t),n.current}var Zge=["radius"],Qge=["radius"];function l8(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 c8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l8(Object(n),!0).forEach(function(r){Jge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jge(t,e,n){return(e=exe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function exe(t){var e=txe(t,"string");return typeof e=="symbol"?e:e+""}function txe(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 rw(){return rw=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},rw.apply(null,arguments)}function u8(t,e){if(t==null)return{};var n,r,i=nxe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nxe(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 d8=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),s=r>=0?1:-1,o=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+s*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+o*d[0],",").concat(e)),u+="L ".concat(t+n-o*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
  17. `).concat(t+n,",").concat(e+s*d[1])),u+="L ".concat(t+n,",").concat(e+r-s*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
  18. `).concat(t+n-o*d[2],",").concat(e+r)),u+="L ".concat(t+o*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
  19. `).concat(t,",").concat(e+r-s*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var p=Math.min(a,i);u="M ".concat(t,",").concat(e+s*p,`
  20. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+o*p,",").concat(e,`
  21. L `).concat(t+n-o*p,",").concat(e,`
  22. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+s*p,`
  23. L `).concat(t+n,",").concat(e+r-s*p,`
  24. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-o*p,",").concat(e+r,`
  25. L `).concat(t+o*p,",").concat(e+r,`
  26. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t,",").concat(e+r-s*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},h8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},_q=t=>{var e=Er(t,h8),n=M.useRef(null),[r,i]=M.useState(-1);M.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:s,width:o,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:v}=e,y=M.useRef(o),b=M.useRef(c),E=M.useRef(a),w=M.useRef(s),A=M.useMemo(()=>({x:a,y:s,width:o,height:c,radius:u}),[a,s,o,c,u]),T=tg(A,"rectangle-");if(a!==+a||s!==+s||o!==+o||c!==+c||o===0||c===0)return null;var C=En("recharts-rectangle",d);if(!v){var k=na(e),{radius:F}=k,N=u8(k,Zge);return M.createElement("path",rw({},N,{radius:typeof u=="number"?u:void 0,className:C,d:d8(a,s,o,c,u)}))}var j=y.current,I=b.current,O=E.current,q=w.current,R="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=xq(["strokeDasharray"],g,typeof f=="string"?f:h8.animationEasing);return M.createElement(eg,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:v,begin:p},G=>{var te=Dn(j,o,G),Y=Dn(I,c,G),J=Dn(O,a,G),U=Dn(q,s,G);n.current&&(y.current=te,b.current=Y,E.current=J,w.current=U);var H;x?G>0?H={transition:K,strokeDasharray:W}:H={strokeDasharray:R}:H={strokeDasharray:W};var ee=na(e),{radius:ie}=ee,pe=u8(ee,Qge);return M.createElement("path",rw({},pe,{radius:typeof u=="number"?u:void 0,className:C,d:d8(J,U,te,Y,u),ref:n,style:c8(c8({},H),e.style)}))})};function f8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function m8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f8(Object(n),!0).forEach(function(r){rxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rxe(t,e,n){return(e=ixe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ixe(t){var e=axe(t,"string");return typeof e=="symbol"?e:e+""}function axe(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 iw=Math.PI/180,sxe=t=>t*180/Math.PI,ti=(t,e,n,r)=>({x:t+Math.cos(-iw*r)*n,y:e+Math.sin(-iw*r)*n}),wq=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},oxe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},lxe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=oxe({x:n,y:r},{x:i,y:a});if(s<=0)return{radius:s,angle:0};var o=(n-i)/s,c=Math.acos(o);return r>a&&(c=2*Math.PI-c),{radius:s,angle:sxe(c),angleInRadian:c}},cxe=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},uxe=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),s=Math.min(i,a);return t+s*360},dxe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=lxe({x:n,y:r},e),{innerRadius:s,outerRadius:o}=e;if(i<s||i>o||i===0)return null;var{startAngle:c,endAngle:u}=cxe(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?m8(m8({},e),{},{radius:i,angle:uxe(d,e)}):null};function Sq(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=ti(e,n,r,i),o=ti(e,n,r,a);return{points:[s,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function b3(){return b3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b3.apply(null,arguments)}var hxe=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Cv=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:s,cornerRadius:o,cornerIsExternal:c}=t,u=o*(s?1:-1)+r,d=Math.asin(o/u)/iw,f=c?i:i+a*d,g=ti(e,n,u,f),p=ti(e,n,r,f),x=c?i-a*d:i,v=ti(e,n,u*Math.cos(d*iw),x);return{center:g,circleTangency:p,lineTangency:v,theta:d}},Mq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,o=hxe(a,s),c=a+o,u=ti(e,n,i,a),d=ti(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
  27. A `).concat(i,",").concat(i,`,0,
  28. `).concat(+(Math.abs(o)>180),",").concat(+(a>c),`,
  29. `).concat(d.x,",").concat(d.y,`
  30. `);if(r>0){var g=ti(e,n,r,a),p=ti(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
  31. A `).concat(r,",").concat(r,`,0,
  32. `).concat(+(Math.abs(o)>180),",").concat(+(a<=c),`,
  33. `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},fxe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:o,startAngle:c,endAngle:u}=t,d=Li(u-c),{circleTangency:f,lineTangency:g,theta:p}=Cv({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:o}),{circleTangency:x,lineTangency:v,theta:y}=Cv({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:o}),b=o?Math.abs(c-u):Math.abs(c-u)-p-y;if(b<0)return s?"M ".concat(g.x,",").concat(g.y,`
  34. a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
  35. a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
  36. `):Mq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var E="M ".concat(g.x,",").concat(g.y,`
  37. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
  38. A`).concat(i,",").concat(i,",0,").concat(+(b>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  39. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
  40. `);if(r>0){var{circleTangency:w,lineTangency:A,theta:T}=Cv({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),{circleTangency:C,lineTangency:k,theta:F}=Cv({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),N=o?Math.abs(c-u):Math.abs(c-u)-T-F;if(N<0&&a===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(k.x,",").concat(k.y,`
  41. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
  42. A`).concat(r,",").concat(r,",0,").concat(+(N>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
  43. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},mxe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Eq=t=>{var e=Er(t,mxe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var g=En("recharts-sector",f),p=a-i,x=ma(s,p,0,!0),v;return x>0&&Math.abs(u-d)<360?v=fxe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,p/2),forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d}):v=Mq({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),M.createElement("path",b3({},na(e),{className:g,d:v}))};function pxe(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(nW(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:o}=e,c=ti(r,i,a,o),u=ti(r,i,s,o);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return Sq(e)}}var $T={},VT={},GT={},p8;function gxe(){return p8||(p8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(GT)),GT}var g8;function xxe(){return g8||(g8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gxe();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})(VT)),VT}var x8;function bxe(){return x8||(x8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gW(),n=xxe();function r(i,a,s){s&&typeof s!="number"&&e.isIterateeCall(i,a,s)&&(a=s=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),s=s===void 0?i<a?1:-1:n.toFinite(s);const o=Math.max(Math.ceil((a-i)/(s||1)),0),c=new Array(o);for(let u=0;u<o;u++)c[u]=i,i+=s;return c}t.range=r})($T)),$T}var WT,b8;function yxe(){return b8||(b8=1,WT=bxe().range),WT}var vxe=yxe();const Aq=mo(vxe);function ed(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function _xe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Pj(t){let e,n,r;t.length!==2?(e=ed,n=(o,c)=>ed(t(o),c),r=(o,c)=>t(o)-c):(e=t===ed||t===_xe?t:wxe,n=t,r=t);function i(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function s(o,c,u=0,d=o.length){const f=i(o,c,u,d-1);return f>u&&r(o[f-1],c)>-r(o[f],c)?f-1:f}return{left:i,center:s,right:a}}function wxe(){return 0}function Tq(t){return t===null?NaN:+t}function*Sxe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const Mxe=Pj(ed),Nb=Mxe.right;Pj(Tq).center;class y8 extends Map{constructor(e,n=Txe){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(v8(this,e))}has(e){return super.has(v8(this,e))}set(e,n){return super.set(Exe(this,e),n)}delete(e){return super.delete(Axe(this,e))}}function v8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Exe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Axe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Txe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Cxe(t=ed){if(t===ed)return Cq;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 Cq(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const Nxe=Math.sqrt(50),kxe=Math.sqrt(10),Pxe=Math.sqrt(2);function aw(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),s=a>=Nxe?10:a>=kxe?5:a>=Pxe?2:1;let o,c,u;return i<0?(u=Math.pow(10,-i)/s,o=Math.round(t*u),c=Math.round(e*u),o/u<t&&++o,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*s,o=Math.round(t/u),c=Math.round(e/u),o*u<t&&++o,c*u>e&&--c),c<o&&.5<=n&&n<2?aw(t,e,n*2):[o,c,u]}function y3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,s]=r?aw(e,t,n):aw(t,e,n);if(!(a>=i))return[];const o=a-i+1,c=new Array(o);if(r)if(s<0)for(let u=0;u<o;++u)c[u]=(a-u)/-s;else for(let u=0;u<o;++u)c[u]=(a-u)*s;else if(s<0)for(let u=0;u<o;++u)c[u]=(i+u)/-s;else for(let u=0;u<o;++u)c[u]=(i+u)*s;return c}function v3(t,e,n){return e=+e,t=+t,n=+n,aw(t,e,n)[2]}function _3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?v3(e,t,n):v3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function _8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function w8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function Nq(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?Cq:Cxe(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+g)),x=Math.min(r,Math.floor(e+(c-u)*f/c+g));Nq(t,e,p,x,i)}const a=t[e];let s=n,o=r;for(mx(t,n,e),i(t[r],a)>0&&mx(t,n,r);s<o;){for(mx(t,s,o),++s,--o;i(t[s],a)<0;)++s;for(;i(t[o],a)>0;)--o}i(t[n],a)===0?mx(t,n,o):(++o,mx(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function mx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function Rxe(t,e,n){if(t=Float64Array.from(Sxe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return w8(t);if(e>=1)return _8(t);var r,i=(r-1)*e,a=Math.floor(i),s=_8(Nq(t,a).subarray(0,a+1)),o=w8(t.subarray(a+1));return s+(o-s)*(i-a)}}function jxe(t,e,n=Tq){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),s=+n(t[a],a,t),o=+n(t[a+1],a+1,t);return s+(o-s)*(i-a)}}function Dxe(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function po(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Wc(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 w3=Symbol("implicit");function Rj(){var t=new y8,e=[],n=[],r=w3;function i(a){let s=t.get(a);if(s===void 0){if(r!==w3)return r;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new y8;for(const s of a)t.has(s)||t.set(s,e.push(s)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return Rj(e,n).unknown(r)},po.apply(i,arguments),i}function jj(){var t=Rj().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,s,o=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,p=i<r,x=p?i:r,v=p?r:i;a=(v-x)/Math.max(1,g-c+u*2),o&&(a=Math.floor(a)),x+=(v-x-a*(g-c))*d,s=a*(1-c),o&&(x=Math.round(x),s=Math.round(s));var y=Dxe(g).map(function(b){return x+a*b});return n(p?y.reverse():y)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(g){return arguments.length?(o=!!g,f()):o},t.padding=function(g){return arguments.length?(c=Math.min(1,u=+g),f()):c},t.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),f()):c},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return jj(e(),[r,i]).round(o).paddingInner(c).paddingOuter(u).align(d)},po.apply(f(),arguments)}function kq(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return kq(e())},t}function Oxe(){return kq(jj.apply(null,arguments).paddingInner(1))}function Dj(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Pq(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function kb(){}var L0=.7,sw=1/L0,ip="\\s*([+-]?\\d+)\\s*",I0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ul="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Lxe=/^#([0-9a-f]{3,8})$/,Ixe=new RegExp(`^rgb\\(${ip},${ip},${ip}\\)$`),Fxe=new RegExp(`^rgb\\(${ul},${ul},${ul}\\)$`),Uxe=new RegExp(`^rgba\\(${ip},${ip},${ip},${I0}\\)$`),zxe=new RegExp(`^rgba\\(${ul},${ul},${ul},${I0}\\)$`),Bxe=new RegExp(`^hsl\\(${I0},${ul},${ul}\\)$`),Hxe=new RegExp(`^hsla\\(${I0},${ul},${ul},${I0}\\)$`),S8={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};Dj(kb,F0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:M8,formatHex:M8,formatHex8:$xe,formatHsl:Vxe,formatRgb:E8,toString:E8});function M8(){return this.rgb().formatHex()}function $xe(){return this.rgb().formatHex8()}function Vxe(){return Rq(this).formatHsl()}function E8(){return this.rgb().formatRgb()}function F0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Lxe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?A8(e):n===3?new Xa(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Nv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Nv(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=Ixe.exec(t))?new Xa(e[1],e[2],e[3],1):(e=Fxe.exec(t))?new Xa(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Uxe.exec(t))?Nv(e[1],e[2],e[3],e[4]):(e=zxe.exec(t))?Nv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Bxe.exec(t))?N8(e[1],e[2]/100,e[3]/100,1):(e=Hxe.exec(t))?N8(e[1],e[2]/100,e[3]/100,e[4]):S8.hasOwnProperty(t)?A8(S8[t]):t==="transparent"?new Xa(NaN,NaN,NaN,0):null}function A8(t){return new Xa(t>>16&255,t>>8&255,t&255,1)}function Nv(t,e,n,r){return r<=0&&(t=e=n=NaN),new Xa(t,e,n,r)}function Gxe(t){return t instanceof kb||(t=F0(t)),t?(t=t.rgb(),new Xa(t.r,t.g,t.b,t.opacity)):new Xa}function S3(t,e,n,r){return arguments.length===1?Gxe(t):new Xa(t,e,n,r??1)}function Xa(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}Dj(Xa,S3,Pq(kb,{brighter(t){return t=t==null?sw:Math.pow(sw,t),new Xa(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?L0:Math.pow(L0,t),new Xa(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Xa(Ph(this.r),Ph(this.g),Ph(this.b),ow(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:T8,formatHex:T8,formatHex8:Wxe,formatRgb:C8,toString:C8}));function T8(){return`#${vh(this.r)}${vh(this.g)}${vh(this.b)}`}function Wxe(){return`#${vh(this.r)}${vh(this.g)}${vh(this.b)}${vh((isNaN(this.opacity)?1:this.opacity)*255)}`}function C8(){const t=ow(this.opacity);return`${t===1?"rgb(":"rgba("}${Ph(this.r)}, ${Ph(this.g)}, ${Ph(this.b)}${t===1?")":`, ${t})`}`}function ow(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ph(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function vh(t){return t=Ph(t),(t<16?"0":"")+t.toString(16)}function N8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ko(t,e,n,r)}function Rq(t){if(t instanceof ko)return new ko(t.h,t.s,t.l,t.opacity);if(t instanceof kb||(t=F0(t)),!t)return new ko;if(t instanceof ko)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),s=NaN,o=a-i,c=(a+i)/2;return o?(e===a?s=(n-r)/o+(n<r)*6:n===a?s=(r-e)/o+2:s=(e-n)/o+4,o/=c<.5?a+i:2-a-i,s*=60):o=c>0&&c<1?0:s,new ko(s,o,c,t.opacity)}function qxe(t,e,n,r){return arguments.length===1?Rq(t):new ko(t,e,n,r??1)}function ko(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}Dj(ko,qxe,Pq(kb,{brighter(t){return t=t==null?sw:Math.pow(sw,t),new ko(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?L0:Math.pow(L0,t),new ko(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 Xa(qT(t>=240?t-240:t+120,i,r),qT(t,i,r),qT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new ko(k8(this.h),kv(this.s),kv(this.l),ow(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=ow(this.opacity);return`${t===1?"hsl(":"hsla("}${k8(this.h)}, ${kv(this.s)*100}%, ${kv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function k8(t){return t=(t||0)%360,t<0?t+360:t}function kv(t){return Math.max(0,Math.min(1,t||0))}function qT(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 Oj=t=>()=>t;function Kxe(t,e){return function(n){return t+n*e}}function Xxe(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 Yxe(t){return(t=+t)==1?jq:function(e,n){return n-e?Xxe(e,n,t):Oj(isNaN(e)?n:e)}}function jq(t,e){var n=e-t;return n?Kxe(t,n):Oj(isNaN(t)?e:t)}const P8=(function t(e){var n=Yxe(e);function r(i,a){var s=n((i=S3(i)).r,(a=S3(a)).r),o=n(i.g,a.g),c=n(i.b,a.b),u=jq(i.opacity,a.opacity);return function(d){return i.r=s(d),i.g=o(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function Zxe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function Qxe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Jxe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)i[s]=ng(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(o){for(s=0;s<r;++s)a[s]=i[s](o);return a}}function e0e(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function lw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function t0e(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=ng(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var M3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,KT=new RegExp(M3.source,"g");function n0e(t){return function(){return t}}function r0e(t){return function(e){return t(e)+""}}function i0e(t,e){var n=M3.lastIndex=KT.lastIndex=0,r,i,a,s=-1,o=[],c=[];for(t=t+"",e=e+"";(r=M3.exec(t))&&(i=KT.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(r=r[0])===(i=i[0])?o[s]?o[s]+=i:o[++s]=i:(o[++s]=null,c.push({i:s,x:lw(r,i)})),n=KT.lastIndex;return n<e.length&&(a=e.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?c[0]?r0e(c[0].x):n0e(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)o[(f=c[d]).i]=f.x(u);return o.join("")})}function ng(t,e){var n=typeof e,r;return e==null||n==="boolean"?Oj(e):(n==="number"?lw:n==="string"?(r=F0(e))?(e=r,P8):i0e:e instanceof F0?P8:e instanceof Date?e0e:Qxe(e)?Zxe:Array.isArray(e)?Jxe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?t0e:lw)(t,e)}function Lj(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function a0e(t,e){e===void 0&&(e=t,t=ng);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(s){var o=Math.max(0,Math.min(r-1,Math.floor(s*=r)));return a[o](s-o)}}function s0e(t){return function(){return t}}function cw(t){return+t}var R8=[0,1];function Aa(t){return t}function E3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:s0e(isNaN(e)?NaN:.5)}function o0e(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function l0e(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=E3(i,r),a=n(s,a)):(r=E3(r,i),a=n(a,s)),function(o){return a(r(o))}}function c0e(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=E3(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(o){var c=Nb(t,o,1,r)-1;return a[c](i[c](o))}}function Pb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function pM(){var t=R8,e=R8,n=ng,r,i,a,s=Aa,o,c,u;function d(){var g=Math.min(t.length,e.length);return s!==Aa&&(s=o0e(t[0],t[g-1])),o=g>2?c0e:l0e,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?a:(c||(c=o(t.map(r),e,n)))(r(s(g)))}return f.invert=function(g){return s(i((u||(u=o(e,t.map(r),lw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,cw),d()):t.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),n=Lj,d()},f.clamp=function(g){return arguments.length?(s=g?!0:Aa,d()):s!==Aa},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(a=g,f):a},function(g,p){return r=g,i=p,d()}}function Ij(){return pM()(Aa,Aa)}function u0e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function uw(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 Tp(t){return t=uw(Math.abs(t)),t?t[1]:NaN}function d0e(t,e){return function(n,r){for(var i=n.length,a=[],s=0,o=t[0],c=0;i>0&&o>0&&(c+o+1>r&&(o=Math.max(1,r-c)),a.push(n.substring(i-=o,i+o)),!((c+=o+1)>r));)o=t[s=(s+1)%t.length];return a.reverse().join(e)}}function h0e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var f0e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function U0(t){if(!(e=f0e.exec(t)))throw new Error("invalid format: "+t);var e;return new Fj({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]})}U0.prototype=Fj.prototype;function Fj(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+""}Fj.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 m0e(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 Dq;function p0e(t,e){var n=uw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(Dq=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+uw(t,Math.max(0,e+a-1))[0]}function j8(t,e){var n=uw(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 D8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:u0e,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)=>j8(t*100,e),r:j8,s:p0e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function O8(t){return t}var L8=Array.prototype.map,I8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function g0e(t){var e=t.grouping===void 0||t.thousands===void 0?O8:d0e(L8.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?O8:h0e(L8.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=U0(f);var g=f.fill,p=f.align,x=f.sign,v=f.symbol,y=f.zero,b=f.width,E=f.comma,w=f.precision,A=f.trim,T=f.type;T==="n"?(E=!0,T="g"):D8[T]||(w===void 0&&(w=12),A=!0,T="g"),(y||g==="0"&&p==="=")&&(y=!0,g="0",p="=");var C=v==="$"?n:v==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",k=v==="$"?r:/[%p]/.test(T)?s:"",F=D8[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 j(I){var O=C,q=k,R,W,K;if(T==="c")q=F(I)+q,I="";else{I=+I;var G=I<0||1/I<0;if(I=isNaN(I)?c:F(Math.abs(I),w),A&&(I=m0e(I)),G&&+I==0&&x!=="+"&&(G=!1),O=(G?x==="("?x:o:x==="-"||x==="("?"":x)+O,q=(T==="s"?I8[8+Dq/3]:"")+q+(G&&x==="("?")":""),N){for(R=-1,W=I.length;++R<W;)if(K=I.charCodeAt(R),48>K||K>57){q=(K===46?i+I.slice(R+1):I.slice(R))+q,I=I.slice(0,R);break}}}E&&!y&&(I=e(I,1/0));var te=O.length+I.length+q.length,Y=te<b?new Array(b-te+1).join(g):"";switch(E&&y&&(I=e(Y+I,Y.length?b-q.length:1/0),Y=""),p){case"<":I=O+I+q+Y;break;case"=":I=O+Y+I+q;break;case"^":I=Y.slice(0,te=Y.length>>1)+O+I+q+Y.slice(te);break;default:I=Y+O+I+q;break}return a(I)}return j.toString=function(){return f+""},j}function d(f,g){var p=u((f=U0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Tp(g)/3)))*3,v=Math.pow(10,-x),y=I8[8+x/3];return function(b){return p(v*b)+y}}return{format:u,formatPrefix:d}}var Pv,Uj,Oq;x0e({thousands:",",grouping:[3],currency:["$",""]});function x0e(t){return Pv=g0e(t),Uj=Pv.format,Oq=Pv.formatPrefix,Pv}function b0e(t){return Math.max(0,-Tp(Math.abs(t)))}function y0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Tp(e)/3)))*3-Tp(Math.abs(t)))}function v0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Tp(e)-Tp(t))+1}function Lq(t,e,n,r){var i=_3(t,e,n),a;switch(r=U0(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=y0e(i,s))&&(r.precision=a),Oq(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=v0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=b0e(i))&&(r.precision=a-(r.type==="%")*2);break}}return Uj(r)}function Td(t){var e=t.domain;return t.ticks=function(n){var r=e();return y3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return Lq(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,s=r[i],o=r[a],c,u,d=10;for(o<s&&(u=s,s=o,o=u,u=i,i=a,a=u);d-- >0;){if(u=v3(s,o,n),u===c)return r[i]=s,r[a]=o,e(r);if(u>0)s=Math.floor(s/u)*u,o=Math.ceil(o/u)*u;else if(u<0)s=Math.ceil(s*u)/u,o=Math.floor(o*u)/u;else break;c=u}return t},t}function Iq(){var t=Ij();return t.copy=function(){return Pb(t,Iq())},po.apply(t,arguments),Td(t)}function Fq(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,cw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return Fq(t).unknown(e)},t=arguments.length?Array.from(t,cw):[0,1],Td(n)}function Uq(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],s;return a<i&&(s=n,n=r,r=s,s=i,i=a,a=s),t[n]=e.floor(i),t[r]=e.ceil(a),t}function F8(t){return Math.log(t)}function U8(t){return Math.exp(t)}function _0e(t){return-Math.log(-t)}function w0e(t){return-Math.exp(-t)}function S0e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function M0e(t){return t===10?S0e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function E0e(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 z8(t){return(e,n)=>-t(-e,n)}function zj(t){const e=t(F8,U8),n=e.domain;let r=10,i,a;function s(){return i=E0e(r),a=M0e(r),n()[0]<0?(i=z8(i),a=z8(a),t(_0e,w0e)):t(F8,U8),e}return e.base=function(o){return arguments.length?(r=+o,s()):r},e.domain=function(o){return arguments.length?(n(o),s()):n()},e.ticks=o=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),p=i(d),x,v;const y=o==null?10:+o;let b=[];if(!(r%1)&&p-g<y){if(g=Math.floor(g),p=Math.ceil(p),u>0){for(;g<=p;++g)for(x=1;x<r;++x)if(v=g<0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}}else for(;g<=p;++g)for(x=r-1;x>=1;--x)if(v=g>0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}b.length*2<y&&(b=y3(u,d,y))}else b=y3(g,p,Math.min(p-g,y)).map(a);return f?b.reverse():b},e.tickFormat=(o,c)=>{if(o==null&&(o=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=U0(c)).precision==null&&(c.trim=!0),c=Uj(c)),o===1/0)return c;const u=Math.max(1,r*o/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(Uq(n(),{floor:o=>a(Math.floor(i(o))),ceil:o=>a(Math.ceil(i(o)))})),e}function zq(){const t=zj(pM()).domain([1,10]);return t.copy=()=>Pb(t,zq()).base(t.base()),po.apply(t,arguments),t}function B8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function H8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function Bj(t){var e=1,n=t(B8(e),H8(e));return n.constant=function(r){return arguments.length?t(B8(e=+r),H8(e)):e},Td(n)}function Bq(){var t=Bj(pM());return t.copy=function(){return Pb(t,Bq()).constant(t.constant())},po.apply(t,arguments)}function $8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function A0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function T0e(t){return t<0?-t*t:t*t}function Hj(t){var e=t(Aa,Aa),n=1;function r(){return n===1?t(Aa,Aa):n===.5?t(A0e,T0e):t($8(n),$8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Td(e)}function $j(){var t=Hj(pM());return t.copy=function(){return Pb(t,$j()).exponent(t.exponent())},po.apply(t,arguments),t}function C0e(){return $j.apply(null,arguments).exponent(.5)}function V8(t){return Math.sign(t)*t*t}function N0e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Hq(){var t=Ij(),e=[0,1],n=!1,r;function i(a){var s=N0e(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(V8(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,cw)).map(V8)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return Hq(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},po.apply(i,arguments),Td(i)}function $q(){var t=[],e=[],n=[],r;function i(){var s=0,o=Math.max(1,e.length);for(n=new Array(o-1);++s<o;)n[s-1]=jxe(t,s/o);return a}function a(s){return s==null||isNaN(s=+s)?r:e[Nb(n,s)]}return a.invertExtent=function(s){var o=e.indexOf(s);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let o of s)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(ed),i()},a.range=function(s){return arguments.length?(e=Array.from(s),i()):e.slice()},a.unknown=function(s){return arguments.length?(r=s,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return $q().domain(t).range(e).unknown(r)},po.apply(a,arguments)}function Vq(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function s(c){return c!=null&&c<=c?i[Nb(r,c,0,n)]:a}function o(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return s}return s.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,o()):[t,e]},s.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,o()):i.slice()},s.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},s.unknown=function(c){return arguments.length&&(a=c),s},s.thresholds=function(){return r.slice()},s.copy=function(){return Vq().domain([t,e]).range(i).unknown(a)},po.apply(Td(s),arguments)}function Gq(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Nb(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var s=e.indexOf(a);return[t[s-1],t[s]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return Gq().domain(t).range(e).unknown(n)},po.apply(i,arguments)}const XT=new Date,YT=new Date;function vi(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const s=i(a),o=i.ceil(a);return a-s<o-a?s:o},i.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,o)=>{const c=[];if(a=i.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return c;let u;do c.push(u=new Date(+a)),e(a,o),t(a);while(u<a&&a<s);return c},i.filter=a=>vi(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!a(s););else for(;--o>=0;)for(;e(s,1),!a(s););}),n&&(i.count=(a,s)=>(XT.setTime(+a),YT.setTime(+s),t(XT),t(YT),Math.floor(n(XT,YT))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?s=>r(s)%a===0:s=>i.count(0,s)%a===0):i)),i}const dw=vi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);dw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?vi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):dw);dw.range;const pc=1e3,ro=pc*60,gc=ro*60,Oc=gc*24,Vj=Oc*7,G8=Oc*30,ZT=Oc*365,_h=vi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*pc)},(t,e)=>(e-t)/pc,t=>t.getUTCSeconds());_h.range;const Gj=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*pc)},(t,e)=>{t.setTime(+t+e*ro)},(t,e)=>(e-t)/ro,t=>t.getMinutes());Gj.range;const Wj=vi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*ro)},(t,e)=>(e-t)/ro,t=>t.getUTCMinutes());Wj.range;const qj=vi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*pc-t.getMinutes()*ro)},(t,e)=>{t.setTime(+t+e*gc)},(t,e)=>(e-t)/gc,t=>t.getHours());qj.range;const Kj=vi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*gc)},(t,e)=>(e-t)/gc,t=>t.getUTCHours());Kj.range;const Rb=vi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ro)/Oc,t=>t.getDate()-1);Rb.range;const gM=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Oc,t=>t.getUTCDate()-1);gM.range;const Wq=vi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Oc,t=>Math.floor(t/Oc));Wq.range;function pf(t){return vi(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())*ro)/Vj)}const xM=pf(0),hw=pf(1),k0e=pf(2),P0e=pf(3),Cp=pf(4),R0e=pf(5),j0e=pf(6);xM.range;hw.range;k0e.range;P0e.range;Cp.range;R0e.range;j0e.range;function gf(t){return vi(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)/Vj)}const bM=gf(0),fw=gf(1),D0e=gf(2),O0e=gf(3),Np=gf(4),L0e=gf(5),I0e=gf(6);bM.range;fw.range;D0e.range;O0e.range;Np.range;L0e.range;I0e.range;const Xj=vi(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());Xj.range;const Yj=vi(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());Yj.range;const Lc=vi(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());Lc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vi(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)});Lc.range;const Ic=vi(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());Ic.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:vi(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)});Ic.range;function qq(t,e,n,r,i,a){const s=[[_h,1,pc],[_h,5,5*pc],[_h,15,15*pc],[_h,30,30*pc],[a,1,ro],[a,5,5*ro],[a,15,15*ro],[a,30,30*ro],[i,1,gc],[i,3,3*gc],[i,6,6*gc],[i,12,12*gc],[r,1,Oc],[r,2,2*Oc],[n,1,Vj],[e,1,G8],[e,3,3*G8],[t,1,ZT]];function o(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return g?x.reverse():x}function c(u,d,f){const g=Math.abs(d-u)/f,p=Pj(([,,y])=>y).right(s,g);if(p===s.length)return t.every(_3(u/ZT,d/ZT,f));if(p===0)return dw.every(Math.max(_3(u,d,f),1));const[x,v]=s[g/s[p-1][2]<s[p][2]/g?p-1:p];return x.every(v)}return[o,c]}const[F0e,U0e]=qq(Ic,Yj,bM,Wq,Kj,Wj),[z0e,B0e]=qq(Lc,Xj,xM,Rb,qj,Gj);function QT(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 JT(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 px(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function H0e(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,s=t.shortDays,o=t.months,c=t.shortMonths,u=gx(i),d=xx(i),f=gx(a),g=xx(a),p=gx(s),x=xx(s),v=gx(o),y=xx(o),b=gx(c),E=xx(c),w={a:G,A:te,b:Y,B:J,c:null,d:Z8,e:Z8,f:dbe,g:_be,G:Sbe,H:lbe,I:cbe,j:ube,L:Kq,m:hbe,M:fbe,p:U,q:H,Q:eB,s:tB,S:mbe,u:pbe,U:gbe,V:xbe,w:bbe,W:ybe,x:null,X:null,y:vbe,Y:wbe,Z:Mbe,"%":J8},A={a:ee,A:ie,b:pe,B:ue,c:null,d:Q8,e:Q8,f:Cbe,g:Fbe,G:zbe,H:Ebe,I:Abe,j:Tbe,L:Yq,m:Nbe,M:kbe,p:be,q:Re,Q:eB,s:tB,S:Pbe,u:Rbe,U:jbe,V:Dbe,w:Obe,W:Lbe,x:null,X:null,y:Ibe,Y:Ube,Z:Bbe,"%":J8},T={a:j,A:I,b:O,B:q,c:R,d:X8,e:X8,f:ibe,g:K8,G:q8,H:Y8,I:Y8,j:ebe,L:rbe,m:J0e,M:tbe,p:N,q:Q0e,Q:sbe,s:obe,S:nbe,u:q0e,U:K0e,V:X0e,w:W0e,W:Y0e,x:W,X:K,y:K8,Y:q8,Z:Z0e,"%":abe};w.x=C(n,w),w.X=C(r,w),w.c=C(e,w),A.x=C(n,A),A.X=C(r,A),A.c=C(e,A);function C(Z,_e){return function(Le){var ce=[],Ie=-1,z=0,B=Z.length,ne,V,Q;for(Le instanceof Date||(Le=new Date(+Le));++Ie<B;)Z.charCodeAt(Ie)===37&&(ce.push(Z.slice(z,Ie)),(V=W8[ne=Z.charAt(++Ie)])!=null?ne=Z.charAt(++Ie):V=ne==="e"?" ":"0",(Q=_e[ne])&&(ne=Q(Le,V)),ce.push(ne),z=Ie+1);return ce.push(Z.slice(z,Ie)),ce.join("")}}function k(Z,_e){return function(Le){var ce=px(1900,void 0,1),Ie=F(ce,Z,Le+="",0),z,B;if(Ie!=Le.length)return null;if("Q"in ce)return new Date(ce.Q);if("s"in ce)return new Date(ce.s*1e3+("L"in ce?ce.L:0));if(_e&&!("Z"in ce)&&(ce.Z=0),"p"in ce&&(ce.H=ce.H%12+ce.p*12),ce.m===void 0&&(ce.m="q"in ce?ce.q:0),"V"in ce){if(ce.V<1||ce.V>53)return null;"w"in ce||(ce.w=1),"Z"in ce?(z=JT(px(ce.y,0,1)),B=z.getUTCDay(),z=B>4||B===0?fw.ceil(z):fw(z),z=gM.offset(z,(ce.V-1)*7),ce.y=z.getUTCFullYear(),ce.m=z.getUTCMonth(),ce.d=z.getUTCDate()+(ce.w+6)%7):(z=QT(px(ce.y,0,1)),B=z.getDay(),z=B>4||B===0?hw.ceil(z):hw(z),z=Rb.offset(z,(ce.V-1)*7),ce.y=z.getFullYear(),ce.m=z.getMonth(),ce.d=z.getDate()+(ce.w+6)%7)}else("W"in ce||"U"in ce)&&("w"in ce||(ce.w="u"in ce?ce.u%7:"W"in ce?1:0),B="Z"in ce?JT(px(ce.y,0,1)).getUTCDay():QT(px(ce.y,0,1)).getDay(),ce.m=0,ce.d="W"in ce?(ce.w+6)%7+ce.W*7-(B+5)%7:ce.w+ce.U*7-(B+6)%7);return"Z"in ce?(ce.H+=ce.Z/100|0,ce.M+=ce.Z%100,JT(ce)):QT(ce)}}function F(Z,_e,Le,ce){for(var Ie=0,z=_e.length,B=Le.length,ne,V;Ie<z;){if(ce>=B)return-1;if(ne=_e.charCodeAt(Ie++),ne===37){if(ne=_e.charAt(Ie++),V=T[ne in W8?_e.charAt(Ie++):ne],!V||(ce=V(Z,Le,ce))<0)return-1}else if(ne!=Le.charCodeAt(ce++))return-1}return ce}function N(Z,_e,Le){var ce=u.exec(_e.slice(Le));return ce?(Z.p=d.get(ce[0].toLowerCase()),Le+ce[0].length):-1}function j(Z,_e,Le){var ce=p.exec(_e.slice(Le));return ce?(Z.w=x.get(ce[0].toLowerCase()),Le+ce[0].length):-1}function I(Z,_e,Le){var ce=f.exec(_e.slice(Le));return ce?(Z.w=g.get(ce[0].toLowerCase()),Le+ce[0].length):-1}function O(Z,_e,Le){var ce=b.exec(_e.slice(Le));return ce?(Z.m=E.get(ce[0].toLowerCase()),Le+ce[0].length):-1}function q(Z,_e,Le){var ce=v.exec(_e.slice(Le));return ce?(Z.m=y.get(ce[0].toLowerCase()),Le+ce[0].length):-1}function R(Z,_e,Le){return F(Z,e,_e,Le)}function W(Z,_e,Le){return F(Z,n,_e,Le)}function K(Z,_e,Le){return F(Z,r,_e,Le)}function G(Z){return s[Z.getDay()]}function te(Z){return a[Z.getDay()]}function Y(Z){return c[Z.getMonth()]}function J(Z){return o[Z.getMonth()]}function U(Z){return i[+(Z.getHours()>=12)]}function H(Z){return 1+~~(Z.getMonth()/3)}function ee(Z){return s[Z.getUTCDay()]}function ie(Z){return a[Z.getUTCDay()]}function pe(Z){return c[Z.getUTCMonth()]}function ue(Z){return o[Z.getUTCMonth()]}function be(Z){return i[+(Z.getUTCHours()>=12)]}function Re(Z){return 1+~~(Z.getUTCMonth()/3)}return{format:function(Z){var _e=C(Z+="",w);return _e.toString=function(){return Z},_e},parse:function(Z){var _e=k(Z+="",!1);return _e.toString=function(){return Z},_e},utcFormat:function(Z){var _e=C(Z+="",A);return _e.toString=function(){return Z},_e},utcParse:function(Z){var _e=k(Z+="",!0);return _e.toString=function(){return Z},_e}}}var W8={"-":"",_:" ",0:"0"},Ui=/^\s*\d+/,$0e=/^%/,V0e=/[\\^$*+?|[\]().{}]/g;function kn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function G0e(t){return t.replace(V0e,"\\$&")}function gx(t){return new RegExp("^(?:"+t.map(G0e).join("|")+")","i")}function xx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function W0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function q0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function K0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function X0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Y0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function q8(t,e,n){var r=Ui.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function K8(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Z0e(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 Q0e(t,e,n){var r=Ui.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function J0e(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function X8(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function ebe(t,e,n){var r=Ui.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function Y8(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function tbe(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function nbe(t,e,n){var r=Ui.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function rbe(t,e,n){var r=Ui.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function ibe(t,e,n){var r=Ui.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function abe(t,e,n){var r=$0e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function sbe(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function obe(t,e,n){var r=Ui.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function Z8(t,e){return kn(t.getDate(),e,2)}function lbe(t,e){return kn(t.getHours(),e,2)}function cbe(t,e){return kn(t.getHours()%12||12,e,2)}function ube(t,e){return kn(1+Rb.count(Lc(t),t),e,3)}function Kq(t,e){return kn(t.getMilliseconds(),e,3)}function dbe(t,e){return Kq(t,e)+"000"}function hbe(t,e){return kn(t.getMonth()+1,e,2)}function fbe(t,e){return kn(t.getMinutes(),e,2)}function mbe(t,e){return kn(t.getSeconds(),e,2)}function pbe(t){var e=t.getDay();return e===0?7:e}function gbe(t,e){return kn(xM.count(Lc(t)-1,t),e,2)}function Xq(t){var e=t.getDay();return e>=4||e===0?Cp(t):Cp.ceil(t)}function xbe(t,e){return t=Xq(t),kn(Cp.count(Lc(t),t)+(Lc(t).getDay()===4),e,2)}function bbe(t){return t.getDay()}function ybe(t,e){return kn(hw.count(Lc(t)-1,t),e,2)}function vbe(t,e){return kn(t.getFullYear()%100,e,2)}function _be(t,e){return t=Xq(t),kn(t.getFullYear()%100,e,2)}function wbe(t,e){return kn(t.getFullYear()%1e4,e,4)}function Sbe(t,e){var n=t.getDay();return t=n>=4||n===0?Cp(t):Cp.ceil(t),kn(t.getFullYear()%1e4,e,4)}function Mbe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+kn(e/60|0,"0",2)+kn(e%60,"0",2)}function Q8(t,e){return kn(t.getUTCDate(),e,2)}function Ebe(t,e){return kn(t.getUTCHours(),e,2)}function Abe(t,e){return kn(t.getUTCHours()%12||12,e,2)}function Tbe(t,e){return kn(1+gM.count(Ic(t),t),e,3)}function Yq(t,e){return kn(t.getUTCMilliseconds(),e,3)}function Cbe(t,e){return Yq(t,e)+"000"}function Nbe(t,e){return kn(t.getUTCMonth()+1,e,2)}function kbe(t,e){return kn(t.getUTCMinutes(),e,2)}function Pbe(t,e){return kn(t.getUTCSeconds(),e,2)}function Rbe(t){var e=t.getUTCDay();return e===0?7:e}function jbe(t,e){return kn(bM.count(Ic(t)-1,t),e,2)}function Zq(t){var e=t.getUTCDay();return e>=4||e===0?Np(t):Np.ceil(t)}function Dbe(t,e){return t=Zq(t),kn(Np.count(Ic(t),t)+(Ic(t).getUTCDay()===4),e,2)}function Obe(t){return t.getUTCDay()}function Lbe(t,e){return kn(fw.count(Ic(t)-1,t),e,2)}function Ibe(t,e){return kn(t.getUTCFullYear()%100,e,2)}function Fbe(t,e){return t=Zq(t),kn(t.getUTCFullYear()%100,e,2)}function Ube(t,e){return kn(t.getUTCFullYear()%1e4,e,4)}function zbe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Np(t):Np.ceil(t),kn(t.getUTCFullYear()%1e4,e,4)}function Bbe(){return"+0000"}function J8(){return"%"}function eB(t){return+t}function tB(t){return Math.floor(+t/1e3)}var em,Qq,Jq;Hbe({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 Hbe(t){return em=H0e(t),Qq=em.format,em.parse,Jq=em.utcFormat,em.utcParse,em}function $be(t){return new Date(t)}function Vbe(t){return t instanceof Date?+t:+new Date(+t)}function Zj(t,e,n,r,i,a,s,o,c,u){var d=Ij(),f=d.invert,g=d.domain,p=u(".%L"),x=u(":%S"),v=u("%I:%M"),y=u("%I %p"),b=u("%a %d"),E=u("%b %d"),w=u("%B"),A=u("%Y");function T(C){return(c(C)<C?p:o(C)<C?x:s(C)<C?v:a(C)<C?y:r(C)<C?i(C)<C?b:E:n(C)<C?w:A)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?g(Array.from(C,Vbe)):g().map($be)},d.ticks=function(C){var k=g();return t(k[0],k[k.length-1],C??10)},d.tickFormat=function(C,k){return k==null?T:u(k)},d.nice=function(C){var k=g();return(!C||typeof C.range!="function")&&(C=e(k[0],k[k.length-1],C??10)),C?g(Uq(k,C)):d},d.copy=function(){return Pb(d,Zj(t,e,n,r,i,a,s,o,c,u))},d}function Gbe(){return po.apply(Zj(z0e,B0e,Lc,Xj,xM,Rb,qj,Gj,_h,Qq).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Wbe(){return po.apply(Zj(F0e,U0e,Ic,Yj,bM,gM,Kj,Wj,_h,Jq).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function yM(){var t=0,e=1,n,r,i,a,s=Aa,o=!1,c;function u(f){return f==null||isNaN(f=+f)?c:s(i===0?.5:(f=(a(f)-n)*i,o?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(o=!!f,u):o},u.interpolator=function(f){return arguments.length?(s=f,u):s};function d(f){return function(g){var p,x;return arguments.length?([p,x]=g,s=f(p,x),u):[s(0),s(1)]}}return u.range=d(ng),u.rangeRound=d(Lj),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function Cd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function eK(){var t=Td(yM()(Aa));return t.copy=function(){return Cd(t,eK())},Wc.apply(t,arguments)}function tK(){var t=zj(yM()).domain([1,10]);return t.copy=function(){return Cd(t,tK()).base(t.base())},Wc.apply(t,arguments)}function nK(){var t=Bj(yM());return t.copy=function(){return Cd(t,nK()).constant(t.constant())},Wc.apply(t,arguments)}function Qj(){var t=Hj(yM());return t.copy=function(){return Cd(t,Qj()).exponent(t.exponent())},Wc.apply(t,arguments)}function qbe(){return Qj.apply(null,arguments).exponent(.5)}function rK(){var t=[],e=Aa;function n(r){if(r!=null&&!isNaN(r=+r))return e((Nb(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(ed),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>Rxe(t,a/r))},n.copy=function(){return rK(e).domain(t)},Wc.apply(n,arguments)}function vM(){var t=0,e=.5,n=1,r=1,i,a,s,o,c,u=Aa,d,f=!1,g;function p(v){return isNaN(v=+v)?g:(v=.5+((v=+d(v))-a)*(r*v<r*a?o:c),u(f?Math.max(0,Math.min(1,v)):v))}p.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),a=d(e=+e),s=d(n=+n),o=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,p):[t,e,n]},p.clamp=function(v){return arguments.length?(f=!!v,p):f},p.interpolator=function(v){return arguments.length?(u=v,p):u};function x(v){return function(y){var b,E,w;return arguments.length?([b,E,w]=y,u=a0e(v,[b,E,w]),p):[u(0),u(.5),u(1)]}}return p.range=x(ng),p.rangeRound=x(Lj),p.unknown=function(v){return arguments.length?(g=v,p):g},function(v){return d=v,i=v(t),a=v(e),s=v(n),o=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,p}}function iK(){var t=Td(vM()(Aa));return t.copy=function(){return Cd(t,iK())},Wc.apply(t,arguments)}function aK(){var t=zj(vM()).domain([.1,1,10]);return t.copy=function(){return Cd(t,aK()).base(t.base())},Wc.apply(t,arguments)}function sK(){var t=Bj(vM());return t.copy=function(){return Cd(t,sK()).constant(t.constant())},Wc.apply(t,arguments)}function Jj(){var t=Hj(vM());return t.copy=function(){return Cd(t,Jj()).exponent(t.exponent())},Wc.apply(t,arguments)}function Kbe(){return Jj.apply(null,arguments).exponent(.5)}const Fx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:jj,scaleDiverging:iK,scaleDivergingLog:aK,scaleDivergingPow:Jj,scaleDivergingSqrt:Kbe,scaleDivergingSymlog:sK,scaleIdentity:Fq,scaleImplicit:w3,scaleLinear:Iq,scaleLog:zq,scaleOrdinal:Rj,scalePoint:Oxe,scalePow:$j,scaleQuantile:$q,scaleQuantize:Vq,scaleRadial:Hq,scaleSequential:eK,scaleSequentialLog:tK,scaleSequentialPow:Qj,scaleSequentialQuantile:rK,scaleSequentialSqrt:qbe,scaleSequentialSymlog:nK,scaleSqrt:C0e,scaleSymlog:Bq,scaleThreshold:Gq,scaleTime:Gbe,scaleUtc:Wbe,tickFormat:Lq},Symbol.toStringTag,{value:"Module"}));var Nd=t=>t.chartData,eD=Ke([Nd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),jb=(t,e,n,r)=>r?eD(t):Nd(t);function md(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if($n(e)&&$n(n))return!0}return!1}function nB(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function oK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if($n(n))i=n;else if(typeof n=="function")return;if($n(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(md(s))return s}}function Xbe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(md(r))return nB(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,s,o;if(i==="auto")e!=null&&(s=Math.min(...e));else if(Rt(i))s=i;else if(typeof i=="function")try{e!=null&&(s=i(e?.[0]))}catch{}else if(typeof i=="string"&&kz.test(i)){var c=kz.exec(i);if(c==null||e==null)s=void 0;else{var u=+c[1];s=e[0]-u}}else s=e?.[0];if(a==="auto")e!=null&&(o=Math.max(...e));else if(Rt(a))o=a;else if(typeof a=="function")try{e!=null&&(o=a(e?.[1]))}catch{}else if(typeof a=="string"&&Pz.test(a)){var d=Pz.exec(a);if(d==null||e==null)o=void 0;else{var f=+d[1];o=e[1]+f}}else o=e?.[1];var g=[s,o];if(md(g))return e==null?g:nB(g,e,n)}}}var rg=1e9,Ybe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},nD,xr=!0,fo="[DecimalError] ",Rh=fo+"Invalid argument: ",tD=fo+"Exponent out of range: ",ig=Math.floor,dh=Math.pow,Zbe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,vs,ji=1e7,hr=7,lK=9007199254740991,mw=ig(lK/hr),jt={};jt.absoluteValue=jt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};jt.comparedTo=jt.cmp=function(t){var e,n,r,i,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};jt.decimalPlaces=jt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*hr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};jt.dividedBy=jt.div=function(t){return Sc(this,new this.constructor(t))};jt.dividedToIntegerBy=jt.idiv=function(t){var e=this,n=e.constructor;return rr(Sc(e,new n(t),0,1),n.precision)};jt.equals=jt.eq=function(t){return!this.cmp(t)};jt.exponent=function(){return ri(this)};jt.greaterThan=jt.gt=function(t){return this.cmp(t)>0};jt.greaterThanOrEqualTo=jt.gte=function(t){return this.cmp(t)>=0};jt.isInteger=jt.isint=function(){return this.e>this.d.length-2};jt.isNegative=jt.isneg=function(){return this.s<0};jt.isPositive=jt.ispos=function(){return this.s>0};jt.isZero=function(){return this.s===0};jt.lessThan=jt.lt=function(t){return this.cmp(t)<0};jt.lessThanOrEqualTo=jt.lte=function(t){return this.cmp(t)<1};jt.logarithm=jt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(vs))throw Error(fo+"NaN");if(n.s<1)throw Error(fo+(n.s?"NaN":"-Infinity"));return n.eq(vs)?new r(0):(xr=!1,e=Sc(z0(n,a),z0(t,a),a),xr=!0,rr(e,i))};jt.minus=jt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?dK(e,t):cK(e,(t.s=-t.s,t))};jt.modulo=jt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(fo+"NaN");return n.s?(xr=!1,e=Sc(n,t,0,1).times(t),xr=!0,n.minus(e)):rr(new r(n),i)};jt.naturalExponential=jt.exp=function(){return uK(this)};jt.naturalLogarithm=jt.ln=function(){return z0(this)};jt.negated=jt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};jt.plus=jt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?cK(e,t):dK(e,(t.s=-t.s,t))};jt.precision=jt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Rh+t);if(e=ri(i)+1,r=i.d.length-1,n=r*hr+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};jt.squareRoot=jt.sqrt=function(){var t,e,n,r,i,a,s,o=this,c=o.constructor;if(o.s<1){if(!o.s)return new c(0);throw Error(fo+"NaN")}for(t=ri(o),xr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=sl(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=ig((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=s=n+3;;)if(a=r,r=a.plus(Sc(o,a,s+2)).times(.5),sl(a.d).slice(0,s)===(e=sl(r.d)).slice(0,s)){if(e=e.slice(s-3,s+1),i==s&&e=="4999"){if(rr(a,n+1,0),a.times(a).eq(o)){r=a;break}}else if(e!="9999")break;s+=4}return xr=!0,rr(r,n)};jt.times=jt.mul=function(t){var e,n,r,i,a,s,o,c,u,d=this,f=d.constructor,g=d.d,p=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=g.length,u=p.length,c<u&&(a=g,g=p,p=a,s=c,c=u,u=s),a=[],s=c+u,r=s;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)o=a[i]+p[r]*g[i-r-1]+e,a[i--]=o%ji|0,e=o/ji|0;a[i]=(a[i]+e)%ji|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,xr?rr(t,f.precision):t};jt.toDecimalPlaces=jt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(ml(t,0,rg),e===void 0?e=r.rounding:ml(e,0,8),rr(n,t+ri(n)+1,e))};jt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Jh(r,!0):(ml(t,0,rg),e===void 0?e=i.rounding:ml(e,0,8),r=rr(new i(r),t+1,e),n=Jh(r,!0,t+1)),n};jt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Jh(i):(ml(t,0,rg),e===void 0?e=a.rounding:ml(e,0,8),r=rr(new a(i),t+ri(i)+1,e),n=Jh(r.abs(),!1,t+ri(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};jt.toInteger=jt.toint=function(){var t=this,e=t.constructor;return rr(new e(t),ri(t)+1,e.rounding)};jt.toNumber=function(){return+this};jt.toPower=jt.pow=function(t){var e,n,r,i,a,s,o=this,c=o.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(vs);if(o=new c(o),!o.s){if(t.s<1)throw Error(fo+"Infinity");return o}if(o.eq(vs))return o;if(r=c.precision,t.eq(vs))return rr(o,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=o.s,s){if((n=d<0?-d:d)<=lK){for(i=new c(vs),e=Math.ceil(r/hr+4),xr=!1;n%2&&(i=i.times(o),iB(i.d,e)),n=ig(n/2),n!==0;)o=o.times(o),iB(o.d,e);return xr=!0,t.s<0?new c(vs).div(i):rr(i,r)}}else if(a<0)throw Error(fo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,xr=!1,i=t.times(z0(o,r+u)),xr=!0,i=uK(i),i.s=a,i};jt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=ri(i),r=Jh(i,n<=a.toExpNeg||n>=a.toExpPos)):(ml(t,1,rg),e===void 0?e=a.rounding:ml(e,0,8),i=rr(new a(i),t,e),n=ri(i),r=Jh(i,t<=n||n<=a.toExpNeg,t)),r};jt.toSignificantDigits=jt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(ml(t,1,rg),e===void 0?e=r.rounding:ml(e,0,8)),rr(new r(n),t,e)};jt.toString=jt.valueOf=jt.val=jt.toJSON=jt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=ri(t),n=t.constructor;return Jh(t,e<=n.toExpNeg||e>=n.toExpPos)};function cK(t,e){var n,r,i,a,s,o,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),xr?rr(e,f):e;if(c=t.d,u=e.d,s=t.e,i=e.e,c=c.slice(),a=s-i,a){for(a<0?(r=c,a=-a,o=u.length):(r=u,i=s,o=c.length),s=Math.ceil(f/hr),o=s>o?s+1:o+1,a>o&&(a=o,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(o=c.length,a=u.length,o-a<0&&(a=o,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/ji|0,c[a]%=ji;for(n&&(c.unshift(n),++i),o=c.length;c[--o]==0;)c.pop();return e.d=c,e.e=i,xr?rr(e,f):e}function ml(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Rh+t)}function sl(t){var e,n,r,i=t.length-1,a="",s=t[0];if(i>0){for(a+=s,e=1;e<i;e++)r=t[e]+"",n=hr-r.length,n&&(a+=Du(n)),a+=r;s=t[e],r=s+"",n=hr-r.length,n&&(a+=Du(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var Sc=(function(){function t(r,i){var a,s=0,o=r.length;for(r=r.slice();o--;)a=r[o]*i+s,r[o]=a%ji|0,s=a/ji|0;return s&&r.unshift(s),r}function e(r,i,a,s){var o,c;if(a!=s)c=a>s?1:-1;else for(o=c=0;o<a;o++)if(r[o]!=i[o]){c=r[o]>i[o]?1:-1;break}return c}function n(r,i,a){for(var s=0;a--;)r[a]-=s,s=r[a]<i[a]?1:0,r[a]=s*ji+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,s){var o,c,u,d,f,g,p,x,v,y,b,E,w,A,T,C,k,F,N=r.constructor,j=r.s==i.s?1:-1,I=r.d,O=i.d;if(!r.s)return new N(r);if(!i.s)throw Error(fo+"Division by zero");for(c=r.e-i.e,k=O.length,T=I.length,p=new N(j),x=p.d=[],u=0;O[u]==(I[u]||0);)++u;if(O[u]>(I[u]||0)&&--c,a==null?E=a=N.precision:s?E=a+(ri(r)-ri(i))+1:E=a,E<0)return new N(0);if(E=E/hr+2|0,u=0,k==1)for(d=0,O=O[0],E++;(u<T||d)&&E--;u++)w=d*ji+(I[u]||0),x[u]=w/O|0,d=w%O|0;else{for(d=ji/(O[0]+1)|0,d>1&&(O=t(O,d),I=t(I,d),k=O.length,T=I.length),A=k,v=I.slice(0,k),y=v.length;y<k;)v[y++]=0;F=O.slice(),F.unshift(0),C=O[0],O[1]>=ji/2&&++C;do d=0,o=e(O,v,k,y),o<0?(b=v[0],k!=y&&(b=b*ji+(v[1]||0)),d=b/C|0,d>1?(d>=ji&&(d=ji-1),f=t(O,d),g=f.length,y=v.length,o=e(f,v,g,y),o==1&&(d--,n(f,k<g?F:O,g))):(d==0&&(o=d=1),f=O.slice()),g=f.length,g<y&&f.unshift(0),n(v,f,y),o==-1&&(y=v.length,o=e(O,v,k,y),o<1&&(d++,n(v,k<y?F:O,y))),y=v.length):o===0&&(d++,v=[0]),x[u++]=d,o&&v[0]?v[y++]=I[A]||0:(v=[I[A]],y=1);while((A++<T||v[0]!==void 0)&&E--)}return x[0]||x.shift(),p.e=c,rr(p,s?a+ri(p)+1:a)}})();function uK(t,e){var n,r,i,a,s,o,c=0,u=0,d=t.constructor,f=d.precision;if(ri(t)>16)throw Error(tD+ri(t));if(!t.s)return new d(vs);for(xr=!1,o=f,s=new d(.03125);t.abs().gte(.1);)t=t.times(s),u+=5;for(r=Math.log(dh(2,u))/Math.LN10*2+5|0,o+=r,n=i=a=new d(vs),d.precision=o;;){if(i=rr(i.times(t),o),n=n.times(++c),s=a.plus(Sc(i,n,o)),sl(s.d).slice(0,o)===sl(a.d).slice(0,o)){for(;u--;)a=rr(a.times(a),o);return d.precision=f,e==null?(xr=!0,rr(a,f)):a}a=s}}function ri(t){for(var e=t.e*hr,n=t.d[0];n>=10;n/=10)e++;return e}function eC(t,e,n){if(e>t.LN10.sd())throw xr=!0,n&&(t.precision=n),Error(fo+"LN10 precision limit exceeded");return rr(new t(t.LN10),e)}function Du(t){for(var e="";t--;)e+="0";return e}function z0(t,e){var n,r,i,a,s,o,c,u,d,f=1,g=10,p=t,x=p.d,v=p.constructor,y=v.precision;if(p.s<1)throw Error(fo+(p.s?"NaN":"-Infinity"));if(p.eq(vs))return new v(0);if(e==null?(xr=!1,u=y):u=e,p.eq(10))return e==null&&(xr=!0),eC(v,u);if(u+=g,v.precision=u,n=sl(x),r=n.charAt(0),a=ri(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=sl(p.d),r=n.charAt(0),f++;a=ri(p),r>1?(p=new v("0."+n),a++):p=new v(r+"."+n.slice(1))}else return c=eC(v,u+2,y).times(a+""),p=z0(new v(r+"."+n.slice(1)),u-g).plus(c),v.precision=y,e==null?(xr=!0,rr(p,y)):p;for(o=s=p=Sc(p.minus(vs),p.plus(vs),u),d=rr(p.times(p),u),i=3;;){if(s=rr(s.times(d),u),c=o.plus(Sc(s,new v(i),u)),sl(c.d).slice(0,u)===sl(o.d).slice(0,u))return o=o.times(2),a!==0&&(o=o.plus(eC(v,u+2,y).times(a+""))),o=Sc(o,new v(f),u),v.precision=y,e==null?(xr=!0,rr(o,y)):o;o=c,i+=2}}function rB(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=ig(n/hr),t.d=[],r=(n+1)%hr,n<0&&(r+=hr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=hr;r<i;)t.d.push(+e.slice(r,r+=hr));e=e.slice(r),r=hr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),xr&&(t.e>mw||t.e<-mw))throw Error(tD+n)}else t.s=0,t.e=0,t.d=[0];return t}function rr(t,e,n){var r,i,a,s,o,c,u,d,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(r=e-s,r<0)r+=hr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/hr),a=f.length,d>=a)return t;for(u=a=f[d],s=1;a>=10;a/=10)s++;r%=hr,i=r-hr+s}if(n!==void 0&&(a=dh(10,s-i-1),o=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(o||c)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||c||n==6&&(r>0?i>0?u/dh(10,s-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=ri(t),f.length=1,e=e-a-1,f[0]=dh(10,(hr-e%hr)%hr),t.e=ig(-e/hr)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=dh(10,hr-r),f[d]=i>0?(u/dh(10,s-i)%dh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==ji&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=ji)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(xr&&(t.e>mw||t.e<-mw))throw Error(tD+ri(t));return t}function dK(t,e){var n,r,i,a,s,o,c,u,d,f,g=t.constructor,p=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),xr?rr(e,p):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),s=u-r,s){for(d=s<0,d?(n=c,s=-s,o=f.length):(n=f,r=u,o=c.length),i=Math.max(Math.ceil(p/hr),o)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=c.length,o=f.length,d=i<o,d&&(o=i),i=0;i<o;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}s=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),o=c.length,i=f.length-o;i>0;--i)c[o++]=0;for(i=f.length;i>s;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=ji-1;--c[a],c[i]+=ji}c[i]-=f[i]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,xr?rr(e,p):e):new g(0)}function Jh(t,e,n){var r,i=ri(t),a=sl(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Du(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Du(-i-1)+a,n&&(r=n-s)>0&&(a+=Du(r))):i>=s?(a+=Du(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+Du(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=Du(r))),t.s<0?"-"+a:a}function iB(t,e){if(t.length>e)return t.length=e,!0}function hK(t){var e,n,r;function i(a){var s=this;if(!(s instanceof i))return new i(a);if(s.constructor=i,a instanceof i){s.s=a.s,s.e=a.e,s.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Rh+a);if(a>0)s.s=1;else if(a<0)a=-a,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(a===~~a&&a<1e7){s.e=0,s.d=[a];return}return rB(s,a.toString())}else if(typeof a!="string")throw Error(Rh+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,Zbe.test(a))rB(s,a);else throw Error(Rh+a)}if(i.prototype=jt,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=hK,i.config=i.set=Qbe,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 Qbe(t){if(!t||typeof t!="object")throw Error(fo+"Object expected");var e,n,r,i=["precision",1,rg,"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(ig(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Rh+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Rh+n+": "+r);return this}var nD=hK(Ybe);vs=new nD(1);const Bn=nD;var Jbe=t=>t,fK={},mK=t=>t===fK,aB=t=>function e(){return arguments.length===0||arguments.length===1&&mK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},pK=(t,e)=>t===1?e:aB(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(s=>s!==fK).length;return a>=t?e(...r):pK(t-a,aB(function(){for(var s=arguments.length,o=new Array(s),c=0;c<s;c++)o[c]=arguments[c];var u=r.map(d=>mK(d)?o.shift():d);return e(...u,...o)}))}),eye=t=>pK(t.length,t),A3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},tye=eye((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),nye=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Jbe;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((o,c)=>c(o),a(...arguments))}},T3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function gK(t){var e;return t===0?e=1:e=Math.floor(new Bn(t).abs().log(10).toNumber())+1,e}function xK(t,e,n){for(var r=new Bn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var bK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},yK=(t,e,n)=>{if(t.lte(0))return new Bn(0);var r=gK(t.toNumber()),i=new Bn(10).pow(r),a=t.div(i),s=r!==1?.05:.1,o=new Bn(Math.ceil(a.div(s).toNumber())).add(n).mul(s),c=o.mul(i);return e?new Bn(c.toNumber()):new Bn(Math.ceil(c.toNumber()))},rye=(t,e,n)=>{var r=new Bn(1),i=new Bn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Bn(10).pow(gK(t)-1),i=new Bn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Bn(Math.floor(t)))}else t===0?i=new Bn(Math.floor((e-1)/2)):n||(i=new Bn(Math.floor(t)));var s=Math.floor((e-1)/2),o=nye(tye(c=>i.add(new Bn(c-s).mul(r)).toNumber()),A3);return o(0,e)},vK=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new Bn(0),tickMin:new Bn(0),tickMax:new Bn(0)};var s=yK(new Bn(n).sub(e).div(r-1),i,a),o;e<=0&&n>=0?o=new Bn(0):(o=new Bn(e).add(n).div(2),o=o.sub(new Bn(o).mod(s)));var c=Math.ceil(o.sub(e).div(s).toNumber()),u=Math.ceil(new Bn(n).sub(o).div(s).toNumber()),d=c+u+1;return d>r?vK(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:s,tickMin:o.sub(new Bn(c).mul(s)),tickMax:o.add(new Bn(u).mul(s))})},iye=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(i,2),[o,c]=bK([n,r]);if(o===-1/0||c===1/0){var u=c===1/0?[o,...A3(0,i-1).map(()=>1/0)]:[...A3(0,i-1).map(()=>-1/0),c];return n>r?T3(u):u}if(o===c)return rye(o,i,a);var{step:d,tickMin:f,tickMax:g}=vK(o,c,s,a,0),p=xK(f,g.add(new Bn(.1).mul(d)),d);return n>r?T3(p):p},aye=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=bK([r,i]);if(s===-1/0||o===1/0)return[r,i];if(s===o)return[s];var c=Math.max(n,2),u=yK(new Bn(o).sub(s).div(c-1),a,0),d=[...xK(new Bn(s),new Bn(o),u),o];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?T3(d):d},_K=t=>t.rootProps.maxBarSize,sye=t=>t.rootProps.barGap,wK=t=>t.rootProps.barCategoryGap,oye=t=>t.rootProps.barSize,Db=t=>t.rootProps.stackOffset,SK=t=>t.rootProps.reverseStackOrder,rD=t=>t.options.chartName,iD=t=>t.rootProps.syncId,MK=t=>t.rootProps.syncMethod,aD=t=>t.options.eventEmitter,lye=t=>t.rootProps.baseValue,Dr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},uc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},bs={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},_M=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},cye={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:uc.angleAxisId,includeHidden:!1,name:void 0,reversed:uc.reversed,scale:uc.scale,tick:uc.tick,tickCount:void 0,ticks:void 0,type:uc.type,unit:void 0},uye={allowDataOverflow:bs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:bs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:bs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:bs.scale,tick:bs.tick,tickCount:bs.tickCount,ticks:void 0,type:bs.type,unit:void 0},dye={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:uc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:uc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:uc.scale,tick:uc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},hye={allowDataOverflow:bs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:bs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:bs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:bs.scale,tick:bs.tick,tickCount:bs.tickCount,ticks:void 0,type:"category",unit:void 0},sD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?dye:cye,oD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?hye:uye,wM=t=>t.polarOptions,lD=Ke([Vc,Gc,bi],wq),EK=Ke([wM,lD],(t,e)=>{if(t!=null)return ma(t.innerRadius,e,0)}),AK=Ke([wM,lD],(t,e)=>{if(t!=null)return ma(t.outerRadius,e,e*.8)}),fye=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},TK=Ke([wM],fye);Ke([sD,TK],_M);var CK=Ke([lD,EK,AK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ke([oD,CK],_M);var NK=Ke([xn,wM,EK,AK,Vc,Gc],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:s,cy:o,startAngle:c,endAngle:u}=e;return{cx:ma(s,i,i/2),cy:ma(o,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),br=(t,e)=>e,Ob=(t,e,n)=>n;function SM(t){return t?.id}function kK(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,s=new Map;return t.forEach(o=>{var c,u=(c=o.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=SM(o);u.forEach((f,g)=>{var p=a==null||i?g:String(Hn(f,a,null)),x=Hn(f,o.dataKey,0),v;s.has(p)?v=s.get(p):v={},Object.assign(v,{[d]:x}),s.set(p,v)})}}),Array.from(s.values())}function MM(t){return t.stackId!=null&&t.dataKey!=null}var EM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function AM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function mye(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 _i=t=>{var e=xn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},ag=t=>t.tooltip.settings.axisId;function sB(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 pw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sB(Object(n),!0).forEach(function(r){pye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pye(t,e,n){return(e=gye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gye(t){var e=xye(t,"string");return typeof e=="symbol"?e:e+""}function xye(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 C3=[0,"auto"],Pi={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},PK=(t,e)=>t.cartesianAxis.xAxis[e],Ml=(t,e)=>{var n=PK(t,e);return n??Pi},Ri={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:C3,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:Ab},RK=(t,e)=>t.cartesianAxis.yAxis[e],El=(t,e)=>{var n=RK(t,e);return n??Ri},bye={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:""},cD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??bye},Ar=(t,e,n)=>{switch(e){case"xAxis":return Ml(t,n);case"yAxis":return El(t,n);case"zAxis":return cD(t,n);case"angleAxis":return sD(t,n);case"radiusAxis":return oD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},yye=(t,e,n)=>{switch(e){case"xAxis":return Ml(t,n);case"yAxis":return El(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Lb=(t,e,n)=>{switch(e){case"xAxis":return Ml(t,n);case"yAxis":return El(t,n);case"angleAxis":return sD(t,n);case"radiusAxis":return oD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},jK=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function uD(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 Ib=t=>t.graphicalItems.cartesianItems,vye=Ke([br,Ob],uD),dD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Fb=Ke([Ib,Ar,vye],dD,{memoizeOptions:{resultEqualityCheck:AM}}),DK=Ke([Fb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(MM)),OK=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),_ye=Ke([Fb],OK),hD=t=>t.map(e=>e.data).filter(Boolean).flat(1),wye=Ke([Fb],hD,{memoizeOptions:{resultEqualityCheck:AM}}),fD=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},mD=Ke([wye,jb],fD),pD=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Hn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Hn(i,r)}))):t.map(r=>({value:r})),TM=Ke([mD,Ar,Fb],pD);function LK(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function s1(t){if(uo(t)||t instanceof Date){var e=Number(t);if($n(e))return e}}function oB(t){if(Array.isArray(t)){var e=[s1(t[0]),s1(t[1])];return md(e)?e:void 0}var n=s1(t);if(n!=null)return[n,n]}function Fc(t){return t.map(s1).filter(yhe)}function Sye(t,e,n){return!n||typeof e!="number"||ns(e)?[]:n.length?Fc(n.flatMap(r=>{var i=Hn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!$n(a)||!$n(s)))return[e-a,e+s]})):[]}var wi=t=>{var e=_i(t),n=ag(t);return Lb(t,e,n)},Ub=Ke([wi],t=>t?.dataKey),Mye=Ke([DK,jb,wi],kK),IK=(t,e,n,r)=>{var i={},a=e.reduce((s,o)=>(o.stackId==null||(s[o.stackId]==null&&(s[o.stackId]=[]),s[o.stackId].push(o)),s),i);return Object.fromEntries(Object.entries(a).map(s=>{var[o,c]=s,u=r?[...c].reverse():c,d=u.map(SM);return[o,{stackedData:$me(t,d,n),graphicalItems:u}]}))},B0=Ke([Mye,DK,Db,SK],IK),FK=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=qme(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},Eye=Ke([Ar],t=>t.allowDataOverflow),gD=t=>{var e;if(t==null||!("domain"in t))return C3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Fc(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:C3},xD=Ke([Ar],gD),bD=Ke([xD,Eye],oK),Aye=Ke([B0,Nd,br,bD],FK,{memoizeOptions:{resultEqualityCheck:EM}}),CM=t=>t.errorBars,Tye=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>LK(n,r)),gw=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),s=Math.min(...a),o=Math.max(...a);return[s,o]}},yD=(t,e,n,r,i)=>{var a,s;if(n.length>0&&t.forEach(o=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(b=>LK(i,b)),g=Hn(o,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=Sye(o,g,f);if(p.length>=2){var x=Math.min(...p),v=Math.max(...p);(a==null||x<a)&&(a=x),(s==null||v>s)&&(s=v)}var y=oB(g);y!=null&&(a=a==null?y[0]:Math.min(a,y[0]),s=s==null?y[1]:Math.max(s,y[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var c=oB(Hn(o,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),s=s==null?c[1]:Math.max(s,c[1]))}),$n(a)&&$n(s))return[a,s]},Cye=Ke([mD,Ar,_ye,CM,br],yD,{memoizeOptions:{resultEqualityCheck:EM}});function Nye(t){var{value:e}=t;if(uo(e)||e instanceof Date)return e}var kye=(t,e,n)=>{var r=t.map(Nye).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&JG(r))?Aq(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},UK=t=>t.referenceElements.dots,sg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),Pye=Ke([UK,br,Ob],sg),zK=t=>t.referenceElements.areas,Rye=Ke([zK,br,Ob],sg),BK=t=>t.referenceElements.lines,jye=Ke([BK,br,Ob],sg),HK=(t,e)=>{var n=Fc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Dye=Ke(Pye,br,HK),$K=(t,e)=>{var n=Fc(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)]},Oye=Ke([Rye,br],$K);function Lye(t){var e;if(t.x!=null)return Fc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Fc(n)}function Iye(t){var e;if(t.y!=null)return Fc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Fc(n)}var VK=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?Lye(r):Iye(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Fye=Ke([jye,br],VK),Uye=Ke(Dye,Fye,Oye,(t,e,n)=>gw(t,n,e)),vD=(t,e,n,r,i,a,s,o)=>{if(n!=null)return n;var c=s==="vertical"&&o==="xAxis"||s==="horizontal"&&o==="yAxis",u=c?gw(r,a,i):gw(a,i);return Xbe(e,u,t.allowDataOverflow)},zye=Ke([Ar,xD,bD,Aye,Cye,Uye,xn,br],vD,{memoizeOptions:{resultEqualityCheck:EM}}),Bye=[0,1],_D=(t,e,n,r,i,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:o,type:c}=t,u=Sl(e,a);if(u&&o==null){var d;return Aq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?kye(r,t,u):i==="expand"?Bye:s}},wD=Ke([Ar,xn,mD,TM,Db,br,zye],_D),GK=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:s}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":s==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":s==="category"?"band":"linear";if(typeof a=="string"){var o="scale".concat(vb(a));return o in Fx?o:"point"}}},og=Ke([Ar,xn,jK,rD,br],GK);function Hye(t){if(t!=null){if(t in Fx)return Fx[t]();var e="scale".concat(vb(t));if(e in Fx)return Fx[e]()}}function SD(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=Hye(e);if(i!=null){var a=i.domain(n).range(r);return Fme(a),a}}}var MD=(t,e,n)=>{var r=gD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&md(t))return iye(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&md(t))return aye(t,e.tickCount,e.allowDecimals)}},ED=Ke([wD,Lb,og],MD),AD=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&md(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],s=e[1],o=n[n.length-1];return[Math.min(i,a),Math.max(s,o)]}return e},$ye=Ke([Ar,wD,ED,br],AD),Vye=Ke(TM,Ar,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Fc(t.map(o=>o.value))).sort((o,c)=>o-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var s=r[a+1]-r[a];n=Math.min(n,s)}return n/i}}),WK=Ke(Vye,xn,wK,bi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!$n(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=ma(n,t*a),o=t*a/2;return o-s-(o-s)/a*s}return 0}),Gye=(t,e)=>{var n=Ml(t,e);return n==null||typeof n.padding!="string"?0:WK(t,"xAxis",e,n.padding)},Wye=(t,e)=>{var n=El(t,e);return n==null||typeof n.padding!="string"?0:WK(t,"yAxis",e,n.padding)},qye=Ke(Ml,Gye,(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}}),Kye=Ke(El,Wye,(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}}),Xye=Ke([bi,qye,uM,cM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),Yye=Ke([bi,xn,Kye,uM,cM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:s}=i;return a?[r.height-s.bottom,s.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),zb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Xye(t,n,r);case"yAxis":return Yye(t,n,r);case"zAxis":return(i=cD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return TK(t);case"radiusAxis":return CK(t,n);default:return}},qK=Ke([Ar,zb],_M),pd=Ke([Ar,og,$ye,qK],SD);Ke([Fb,CM,br],Tye);function KK(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var NM=(t,e)=>e,kM=(t,e,n)=>n,Zye=Ke(oM,NM,kM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(KK)),Qye=Ke(lM,NM,kM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(KK)),XK=(t,e)=>({width:t.width,height:e.height}),Jye=(t,e)=>{var n=typeof e.width=="number"?e.width:Ab;return{width:n,height:t.height}},YK=Ke(bi,Ml,XK),eve=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},tve=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},nve=Ke(Gc,bi,Zye,NM,kM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var c=XK(e,o);s==null&&(s=eve(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[o.id]=s-Number(u)*c.height,s+=(u?-1:1)*c.height}),a}),rve=Ke(Vc,bi,Qye,NM,kM,(t,e,n,r,i)=>{var a={},s;return n.forEach(o=>{var c=Jye(e,o);s==null&&(s=tve(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[o.id]=s-Number(u)*c.width,s+=(u?-1:1)*c.width}),a}),ive=(t,e)=>{var n=Ml(t,e);if(n!=null)return nve(t,n.orientation,n.mirror)},ave=Ke([bi,Ml,ive,(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}}}),sve=(t,e)=>{var n=El(t,e);if(n!=null)return rve(t,n.orientation,n.mirror)},ove=Ke([bi,El,sve,(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}}}),ZK=Ke(bi,El,(t,e)=>{var n=typeof e.width=="number"?e.width:Ab;return{width:n,height:t.height}}),lB=(t,e,n)=>{switch(e){case"xAxis":return YK(t,n).width;case"yAxis":return ZK(t,n).height;default:return}},QK=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:s}=n,o=Sl(t,r),c=e.map(u=>u.value);if(s&&o&&a==="category"&&i&&JG(c))return c}},TD=Ke([xn,TM,Ar,br],QK),JK=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,s=Sl(t,r);if(s&&(i==="number"||a!=="auto"))return e.map(o=>o.value)}},CD=Ke([xn,TM,Lb,br],JK),cB=Ke([xn,yye,og,pd,TD,CD,zb,ED,br],(t,e,n,r,i,a,s,o,c)=>{if(e!=null){var u=Sl(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:o,range:s,realScaleType:n,scale:r}}}),lve=(t,e,n,r,i,a,s,o,c)=>{if(!(e==null||r==null)){var u=Sl(t,c),{type:d,ticks:f,tickCount:g}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Li(a[0]-a[1])*2*x:x;var v=f||i;if(v){var y=v.map((b,E)=>{var w=s?s.indexOf(b):b;return{index:E,coordinate:r(w)+x,value:b,offset:x}});return y.filter(b=>$n(b.coordinate))}return u&&o?o.map((b,E)=>({coordinate:r(b)+x,value:b,index:E,offset:x})).filter(b=>$n(b.coordinate)):r.ticks?r.ticks(g).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,E)=>({coordinate:r(b)+x,value:s?s[b]:b,index:E,offset:x}))}},eX=Ke([xn,Lb,og,pd,ED,zb,TD,CD,br],lve),cve=(t,e,n,r,i,a,s)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=Sl(t,s),{tickCount:c}=e,u=0;return u=s==="angleAxis"&&r?.length>=2?Li(r[0]-r[1])*2*u:u,o&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},pl=Ke([xn,Lb,pd,zb,TD,CD,br],cve),gl=Ke(Ar,pd,(t,e)=>{if(!(t==null||e==null))return pw(pw({},t),{},{scale:e})}),uve=Ke([Ar,og,wD,qK],SD);Ke((t,e,n)=>cD(t,n),uve,(t,e)=>{if(!(t==null||e==null))return pw(pw({},t),{},{scale:e})});var dve=Ke([xn,oM,lM],(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}}),tX=t=>t.options.defaultTooltipEventType,nX=t=>t.options.validateTooltipEventTypes;function rX(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function ND(t,e){var n=tX(t),r=nX(t);return rX(e,n,r)}function hve(t){return kt(e=>ND(e,t))}var iX=(t,e)=>{var n,r=Number(e);if(!(ns(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},fve=t=>t.tooltip.settings,Hu={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},mve={itemInteraction:{click:Hu,hover:Hu},axisInteraction:{click:Hu,hover:Hu},keyboardInteraction:Hu,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}},aX=rs({name:"tooltip",initialState:mve,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:pr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:pr()},removeTooltipEntrySettings:{reducer(t,e){var n=Lo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:pr()},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:pve,replaceTooltipEntrySettings:gve,removeTooltipEntrySettings:xve,setTooltipSettingsState:bve,setActiveMouseOverItemIndex:sX,mouseLeaveItem:yve,mouseLeaveChart:oX,setActiveClickItemIndex:vve,setMouseOverAxisIndex:lX,setMouseClickAxisIndex:_ve,setSyncInteraction:N3,setKeyboardInteraction:k3}=aX.actions,wve=aX.reducer;function uB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Rv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uB(Object(n),!0).forEach(function(r){Sve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Sve(t,e,n){return(e=Mve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mve(t){var e=Eve(t,"string");return typeof e=="symbol"?e:e+""}function Eve(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 Ave(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function Tve(t){return t.index!=null}var cX=(t,e,n,r)=>{if(e==null)return Hu;var i=Ave(t,e,n);if(i==null)return Hu;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var a=t.settings.active===!0;if(Tve(i)){if(a)return Rv(Rv({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Rv(Rv({},Hu),{},{coordinate:i.coordinate})};function Cve(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 Nve(t,e){var n=Cve(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),s=Math.max(r,i);return n>=a&&n<=s}function kve(t,e,n){if(n==null||e==null)return!0;var r=Hn(t,e);return r==null||!md(n)?!0:Nve(r,n)}var kD=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!$n(a))return i;var s=0,o=1/0;e.length>0&&(o=e.length-1);var c=Math.max(s,Math.min(a,o)),u=e[c];return u==null||kve(u,n,r)?String(c):null},uX=(t,e,n,r,i,a,s,o)=>{if(!(a==null||o==null)){var c=s[0],u=c==null?void 0:o(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},dX=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var s;return((s=a.settings)===null||s===void 0?void 0:s.dataKey)===i})},Bb=t=>t.options.tooltipPayloadSearcher,lg=t=>t.tooltip;function dB(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 hB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dB(Object(n),!0).forEach(function(r){Pve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pve(t,e,n){return(e=Rve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rve(t){var e=jve(t,"string");return typeof e=="symbol"?e:e+""}function jve(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 Dve(t,e){return t??e}var hX=(t,e,n,r,i,a,s)=>{if(!(e==null||a==null)){var{chartData:o,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,p)=>{var x,{dataDefinedOnItem:v,settings:y}=p,b=Dve(v,o),E=Array.isArray(b)?KW(b,u,d):b,w=(x=y?.dataKey)!==null&&x!==void 0?x:r,A=y?.nameKey,T;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&s==="axis"?T=eW(E,r,i):T=a(E,e,c,A),Array.isArray(T))T.forEach(k=>{var F=hB(hB({},y),{},{name:k.name,unit:k.unit,color:void 0,fill:void 0});g.push(Rz({tooltipEntrySettings:F,dataKey:k.dataKey,payload:k.payload,value:Hn(k.payload,k.dataKey),name:k.name}))});else{var C;g.push(Rz({tooltipEntrySettings:y,dataKey:w,payload:T,value:Hn(T,w),name:(C=Hn(T,A))!==null&&C!==void 0?C:y?.name}))}return g},f)}},PD=Ke([wi,xn,jK,rD,_i],GK),Ove=Ke([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),Lve=Ke([_i,ag],uD),Hb=Ke([Ove,wi,Lve],dD,{memoizeOptions:{resultEqualityCheck:AM}}),Ive=Ke([Hb],t=>t.filter(MM)),Fve=Ke([Hb],hD,{memoizeOptions:{resultEqualityCheck:AM}}),cg=Ke([Fve,Nd],fD),Uve=Ke([Ive,Nd,wi],kK),RD=Ke([cg,wi,Hb],pD),fX=Ke([wi],gD),zve=Ke([wi],t=>t.allowDataOverflow),mX=Ke([fX,zve],oK),Bve=Ke([Hb],t=>t.filter(MM)),Hve=Ke([Uve,Bve,Db,SK],IK),$ve=Ke([Hve,Nd,_i,mX],FK),Vve=Ke([Hb],OK),Gve=Ke([cg,wi,Vve,CM,_i],yD,{memoizeOptions:{resultEqualityCheck:EM}}),Wve=Ke([UK,_i,ag],sg),qve=Ke([Wve,_i],HK),Kve=Ke([zK,_i,ag],sg),Xve=Ke([Kve,_i],$K),Yve=Ke([BK,_i,ag],sg),Zve=Ke([Yve,_i],VK),Qve=Ke([qve,Zve,Xve],gw),Jve=Ke([wi,fX,mX,$ve,Gve,Qve,xn,_i],vD),$b=Ke([wi,xn,cg,RD,Db,_i,Jve],_D),e_e=Ke([$b,wi,PD],MD),t_e=Ke([wi,$b,e_e,_i],AD),pX=t=>{var e=_i(t),n=ag(t),r=!1;return zb(t,e,n,r)},gX=Ke([wi,pX],_M),xX=Ke([wi,PD,t_e,gX],SD),n_e=Ke([xn,RD,wi,_i],QK),r_e=Ke([xn,RD,wi,_i],JK),i_e=(t,e,n,r,i,a,s,o)=>{if(e){var{type:c}=e,u=Sl(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=o==="angleAxis"&&i!=null&&i?.length>=2?Li(i[0]-i[1])*2*f:f,u&&s?s.map((g,p)=>({coordinate:r(g)+f,value:g,index:p,offset:f})):r.domain().map((g,p)=>({coordinate:r(g)+f,value:a?a[g]:g,index:p,offset:f}))}}},qc=Ke([xn,wi,PD,xX,pX,n_e,r_e,_i],i_e),jD=Ke([tX,nX,fve],(t,e,n)=>rX(n.shared,t,e)),bX=t=>t.tooltip.settings.trigger,DD=t=>t.tooltip.settings.defaultIndex,Vb=Ke([lg,jD,bX,DD],cX),gd=Ke([Vb,cg,Ub,$b],kD),yX=Ke([qc,gd],iX),OD=Ke([Vb],t=>{if(t)return t.dataKey}),a_e=Ke([Vb],t=>{if(t)return t.graphicalItemId}),vX=Ke([lg,jD,bX,DD],dX),s_e=Ke([Vc,Gc,xn,bi,qc,DD,vX,Bb],uX),o_e=Ke([Vb,s_e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),l_e=Ke([Vb],t=>t.active),c_e=Ke([vX,gd,Nd,Ub,yX,Bb,jD],hX),u_e=Ke([c_e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function fB(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 mB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fB(Object(n),!0).forEach(function(r){d_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function d_e(t,e,n){return(e=h_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h_e(t){var e=f_e(t,"string");return typeof e=="symbol"?e:e+""}function f_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)}var m_e=()=>kt(wi),p_e=()=>{var t=m_e(),e=kt(qc),n=kt(xX);return fd(!t||!n?void 0:mB(mB({},t),{},{scale:n}),e)};function pB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pB(Object(n),!0).forEach(function(r){g_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function g_e(t,e,n){return(e=x_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x_e(t){var e=b_e(t,"string");return typeof e=="symbol"?e:e+""}function b_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)}var y_e=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},v_e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:s}=r;return tm(tm(tm({},r),ti(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}var o=i.coordinate,{angle:c}=r;return tm(tm(tm({},r),ti(r.cx,r.cy,o,c)),{},{angle:c,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 __e(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 _X=(t,e,n,r,i)=>{var a,s=-1,o=(a=e?.length)!==null&&a!==void 0?a:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<o;c++){var u=c>0?n[c-1].coordinate:n[o-1].coordinate,d=n[c].coordinate,f=c>=o-1?n[0].coordinate:n[c+1].coordinate,g=void 0;if(Li(d-u)!==Li(f-d)){var p=[];if(Li(f-d)===Li(i[1]-i[0])){g=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{g=u;var v=f+i[1]-i[0];p[0]=Math.min(d,(v+d)/2),p[1]=Math.max(d,(v+d)/2)}var y=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>y[0]&&t<=y[1]||t>=p[0]&&t<=p[1]){({index:s}=n[c]);break}}else{var b=Math.min(u,f),E=Math.max(u,f);if(t>(b+d)/2&&t<=(E+d)/2){({index:s}=n[c]);break}}}else if(e){for(var w=0;w<o;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:s}=e[w]);break}}return s},wX=()=>kt(rD),LD=(t,e)=>e,SX=(t,e,n)=>n,ID=(t,e,n,r)=>r,w_e=Ke(qc,t=>QS(t,e=>e.coordinate)),FD=Ke([lg,LD,SX,ID],cX),UD=Ke([FD,cg,Ub,$b],kD),S_e=(t,e,n)=>{if(e!=null){var r=lg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},MX=Ke([lg,LD,SX,ID],dX),xw=Ke([Vc,Gc,xn,bi,qc,ID,MX,Bb],uX),M_e=Ke([FD,xw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),EX=Ke([qc,UD],iX),E_e=Ke([MX,UD,Nd,Ub,EX,Bb,LD],hX),A_e=Ke([FD,UD],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),T_e=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&__e(t,s)){var o=Kme(t,e),c=_X(o,a,i,n,r),u=y_e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},C_e=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var o=dxe(t,n);if(o){var c=Xme(o,e),u=_X(c,s,a,r,i),d=v_e(e,a,u,o);return{activeIndex:String(u),activeCoordinate:d}}}},N_e=(t,e,n,r,i,a,s,o)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?T_e(t,e,r,i,a,s,o):C_e(t,e,n,r,i,a,s)},k_e=Ke(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}}),P_e=Ke(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Dr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:mye}});function gB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gB(Object(n),!0).forEach(function(r){R_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R_e(t,e,n){return(e=j_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j_e(t){var e=D_e(t,"string");return typeof e=="symbol"?e:e+""}function D_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var 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 O_e={},L_e={zIndexMap:Object.values(Dr).reduce((t,e)=>xB(xB({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),O_e)},I_e=new Set(Object.values(Dr));function F_e(t){return I_e.has(t)}var AX=rs({name:"zIndex",initialState:L_e,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:pr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!F_e(n)&&delete t.zIndexMap[n])},prepare:pr()},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:pr()},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:pr()}}}),{registerZIndexPortal:U_e,unregisterZIndexPortal:z_e,registerZIndexPortalId:B_e,unregisterZIndexPortalId:H_e}=AX.actions,$_e=AX.reducer;function ga(t){var{zIndex:e,children:n}=t,r=Tpe(),i=r&&e!==void 0&&e!==0,a=yi(),s=ir();M.useLayoutEffect(()=>i?(s(U_e({zIndex:e})),()=>{s(z_e({zIndex:e}))}):_b,[s,e,i]);var o=kt(u=>k_e(u,e,a));if(!i)return n;if(!o)return null;var c=document.getElementById(o);return c?mc.createPortal(n,c):null}function P3(){return P3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P3.apply(null,arguments)}function bB(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 jv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bB(Object(n),!0).forEach(function(r){V_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function V_e(t,e,n){return(e=G_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function G_e(t){var e=W_e(t,"string");return typeof e=="symbol"?e:e+""}function W_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 q_e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return M.isValidElement(e)?M.cloneElement(e,r):M.createElement(n,r)}function K_e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:s,layout:o,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,v,y;if(d==="ScatterChart")x=f,v=Age,y=Dr.cursorLine;else if(d==="BarChart")x=Tge(o,f,a,s),v=_q,y=Dr.cursorRectangle;else if(o==="radial"&&nW(f)){var{cx:b,cy:E,radius:w,startAngle:A,endAngle:T}=Sq(f);x={cx:b,cy:E,startAngle:A,endAngle:T,innerRadius:w,outerRadius:w},v=Eq,y=Dr.cursorLine}else x={points:pxe(o,f,a)},v=rp,y=Dr.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,k=jv(jv(jv(jv({stroke:"#ccc",pointerEvents:"none"},a),x),Xh(c)),{},{payload:g,payloadIndex:p,className:En("recharts-tooltip-cursor",C)});return M.createElement(ga,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:y},M.createElement(q_e,{cursor:c,cursorComp:v,cursorProps:k}))}function X_e(t){var e=p_e(),n=aq(),r=mf(),i=wX();return e==null||n==null||r==null||i==null?null:M.createElement(K_e,P3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var TX=M.createContext(null),Y_e=()=>M.useContext(TX),tC={exports:{}},yB;function Z_e(){return yB||(yB=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,g),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function s(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,p=f.length,x=new Array(p);g<p;g++)x[g]=f[g].fn;return x},o.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,d,f,g,p,x){var v=n?n+u:u;if(!this._events[v])return!1;var y=this._events[v],b=arguments.length,E,w;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,f),!0;case 4:return y.fn.call(y.context,d,f,g),!0;case 5:return y.fn.call(y.context,d,f,g,p),!0;case 6:return y.fn.call(y.context,d,f,g,p,x),!0}for(w=1,E=new Array(b-1);w<b;w++)E[w-1]=arguments[w];y.fn.apply(y.context,E)}else{var A=y.length,T;for(w=0;w<A;w++)switch(y[w].once&&this.removeListener(u,y[w].fn,void 0,!0),b){case 1:y[w].fn.call(y[w].context);break;case 2:y[w].fn.call(y[w].context,d);break;case 3:y[w].fn.call(y[w].context,d,f);break;case 4:y[w].fn.call(y[w].context,d,f,g);break;default:if(!E)for(T=1,E=new Array(b-1);T<b;T++)E[T-1]=arguments[T];y[w].fn.apply(y[w].context,E)}}return!0},o.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,g){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return s(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&s(this,p);else{for(var v=0,y=[],b=x.length;v<b;v++)(x[v].fn!==d||g&&!x[v].once||f&&x[v].context!==f)&&y.push(x[v]);y.length?this._events[p]=y.length===1?y[0]:y:s(this,p)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&s(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})(tC)),tC.exports}var Q_e=Z_e();const J_e=mo(Q_e);var H0=new J_e,R3="recharts.syncEvent.tooltip",vB="recharts.syncEvent.brush";function PM(t,e){if(e){var n=Number.parseInt(e,10);if(!ns(n))return t?.[n]}}var e1e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},CX=rs({name:"options",initialState:e1e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),t1e=CX.reducer,{createEventEmitter:n1e}=CX.actions;function r1e(t){return t.tooltip.syncInteraction}var i1e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},NX=rs({name:"chartData",initialState:i1e,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:_B,setDataStartEndIndexes:a1e,setComputedData:oWe}=NX.actions,s1e=NX.reducer,o1e=["x","y"];function wB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wB(Object(n),!0).forEach(function(r){l1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function l1e(t,e,n){return(e=c1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c1e(t){var e=u1e(t,"string");return typeof e=="symbol"?e:e+""}function u1e(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 d1e(t,e){if(t==null)return{};var n,r,i=h1e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function h1e(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 f1e(){var t=kt(iD),e=kt(aD),n=ir(),r=kt(MK),i=kt(qc),a=mf(),s=Tb(),o=kt(c=>c.rootProps.className);M.useEffect(()=>{if(t==null)return _b;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(s&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y:v}=p,y=d1e(p,o1e),{x:b,y:E,width:w,height:A}=d.payload.sourceViewBox,T=nm(nm({},y),{},{x:s.x+(w?(x-b)/w:0)*s.width,y:s.y+(A?(v-E)/A:0)*s.height});n(nm(nm({},d),{},{payload:nm(nm({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var k={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},F=r(i,k);C=i[F]}else r==="value"&&(C=i.find(K=>String(K.value)===d.payload.label));var{coordinate:N}=d.payload;if(C==null||d.payload.active===!1||N==null||s==null){n(N3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:j,y:I}=N,O=Math.min(j,s.x+s.width),q=Math.min(I,s.y+s.height),R={x:a==="horizontal"?C.coordinate:O,y:a==="horizontal"?q:C.coordinate},W=N3({active:d.payload.active,coordinate:R,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return H0.on(R3,c),()=>{H0.off(R3,c)}},[o,n,e,t,r,i,a,s])}function m1e(){var t=kt(iD),e=kt(aD),n=ir();M.useEffect(()=>{if(t==null)return _b;var r=(i,a,s)=>{e!==s&&t===i&&n(a1e(a))};return H0.on(vB,r),()=>{H0.off(vB,r)}},[n,e,t])}function p1e(){var t=ir();M.useEffect(()=>{t(n1e())},[t]),f1e(),m1e()}function g1e(t,e,n,r,i,a){var s=kt(p=>S_e(p,t,e)),o=kt(aD),c=kt(iD),u=kt(MK),d=kt(r1e),f=d?.active,g=Tb();M.useEffect(()=>{if(!f&&c!=null&&o!=null){var p=N3({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});H0.emit(R3,c,p,o)}},[f,n,s,i,r,o,c,u,a,g])}function SB(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 MB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SB(Object(n),!0).forEach(function(r){x1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function x1e(t,e,n){return(e=b1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b1e(t){var e=y1e(t,"string");return typeof e=="symbol"?e:e+""}function y1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function v1e(t){return t.dataKey}function _1e(t,e){return M.isValidElement(t)?M.cloneElement(t,e):typeof t=="function"?M.createElement(t,e):M.createElement(age,e)}var EB=[],w1e={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 o1(t){var e,n,r=Er(t,w1e),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:o,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:p,reverseDirection:x,useTranslate3d:v,wrapperStyle:y,cursor:b,shared:E,trigger:w,defaultIndex:A,portal:T,axisId:C}=r,k=ir(),F=typeof A=="number"?String(A):A;M.useEffect(()=>{k(bve({shared:E,trigger:w,axisId:C,active:i,defaultIndex:F}))},[k,E,w,C,i,F]);var N=Tb(),j=gq(),I=hve(E),{activeIndex:O,isActive:q}=(e=kt(be=>A_e(be,I,w,F)))!==null&&e!==void 0?e:{},R=kt(be=>E_e(be,I,w,F)),W=kt(be=>EX(be,I,w,F)),K=kt(be=>M_e(be,I,w,F)),G=R,te=Y_e(),Y=(n=i??q)!==null&&n!==void 0?n:!1,[J,U]=bW([G,Y]),H=I==="axis"?W:void 0;g1e(I,w,K,H,O,Y);var ee=T??te;if(ee==null||N==null||I==null)return null;var ie=G??EB;Y||(ie=EB),u&&ie.length&&(ie=hW(ie.filter(be=>be.value!=null&&(be.hide!==!0||r.includeHidden)),g,v1e));var pe=ie.length>0,ue=M.createElement(hge,{allowEscapeViewBox:a,animationDuration:s,animationEasing:o,isAnimationActive:d,active:Y,coordinate:K,hasPayload:pe,offset:f,position:p,reverseDirection:x,useTranslate3d:v,viewBox:N,wrapperStyle:y,lastBoundingBox:J,innerRef:U,hasPortalFromProps:!!T},_1e(c,MB(MB({},r),{},{payload:ie,label:H,active:Y,activeIndex:O,coordinate:K,accessibilityLayer:j})));return M.createElement(M.Fragment,null,mc.createPortal(ue,ee),Y&&M.createElement(X_e,{cursor:b,tooltipEventType:I,coordinate:K,payload:ie,index:O}))}var Gb=t=>null;Gb.displayName="Cell";function S1e(t,e,n){return(e=M1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M1e(t){var e=E1e(t,"string");return typeof e=="symbol"?e:e+""}function E1e(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 A1e{constructor(e){S1e(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 AB(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 T1e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AB(Object(n),!0).forEach(function(r){C1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function C1e(t,e,n){return(e=N1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function N1e(t){var e=k1e(t,"string");return typeof e=="symbol"?e:e+""}function k1e(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 P1e={cacheSize:2e3,enableCache:!0},kX=T1e({},P1e),TB=new A1e(kX.cacheSize),R1e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},CB="recharts_measurement_span";function j1e(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(s,"|").concat(o)}var NB=(t,e)=>{try{var n=document.getElementById(CB);n||(n=document.createElement("span"),n.setAttribute("id",CB),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,R1e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Zx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Jp.isSsr)return{width:0,height:0};if(!kX.enableCache)return NB(e,n);var r=j1e(e,n),i=TB.get(r);if(i)return i;var a=NB(e,n);return TB.set(r,a),a},kB=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,PB=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,D1e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,O1e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,PX={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},L1e=Object.keys(PX),Km="NaN";function I1e(t,e){return t*PX[e]}class Wa{static parse(e){var n,[,r,i]=(n=O1e.exec(e))!==null&&n!==void 0?n:[];return new Wa(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ns(e)&&(this.unit=""),n!==""&&!D1e.test(n)&&(this.num=NaN,this.unit=""),L1e.includes(n)&&(this.num=I1e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Wa(NaN,""):new Wa(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Wa(NaN,""):new Wa(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Wa(NaN,""):new Wa(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Wa(NaN,""):new Wa(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ns(this.num)}}function RX(t){if(t.includes(Km))return Km;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=kB.exec(e))!==null&&n!==void 0?n:[],s=Wa.parse(r??""),o=Wa.parse(a??""),c=i==="*"?s.multiply(o):s.divide(o);if(c.isNaN())return Km;e=e.replace(kB,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=PB.exec(e))!==null&&u!==void 0?u:[],p=Wa.parse(d??""),x=Wa.parse(g??""),v=f==="+"?p.add(x):p.subtract(x);if(v.isNaN())return Km;e=e.replace(PB,v.toString())}return e}var RB=/\(([^()]*)\)/;function F1e(t){for(var e=t,n;(n=RB.exec(e))!=null;){var[,r]=n;e=e.replace(RB,RX(r))}return e}function U1e(t){var e=t.replace(/\s+/g,"");return e=F1e(e),e=RX(e),e}function z1e(t){try{return U1e(t)}catch{return Km}}function nC(t){var e=z1e(t.slice(5,-1));return e===Km?"":e}var B1e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],H1e=["dx","dy","angle","className","breakAll"];function j3(){return j3=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},j3.apply(null,arguments)}function jB(t,e){if(t==null)return{};var n,r,i=$1e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function $1e(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 jX=/[ \f\n\r\t\v\u2028\u2029]+/,DX=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];fr(e)||(n?i=e.toString().split(""):i=e.toString().split(jX));var a=i.map(o=>({word:o,width:Zx(o,r).width})),s=n?0:Zx(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function V1e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var OX=(t,e,n,r)=>t.reduce((i,a)=>{var{word:s,width:o}=a,c=i[i.length-1];if(c&&o!=null&&(e==null||r||c.width+o+n<Number(e)))c.words.push(s),c.width+=o+n;else{var u={words:[s],width:o};i.push(u)}return i},[]),LX=t=>t.reduce((e,n)=>e.width>n.width?e:n),G1e="…",DB=(t,e,n,r,i,a,s,o)=>{var c=t.slice(0,e),u=DX({breakAll:n,style:r,children:c+G1e});if(!u)return[!1,[]];var d=OX(u.wordsWithComputedWidth,a,s,o),f=d.length>i||LX(d).width>Number(a);return[f,d]},W1e=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:o,breakAll:c}=t,u=Rt(a),d=String(s),f=OX(e,r,n,i);if(!u||i)return f;var g=f.length>a||LX(f).width>Number(r);if(!g)return f;for(var p=0,x=d.length-1,v=0,y;p<=x&&v<=d.length-1;){var b=Math.floor((p+x)/2),E=b-1,[w,A]=DB(d,E,c,o,a,r,n,i),[T]=DB(d,b,c,o,a,r,n,i);if(!w&&!T&&(p=b+1),w&&T&&(x=b-1),!w&&T){y=A;break}v++}return y||f},OB=t=>{var e=fr(t)?[]:t.toString().split(jX);return[{words:e,width:void 0}]},q1e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!Jp.isSsr){var o,c,u=DX({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;o=d,c=f}else return OB(r);return W1e({breakAll:a,children:r,maxLines:s,style:i},o,c,e,!!n)}return OB(r)},IX="#808080",K1e={angle:0,breakAll:!1,capHeight:"0.71em",fill:IX,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},RM=M.forwardRef((t,e)=>{var n=Er(t,K1e),{x:r,y:i,lineHeight:a,capHeight:s,fill:o,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=jB(n,B1e),g=M.useMemo(()=>q1e({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:x,angle:v,className:y,breakAll:b}=f,E=jB(f,H1e);if(!uo(r)||!uo(i)||g.length===0)return null;var w=Number(r)+(Rt(p)?p:0),A=Number(i)+(Rt(x)?x:0);if(!$n(w)||!$n(A))return null;var T;switch(d){case"start":T=nC("calc(".concat(s,")"));break;case"middle":T=nC("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=nC("calc(".concat(g.length-1," * -").concat(a,")"));break}var C=[];if(c){var k=g[0].width,{width:F}=f;C.push("scale(".concat(Rt(F)&&Rt(k)?F/k:1,")"))}return v&&C.push("rotate(".concat(v,", ").concat(w,", ").concat(A,")")),C.length&&(E.transform=C.join(" ")),M.createElement("text",j3({},na(E),{ref:e,x:w,y:A,className:En("recharts-text",y),textAnchor:u,fill:o.includes("url")?IX:o}),g.map((N,j)=>{var I=N.words.join(b?"":" ");return M.createElement("tspan",{x:w,dy:j===0?T:a,key:"".concat(I,"-").concat(j)},I)}))});RM.displayName="Text";var X1e=["labelRef"];function Y1e(t,e){if(t==null)return{};var n,r,i=Z1e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Z1e(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 LB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Br(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LB(Object(n),!0).forEach(function(r){Q1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q1e(t,e,n){return(e=J1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function J1e(t){var e=ewe(t,"string");return typeof e=="symbol"?e:e+""}function ewe(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 dc(){return dc=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},dc.apply(null,arguments)}var FX=M.createContext(null),UX=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s,children:o}=t,c=M.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s}),[e,n,r,i,a,s]);return M.createElement(FX.Provider,{value:c},o)},zX=()=>{var t=M.useContext(FX),e=Tb();return t||iq(e)},twe=M.createContext(null),nwe=()=>{var t=M.useContext(twe),e=kt(NK);return t||e},rwe=t=>{var{value:e,formatter:n}=t,r=fr(t.children)?e:t.children;return typeof n=="function"?n(r):r},zD=t=>t!=null&&typeof t=="function",iwe=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r},awe=(t,e,n,r,i)=>{var{offset:a,className:s}=t,{cx:o,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:p}=i,x=(u+d)/2,v=iwe(f,g),y=v>=0?1:-1,b,E;switch(e){case"insideStart":b=f+y*a,E=p;break;case"insideEnd":b=g-y*a,E=!p;break;case"end":b=g+y*a,E=p;break;default:throw new Error("Unsupported position ".concat(e))}E=v<=0?E:!E;var w=ti(o,c,x,b),A=ti(o,c,x,b+(E?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
  44. A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
  45. `).concat(A.x,",").concat(A.y),C=fr(t.id)?C0("recharts-radial-line-"):t.id;return M.createElement("text",dc({},r,{dominantBaseline:"central",className:En("recharts-radial-bar-label",s)}),M.createElement("defs",null,M.createElement("path",{id:C,d:T})),M.createElement("textPath",{xlinkHref:"#".concat(C)},n))},swe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:s,startAngle:o,endAngle:c}=t,u=(o+c)/2;if(n==="outside"){var{x:d,y:f}=ti(r,i,s+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(a+s)/2,{x:p,y:x}=ti(r,i,g,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},D3=t=>"cx"in t&&Rt(t.cx),owe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!D3(n)&&(a=n);var{x:s,y:o,upperWidth:c,lowerWidth:u,height:d}=e,f=s,g=s+(c-u)/2,p=(f+g)/2,x=(c+u)/2,v=f+c/2,y=d>=0?1:-1,b=y*r,E=y>0?"end":"start",w=y>0?"start":"end",A=c>=0?1:-1,T=A*r,C=A>0?"end":"start",k=A>0?"start":"end";if(i==="top"){var F={x:f+c/2,y:o-b,textAnchor:"middle",verticalAnchor:E};return Br(Br({},F),a?{height:Math.max(o-a.y,0),width:c}:{})}if(i==="bottom"){var N={x:g+u/2,y:o+d+b,textAnchor:"middle",verticalAnchor:w};return Br(Br({},N),a?{height:Math.max(a.y+a.height-(o+d),0),width:u}:{})}if(i==="left"){var j={x:p-T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"};return Br(Br({},j),a?{width:Math.max(j.x-a.x,0),height:d}:{})}if(i==="right"){var I={x:p+x+T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"};return Br(Br({},I),a?{width:Math.max(a.x+a.width-I.x,0),height:d}:{})}var O=a?{width:x,height:d}:{};return i==="insideLeft"?Br({x:p+T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"},O):i==="insideRight"?Br({x:p+x-T,y:o+d/2,textAnchor:C,verticalAnchor:"middle"},O):i==="insideTop"?Br({x:f+c/2,y:o+b,textAnchor:"middle",verticalAnchor:w},O):i==="insideBottom"?Br({x:g+u/2,y:o+d-b,textAnchor:"middle",verticalAnchor:E},O):i==="insideTopLeft"?Br({x:f+T,y:o+b,textAnchor:k,verticalAnchor:w},O):i==="insideTopRight"?Br({x:f+c-T,y:o+b,textAnchor:C,verticalAnchor:w},O):i==="insideBottomLeft"?Br({x:g+T,y:o+d-b,textAnchor:k,verticalAnchor:E},O):i==="insideBottomRight"?Br({x:g+u-T,y:o+d-b,textAnchor:C,verticalAnchor:E},O):i&&typeof i=="object"&&(Rt(i.x)||jc(i.x))&&(Rt(i.y)||jc(i.y))?Br({x:s+ma(i.x,x),y:o+ma(i.y,d),textAnchor:"end",verticalAnchor:"end"},O):Br({x:v,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},O)},lwe={angle:0,offset:5,zIndex:Dr.label,position:"middle",textBreakAll:!1};function Ou(t){var e=Er(t,lwe),{viewBox:n,position:r,value:i,children:a,content:s,className:o="",textBreakAll:c,labelRef:u}=e,d=nwe(),f=zX(),g=r==="center"?f:d??f,p,x,v;if(n==null?p=g:D3(n)?p=n:p=iq(n),!p||fr(i)&&fr(a)&&!M.isValidElement(s)&&typeof s!="function")return null;var y=Br(Br({},e),{},{viewBox:p});if(M.isValidElement(s)){var{labelRef:b}=y,E=Y1e(y,X1e);return M.cloneElement(s,E)}if(typeof s=="function"){if(x=M.createElement(s,y),M.isValidElement(x))return x}else x=rwe(e);var w=na(e);if(D3(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return awe(e,r,x,w,p);v=swe(p,e.offset,e.position)}else v=owe(e,p);return M.createElement(ga,{zIndex:e.zIndex},M.createElement(RM,dc({ref:u,className:En("recharts-label",o)},w,v,{textAnchor:V1e(w.textAnchor)?w.textAnchor:v.textAnchor,breakAll:c}),x))}Ou.displayName="Label";var cwe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?M.createElement(Ou,dc({key:"label-implicit"},r)):uo(t)?M.createElement(Ou,dc({key:"label-implicit",value:t},r)):M.isValidElement(t)?t.type===Ou?M.cloneElement(t,Br({key:"label-implicit"},r)):M.createElement(Ou,dc({key:"label-implicit",content:t},r)):zD(t)?M.createElement(Ou,dc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?M.createElement(Ou,dc({},t,{key:"label-implicit"},r)):null};function BX(t){var{label:e,labelRef:n}=t,r=zX();return cwe(e,r,n)||null}var rC={},iC={},IB;function uwe(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(iC)),iC}var aC={},FB;function dwe(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(aC)),aC}var UB;function hwe(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uwe(),n=dwe(),r=mj();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(rC)),rC}var sC,zB;function fwe(){return zB||(zB=1,sC=hwe().last),sC}var mwe=fwe();const pwe=mo(mwe);var gwe=["valueAccessor"],xwe=["dataKey","clockWise","id","textBreakAll","zIndex"];function bw(){return bw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},bw.apply(null,arguments)}function BB(t,e){if(t==null)return{};var n,r,i=bwe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function bwe(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 ywe=t=>Array.isArray(t.value)?pwe(t.value):t.value,HX=M.createContext(void 0),BD=HX.Provider,$X=M.createContext(void 0),vwe=$X.Provider;function _we(){return M.useContext(HX)}function wwe(){return M.useContext($X)}function l1(t){var{valueAccessor:e=ywe}=t,n=BB(t,gwe),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:o}=n,c=BB(n,xwe),u=_we(),d=wwe(),f=u||d;return!f||!f.length?null:M.createElement(ga,{zIndex:o??Dr.label},M.createElement(Mr,{className:"recharts-label-list"},f.map((g,p)=>{var x,v=fr(r)?e(g,p):Hn(g&&g.payload,r),y=fr(a)?{}:{id:"".concat(a,"-").concat(p)};return M.createElement(Ou,bw({key:"label-".concat(p)},na(g),c,y,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:v,textBreakAll:s,viewBox:g.viewBox,index:p,zIndex:0}))})))}l1.displayName="LabelList";function jM(t){var{label:e}=t;return e?e===!0?M.createElement(l1,{key:"labelList-implicit"}):M.isValidElement(e)||zD(e)?M.createElement(l1,{key:"labelList-implicit",content:e}):typeof e=="object"?M.createElement(l1,bw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function O3(){return O3=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},O3.apply(null,arguments)}var VX=t=>{var{cx:e,cy:n,r,className:i}=t,a=En("recharts-dot",i);return Rt(e)&&Rt(n)&&Rt(r)?M.createElement("circle",O3({},ka(t),fj(t),{className:a,cx:e,cy:n,r})):null},GX=t=>t.graphicalItems.polarItems,Swe=Ke([br,Ob],uD),DM=Ke([GX,Ar,Swe],dD),Mwe=Ke([DM],hD),OM=Ke([Mwe,eD],fD),Ewe=Ke([OM,Ar,DM],pD);Ke([OM,Ar,DM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Hn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Hn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var HB=()=>{},Awe=Ke([OM,Ar,DM,CM,br],yD),Twe=Ke([Ar,xD,bD,HB,Awe,HB,xn,br],vD),WX=Ke([Ar,xn,OM,Ewe,Db,br,Twe],_D),Cwe=Ke([WX,Ar,og],MD);Ke([Ar,WX,Cwe,br],AD);var Nwe={radiusAxis:{},angleAxis:{}},qX=rs({name:"polarAxis",initialState:Nwe,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:lWe,removeRadiusAxis:cWe,addAngleAxis:uWe,removeAngleAxis:dWe}=qX.actions,kwe=qX.reducer;function $B(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function VB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$B(Object(n),!0).forEach(function(r){Pwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$B(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pwe(t,e,n){return(e=Rwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rwe(t){var e=jwe(t,"string");return typeof e=="symbol"?e:e+""}function jwe(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 Dwe=(t,e)=>e,HD=Ke([GX,Dwe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),Owe=[],$D=(t,e,n)=>n?.length===0?Owe:n,KX=Ke([eD,HD,$D],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>VB(VB({},e.presentationProps),a.props))),i!=null)return i}}),Lwe=Ke([KX,HD,$D],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Hn(r,e.nameKey,e.name),o;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:Ad(s,e.dataKey),color:o,payload:r,type:e.legendType}})}),Iwe=Ke([KX,HD,$D,bi],(t,e,n,r)=>{if(!(e==null||t==null))return FSe({offset:r,pieSettings:e,displayedData:t,cells:n})}),oC={exports:{}},qn={};var GB;function Fwe(){if(GB)return qn;GB=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(v){if(typeof v=="object"&&v!==null){var y=v.$$typeof;switch(y){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case g:return v;default:switch(v=v&&v.$$typeof,v){case s:case o:case f:case d:return v;case a:return v;default:return y}}case e:return y}}}return qn.ContextConsumer=a,qn.ContextProvider=s,qn.Element=t,qn.ForwardRef=o,qn.Fragment=n,qn.Lazy=f,qn.Memo=d,qn.Portal=e,qn.Profiler=i,qn.StrictMode=r,qn.Suspense=c,qn.SuspenseList=u,qn.isContextConsumer=function(v){return x(v)===a},qn.isContextProvider=function(v){return x(v)===s},qn.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},qn.isForwardRef=function(v){return x(v)===o},qn.isFragment=function(v){return x(v)===n},qn.isLazy=function(v){return x(v)===f},qn.isMemo=function(v){return x(v)===d},qn.isPortal=function(v){return x(v)===e},qn.isProfiler=function(v){return x(v)===i},qn.isStrictMode=function(v){return x(v)===r},qn.isSuspense=function(v){return x(v)===c},qn.isSuspenseList=function(v){return x(v)===u},qn.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===d||v.$$typeof===s||v.$$typeof===a||v.$$typeof===o||v.$$typeof===p||v.getModuleId!==void 0)},qn.typeOf=x,qn}var WB;function Uwe(){return WB||(WB=1,oC.exports=Fwe()),oC.exports}var zwe=Uwe(),qB=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",KB=null,lC=null,XX=t=>{if(t===KB&&Array.isArray(lC))return lC;var e=[];return M.Children.forEach(t,n=>{fr(n)||(zwe.isFragment(n)?e=e.concat(XX(n.props.children)):e.push(n))}),lC=e,KB=t,e};function VD(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>qB(i)):r=[qB(e)],XX(t).forEach(i=>{var a=Yh(i,"type.displayName")||Yh(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var GD=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,cC={},XB;function Bwe(){return XB||(XB=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})(cC)),cC}var uC,YB;function Hwe(){return YB||(YB=1,uC=Bwe().isPlainObject),uC}var $we=Hwe();const Vwe=mo($we);function ZB(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 QB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZB(Object(n),!0).forEach(function(r){Gwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gwe(t,e,n){return(e=Wwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wwe(t){var e=qwe(t,"string");return typeof e=="symbol"?e:e+""}function qwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yw(){return yw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yw.apply(null,arguments)}var JB=(t,e,n,r,i)=>{var a=n-r,s;return s="M ".concat(t,",").concat(e),s+="L ".concat(t+n,",").concat(e),s+="L ".concat(t+n-a/2,",").concat(e+i),s+="L ".concat(t+n-a/2-r,",").concat(e+i),s+="L ".concat(t,",").concat(e," Z"),s},Kwe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Xwe=t=>{var e=Er(t,Kwe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:s,className:o}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=M.useRef(null),[p,x]=M.useState(-1),v=M.useRef(i),y=M.useRef(a),b=M.useRef(s),E=M.useRef(n),w=M.useRef(r),A=tg(t,"trapezoid-");if(M.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&x(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var T=En("recharts-trapezoid",o);if(!f)return M.createElement("g",null,M.createElement("path",yw({},na(e),{className:T,d:JB(n,r,i,a,s)})));var C=v.current,k=y.current,F=b.current,N=E.current,j=w.current,I="0px ".concat(p===-1?1:p,"px"),O="".concat(p,"px 0px"),q=xq(["strokeDasharray"],u,c);return M.createElement(eg,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},R=>{var W=Dn(C,i,R),K=Dn(k,a,R),G=Dn(F,s,R),te=Dn(N,n,R),Y=Dn(j,r,R);g.current&&(v.current=W,y.current=K,b.current=G,E.current=te,w.current=Y);var J=R>0?{transition:q,strokeDasharray:O}:{strokeDasharray:I};return M.createElement("path",yw({},na(e),{className:T,d:JB(te,Y,W,K,G),ref:g,style:QB(QB({},J),e.style)}))})},Ywe=["option","shapeType","propTransformer","activeClassName"];function Zwe(t,e){if(t==null)return{};var n,r,i=Qwe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Qwe(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 e6(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 vw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e6(Object(n),!0).forEach(function(r){Jwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jwe(t,e,n){return(e=eSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eSe(t){var e=tSe(t,"string");return typeof e=="symbol"?e:e+""}function tSe(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 nSe(t,e){return vw(vw({},e),t)}function rSe(t,e){return t==="symbols"}function t6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return M.createElement(_q,n);case"trapezoid":return M.createElement(Xwe,n);case"sector":return M.createElement(Eq,n);case"symbols":if(rSe(e))return M.createElement(hj,n);break;case"curve":return M.createElement(rp,n);default:return null}}function iSe(t){return M.isValidElement(t)?t.props:t}function WD(t){var{option:e,shapeType:n,propTransformer:r=nSe,activeClassName:i="recharts-active-shape"}=t,a=Zwe(t,Ywe),s;if(M.isValidElement(e))s=M.cloneElement(e,vw(vw({},a),iSe(e)));else if(typeof e=="function")s=e(a,a.index);else if(Vwe(e)&&typeof e!="boolean"){var o=r(e,a);s=M.createElement(t6,{shapeType:n,elementProps:o})}else{var c=a;s=M.createElement(t6,{shapeType:n,elementProps:c})}return a.isActive?M.createElement(Mr,{className:i},s):s}var qD=(t,e,n)=>{var r=ir();return(i,a)=>s=>{t?.(i,a,s),r(sX({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},KD=t=>{var e=ir();return(n,r)=>i=>{t?.(n,r,i),e(yve())}},XD=(t,e,n)=>{var r=ir();return(i,a)=>s=>{t?.(i,a,s),r(vve({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function LM(t){var{tooltipEntrySettings:e}=t,n=ir(),r=yi(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(pve(e)):i.current!==e&&n(gve({prev:i.current,next:e})),i.current=e)},[e,n,r]),M.useLayoutEffect(()=>()=>{i.current&&(n(xve(i.current)),i.current=null)},[n]),null}function YD(t){var{legendPayload:e}=t,n=ir(),r=yi(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(fq(e)):i.current!==e&&n(mq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(pq(i.current)),i.current=null)},[n]),null}function aSe(t){var{legendPayload:e}=t,n=ir(),r=kt(xn),i=M.useRef(null);return M.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(fq(e)):i.current!==e&&n(mq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(pq(i.current)),i.current=null)},[n]),null}var dC,sSe=()=>{var[t]=M.useState(()=>C0("uid-"));return t},oSe=(dC=Dre.useId)!==null&&dC!==void 0?dC:sSe;function YX(t,e){var n=oSe();return e||(t?"".concat(t,"-").concat(n):n)}var lSe=M.createContext(void 0),IM=t=>{var{id:e,type:n,children:r}=t,i=YX("recharts-".concat(n),e);return M.createElement(lSe.Provider,{value:i},r(i))},cSe={cartesianItems:[],polarItems:[]},ZX=rs({name:"graphicalItems",initialState:cSe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:pr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:pr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Lo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:pr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:pr()},removePolarGraphicalItem:{reducer(t,e){var n=Lo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:pr()}}}),{addCartesianGraphicalItem:uSe,replaceCartesianGraphicalItem:dSe,removeCartesianGraphicalItem:hSe,addPolarGraphicalItem:fSe,removePolarGraphicalItem:mSe}=ZX.actions,pSe=ZX.reducer,gSe=t=>{var e=ir(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(uSe(t)):n.current!==t&&e(dSe({prev:n.current,next:t})),n.current=t},[e,t]),M.useLayoutEffect(()=>()=>{n.current&&(e(hSe(n.current)),n.current=null)},[e]),null},ZD=M.memo(gSe);function xSe(t){var e=ir();return M.useLayoutEffect(()=>(e(fSe(t)),()=>{e(mSe(t))}),[e,t]),null}var bSe=["key"],ySe=["onMouseEnter","onClick","onMouseLeave"],vSe=["id"],_Se=["id"];function n6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Rr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n6(Object(n),!0).forEach(function(r){wSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wSe(t,e,n){return(e=SSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SSe(t){var e=MSe(t,"string");return typeof e=="symbol"?e:e+""}function MSe(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 xd(){return xd=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},xd.apply(null,arguments)}function FM(t,e){if(t==null)return{};var n,r,i=ESe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ESe(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 ASe(t){var e=M.useMemo(()=>VD(t.children,Gb),[t.children]),n=kt(r=>Lwe(r,t.id,e));return n==null?null:M.createElement(aSe,{legendPayload:n})}var TSe=M.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:s,name:o,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:Ad(o,e),hide:c,type:u,color:s,unit:""}};return M.createElement(LM,{tooltipEntrySettings:d})}),CSe=(t,e)=>t>e?"start":t<e?"end":"middle",NSe=(t,e,n)=>ma(typeof e=="function"?e(t):e,n,n*.8),kSe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,o=wq(a,s),c=i+ma(t.cx,a,a/2),u=r+ma(t.cy,s,s/2),d=ma(t.innerRadius,o,0),f=NSe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},PSe=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function RSe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var jSe=(t,e)=>{if(M.isValidElement(t))return M.cloneElement(t,e);if(typeof t=="function")return t(e);var n=En("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=FM(e,bSe);return M.createElement(rp,xd({},i,{type:"linear",className:n}))},DSe=(t,e,n)=>{if(M.isValidElement(t))return M.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),M.isValidElement(r)))return r;var i=En("recharts-pie-label-text",RSe(t));return M.createElement(RM,xd({},e,{alignmentBaseline:"middle",className:i}),r)};function OSe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var o=ka(n),c=Xh(i),u=Xh(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,p)=>{var x=(g.startAngle+g.endAngle)/2,v=ti(g.cx,g.cy,g.outerRadius+d,x),y=Rr(Rr(Rr(Rr({},o),g),{},{stroke:"none"},c),{},{index:p,textAnchor:CSe(v.x,g.cx)},v),b=Rr(Rr(Rr(Rr({},o),g),{},{fill:"none",stroke:g.fill},u),{},{index:p,points:[ti(g.cx,g.cy,g.outerRadius,x),v],key:"line"});return M.createElement(ga,{zIndex:Dr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(p)},M.createElement(Mr,null,a&&jSe(a,b),DSe(i,y,Hn(g,s))))});return M.createElement(Mr,{className:"recharts-pie-labels"},f)}function LSe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?M.createElement(jM,{label:i}):M.createElement(OSe,{sectors:e,props:n,showLabels:r})}function ISe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,o=kt(gd),c=kt(OD),u=kt(a_e),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,p=FM(i,ySe),x=qD(d,i.dataKey,s),v=KD(g),y=XD(f,i.dataKey,s);return e==null||e.length===0?null:M.createElement(M.Fragment,null,e.map((b,E)=>{if(b?.startAngle===0&&b?.endAngle===0&&e.length!==1)return null;var w=u==null||u===s,A=String(E)===o&&(c==null||i.dataKey===c)&&w,T=o?r:null,C=n&&A?n:T,k=Rr(Rr({},b),{},{stroke:b.stroke,tabIndex:-1,[JW]:E,[eq]:i.dataKey});return M.createElement(Mr,xd({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},wb(p,b,E),{onMouseEnter:x(b,E),onMouseLeave:v(b,E),onClick:y(b,E)}),M.createElement(WD,xd({option:a??C,index:E,shapeType:"sector",isActive:A},k)))}))}function FSe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:s,startAngle:o,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),p=PSe(o,c),x=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,y=r.filter(C=>Hn(C,u,0)!==0).length,b=(x>=360?y:y-1)*v,E=x-y*g-b,w=r.reduce((C,k)=>{var F=Hn(k,u,0);return C+(Rt(F)?F:0)},0),A;if(w>0){var T;A=r.map((C,k)=>{var F=Hn(C,u,0),N=Hn(C,d,k),j=kSe(n,a,C),I=(Rt(F)?F:0)/w,O,q=Rr(Rr({},C),i&&i[k]&&i[k].props);k?O=T.endAngle+Li(p)*v*(F!==0?1:0):O=o;var R=O+Li(p)*((F!==0?g:0)+I*E),W=(O+R)/2,K=(j.innerRadius+j.outerRadius)/2,G=[{name:N,value:F,payload:q,dataKey:u,type:f}],te=ti(j.cx,j.cy,K,W);return T=Rr(Rr(Rr(Rr({},n.presentationProps),{},{percent:I,cornerRadius:typeof s=="string"?parseFloat(s):s,name:N,tooltipPayload:G,midAngle:W,middleRadius:K,tooltipPosition:te},q),j),{},{value:F,dataKey:u,startAngle:O,endAngle:R,payload:q,paddingAngle:Li(p)*v}),T})}return A}function USe(t){var{showLabels:e,sectors:n,children:r}=t,i=M.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return M.createElement(vwe,{value:e?i:void 0},r)}function zSe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,p=tg(e,"recharts-pie-"),x=n.current,[v,y]=M.useState(!1),b=M.useCallback(()=>{typeof g=="function"&&g(),y(!1)},[g]),E=M.useCallback(()=>{typeof f=="function"&&f(),y(!0)},[f]);return M.createElement(USe,{showLabels:!v,sectors:i},M.createElement(eg,{animationId:p,begin:s,duration:o,isActive:a,easing:c,onAnimationStart:E,onAnimationEnd:b,key:p},w=>{var A=[],T=i&&i[0],C=T?.startAngle;return i?.forEach((k,F)=>{var N=x&&x[F],j=F>0?Yh(k,"paddingAngle",0):0;if(N){var I=Dn(N.endAngle-N.startAngle,k.endAngle-k.startAngle,w),O=Rr(Rr({},k),{},{startAngle:C+j,endAngle:C+I+j});A.push(O),C=O.endAngle}else{var{endAngle:q,startAngle:R}=k,W=Dn(0,q-R,w),K=Rr(Rr({},k),{},{startAngle:C+j,endAngle:C+W+j});A.push(K),C=K.endAngle}}),n.current=A,M.createElement(Mr,null,M.createElement(ISe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),M.createElement(LSe,{showLabels:!v,sectors:i,props:e}),e.children)}var BSe={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:Dr.area};function HSe(t){var{id:e}=t,n=FM(t,vSe),{hide:r,className:i,rootTabIndex:a}=t,s=M.useMemo(()=>VD(t.children,Gb),[t.children]),o=kt(d=>Iwe(d,e,s)),c=M.useRef(null),u=En("recharts-pie",i);return r||o==null?(c.current=null,M.createElement(Mr,{tabIndex:a,className:u})):M.createElement(ga,{zIndex:t.zIndex},M.createElement(TSe,{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}),M.createElement(Mr,{tabIndex:a,className:u},M.createElement(zSe,{props:Rr(Rr({},n),{},{sectors:o}),previousSectorsRef:c,id:e})))}function QX(t){var e=Er(t,BSe),{id:n}=e,r=FM(e,_Se),i=ka(r);return M.createElement(IM,{id:n,type:"pie"},a=>M.createElement(M.Fragment,null,M.createElement(xSe,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),M.createElement(ASe,xd({},r,{id:a})),M.createElement(HSe,xd({},r,{id:a}))))}QX.displayName="Pie";var $Se=["points"];function r6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r6(Object(n),!0).forEach(function(r){VSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VSe(t,e,n){return(e=GSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GSe(t){var e=WSe(t,"string");return typeof e=="symbol"?e:e+""}function WSe(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 _w(){return _w=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},_w.apply(null,arguments)}function qSe(t,e){if(t==null)return{};var n,r,i=KSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function KSe(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 XSe(t){var{option:e,dotProps:n,className:r}=t;if(M.isValidElement(e))return M.cloneElement(e,n);if(typeof e=="function")return e(n);var i=En(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,o=qSe(a,$Se);return M.createElement(VX,_w({},o,{className:i}))}function YSe(t,e){return t==null?!1:e?!0:t.length===1}function JX(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:o,clipPathId:c,zIndex:u=Dr.scatter}=t;if(!YSe(e,n))return null;var d=GD(n),f=Tde(n),g=e.map((x,v)=>{var y,b,E=hC(hC(hC({r:3},s),f),{},{index:v,cx:(y=x.x)!==null&&y!==void 0?y:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return M.createElement(XSe,{key:"dot-".concat(v),option:n,dotProps:E,className:i})}),p={};return o&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),M.createElement(ga,{zIndex:u},M.createElement(Mr,_w({className:r},p),g))}function i6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function a6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i6(Object(n),!0).forEach(function(r){ZSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZSe(t,e,n){return(e=QSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QSe(t){var e=JSe(t,"string");return typeof e=="symbol"?e:e+""}function JSe(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 eMe={xAxis:{},yAxis:{},zAxis:{}},eY=rs({name:"cartesianAxis",initialState:eMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:pr()},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:pr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:pr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:pr()},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:pr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:pr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:pr()},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:pr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:pr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var s=[...a,r].slice(-3);t.yAxis[n]=a6(a6({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:tMe,replaceXAxis:nMe,removeXAxis:rMe,addYAxis:iMe,replaceYAxis:aMe,removeYAxis:sMe,addZAxis:hWe,replaceZAxis:fWe,removeZAxis:mWe,updateYAxisWidth:oMe}=eY.actions,lMe=eY.reducer,cMe=Ke([bi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),uMe=Ke([cMe,Vc,Gc],(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)}}),UM=()=>kt(uMe),dMe=()=>kt(u_e);function s6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s6(Object(n),!0).forEach(function(r){hMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hMe(t,e,n){return(e=fMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fMe(t){var e=mMe(t,"string");return typeof e=="symbol"?e:e+""}function mMe(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 pMe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:s}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=fC(fC(fC({},o),Xh(i)),fj(i)),u;return M.isValidElement(i)?u=M.cloneElement(i,c):typeof i=="function"?u=i(c):u=M.createElement(VX,c),M.createElement(Mr,{className:"recharts-active-dot",clipPath:s},u)};function L3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=Dr.activeDot}=t,o=kt(gd),c=dMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return fr(u)?null:M.createElement(ga,{zIndex:s},M.createElement(pMe,{point:u,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var gMe="Invariant failed";function xMe(t,e){throw new Error(gMe)}var bMe=["x","y"];function I3(){return I3=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},I3.apply(null,arguments)}function o6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o6(Object(n),!0).forEach(function(r){yMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yMe(t,e,n){return(e=vMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vMe(t){var e=_Me(t,"string");return typeof e=="symbol"?e:e+""}function _Me(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 wMe(t,e){if(t==null)return{};var n,r,i=SMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function SMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function MMe(t,e){var{x:n,y:r}=t,i=wMe(t,bMe),a="".concat(n),s=parseInt(a,10),o="".concat(r),c=parseInt(o,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return bx(bx(bx(bx(bx({},e),i),s?{x:s}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function ww(t){return M.createElement(WD,I3({shapeType:"rectangle",propTransformer:MMe,activeClassName:"recharts-active-bar"},t))}var EMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Rt(e))return e;var a=Rt(r)||fr(r);return a?e(r,i):(a||xMe(),n)}},AMe={},tY=rs({name:"errorBars",initialState:AMe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:pWe,replaceErrorBar:gWe,removeErrorBar:xWe}=tY.actions,TMe=tY.reducer,CMe=["children"];function NMe(t,e){if(t==null)return{};var n,r,i=kMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function kMe(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 PMe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},RMe=M.createContext(PMe);function nY(t){var{children:e}=t,n=NMe(t,CMe);return M.createElement(RMe.Provider,{value:n},e)}function zM(t,e){var n,r,i=kt(u=>Ml(u,t)),a=kt(u=>El(u,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Pi.allowDataOverflow,o=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Ri.allowDataOverflow,c=s||o;return{needClip:c,needClipX:s,needClipY:o}}function QD(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=UM(),{needClipX:a,needClipY:s,needClip:o}=zM(e,n);if(!o||!i)return null;var{x:c,y:u,width:d,height:f}=i;return M.createElement("clipPath",{id:"clipPath-".concat(r)},M.createElement("rect",{x:a?c:c-d/2,y:s?u:u-f/2,width:a?d:d*2,height:s?f:f*2}))}function jMe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&$n(t.zIndex)?t.zIndex:e}var mC={exports:{}},pC={};var l6;function DMe(){if(l6)return pC;l6=1;var t=qp();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,o=t.useDebugValue;return pC.useSyncExternalStoreWithSelector=function(c,u,d,f,g){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=s(function(){function y(T){if(!b){if(b=!0,E=T,T=f(T),g!==void 0&&x.hasValue){var C=x.value;if(g(C,T))return w=C}return w=T}if(C=w,n(E,T))return C;var k=f(T);return g!==void 0&&g(C,k)?(E=T,C):(E=T,w=k)}var b=!1,E,w,A=d===void 0?null:d;return[function(){return y(u())},A===null?void 0:function(){return y(A())}]},[u,d,f,g]);var v=r(c,p[0],p[1]);return a(function(){x.hasValue=!0,x.value=v},[v]),o(v),v},pC}var c6;function OMe(){return c6||(c6=1,mC.exports=DMe()),mC.exports}OMe();function LMe(t){t()}function IMe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){LMe(()=>{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 u6={notify(){},get:()=>[]};function FMe(t,e){let n,r=u6,i=0,a=!1;function s(v){d();const y=r.subscribe(v);let b=!1;return()=>{b||(b=!0,y(),f())}}function o(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=IMe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=u6)}function g(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const x={addNestedSub:s,notifyNestedSubs:o,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:p,getListeners:()=>r};return x}var UMe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",zMe=UMe(),BMe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",HMe=BMe(),$Me=()=>zMe||HMe?M.useLayoutEffect:M.useEffect,VMe=$Me();function d6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function GMe(t,e){if(d6(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])||!d6(t[n[i]],e[n[i]]))return!1;return!0}var WMe=Symbol.for("react-redux-context"),qMe=typeof globalThis<"u"?globalThis:{};function KMe(){if(!M.createContext)return{};const t=qMe[WMe]??=new Map;let e=t.get(M.createContext);return e||(e=M.createContext(null),t.set(M.createContext,e)),e}var XMe=KMe();function YMe(t){const{children:e,context:n,serverState:r,store:i}=t,a=M.useMemo(()=>{const c=FMe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),s=M.useMemo(()=>i.getState(),[i]);VMe(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),s!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,s]);const o=n||XMe;return M.createElement(o.Provider,{value:a},e)}var ZMe=YMe,QMe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function JMe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Wb(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(QMe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!GMe(t[r],e[r]))return!1}else if(!JMe(t[r],e[r]))return!1;return!0}var eEe=["onMouseEnter","onMouseLeave","onClick"],tEe=["value","background","tooltipPosition"],nEe=["id"],rEe=["onMouseEnter","onClick","onMouseLeave"];function Uc(){return Uc=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},Uc.apply(null,arguments)}function h6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ma(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h6(Object(n),!0).forEach(function(r){iEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iEe(t,e,n){return(e=aEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aEe(t){var e=sEe(t,"string");return typeof e=="symbol"?e:e+""}function sEe(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 Sw(t,e){if(t==null)return{};var n,r,i=oEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function oEe(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 lEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Ad(n,e),payload:t}]},cEe=M.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:o,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Ad(a,e),hide:s,type:c,color:i,unit:o}};return M.createElement(LM,{tooltipEntrySettings:u})});function uEe(t){var e=kt(gd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:o,onClick:c}=a,u=Sw(a,eEe),d=qD(s,r),f=KD(o),g=XD(c,r);if(!i||n==null)return null;var p=Xh(i);return M.createElement(ga,{zIndex:jMe(i,Dr.barBackground)},n.map((x,v)=>{var{value:y,background:b,tooltipPosition:E}=x,w=Sw(x,tEe);if(!b)return null;var A=d(x,v),T=f(x,v),C=g(x,v),k=Ma(Ma(Ma(Ma(Ma({option:i,isActive:String(v)===e},w),{},{fill:"#eee"},b),p),wb(u,x,v)),{},{onMouseEnter:A,onMouseLeave:T,onClick:C,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return M.createElement(ww,Uc({key:"background-bar-".concat(v)},k))}))}function dEe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var s={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Ma(Ma({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return M.createElement(BD,{value:e?i:void 0},n)}function hEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,o=kt(gd),c=kt(OD),u=n&&String(a)===o&&(c==null||s===c),d=u?n:e;return u?M.createElement(ga,{zIndex:Dr.activeBar},M.createElement(ww,Uc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))):M.createElement(ww,Uc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))}function fEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return M.createElement(ww,Uc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function mEe(t){var e,{data:n,props:r}=t,i=(e=ka(r))!==null&&e!==void 0?e:{},{id:a}=i,s=Sw(i,nEe),{shape:o,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,p=Sw(r,rEe),x=qD(d,c),v=KD(g),y=XD(f,c);return n?M.createElement(M.Fragment,null,n.map((b,E)=>M.createElement(Mr,Uc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(E),className:"recharts-bar-rectangle"},wb(p,b,E),{onMouseEnter:x(b,E),onMouseLeave:v(b,E),onClick:y(b,E)}),u?M.createElement(hEe,{shape:o,activeBar:u,baseProps:s,entry:b,index:E,dataKey:c}):M.createElement(fEe,{shape:o,baseProps:s,entry:b,index:E,dataKey:c})))):null}function pEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=tg(e,"recharts-bar-"),[p,x]=M.useState(!1),v=!p,y=M.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),b=M.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return M.createElement(dEe,{showLabels:v,rects:r},M.createElement(eg,{animationId:g,begin:s,duration:o,isActive:a,easing:c,onAnimationEnd:y,onAnimationStart:b,key:g},E=>{var w=E===1?r:r?.map((A,T)=>{var C=f&&f[T];if(C)return Ma(Ma({},A),{},{x:Dn(C.x,A.x,E),y:Dn(C.y,A.y,E),width:Dn(C.width,A.width,E),height:Dn(C.height,A.height,E)});if(i==="horizontal"){var k=Dn(0,A.height,E),F=Dn(A.stackedBarStart,A.y,E);return Ma(Ma({},A),{},{y:F,height:k})}var N=Dn(0,A.width,E),j=Dn(A.stackedBarStart,A.x,E);return Ma(Ma({},A),{},{width:N,x:j})});return E>0&&(n.current=w??null),w==null?null:M.createElement(Mr,null,M.createElement(mEe,{props:e,data:w}))}),M.createElement(jM,{label:e.label}),e.children)}function gEe(t){var e=M.useRef(null);return M.createElement(pEe,{previousRectanglesRef:e,props:t})}var rY=0,xEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Hn(t,e)}};class bEe extends M.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:s,needClip:o,background:c,id:u}=this.props;if(e||n==null)return null;var d=En("recharts-bar",i),f=u;return M.createElement(Mr,{className:d,id:u},o&&M.createElement("defs",null,M.createElement(QD,{clipPathId:f,xAxisId:a,yAxisId:s})),M.createElement(Mr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},M.createElement(uEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),M.createElement(gEe,this.props)))}}var yEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:rY,xAxisId:0,yAxisId:0,zIndex:Dr.bar};function vEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=zM(e,n),g=mf(),p=yi(),x=VD(t.children,Gb),v=kt(E=>KEe(E,e,n,p,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var y,b=v?.[0];return b==null||b.height==null||b.width==null?y=0:y=g==="vertical"?b.height/2:b.width/2,M.createElement(nY,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:xEe,errorBarOffset:y},M.createElement(bEe,Uc({},t,{layout:g,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function _Ee(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:s,yAxis:o,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:p,parentViewBox:x,dataStartIndex:v}=t,y=e==="horizontal"?o:s,b=d?y.scale.domain():null,E=Vme({numericAxis:y}),w=y.scale(E);return f.map((A,T)=>{var C,k,F,N,j,I;d?C=Ume(d[T+v],b):(C=Hn(A,n),Array.isArray(C)||(C=[E,C]));var O=EMe(r,rY)(C[1],T);if(e==="horizontal"){var q,[R,W]=[o.scale(C[0]),o.scale(C[1])];k=Nz({axis:s,ticks:c,bandSize:a,offset:i.offset,entry:A,index:T}),F=(q=W??R)!==null&&q!==void 0?q:void 0,N=i.size;var K=R-W;if(j=ns(K)?0:K,I={x:k,y:g.top,width:N,height:g.height},Math.abs(O)>0&&Math.abs(j)<Math.abs(O)){var G=Li(j||O)*(Math.abs(O)-Math.abs(j));F-=G,j+=G}}else{var[te,Y]=[s.scale(C[0]),s.scale(C[1])];if(k=te,F=Nz({axis:o,ticks:u,bandSize:a,offset:i.offset,entry:A,index:T}),N=Y-te,j=i.size,I={x:g.left,y:F,width:g.width,height:j},Math.abs(O)>0&&Math.abs(N)<Math.abs(O)){var J=Li(N||O)*(Math.abs(O)-Math.abs(N));N+=J}}if(k==null||F==null||N==null||j==null)return null;var U=Ma(Ma({},A),{},{stackedBarStart:w,x:k,y:F,width:N,height:j,value:d?C:C[1],payload:A,background:I,tooltipPosition:{x:k+N/2,y:F+j/2},parentViewBox:x},p&&p[T]&&p[T].props);return U}).filter(Boolean)}function wEe(t){var e=Er(t,yEe),n=yi();return M.createElement(IM,{id:e.id,type:"bar"},r=>M.createElement(M.Fragment,null,M.createElement(YD,{legendPayload:lEe(e)}),M.createElement(cEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),M.createElement(ZD,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:ZW(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),M.createElement(ga,{zIndex:e.zIndex},M.createElement(vEe,Uc({},e,{id:r})))))}var iY=M.memo(wEe,Wb);iY.displayName="Bar";function f6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Dv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f6(Object(n),!0).forEach(function(r){SEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SEe(t,e,n){return(e=MEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MEe(t){var e=EEe(t,"string");return typeof e=="symbol"?e:e+""}function EEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var AEe=(t,e)=>e,TEe=(t,e,n)=>n,CEe=(t,e,n,r)=>r,NEe=(t,e,n,r,i)=>i,qb=Ke([Ib,NEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),kEe=Ke([qb],t=>t?.maxBarSize),PEe=(t,e,n,r,i,a)=>a,m6=(t,e,n)=>{var r=n??t;if(!fr(r))return ma(r,e,0)},REe=Ke([xn,Ib,AEe,TEe,CEe],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),jEe=(t,e,n,r)=>{var i=xn(t);return i==="horizontal"?B0(t,"yAxis",n,r):B0(t,"xAxis",e,r)},DEe=(t,e,n)=>{var r=xn(t);return r==="horizontal"?lB(t,"xAxis",e):lB(t,"yAxis",n)},OEe=(t,e,n)=>{var r={},i=t.filter(MM),a=t.filter(u=>u.stackId==null),s=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),o=Object.entries(s).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),p=m6(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:p}}),c=a.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=m6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...o,...c]},LEe=Ke([REe,oye,DEe],OEe),IEe=(t,e,n,r,i)=>{var a,s,o=qb(t,e,n,r,i);if(o!=null){var c=xn(t),u=_K(t),{maxBarSize:d}=o,f=fr(d)?u:d,g,p;return c==="horizontal"?(g=gl(t,"xAxis",e,r),p=pl(t,"xAxis",e,r)):(g=gl(t,"yAxis",n,r),p=pl(t,"yAxis",n,r)),(a=(s=fd(g,p,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},aY=(t,e,n,r)=>{var i=xn(t),a,s;return i==="horizontal"?(a=gl(t,"xAxis",e,r),s=pl(t,"xAxis",e,r)):(a=gl(t,"yAxis",n,r),s=pl(t,"yAxis",n,r)),fd(a,s)};function FEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=ma(t,n,0,!0),o,c=[];if($n(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((b,E)=>b+(E.barSize||0),0);f+=(a-1)*s,f>=n&&(f-=(a-1)*s,s=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var g=(n-f)/2>>0,p={offset:g-s,size:0};o=r.reduce((b,E)=>{var w,A={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:p.offset+p.size+s,size:u?d:(w=E.barSize)!==null&&w!==void 0?w:0}},T=[...b,A];return p=T[T.length-1].position,T},c)}else{var x=ma(e,n,0,!0);n-2*x-(a-1)*s<=0&&(s=0);var v=(n-2*x-(a-1)*s)/a;v>1&&(v>>=0);var y=$n(i)?Math.min(v,i):v;o=r.reduce((b,E,w)=>[...b,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(v+s)*w+(v-y)/2,size:y}}],c)}return o}}var UEe=(t,e,n,r,i,a,s)=>{var o=fr(s)?e:s,c=FEe(n,r,i!==a?i:a,t,o);return i!==a&&c!=null&&(c=c.map(u=>Dv(Dv({},u),{},{position:Dv(Dv({},u.position),{},{offset:u.position.offset-i/2})}))),c},zEe=Ke([LEe,_K,sye,wK,IEe,aY,kEe],UEe),BEe=(t,e,n,r)=>gl(t,"xAxis",e,r),HEe=(t,e,n,r)=>gl(t,"yAxis",n,r),$Ee=(t,e,n,r)=>pl(t,"xAxis",e,r),VEe=(t,e,n,r)=>pl(t,"yAxis",n,r),GEe=Ke([zEe,qb],(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}}),WEe=(t,e)=>{var n=SM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(s=>s.key===n)}}}},qEe=Ke([jEe,qb],WEe),KEe=Ke([bi,Mj,BEe,HEe,$Ee,VEe,GEe,xn,jb,aY,qEe,qb,PEe],(t,e,n,r,i,a,s,o,c,u,d,f,g)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:v}=c;if(!(f==null||s==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:y}=f,b;if(y!=null&&y.length>0?b=y:b=p?.slice(x,v+1),b!=null)return _Ee({layout:o,barSettings:f,pos:s,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:b,offset:t,cells:g,dataStartIndex:x})}}),sY=t=>{var{chartData:e}=t,n=ir(),r=yi();return M.useEffect(()=>r?()=>{}:(n(_B(e)),()=>{n(_B(void 0))}),[e,n,r]),null},p6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},oY=rs({name:"brush",initialState:p6,reducers:{setBrushSettings(t,e){return e.payload==null?p6:e.payload}}}),{setBrushSettings:bWe}=oY.actions,XEe=oY.reducer;function g6(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 Ov(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g6(Object(n),!0).forEach(function(r){lY(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lY(t,e,n){return(e=YEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YEe(t){var e=ZEe(t,"string");return typeof e=="symbol"?e:e+""}function ZEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var QEe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},JEe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return QEe({x:e,y:n},{x:r,y:i})};class BM{static create(e){return new BM(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var s=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+s}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}lY(BM,"EPS",1e-4);var e2e=t=>{var e=Object.keys(t).reduce((n,r)=>Ov(Ov({},n),{},{[r]:BM.create(t[r])}),{});return Ov(Ov({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[s,o]=a;return[s,e[s].apply(o,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function t2e(t){return(t%180+180)%180}var n2e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=t2e(i),s=a*Math.PI/180,o=Math.atan(r/n),c=s>o&&s<Math.PI-o?r/Math.sin(s):n/Math.cos(s);return Math.abs(c)},r2e={dots:[],areas:[],lines:[]},cY=rs({name:"referenceElements",initialState:r2e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Lo(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=Lo(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=Lo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:yWe,removeDot:vWe,addArea:_We,removeArea:wWe,addLine:i2e,removeLine:a2e}=cY.actions,s2e=cY.reducer,uY=M.createContext(void 0),o2e=t=>{var{children:e}=t,[n]=M.useState("".concat(C0("recharts"),"-clip")),r=UM();if(r==null)return null;var{x:i,y:a,width:s,height:o}=r;return M.createElement(uY.Provider,{value:n},M.createElement("defs",null,M.createElement("clipPath",{id:n},M.createElement("rect",{x:i,y:a,height:o,width:s}))),e)},l2e=()=>M.useContext(uY);function x6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function b6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x6(Object(n),!0).forEach(function(r){c2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function c2e(t,e,n){return(e=u2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u2e(t){var e=d2e(t,"string");return typeof e=="symbol"?e:e+""}function d2e(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 Mw(){return Mw=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},Mw.apply(null,arguments)}var h2e=(t,e)=>{var n;if(M.isValidElement(t))n=M.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!$n(e.x1)||!$n(e.y1)||!$n(e.x2)||!$n(e.y2))return null;n=M.createElement("line",Mw({},e,{className:"recharts-reference-line-line"}))}return n},f2e=(t,e,n,r,i,a)=>{var{x:s,width:o}=a,c=i.y.apply(t,{position:n});if(ns(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:s+o,y:c},{x:s,y:c}];return r==="left"?u.reverse():u},m2e=(t,e,n,r,i,a)=>{var{y:s,height:o}=a,c=i.x.apply(t,{position:n});if(ns(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:s+o},{x:c,y:s}];return r==="top"?u.reverse():u},p2e=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},g2e=(t,e,n,r,i,a)=>{var{x:s,y:o,segment:c,ifOverflow:u}=a,d=uo(s),f=uo(o);return f?f2e(o,u,n,i,t,e):d?m2e(s,u,n,r,t,e):c!=null&&c.length===2?p2e(c,u,n,t):null};function x2e(t){var e=ir();return M.useEffect(()=>(e(i2e(t)),()=>{e(a2e(t))})),null}function b2e(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,s=yi(),o=l2e(),c=kt(C=>Ml(C,e)),u=kt(C=>El(C,n)),d=kt(C=>pd(C,"xAxis",e,s)),f=kt(C=>pd(C,"yAxis",n,s)),g=Tb();if(!o||!g||c==null||u==null||d==null||f==null)return null;var p=e2e({x:d,y:f}),x=g2e(p,g,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:v,y},{x:b,y:E}]=x,w=a==="hidden"?"url(#".concat(o,")"):void 0,A=b6(b6({clipPath:w},na(t)),{},{x1:v,y1:y,x2:b,y2:E}),T=JEe({x1:v,y1:y,x2:b,y2:E});return M.createElement(ga,{zIndex:t.zIndex},M.createElement(Mr,{className:En("recharts-reference-line",i)},h2e(r,A),M.createElement(UX,Mw({},T,{lowerWidth:T.width,upperWidth:T.width}),M.createElement(BX,{label:t.label}),t.children)))}var y2e={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Dr.line};function Ux(t){var e=Er(t,y2e);return M.createElement(M.Fragment,null,M.createElement(x2e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),M.createElement(b2e,e))}Ux.displayName="ReferenceLine";function dY(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 v2e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return n2e(r,n)}function _2e(t,e,n){var r=n==="width",{x:i,y:a,width:s,height:o}=t;return e===1?{start:r?i:a,end:r?i+s:a+o}:{start:r?i+s:a+o,end:r?i:a}}function Ew(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function w2e(t,e){return dY(t,e+1)}function S2e(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:o}=e,c=0,u=1,d=s,f=function(){var x=r?.[c];if(x===void 0)return{v:dY(r,u)};var v=c,y,b=()=>(y===void 0&&(y=n(x,v)),y),E=x.coordinate,w=c===0||Ew(t,E,b,d,o);w||(c=0,d=s,u+=1),w&&(d=E+t*(b()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}function y6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ua(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y6(Object(n),!0).forEach(function(r){M2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function M2e(t,e,n){return(e=E2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function E2e(t){var e=A2e(t,"string");return typeof e=="symbol"?e:e+""}function A2e(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 T2e(t,e,n,r,i){for(var a=(r||[]).slice(),s=a.length,{start:o}=e,{end:c}=e,u=function(g){var p=a[g],x,v=()=>(x===void 0&&(x=n(p,g)),x);if(g===s-1){var y=t*(p.coordinate+t*v()/2-c);a[g]=p=ua(ua({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate})}else a[g]=p=ua(ua({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var b=Ew(t,p.tickCoord,v,o,c);b&&(c=p.tickCoord-t*(v()/2+i),a[g]=ua(ua({},p),{},{isShow:!0}))}},d=s-1;d>=0;d--)u(d);return a}function C2e(t,e,n,r,i,a){var s=(r||[]).slice(),o=s.length,{start:c,end:u}=e;if(a){var d=r[o-1],f=n(d,o-1),g=t*(d.coordinate+t*f/2-u);if(s[o-1]=d=ua(ua({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var p=Ew(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),s[o-1]=ua(ua({},d),{},{isShow:!0}))}}for(var x=a?o-1:o,v=function(E){var w=s[E],A,T=()=>(A===void 0&&(A=n(w,E)),A);if(E===0){var C=t*(w.coordinate-t*T()/2-c);s[E]=w=ua(ua({},w),{},{tickCoord:C<0?w.coordinate-C*t:w.coordinate})}else s[E]=w=ua(ua({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var k=Ew(t,w.tickCoord,T,c,u);k&&(c=w.tickCoord+t*(T()/2+i),s[E]=ua(ua({},w),{},{isShow:!0}))}},y=0;y<x;y++)v(y);return s}function JD(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:s,orientation:o,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Rt(c)||Jp.isSsr){var g;return(g=w2e(i,Rt(c)?c:0))!==null&&g!==void 0?g:[]}var p=[],x=o==="top"||o==="bottom"?"width":"height",v=d&&x==="width"?Zx(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},y=(w,A)=>{var T=typeof u=="function"?u(w.value,A):w.value;return x==="width"?v2e(Zx(T,{fontSize:e,letterSpacing:n}),v,f):Zx(T,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?Li(i[1].coordinate-i[0].coordinate):1,E=_2e(a,b,x);return c==="equidistantPreserveStart"?S2e(b,E,y,i,s):(c==="preserveStart"||c==="preserveStartEnd"?p=C2e(b,E,y,i,s,c==="preserveStartEnd"):p=T2e(b,E,y,i,s),p.filter(w=>w.isShow))}var N2e=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>s&&(s=f.width)}});var o=n?n.getBoundingClientRect().width:0,c=i+a,u=s+c+o+(n?r:0);return Math.round(u)}return 0},k2e=["axisLine","width","height","className","hide","ticks","axisType"];function P2e(t,e){if(t==null)return{};var n,r,i=R2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function R2e(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 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 v6(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 Jr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v6(Object(n),!0).forEach(function(r){j2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function j2e(t,e,n){return(e=D2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D2e(t){var e=O2e(t,"string");return typeof e=="symbol"?e:e+""}function O2e(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 Mc={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:Dr.axis};function L2e(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:s,axisLine:o,otherSvgProps:c}=t;if(!o)return null;var u=Jr(Jr(Jr({},c),ka(o)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!s||a==="bottom"&&s);u=Jr(Jr({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!s||a==="right"&&s);u=Jr(Jr({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return M.createElement("line",ef({},u,{className:En("recharts-cartesian-axis-line",Yh(o,"className"))}))}function I2e(t,e,n,r,i,a,s,o,c){var u,d,f,g,p,x,v=o?-1:1,y=t.tickSize||s,b=Rt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!o*i,f=g-v*y,x=f-v*c,p=b;break;case"left":f=g=t.coordinate,d=e+ +!o*r,u=d-v*y,p=u-v*c,x=b;break;case"right":f=g=t.coordinate,d=e+ +o*r,u=d+v*y,p=u+v*c,x=b;break;default:u=d=t.coordinate,g=n+ +o*i,f=g+v*y,x=f+v*c,p=b;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:p,y:x}}}function F2e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function U2e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function z2e(t){var{option:e,tickProps:n,value:r}=t,i,a=En(n.className,"recharts-cartesian-axis-tick-value");if(M.isValidElement(e))i=M.cloneElement(e,Jr(Jr({},n),{},{className:a}));else if(typeof e=="function")i=e(Jr(Jr({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=En(s,e?.className)),i=M.createElement(RM,ef({},n,{className:s}),r)}return i}var B2e=M.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:s,unit:o,padding:c,tickTextProps:u,orientation:d,mirror:f,x:g,y:p,width:x,height:v,tickSize:y,tickMargin:b,fontSize:E,letterSpacing:w,getTicksConfig:A,events:T,axisType:C}=t,k=JD(Jr(Jr({},A),{},{ticks:n}),E,w),F=F2e(d,f),N=U2e(d,f),j=ka(A),I=Xh(r),O={};typeof i=="object"&&(O=i);var q=Jr(Jr({},j),{},{fill:"none"},O),R=k.map(G=>Jr({entry:G},I2e(G,g,p,x,v,d,y,f,b))),W=R.map(G=>{var{entry:te,line:Y}=G;return M.createElement(Mr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(te.value,"-").concat(te.coordinate,"-").concat(te.tickCoord)},i&&M.createElement("line",ef({},q,Y,{className:En("recharts-cartesian-axis-tick-line",Yh(i,"className"))})))}),K=R.map((G,te)=>{var{entry:Y,tick:J}=G,U=Jr(Jr(Jr(Jr({textAnchor:F,verticalAnchor:N},j),{},{stroke:"none",fill:a},I),J),{},{index:te,payload:Y,visibleTicksCount:k.length,tickFormatter:s,padding:c},u);return M.createElement(Mr,ef({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},wb(T,Y,te)),r&&M.createElement(z2e,{option:r,tickProps:U,value:"".concat(typeof s=="function"?s(Y.value,te):Y.value).concat(o||"")}))});return M.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},K.length>0&&M.createElement(ga,{zIndex:Dr.label},M.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},K)),W.length>0&&M.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},W))}),H2e=M.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:o,axisType:c}=t,u=P2e(t,k2e),[d,f]=M.useState(""),[g,p]=M.useState(""),x=M.useRef(null);M.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var y;return N2e({ticks:x.current,label:(y=t.labelRef)===null||y===void 0?void 0:y.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=M.useCallback(y=>{if(y){var b=y.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var E=b[0];if(E){var w=window.getComputedStyle(E),A=w.fontSize,T=w.letterSpacing;(A!==d||T!==g)&&(f(A),p(T))}}},[d,g]);return s||r!=null&&r<=0||i!=null&&i<=0?null:M.createElement(ga,{zIndex:t.zIndex},M.createElement(Mr,{className:En("recharts-cartesian-axis",a)},M.createElement(L2e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:ka(t)}),M.createElement(B2e,{ref:v,axisType:c,events:u,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}),M.createElement(UX,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},M.createElement(BX,{label:t.label,labelRef:t.labelRef}),t.children)))}),eO=M.forwardRef((t,e)=>{var n=Er(t,Mc);return M.createElement(H2e,ef({},n,{ref:e}))});eO.displayName="CartesianAxis";var $2e=["x1","y1","x2","y2","key"],V2e=["offset"],G2e=["xAxisId","yAxisId"],W2e=["xAxisId","yAxisId"];function _6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ha(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_6(Object(n),!0).forEach(function(r){q2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function q2e(t,e,n){return(e=K2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function K2e(t){var e=X2e(t,"string");return typeof e=="symbol"?e:e+""}function X2e(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 wh(){return wh=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},wh.apply(null,arguments)}function Aw(t,e){if(t==null)return{};var n,r,i=Y2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Y2e(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 Z2e=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:s,ry:o}=t;return M.createElement("rect",{x:r,y:i,ry:o,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function hY(t){var{option:e,lineItemProps:n}=t,r;if(M.isValidElement(e))r=M.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:s,x2:o,y2:c,key:u}=n,d=Aw(n,$2e),f=(i=ka(d))!==null&&i!==void 0?i:{},{offset:g}=f,p=Aw(f,V2e);r=M.createElement("line",wh({},p,{x1:a,y1:s,x2:o,y2:c,fill:"none",key:u}))}return r}function Q2e(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=Aw(t,G2e),c=i.map((u,d)=>{var f=ha(ha({},o),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return M.createElement(hY,{key:"line-".concat(d),option:r,lineItemProps:f})});return M.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function J2e(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,o=Aw(t,W2e),c=i.map((u,d)=>{var f=ha(ha({},o),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return M.createElement(hY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return M.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function eAe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:s,horizontalPoints:o,horizontal:c=!0}=t;if(!c||!e||!e.length||o==null)return null;var u=o.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%e.length;return M.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:a,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function tAe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:s,height:o,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%n.length;return M.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:x,height:o,stroke:"none",fill:n[v],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var nAe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return XW(JD(ha(ha(ha({},Mc),n),{},{ticks:YW(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},rAe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return XW(JD(ha(ha(ha({},Mc),n),{},{ticks:YW(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},iAe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Dr.grid};function Tw(t){var e=Aj(),n=Tj(),r=aq(),i=ha(ha({},Er(t,iAe)),{},{x:Rt(t.x)?t.x:r.left,y:Rt(t.y)?t.y:r.top,width:Rt(t.width)?t.width:r.width,height:Rt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:s,x:o,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:p}=i,x=yi(),v=kt(N=>cB(N,"xAxis",a,x)),y=kt(N=>cB(N,"yAxis",s,x));if(!fl(u)||!fl(d)||!Rt(o)||!Rt(c))return null;var b=i.verticalCoordinatesGenerator||nAe,E=i.horizontalCoordinatesGenerator||rAe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof E=="function"){var T=g&&g.length,C=E({yAxis:y?ha(ha({},y),{},{ticks:T?g:y.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);Y1(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}if((!A||!A.length)&&typeof b=="function"){var k=p&&p.length,F=b({xAxis:v?ha(ha({},v),{},{ticks:k?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},k?!0:f);Y1(Array.isArray(F),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof F,"]")),Array.isArray(F)&&(A=F)}return M.createElement(ga,{zIndex:i.zIndex},M.createElement("g",{className:"recharts-cartesian-grid"},M.createElement(Z2e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),M.createElement(eAe,wh({},i,{horizontalPoints:w})),M.createElement(tAe,wh({},i,{verticalPoints:A})),M.createElement(Q2e,wh({},i,{offset:r,horizontalPoints:w,xAxis:v,yAxis:y})),M.createElement(J2e,wh({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:y}))))}Tw.displayName="CartesianGrid";var fY=(t,e,n,r)=>gl(t,"xAxis",e,r),mY=(t,e,n,r)=>pl(t,"xAxis",e,r),pY=(t,e,n,r)=>gl(t,"yAxis",n,r),gY=(t,e,n,r)=>pl(t,"yAxis",n,r),aAe=Ke([xn,fY,pY,mY,gY],(t,e,n,r,i)=>Sl(t,"xAxis")?fd(e,r,!1):fd(n,i,!1)),sAe=(t,e,n,r,i)=>i;function oAe(t){return t.type==="line"}var lAe=Ke([Ib,sAe],(t,e)=>t.filter(oAe).find(n=>n.id===e)),cAe=Ke([xn,fY,pY,mY,gY,lAe,aAe,jb],(t,e,n,r,i,a,s,o)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=o;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:g}=a,p;if(g!=null&&g.length>0?p=g:p=c?.slice(u,d+1),p!=null)return NAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:s,displayedData:p})}});function xY(t){var e=Xh(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,s=Number(i),o=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(o)||o<0)&&(o=r),{r:s,strokeWidth:o}}return{r:n,strokeWidth:r}}var uAe=["id"],dAe=["type","layout","connectNulls","needClip","shape"],hAe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function $0(){return $0=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},$0.apply(null,arguments)}function w6(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 tl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w6(Object(n),!0).forEach(function(r){fAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fAe(t,e,n){return(e=mAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mAe(t){var e=pAe(t,"string");return typeof e=="symbol"?e:e+""}function pAe(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 tO(t,e){if(t==null)return{};var n,r,i=gAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gAe(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 xAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Ad(n,e),payload:t}]},bAe=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Ad(s,e),hide:o,type:u,color:r,unit:c}};return M.createElement(LM,{tooltipEntrySettings:d})}),bY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function yAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var vAe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return bY(e,t);for(var i=Math.floor(t/r),a=t%r,s=e-t,o=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){o=[...n.slice(0,c),a-u];break}var d=o.length%2===0?[0,s]:[s];return[...yAe(n,i),...o,...d].map(f=>"".concat(f,"px")).join(", ")};function _Ae(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:s}=r,{id:o}=r,c=tO(r,uAe),u=ka(c);return M.createElement(JX,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:s,clipPathId:e})}function wAe(t){var{showLabels:e,children:n,points:r}=t,i=M.useMemo(()=>r?.map(a=>{var s,o,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return tl(tl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return M.createElement(BD,{value:e?i:void 0},n)}function S6(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:s,layout:o,connectNulls:c,needClip:u,shape:d}=a,f=tO(a,dAe),g=tl(tl({},na(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:s,layout:o,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return M.createElement(M.Fragment,null,r?.length>1&&M.createElement(WD,$0({shapeType:"curve",option:d},g,{pathRef:n})),M.createElement(_Ae,{points:r,clipPathId:e,props:a}))}function SAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function MAe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:s,strokeDasharray:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:p,height:x,onAnimationEnd:v,onAnimationStart:y}=n,b=i.current,E=tg(s,"recharts-line-"),w=M.useRef(E),[A,T]=M.useState(!1),C=!A,k=M.useCallback(()=>{typeof v=="function"&&v(),T(!1)},[v]),F=M.useCallback(()=>{typeof y=="function"&&y(),T(!0)},[y]),N=SAe(r.current),j=M.useRef(0);w.current!==E&&(j.current=a.current,w.current=E);var I=j.current;return M.createElement(wAe,{points:s,showLabels:C},n.children,M.createElement(eg,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:k,onAnimationStart:F,key:E},O=>{var q=Dn(I,N+I,O),R=Math.min(q,N),W;if(c)if(o){var K="".concat(o).split(/[,\s]+/gim).map(Y=>parseFloat(Y));W=vAe(R,N,K)}else W=bY(N,R);else W=o==null?void 0:String(o);if(O>0&&N>0&&(i.current=s,a.current=Math.max(a.current,R)),b){var G=b.length/s.length,te=O===1?s:s.map((Y,J)=>{var U=Math.floor(J*G);if(b[U]){var H=b[U];return tl(tl({},Y),{},{x:Dn(H.x,Y.x,O),y:Dn(H.y,Y.y,O)})}return g?tl(tl({},Y),{},{x:Dn(p*2,Y.x,O),y:Dn(x/2,Y.y,O)}):tl(tl({},Y),{},{x:Y.x,y:Y.y})});return i.current=te,M.createElement(S6,{props:n,points:te,clipPathId:e,pathRef:r,strokeDasharray:W})}return M.createElement(S6,{props:n,points:s,clipPathId:e,pathRef:r,strokeDasharray:W})}),M.createElement(jM,{label:n.label}))}function EAe(t){var{clipPathId:e,props:n}=t,r=M.useRef(null),i=M.useRef(0),a=M.useRef(null);return M.createElement(MAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var AAe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:Hn(t.payload,e)}};class TAe extends M.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:s,top:o,left:c,width:u,height:d,id:f,needClip:g,zIndex:p}=this.props;if(e)return null;var x=En("recharts-line",i),v=f,{r:y,strokeWidth:b}=xY(n),E=GD(n),w=y*2+b,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(v,")"):void 0;return M.createElement(ga,{zIndex:p},M.createElement(Mr,{className:x},g&&M.createElement("defs",null,M.createElement(QD,{clipPathId:v,xAxisId:a,yAxisId:s}),!E&&M.createElement("clipPath",{id:"clipPath-dots-".concat(v)},M.createElement("rect",{x:c-w/2,y:o-w/2,width:u+w,height:d+w}))),M.createElement(nY,{xAxisId:a,yAxisId:s,data:r,dataPointFormatter:AAe,errorBarOffset:0},M.createElement(EAe,{props:this.props,clipPathId:v}))),M.createElement(L3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var yY={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Dr.line,type:"linear"};function CAe(t){var e=Er(t,yY),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:p,yAxisId:x,id:v}=e,y=tO(e,hAe),{needClip:b}=zM(p,x),E=UM(),w=mf(),A=yi(),T=kt(j=>cAe(j,p,x,A,v));if(w!=="horizontal"&&w!=="vertical"||T==null||E==null)return null;var{height:C,width:k,x:F,y:N}=E;return M.createElement(TAe,$0({},y,{id:v,connectNulls:o,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:p,yAxisId:x,points:T,layout:w,height:C,width:k,left:F,top:N,needClip:b}))}function NAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:s,bandSize:o,displayedData:c}=t;return c.map((u,d)=>{var f=Hn(u,s);if(e==="horizontal"){var g=X1({axis:n,ticks:i,bandSize:o,entry:u,index:d}),p=fr(f)?null:r.scale(f);return{x:g,y:p,value:f,payload:u}}var x=fr(f)?null:n.scale(f),v=X1({axis:r,ticks:a,bandSize:o,entry:u,index:d});return x==null||v==null?null:{x,y:v,value:f,payload:u}}).filter(Boolean)}function kAe(t){var e=Er(t,yY),n=yi();return M.createElement(IM,{id:e.id,type:"line"},r=>M.createElement(M.Fragment,null,M.createElement(YD,{legendPayload:xAe(e)}),M.createElement(bAe,{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}),M.createElement(ZD,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),M.createElement(CAe,$0({},e,{id:r}))))}var vY=M.memo(kAe,Wb);vY.displayName="Line";var _Y=(t,e,n,r)=>gl(t,"xAxis",e,r),wY=(t,e,n,r)=>pl(t,"xAxis",e,r),SY=(t,e,n,r)=>gl(t,"yAxis",n,r),MY=(t,e,n,r)=>pl(t,"yAxis",n,r),PAe=Ke([xn,_Y,SY,wY,MY],(t,e,n,r,i)=>Sl(t,"xAxis")?fd(e,r,!1):fd(n,i,!1)),RAe=(t,e,n,r,i)=>i,EY=Ke([Ib,RAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),jAe=(t,e,n,r,i)=>{var a,s=EY(t,e,n,r,i);if(s!=null){var o=xn(t),c=Sl(o,"xAxis"),u;if(c?u=B0(t,"yAxis",n,r):u=B0(t,"xAxis",e,r),u!=null){var{stackId:d}=s,f=SM(s);if(!(d==null||f==null)){var g=(a=u[d])===null||a===void 0?void 0:a.stackedData;return g?.find(p=>p.key===f)}}}},DAe=Ke([xn,_Y,SY,wY,MY,jAe,jb,PAe,EY,lye],(t,e,n,r,i,a,s,o,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=s;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,g+1),x!=null)return JAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:o})}}),OAe=["id"],LAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function jh(){return jh=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},jh.apply(null,arguments)}function AY(t,e){if(t==null)return{};var n,r,i=IAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function IAe(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 M6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M6(Object(n),!0).forEach(function(r){FAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FAe(t,e,n){return(e=UAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UAe(t){var e=zAe(t,"string");return typeof e=="symbol"?e:e+""}function zAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Cw(t,e){return t&&t!=="none"?t:e}var BAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:Cw(r,i),value:Ad(n,e),payload:t}]},HAe=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Ad(s,e),hide:o,type:u,color:Cw(r,a),unit:c}};return M.createElement(LM,{tooltipEntrySettings:d})});function $Ae(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,o=ka(r);return M.createElement(JX,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:o,needClip:i,clipPathId:e})}function VAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var s,o,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Xm(Xm({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return M.createElement(BD,{value:e?i:void 0},n)}function E6(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:s,type:o,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,g=AY(a,OAe),p=ka(g),x=na(g);return M.createElement(M.Fragment,null,e?.length>1&&M.createElement(Mr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},M.createElement(rp,jh({},x,{id:f,points:e,connectNulls:u,type:o,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),c!=="none"&&M.createElement(rp,jh({},p,{className:"recharts-area-curve",layout:s,type:o,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&M.createElement(rp,jh({},p,{className:"recharts-area-curve",layout:s,type:o,connectNulls:u,fill:"none",points:n}))),M.createElement($Ae,{points:e,props:g,clipPathId:i}))}function GAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!$n(a)||!$n(s))return null;var o=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.x||0));return Rt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Rt(c)?M.createElement("rect",{x:0,y:a<s?a:a-o,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function WAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!$n(a)||!$n(s))return null;var o=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.y||0));return Rt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Rt(c)?M.createElement("rect",{x:a<s?a:a-o,y:0,width:o,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function qAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?M.createElement(GAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):M.createElement(WAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function KAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:s,baseLine:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:p}=r,x=M.useMemo(()=>({points:s,baseLine:o}),[s,o]),v=tg(x,"recharts-area-"),y=Ape(),[b,E]=M.useState(!1),w=!b,A=M.useCallback(()=>{typeof p=="function"&&p(),E(!1)},[p]),T=M.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(y==null)return null;var C=i.current,k=a.current;return M.createElement(VAe,{showLabels:w,points:s},r.children,M.createElement(eg,{animationId:v,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:T,key:v},F=>{if(C){var N=C.length/s.length,j=F===1?s:s.map((O,q)=>{var R=Math.floor(q*N);if(C[R]){var W=C[R];return Xm(Xm({},O),{},{x:Dn(W.x,O.x,F),y:Dn(W.y,O.y,F)})}return O}),I;return Rt(o)?I=Dn(k,o,F):fr(o)||ns(o)?I=Dn(k,0,F):I=o.map((O,q)=>{var R=Math.floor(q*N);if(Array.isArray(k)&&k[R]){var W=k[R];return Xm(Xm({},O),{},{x:Dn(W.x,O.x,F),y:Dn(W.y,O.y,F)})}return O}),F>0&&(i.current=j,a.current=I),M.createElement(E6,{points:j,baseLine:I,needClip:e,clipPathId:n,props:r})}return F>0&&(i.current=s,a.current=o),M.createElement(Mr,null,c&&M.createElement("defs",null,M.createElement("clipPath",{id:"animationClipPath-".concat(n)},M.createElement(qAe,{alpha:F,points:s,baseLine:o,layout:y,strokeWidth:r.strokeWidth}))),M.createElement(Mr,{clipPath:"url(#animationClipPath-".concat(n,")")},M.createElement(E6,{points:s,baseLine:o,needClip:e,clipPathId:n,props:r})))}),M.createElement(jM,{label:r.label}))}function XAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=M.useRef(null),a=M.useRef();return M.createElement(KAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class YAe extends M.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:s,needClip:o,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:p,zIndex:x}=this.props;if(e)return null;var v=En("recharts-area",i),y=g,{r:b,strokeWidth:E}=xY(n),w=GD(n),A=b*2+E,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(y,")"):void 0;return M.createElement(ga,{zIndex:x},M.createElement(Mr,{className:v},o&&M.createElement("defs",null,M.createElement(QD,{clipPathId:y,xAxisId:c,yAxisId:u}),!w&&M.createElement("clipPath",{id:"clipPath-dots-".concat(y)},M.createElement("rect",{x:s-A/2,y:a-A/2,width:d+A,height:f+A}))),M.createElement(XAe,{needClip:o,clipPathId:y,props:this.props})),M.createElement(L3,{points:r,mainColor:Cw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(p)&&M.createElement(L3,{points:p,mainColor:Cw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var TY={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:Dr.area};function ZAe(t){var e,n=Er(t,TY),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:o,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:p,stroke:x,xAxisId:v,yAxisId:y}=n,b=AY(n,LAe),E=mf(),w=wX(),{needClip:A}=zM(v,y),T=yi(),{points:C,isRange:k,baseLine:F}=(e=kt(R=>DAe(R,v,y,T,t.id)))!==null&&e!==void 0?e:{},N=UM();if(E!=="horizontal"&&E!=="vertical"||N==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:j,width:I,x:O,y:q}=N;return!C||!C.length?null:M.createElement(YAe,jh({},b,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,baseLine:F,connectNulls:o,dot:c,fill:u,fillOpacity:d,height:j,hide:f,layout:E,isAnimationActive:g==="auto"?!Jp.isSsr:g,isRange:k,legendType:p,needClip:A,points:C,stroke:x,width:I,left:O,top:q,xAxisId:v,yAxisId:y}))}var QAe=(t,e,n,r,i)=>{var a=n??e;if(Rt(a))return a;var s=t==="horizontal"?i:r,o=s.scale.domain();if(s.type==="number"){var c=Math.max(o[0],o[1]),u=Math.min(o[0],o[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(o[0],o[1]),0)}return a==="dataMin"?o[0]:a==="dataMax"?o[1]:o[0]};function JAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:o,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:p}=t,x=i&&i.length,v=QAe(a,s,n,o,c),y=a==="horizontal",b=!1,E=u.map((A,T)=>{var C;x?C=i[d+T]:(C=Hn(A,r),Array.isArray(C)?b=!0:C=[v,C]);var k=C[1]==null||x&&!e&&Hn(A,r)==null;return y?{x:X1({axis:o,ticks:f,bandSize:p,entry:A,index:T}),y:k?null:c.scale(C[1]),value:C,payload:A}:{x:k?null:o.scale(C[1]),y:X1({axis:c,ticks:g,bandSize:p,entry:A,index:T}),value:C,payload:A}}),w;return x||b?w=E.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return y?{x:A.x,y:T!=null&&A.y!=null?c.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):w=y?c.scale(v):o.scale(v),{points:E,baseLine:w,isRange:b}}function eTe(t){var e=Er(t,TY),n=yi();return M.createElement(IM,{id:e.id,type:"area"},r=>M.createElement(M.Fragment,null,M.createElement(YD,{legendPayload:BAe(e)}),M.createElement(HAe,{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}),M.createElement(ZD,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:ZW(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),M.createElement(ZAe,jh({},e,{id:r}))))}var CY=M.memo(eTe,Wb);CY.displayName="Area";var tTe=["domain","range"],nTe=["domain","range"];function A6(t,e){if(t==null)return{};var n,r,i=rTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function rTe(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 T6(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 NY(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=A6(t,tTe),{domain:a,range:s}=e,o=A6(e,nTe);return!T6(n,a)||!T6(r,s)?!1:Wb(i,o)}var iTe=["dangerouslySetInnerHTML","ticks"],aTe=["id"];function F3(){return F3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},F3.apply(null,arguments)}function C6(t,e){if(t==null)return{};var n,r,i=sTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function sTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function oTe(t){var e=ir(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(tMe(t)):n.current!==t&&e(nMe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(rMe(n.current)),n.current=null)},[e]),null}var lTe=t=>{var{xAxisId:e,className:n}=t,r=kt(Mj),i=yi(),a="xAxis",s=kt(y=>pd(y,a,e,i)),o=kt(y=>eX(y,a,e,i)),c=kt(y=>YK(y,e)),u=kt(y=>ave(y,e)),d=kt(y=>PK(y,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,p=C6(t,iTe),{id:x}=d,v=C6(d,aTe);return M.createElement(eO,F3({},p,v,{scale:s,x:u.x,y:u.y,width:c.width,height:c.height,className:En("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},cTe={allowDataOverflow:Pi.allowDataOverflow,allowDecimals:Pi.allowDecimals,allowDuplicatedCategory:Pi.allowDuplicatedCategory,angle:Pi.angle,axisLine:Mc.axisLine,height:Pi.height,hide:!1,includeHidden:Pi.includeHidden,interval:Pi.interval,minTickGap:Pi.minTickGap,mirror:Pi.mirror,orientation:Pi.orientation,padding:Pi.padding,reversed:Pi.reversed,scale:Pi.scale,tick:Pi.tick,tickCount:Pi.tickCount,tickLine:Mc.tickLine,tickSize:Mc.tickSize,type:Pi.type,xAxisId:0},uTe=t=>{var e=Er(t,cTe);return M.createElement(M.Fragment,null,M.createElement(oTe,{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}),M.createElement(lTe,e))},Nw=M.memo(uTe,NY);Nw.displayName="XAxis";var dTe=["dangerouslySetInnerHTML","ticks"],hTe=["id"];function U3(){return U3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},U3.apply(null,arguments)}function N6(t,e){if(t==null)return{};var n,r,i=fTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function fTe(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 mTe(t){var e=ir(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(iMe(t)):n.current!==t&&e(aMe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(sMe(n.current)),n.current=null)},[e]),null}var pTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=M.useRef(null),s=M.useRef(null),o=kt(Mj),c=yi(),u=ir(),d="yAxis",f=kt(T=>pd(T,d,e,c)),g=kt(T=>ZK(T,e)),p=kt(T=>ove(T,e)),x=kt(T=>eX(T,d,e,c)),v=kt(T=>RK(T,e));if(M.useLayoutEffect(()=>{if(!(r!=="auto"||!g||zD(i)||M.isValidElement(i)||v==null)){var T=a.current;if(T){var C=T.getCalculatedWidth();Math.round(g.width)!==Math.round(C)&&u(oMe({id:e,width:C}))}}},[x,g,u,i,e,r,v]),g==null||p==null||v==null)return null;var{dangerouslySetInnerHTML:y,ticks:b}=t,E=N6(t,dTe),{id:w}=v,A=N6(v,hTe);return M.createElement(eO,U3({},E,A,{ref:a,labelRef:s,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:En("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:x,axisType:d}))},gTe={allowDataOverflow:Ri.allowDataOverflow,allowDecimals:Ri.allowDecimals,allowDuplicatedCategory:Ri.allowDuplicatedCategory,angle:Ri.angle,axisLine:Mc.axisLine,hide:!1,includeHidden:Ri.includeHidden,interval:Ri.interval,minTickGap:Ri.minTickGap,mirror:Ri.mirror,orientation:Ri.orientation,padding:Ri.padding,reversed:Ri.reversed,scale:Ri.scale,tick:Ri.tick,tickCount:Ri.tickCount,tickLine:Mc.tickLine,tickSize:Mc.tickSize,type:Ri.type,width:Ri.width,yAxisId:0},xTe=t=>{var e=Er(t,gTe);return M.createElement(M.Fragment,null,M.createElement(mTe,{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}),M.createElement(pTe,e))},kw=M.memo(xTe,NY);kw.displayName="YAxis";var bTe=(t,e)=>e,nO=Ke([bTe,xn,NK,_i,gX,qc,w_e,bi],N_e),rO=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)}},kY=ho("mouseClick"),PY=Eb();PY.startListening({actionCreator:kY,effect:(t,e)=>{var n=t.payload,r=nO(e.getState(),rO(n));r?.activeIndex!=null&&e.dispatch(_ve({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var z3=ho("mouseMove"),RY=Eb(),Lv=null;RY.startListening({actionCreator:z3,effect:(t,e)=>{var n=t.payload;Lv!==null&&cancelAnimationFrame(Lv);var r=rO(n);Lv=requestAnimationFrame(()=>{var i=e.getState(),a=ND(i,i.tooltip.settings.shared);if(a==="axis"){var s=nO(i,r);s?.activeIndex!=null?e.dispatch(lX({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(oX())}Lv=null})}});var k6={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},jY=rs({name:"rootProps",initialState:k6,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:k6.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}}}),yTe=jY.reducer,{updateOptions:vTe}=jY.actions,DY=rs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:_Te}=DY.actions,wTe=DY.reducer,OY=ho("keyDown"),LY=ho("focus"),iO=Eb();iO.startListening({actionCreator:OY,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var s=kD(i,cg(n),Ub(n),$b(n)),o=s==null?-1:Number(s);if(!(!Number.isFinite(o)||o<0)){var c=qc(n);if(a==="Enter"){var u=xw(n,"axis","hover",String(i.index));e.dispatch(k3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=dve(n),f=d==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,p=o+g*f;if(!(c==null||p>=c.length||p<0)){var x=xw(n,"axis","hover",String(p));e.dispatch(k3({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});iO.startListening({actionCreator:LY,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",s=xw(n,"axis","hover",String(a));e.dispatch(k3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var Vs=ho("externalEvent"),IY=Eb(),gC=new Map;IY.startListening({actionCreator:Vs,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=gC.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var o=e.getState(),c={activeCoordinate:o_e(o),activeDataKey:OD(o),activeIndex:gd(o),activeLabel:yX(o),activeTooltipIndex:gd(o),isTooltipActive:l_e(o)};n(c,r)}finally{gC.delete(i)}});gC.set(i,s)}}});var STe=Ke([lg],t=>t.tooltipItemPayloads),MTe=Ke([STe,Bb,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var s=e(a,n);return s}}}),FY=ho("touchMove"),UY=Eb();UY.startListening({actionCreator:FY,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=ND(r,r.tooltip.settings.shared);if(i==="axis"){var a=nO(r,rO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(lX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var s,o=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(o.clientX,o.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(JW),d=(s=c.getAttribute(eq))!==null&&s!==void 0?s:void 0,f=MTe(e.getState(),u,d);e.dispatch(sX({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var ETe=vW({brush:XEe,cartesianAxis:lMe,chartData:s1e,errorBars:TMe,graphicalItems:pSe,layout:jme,legend:Bpe,options:t1e,polarAxis:kwe,polarOptions:wTe,referenceElements:s2e,rootProps:yTe,tooltip:wve,zIndex:$_e}),ATe=function(e){return ime({reducer:ETe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([PY.middleware,RY.middleware,iO.middleware,IY.middleware,UY.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(OW({type:"raf"}))},devTools:Jp.devToolsEnabled})};function zY(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=yi(),a=M.useRef(null);if(i)return n;a.current==null&&(a.current=ATe(e));var s=pj;return M.createElement(ZMe,{context:s,store:a.current},n)}function TTe(t){var{layout:e,margin:n}=t,r=ir(),i=yi();return M.useEffect(()=>{i||(r(kme(e)),r(Nme(n)))},[r,i,e,n]),null}var BY=M.memo(TTe,Wb);function HY(t){var e=ir();return M.useEffect(()=>{e(vTe(t))},[e,t]),null}function P6(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=YX("".concat(r).concat(e)),a=ir();return M.useLayoutEffect(()=>(a(B_e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(H_e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),M.createElement("g",{tabIndex:-1,id:i})}function R6(t){var{children:e,isPanorama:n}=t,r=kt(P_e);if(!r||r.length===0)return e;var i=r.filter(s=>s<0),a=r.filter(s=>s>0);return M.createElement(M.Fragment,null,i.map(s=>M.createElement(P6,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>M.createElement(P6,{key:s,zIndex:s,isPanorama:n})))}var CTe=["children"];function NTe(t,e){if(t==null)return{};var n,r,i=kTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function kTe(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 Pw(){return Pw=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},Pw.apply(null,arguments)}var PTe={width:"100%",height:"100%",display:"block"},RTe=M.forwardRef((t,e)=>{var n=Aj(),r=Tj(),i=gq();if(!fl(n)||!fl(r))return null;var{children:a,otherAttributes:s,title:o,desc:c}=t,u,d;return s!=null&&(typeof s.tabIndex=="number"?u=s.tabIndex:u=i?0:void 0,typeof s.role=="string"?d=s.role:d=i?"application":void 0),M.createElement(aj,Pw({},s,{title:o,desc:c,role:d,tabIndex:u,width:n,height:r,style:PTe,ref:e}),a)}),jTe=t=>{var{children:e}=t,n=kt(uM);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return M.createElement(aj,{width:r,height:i,x:s,y:a},e)},j6=M.forwardRef((t,e)=>{var{children:n}=t,r=NTe(t,CTe),i=yi();return i?M.createElement(jTe,null,M.createElement(R6,{isPanorama:!0},n)):M.createElement(RTe,Pw({ref:e},r),M.createElement(R6,{isPanorama:!1},n))});function DTe(){var t=ir(),[e,n]=M.useState(null),r=kt(Yme);return M.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;$n(a)&&a!==r&&t(Rme(a))}},[e,t,r]),n}function D6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function OTe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D6(Object(n),!0).forEach(function(r){LTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LTe(t,e,n){return(e=ITe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ITe(t){var e=FTe(t,"string");return typeof e=="symbol"?e:e+""}function FTe(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 tf(){return tf=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},tf.apply(null,arguments)}var UTe=()=>(p1e(),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 zTe=M.forwardRef((t,e)=>{var n,r,i=M.useRef(null),[a,s]=M.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=M.useCallback((u,d)=>{s(f=>{var g=Math.round(u),p=Math.round(d);return f.containerWidth===g&&f.containerHeight===p?f:{containerWidth:g,containerHeight:p}})},[]),c=M.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();o(d,f);var g=x=>{var{width:v,height:y}=x[0].contentRect;o(v,y)},p=new ResizeObserver(g);p.observe(u),i.current=p}},[e,o]);return M.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[o]),M.createElement(M.Fragment,null,M.createElement(dM,{width:a.containerWidth,height:a.containerHeight}),M.createElement("div",tf({ref:c},t)))}),BTe=M.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=M.useState({containerWidth:Rw(n),containerHeight:Rw(r)}),s=M.useCallback((c,u)=>{a(d=>{var f=Math.round(c),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),o=M.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();s(u,d)}},[e,s]);return M.createElement(M.Fragment,null,M.createElement(dM,{width:i.containerWidth,height:i.containerHeight}),M.createElement("div",tf({ref:o},t)))}),HTe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return M.createElement(M.Fragment,null,M.createElement(dM,{width:n,height:r}),M.createElement("div",tf({ref:e},t)))}),$Te=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return jc(n)||jc(r)?M.createElement(BTe,tf({},t,{ref:e})):M.createElement(HTe,tf({},t,{ref:e}))});function VTe(t){return t===!0?zTe:$Te}var GTe=M.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:s,onDoubleClick:o,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:p,onTouchMove:x,onTouchStart:v,style:y,width:b,responsive:E,dispatchTouchEvents:w=!0}=t,A=M.useRef(null),T=ir(),[C,k]=M.useState(null),[F,N]=M.useState(null),j=DTe(),I=Ej(),O=I?.width>0?I.width:b,q=I?.height>0?I.height:i,R=M.useCallback(Z=>{j(Z),typeof e=="function"&&e(Z),k(Z),N(Z),Z!=null&&(A.current=Z)},[j,e,k,N]),W=M.useCallback(Z=>{T(kY(Z)),T(Vs({handler:a,reactEvent:Z}))},[T,a]),K=M.useCallback(Z=>{T(z3(Z)),T(Vs({handler:u,reactEvent:Z}))},[T,u]),G=M.useCallback(Z=>{T(oX()),T(Vs({handler:d,reactEvent:Z}))},[T,d]),te=M.useCallback(Z=>{T(z3(Z)),T(Vs({handler:f,reactEvent:Z}))},[T,f]),Y=M.useCallback(()=>{T(LY())},[T]),J=M.useCallback(Z=>{T(OY(Z.key))},[T]),U=M.useCallback(Z=>{T(Vs({handler:s,reactEvent:Z}))},[T,s]),H=M.useCallback(Z=>{T(Vs({handler:o,reactEvent:Z}))},[T,o]),ee=M.useCallback(Z=>{T(Vs({handler:c,reactEvent:Z}))},[T,c]),ie=M.useCallback(Z=>{T(Vs({handler:g,reactEvent:Z}))},[T,g]),pe=M.useCallback(Z=>{T(Vs({handler:v,reactEvent:Z}))},[T,v]),ue=M.useCallback(Z=>{w&&T(FY(Z)),T(Vs({handler:x,reactEvent:Z}))},[T,w,x]),be=M.useCallback(Z=>{T(Vs({handler:p,reactEvent:Z}))},[T,p]),Re=VTe(E);return M.createElement(TX.Provider,{value:C},M.createElement(OG.Provider,{value:F},M.createElement(Re,{width:O??y?.width,height:q??y?.height,className:En("recharts-wrapper",r),style:OTe({position:"relative",cursor:"default",width:O,height:q},y),onClick:W,onContextMenu:U,onDoubleClick:H,onFocus:Y,onKeyDown:J,onMouseDown:ee,onMouseEnter:K,onMouseLeave:G,onMouseMove:te,onMouseUp:ie,onTouchEnd:be,onTouchMove:ue,onTouchStart:pe,ref:R},M.createElement(UTe,null),n)))}),WTe=["width","height","responsive","children","className","style","compact","title","desc"];function qTe(t,e){if(t==null)return{};var n,r,i=KTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function KTe(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 $Y=M.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:s,style:o,compact:c,title:u,desc:d}=t,f=qTe(t,WTe),g=ka(f);return c?M.createElement(M.Fragment,null,M.createElement(dM,{width:n,height:r}),M.createElement(j6,{otherAttributes:g,title:u,desc:d},a)):M.createElement(GTe,{className:s,style:o,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},M.createElement(j6,{otherAttributes:g,title:u,desc:d,ref:e},M.createElement(o2e,null,a)))});function B3(){return B3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},B3.apply(null,arguments)}var XTe={top:5,right:5,bottom:5,left:5},YTe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:XTe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},aO=M.forwardRef(function(e,n){var r,i=Er(e.categoricalChartProps,YTe),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,eventEmitter:void 0};return M.createElement(zY,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},M.createElement(sY,{chartData:u.data}),M.createElement(BY,{layout:i.layout,margin:i.margin}),M.createElement(HY,{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}),M.createElement($Y,B3({},i,{ref:n})))}),ZTe=["axis"],QTe=M.forwardRef((t,e)=>M.createElement(aO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:ZTe,tooltipPayloadSearcher:PM,categoricalChartProps:t,ref:e})),JTe=["axis","item"],eCe=M.forwardRef((t,e)=>M.createElement(aO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JTe,tooltipPayloadSearcher:PM,categoricalChartProps:t,ref:e}));function tCe(t){var e=ir();return M.useEffect(()=>{e(_Te(t))},[e,t]),null}var nCe=["layout"];function H3(){return H3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},H3.apply(null,arguments)}function rCe(t,e){if(t==null)return{};var n,r,i=iCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function iCe(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 aCe={top:5,right:5,bottom:5,left:5},VY={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:aCe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},sCe=M.forwardRef(function(e,n){var r,i=Er(e.categoricalChartProps,VY),{layout:a}=i,s=rCe(i,nCe),{chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return M.createElement(zY,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},M.createElement(sY,{chartData:i.data}),M.createElement(BY,{layout:a,margin:i.margin}),M.createElement(HY,{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}),M.createElement(tCe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),M.createElement($Y,H3({},s,{ref:n})))});function O6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function L6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O6(Object(n),!0).forEach(function(r){oCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oCe(t,e,n){return(e=lCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lCe(t){var e=cCe(t,"string");return typeof e=="symbol"?e:e+""}function cCe(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 uCe=["item"],dCe=L6(L6({},VY),{},{layout:"centric",startAngle:0,endAngle:360}),hCe=M.forwardRef((t,e)=>{var n=Er(t,dCe);return M.createElement(sCe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:uCe,tooltipPayloadSearcher:PM,categoricalChartProps:n,ref:e})}),fCe=["axis"],mCe=M.forwardRef((t,e)=>M.createElement(aO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:fCe,tooltipPayloadSearcher:PM,categoricalChartProps:t,ref:e}));const I6=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function pCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:s="humidity",thresholds:o}){const{t:c}=Kp(),{theme:u}=yb(),[d,f]=M.useState("24h"),[g,p]=M.useState(s),x=u==="dark";M.useEffect(()=>{if(!t)return;const H=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[t,e]);const v=I6.find(H=>H.value===d)?.hours||24,{data:y,isLoading:b,error:E}=yt({queryKey:["ams-history",n,i,v],queryFn:()=>Ce.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const w=y?.data.map(H=>({time:new Date(H.recorded_at).getTime(),humidity:H.humidity,temperature:H.temperature,timeLabel:new Date(H.recorded_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}})}))||[],A=o?.humidityGood||40,T=o?.humidityFair||60,C=o?.tempGood||30,k=o?.tempFair||35,F=w[w.length-1],N=F?.humidity,j=F?.temperature,I=H=>{const ee=H.filter(Z=>Z!=null);if(ee.length<4)return"stable";const ie=ee.slice(0,Math.floor(ee.length/4)),pe=ee.slice(-Math.floor(ee.length/4)),ue=ie.reduce((Z,_e)=>Z+_e,0)/ie.length,Re=pe.reduce((Z,_e)=>Z+_e,0)/pe.length-ue;return Math.abs(Re)<2?"stable":Re>0?"up":"down"},O=I(w.map(H=>H.humidity)),q=I(w.map(H=>H.temperature)),R=({trend:H})=>H==="up"?l.jsx(SG,{className:"w-4 h-4 text-red-400"}):H==="down"?l.jsx(wG,{className:"w-4 h-4 text-green-400"}):l.jsx(Fk,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),W=H=>H==null?"#9ca3af":H<=A?"#22a352":H<=T?"#d4a017":"#c62828",K=H=>H==null?"#9ca3af":H<=C?"#22a352":H<=k?"#d4a017":"#c62828",G=x?"#2d2d2d":"#ffffff",te=x?"#1d1d1d":"#f3f4f6",Y=x?"#3d3d3d":"#e5e7eb",J=x?"#ffffff":"#111827",U=x?"#9ca3af":"#4b5563";return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:G},onClick:H=>H.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:Y},children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold",style:{color:J},children:[a," ",c("common.history","History")]}),l.jsx("p",{className:"text-sm",style:{color:U},children:r})]}),l.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:U},children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:te},children:[l.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="humidity"?"bg-blue-600 text-white":""}`,style:g!=="humidity"?{color:U}:void 0,children:[l.jsx(mG,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),l.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="temperature"?"bg-orange-600 text-white":""}`,style:g!=="temperature"?{color:U}:void 0,children:[l.jsx(qS,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),l.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:te},children:I6.map(H=>l.jsx("button",{onClick:()=>f(H.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===H.value?"bg-bambu-green text-white":""}`,style:d!==H.value?{color:U}:void 0,children:H.label},H.value))})]}),l.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:W(N)},children:N!=null?`${N}%`:"—"}),l.jsx(R,{trend:O})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:J},children:y?.avg_humidity!=null?`${y.avg_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-green-500",children:y?.min_humidity!=null?`${y.min_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_humidity!=null?`${y.max_humidity}%`:"—"})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:K(j)},children:j!=null?`${j}°C`:"—"}),l.jsx(R,{trend:q})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:J},children:y?.avg_temperature!=null?`${y.avg_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-blue-500",children:y?.min_temperature!=null?`${y.min_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_temperature!=null?`${y.max_temperature}°C`:"—"})]})]})}),l.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:b?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.loading","Loading...")}):E?l.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):w.length===0?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.noData","No data available for this time range")}):l.jsx(a1,{width:"100%",height:300,children:l.jsxs(QTe,{data:w,children:[l.jsx(Tw,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),l.jsx(Nw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:H=>{const ee=new Date(H);return v>24?ee.toLocaleDateString([],{day:"numeric",month:"short"}):ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),l.jsx(kw,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:H=>g==="humidity"?`${H}%`:`${H}°C`}),l.jsx(o1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:H=>new Date(H).toLocaleString(),formatter:H=>[g==="humidity"?`${H}%`:`${H}°C`,g==="humidity"?"Humidity":"Temperature"]}),l.jsx(kj,{}),g==="humidity"?l.jsxs(l.Fragment,{children:[l.jsx(Ux,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(Ux,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):l.jsxs(l.Fragment,{children:[l.jsx(Ux,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(Ux,{y:k,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),l.jsx(vY,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),l.jsx("div",{className:"text-xs text-center",style:{color:U},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function gCe({side:t}){const{theme:e}=yb(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return l.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 xCe({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 l.jsxs("svg",{className:e,width:"56",height:"34",viewBox:"0 0 52 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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]?l.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:t[i]},i):l.jsxs("g",{children:[l.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:"#ffffff"}),l.jsx("line",{x1:r.x,y1:"8",x2:r.x+6,y2:"24",stroke:"#555555",strokeWidth:"1.5"})]},i)),l.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"}),l.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 bCe({color:t,className:e}){return l.jsxs("svg",{className:e,width:"56",height:"56",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t?l.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:t,rx:"0.3"}):l.jsxs("g",{children:[l.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:"#ffffff",rx:"0.3"}),l.jsx("line",{x1:"8.3",y1:"5.2",x2:"12.1",y2:"10.3",stroke:"#555555",strokeWidth:"0.8"})]}),l.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"}),l.jsx("rect",{x:"3.8725",y:"10.3887",width:"12.7037",height:"7.55371",rx:"1.2",stroke:"#6B6B6B"}),l.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 F6({className:t}){return l.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:l.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 yCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.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 vCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.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 _Ce({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.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"}),l.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function wCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),l.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 SCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),l.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 xC({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?l.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),l.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),l.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function MCe({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r}){const i=typeof t=="string"?parseInt(t,10):t,a=typeof e=="number"?e:40,s=typeof n=="number"?n:60;let o,c;isNaN(i)?(o="#C3C2C1",c="Unknown"):i<=a?(o="#22a352",c="Good"):i<=s?(o="#d4a017",c="Fair"):(o="#c62828",c="Bad");let u;return isNaN(i)||i<=a?u=F6:i<=s?u=yCe:u=vCe,l.jsxs("button",{type:"button",onClick:r,className:`flex items-center justify-end gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${i}% - ${c}${r?" (click for history)":""}`,children:[l.jsx(u,{className:"w-3 h-4"}),l.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:o},children:[i,"%"]})]})}function ECe({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r}){const i=typeof e=="number"?e:28,a=typeof n=="number"?n:35;let s,o,c;return t<=i?(s="#22a352",o="Good",c=_Ce):t<=a?(s="#d4a017",o="Fair",c=wCe):(s="#c62828",o="Bad",c=SCe),l.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${o}${r?" (click for history)":""}`,children:[l.jsx(c,{className:"w-3 h-4"}),l.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:s},children:[t,"°C"]})]})}function bC(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,s=String.fromCharCode(65+a);return i?`HT-${s}`:`AMS-${s}`}function ACe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function TCe(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 a=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),s=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return s===0?a:s===1?`Tomorrow ${a}`:n.toLocaleDateString([],{weekday:"short"})+" "+a}function CCe(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 NCe(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]=M.useState(!1),[i,a]=M.useState(!1),[s,o]=M.useState(!1);return l.jsxs(l.Fragment,{children:[l.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?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&l.jsx(pp,{className:"w-8 h-8 text-bambu-gray"})]}):l.jsx(pp,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:l.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[l.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&l.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function PCe({printers:t}){const e=Mn(),n=M.useMemo(()=>{let i=0,a=0,s=0,o=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?o++:u.connected?u.state==="RUNNING"?i++:a++:s++}),{printing:i,idle:a,offline:s,loading:o,total:t?.length||0}},[t,e]),[,r]=M.useState(0);return M.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(s=>s+1),i=!1}))});return()=>a()},[e]),t?.length?l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function U6(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function z6({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const a=Mn(),s=gb(),[o,c]=M.useState(!1),[u,d]=M.useState(!1),[f,g]=M.useState(!0),[p,x]=M.useState(!1),[v,y]=M.useState(!1),[b,E]=M.useState(!1),[w,A]=M.useState(!1),[T,C]=M.useState(!1),[k,F]=M.useState(!1),[N,j]=M.useState(null),{data:I}=yt({queryKey:["printerStatus",t.id],queryFn:()=>Ce.getPrinterStatus(t.id),refetchInterval:3e4}),[O,q]=M.useState(null);M.useEffect(()=>{I?.wifi_signal!=null&&q(I.wifi_signal)},[I?.wifi_signal]);const R=I?.wifi_signal??O,W=M.useRef(void 0);M.useEffect(()=>{I?.connected!==void 0&&(W.current=I.connected)},[I?.connected]);const K=I?.connected??W.current,G=M.useRef({});M.useEffect(()=>{I?.ams_extruder_map&&Object.keys(I.ams_extruder_map).length>0&&(G.current=I.ams_extruder_map)},[I?.ams_extruder_map]);const te=I?.ams_extruder_map&&Object.keys(I.ams_extruder_map).length>0?I.ams_extruder_map:G.current,Y=M.useRef([]);M.useEffect(()=>{I?.ams&&I.ams.length>0&&(Y.current=I.ams)},[I?.ams]);const J=I?.ams&&I.ams.length>0?I.ams:Y.current,{data:U}=yt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Ce.getSmartPlugByPrinter(t.id)}),{data:H}=yt({queryKey:["smartPlugStatus",U?.id],queryFn:()=>U?Ce.getSmartPlugStatus(U.id):null,enabled:!!U,refetchInterval:1e4}),{data:ee}=yt({queryKey:["queue",t.id,"pending"],queryFn:()=>Ce.getQueue(t.id,"pending")}),ie=ee?.length||0,{data:pe}=yt({queryKey:["archives",t.id,"last"],queryFn:()=>Ce.getArchives(t.id,1,0),enabled:I?.connected&&I?.state!=="RUNNING"}),ue=pe?.[0],be=e&&K===!1,Re=vt({mutationFn:ce=>Ce.deletePrinter(t.id,ce.deleteArchives),onSuccess:()=>{a.invalidateQueries({queryKey:["printers"]}),a.invalidateQueries({queryKey:["archives"]})}}),Z=vt({mutationFn:()=>Ce.connectPrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printerStatus",t.id]})}}),_e=vt({mutationFn:ce=>U?Ce.controlSmartPlug(U.id,ce):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugStatus",U?.id]})}}),Le=vt({mutationFn:ce=>U?Ce.updateSmartPlug(U.id,{auto_off:ce}):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),a.invalidateQueries({queryKey:["smart-plugs"]})}});return be?null:l.jsxs(Mt,{className:"relative",children:[l.jsxs(Nt,{children:[l.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx("img",{src:CCe(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"}`}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&l.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${I?.connected?"bg-bambu-green":"bg-red-500"}`,title:I?.connected?"Connected":"Offline"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&I?.nozzles&&I.nozzles[0]?.nozzle_diameter&&l.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:I.nozzles[0].nozzle_type||"Nozzle",children:["• ",I.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&l.jsxs("span",{className:"ml-2 text-bambu-gray",children:[l.jsx(sr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),l.jsxs("div",{className:"relative flex-shrink-0",children:[l.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>c(!o),children:l.jsx(WR,{className:"w-4 h-4"})}),o&&l.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:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{x(!0),c(!1)},children:[l.jsx(dd,{className:"w-4 h-4"}),"Edit"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Z.mutate(),c(!1)},children:[l.jsx(Na,{className:"w-4 h-4"}),"Reconnect"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{E(!0),c(!1)},children:[l.jsx(_G,{className:"w-4 h-4"}),"MQTT Debug"]}),l.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),c(!1)},children:[l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[l.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${I?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[I?.connected?l.jsx(VS,{className:"w-3 h-3"}):l.jsx(MG,{className:"w-3 h-3"}),I?.connected?"Connected":"Offline"]}),I?.connected&&R!=null&&l.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${R>=-50||R>=-60?"bg-bambu-green/20 text-bambu-green":R>=-70?"bg-amber-500/20 text-amber-600":R>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${R} dBm - ${NCe(R).label}`,children:[l.jsx(hue,{className:"w-3 h-3"}),R,"dBm"]}),I?.connected&&(()=>{const ce=I.hms_errors?yde(I.hms_errors):[];return l.jsxs("button",{onClick:()=>F(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${ce.length>0?ce.some(Ie=>Ie.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[l.jsx(Sr,{className:"w-3 h-3"}),ce.length>0?ce.length:"OK"]})})(),n&&l.jsxs("button",{onClick:()=>s("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[l.jsx(hd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),ie>0&&l.jsxs("button",{onClick:()=>s("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${ie} print${ie>1?"s":""} in queue`,children:[l.jsx(ud,{className:"w-3 h-3"}),ie]})]})]}),u&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:l.jsx(Mt,{className:"w-full max-w-md mx-4",children:l.jsxs(Nt,{children:[l.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[l.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:l.jsx(Sr,{className:"w-5 h-5 text-red-400"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),l.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),l.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:l.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:f,onChange:ce=>g(ce.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:f?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(Pe,{variant:"secondary",onClick:()=>{d(!1),g(!0)},children:"Cancel"}),l.jsx(Pe,{variant:"danger",onClick:()=>{Re.mutate({deleteArchives:f}),d(!1),g(!0)},children:"Delete"})]})]})})}),I?.connected&&l.jsxs(l.Fragment,{children:[r==="compact"?l.jsx("div",{className:"mt-2",children:I.state==="RUNNING"?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:l.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${I.progress||0}%`}})}),l.jsxs("span",{className:"text-xs text-white",children:[Math.round(I.progress||0),"%"]})]}):l.jsx("p",{className:"text-xs text-bambu-gray",children:U6(I.state,I.stg_cur_name)})}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex gap-3",children:[l.jsx(kCe,{url:I.state==="RUNNING"?I.cover_url:null,printName:I.state==="RUNNING"&&(I.subtask_name||I.current_print)||void 0}),l.jsx("div",{className:"flex-1 min-w-0",children:I.current_print&&I.state==="RUNNING"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:I.stg_cur_name||"Printing"}),l.jsx("p",{className:"text-white text-sm mb-2 truncate",children:I.subtask_name||I.current_print}),l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:l.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${I.progress||0}%`}})}),l.jsxs("span",{className:"text-white",children:[Math.round(I.progress||0),"%"]})]}),l.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[I.remaining_time!=null&&I.remaining_time>0&&l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx(sr,{className:"w-3 h-3"}),ACe(I.remaining_time*60)]}),l.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",TCe(I.remaining_time)]})]}),I.layer_num!=null&&I.total_layers!=null&&I.total_layers>0&&l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx(ud,{className:"w-3 h-3"}),I.layer_num,"/",I.total_layers]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),l.jsx("p",{className:"text-white text-sm mb-2",children:U6(I.state,I.stg_cur_name)}),l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:l.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),l.jsx("span",{className:"text-bambu-gray",children:"—"})]}),ue?l.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:ue.print_name||ue.filename,children:["Last: ",ue.print_name||ue.filename,ue.completed_at&&l.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(ue.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):l.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),I.state!=="RUNNING"&&l.jsx(Sde,{printerId:t.id})]}),I.temperatures&&r==="expanded"&&(()=>{const ce=I.temperatures.nozzle_heating||I.temperatures.nozzle_2_heating||!1,Ie=I.temperatures.bed_heating||!1,z=I.temperatures.chamber_heating||!1;return l.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(xC,{className:"w-4 h-4 mx-auto mb-1",color:"text-orange-400",isHeating:ce}),I.temperatures.nozzle_2!==void 0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.nozzle||0),"°C / ",Math.round(I.temperatures.nozzle_2||0),"°C"]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.nozzle||0),"°C"]})]})]}),l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(xC,{className:"w-4 h-4 mx-auto mb-1",color:"text-blue-400",isHeating:Ie}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.bed||0),"°C"]})]}),I.temperatures.chamber!==void 0&&l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(xC,{className:"w-4 h-4 mx-auto mb-1",color:"text-green-400",isHeating:z}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(I.temperatures.chamber||0),"°C"]})]})]})})(),J&&J.length>0&&r==="expanded"&&l.jsxs("div",{className:"mt-3 space-y-2",children:[J.map(ce=>{const Ie=te[String(ce.id)],z=ce.id>=128?ce.id-128:ce.id,B=Ie!==void 0?Ie:z,ne=t.nozzle_count===2||I?.temperatures?.nozzle_2!==void 0,V=B===1,Q=B===0,se=ce.tray.map(Ae=>Ae.tray_color?`#${Ae.tray_color}`:Ae.tray_type?"#333":null),Me=ce.tray.length===1;return l.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[ne&&(V||Q)&&l.jsx(gCe,{side:V?"L":"R"}),Me?l.jsx(bCe,{color:se[0],className:"flex-shrink-0"}):l.jsx(xCe,{colors:se,className:"flex-shrink-0"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:bC(ce.id,ce.tray.length)}),l.jsx("div",{className:"mt-0.5 text-[10px] flex items-start",children:ce.tray.map((Ae,Se)=>l.jsxs("div",{className:"flex items-start",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-bambu-gray/70 truncate",children:Ae.tray_type?Ae.tray_sub_brands||Ae.tray_type:"—"}),l.jsx("span",{className:"text-bambu-gray/50 truncate",children:Ae.tray_type&&Ae.remain>=0?`${Ae.remain}%`:"—"})]}),Se<ce.tray.length-1&&l.jsxs("span",{className:"text-bambu-gray/50 mx-1 flex flex-col",children:[l.jsx("span",{children:"·"}),l.jsx("span",{children:"·"})]})]},Se))})]}),(ce.humidity!=null||ce.temp!=null)&&l.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[ce.humidity!=null&&l.jsx(MCe,{humidity:ce.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>j({amsId:ce.id,amsLabel:bC(ce.id,ce.tray.length),mode:"humidity"})}),ce.temp!=null&&l.jsx(ECe,{temp:ce.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>j({amsId:ce.id,amsLabel:bC(ce.id,ce.tray.length),mode:"temperature"})})]})]})},ce.id)}),I.vt_tray&&I.vt_tray.tray_type&&l.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-white/20 flex-shrink-0",style:{backgroundColor:I.vt_tray.tray_color?`#${I.vt_tray.tray_color}`:"#333"}}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:"External"}),l.jsx("p",{className:"text-[10px] text-bambu-gray/70",children:I.vt_tray.tray_sub_brands||I.vt_tray.tray_type||"Spool"})]})]})})]})]}),U&&r==="expanded"&&l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(_p,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"text-sm text-white truncate",children:U.name}),H&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${H.state==="ON"?"bg-bambu-green/20 text-bambu-green":H.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:H.state||"?"}),H?.energy?.power!=null&&H.state==="ON"&&l.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[H.energy.power,"W"]})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:()=>A(!0),disabled:_e.isPending||H?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${H?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[l.jsx(Ed,{className:"w-3 h-3"}),"On"]}),l.jsxs("button",{onClick:()=>C(!0),disabled:_e.isPending||H?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${H?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[l.jsx(ej,{className:"w-3 h-3"}),"Off"]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx("span",{className:`text-xs hidden sm:inline ${U.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:U.auto_off_executed?"Auto-off done":"Auto-off"}),l.jsx("button",{onClick:()=>Le.mutate(!U.auto_off),disabled:Le.isPending||U.auto_off_executed,title:U.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 ${U.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":U.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:l.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${U.auto_off||U.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&l.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs text-bambu-gray",children:[l.jsx("p",{children:t.ip_address}),l.jsx("p",{className:"truncate",children:t.serial_number})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Pe,{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:!I?.connected,title:"Open camera in new window",children:l.jsx(EG,{className:"w-4 h-4"})}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>y(!0),title:"Browse printer files",children:[l.jsx(ZR,{className:"w-4 h-4"}),"Files"]})]})]})]}),v&&l.jsx(gde,{printerId:t.id,printerName:t.name,onClose:()=>y(!1)}),b&&l.jsx(xde,{printerId:t.id,printerName:t.name,onClose:()=>E(!1)}),w&&U&&l.jsx(fi,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{_e.mutate("on"),A(!1)},onCancel:()=>A(!1)}),T&&U&&l.jsx(fi,{title:"Power Off Printer",message:I?.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:()=>{_e.mutate("off"),C(!1)},onCancel:()=>C(!1)}),k&&l.jsx(_de,{printerName:t.name,errors:I?.hms_errors||[],onClose:()=>F(!1)}),N&&l.jsx(pCe,{isOpen:!!N,onClose:()=>j(null),printerId:t.id,printerName:t.name,amsId:N.amsId,amsLabel:N.amsLabel,initialMode:N.mode,thresholds:i}),p&&l.jsx(jCe,{printer:t,onClose:()=>x(!1)})]})}function RCe({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=M.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,s]=M.useState(!1),[o,c]=M.useState([]),[u,d]=M.useState(""),[f,g]=M.useState(!1),p=o.filter(b=>!n.includes(b.serial)),x=async()=>{d(""),c([]),s(!0),g(!1);try{await ux.startDiscovery(10);const b=setInterval(async()=>{try{const E=await ux.getDiscoveredPrinters();c(E)}catch(E){console.error("Failed to get discovered printers:",E)}},1e3);setTimeout(async()=>{clearInterval(b);try{await ux.stopDiscovery()}catch{}s(!1),g(!0);try{const E=await ux.getDiscoveredPrinters();c(E)}catch(E){console.error("Failed to get final discovered printers:",E)}},1e4)}catch(b){console.error("Failed to start discovery:",b),d(b instanceof Error?b.message:"Failed to start discovery"),s(!1),g(!0)}},v=b=>b?{O1D:"H2D",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D",H2C:"H2C",H2S:"H2S"}[b]||b:"",y=b=>{i({...r,name:b.name||"",serial_number:b.serial,ip_address:b.ip_address,model:v(b.model)}),c([])};return M.useEffect(()=>()=>{ux.stopDiscovery().catch(()=>{})},[]),M.useEffect(()=>{const b=E=>{E.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:l.jsx(Mt,{className:"w-full max-w-md",onClick:b=>b.stopPropagation(),children:l.jsxs(Nt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),l.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:x,disabled:a,className:"w-full",children:a?l.jsxs(l.Fragment,{children:[l.jsx(_t,{className:"w-4 h-4 animate-spin"}),"Scanning..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Rc,{className:"w-4 h-4"}),"Discover Printers on Network"]})}),u&&l.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),p.length>0&&l.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:p.map(b=>l.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>y(b),children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"font-medium text-white text-sm truncate",children:b.name||b.serial}),l.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[b.model||"Unknown"," • ",b.ip_address]})]}),l.jsx(Hc,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},b.serial))}),a&&l.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"Scanning network..."}),f&&!a&&o.length===0&&l.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"No printers found on the network."}),f&&!a&&o.length>0&&p.length===0&&l.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),l.jsxs("form",{onSubmit:b=>{b.preventDefault(),e(r)},className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.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:b=>i({...r,name:b.target.value}),placeholder:"My Printer"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.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:b=>i({...r,ip_address:b.target.value}),placeholder:"192.168.1.100"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.serial_number,onChange:b=>i({...r,serial_number:b.target.value}),placeholder:"01P00A000000000"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:b=>i({...r,access_code:b.target.value}),placeholder:"From printer settings"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),l.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:b=>i({...r,model:b.target.value}),children:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:b=>i({...r,auto_archive:b.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsx(Pe,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function jCe({printer:t,onClose:e}){const n=Mn(),[r,i]=M.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=vt({mutationFn:o=>Ce.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});M.useEffect(()=>{const o=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const s=o=>{o.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsx(Mt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:l.jsxs(Nt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),l.jsxs("form",{onSubmit:s,className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.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}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),l.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:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),l.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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.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"}),l.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Pe,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function DCe(t){const{data:e}=yt({queryKey:["printerStatus",t],queryFn:()=>Ce.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function OCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=DCe(t.id),{data:a}=yt({queryKey:["smartPlugStatus",e.id],queryFn:()=>Ce.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),l.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[l.jsx(Ed,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function LCe(){const[t,e]=M.useState(!1),[n,r]=M.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=M.useState(!1),[s,o]=M.useState(null),[c,u]=M.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=M.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,p]=M.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),x=Mn(),{data:v,isLoading:y}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:b}=yt({queryKey:["settings"],queryFn:Ce.getSettings}),{data:E}=yt({queryKey:["smart-plugs"],queryFn:Ce.getSmartPlugs}),{data:w}=yt({queryKey:["maintenanceOverview"],queryFn:Ce.getMaintenanceOverview,staleTime:60*1e3}),A=w?.reduce((R,W)=>(R[W.printer_id]={due_count:W.due_count,warning_count:W.warning_count,total_print_hours:W.total_print_hours},R),{})||{},T=E?.reduce((R,W)=>(W.printer_id&&(R[W.printer_id]=W),R),{})||{},C=vt({mutationFn:Ce.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),k=vt({mutationFn:R=>Ce.controlSmartPlug(R,"on"),onSuccess:()=>{x.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),F=()=>{const R=!n;r(R),localStorage.setItem("hideDisconnectedPrinters",String(R))},N=R=>{u(R),localStorage.setItem("printerSortBy",R)},j=()=>{const R=!d;f(R),localStorage.setItem("printerSortAsc",String(R))},I=()=>{const R=g==="expanded"?"compact":"expanded";p(R),localStorage.setItem("printerViewMode",R)},O=M.useMemo(()=>{if(!v)return[];const R=[...v];switch(c){case"name":R.sort((W,K)=>W.name.localeCompare(K.name));break;case"model":R.sort((W,K)=>(W.model||"").localeCompare(K.model||""));break;case"location":R.sort((W,K)=>{const G=W.location||"",te=K.location||"";return!G&&te?1:G&&!te?-1:G.localeCompare(te)||W.name.localeCompare(K.name)});break;case"status":R.sort((W,K)=>{const G=x.getQueryData(["printerStatus",W.id]),te=x.getQueryData(["printerStatus",K.id]),Y=J=>J?.connected?J.state==="RUNNING"?0:1:2;return Y(G)-Y(te)});break}return d||R.reverse(),R},[v,c,d,x]),q=M.useMemo(()=>{if(c!=="location")return null;const R={};return O.forEach(W=>{const K=W.location||"Ungrouped";R[K]||(R[K]=[]),R[K].push(W)}),R},[c,O]);return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),l.jsx(PCe,{printers:v})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("select",{value:c,onChange:R=>N(R.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:[l.jsx("option",{value:"name",children:"Name"}),l.jsx("option",{value:"status",children:"Status"}),l.jsx("option",{value:"model",children:"Model"}),l.jsx("option",{value:"location",children:"Location"})]}),l.jsx("button",{onClick:j,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?l.jsx(mp,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(_0,{className:"w-4 h-4 text-bambu-gray"})})]}),l.jsx("button",{onClick:I,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"?l.jsx(Qle,{className:"w-5 h-5 text-bambu-gray"}):l.jsx(gG,{className:"w-5 h-5 text-bambu-gray"})}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:n,onChange:F,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(T).length>0&&l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[l.jsx(Ed,{className:"w-4 h-4"}),"Power On",l.jsx(Hc,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),l.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:[l.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"}),v?.filter(R=>T[R.id]).map(R=>l.jsx(OCe,{printer:R,plug:T[R.id],onPowerOn:W=>{o(W),k.mutate(W)},isPowering:s===T[R.id]?.id},R.id)),v?.filter(R=>T[R.id]).length===0&&l.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),l.jsxs(Pe,{onClick:()=>e(!0),children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),y?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):v?.length===0?l.jsx(Mt,{children:l.jsxs(Nt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),l.jsxs(Pe,{onClick:()=>e(!0),children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?l.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([R,W])=>l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),R,l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.length,")"]})]}),l.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:W.map(K=>l.jsx(z6,{printer:K,hideIfDisconnected:n,maintenanceInfo:A[K.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},K.id))})]},R))}):l.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:O.map(R=>l.jsx(z6,{printer:R,hideIfDisconnected:n,maintenanceInfo:A[R.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},R.id))}),t&&l.jsx(RCe,{onClose:()=>e(!1),onAdd:R=>C.mutate(R),existingSerials:v?.map(R=>R.serial_number)||[]})]})}const sO="181",ap={ROTATE:0,DOLLY:1,PAN:2},Ym={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ICe=0,B6=1,FCe=2,GY=1,UCe=2,ac=3,bd=0,Za=1,rl=2,Ec=0,sp=1,H6=2,$6=3,V6=4,zCe=5,fh=100,BCe=101,HCe=102,$Ce=103,VCe=104,GCe=200,WCe=201,qCe=202,KCe=203,$3=204,V3=205,XCe=206,YCe=207,ZCe=208,QCe=209,JCe=210,eNe=211,tNe=212,nNe=213,rNe=214,G3=0,W3=1,q3=2,kp=3,K3=4,X3=5,Y3=6,Z3=7,oO=0,iNe=1,aNe=2,td=0,sNe=1,oNe=2,lNe=3,cNe=4,uNe=5,dNe=6,hNe=7,WY=300,Pp=301,Rp=302,Q3=303,J3=304,HM=306,eP=1e3,xc=1001,tP=1002,Es=1003,fNe=1004,Iv=1005,io=1006,yC=1007,Sh=1008,xl=1009,qY=1010,KY=1011,V0=1012,lO=1013,nf=1014,bc=1015,ug=1016,cO=1017,uO=1018,G0=1020,XY=35902,YY=35899,ZY=1021,QY=1022,jo=1023,W0=1026,q0=1027,JY=1028,dO=1029,hO=1030,fO=1031,mO=1033,c1=33776,u1=33777,d1=33778,h1=33779,nP=35840,rP=35841,iP=35842,aP=35843,sP=36196,oP=37492,lP=37496,cP=37808,uP=37809,dP=37810,hP=37811,fP=37812,mP=37813,pP=37814,gP=37815,xP=37816,bP=37817,yP=37818,vP=37819,_P=37820,wP=37821,SP=36492,MP=36494,EP=36495,AP=36283,TP=36284,CP=36285,NP=36286,mNe=3200,pNe=3201,eZ=0,gNe=1,$u="",Ks="srgb",jp="srgb-linear",jw="linear",Kn="srgb",rm=7680,G6=519,xNe=512,bNe=513,yNe=514,tZ=515,vNe=516,_Ne=517,wNe=518,SNe=519,W6=35044,q6="300 es",ol=2e3,Dw=2001;function nZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Ow(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function MNe(){const t=Ow("canvas");return t.style.display="block",t}const K6={};function X6(...t){const e="THREE."+t.shift();console.log(e,...t)}function Yt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Hr(...t){const e="THREE."+t.shift();console.error(e,...t)}function K0(...t){const e=t.join(" ");e in K6||(K6[e]=!0,Yt(...t))}function ENe(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let xf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}};const aa=["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"],f1=Math.PI/180,kP=180/Math.PI;function Kb(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(aa[t&255]+aa[t>>8&255]+aa[t>>16&255]+aa[t>>24&255]+"-"+aa[e&255]+aa[e>>8&255]+"-"+aa[e>>16&15|64]+aa[e>>24&255]+"-"+aa[n&63|128]+aa[n>>8&255]+"-"+aa[n>>16&255]+aa[n>>24&255]+aa[r&255]+aa[r>>8&255]+aa[r>>16&255]+aa[r>>24&255]).toLowerCase()}function gn(t,e,n){return Math.max(e,Math.min(n,t))}function ANe(t,e){return(t%e+e)%e}function vC(t,e,n){return(1-n)*t+n*e}function yx(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 Ha(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 TNe={DEG2RAD:f1};let cn=class rZ{constructor(e=0,n=0){rZ.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=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(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(gn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},rf=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,o){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=a[s+0],p=a[s+1],x=a[s+2],v=a[s+3];if(o<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o>=1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==x){let y=c*g+u*p+d*x+f*v;y<0&&(g=-g,p=-p,x=-x,v=-v,y=-y);let b=1-o;if(y<.9995){const E=Math.acos(y),w=Math.sin(E);b=Math.sin(b*E)/w,o=Math.sin(o*E)/w,c=c*b+g*o,u=u*b+p*o,d=d*b+x*o,f=f*b+v*o}else{c=c*b+g*o,u=u*b+p*o,d=d*b+x*o,f=f*b+v*o;const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],p=a[s+2],x=a[s+3];return e[n]=o*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-o*p,e[n+2]=u*x+d*p+o*g-c*f,e[n+3]=d*x-o*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),d=o(i/2),f=o(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:Yt("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(s-i)*p}else if(r>o&&r>f){const p=2*Math.sqrt(1+r-o-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+s)/p,this._z=(a+u)/p}else if(o>f){const p=2*Math.sqrt(1+o-r-f);this._w=(a-u)/p,this._x=(i+s)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-o);this._w=(s-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(gn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*o+i*u-a*c,this._y=i*d+s*c+a*o-r*u,this._z=a*d+s*u+r*c-i*o,this._w=s*d-r*o-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,a=-a,s=-s,o=-o);let c=1-n;if(o<.9995){const u=Math.acos(o),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},et=class iZ{constructor(e=0,n=0,r=0){iZ.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(Y6.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Y6.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),d=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-o*d,this.y=r+c*d+o*u-a*f,this.z=i+c*f+a*d-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return _C.copy(this).projectOnVector(e),this.sub(_C)}reflect(e){return this.sub(_C.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(gn(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 _C=new et,Y6=new rf;let dn=class aZ{constructor(e,n,r,i,a,s,o,c,u){aZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],v=i[0],y=i[3],b=i[6],E=i[1],w=i[4],A=i[7],T=i[2],C=i[5],k=i[8];return a[0]=s*v+o*E+c*T,a[3]=s*y+o*w+c*C,a[6]=s*b+o*A+c*k,a[1]=u*v+d*E+f*T,a[4]=u*y+d*w+f*C,a[7]=u*b+d*A+f*k,a[2]=g*v+p*E+x*T,a[5]=g*y+p*w+x*C,a[8]=g*b+p*A+x*k,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*o*u-r*a*d+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*s-o*u,g=o*c-d*a,p=u*a-s*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(o*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-o*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(wC.makeScale(e,n)),this}rotate(e){return this.premultiply(wC.makeRotation(-e)),this}translate(e,n){return this.premultiply(wC.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 wC=new dn,Z6=new dn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Q6=new dn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function CNe(){const t={enabled:!0,workingColorSpace:jp,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Kn&&(i.r=Ac(i.r),i.g=Ac(i.g),i.b=Ac(i.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Kn&&(i.r=op(i.r),i.g=op(i.g),i.b=op(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===$u?jw:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return K0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return K0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[jp]:{primaries:e,whitePoint:r,transfer:jw,toXYZ:Z6,fromXYZ:Q6,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ks},outputColorSpaceConfig:{drawingBufferColorSpace:Ks}},[Ks]:{primaries:e,whitePoint:r,transfer:Kn,toXYZ:Z6,fromXYZ:Q6,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ks}}}),t}const Nn=CNe();function Ac(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function op(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let im,NNe=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{im===void 0&&(im=Ow("canvas")),im.width=e.width,im.height=e.height;const i=im.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=im}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=Ow("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let s=0;s<a.length;s++)a[s]=Ac(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Ac(n[r]/255)*255):n[r]=Ac(n[r]);return{data:n,width:e.width,height:e.height}}else return Yt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},kNe=0,pO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:kNe++}),this.uuid=Kb(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(SC(i[s].image)):a.push(SC(i[s]))}else a=SC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function SC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?NNe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Yt("Texture: Unable to serialize Texture."),{})}let PNe=0;const MC=new et;let $o=class m1 extends xf{constructor(e=m1.DEFAULT_IMAGE,n=m1.DEFAULT_MAPPING,r=xc,i=xc,a=io,s=Sh,o=jo,c=xl,u=m1.DEFAULT_ANISOTROPY,d=$u){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:PNe++}),this.uuid=Kb(),this.name="",this.source=new pO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new cn(0,0),this.repeat=new cn(1,1),this.center=new cn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dn,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(MC).x}get height(){return this.source.getSize(MC).y}get depth(){return this.source.getSize(MC).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){Yt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`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!==WY)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case eP:e.x=e.x-Math.floor(e.x);break;case xc:e.x=e.x<0?0:1;break;case tP: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 eP:e.y=e.y-Math.floor(e.y);break;case xc:e.y=e.y<0?0:1;break;case tP: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++}};$o.DEFAULT_IMAGE=null;$o.DEFAULT_MAPPING=WY;$o.DEFAULT_ANISOTROPY=1;let ei=class sZ{constructor(e=0,n=0,r=0,i=1){sZ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,T=(b+1)/2,C=(d+g)/4,k=(f+v)/4,F=(x+y)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=k/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=F/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=k/a,i=F/a),this.set(r,i,a,n),this}let E=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(y-x)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+b-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=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this.w=gn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this.w=gn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(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}},RNe=class extends xf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:io,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 ei(0,0,e,n),this.scissorTest=!1,this.viewport=new ei(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new $o(i);this.textures=[];const s=r.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:io,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new pO(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"})}},af=class extends RNe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},oZ=class extends $o{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=Es,this.minFilter=Es,this.wrapR=xc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},jNe=class extends $o{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=Es,this.minFilter=Es,this.wrapR=xc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},sf=class{constructor(e=new et(1/0,1/0,1/0),n=new et(-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(_o.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(_o.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=_o.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,_o):_o.fromBufferAttribute(a,s),_o.applyMatrix4(e.matrixWorld),this.expandByPoint(_o);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Fv.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Fv.copy(r.boundingBox)),Fv.applyMatrix4(e.matrixWorld),this.union(Fv)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,_o),_o.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(vx),Uv.subVectors(this.max,vx),am.subVectors(e.a,vx),sm.subVectors(e.b,vx),om.subVectors(e.c,vx),yu.subVectors(sm,am),vu.subVectors(om,sm),Xd.subVectors(am,om);let n=[0,-yu.z,yu.y,0,-vu.z,vu.y,0,-Xd.z,Xd.y,yu.z,0,-yu.x,vu.z,0,-vu.x,Xd.z,0,-Xd.x,-yu.y,yu.x,0,-vu.y,vu.x,0,-Xd.y,Xd.x,0];return!EC(n,am,sm,om,Uv)||(n=[1,0,0,0,1,0,0,0,1],!EC(n,am,sm,om,Uv))?!1:(zv.crossVectors(yu,vu),n=[zv.x,zv.y,zv.z],EC(n,am,sm,om,Uv))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,_o).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(_o).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:(Gl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gl),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 Gl=[new et,new et,new et,new et,new et,new et,new et,new et],_o=new et,Fv=new sf,am=new et,sm=new et,om=new et,yu=new et,vu=new et,Xd=new et,vx=new et,Uv=new et,zv=new et,Yd=new et;function EC(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){Yd.fromArray(t,a);const o=i.x*Math.abs(Yd.x)+i.y*Math.abs(Yd.y)+i.z*Math.abs(Yd.z),c=e.dot(Yd),u=n.dot(Yd),d=r.dot(Yd);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>o)return!1}return!0}const DNe=new sf,_x=new et,AC=new et;let $M=class{constructor(e=new et,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):DNe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;_x.subVectors(e,this.center);const n=_x.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(_x,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):(AC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(_x.copy(e.center).add(AC)),this.expandByPoint(_x.copy(e.center).sub(AC))),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 Wl=new et,TC=new et,Bv=new et,_u=new et,CC=new et,Hv=new et,NC=new et;let gO=class{constructor(e=new et,n=new et(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,Wl)),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=Wl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Wl.copy(this.origin).addScaledVector(this.direction,n),Wl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){TC.copy(e).add(n).multiplyScalar(.5),Bv.copy(n).sub(e).normalize(),_u.copy(this.origin).sub(TC);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Bv),o=_u.dot(this.direction),c=-_u.dot(Bv),u=_u.lengthSq(),d=Math.abs(1-s*s);let f,g,p,x;if(d>0)if(f=s*c-o,g=s*o-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,p=f*(f+s*g+2*o)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+o)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+o)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+o)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(TC).addScaledVector(Bv,g),p}intersectSphere(e,n){Wl.subVectors(e.center,this.origin);const r=Wl.dot(this.direction),i=Wl.dot(Wl)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Wl)!==null}intersectTriangle(e,n,r,i,a){CC.subVectors(n,e),Hv.subVectors(r,e),NC.crossVectors(CC,Hv);let s=this.direction.dot(NC),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;_u.subVectors(this.origin,e);const c=o*this.direction.dot(Hv.crossVectors(_u,Hv));if(c<0)return null;const u=o*this.direction.dot(CC.cross(_u));if(u<0||c+u>s)return null;const d=-o*_u.dot(NC);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ii=class PP{constructor(e,n,r,i,a,s,o,c,u,d,f,g,p,x,v,y){PP.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u,d,f,g,p,x,v,y)}set(e,n,r,i,a,s,o,c,u,d,f,g,p,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=o,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=p,b[7]=x,b[11]=v,b[15]=y,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 PP().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/lm.setFromMatrixColumn(e,0).length(),a=1/lm.setFromMatrixColumn(e,1).length(),s=1/lm.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,p=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-v*u,n[9]=-o*c,n[2]=v-g*u,n[6]=x+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g+v*o,n[4]=x*o-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=p*o-x,n[6]=v+g*o,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g-v*o,n[4]=-s*f,n[8]=x+p*o,n[1]=p+x*o,n[5]=s*d,n[9]=v-g*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,p=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-x,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+p,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=o*d,n[10]=v*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(ONe,e,LNe)}lookAt(e,n,r){const i=this.elements;return ms.subVectors(e,n),ms.lengthSq()===0&&(ms.z=1),ms.normalize(),wu.crossVectors(r,ms),wu.lengthSq()===0&&(Math.abs(r.z)===1?ms.x+=1e-4:ms.z+=1e-4,ms.normalize(),wu.crossVectors(r,ms)),wu.normalize(),$v.crossVectors(ms,wu),i[0]=wu.x,i[4]=$v.x,i[8]=ms.x,i[1]=wu.y,i[5]=$v.y,i[9]=ms.y,i[2]=wu.z,i[6]=$v.z,i[10]=ms.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],v=r[6],y=r[10],b=r[14],E=r[3],w=r[7],A=r[11],T=r[15],C=i[0],k=i[4],F=i[8],N=i[12],j=i[1],I=i[5],O=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],te=i[3],Y=i[7],J=i[11],U=i[15];return a[0]=s*C+o*j+c*R+u*te,a[4]=s*k+o*I+c*W+u*Y,a[8]=s*F+o*O+c*K+u*J,a[12]=s*N+o*q+c*G+u*U,a[1]=d*C+f*j+g*R+p*te,a[5]=d*k+f*I+g*W+p*Y,a[9]=d*F+f*O+g*K+p*J,a[13]=d*N+f*q+g*G+p*U,a[2]=x*C+v*j+y*R+b*te,a[6]=x*k+v*I+y*W+b*Y,a[10]=x*F+v*O+y*K+b*J,a[14]=x*N+v*q+y*G+b*U,a[3]=E*C+w*j+A*R+T*te,a[7]=E*k+w*I+A*W+T*Y,a[11]=E*F+w*O+A*K+T*J,a[15]=E*N+w*q+A*G+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*o*g+r*u*g+i*o*p-r*c*p)+v*(+n*c*p-n*u*g+a*s*g-i*s*p+i*u*d-a*c*d)+y*(+n*u*f-n*o*p-a*s*f+r*s*p+a*o*d-r*u*d)+b*(-i*o*d-n*c*f+n*o*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],v=e[13],y=e[14],b=e[15],E=f*y*u-v*g*u+v*c*p-o*y*p-f*c*b+o*g*b,w=x*g*u-d*y*u-x*c*p+s*y*p+d*c*b-s*g*b,A=d*v*u-x*f*u+x*o*p-s*v*p-d*o*b+s*f*b,T=x*f*c-d*v*c-x*o*g+s*v*g+d*o*y-s*f*y,C=n*E+r*w+i*A+a*T;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/C;return e[0]=E*k,e[1]=(v*g*a-f*y*a-v*i*p+r*y*p+f*i*b-r*g*b)*k,e[2]=(o*y*a-v*c*a+v*i*u-r*y*u-o*i*b+r*c*b)*k,e[3]=(f*c*a-o*g*a-f*i*u+r*g*u+o*i*p-r*c*p)*k,e[4]=w*k,e[5]=(d*y*a-x*g*a+x*i*p-n*y*p-d*i*b+n*g*b)*k,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*k,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*p+n*c*p)*k,e[8]=A*k,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*b-n*f*b)*k,e[10]=(s*v*a-x*o*a+x*r*u-n*v*u-s*r*b+n*o*b)*k,e[11]=(d*o*a-s*f*a-d*r*u+n*f*u+s*r*p-n*o*p)*k,e[12]=T*k,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*k,e[14]=(x*o*i-s*v*i-x*r*c+n*v*c+s*r*y-n*o*y)*k,e[15]=(s*f*i-d*o*i+d*r*c-n*f*c-s*r*g+n*o*g)*k,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,c=e.z,u=a*s,d=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*s,0,u*c-i*o,d*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,d=s+s,f=o+o,g=a*u,p=a*d,x=a*f,v=s*d,y=s*f,b=o*f,E=c*u,w=c*d,A=c*f,T=r.x,C=r.y,k=r.z;return i[0]=(1-(v+b))*T,i[1]=(p+A)*T,i[2]=(x-w)*T,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+b))*C,i[6]=(y+E)*C,i[7]=0,i[8]=(x+w)*k,i[9]=(y-E)*k,i[10]=(1-(g+v))*k,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=lm.set(i[0],i[1],i[2]).length();const s=lm.set(i[4],i[5],i[6]).length(),o=lm.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],wo.copy(this);const u=1/a,d=1/s,f=1/o;return wo.elements[0]*=u,wo.elements[1]*=u,wo.elements[2]*=u,wo.elements[4]*=d,wo.elements[5]*=d,wo.elements[6]*=d,wo.elements[8]*=f,wo.elements[9]*=f,wo.elements[10]*=f,n.setFromRotationMatrix(wo),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=ol,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),p=(r+i)/(r-i);let x,v;if(c)x=a/(s-a),v=s*a/(s-a);else if(o===ol)x=-(s+a)/(s-a),v=-2*s*a/(s-a);else if(o===Dw)x=-s/(s-a),v=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=ol,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,v;if(c)x=1/(s-a),v=s/(s-a);else if(o===ol)x=-2/(s-a),v=-(s+a)/(s-a);else if(o===Dw)x=-1/(s-a),v=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const lm=new et,wo=new ii,ONe=new et(0,0,0),LNe=new et(1,1,1),wu=new et,$v=new et,ms=new et,J6=new ii,eH=new rf;let yd=class lZ{constructor(e=0,n=0,r=0,i=lZ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(gn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-gn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(gn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-gn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(gn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-gn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:Yt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return J6.makeRotationFromQuaternion(e),this.setFromRotationMatrix(J6,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return eH.setFromEuler(this),this.setFromQuaternion(eH,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}};yd.DEFAULT_ORDER="XYZ";let cZ=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}},INe=0;const tH=new et,cm=new rf,ql=new ii,Vv=new et,wx=new et,FNe=new et,UNe=new rf,nH=new et(1,0,0),rH=new et(0,1,0),iH=new et(0,0,1),aH={type:"added"},zNe={type:"removed"},um={type:"childadded",child:null},kC={type:"childremoved",child:null};let ks=class p1 extends xf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:INe++}),this.uuid=Kb(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=p1.DEFAULT_UP.clone();const e=new et,n=new yd,r=new rf,i=new et(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ii},normalMatrix:{value:new dn}}),this.matrix=new ii,this.matrixWorld=new ii,this.matrixAutoUpdate=p1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=p1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new cZ,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 cm.setFromAxisAngle(e,n),this.quaternion.multiply(cm),this}rotateOnWorldAxis(e,n){return cm.setFromAxisAngle(e,n),this.quaternion.premultiply(cm),this}rotateX(e){return this.rotateOnAxis(nH,e)}rotateY(e){return this.rotateOnAxis(rH,e)}rotateZ(e){return this.rotateOnAxis(iH,e)}translateOnAxis(e,n){return tH.copy(e).applyQuaternion(this.quaternion),this.position.add(tH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(nH,e)}translateY(e){return this.translateOnAxis(rH,e)}translateZ(e){return this.translateOnAxis(iH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ql.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Vv.copy(e):Vv.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),wx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ql.lookAt(wx,Vv,this.up):ql.lookAt(Vv,wx,this.up),this.quaternion.setFromRotationMatrix(ql),i&&(ql.extractRotation(i.matrixWorld),cm.setFromRotationMatrix(ql),this.quaternion.premultiply(cm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Hr("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(aH),um.child=e,this.dispatchEvent(um),um.child=null):Hr("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(zNe),kC.child=e,this.dispatchEvent(kC),kC.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),ql.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ql.multiply(e.parent.matrixWorld)),e.applyMatrix4(ql),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(aH),um.child=e,this.dispatchEvent(um),um.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wx,e,FNe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(wx,UNe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),p=s(e.animations),x=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(o){const c=[];for(const u in o){const d=o[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};ks.DEFAULT_UP=new et(0,1,0);ks.DEFAULT_MATRIX_AUTO_UPDATE=!0;ks.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const So=new et,Kl=new et,PC=new et,Xl=new et,dm=new et,hm=new et,sH=new et,RC=new et,jC=new et,DC=new et,OC=new ei,LC=new ei,IC=new ei;let Sx=class Bm{constructor(e=new et,n=new et,r=new et){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),So.subVectors(e,n),i.cross(So);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){So.subVectors(i,n),Kl.subVectors(r,n),PC.subVectors(e,n);const s=So.dot(So),o=So.dot(Kl),c=So.dot(PC),u=Kl.dot(Kl),d=Kl.dot(PC),f=s*u-o*o;if(f===0)return a.set(0,0,0),null;const g=1/f,p=(u*c-o*d)*g,x=(s*d-o*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Xl)===null?!1:Xl.x>=0&&Xl.y>=0&&Xl.x+Xl.y<=1}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,Xl)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,Xl.x),c.addScaledVector(s,Xl.y),c.addScaledVector(o,Xl.z),c)}static getInterpolatedAttribute(e,n,r,i,a,s){return OC.setScalar(0),LC.setScalar(0),IC.setScalar(0),OC.fromBufferAttribute(e,n),LC.fromBufferAttribute(e,r),IC.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(OC,a.x),s.addScaledVector(LC,a.y),s.addScaledVector(IC,a.z),s}static isFrontFacing(e,n,r,i){return So.subVectors(r,n),Kl.subVectors(e,n),So.cross(Kl).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 So.subVectors(this.c,this.b),Kl.subVectors(this.a,this.b),So.cross(Kl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Bm.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Bm.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Bm.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Bm.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Bm.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;dm.subVectors(i,r),hm.subVectors(a,r),RC.subVectors(e,r);const c=dm.dot(RC),u=hm.dot(RC);if(c<=0&&u<=0)return n.copy(r);jC.subVectors(e,i);const d=dm.dot(jC),f=hm.dot(jC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return s=c/(c-d),n.copy(r).addScaledVector(dm,s);DC.subVectors(e,a);const p=dm.dot(DC),x=hm.dot(DC);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(hm,o);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return sH.subVectors(a,i),o=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(sH,o);const b=1/(y+v+g);return s=v*b,o=g*b,n.copy(r).addScaledVector(dm,s).addScaledVector(hm,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const uZ={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},Su={h:0,s:0,l:0},Gv={h:0,s:0,l:0};function FC(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 _n=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=Ks){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Nn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Nn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Nn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Nn.workingColorSpace){if(e=ANe(e,1),n=gn(n,0,1),r=gn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=FC(s,a,e+1/3),this.g=FC(s,a,e),this.b=FC(s,a,e-1/3)}return Nn.colorSpaceToWorking(this,i),this}setStyle(e,n=Ks){function r(a){a!==void 0&&parseFloat(a)<1&&Yt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:Yt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);Yt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ks){const r=uZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Yt("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=Ac(e.r),this.g=Ac(e.g),this.b=Ac(e.b),this}copyLinearToSRGB(e){return this.r=op(e.r),this.g=op(e.g),this.b=op(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ks){return Nn.workingToColorSpace(sa.copy(this),e),Math.round(gn(sa.r*255,0,255))*65536+Math.round(gn(sa.g*255,0,255))*256+Math.round(gn(sa.b*255,0,255))}getHexString(e=Ks){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Nn.workingColorSpace){Nn.workingToColorSpace(sa.copy(this),n);const r=sa.r,i=sa.g,a=sa.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const d=(o+s)/2;if(o===s)c=0,u=0;else{const f=s-o;switch(u=d<=.5?f/(s+o):f/(2-s-o),s){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Nn.workingColorSpace){return Nn.workingToColorSpace(sa.copy(this),n),e.r=sa.r,e.g=sa.g,e.b=sa.b,e}getStyle(e=Ks){Nn.workingToColorSpace(sa.copy(this),e);const n=sa.r,r=sa.g,i=sa.b;return e!==Ks?`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(Su),this.setHSL(Su.h+e,Su.s+n,Su.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(Su),e.getHSL(Gv);const r=vC(Su.h,Gv.h,n),i=vC(Su.s,Gv.s,n),a=vC(Su.l,Gv.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const sa=new _n;_n.NAMES=uZ;let BNe=0,dg=class extends xf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:BNe++}),this.uuid=Kb(),this.name="",this.type="Material",this.blending=sp,this.side=bd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=$3,this.blendDst=V3,this.blendEquation=fh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _n(0,0,0),this.blendAlpha=0,this.depthFunc=kp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=G6,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=rm,this.stencilZFail=rm,this.stencilZPass=rm,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){Yt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`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!==sp&&(r.blending=this.blending),this.side!==bd&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==$3&&(r.blendSrc=this.blendSrc),this.blendDst!==V3&&(r.blendDst=this.blendDst),this.blendEquation!==fh&&(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!==kp&&(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!==G6&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==rm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==rm&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},xO=class extends dg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _n(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 yd,this.combine=oO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const Zr=new et,Wv=new cn;let HNe=0,ao=class{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:HNe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=W6,this.updateRanges=[],this.gpuType=bc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)Wv.fromBufferAttribute(this,n),Wv.applyMatrix3(e),this.setXY(n,Wv.x,Wv.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Zr.fromBufferAttribute(this,n),Zr.applyMatrix3(e),this.setXYZ(n,Zr.x,Zr.y,Zr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Zr.fromBufferAttribute(this,n),Zr.applyMatrix4(e),this.setXYZ(n,Zr.x,Zr.y,Zr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Zr.fromBufferAttribute(this,n),Zr.applyNormalMatrix(e),this.setXYZ(n,Zr.x,Zr.y,Zr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Zr.fromBufferAttribute(this,n),Zr.transformDirection(e),this.setXYZ(n,Zr.x,Zr.y,Zr.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=yx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ha(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=yx(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ha(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=yx(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ha(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=yx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ha(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=yx(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ha(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ha(n,this.array),r=Ha(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=Ha(n,this.array),r=Ha(r,this.array),i=Ha(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Ha(n,this.array),r=Ha(r,this.array),i=Ha(i,this.array),a=Ha(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==W6&&(e.usage=this.usage),e}},dZ=class extends ao{constructor(e,n,r){super(new Uint16Array(e),n,r)}},hZ=class extends ao{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Io=class extends ao{constructor(e,n,r){super(new Float32Array(e),n,r)}},$Ne=0;const Bs=new ii,UC=new ks,fm=new et,ps=new sf,Mx=new sf,Ni=new et;let Al=class fZ extends xf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$Ne++}),this.uuid=Kb(),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(nZ(e)?hZ:dZ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new dn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Bs.makeRotationFromQuaternion(e),this.applyMatrix4(Bs),this}rotateX(e){return Bs.makeRotationX(e),this.applyMatrix4(Bs),this}rotateY(e){return Bs.makeRotationY(e),this.applyMatrix4(Bs),this}rotateZ(e){return Bs.makeRotationZ(e),this.applyMatrix4(Bs),this}translate(e,n,r){return Bs.makeTranslation(e,n,r),this.applyMatrix4(Bs),this}scale(e,n,r){return Bs.makeScale(e,n,r),this.applyMatrix4(Bs),this}lookAt(e){return UC.lookAt(e),UC.updateMatrix(),this.applyMatrix4(UC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fm).negate(),this.translate(fm.x,fm.y,fm.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new Io(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&Yt("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 sf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Hr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new et(-1/0,-1/0,-1/0),new et(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ps.setFromBufferAttribute(a),this.morphTargetsRelative?(Ni.addVectors(this.boundingBox.min,ps.min),this.boundingBox.expandByPoint(Ni),Ni.addVectors(this.boundingBox.max,ps.max),this.boundingBox.expandByPoint(Ni)):(this.boundingBox.expandByPoint(ps.min),this.boundingBox.expandByPoint(ps.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Hr('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 $M);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Hr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new et,1/0);return}if(e){const r=this.boundingSphere.center;if(ps.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Mx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ni.addVectors(ps.min,Mx.min),ps.expandByPoint(Ni),Ni.addVectors(ps.max,Mx.max),ps.expandByPoint(Ni)):(ps.expandByPoint(Mx.min),ps.expandByPoint(Mx.max))}ps.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Ni.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ni));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ni.fromBufferAttribute(o,u),c&&(fm.fromBufferAttribute(e,u),Ni.add(fm)),i=Math.max(i,r.distanceToSquared(Ni))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Hr('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){Hr("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ao(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),o=[],c=[];for(let F=0;F<r.count;F++)o[F]=new et,c[F]=new et;const u=new et,d=new et,f=new et,g=new cn,p=new cn,x=new cn,v=new et,y=new et;function b(F,N,j){u.fromBufferAttribute(r,F),d.fromBufferAttribute(r,N),f.fromBufferAttribute(r,j),g.fromBufferAttribute(a,F),p.fromBufferAttribute(a,N),x.fromBufferAttribute(a,j),d.sub(u),f.sub(u),p.sub(g),x.sub(g);const I=1/(p.x*x.y-x.x*p.y);isFinite(I)&&(v.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(I),y.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(I),o[F].add(v),o[N].add(v),o[j].add(v),c[F].add(y),c[N].add(y),c[j].add(y))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let F=0,N=E.length;F<N;++F){const j=E[F],I=j.start,O=j.count;for(let q=I,R=I+O;q<R;q+=3)b(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const w=new et,A=new et,T=new et,C=new et;function k(F){T.fromBufferAttribute(i,F),C.copy(T);const N=o[F];w.copy(N),w.sub(T.multiplyScalar(T.dot(N))).normalize(),A.crossVectors(C,N);const I=A.dot(c[F])<0?-1:1;s.setXYZW(F,w.x,w.y,w.z,I)}for(let F=0,N=E.length;F<N;++F){const j=E[F],I=j.start,O=j.count;for(let q=I,R=I+O;q<R;q+=3)k(e.getX(q+0)),k(e.getX(q+1)),k(e.getX(q+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new ao(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new et,a=new et,s=new et,o=new et,c=new et,u=new et,d=new et,f=new et;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),o.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),o.add(d),c.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),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++)Ni.fromBufferAttribute(e,n),Ni.normalize(),e.setXYZ(n,Ni.x,Ni.y,Ni.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,y=c.length;v<y;v++){o.isInterleavedBufferAttribute?p=c[v]*o.data.stride+o.offset:p=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[p++]}return new ao(g,d,f)}if(this.index===null)return Yt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new fZ,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const oH=new ii,Zd=new gO,qv=new $M,lH=new et,Kv=new et,Xv=new et,Yv=new et,zC=new et,Zv=new et,cH=new et,Qv=new et;let bl=class extends ks{constructor(e=new Al,n=new xO){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){Zv.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=o[c],f=a[c];d!==0&&(zC.fromBufferAttribute(f,e),s?Zv.addScaledVector(zC,d):Zv.addScaledVector(zC.sub(n),d))}n.add(Zv)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),qv.copy(r.boundingSphere),qv.applyMatrix4(a),Zd.copy(e.ray).recast(e.near),!(qv.containsPoint(Zd.origin)===!1&&(Zd.intersectSphere(qv,lH)===null||Zd.origin.distanceToSquared(lH)>(e.far-e.near)**2))&&(oH.copy(a).invert(),Zd.copy(e.ray).applyMatrix4(oH),!(r.boundingBox!==null&&Zd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Zd)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,p=a.drawRange;if(o!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(o.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=o.getX(A),k=o.getX(A+1),F=o.getX(A+2);i=Jv(this,b,e,r,u,d,f,C,k,F),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=o.getX(y),w=o.getX(y+1),A=o.getX(y+2);i=Jv(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=A,k=A+1,F=A+2;i=Jv(this,b,e,r,u,d,f,C,k,F),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=y,w=y+1,A=y+2;i=Jv(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}};function VNe(t,e,n,r,i,a,s,o){let c;if(e.side===Za?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===bd,o),c===null)return null;Qv.copy(o),Qv.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Qv);return u<n.near||u>n.far?null:{distance:u,point:Qv.clone(),object:t}}function Jv(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Kv),t.getVertexPosition(c,Xv),t.getVertexPosition(u,Yv);const d=VNe(t,e,n,r,Kv,Xv,Yv,cH);if(d){const f=new et;Sx.getBarycoord(cH,Kv,Xv,Yv,f),i&&(d.uv=Sx.getInterpolatedAttribute(i,o,c,u,f,new cn)),a&&(d.uv1=Sx.getInterpolatedAttribute(a,o,c,u,f,new cn)),s&&(d.normal=Sx.getInterpolatedAttribute(s,o,c,u,f,new et),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:c,c:u,normal:new et,materialIndex:0};Sx.getNormal(Kv,Xv,Yv,g.normal),d.face=g,d.barycoord=f}return d}let bO=class mZ extends Al{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Io(u,3)),this.setAttribute("normal",new Io(d,3)),this.setAttribute("uv",new Io(f,2));function x(v,y,b,E,w,A,T,C,k,F,N){const j=A/k,I=T/F,O=A/2,q=T/2,R=C/2,W=k+1,K=F+1;let G=0,te=0;const Y=new et;for(let J=0;J<K;J++){const U=J*I-q;for(let H=0;H<W;H++){const ee=H*j-O;Y[v]=ee*E,Y[y]=U*w,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[v]=0,Y[y]=0,Y[b]=C>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push(H/k),f.push(1-J/F),G+=1}}for(let J=0;J<F;J++)for(let U=0;U<k;U++){const H=g+U+W*J,ee=g+U+W*(J+1),ie=g+(U+1)+W*(J+1),pe=g+(U+1)+W*J;c.push(H,ee,pe),c.push(ee,ie,pe),te+=6}o.addGroup(p,te,N),p+=te,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Dp(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?(Yt("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 _a(t){const e={};for(let n=0;n<t.length;n++){const r=Dp(t[n]);for(const i in r)e[i]=r[i]}return e}function GNe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function pZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Nn.workingColorSpace}const WNe={clone:Dp,merge:_a};var qNe=`void main() {
  46. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  47. }`,KNe=`void main() {
  48. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  49. }`;let zc=class extends dg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=qNe,this.fragmentShader=KNe,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=Dp(e.uniforms),this.uniformsGroups=GNe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},gZ=class extends ks{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ii,this.projectionMatrix=new ii,this.projectionMatrixInverse=new ii,this.coordinateSystem=ol,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 Mu=new et,uH=new cn,dH=new cn;let Zs=class extends gZ{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=kP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(f1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return kP*2*Math.atan(Math.tan(f1*.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){Mu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Mu.x,Mu.y).multiplyScalar(-e/Mu.z),Mu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Mu.x,Mu.y).multiplyScalar(-e/Mu.z)}getViewSize(e,n){return this.getViewBounds(e,uH,dH),n.subVectors(dH,uH)}setViewOffset(e,n,r,i,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(f1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const mm=-90,pm=1;let XNe=class extends ks{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Zs(mm,pm,e,n);i.layers=this.layers,this.add(i);const a=new Zs(mm,pm,e,n);a.layers=this.layers,this.add(a);const s=new Zs(mm,pm,e,n);s.layers=this.layers,this.add(s);const o=new Zs(mm,pm,e,n);o.layers=this.layers,this.add(o);const c=new Zs(mm,pm,e,n);c.layers=this.layers,this.add(c);const u=new Zs(mm,pm,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,c]=n;for(const u of n)this.remove(u);if(e===ol)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Dw)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},xZ=class extends $o{constructor(e=[],n=Pp,r,i,a,s,o,c,u,d){super(e,n,r,i,a,s,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},YNe=class extends af{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 xZ(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:`
  50. varying vec3 vWorldDirection;
  51. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  52. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  53. }
  54. void main() {
  55. vWorldDirection = transformDirection( position, modelMatrix );
  56. #include <begin_vertex>
  57. #include <project_vertex>
  58. }
  59. `,fragmentShader:`
  60. uniform sampler2D tEquirect;
  61. varying vec3 vWorldDirection;
  62. #include <common>
  63. void main() {
  64. vec3 direction = normalize( vWorldDirection );
  65. vec2 sampleUV = equirectUv( direction );
  66. gl_FragColor = texture2D( tEquirect, sampleUV );
  67. }
  68. `},i=new bO(5,5,5),a=new zc({name:"CubemapFromEquirect",uniforms:Dp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Za,blending:Ec});a.uniforms.tEquirect.value=n;const s=new bl(i,a),o=n.minFilter;return n.minFilter===Sh&&(n.minFilter=io),new XNe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}},zx=class extends ks{constructor(){super(),this.isGroup=!0,this.type="Group"}};const ZNe={type:"move"};let BC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new zx,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 zx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new et,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new et),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new zx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new et,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new et),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(ZNe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new zx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},QNe=class extends ks{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 yd,this.environmentIntensity=1,this.environmentRotation=new yd,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}},JNe=class extends $o{constructor(e=null,n=1,r=1,i,a,s,o,c,u=Es,d=Es,f,g){super(null,s,o,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const HC=new et,eke=new et,tke=new dn;let Lu=class{constructor(e=new et(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=HC.subVectors(r,n).cross(eke.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(HC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||tke.getNormalMatrix(e),i=this.coplanarPoint(HC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Qd=new $M,nke=new cn(.5,.5),e_=new et;let yO=class{constructor(e=new Lu,n=new Lu,r=new Lu,i=new Lu,a=new Lu,s=new Lu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=ol,r=!1){const i=this.planes,a=e.elements,s=a[0],o=a[1],c=a[2],u=a[3],d=a[4],f=a[5],g=a[6],p=a[7],x=a[8],v=a[9],y=a[10],b=a[11],E=a[12],w=a[13],A=a[14],T=a[15];if(i[0].setComponents(u-s,p-d,b-x,T-E).normalize(),i[1].setComponents(u+s,p+d,b+x,T+E).normalize(),i[2].setComponents(u+o,p+f,b+v,T+w).normalize(),i[3].setComponents(u-o,p-f,b-v,T-w).normalize(),r)i[4].setComponents(c,g,y,A).normalize(),i[5].setComponents(u-c,p-g,b-y,T-A).normalize();else if(i[4].setComponents(u-c,p-g,b-y,T-A).normalize(),n===ol)i[5].setComponents(u+c,p+g,b+y,T+A).normalize();else if(n===Dw)i[5].setComponents(c,g,y,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(),Qd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Qd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Qd)}intersectsSprite(e){Qd.center.set(0,0,0);const n=nke.distanceTo(e.center);return Qd.radius=.7071067811865476+n,Qd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Qd)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(e_.x=i.normal.x>0?e.max.x:e.min.x,e_.y=i.normal.y>0?e.max.y:e.min.y,e_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(e_)<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)}},bZ=class extends dg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _n(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 Lw=new et,Iw=new et,hH=new ii,Ex=new gO,t_=new $M,$C=new et,fH=new et;let rke=class extends ks{constructor(e=new Al,n=new bZ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)Lw.fromBufferAttribute(n,i-1),Iw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Lw.distanceTo(Iw);e.setAttribute("lineDistance",new Io(r,1))}else Yt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),t_.copy(r.boundingSphere),t_.applyMatrix4(i),t_.radius+=a,e.ray.intersectsSphere(t_)===!1)return;hH.copy(i).invert(),Ex.copy(e.ray).applyMatrix4(hH);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const p=Math.max(0,s.start),x=Math.min(d.count,s.start+s.count);for(let v=p,y=x-1;v<y;v+=u){const b=d.getX(v),E=d.getX(v+1),w=n_(this,e,Ex,c,b,E,v);w&&n.push(w)}if(this.isLineLoop){const v=d.getX(x-1),y=d.getX(p),b=n_(this,e,Ex,c,v,y,x-1);b&&n.push(b)}}else{const p=Math.max(0,s.start),x=Math.min(g.count,s.start+s.count);for(let v=p,y=x-1;v<y;v+=u){const b=n_(this,e,Ex,c,v,v+1,v);b&&n.push(b)}if(this.isLineLoop){const v=n_(this,e,Ex,c,x-1,p,x-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function n_(t,e,n,r,i,a,s){const o=t.geometry.attributes.position;if(Lw.fromBufferAttribute(o,i),Iw.fromBufferAttribute(o,a),n.distanceSqToSegment(Lw,Iw,$C,fH)>r)return;$C.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo($C);if(!(u<e.near||u>e.far))return{distance:u,point:fH.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const mH=new et,pH=new et;let ike=class extends rke{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)mH.fromBufferAttribute(n,i),pH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+mH.distanceTo(pH);e.setAttribute("lineDistance",new Io(r,1))}else Yt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},yZ=class extends $o{constructor(e,n,r=nf,i,a,s,o=Es,c=Es,u,d=W0,f=1){if(d!==W0&&d!==q0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,a,s,o,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new pO(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 vZ extends $o{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let vO=class _Z extends Al{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,p=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const E=b*g-s;for(let w=0;w<u;w++){const A=w*f-a;x.push(A,-E,0),v.push(0,0,1),y.push(w/o),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<o;E++){const w=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),C=E+1+u*b;p.push(w,A,C),p.push(A,T,C)}this.setIndex(p),this.setAttribute("position",new Io(x,3)),this.setAttribute("normal",new Io(v,3)),this.setAttribute("uv",new Io(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _Z(e.width,e.height,e.widthSegments,e.heightSegments)}};class ake extends dg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _n(16777215),this.specular=new _n(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=eZ,this.normalScale=new cn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new yd,this.combine=oO,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 ske=class extends dg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=mNe,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}},oke=class extends dg{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}},wZ=class extends ks{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new _n(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 VC=new ii,gH=new et,xH=new et;let lke=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new cn(512,512),this.mapType=xl,this.map=null,this.mapPass=null,this.matrix=new ii,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yO,this._frameExtents=new cn(1,1),this._viewportCount=1,this._viewports=[new ei(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;gH.setFromMatrixPosition(e.matrixWorld),n.position.copy(gH),xH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(xH),n.updateMatrixWorld(),VC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(VC,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(VC)}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}},SZ=class extends gZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class cke extends lke{constructor(){super(new SZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class bH extends wZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ks.DEFAULT_UP),this.updateMatrix(),this.target=new ks,this.shadow=new cke}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let uke=class extends wZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},dke=class extends Zs{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},yH=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=gn(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(gn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class hke extends ike{constructor(e=10,n=10,r=4473924,i=8947848){r=new _n(r),i=new _n(i);const a=n/2,s=e/n,o=e/2,c=[],u=[];for(let g=0,p=0,x=-o;g<=n;g++,x+=s){c.push(-o,0,x,o,0,x),c.push(x,0,-o,x,0,o);const v=g===a?r:i;v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3}const d=new Al;d.setAttribute("position",new Io(c,3)),d.setAttribute("color",new Io(u,3));const f=new bZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class fke extends xf{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){Yt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function vH(t,e,n,r){const i=mke(r);switch(n){case ZY:return t*e;case JY:return t*e/i.components*i.byteLength;case dO:return t*e/i.components*i.byteLength;case hO:return t*e*2/i.components*i.byteLength;case fO:return t*e*2/i.components*i.byteLength;case QY:return t*e*3/i.components*i.byteLength;case jo:return t*e*4/i.components*i.byteLength;case mO:return t*e*4/i.components*i.byteLength;case c1:case u1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case d1:case h1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case rP:case aP:return Math.max(t,16)*Math.max(e,8)/4;case nP:case iP:return Math.max(t,8)*Math.max(e,8)/2;case sP:case oP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case lP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case cP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case uP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case dP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case hP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case fP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case mP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case pP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case gP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case xP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case bP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case yP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case vP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case _P:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case wP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case SP:case MP:case EP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case AP:case TP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case CP:case NP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function mke(t){switch(t){case xl:case qY:return{byteLength:1,components:1};case V0:case KY:case ug:return{byteLength:2,components:1};case cO:case uO:return{byteLength:2,components:4};case nf:case lO:case bc:return{byteLength:4,components:1};case XY:case YY:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:sO}}));typeof window<"u"&&(window.__THREE__?Yt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=sO);function MZ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function pke(t){const e=new WeakMap;function n(o,c){const u=o.array,d=o.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(c,g),t.bufferData(c,u,d),o.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)o.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:o.version,size:f}}function r(o,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,o),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,x)=>p.start-x.start);let g=0;for(let p=1;p<f.length;p++){const x=f[g],v=f[p];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++g,f[g]=v)}f.length=g+1;for(let p=0,x=f.length;p<x;p++){const v=f[p];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(t.deleteBuffer(c.buffer),e.delete(o))}function s(o,c){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 u=e.get(o);if(u===void 0)e.set(o,n(o,c));else if(u.version<o.version){if(u.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(u.buffer,o,c),u.version=o.version}}return{get:i,remove:a,update:s}}var gke=`#ifdef USE_ALPHAHASH
  69. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  70. #endif`,xke=`#ifdef USE_ALPHAHASH
  71. const float ALPHA_HASH_SCALE = 0.05;
  72. float hash2D( vec2 value ) {
  73. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  74. }
  75. float hash3D( vec3 value ) {
  76. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  77. }
  78. float getAlphaHashThreshold( vec3 position ) {
  79. float maxDeriv = max(
  80. length( dFdx( position.xyz ) ),
  81. length( dFdy( position.xyz ) )
  82. );
  83. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  84. vec2 pixScales = vec2(
  85. exp2( floor( log2( pixScale ) ) ),
  86. exp2( ceil( log2( pixScale ) ) )
  87. );
  88. vec2 alpha = vec2(
  89. hash3D( floor( pixScales.x * position.xyz ) ),
  90. hash3D( floor( pixScales.y * position.xyz ) )
  91. );
  92. float lerpFactor = fract( log2( pixScale ) );
  93. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  94. float a = min( lerpFactor, 1.0 - lerpFactor );
  95. vec3 cases = vec3(
  96. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  97. ( x - 0.5 * a ) / ( 1.0 - a ),
  98. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  99. );
  100. float threshold = ( x < ( 1.0 - a ) )
  101. ? ( ( x < a ) ? cases.x : cases.y )
  102. : cases.z;
  103. return clamp( threshold , 1.0e-6, 1.0 );
  104. }
  105. #endif`,bke=`#ifdef USE_ALPHAMAP
  106. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  107. #endif`,yke=`#ifdef USE_ALPHAMAP
  108. uniform sampler2D alphaMap;
  109. #endif`,vke=`#ifdef USE_ALPHATEST
  110. #ifdef ALPHA_TO_COVERAGE
  111. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  112. if ( diffuseColor.a == 0.0 ) discard;
  113. #else
  114. if ( diffuseColor.a < alphaTest ) discard;
  115. #endif
  116. #endif`,_ke=`#ifdef USE_ALPHATEST
  117. uniform float alphaTest;
  118. #endif`,wke=`#ifdef USE_AOMAP
  119. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  120. reflectedLight.indirectDiffuse *= ambientOcclusion;
  121. #if defined( USE_CLEARCOAT )
  122. clearcoatSpecularIndirect *= ambientOcclusion;
  123. #endif
  124. #if defined( USE_SHEEN )
  125. sheenSpecularIndirect *= ambientOcclusion;
  126. #endif
  127. #if defined( USE_ENVMAP ) && defined( STANDARD )
  128. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  129. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  130. #endif
  131. #endif`,Ske=`#ifdef USE_AOMAP
  132. uniform sampler2D aoMap;
  133. uniform float aoMapIntensity;
  134. #endif`,Mke=`#ifdef USE_BATCHING
  135. #if ! defined( GL_ANGLE_multi_draw )
  136. #define gl_DrawID _gl_DrawID
  137. uniform int _gl_DrawID;
  138. #endif
  139. uniform highp sampler2D batchingTexture;
  140. uniform highp usampler2D batchingIdTexture;
  141. mat4 getBatchingMatrix( const in float i ) {
  142. int size = textureSize( batchingTexture, 0 ).x;
  143. int j = int( i ) * 4;
  144. int x = j % size;
  145. int y = j / size;
  146. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  147. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  148. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  149. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  150. return mat4( v1, v2, v3, v4 );
  151. }
  152. float getIndirectIndex( const in int i ) {
  153. int size = textureSize( batchingIdTexture, 0 ).x;
  154. int x = i % size;
  155. int y = i / size;
  156. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  157. }
  158. #endif
  159. #ifdef USE_BATCHING_COLOR
  160. uniform sampler2D batchingColorTexture;
  161. vec3 getBatchingColor( const in float i ) {
  162. int size = textureSize( batchingColorTexture, 0 ).x;
  163. int j = int( i );
  164. int x = j % size;
  165. int y = j / size;
  166. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  167. }
  168. #endif`,Eke=`#ifdef USE_BATCHING
  169. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  170. #endif`,Ake=`vec3 transformed = vec3( position );
  171. #ifdef USE_ALPHAHASH
  172. vPosition = vec3( position );
  173. #endif`,Tke=`vec3 objectNormal = vec3( normal );
  174. #ifdef USE_TANGENT
  175. vec3 objectTangent = vec3( tangent.xyz );
  176. #endif`,Cke=`float G_BlinnPhong_Implicit( ) {
  177. return 0.25;
  178. }
  179. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  180. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  181. }
  182. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  183. vec3 halfDir = normalize( lightDir + viewDir );
  184. float dotNH = saturate( dot( normal, halfDir ) );
  185. float dotVH = saturate( dot( viewDir, halfDir ) );
  186. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  187. float G = G_BlinnPhong_Implicit( );
  188. float D = D_BlinnPhong( shininess, dotNH );
  189. return F * ( G * D );
  190. } // validated`,Nke=`#ifdef USE_IRIDESCENCE
  191. const mat3 XYZ_TO_REC709 = mat3(
  192. 3.2404542, -0.9692660, 0.0556434,
  193. -1.5371385, 1.8760108, -0.2040259,
  194. -0.4985314, 0.0415560, 1.0572252
  195. );
  196. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  197. vec3 sqrtF0 = sqrt( fresnel0 );
  198. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  199. }
  200. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  201. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  202. }
  203. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  204. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  205. }
  206. vec3 evalSensitivity( float OPD, vec3 shift ) {
  207. float phase = 2.0 * PI * OPD * 1.0e-9;
  208. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  209. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  210. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  211. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  212. 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 ) );
  213. xyz /= 1.0685e-7;
  214. vec3 rgb = XYZ_TO_REC709 * xyz;
  215. return rgb;
  216. }
  217. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  218. vec3 I;
  219. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  220. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  221. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  222. if ( cosTheta2Sq < 0.0 ) {
  223. return vec3( 1.0 );
  224. }
  225. float cosTheta2 = sqrt( cosTheta2Sq );
  226. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  227. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  228. float T121 = 1.0 - R12;
  229. float phi12 = 0.0;
  230. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  231. float phi21 = PI - phi12;
  232. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  233. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  234. vec3 phi23 = vec3( 0.0 );
  235. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  236. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  237. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  238. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  239. vec3 phi = vec3( phi21 ) + phi23;
  240. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  241. vec3 r123 = sqrt( R123 );
  242. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  243. vec3 C0 = R12 + Rs;
  244. I = C0;
  245. vec3 Cm = Rs - T121;
  246. for ( int m = 1; m <= 2; ++ m ) {
  247. Cm *= r123;
  248. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  249. I += Cm * Sm;
  250. }
  251. return max( I, vec3( 0.0 ) );
  252. }
  253. #endif`,kke=`#ifdef USE_BUMPMAP
  254. uniform sampler2D bumpMap;
  255. uniform float bumpScale;
  256. vec2 dHdxy_fwd() {
  257. vec2 dSTdx = dFdx( vBumpMapUv );
  258. vec2 dSTdy = dFdy( vBumpMapUv );
  259. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  260. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  261. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  262. return vec2( dBx, dBy );
  263. }
  264. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  265. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  266. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  267. vec3 vN = surf_norm;
  268. vec3 R1 = cross( vSigmaY, vN );
  269. vec3 R2 = cross( vN, vSigmaX );
  270. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  271. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  272. return normalize( abs( fDet ) * surf_norm - vGrad );
  273. }
  274. #endif`,Pke=`#if NUM_CLIPPING_PLANES > 0
  275. vec4 plane;
  276. #ifdef ALPHA_TO_COVERAGE
  277. float distanceToPlane, distanceGradient;
  278. float clipOpacity = 1.0;
  279. #pragma unroll_loop_start
  280. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  281. plane = clippingPlanes[ i ];
  282. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  283. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  284. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  285. if ( clipOpacity == 0.0 ) discard;
  286. }
  287. #pragma unroll_loop_end
  288. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  289. float unionClipOpacity = 1.0;
  290. #pragma unroll_loop_start
  291. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  292. plane = clippingPlanes[ i ];
  293. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  294. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  295. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  296. }
  297. #pragma unroll_loop_end
  298. clipOpacity *= 1.0 - unionClipOpacity;
  299. #endif
  300. diffuseColor.a *= clipOpacity;
  301. if ( diffuseColor.a == 0.0 ) discard;
  302. #else
  303. #pragma unroll_loop_start
  304. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  305. plane = clippingPlanes[ i ];
  306. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  307. }
  308. #pragma unroll_loop_end
  309. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  310. bool clipped = true;
  311. #pragma unroll_loop_start
  312. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  313. plane = clippingPlanes[ i ];
  314. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  315. }
  316. #pragma unroll_loop_end
  317. if ( clipped ) discard;
  318. #endif
  319. #endif
  320. #endif`,Rke=`#if NUM_CLIPPING_PLANES > 0
  321. varying vec3 vClipPosition;
  322. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  323. #endif`,jke=`#if NUM_CLIPPING_PLANES > 0
  324. varying vec3 vClipPosition;
  325. #endif`,Dke=`#if NUM_CLIPPING_PLANES > 0
  326. vClipPosition = - mvPosition.xyz;
  327. #endif`,Oke=`#if defined( USE_COLOR_ALPHA )
  328. diffuseColor *= vColor;
  329. #elif defined( USE_COLOR )
  330. diffuseColor.rgb *= vColor;
  331. #endif`,Lke=`#if defined( USE_COLOR_ALPHA )
  332. varying vec4 vColor;
  333. #elif defined( USE_COLOR )
  334. varying vec3 vColor;
  335. #endif`,Ike=`#if defined( USE_COLOR_ALPHA )
  336. varying vec4 vColor;
  337. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  338. varying vec3 vColor;
  339. #endif`,Fke=`#if defined( USE_COLOR_ALPHA )
  340. vColor = vec4( 1.0 );
  341. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  342. vColor = vec3( 1.0 );
  343. #endif
  344. #ifdef USE_COLOR
  345. vColor *= color;
  346. #endif
  347. #ifdef USE_INSTANCING_COLOR
  348. vColor.xyz *= instanceColor.xyz;
  349. #endif
  350. #ifdef USE_BATCHING_COLOR
  351. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  352. vColor.xyz *= batchingColor.xyz;
  353. #endif`,Uke=`#define PI 3.141592653589793
  354. #define PI2 6.283185307179586
  355. #define PI_HALF 1.5707963267948966
  356. #define RECIPROCAL_PI 0.3183098861837907
  357. #define RECIPROCAL_PI2 0.15915494309189535
  358. #define EPSILON 1e-6
  359. #ifndef saturate
  360. #define saturate( a ) clamp( a, 0.0, 1.0 )
  361. #endif
  362. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  363. float pow2( const in float x ) { return x*x; }
  364. vec3 pow2( const in vec3 x ) { return x*x; }
  365. float pow3( const in float x ) { return x*x*x; }
  366. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  367. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  368. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  369. highp float rand( const in vec2 uv ) {
  370. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  371. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  372. return fract( sin( sn ) * c );
  373. }
  374. #ifdef HIGH_PRECISION
  375. float precisionSafeLength( vec3 v ) { return length( v ); }
  376. #else
  377. float precisionSafeLength( vec3 v ) {
  378. float maxComponent = max3( abs( v ) );
  379. return length( v / maxComponent ) * maxComponent;
  380. }
  381. #endif
  382. struct IncidentLight {
  383. vec3 color;
  384. vec3 direction;
  385. bool visible;
  386. };
  387. struct ReflectedLight {
  388. vec3 directDiffuse;
  389. vec3 directSpecular;
  390. vec3 indirectDiffuse;
  391. vec3 indirectSpecular;
  392. };
  393. #ifdef USE_ALPHAHASH
  394. varying vec3 vPosition;
  395. #endif
  396. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  397. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  398. }
  399. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  400. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  401. }
  402. bool isPerspectiveMatrix( mat4 m ) {
  403. return m[ 2 ][ 3 ] == - 1.0;
  404. }
  405. vec2 equirectUv( in vec3 dir ) {
  406. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  407. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  408. return vec2( u, v );
  409. }
  410. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  411. return RECIPROCAL_PI * diffuseColor;
  412. }
  413. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  414. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  415. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  416. }
  417. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  418. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  419. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  420. } // validated`,zke=`#ifdef ENVMAP_TYPE_CUBE_UV
  421. #define cubeUV_minMipLevel 4.0
  422. #define cubeUV_minTileSize 16.0
  423. float getFace( vec3 direction ) {
  424. vec3 absDirection = abs( direction );
  425. float face = - 1.0;
  426. if ( absDirection.x > absDirection.z ) {
  427. if ( absDirection.x > absDirection.y )
  428. face = direction.x > 0.0 ? 0.0 : 3.0;
  429. else
  430. face = direction.y > 0.0 ? 1.0 : 4.0;
  431. } else {
  432. if ( absDirection.z > absDirection.y )
  433. face = direction.z > 0.0 ? 2.0 : 5.0;
  434. else
  435. face = direction.y > 0.0 ? 1.0 : 4.0;
  436. }
  437. return face;
  438. }
  439. vec2 getUV( vec3 direction, float face ) {
  440. vec2 uv;
  441. if ( face == 0.0 ) {
  442. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  443. } else if ( face == 1.0 ) {
  444. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  445. } else if ( face == 2.0 ) {
  446. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  447. } else if ( face == 3.0 ) {
  448. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  449. } else if ( face == 4.0 ) {
  450. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  451. } else {
  452. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  453. }
  454. return 0.5 * ( uv + 1.0 );
  455. }
  456. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  457. float face = getFace( direction );
  458. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  459. mipInt = max( mipInt, cubeUV_minMipLevel );
  460. float faceSize = exp2( mipInt );
  461. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  462. if ( face > 2.0 ) {
  463. uv.y += faceSize;
  464. face -= 3.0;
  465. }
  466. uv.x += face * faceSize;
  467. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  468. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  469. uv.x *= CUBEUV_TEXEL_WIDTH;
  470. uv.y *= CUBEUV_TEXEL_HEIGHT;
  471. #ifdef texture2DGradEXT
  472. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  473. #else
  474. return texture2D( envMap, uv ).rgb;
  475. #endif
  476. }
  477. #define cubeUV_r0 1.0
  478. #define cubeUV_m0 - 2.0
  479. #define cubeUV_r1 0.8
  480. #define cubeUV_m1 - 1.0
  481. #define cubeUV_r4 0.4
  482. #define cubeUV_m4 2.0
  483. #define cubeUV_r5 0.305
  484. #define cubeUV_m5 3.0
  485. #define cubeUV_r6 0.21
  486. #define cubeUV_m6 4.0
  487. float roughnessToMip( float roughness ) {
  488. float mip = 0.0;
  489. if ( roughness >= cubeUV_r1 ) {
  490. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  491. } else if ( roughness >= cubeUV_r4 ) {
  492. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  493. } else if ( roughness >= cubeUV_r5 ) {
  494. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  495. } else if ( roughness >= cubeUV_r6 ) {
  496. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  497. } else {
  498. mip = - 2.0 * log2( 1.16 * roughness ); }
  499. return mip;
  500. }
  501. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  502. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  503. float mipF = fract( mip );
  504. float mipInt = floor( mip );
  505. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  506. if ( mipF == 0.0 ) {
  507. return vec4( color0, 1.0 );
  508. } else {
  509. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  510. return vec4( mix( color0, color1, mipF ), 1.0 );
  511. }
  512. }
  513. #endif`,Bke=`vec3 transformedNormal = objectNormal;
  514. #ifdef USE_TANGENT
  515. vec3 transformedTangent = objectTangent;
  516. #endif
  517. #ifdef USE_BATCHING
  518. mat3 bm = mat3( batchingMatrix );
  519. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  520. transformedNormal = bm * transformedNormal;
  521. #ifdef USE_TANGENT
  522. transformedTangent = bm * transformedTangent;
  523. #endif
  524. #endif
  525. #ifdef USE_INSTANCING
  526. mat3 im = mat3( instanceMatrix );
  527. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  528. transformedNormal = im * transformedNormal;
  529. #ifdef USE_TANGENT
  530. transformedTangent = im * transformedTangent;
  531. #endif
  532. #endif
  533. transformedNormal = normalMatrix * transformedNormal;
  534. #ifdef FLIP_SIDED
  535. transformedNormal = - transformedNormal;
  536. #endif
  537. #ifdef USE_TANGENT
  538. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  539. #ifdef FLIP_SIDED
  540. transformedTangent = - transformedTangent;
  541. #endif
  542. #endif`,Hke=`#ifdef USE_DISPLACEMENTMAP
  543. uniform sampler2D displacementMap;
  544. uniform float displacementScale;
  545. uniform float displacementBias;
  546. #endif`,$ke=`#ifdef USE_DISPLACEMENTMAP
  547. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  548. #endif`,Vke=`#ifdef USE_EMISSIVEMAP
  549. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  550. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  551. emissiveColor = sRGBTransferEOTF( emissiveColor );
  552. #endif
  553. totalEmissiveRadiance *= emissiveColor.rgb;
  554. #endif`,Gke=`#ifdef USE_EMISSIVEMAP
  555. uniform sampler2D emissiveMap;
  556. #endif`,Wke="gl_FragColor = linearToOutputTexel( gl_FragColor );",qke=`vec4 LinearTransferOETF( in vec4 value ) {
  557. return value;
  558. }
  559. vec4 sRGBTransferEOTF( in vec4 value ) {
  560. 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 );
  561. }
  562. vec4 sRGBTransferOETF( in vec4 value ) {
  563. 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 );
  564. }`,Kke=`#ifdef USE_ENVMAP
  565. #ifdef ENV_WORLDPOS
  566. vec3 cameraToFrag;
  567. if ( isOrthographic ) {
  568. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  569. } else {
  570. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  571. }
  572. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  573. #ifdef ENVMAP_MODE_REFLECTION
  574. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  575. #else
  576. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  577. #endif
  578. #else
  579. vec3 reflectVec = vReflect;
  580. #endif
  581. #ifdef ENVMAP_TYPE_CUBE
  582. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  583. #else
  584. vec4 envColor = vec4( 0.0 );
  585. #endif
  586. #ifdef ENVMAP_BLENDING_MULTIPLY
  587. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  588. #elif defined( ENVMAP_BLENDING_MIX )
  589. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  590. #elif defined( ENVMAP_BLENDING_ADD )
  591. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  592. #endif
  593. #endif`,Xke=`#ifdef USE_ENVMAP
  594. uniform float envMapIntensity;
  595. uniform float flipEnvMap;
  596. uniform mat3 envMapRotation;
  597. #ifdef ENVMAP_TYPE_CUBE
  598. uniform samplerCube envMap;
  599. #else
  600. uniform sampler2D envMap;
  601. #endif
  602. #endif`,Yke=`#ifdef USE_ENVMAP
  603. uniform float reflectivity;
  604. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  605. #define ENV_WORLDPOS
  606. #endif
  607. #ifdef ENV_WORLDPOS
  608. varying vec3 vWorldPosition;
  609. uniform float refractionRatio;
  610. #else
  611. varying vec3 vReflect;
  612. #endif
  613. #endif`,Zke=`#ifdef USE_ENVMAP
  614. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  615. #define ENV_WORLDPOS
  616. #endif
  617. #ifdef ENV_WORLDPOS
  618. varying vec3 vWorldPosition;
  619. #else
  620. varying vec3 vReflect;
  621. uniform float refractionRatio;
  622. #endif
  623. #endif`,Qke=`#ifdef USE_ENVMAP
  624. #ifdef ENV_WORLDPOS
  625. vWorldPosition = worldPosition.xyz;
  626. #else
  627. vec3 cameraToVertex;
  628. if ( isOrthographic ) {
  629. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  630. } else {
  631. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  632. }
  633. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  634. #ifdef ENVMAP_MODE_REFLECTION
  635. vReflect = reflect( cameraToVertex, worldNormal );
  636. #else
  637. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  638. #endif
  639. #endif
  640. #endif`,Jke=`#ifdef USE_FOG
  641. vFogDepth = - mvPosition.z;
  642. #endif`,e3e=`#ifdef USE_FOG
  643. varying float vFogDepth;
  644. #endif`,t3e=`#ifdef USE_FOG
  645. #ifdef FOG_EXP2
  646. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  647. #else
  648. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  649. #endif
  650. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  651. #endif`,n3e=`#ifdef USE_FOG
  652. uniform vec3 fogColor;
  653. varying float vFogDepth;
  654. #ifdef FOG_EXP2
  655. uniform float fogDensity;
  656. #else
  657. uniform float fogNear;
  658. uniform float fogFar;
  659. #endif
  660. #endif`,r3e=`#ifdef USE_GRADIENTMAP
  661. uniform sampler2D gradientMap;
  662. #endif
  663. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  664. float dotNL = dot( normal, lightDirection );
  665. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  666. #ifdef USE_GRADIENTMAP
  667. return vec3( texture2D( gradientMap, coord ).r );
  668. #else
  669. vec2 fw = fwidth( coord ) * 0.5;
  670. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  671. #endif
  672. }`,i3e=`#ifdef USE_LIGHTMAP
  673. uniform sampler2D lightMap;
  674. uniform float lightMapIntensity;
  675. #endif`,a3e=`LambertMaterial material;
  676. material.diffuseColor = diffuseColor.rgb;
  677. material.specularStrength = specularStrength;`,s3e=`varying vec3 vViewPosition;
  678. struct LambertMaterial {
  679. vec3 diffuseColor;
  680. float specularStrength;
  681. };
  682. 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 ) {
  683. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  684. vec3 irradiance = dotNL * directLight.color;
  685. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  686. }
  687. 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 ) {
  688. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  689. }
  690. #define RE_Direct RE_Direct_Lambert
  691. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,o3e=`uniform bool receiveShadow;
  692. uniform vec3 ambientLightColor;
  693. #if defined( USE_LIGHT_PROBES )
  694. uniform vec3 lightProbe[ 9 ];
  695. #endif
  696. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  697. float x = normal.x, y = normal.y, z = normal.z;
  698. vec3 result = shCoefficients[ 0 ] * 0.886227;
  699. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  700. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  701. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  702. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  703. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  704. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  705. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  706. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  707. return result;
  708. }
  709. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  710. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  711. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  712. return irradiance;
  713. }
  714. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  715. vec3 irradiance = ambientLightColor;
  716. return irradiance;
  717. }
  718. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  719. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  720. if ( cutoffDistance > 0.0 ) {
  721. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  722. }
  723. return distanceFalloff;
  724. }
  725. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  726. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  727. }
  728. #if NUM_DIR_LIGHTS > 0
  729. struct DirectionalLight {
  730. vec3 direction;
  731. vec3 color;
  732. };
  733. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  734. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  735. light.color = directionalLight.color;
  736. light.direction = directionalLight.direction;
  737. light.visible = true;
  738. }
  739. #endif
  740. #if NUM_POINT_LIGHTS > 0
  741. struct PointLight {
  742. vec3 position;
  743. vec3 color;
  744. float distance;
  745. float decay;
  746. };
  747. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  748. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  749. vec3 lVector = pointLight.position - geometryPosition;
  750. light.direction = normalize( lVector );
  751. float lightDistance = length( lVector );
  752. light.color = pointLight.color;
  753. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  754. light.visible = ( light.color != vec3( 0.0 ) );
  755. }
  756. #endif
  757. #if NUM_SPOT_LIGHTS > 0
  758. struct SpotLight {
  759. vec3 position;
  760. vec3 direction;
  761. vec3 color;
  762. float distance;
  763. float decay;
  764. float coneCos;
  765. float penumbraCos;
  766. };
  767. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  768. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  769. vec3 lVector = spotLight.position - geometryPosition;
  770. light.direction = normalize( lVector );
  771. float angleCos = dot( light.direction, spotLight.direction );
  772. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  773. if ( spotAttenuation > 0.0 ) {
  774. float lightDistance = length( lVector );
  775. light.color = spotLight.color * spotAttenuation;
  776. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  777. light.visible = ( light.color != vec3( 0.0 ) );
  778. } else {
  779. light.color = vec3( 0.0 );
  780. light.visible = false;
  781. }
  782. }
  783. #endif
  784. #if NUM_RECT_AREA_LIGHTS > 0
  785. struct RectAreaLight {
  786. vec3 color;
  787. vec3 position;
  788. vec3 halfWidth;
  789. vec3 halfHeight;
  790. };
  791. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  792. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  793. #endif
  794. #if NUM_HEMI_LIGHTS > 0
  795. struct HemisphereLight {
  796. vec3 direction;
  797. vec3 skyColor;
  798. vec3 groundColor;
  799. };
  800. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  801. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  802. float dotNL = dot( normal, hemiLight.direction );
  803. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  804. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  805. return irradiance;
  806. }
  807. #endif`,l3e=`#ifdef USE_ENVMAP
  808. vec3 getIBLIrradiance( const in vec3 normal ) {
  809. #ifdef ENVMAP_TYPE_CUBE_UV
  810. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  811. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  812. return PI * envMapColor.rgb * envMapIntensity;
  813. #else
  814. return vec3( 0.0 );
  815. #endif
  816. }
  817. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  818. #ifdef ENVMAP_TYPE_CUBE_UV
  819. vec3 reflectVec = reflect( - viewDir, normal );
  820. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  821. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  822. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  823. return envMapColor.rgb * envMapIntensity;
  824. #else
  825. return vec3( 0.0 );
  826. #endif
  827. }
  828. #ifdef USE_ANISOTROPY
  829. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  830. #ifdef ENVMAP_TYPE_CUBE_UV
  831. vec3 bentNormal = cross( bitangent, viewDir );
  832. bentNormal = normalize( cross( bentNormal, bitangent ) );
  833. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  834. return getIBLRadiance( viewDir, bentNormal, roughness );
  835. #else
  836. return vec3( 0.0 );
  837. #endif
  838. }
  839. #endif
  840. #endif`,c3e=`ToonMaterial material;
  841. material.diffuseColor = diffuseColor.rgb;`,u3e=`varying vec3 vViewPosition;
  842. struct ToonMaterial {
  843. vec3 diffuseColor;
  844. };
  845. 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 ) {
  846. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  847. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  848. }
  849. 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 ) {
  850. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  851. }
  852. #define RE_Direct RE_Direct_Toon
  853. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,d3e=`BlinnPhongMaterial material;
  854. material.diffuseColor = diffuseColor.rgb;
  855. material.specularColor = specular;
  856. material.specularShininess = shininess;
  857. material.specularStrength = specularStrength;`,h3e=`varying vec3 vViewPosition;
  858. struct BlinnPhongMaterial {
  859. vec3 diffuseColor;
  860. vec3 specularColor;
  861. float specularShininess;
  862. float specularStrength;
  863. };
  864. 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 ) {
  865. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  866. vec3 irradiance = dotNL * directLight.color;
  867. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  868. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  869. }
  870. 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 ) {
  871. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  872. }
  873. #define RE_Direct RE_Direct_BlinnPhong
  874. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,f3e=`PhysicalMaterial material;
  875. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  876. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  877. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  878. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  879. material.roughness = min( material.roughness, 1.0 );
  880. #ifdef IOR
  881. material.ior = ior;
  882. #ifdef USE_SPECULAR
  883. float specularIntensityFactor = specularIntensity;
  884. vec3 specularColorFactor = specularColor;
  885. #ifdef USE_SPECULAR_COLORMAP
  886. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  887. #endif
  888. #ifdef USE_SPECULAR_INTENSITYMAP
  889. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  890. #endif
  891. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  892. #else
  893. float specularIntensityFactor = 1.0;
  894. vec3 specularColorFactor = vec3( 1.0 );
  895. material.specularF90 = 1.0;
  896. #endif
  897. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  898. #else
  899. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  900. material.specularF90 = 1.0;
  901. #endif
  902. #ifdef USE_CLEARCOAT
  903. material.clearcoat = clearcoat;
  904. material.clearcoatRoughness = clearcoatRoughness;
  905. material.clearcoatF0 = vec3( 0.04 );
  906. material.clearcoatF90 = 1.0;
  907. #ifdef USE_CLEARCOATMAP
  908. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  909. #endif
  910. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  911. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  912. #endif
  913. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  914. material.clearcoatRoughness += geometryRoughness;
  915. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  916. #endif
  917. #ifdef USE_DISPERSION
  918. material.dispersion = dispersion;
  919. #endif
  920. #ifdef USE_IRIDESCENCE
  921. material.iridescence = iridescence;
  922. material.iridescenceIOR = iridescenceIOR;
  923. #ifdef USE_IRIDESCENCEMAP
  924. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  925. #endif
  926. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  927. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  928. #else
  929. material.iridescenceThickness = iridescenceThicknessMaximum;
  930. #endif
  931. #endif
  932. #ifdef USE_SHEEN
  933. material.sheenColor = sheenColor;
  934. #ifdef USE_SHEEN_COLORMAP
  935. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  936. #endif
  937. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  938. #ifdef USE_SHEEN_ROUGHNESSMAP
  939. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  940. #endif
  941. #endif
  942. #ifdef USE_ANISOTROPY
  943. #ifdef USE_ANISOTROPYMAP
  944. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  945. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  946. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  947. #else
  948. vec2 anisotropyV = anisotropyVector;
  949. #endif
  950. material.anisotropy = length( anisotropyV );
  951. if( material.anisotropy == 0.0 ) {
  952. anisotropyV = vec2( 1.0, 0.0 );
  953. } else {
  954. anisotropyV /= material.anisotropy;
  955. material.anisotropy = saturate( material.anisotropy );
  956. }
  957. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  958. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  959. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  960. #endif`,m3e=`uniform sampler2D dfgLUT;
  961. struct PhysicalMaterial {
  962. vec3 diffuseColor;
  963. float roughness;
  964. vec3 specularColor;
  965. float specularF90;
  966. float dispersion;
  967. #ifdef USE_CLEARCOAT
  968. float clearcoat;
  969. float clearcoatRoughness;
  970. vec3 clearcoatF0;
  971. float clearcoatF90;
  972. #endif
  973. #ifdef USE_IRIDESCENCE
  974. float iridescence;
  975. float iridescenceIOR;
  976. float iridescenceThickness;
  977. vec3 iridescenceFresnel;
  978. vec3 iridescenceF0;
  979. #endif
  980. #ifdef USE_SHEEN
  981. vec3 sheenColor;
  982. float sheenRoughness;
  983. #endif
  984. #ifdef IOR
  985. float ior;
  986. #endif
  987. #ifdef USE_TRANSMISSION
  988. float transmission;
  989. float transmissionAlpha;
  990. float thickness;
  991. float attenuationDistance;
  992. vec3 attenuationColor;
  993. #endif
  994. #ifdef USE_ANISOTROPY
  995. float anisotropy;
  996. float alphaT;
  997. vec3 anisotropyT;
  998. vec3 anisotropyB;
  999. #endif
  1000. };
  1001. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1002. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1003. vec3 sheenSpecularDirect = vec3( 0.0 );
  1004. vec3 sheenSpecularIndirect = vec3(0.0 );
  1005. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1006. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1007. float x2 = x * x;
  1008. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1009. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1010. }
  1011. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1012. float a2 = pow2( alpha );
  1013. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1014. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1015. return 0.5 / max( gv + gl, EPSILON );
  1016. }
  1017. float D_GGX( const in float alpha, const in float dotNH ) {
  1018. float a2 = pow2( alpha );
  1019. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1020. return RECIPROCAL_PI * a2 / pow2( denom );
  1021. }
  1022. #ifdef USE_ANISOTROPY
  1023. 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 ) {
  1024. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1025. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1026. float v = 0.5 / ( gv + gl );
  1027. return saturate(v);
  1028. }
  1029. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1030. float a2 = alphaT * alphaB;
  1031. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1032. highp float v2 = dot( v, v );
  1033. float w2 = a2 / v2;
  1034. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1035. }
  1036. #endif
  1037. #ifdef USE_CLEARCOAT
  1038. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1039. vec3 f0 = material.clearcoatF0;
  1040. float f90 = material.clearcoatF90;
  1041. float roughness = material.clearcoatRoughness;
  1042. float alpha = pow2( roughness );
  1043. vec3 halfDir = normalize( lightDir + viewDir );
  1044. float dotNL = saturate( dot( normal, lightDir ) );
  1045. float dotNV = saturate( dot( normal, viewDir ) );
  1046. float dotNH = saturate( dot( normal, halfDir ) );
  1047. float dotVH = saturate( dot( viewDir, halfDir ) );
  1048. vec3 F = F_Schlick( f0, f90, dotVH );
  1049. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1050. float D = D_GGX( alpha, dotNH );
  1051. return F * ( V * D );
  1052. }
  1053. #endif
  1054. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1055. vec3 f0 = material.specularColor;
  1056. float f90 = material.specularF90;
  1057. float roughness = material.roughness;
  1058. float alpha = pow2( roughness );
  1059. vec3 halfDir = normalize( lightDir + viewDir );
  1060. float dotNL = saturate( dot( normal, lightDir ) );
  1061. float dotNV = saturate( dot( normal, viewDir ) );
  1062. float dotNH = saturate( dot( normal, halfDir ) );
  1063. float dotVH = saturate( dot( viewDir, halfDir ) );
  1064. vec3 F = F_Schlick( f0, f90, dotVH );
  1065. #ifdef USE_IRIDESCENCE
  1066. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1067. #endif
  1068. #ifdef USE_ANISOTROPY
  1069. float dotTL = dot( material.anisotropyT, lightDir );
  1070. float dotTV = dot( material.anisotropyT, viewDir );
  1071. float dotTH = dot( material.anisotropyT, halfDir );
  1072. float dotBL = dot( material.anisotropyB, lightDir );
  1073. float dotBV = dot( material.anisotropyB, viewDir );
  1074. float dotBH = dot( material.anisotropyB, halfDir );
  1075. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1076. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1077. #else
  1078. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1079. float D = D_GGX( alpha, dotNH );
  1080. #endif
  1081. return F * ( V * D );
  1082. }
  1083. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1084. const float LUT_SIZE = 64.0;
  1085. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1086. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1087. float dotNV = saturate( dot( N, V ) );
  1088. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1089. uv = uv * LUT_SCALE + LUT_BIAS;
  1090. return uv;
  1091. }
  1092. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1093. float l = length( f );
  1094. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1095. }
  1096. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1097. float x = dot( v1, v2 );
  1098. float y = abs( x );
  1099. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1100. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1101. float v = a / b;
  1102. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1103. return cross( v1, v2 ) * theta_sintheta;
  1104. }
  1105. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1106. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1107. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1108. vec3 lightNormal = cross( v1, v2 );
  1109. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1110. vec3 T1, T2;
  1111. T1 = normalize( V - N * dot( V, N ) );
  1112. T2 = - cross( N, T1 );
  1113. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1114. vec3 coords[ 4 ];
  1115. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1116. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1117. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1118. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1119. coords[ 0 ] = normalize( coords[ 0 ] );
  1120. coords[ 1 ] = normalize( coords[ 1 ] );
  1121. coords[ 2 ] = normalize( coords[ 2 ] );
  1122. coords[ 3 ] = normalize( coords[ 3 ] );
  1123. vec3 vectorFormFactor = vec3( 0.0 );
  1124. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1125. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1126. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1127. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1128. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1129. return vec3( result );
  1130. }
  1131. #if defined( USE_SHEEN )
  1132. float D_Charlie( float roughness, float dotNH ) {
  1133. float alpha = pow2( roughness );
  1134. float invAlpha = 1.0 / alpha;
  1135. float cos2h = dotNH * dotNH;
  1136. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1137. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1138. }
  1139. float V_Neubelt( float dotNV, float dotNL ) {
  1140. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1141. }
  1142. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1143. vec3 halfDir = normalize( lightDir + viewDir );
  1144. float dotNL = saturate( dot( normal, lightDir ) );
  1145. float dotNV = saturate( dot( normal, viewDir ) );
  1146. float dotNH = saturate( dot( normal, halfDir ) );
  1147. float D = D_Charlie( sheenRoughness, dotNH );
  1148. float V = V_Neubelt( dotNV, dotNL );
  1149. return sheenColor * ( D * V );
  1150. }
  1151. #endif
  1152. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1153. float dotNV = saturate( dot( normal, viewDir ) );
  1154. float r2 = roughness * roughness;
  1155. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1156. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1157. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1158. return saturate( DG * RECIPROCAL_PI );
  1159. }
  1160. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1161. float dotNV = saturate( dot( normal, viewDir ) );
  1162. vec2 uv = vec2( roughness, dotNV );
  1163. return texture2D( dfgLUT, uv ).rg;
  1164. }
  1165. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1166. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1167. return specularColor * fab.x + specularF90 * fab.y;
  1168. }
  1169. #ifdef USE_IRIDESCENCE
  1170. 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 ) {
  1171. #else
  1172. 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 ) {
  1173. #endif
  1174. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1175. #ifdef USE_IRIDESCENCE
  1176. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1177. #else
  1178. vec3 Fr = specularColor;
  1179. #endif
  1180. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1181. float Ess = fab.x + fab.y;
  1182. float Ems = 1.0 - Ess;
  1183. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1184. singleScatter += FssEss;
  1185. multiScatter += Fms * Ems;
  1186. }
  1187. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1188. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1189. float dotNL = saturate( dot( normal, lightDir ) );
  1190. float dotNV = saturate( dot( normal, viewDir ) );
  1191. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1192. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1193. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1194. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1195. float Ess_V = dfgV.x + dfgV.y;
  1196. float Ess_L = dfgL.x + dfgL.y;
  1197. float Ems_V = 1.0 - Ess_V;
  1198. float Ems_L = 1.0 - Ess_L;
  1199. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1200. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1201. float compensationFactor = Ems_V * Ems_L;
  1202. vec3 multiScatter = Fms * compensationFactor;
  1203. return singleScatter + multiScatter;
  1204. }
  1205. #if NUM_RECT_AREA_LIGHTS > 0
  1206. 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 ) {
  1207. vec3 normal = geometryNormal;
  1208. vec3 viewDir = geometryViewDir;
  1209. vec3 position = geometryPosition;
  1210. vec3 lightPos = rectAreaLight.position;
  1211. vec3 halfWidth = rectAreaLight.halfWidth;
  1212. vec3 halfHeight = rectAreaLight.halfHeight;
  1213. vec3 lightColor = rectAreaLight.color;
  1214. float roughness = material.roughness;
  1215. vec3 rectCoords[ 4 ];
  1216. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1217. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1218. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1219. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1220. vec4 t1 = texture2D( ltc_1, uv );
  1221. vec4 t2 = texture2D( ltc_2, uv );
  1222. mat3 mInv = mat3(
  1223. vec3( t1.x, 0, t1.y ),
  1224. vec3( 0, 1, 0 ),
  1225. vec3( t1.z, 0, t1.w )
  1226. );
  1227. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1228. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1229. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1230. }
  1231. #endif
  1232. 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 ) {
  1233. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1234. vec3 irradiance = dotNL * directLight.color;
  1235. #ifdef USE_CLEARCOAT
  1236. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1237. vec3 ccIrradiance = dotNLcc * directLight.color;
  1238. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1239. #endif
  1240. #ifdef USE_SHEEN
  1241. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1242. #endif
  1243. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1244. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1245. }
  1246. 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 ) {
  1247. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1248. }
  1249. 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) {
  1250. #ifdef USE_CLEARCOAT
  1251. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1252. #endif
  1253. #ifdef USE_SHEEN
  1254. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1255. #endif
  1256. vec3 singleScattering = vec3( 0.0 );
  1257. vec3 multiScattering = vec3( 0.0 );
  1258. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1259. #ifdef USE_IRIDESCENCE
  1260. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1261. #else
  1262. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1263. #endif
  1264. vec3 totalScattering = singleScattering + multiScattering;
  1265. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1266. reflectedLight.indirectSpecular += radiance * singleScattering;
  1267. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1268. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1269. }
  1270. #define RE_Direct RE_Direct_Physical
  1271. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1272. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1273. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1274. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1275. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1276. }`,p3e=`
  1277. vec3 geometryPosition = - vViewPosition;
  1278. vec3 geometryNormal = normal;
  1279. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1280. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1281. #ifdef USE_CLEARCOAT
  1282. geometryClearcoatNormal = clearcoatNormal;
  1283. #endif
  1284. #ifdef USE_IRIDESCENCE
  1285. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1286. if ( material.iridescenceThickness == 0.0 ) {
  1287. material.iridescence = 0.0;
  1288. } else {
  1289. material.iridescence = saturate( material.iridescence );
  1290. }
  1291. if ( material.iridescence > 0.0 ) {
  1292. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1293. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1294. }
  1295. #endif
  1296. IncidentLight directLight;
  1297. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1298. PointLight pointLight;
  1299. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1300. PointLightShadow pointLightShadow;
  1301. #endif
  1302. #pragma unroll_loop_start
  1303. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1304. pointLight = pointLights[ i ];
  1305. getPointLightInfo( pointLight, geometryPosition, directLight );
  1306. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1307. pointLightShadow = pointLightShadows[ i ];
  1308. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1309. #endif
  1310. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1311. }
  1312. #pragma unroll_loop_end
  1313. #endif
  1314. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1315. SpotLight spotLight;
  1316. vec4 spotColor;
  1317. vec3 spotLightCoord;
  1318. bool inSpotLightMap;
  1319. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1320. SpotLightShadow spotLightShadow;
  1321. #endif
  1322. #pragma unroll_loop_start
  1323. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1324. spotLight = spotLights[ i ];
  1325. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1326. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1327. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1328. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1329. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1330. #else
  1331. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1332. #endif
  1333. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1334. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1335. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1336. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1337. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1338. #endif
  1339. #undef SPOT_LIGHT_MAP_INDEX
  1340. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1341. spotLightShadow = spotLightShadows[ i ];
  1342. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1343. #endif
  1344. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1345. }
  1346. #pragma unroll_loop_end
  1347. #endif
  1348. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1349. DirectionalLight directionalLight;
  1350. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1351. DirectionalLightShadow directionalLightShadow;
  1352. #endif
  1353. #pragma unroll_loop_start
  1354. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1355. directionalLight = directionalLights[ i ];
  1356. getDirectionalLightInfo( directionalLight, directLight );
  1357. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1358. directionalLightShadow = directionalLightShadows[ i ];
  1359. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1360. #endif
  1361. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1362. }
  1363. #pragma unroll_loop_end
  1364. #endif
  1365. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1366. RectAreaLight rectAreaLight;
  1367. #pragma unroll_loop_start
  1368. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1369. rectAreaLight = rectAreaLights[ i ];
  1370. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1371. }
  1372. #pragma unroll_loop_end
  1373. #endif
  1374. #if defined( RE_IndirectDiffuse )
  1375. vec3 iblIrradiance = vec3( 0.0 );
  1376. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1377. #if defined( USE_LIGHT_PROBES )
  1378. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1379. #endif
  1380. #if ( NUM_HEMI_LIGHTS > 0 )
  1381. #pragma unroll_loop_start
  1382. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1383. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1384. }
  1385. #pragma unroll_loop_end
  1386. #endif
  1387. #endif
  1388. #if defined( RE_IndirectSpecular )
  1389. vec3 radiance = vec3( 0.0 );
  1390. vec3 clearcoatRadiance = vec3( 0.0 );
  1391. #endif`,g3e=`#if defined( RE_IndirectDiffuse )
  1392. #ifdef USE_LIGHTMAP
  1393. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1394. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1395. irradiance += lightMapIrradiance;
  1396. #endif
  1397. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1398. iblIrradiance += getIBLIrradiance( geometryNormal );
  1399. #endif
  1400. #endif
  1401. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1402. #ifdef USE_ANISOTROPY
  1403. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1404. #else
  1405. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1406. #endif
  1407. #ifdef USE_CLEARCOAT
  1408. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1409. #endif
  1410. #endif`,x3e=`#if defined( RE_IndirectDiffuse )
  1411. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1412. #endif
  1413. #if defined( RE_IndirectSpecular )
  1414. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1415. #endif`,b3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1416. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1417. #endif`,y3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1418. uniform float logDepthBufFC;
  1419. varying float vFragDepth;
  1420. varying float vIsPerspective;
  1421. #endif`,v3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1422. varying float vFragDepth;
  1423. varying float vIsPerspective;
  1424. #endif`,_3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1425. vFragDepth = 1.0 + gl_Position.w;
  1426. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1427. #endif`,w3e=`#ifdef USE_MAP
  1428. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1429. #ifdef DECODE_VIDEO_TEXTURE
  1430. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1431. #endif
  1432. diffuseColor *= sampledDiffuseColor;
  1433. #endif`,S3e=`#ifdef USE_MAP
  1434. uniform sampler2D map;
  1435. #endif`,M3e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1436. #if defined( USE_POINTS_UV )
  1437. vec2 uv = vUv;
  1438. #else
  1439. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1440. #endif
  1441. #endif
  1442. #ifdef USE_MAP
  1443. diffuseColor *= texture2D( map, uv );
  1444. #endif
  1445. #ifdef USE_ALPHAMAP
  1446. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1447. #endif`,E3e=`#if defined( USE_POINTS_UV )
  1448. varying vec2 vUv;
  1449. #else
  1450. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1451. uniform mat3 uvTransform;
  1452. #endif
  1453. #endif
  1454. #ifdef USE_MAP
  1455. uniform sampler2D map;
  1456. #endif
  1457. #ifdef USE_ALPHAMAP
  1458. uniform sampler2D alphaMap;
  1459. #endif`,A3e=`float metalnessFactor = metalness;
  1460. #ifdef USE_METALNESSMAP
  1461. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1462. metalnessFactor *= texelMetalness.b;
  1463. #endif`,T3e=`#ifdef USE_METALNESSMAP
  1464. uniform sampler2D metalnessMap;
  1465. #endif`,C3e=`#ifdef USE_INSTANCING_MORPH
  1466. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1467. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1468. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1469. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1470. }
  1471. #endif`,N3e=`#if defined( USE_MORPHCOLORS )
  1472. vColor *= morphTargetBaseInfluence;
  1473. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1474. #if defined( USE_COLOR_ALPHA )
  1475. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1476. #elif defined( USE_COLOR )
  1477. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1478. #endif
  1479. }
  1480. #endif`,k3e=`#ifdef USE_MORPHNORMALS
  1481. objectNormal *= morphTargetBaseInfluence;
  1482. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1483. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1484. }
  1485. #endif`,P3e=`#ifdef USE_MORPHTARGETS
  1486. #ifndef USE_INSTANCING_MORPH
  1487. uniform float morphTargetBaseInfluence;
  1488. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1489. #endif
  1490. uniform sampler2DArray morphTargetsTexture;
  1491. uniform ivec2 morphTargetsTextureSize;
  1492. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1493. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1494. int y = texelIndex / morphTargetsTextureSize.x;
  1495. int x = texelIndex - y * morphTargetsTextureSize.x;
  1496. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1497. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1498. }
  1499. #endif`,R3e=`#ifdef USE_MORPHTARGETS
  1500. transformed *= morphTargetBaseInfluence;
  1501. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1502. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1503. }
  1504. #endif`,j3e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1505. #ifdef FLAT_SHADED
  1506. vec3 fdx = dFdx( vViewPosition );
  1507. vec3 fdy = dFdy( vViewPosition );
  1508. vec3 normal = normalize( cross( fdx, fdy ) );
  1509. #else
  1510. vec3 normal = normalize( vNormal );
  1511. #ifdef DOUBLE_SIDED
  1512. normal *= faceDirection;
  1513. #endif
  1514. #endif
  1515. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1516. #ifdef USE_TANGENT
  1517. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1518. #else
  1519. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1520. #if defined( USE_NORMALMAP )
  1521. vNormalMapUv
  1522. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1523. vClearcoatNormalMapUv
  1524. #else
  1525. vUv
  1526. #endif
  1527. );
  1528. #endif
  1529. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1530. tbn[0] *= faceDirection;
  1531. tbn[1] *= faceDirection;
  1532. #endif
  1533. #endif
  1534. #ifdef USE_CLEARCOAT_NORMALMAP
  1535. #ifdef USE_TANGENT
  1536. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1537. #else
  1538. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1539. #endif
  1540. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1541. tbn2[0] *= faceDirection;
  1542. tbn2[1] *= faceDirection;
  1543. #endif
  1544. #endif
  1545. vec3 nonPerturbedNormal = normal;`,D3e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1546. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1547. #ifdef FLIP_SIDED
  1548. normal = - normal;
  1549. #endif
  1550. #ifdef DOUBLE_SIDED
  1551. normal = normal * faceDirection;
  1552. #endif
  1553. normal = normalize( normalMatrix * normal );
  1554. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1555. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1556. mapN.xy *= normalScale;
  1557. normal = normalize( tbn * mapN );
  1558. #elif defined( USE_BUMPMAP )
  1559. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1560. #endif`,O3e=`#ifndef FLAT_SHADED
  1561. varying vec3 vNormal;
  1562. #ifdef USE_TANGENT
  1563. varying vec3 vTangent;
  1564. varying vec3 vBitangent;
  1565. #endif
  1566. #endif`,L3e=`#ifndef FLAT_SHADED
  1567. varying vec3 vNormal;
  1568. #ifdef USE_TANGENT
  1569. varying vec3 vTangent;
  1570. varying vec3 vBitangent;
  1571. #endif
  1572. #endif`,I3e=`#ifndef FLAT_SHADED
  1573. vNormal = normalize( transformedNormal );
  1574. #ifdef USE_TANGENT
  1575. vTangent = normalize( transformedTangent );
  1576. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1577. #endif
  1578. #endif`,F3e=`#ifdef USE_NORMALMAP
  1579. uniform sampler2D normalMap;
  1580. uniform vec2 normalScale;
  1581. #endif
  1582. #ifdef USE_NORMALMAP_OBJECTSPACE
  1583. uniform mat3 normalMatrix;
  1584. #endif
  1585. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1586. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1587. vec3 q0 = dFdx( eye_pos.xyz );
  1588. vec3 q1 = dFdy( eye_pos.xyz );
  1589. vec2 st0 = dFdx( uv.st );
  1590. vec2 st1 = dFdy( uv.st );
  1591. vec3 N = surf_norm;
  1592. vec3 q1perp = cross( q1, N );
  1593. vec3 q0perp = cross( N, q0 );
  1594. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1595. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1596. float det = max( dot( T, T ), dot( B, B ) );
  1597. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1598. return mat3( T * scale, B * scale, N );
  1599. }
  1600. #endif`,U3e=`#ifdef USE_CLEARCOAT
  1601. vec3 clearcoatNormal = nonPerturbedNormal;
  1602. #endif`,z3e=`#ifdef USE_CLEARCOAT_NORMALMAP
  1603. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1604. clearcoatMapN.xy *= clearcoatNormalScale;
  1605. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1606. #endif`,B3e=`#ifdef USE_CLEARCOATMAP
  1607. uniform sampler2D clearcoatMap;
  1608. #endif
  1609. #ifdef USE_CLEARCOAT_NORMALMAP
  1610. uniform sampler2D clearcoatNormalMap;
  1611. uniform vec2 clearcoatNormalScale;
  1612. #endif
  1613. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1614. uniform sampler2D clearcoatRoughnessMap;
  1615. #endif`,H3e=`#ifdef USE_IRIDESCENCEMAP
  1616. uniform sampler2D iridescenceMap;
  1617. #endif
  1618. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1619. uniform sampler2D iridescenceThicknessMap;
  1620. #endif`,$3e=`#ifdef OPAQUE
  1621. diffuseColor.a = 1.0;
  1622. #endif
  1623. #ifdef USE_TRANSMISSION
  1624. diffuseColor.a *= material.transmissionAlpha;
  1625. #endif
  1626. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,V3e=`vec3 packNormalToRGB( const in vec3 normal ) {
  1627. return normalize( normal ) * 0.5 + 0.5;
  1628. }
  1629. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1630. return 2.0 * rgb.xyz - 1.0;
  1631. }
  1632. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1633. const float Inv255 = 1. / 255.;
  1634. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1635. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1636. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1637. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1638. vec4 packDepthToRGBA( const in float v ) {
  1639. if( v <= 0.0 )
  1640. return vec4( 0., 0., 0., 0. );
  1641. if( v >= 1.0 )
  1642. return vec4( 1., 1., 1., 1. );
  1643. float vuf;
  1644. float af = modf( v * PackFactors.a, vuf );
  1645. float bf = modf( vuf * ShiftRight8, vuf );
  1646. float gf = modf( vuf * ShiftRight8, vuf );
  1647. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1648. }
  1649. vec3 packDepthToRGB( const in float v ) {
  1650. if( v <= 0.0 )
  1651. return vec3( 0., 0., 0. );
  1652. if( v >= 1.0 )
  1653. return vec3( 1., 1., 1. );
  1654. float vuf;
  1655. float bf = modf( v * PackFactors.b, vuf );
  1656. float gf = modf( vuf * ShiftRight8, vuf );
  1657. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1658. }
  1659. vec2 packDepthToRG( const in float v ) {
  1660. if( v <= 0.0 )
  1661. return vec2( 0., 0. );
  1662. if( v >= 1.0 )
  1663. return vec2( 1., 1. );
  1664. float vuf;
  1665. float gf = modf( v * 256., vuf );
  1666. return vec2( vuf * Inv255, gf );
  1667. }
  1668. float unpackRGBAToDepth( const in vec4 v ) {
  1669. return dot( v, UnpackFactors4 );
  1670. }
  1671. float unpackRGBToDepth( const in vec3 v ) {
  1672. return dot( v, UnpackFactors3 );
  1673. }
  1674. float unpackRGToDepth( const in vec2 v ) {
  1675. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1676. }
  1677. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1678. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1679. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1680. }
  1681. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1682. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1683. }
  1684. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1685. return ( viewZ + near ) / ( near - far );
  1686. }
  1687. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1688. return depth * ( near - far ) - near;
  1689. }
  1690. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1691. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1692. }
  1693. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1694. return ( near * far ) / ( ( far - near ) * depth - far );
  1695. }`,G3e=`#ifdef PREMULTIPLIED_ALPHA
  1696. gl_FragColor.rgb *= gl_FragColor.a;
  1697. #endif`,W3e=`vec4 mvPosition = vec4( transformed, 1.0 );
  1698. #ifdef USE_BATCHING
  1699. mvPosition = batchingMatrix * mvPosition;
  1700. #endif
  1701. #ifdef USE_INSTANCING
  1702. mvPosition = instanceMatrix * mvPosition;
  1703. #endif
  1704. mvPosition = modelViewMatrix * mvPosition;
  1705. gl_Position = projectionMatrix * mvPosition;`,q3e=`#ifdef DITHERING
  1706. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1707. #endif`,K3e=`#ifdef DITHERING
  1708. vec3 dithering( vec3 color ) {
  1709. float grid_position = rand( gl_FragCoord.xy );
  1710. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1711. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1712. return color + dither_shift_RGB;
  1713. }
  1714. #endif`,X3e=`float roughnessFactor = roughness;
  1715. #ifdef USE_ROUGHNESSMAP
  1716. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1717. roughnessFactor *= texelRoughness.g;
  1718. #endif`,Y3e=`#ifdef USE_ROUGHNESSMAP
  1719. uniform sampler2D roughnessMap;
  1720. #endif`,Z3e=`#if NUM_SPOT_LIGHT_COORDS > 0
  1721. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1722. #endif
  1723. #if NUM_SPOT_LIGHT_MAPS > 0
  1724. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1725. #endif
  1726. #ifdef USE_SHADOWMAP
  1727. #if NUM_DIR_LIGHT_SHADOWS > 0
  1728. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1729. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1730. struct DirectionalLightShadow {
  1731. float shadowIntensity;
  1732. float shadowBias;
  1733. float shadowNormalBias;
  1734. float shadowRadius;
  1735. vec2 shadowMapSize;
  1736. };
  1737. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1738. #endif
  1739. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1740. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1741. struct SpotLightShadow {
  1742. float shadowIntensity;
  1743. float shadowBias;
  1744. float shadowNormalBias;
  1745. float shadowRadius;
  1746. vec2 shadowMapSize;
  1747. };
  1748. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1749. #endif
  1750. #if NUM_POINT_LIGHT_SHADOWS > 0
  1751. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1752. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1753. struct PointLightShadow {
  1754. float shadowIntensity;
  1755. float shadowBias;
  1756. float shadowNormalBias;
  1757. float shadowRadius;
  1758. vec2 shadowMapSize;
  1759. float shadowCameraNear;
  1760. float shadowCameraFar;
  1761. };
  1762. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1763. #endif
  1764. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1765. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1766. #ifdef USE_REVERSED_DEPTH_BUFFER
  1767. return step( depth, compare );
  1768. #else
  1769. return step( compare, depth );
  1770. #endif
  1771. }
  1772. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1773. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1774. }
  1775. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1776. float occlusion = 1.0;
  1777. vec2 distribution = texture2DDistribution( shadow, uv );
  1778. #ifdef USE_REVERSED_DEPTH_BUFFER
  1779. float hard_shadow = step( distribution.x, compare );
  1780. #else
  1781. float hard_shadow = step( compare, distribution.x );
  1782. #endif
  1783. if ( hard_shadow != 1.0 ) {
  1784. float distance = compare - distribution.x;
  1785. float variance = max( 0.00000, distribution.y * distribution.y );
  1786. 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 );
  1787. }
  1788. return occlusion;
  1789. }
  1790. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1791. float shadow = 1.0;
  1792. shadowCoord.xyz /= shadowCoord.w;
  1793. shadowCoord.z += shadowBias;
  1794. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1795. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1796. if ( frustumTest ) {
  1797. #if defined( SHADOWMAP_TYPE_PCF )
  1798. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1799. float dx0 = - texelSize.x * shadowRadius;
  1800. float dy0 = - texelSize.y * shadowRadius;
  1801. float dx1 = + texelSize.x * shadowRadius;
  1802. float dy1 = + texelSize.y * shadowRadius;
  1803. float dx2 = dx0 / 2.0;
  1804. float dy2 = dy0 / 2.0;
  1805. float dx3 = dx1 / 2.0;
  1806. float dy3 = dy1 / 2.0;
  1807. shadow = (
  1808. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1809. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1810. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1811. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1812. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1813. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1814. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1815. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1816. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1817. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1818. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1819. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1820. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1821. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1822. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1823. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1824. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1825. ) * ( 1.0 / 17.0 );
  1826. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1827. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1828. float dx = texelSize.x;
  1829. float dy = texelSize.y;
  1830. vec2 uv = shadowCoord.xy;
  1831. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1832. uv -= f * texelSize;
  1833. shadow = (
  1834. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1835. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1836. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1837. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1838. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1839. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1840. f.x ) +
  1841. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1842. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1843. f.x ) +
  1844. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1845. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1846. f.y ) +
  1847. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1848. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1849. f.y ) +
  1850. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1851. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1852. f.x ),
  1853. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1854. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1855. f.x ),
  1856. f.y )
  1857. ) * ( 1.0 / 9.0 );
  1858. #elif defined( SHADOWMAP_TYPE_VSM )
  1859. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1860. #else
  1861. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1862. #endif
  1863. }
  1864. return mix( 1.0, shadow, shadowIntensity );
  1865. }
  1866. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1867. vec3 absV = abs( v );
  1868. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1869. absV *= scaleToCube;
  1870. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1871. vec2 planar = v.xy;
  1872. float almostATexel = 1.5 * texelSizeY;
  1873. float almostOne = 1.0 - almostATexel;
  1874. if ( absV.z >= almostOne ) {
  1875. if ( v.z > 0.0 )
  1876. planar.x = 4.0 - v.x;
  1877. } else if ( absV.x >= almostOne ) {
  1878. float signX = sign( v.x );
  1879. planar.x = v.z * signX + 2.0 * signX;
  1880. } else if ( absV.y >= almostOne ) {
  1881. float signY = sign( v.y );
  1882. planar.x = v.x + 2.0 * signY + 2.0;
  1883. planar.y = v.z * signY - 2.0;
  1884. }
  1885. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1886. }
  1887. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1888. float shadow = 1.0;
  1889. vec3 lightToPosition = shadowCoord.xyz;
  1890. float lightToPositionLength = length( lightToPosition );
  1891. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1892. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1893. vec3 bd3D = normalize( lightToPosition );
  1894. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1895. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1896. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1897. shadow = (
  1898. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1899. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1900. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1901. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1902. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1903. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1904. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1905. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1906. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1907. ) * ( 1.0 / 9.0 );
  1908. #else
  1909. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1910. #endif
  1911. }
  1912. return mix( 1.0, shadow, shadowIntensity );
  1913. }
  1914. #endif`,Q3e=`#if NUM_SPOT_LIGHT_COORDS > 0
  1915. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1916. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1917. #endif
  1918. #ifdef USE_SHADOWMAP
  1919. #if NUM_DIR_LIGHT_SHADOWS > 0
  1920. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1921. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1922. struct DirectionalLightShadow {
  1923. float shadowIntensity;
  1924. float shadowBias;
  1925. float shadowNormalBias;
  1926. float shadowRadius;
  1927. vec2 shadowMapSize;
  1928. };
  1929. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1930. #endif
  1931. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1932. struct SpotLightShadow {
  1933. float shadowIntensity;
  1934. float shadowBias;
  1935. float shadowNormalBias;
  1936. float shadowRadius;
  1937. vec2 shadowMapSize;
  1938. };
  1939. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1940. #endif
  1941. #if NUM_POINT_LIGHT_SHADOWS > 0
  1942. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1943. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1944. struct PointLightShadow {
  1945. float shadowIntensity;
  1946. float shadowBias;
  1947. float shadowNormalBias;
  1948. float shadowRadius;
  1949. vec2 shadowMapSize;
  1950. float shadowCameraNear;
  1951. float shadowCameraFar;
  1952. };
  1953. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1954. #endif
  1955. #endif`,J3e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1956. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1957. vec4 shadowWorldPosition;
  1958. #endif
  1959. #if defined( USE_SHADOWMAP )
  1960. #if NUM_DIR_LIGHT_SHADOWS > 0
  1961. #pragma unroll_loop_start
  1962. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1963. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1964. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1965. }
  1966. #pragma unroll_loop_end
  1967. #endif
  1968. #if NUM_POINT_LIGHT_SHADOWS > 0
  1969. #pragma unroll_loop_start
  1970. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1971. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1972. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1973. }
  1974. #pragma unroll_loop_end
  1975. #endif
  1976. #endif
  1977. #if NUM_SPOT_LIGHT_COORDS > 0
  1978. #pragma unroll_loop_start
  1979. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1980. shadowWorldPosition = worldPosition;
  1981. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1982. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1983. #endif
  1984. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1985. }
  1986. #pragma unroll_loop_end
  1987. #endif`,ePe=`float getShadowMask() {
  1988. float shadow = 1.0;
  1989. #ifdef USE_SHADOWMAP
  1990. #if NUM_DIR_LIGHT_SHADOWS > 0
  1991. DirectionalLightShadow directionalLight;
  1992. #pragma unroll_loop_start
  1993. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1994. directionalLight = directionalLightShadows[ i ];
  1995. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1996. }
  1997. #pragma unroll_loop_end
  1998. #endif
  1999. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2000. SpotLightShadow spotLight;
  2001. #pragma unroll_loop_start
  2002. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2003. spotLight = spotLightShadows[ i ];
  2004. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2005. }
  2006. #pragma unroll_loop_end
  2007. #endif
  2008. #if NUM_POINT_LIGHT_SHADOWS > 0
  2009. PointLightShadow pointLight;
  2010. #pragma unroll_loop_start
  2011. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2012. pointLight = pointLightShadows[ i ];
  2013. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2014. }
  2015. #pragma unroll_loop_end
  2016. #endif
  2017. #endif
  2018. return shadow;
  2019. }`,tPe=`#ifdef USE_SKINNING
  2020. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2021. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2022. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2023. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2024. #endif`,nPe=`#ifdef USE_SKINNING
  2025. uniform mat4 bindMatrix;
  2026. uniform mat4 bindMatrixInverse;
  2027. uniform highp sampler2D boneTexture;
  2028. mat4 getBoneMatrix( const in float i ) {
  2029. int size = textureSize( boneTexture, 0 ).x;
  2030. int j = int( i ) * 4;
  2031. int x = j % size;
  2032. int y = j / size;
  2033. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2034. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2035. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2036. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2037. return mat4( v1, v2, v3, v4 );
  2038. }
  2039. #endif`,rPe=`#ifdef USE_SKINNING
  2040. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2041. vec4 skinned = vec4( 0.0 );
  2042. skinned += boneMatX * skinVertex * skinWeight.x;
  2043. skinned += boneMatY * skinVertex * skinWeight.y;
  2044. skinned += boneMatZ * skinVertex * skinWeight.z;
  2045. skinned += boneMatW * skinVertex * skinWeight.w;
  2046. transformed = ( bindMatrixInverse * skinned ).xyz;
  2047. #endif`,iPe=`#ifdef USE_SKINNING
  2048. mat4 skinMatrix = mat4( 0.0 );
  2049. skinMatrix += skinWeight.x * boneMatX;
  2050. skinMatrix += skinWeight.y * boneMatY;
  2051. skinMatrix += skinWeight.z * boneMatZ;
  2052. skinMatrix += skinWeight.w * boneMatW;
  2053. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2054. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2055. #ifdef USE_TANGENT
  2056. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2057. #endif
  2058. #endif`,aPe=`float specularStrength;
  2059. #ifdef USE_SPECULARMAP
  2060. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2061. specularStrength = texelSpecular.r;
  2062. #else
  2063. specularStrength = 1.0;
  2064. #endif`,sPe=`#ifdef USE_SPECULARMAP
  2065. uniform sampler2D specularMap;
  2066. #endif`,oPe=`#if defined( TONE_MAPPING )
  2067. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2068. #endif`,lPe=`#ifndef saturate
  2069. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2070. #endif
  2071. uniform float toneMappingExposure;
  2072. vec3 LinearToneMapping( vec3 color ) {
  2073. return saturate( toneMappingExposure * color );
  2074. }
  2075. vec3 ReinhardToneMapping( vec3 color ) {
  2076. color *= toneMappingExposure;
  2077. return saturate( color / ( vec3( 1.0 ) + color ) );
  2078. }
  2079. vec3 CineonToneMapping( vec3 color ) {
  2080. color *= toneMappingExposure;
  2081. color = max( vec3( 0.0 ), color - 0.004 );
  2082. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2083. }
  2084. vec3 RRTAndODTFit( vec3 v ) {
  2085. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2086. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2087. return a / b;
  2088. }
  2089. vec3 ACESFilmicToneMapping( vec3 color ) {
  2090. const mat3 ACESInputMat = mat3(
  2091. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2092. vec3( 0.04823, 0.01566, 0.83777 )
  2093. );
  2094. const mat3 ACESOutputMat = mat3(
  2095. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2096. vec3( -0.07367, -0.00605, 1.07602 )
  2097. );
  2098. color *= toneMappingExposure / 0.6;
  2099. color = ACESInputMat * color;
  2100. color = RRTAndODTFit( color );
  2101. color = ACESOutputMat * color;
  2102. return saturate( color );
  2103. }
  2104. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2105. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2106. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2107. vec3( - 0.0728, - 0.0083, 1.1187 )
  2108. );
  2109. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2110. vec3( 0.6274, 0.0691, 0.0164 ),
  2111. vec3( 0.3293, 0.9195, 0.0880 ),
  2112. vec3( 0.0433, 0.0113, 0.8956 )
  2113. );
  2114. vec3 agxDefaultContrastApprox( vec3 x ) {
  2115. vec3 x2 = x * x;
  2116. vec3 x4 = x2 * x2;
  2117. return + 15.5 * x4 * x2
  2118. - 40.14 * x4 * x
  2119. + 31.96 * x4
  2120. - 6.868 * x2 * x
  2121. + 0.4298 * x2
  2122. + 0.1191 * x
  2123. - 0.00232;
  2124. }
  2125. vec3 AgXToneMapping( vec3 color ) {
  2126. const mat3 AgXInsetMatrix = mat3(
  2127. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2128. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2129. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2130. );
  2131. const mat3 AgXOutsetMatrix = mat3(
  2132. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2133. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2134. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2135. );
  2136. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2137. color *= toneMappingExposure;
  2138. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2139. color = AgXInsetMatrix * color;
  2140. color = max( color, 1e-10 ); color = log2( color );
  2141. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2142. color = clamp( color, 0.0, 1.0 );
  2143. color = agxDefaultContrastApprox( color );
  2144. color = AgXOutsetMatrix * color;
  2145. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2146. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2147. color = clamp( color, 0.0, 1.0 );
  2148. return color;
  2149. }
  2150. vec3 NeutralToneMapping( vec3 color ) {
  2151. const float StartCompression = 0.8 - 0.04;
  2152. const float Desaturation = 0.15;
  2153. color *= toneMappingExposure;
  2154. float x = min( color.r, min( color.g, color.b ) );
  2155. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2156. color -= offset;
  2157. float peak = max( color.r, max( color.g, color.b ) );
  2158. if ( peak < StartCompression ) return color;
  2159. float d = 1. - StartCompression;
  2160. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2161. color *= newPeak / peak;
  2162. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2163. return mix( color, vec3( newPeak ), g );
  2164. }
  2165. vec3 CustomToneMapping( vec3 color ) { return color; }`,cPe=`#ifdef USE_TRANSMISSION
  2166. material.transmission = transmission;
  2167. material.transmissionAlpha = 1.0;
  2168. material.thickness = thickness;
  2169. material.attenuationDistance = attenuationDistance;
  2170. material.attenuationColor = attenuationColor;
  2171. #ifdef USE_TRANSMISSIONMAP
  2172. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2173. #endif
  2174. #ifdef USE_THICKNESSMAP
  2175. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2176. #endif
  2177. vec3 pos = vWorldPosition;
  2178. vec3 v = normalize( cameraPosition - pos );
  2179. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2180. vec4 transmitted = getIBLVolumeRefraction(
  2181. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2182. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2183. material.attenuationColor, material.attenuationDistance );
  2184. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2185. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2186. #endif`,uPe=`#ifdef USE_TRANSMISSION
  2187. uniform float transmission;
  2188. uniform float thickness;
  2189. uniform float attenuationDistance;
  2190. uniform vec3 attenuationColor;
  2191. #ifdef USE_TRANSMISSIONMAP
  2192. uniform sampler2D transmissionMap;
  2193. #endif
  2194. #ifdef USE_THICKNESSMAP
  2195. uniform sampler2D thicknessMap;
  2196. #endif
  2197. uniform vec2 transmissionSamplerSize;
  2198. uniform sampler2D transmissionSamplerMap;
  2199. uniform mat4 modelMatrix;
  2200. uniform mat4 projectionMatrix;
  2201. varying vec3 vWorldPosition;
  2202. float w0( float a ) {
  2203. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2204. }
  2205. float w1( float a ) {
  2206. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2207. }
  2208. float w2( float a ){
  2209. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2210. }
  2211. float w3( float a ) {
  2212. return ( 1.0 / 6.0 ) * ( a * a * a );
  2213. }
  2214. float g0( float a ) {
  2215. return w0( a ) + w1( a );
  2216. }
  2217. float g1( float a ) {
  2218. return w2( a ) + w3( a );
  2219. }
  2220. float h0( float a ) {
  2221. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2222. }
  2223. float h1( float a ) {
  2224. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2225. }
  2226. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2227. uv = uv * texelSize.zw + 0.5;
  2228. vec2 iuv = floor( uv );
  2229. vec2 fuv = fract( uv );
  2230. float g0x = g0( fuv.x );
  2231. float g1x = g1( fuv.x );
  2232. float h0x = h0( fuv.x );
  2233. float h1x = h1( fuv.x );
  2234. float h0y = h0( fuv.y );
  2235. float h1y = h1( fuv.y );
  2236. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2237. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2238. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2239. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2240. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2241. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2242. }
  2243. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2244. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2245. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2246. vec2 fLodSizeInv = 1.0 / fLodSize;
  2247. vec2 cLodSizeInv = 1.0 / cLodSize;
  2248. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2249. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2250. return mix( fSample, cSample, fract( lod ) );
  2251. }
  2252. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2253. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2254. vec3 modelScale;
  2255. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2256. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2257. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2258. return normalize( refractionVector ) * thickness * modelScale;
  2259. }
  2260. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2261. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2262. }
  2263. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2264. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2265. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2266. }
  2267. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2268. if ( isinf( attenuationDistance ) ) {
  2269. return vec3( 1.0 );
  2270. } else {
  2271. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2272. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2273. }
  2274. }
  2275. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2276. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2277. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2278. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2279. vec4 transmittedLight;
  2280. vec3 transmittance;
  2281. #ifdef USE_DISPERSION
  2282. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2283. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2284. for ( int i = 0; i < 3; i ++ ) {
  2285. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2286. vec3 refractedRayExit = position + transmissionRay;
  2287. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2288. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2289. refractionCoords += 1.0;
  2290. refractionCoords /= 2.0;
  2291. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2292. transmittedLight[ i ] = transmissionSample[ i ];
  2293. transmittedLight.a += transmissionSample.a;
  2294. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2295. }
  2296. transmittedLight.a /= 3.0;
  2297. #else
  2298. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2299. vec3 refractedRayExit = position + transmissionRay;
  2300. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2301. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2302. refractionCoords += 1.0;
  2303. refractionCoords /= 2.0;
  2304. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2305. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2306. #endif
  2307. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2308. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2309. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2310. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2311. }
  2312. #endif`,dPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2313. varying vec2 vUv;
  2314. #endif
  2315. #ifdef USE_MAP
  2316. varying vec2 vMapUv;
  2317. #endif
  2318. #ifdef USE_ALPHAMAP
  2319. varying vec2 vAlphaMapUv;
  2320. #endif
  2321. #ifdef USE_LIGHTMAP
  2322. varying vec2 vLightMapUv;
  2323. #endif
  2324. #ifdef USE_AOMAP
  2325. varying vec2 vAoMapUv;
  2326. #endif
  2327. #ifdef USE_BUMPMAP
  2328. varying vec2 vBumpMapUv;
  2329. #endif
  2330. #ifdef USE_NORMALMAP
  2331. varying vec2 vNormalMapUv;
  2332. #endif
  2333. #ifdef USE_EMISSIVEMAP
  2334. varying vec2 vEmissiveMapUv;
  2335. #endif
  2336. #ifdef USE_METALNESSMAP
  2337. varying vec2 vMetalnessMapUv;
  2338. #endif
  2339. #ifdef USE_ROUGHNESSMAP
  2340. varying vec2 vRoughnessMapUv;
  2341. #endif
  2342. #ifdef USE_ANISOTROPYMAP
  2343. varying vec2 vAnisotropyMapUv;
  2344. #endif
  2345. #ifdef USE_CLEARCOATMAP
  2346. varying vec2 vClearcoatMapUv;
  2347. #endif
  2348. #ifdef USE_CLEARCOAT_NORMALMAP
  2349. varying vec2 vClearcoatNormalMapUv;
  2350. #endif
  2351. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2352. varying vec2 vClearcoatRoughnessMapUv;
  2353. #endif
  2354. #ifdef USE_IRIDESCENCEMAP
  2355. varying vec2 vIridescenceMapUv;
  2356. #endif
  2357. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2358. varying vec2 vIridescenceThicknessMapUv;
  2359. #endif
  2360. #ifdef USE_SHEEN_COLORMAP
  2361. varying vec2 vSheenColorMapUv;
  2362. #endif
  2363. #ifdef USE_SHEEN_ROUGHNESSMAP
  2364. varying vec2 vSheenRoughnessMapUv;
  2365. #endif
  2366. #ifdef USE_SPECULARMAP
  2367. varying vec2 vSpecularMapUv;
  2368. #endif
  2369. #ifdef USE_SPECULAR_COLORMAP
  2370. varying vec2 vSpecularColorMapUv;
  2371. #endif
  2372. #ifdef USE_SPECULAR_INTENSITYMAP
  2373. varying vec2 vSpecularIntensityMapUv;
  2374. #endif
  2375. #ifdef USE_TRANSMISSIONMAP
  2376. uniform mat3 transmissionMapTransform;
  2377. varying vec2 vTransmissionMapUv;
  2378. #endif
  2379. #ifdef USE_THICKNESSMAP
  2380. uniform mat3 thicknessMapTransform;
  2381. varying vec2 vThicknessMapUv;
  2382. #endif`,hPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2383. varying vec2 vUv;
  2384. #endif
  2385. #ifdef USE_MAP
  2386. uniform mat3 mapTransform;
  2387. varying vec2 vMapUv;
  2388. #endif
  2389. #ifdef USE_ALPHAMAP
  2390. uniform mat3 alphaMapTransform;
  2391. varying vec2 vAlphaMapUv;
  2392. #endif
  2393. #ifdef USE_LIGHTMAP
  2394. uniform mat3 lightMapTransform;
  2395. varying vec2 vLightMapUv;
  2396. #endif
  2397. #ifdef USE_AOMAP
  2398. uniform mat3 aoMapTransform;
  2399. varying vec2 vAoMapUv;
  2400. #endif
  2401. #ifdef USE_BUMPMAP
  2402. uniform mat3 bumpMapTransform;
  2403. varying vec2 vBumpMapUv;
  2404. #endif
  2405. #ifdef USE_NORMALMAP
  2406. uniform mat3 normalMapTransform;
  2407. varying vec2 vNormalMapUv;
  2408. #endif
  2409. #ifdef USE_DISPLACEMENTMAP
  2410. uniform mat3 displacementMapTransform;
  2411. varying vec2 vDisplacementMapUv;
  2412. #endif
  2413. #ifdef USE_EMISSIVEMAP
  2414. uniform mat3 emissiveMapTransform;
  2415. varying vec2 vEmissiveMapUv;
  2416. #endif
  2417. #ifdef USE_METALNESSMAP
  2418. uniform mat3 metalnessMapTransform;
  2419. varying vec2 vMetalnessMapUv;
  2420. #endif
  2421. #ifdef USE_ROUGHNESSMAP
  2422. uniform mat3 roughnessMapTransform;
  2423. varying vec2 vRoughnessMapUv;
  2424. #endif
  2425. #ifdef USE_ANISOTROPYMAP
  2426. uniform mat3 anisotropyMapTransform;
  2427. varying vec2 vAnisotropyMapUv;
  2428. #endif
  2429. #ifdef USE_CLEARCOATMAP
  2430. uniform mat3 clearcoatMapTransform;
  2431. varying vec2 vClearcoatMapUv;
  2432. #endif
  2433. #ifdef USE_CLEARCOAT_NORMALMAP
  2434. uniform mat3 clearcoatNormalMapTransform;
  2435. varying vec2 vClearcoatNormalMapUv;
  2436. #endif
  2437. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2438. uniform mat3 clearcoatRoughnessMapTransform;
  2439. varying vec2 vClearcoatRoughnessMapUv;
  2440. #endif
  2441. #ifdef USE_SHEEN_COLORMAP
  2442. uniform mat3 sheenColorMapTransform;
  2443. varying vec2 vSheenColorMapUv;
  2444. #endif
  2445. #ifdef USE_SHEEN_ROUGHNESSMAP
  2446. uniform mat3 sheenRoughnessMapTransform;
  2447. varying vec2 vSheenRoughnessMapUv;
  2448. #endif
  2449. #ifdef USE_IRIDESCENCEMAP
  2450. uniform mat3 iridescenceMapTransform;
  2451. varying vec2 vIridescenceMapUv;
  2452. #endif
  2453. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2454. uniform mat3 iridescenceThicknessMapTransform;
  2455. varying vec2 vIridescenceThicknessMapUv;
  2456. #endif
  2457. #ifdef USE_SPECULARMAP
  2458. uniform mat3 specularMapTransform;
  2459. varying vec2 vSpecularMapUv;
  2460. #endif
  2461. #ifdef USE_SPECULAR_COLORMAP
  2462. uniform mat3 specularColorMapTransform;
  2463. varying vec2 vSpecularColorMapUv;
  2464. #endif
  2465. #ifdef USE_SPECULAR_INTENSITYMAP
  2466. uniform mat3 specularIntensityMapTransform;
  2467. varying vec2 vSpecularIntensityMapUv;
  2468. #endif
  2469. #ifdef USE_TRANSMISSIONMAP
  2470. uniform mat3 transmissionMapTransform;
  2471. varying vec2 vTransmissionMapUv;
  2472. #endif
  2473. #ifdef USE_THICKNESSMAP
  2474. uniform mat3 thicknessMapTransform;
  2475. varying vec2 vThicknessMapUv;
  2476. #endif`,fPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2477. vUv = vec3( uv, 1 ).xy;
  2478. #endif
  2479. #ifdef USE_MAP
  2480. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2481. #endif
  2482. #ifdef USE_ALPHAMAP
  2483. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2484. #endif
  2485. #ifdef USE_LIGHTMAP
  2486. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2487. #endif
  2488. #ifdef USE_AOMAP
  2489. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2490. #endif
  2491. #ifdef USE_BUMPMAP
  2492. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2493. #endif
  2494. #ifdef USE_NORMALMAP
  2495. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2496. #endif
  2497. #ifdef USE_DISPLACEMENTMAP
  2498. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2499. #endif
  2500. #ifdef USE_EMISSIVEMAP
  2501. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2502. #endif
  2503. #ifdef USE_METALNESSMAP
  2504. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2505. #endif
  2506. #ifdef USE_ROUGHNESSMAP
  2507. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2508. #endif
  2509. #ifdef USE_ANISOTROPYMAP
  2510. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2511. #endif
  2512. #ifdef USE_CLEARCOATMAP
  2513. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2514. #endif
  2515. #ifdef USE_CLEARCOAT_NORMALMAP
  2516. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2517. #endif
  2518. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2519. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2520. #endif
  2521. #ifdef USE_IRIDESCENCEMAP
  2522. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2523. #endif
  2524. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2525. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2526. #endif
  2527. #ifdef USE_SHEEN_COLORMAP
  2528. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2529. #endif
  2530. #ifdef USE_SHEEN_ROUGHNESSMAP
  2531. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2532. #endif
  2533. #ifdef USE_SPECULARMAP
  2534. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2535. #endif
  2536. #ifdef USE_SPECULAR_COLORMAP
  2537. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2538. #endif
  2539. #ifdef USE_SPECULAR_INTENSITYMAP
  2540. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2541. #endif
  2542. #ifdef USE_TRANSMISSIONMAP
  2543. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2544. #endif
  2545. #ifdef USE_THICKNESSMAP
  2546. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2547. #endif`,mPe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2548. vec4 worldPosition = vec4( transformed, 1.0 );
  2549. #ifdef USE_BATCHING
  2550. worldPosition = batchingMatrix * worldPosition;
  2551. #endif
  2552. #ifdef USE_INSTANCING
  2553. worldPosition = instanceMatrix * worldPosition;
  2554. #endif
  2555. worldPosition = modelMatrix * worldPosition;
  2556. #endif`;const pPe=`varying vec2 vUv;
  2557. uniform mat3 uvTransform;
  2558. void main() {
  2559. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2560. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2561. }`,gPe=`uniform sampler2D t2D;
  2562. uniform float backgroundIntensity;
  2563. varying vec2 vUv;
  2564. void main() {
  2565. vec4 texColor = texture2D( t2D, vUv );
  2566. #ifdef DECODE_VIDEO_TEXTURE
  2567. 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 );
  2568. #endif
  2569. texColor.rgb *= backgroundIntensity;
  2570. gl_FragColor = texColor;
  2571. #include <tonemapping_fragment>
  2572. #include <colorspace_fragment>
  2573. }`,xPe=`varying vec3 vWorldDirection;
  2574. #include <common>
  2575. void main() {
  2576. vWorldDirection = transformDirection( position, modelMatrix );
  2577. #include <begin_vertex>
  2578. #include <project_vertex>
  2579. gl_Position.z = gl_Position.w;
  2580. }`,bPe=`#ifdef ENVMAP_TYPE_CUBE
  2581. uniform samplerCube envMap;
  2582. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2583. uniform sampler2D envMap;
  2584. #endif
  2585. uniform float flipEnvMap;
  2586. uniform float backgroundBlurriness;
  2587. uniform float backgroundIntensity;
  2588. uniform mat3 backgroundRotation;
  2589. varying vec3 vWorldDirection;
  2590. #include <cube_uv_reflection_fragment>
  2591. void main() {
  2592. #ifdef ENVMAP_TYPE_CUBE
  2593. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2594. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2595. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2596. #else
  2597. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2598. #endif
  2599. texColor.rgb *= backgroundIntensity;
  2600. gl_FragColor = texColor;
  2601. #include <tonemapping_fragment>
  2602. #include <colorspace_fragment>
  2603. }`,yPe=`varying vec3 vWorldDirection;
  2604. #include <common>
  2605. void main() {
  2606. vWorldDirection = transformDirection( position, modelMatrix );
  2607. #include <begin_vertex>
  2608. #include <project_vertex>
  2609. gl_Position.z = gl_Position.w;
  2610. }`,vPe=`uniform samplerCube tCube;
  2611. uniform float tFlip;
  2612. uniform float opacity;
  2613. varying vec3 vWorldDirection;
  2614. void main() {
  2615. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2616. gl_FragColor = texColor;
  2617. gl_FragColor.a *= opacity;
  2618. #include <tonemapping_fragment>
  2619. #include <colorspace_fragment>
  2620. }`,_Pe=`#include <common>
  2621. #include <batching_pars_vertex>
  2622. #include <uv_pars_vertex>
  2623. #include <displacementmap_pars_vertex>
  2624. #include <morphtarget_pars_vertex>
  2625. #include <skinning_pars_vertex>
  2626. #include <logdepthbuf_pars_vertex>
  2627. #include <clipping_planes_pars_vertex>
  2628. varying vec2 vHighPrecisionZW;
  2629. void main() {
  2630. #include <uv_vertex>
  2631. #include <batching_vertex>
  2632. #include <skinbase_vertex>
  2633. #include <morphinstance_vertex>
  2634. #ifdef USE_DISPLACEMENTMAP
  2635. #include <beginnormal_vertex>
  2636. #include <morphnormal_vertex>
  2637. #include <skinnormal_vertex>
  2638. #endif
  2639. #include <begin_vertex>
  2640. #include <morphtarget_vertex>
  2641. #include <skinning_vertex>
  2642. #include <displacementmap_vertex>
  2643. #include <project_vertex>
  2644. #include <logdepthbuf_vertex>
  2645. #include <clipping_planes_vertex>
  2646. vHighPrecisionZW = gl_Position.zw;
  2647. }`,wPe=`#if DEPTH_PACKING == 3200
  2648. uniform float opacity;
  2649. #endif
  2650. #include <common>
  2651. #include <packing>
  2652. #include <uv_pars_fragment>
  2653. #include <map_pars_fragment>
  2654. #include <alphamap_pars_fragment>
  2655. #include <alphatest_pars_fragment>
  2656. #include <alphahash_pars_fragment>
  2657. #include <logdepthbuf_pars_fragment>
  2658. #include <clipping_planes_pars_fragment>
  2659. varying vec2 vHighPrecisionZW;
  2660. void main() {
  2661. vec4 diffuseColor = vec4( 1.0 );
  2662. #include <clipping_planes_fragment>
  2663. #if DEPTH_PACKING == 3200
  2664. diffuseColor.a = opacity;
  2665. #endif
  2666. #include <map_fragment>
  2667. #include <alphamap_fragment>
  2668. #include <alphatest_fragment>
  2669. #include <alphahash_fragment>
  2670. #include <logdepthbuf_fragment>
  2671. #ifdef USE_REVERSED_DEPTH_BUFFER
  2672. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2673. #else
  2674. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2675. #endif
  2676. #if DEPTH_PACKING == 3200
  2677. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2678. #elif DEPTH_PACKING == 3201
  2679. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2680. #elif DEPTH_PACKING == 3202
  2681. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2682. #elif DEPTH_PACKING == 3203
  2683. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2684. #endif
  2685. }`,SPe=`#define DISTANCE
  2686. varying vec3 vWorldPosition;
  2687. #include <common>
  2688. #include <batching_pars_vertex>
  2689. #include <uv_pars_vertex>
  2690. #include <displacementmap_pars_vertex>
  2691. #include <morphtarget_pars_vertex>
  2692. #include <skinning_pars_vertex>
  2693. #include <clipping_planes_pars_vertex>
  2694. void main() {
  2695. #include <uv_vertex>
  2696. #include <batching_vertex>
  2697. #include <skinbase_vertex>
  2698. #include <morphinstance_vertex>
  2699. #ifdef USE_DISPLACEMENTMAP
  2700. #include <beginnormal_vertex>
  2701. #include <morphnormal_vertex>
  2702. #include <skinnormal_vertex>
  2703. #endif
  2704. #include <begin_vertex>
  2705. #include <morphtarget_vertex>
  2706. #include <skinning_vertex>
  2707. #include <displacementmap_vertex>
  2708. #include <project_vertex>
  2709. #include <worldpos_vertex>
  2710. #include <clipping_planes_vertex>
  2711. vWorldPosition = worldPosition.xyz;
  2712. }`,MPe=`#define DISTANCE
  2713. uniform vec3 referencePosition;
  2714. uniform float nearDistance;
  2715. uniform float farDistance;
  2716. varying vec3 vWorldPosition;
  2717. #include <common>
  2718. #include <packing>
  2719. #include <uv_pars_fragment>
  2720. #include <map_pars_fragment>
  2721. #include <alphamap_pars_fragment>
  2722. #include <alphatest_pars_fragment>
  2723. #include <alphahash_pars_fragment>
  2724. #include <clipping_planes_pars_fragment>
  2725. void main () {
  2726. vec4 diffuseColor = vec4( 1.0 );
  2727. #include <clipping_planes_fragment>
  2728. #include <map_fragment>
  2729. #include <alphamap_fragment>
  2730. #include <alphatest_fragment>
  2731. #include <alphahash_fragment>
  2732. float dist = length( vWorldPosition - referencePosition );
  2733. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2734. dist = saturate( dist );
  2735. gl_FragColor = packDepthToRGBA( dist );
  2736. }`,EPe=`varying vec3 vWorldDirection;
  2737. #include <common>
  2738. void main() {
  2739. vWorldDirection = transformDirection( position, modelMatrix );
  2740. #include <begin_vertex>
  2741. #include <project_vertex>
  2742. }`,APe=`uniform sampler2D tEquirect;
  2743. varying vec3 vWorldDirection;
  2744. #include <common>
  2745. void main() {
  2746. vec3 direction = normalize( vWorldDirection );
  2747. vec2 sampleUV = equirectUv( direction );
  2748. gl_FragColor = texture2D( tEquirect, sampleUV );
  2749. #include <tonemapping_fragment>
  2750. #include <colorspace_fragment>
  2751. }`,TPe=`uniform float scale;
  2752. attribute float lineDistance;
  2753. varying float vLineDistance;
  2754. #include <common>
  2755. #include <uv_pars_vertex>
  2756. #include <color_pars_vertex>
  2757. #include <fog_pars_vertex>
  2758. #include <morphtarget_pars_vertex>
  2759. #include <logdepthbuf_pars_vertex>
  2760. #include <clipping_planes_pars_vertex>
  2761. void main() {
  2762. vLineDistance = scale * lineDistance;
  2763. #include <uv_vertex>
  2764. #include <color_vertex>
  2765. #include <morphinstance_vertex>
  2766. #include <morphcolor_vertex>
  2767. #include <begin_vertex>
  2768. #include <morphtarget_vertex>
  2769. #include <project_vertex>
  2770. #include <logdepthbuf_vertex>
  2771. #include <clipping_planes_vertex>
  2772. #include <fog_vertex>
  2773. }`,CPe=`uniform vec3 diffuse;
  2774. uniform float opacity;
  2775. uniform float dashSize;
  2776. uniform float totalSize;
  2777. varying float vLineDistance;
  2778. #include <common>
  2779. #include <color_pars_fragment>
  2780. #include <uv_pars_fragment>
  2781. #include <map_pars_fragment>
  2782. #include <fog_pars_fragment>
  2783. #include <logdepthbuf_pars_fragment>
  2784. #include <clipping_planes_pars_fragment>
  2785. void main() {
  2786. vec4 diffuseColor = vec4( diffuse, opacity );
  2787. #include <clipping_planes_fragment>
  2788. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2789. discard;
  2790. }
  2791. vec3 outgoingLight = vec3( 0.0 );
  2792. #include <logdepthbuf_fragment>
  2793. #include <map_fragment>
  2794. #include <color_fragment>
  2795. outgoingLight = diffuseColor.rgb;
  2796. #include <opaque_fragment>
  2797. #include <tonemapping_fragment>
  2798. #include <colorspace_fragment>
  2799. #include <fog_fragment>
  2800. #include <premultiplied_alpha_fragment>
  2801. }`,NPe=`#include <common>
  2802. #include <batching_pars_vertex>
  2803. #include <uv_pars_vertex>
  2804. #include <envmap_pars_vertex>
  2805. #include <color_pars_vertex>
  2806. #include <fog_pars_vertex>
  2807. #include <morphtarget_pars_vertex>
  2808. #include <skinning_pars_vertex>
  2809. #include <logdepthbuf_pars_vertex>
  2810. #include <clipping_planes_pars_vertex>
  2811. void main() {
  2812. #include <uv_vertex>
  2813. #include <color_vertex>
  2814. #include <morphinstance_vertex>
  2815. #include <morphcolor_vertex>
  2816. #include <batching_vertex>
  2817. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2818. #include <beginnormal_vertex>
  2819. #include <morphnormal_vertex>
  2820. #include <skinbase_vertex>
  2821. #include <skinnormal_vertex>
  2822. #include <defaultnormal_vertex>
  2823. #endif
  2824. #include <begin_vertex>
  2825. #include <morphtarget_vertex>
  2826. #include <skinning_vertex>
  2827. #include <project_vertex>
  2828. #include <logdepthbuf_vertex>
  2829. #include <clipping_planes_vertex>
  2830. #include <worldpos_vertex>
  2831. #include <envmap_vertex>
  2832. #include <fog_vertex>
  2833. }`,kPe=`uniform vec3 diffuse;
  2834. uniform float opacity;
  2835. #ifndef FLAT_SHADED
  2836. varying vec3 vNormal;
  2837. #endif
  2838. #include <common>
  2839. #include <dithering_pars_fragment>
  2840. #include <color_pars_fragment>
  2841. #include <uv_pars_fragment>
  2842. #include <map_pars_fragment>
  2843. #include <alphamap_pars_fragment>
  2844. #include <alphatest_pars_fragment>
  2845. #include <alphahash_pars_fragment>
  2846. #include <aomap_pars_fragment>
  2847. #include <lightmap_pars_fragment>
  2848. #include <envmap_common_pars_fragment>
  2849. #include <envmap_pars_fragment>
  2850. #include <fog_pars_fragment>
  2851. #include <specularmap_pars_fragment>
  2852. #include <logdepthbuf_pars_fragment>
  2853. #include <clipping_planes_pars_fragment>
  2854. void main() {
  2855. vec4 diffuseColor = vec4( diffuse, opacity );
  2856. #include <clipping_planes_fragment>
  2857. #include <logdepthbuf_fragment>
  2858. #include <map_fragment>
  2859. #include <color_fragment>
  2860. #include <alphamap_fragment>
  2861. #include <alphatest_fragment>
  2862. #include <alphahash_fragment>
  2863. #include <specularmap_fragment>
  2864. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2865. #ifdef USE_LIGHTMAP
  2866. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2867. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2868. #else
  2869. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2870. #endif
  2871. #include <aomap_fragment>
  2872. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2873. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2874. #include <envmap_fragment>
  2875. #include <opaque_fragment>
  2876. #include <tonemapping_fragment>
  2877. #include <colorspace_fragment>
  2878. #include <fog_fragment>
  2879. #include <premultiplied_alpha_fragment>
  2880. #include <dithering_fragment>
  2881. }`,PPe=`#define LAMBERT
  2882. varying vec3 vViewPosition;
  2883. #include <common>
  2884. #include <batching_pars_vertex>
  2885. #include <uv_pars_vertex>
  2886. #include <displacementmap_pars_vertex>
  2887. #include <envmap_pars_vertex>
  2888. #include <color_pars_vertex>
  2889. #include <fog_pars_vertex>
  2890. #include <normal_pars_vertex>
  2891. #include <morphtarget_pars_vertex>
  2892. #include <skinning_pars_vertex>
  2893. #include <shadowmap_pars_vertex>
  2894. #include <logdepthbuf_pars_vertex>
  2895. #include <clipping_planes_pars_vertex>
  2896. void main() {
  2897. #include <uv_vertex>
  2898. #include <color_vertex>
  2899. #include <morphinstance_vertex>
  2900. #include <morphcolor_vertex>
  2901. #include <batching_vertex>
  2902. #include <beginnormal_vertex>
  2903. #include <morphnormal_vertex>
  2904. #include <skinbase_vertex>
  2905. #include <skinnormal_vertex>
  2906. #include <defaultnormal_vertex>
  2907. #include <normal_vertex>
  2908. #include <begin_vertex>
  2909. #include <morphtarget_vertex>
  2910. #include <skinning_vertex>
  2911. #include <displacementmap_vertex>
  2912. #include <project_vertex>
  2913. #include <logdepthbuf_vertex>
  2914. #include <clipping_planes_vertex>
  2915. vViewPosition = - mvPosition.xyz;
  2916. #include <worldpos_vertex>
  2917. #include <envmap_vertex>
  2918. #include <shadowmap_vertex>
  2919. #include <fog_vertex>
  2920. }`,RPe=`#define LAMBERT
  2921. uniform vec3 diffuse;
  2922. uniform vec3 emissive;
  2923. uniform float opacity;
  2924. #include <common>
  2925. #include <packing>
  2926. #include <dithering_pars_fragment>
  2927. #include <color_pars_fragment>
  2928. #include <uv_pars_fragment>
  2929. #include <map_pars_fragment>
  2930. #include <alphamap_pars_fragment>
  2931. #include <alphatest_pars_fragment>
  2932. #include <alphahash_pars_fragment>
  2933. #include <aomap_pars_fragment>
  2934. #include <lightmap_pars_fragment>
  2935. #include <emissivemap_pars_fragment>
  2936. #include <envmap_common_pars_fragment>
  2937. #include <envmap_pars_fragment>
  2938. #include <fog_pars_fragment>
  2939. #include <bsdfs>
  2940. #include <lights_pars_begin>
  2941. #include <normal_pars_fragment>
  2942. #include <lights_lambert_pars_fragment>
  2943. #include <shadowmap_pars_fragment>
  2944. #include <bumpmap_pars_fragment>
  2945. #include <normalmap_pars_fragment>
  2946. #include <specularmap_pars_fragment>
  2947. #include <logdepthbuf_pars_fragment>
  2948. #include <clipping_planes_pars_fragment>
  2949. void main() {
  2950. vec4 diffuseColor = vec4( diffuse, opacity );
  2951. #include <clipping_planes_fragment>
  2952. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2953. vec3 totalEmissiveRadiance = emissive;
  2954. #include <logdepthbuf_fragment>
  2955. #include <map_fragment>
  2956. #include <color_fragment>
  2957. #include <alphamap_fragment>
  2958. #include <alphatest_fragment>
  2959. #include <alphahash_fragment>
  2960. #include <specularmap_fragment>
  2961. #include <normal_fragment_begin>
  2962. #include <normal_fragment_maps>
  2963. #include <emissivemap_fragment>
  2964. #include <lights_lambert_fragment>
  2965. #include <lights_fragment_begin>
  2966. #include <lights_fragment_maps>
  2967. #include <lights_fragment_end>
  2968. #include <aomap_fragment>
  2969. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2970. #include <envmap_fragment>
  2971. #include <opaque_fragment>
  2972. #include <tonemapping_fragment>
  2973. #include <colorspace_fragment>
  2974. #include <fog_fragment>
  2975. #include <premultiplied_alpha_fragment>
  2976. #include <dithering_fragment>
  2977. }`,jPe=`#define MATCAP
  2978. varying vec3 vViewPosition;
  2979. #include <common>
  2980. #include <batching_pars_vertex>
  2981. #include <uv_pars_vertex>
  2982. #include <color_pars_vertex>
  2983. #include <displacementmap_pars_vertex>
  2984. #include <fog_pars_vertex>
  2985. #include <normal_pars_vertex>
  2986. #include <morphtarget_pars_vertex>
  2987. #include <skinning_pars_vertex>
  2988. #include <logdepthbuf_pars_vertex>
  2989. #include <clipping_planes_pars_vertex>
  2990. void main() {
  2991. #include <uv_vertex>
  2992. #include <color_vertex>
  2993. #include <morphinstance_vertex>
  2994. #include <morphcolor_vertex>
  2995. #include <batching_vertex>
  2996. #include <beginnormal_vertex>
  2997. #include <morphnormal_vertex>
  2998. #include <skinbase_vertex>
  2999. #include <skinnormal_vertex>
  3000. #include <defaultnormal_vertex>
  3001. #include <normal_vertex>
  3002. #include <begin_vertex>
  3003. #include <morphtarget_vertex>
  3004. #include <skinning_vertex>
  3005. #include <displacementmap_vertex>
  3006. #include <project_vertex>
  3007. #include <logdepthbuf_vertex>
  3008. #include <clipping_planes_vertex>
  3009. #include <fog_vertex>
  3010. vViewPosition = - mvPosition.xyz;
  3011. }`,DPe=`#define MATCAP
  3012. uniform vec3 diffuse;
  3013. uniform float opacity;
  3014. uniform sampler2D matcap;
  3015. varying vec3 vViewPosition;
  3016. #include <common>
  3017. #include <dithering_pars_fragment>
  3018. #include <color_pars_fragment>
  3019. #include <uv_pars_fragment>
  3020. #include <map_pars_fragment>
  3021. #include <alphamap_pars_fragment>
  3022. #include <alphatest_pars_fragment>
  3023. #include <alphahash_pars_fragment>
  3024. #include <fog_pars_fragment>
  3025. #include <normal_pars_fragment>
  3026. #include <bumpmap_pars_fragment>
  3027. #include <normalmap_pars_fragment>
  3028. #include <logdepthbuf_pars_fragment>
  3029. #include <clipping_planes_pars_fragment>
  3030. void main() {
  3031. vec4 diffuseColor = vec4( diffuse, opacity );
  3032. #include <clipping_planes_fragment>
  3033. #include <logdepthbuf_fragment>
  3034. #include <map_fragment>
  3035. #include <color_fragment>
  3036. #include <alphamap_fragment>
  3037. #include <alphatest_fragment>
  3038. #include <alphahash_fragment>
  3039. #include <normal_fragment_begin>
  3040. #include <normal_fragment_maps>
  3041. vec3 viewDir = normalize( vViewPosition );
  3042. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3043. vec3 y = cross( viewDir, x );
  3044. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3045. #ifdef USE_MATCAP
  3046. vec4 matcapColor = texture2D( matcap, uv );
  3047. #else
  3048. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3049. #endif
  3050. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3051. #include <opaque_fragment>
  3052. #include <tonemapping_fragment>
  3053. #include <colorspace_fragment>
  3054. #include <fog_fragment>
  3055. #include <premultiplied_alpha_fragment>
  3056. #include <dithering_fragment>
  3057. }`,OPe=`#define NORMAL
  3058. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3059. varying vec3 vViewPosition;
  3060. #endif
  3061. #include <common>
  3062. #include <batching_pars_vertex>
  3063. #include <uv_pars_vertex>
  3064. #include <displacementmap_pars_vertex>
  3065. #include <normal_pars_vertex>
  3066. #include <morphtarget_pars_vertex>
  3067. #include <skinning_pars_vertex>
  3068. #include <logdepthbuf_pars_vertex>
  3069. #include <clipping_planes_pars_vertex>
  3070. void main() {
  3071. #include <uv_vertex>
  3072. #include <batching_vertex>
  3073. #include <beginnormal_vertex>
  3074. #include <morphinstance_vertex>
  3075. #include <morphnormal_vertex>
  3076. #include <skinbase_vertex>
  3077. #include <skinnormal_vertex>
  3078. #include <defaultnormal_vertex>
  3079. #include <normal_vertex>
  3080. #include <begin_vertex>
  3081. #include <morphtarget_vertex>
  3082. #include <skinning_vertex>
  3083. #include <displacementmap_vertex>
  3084. #include <project_vertex>
  3085. #include <logdepthbuf_vertex>
  3086. #include <clipping_planes_vertex>
  3087. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3088. vViewPosition = - mvPosition.xyz;
  3089. #endif
  3090. }`,LPe=`#define NORMAL
  3091. uniform float opacity;
  3092. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3093. varying vec3 vViewPosition;
  3094. #endif
  3095. #include <packing>
  3096. #include <uv_pars_fragment>
  3097. #include <normal_pars_fragment>
  3098. #include <bumpmap_pars_fragment>
  3099. #include <normalmap_pars_fragment>
  3100. #include <logdepthbuf_pars_fragment>
  3101. #include <clipping_planes_pars_fragment>
  3102. void main() {
  3103. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3104. #include <clipping_planes_fragment>
  3105. #include <logdepthbuf_fragment>
  3106. #include <normal_fragment_begin>
  3107. #include <normal_fragment_maps>
  3108. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3109. #ifdef OPAQUE
  3110. gl_FragColor.a = 1.0;
  3111. #endif
  3112. }`,IPe=`#define PHONG
  3113. varying vec3 vViewPosition;
  3114. #include <common>
  3115. #include <batching_pars_vertex>
  3116. #include <uv_pars_vertex>
  3117. #include <displacementmap_pars_vertex>
  3118. #include <envmap_pars_vertex>
  3119. #include <color_pars_vertex>
  3120. #include <fog_pars_vertex>
  3121. #include <normal_pars_vertex>
  3122. #include <morphtarget_pars_vertex>
  3123. #include <skinning_pars_vertex>
  3124. #include <shadowmap_pars_vertex>
  3125. #include <logdepthbuf_pars_vertex>
  3126. #include <clipping_planes_pars_vertex>
  3127. void main() {
  3128. #include <uv_vertex>
  3129. #include <color_vertex>
  3130. #include <morphcolor_vertex>
  3131. #include <batching_vertex>
  3132. #include <beginnormal_vertex>
  3133. #include <morphinstance_vertex>
  3134. #include <morphnormal_vertex>
  3135. #include <skinbase_vertex>
  3136. #include <skinnormal_vertex>
  3137. #include <defaultnormal_vertex>
  3138. #include <normal_vertex>
  3139. #include <begin_vertex>
  3140. #include <morphtarget_vertex>
  3141. #include <skinning_vertex>
  3142. #include <displacementmap_vertex>
  3143. #include <project_vertex>
  3144. #include <logdepthbuf_vertex>
  3145. #include <clipping_planes_vertex>
  3146. vViewPosition = - mvPosition.xyz;
  3147. #include <worldpos_vertex>
  3148. #include <envmap_vertex>
  3149. #include <shadowmap_vertex>
  3150. #include <fog_vertex>
  3151. }`,FPe=`#define PHONG
  3152. uniform vec3 diffuse;
  3153. uniform vec3 emissive;
  3154. uniform vec3 specular;
  3155. uniform float shininess;
  3156. uniform float opacity;
  3157. #include <common>
  3158. #include <packing>
  3159. #include <dithering_pars_fragment>
  3160. #include <color_pars_fragment>
  3161. #include <uv_pars_fragment>
  3162. #include <map_pars_fragment>
  3163. #include <alphamap_pars_fragment>
  3164. #include <alphatest_pars_fragment>
  3165. #include <alphahash_pars_fragment>
  3166. #include <aomap_pars_fragment>
  3167. #include <lightmap_pars_fragment>
  3168. #include <emissivemap_pars_fragment>
  3169. #include <envmap_common_pars_fragment>
  3170. #include <envmap_pars_fragment>
  3171. #include <fog_pars_fragment>
  3172. #include <bsdfs>
  3173. #include <lights_pars_begin>
  3174. #include <normal_pars_fragment>
  3175. #include <lights_phong_pars_fragment>
  3176. #include <shadowmap_pars_fragment>
  3177. #include <bumpmap_pars_fragment>
  3178. #include <normalmap_pars_fragment>
  3179. #include <specularmap_pars_fragment>
  3180. #include <logdepthbuf_pars_fragment>
  3181. #include <clipping_planes_pars_fragment>
  3182. void main() {
  3183. vec4 diffuseColor = vec4( diffuse, opacity );
  3184. #include <clipping_planes_fragment>
  3185. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3186. vec3 totalEmissiveRadiance = emissive;
  3187. #include <logdepthbuf_fragment>
  3188. #include <map_fragment>
  3189. #include <color_fragment>
  3190. #include <alphamap_fragment>
  3191. #include <alphatest_fragment>
  3192. #include <alphahash_fragment>
  3193. #include <specularmap_fragment>
  3194. #include <normal_fragment_begin>
  3195. #include <normal_fragment_maps>
  3196. #include <emissivemap_fragment>
  3197. #include <lights_phong_fragment>
  3198. #include <lights_fragment_begin>
  3199. #include <lights_fragment_maps>
  3200. #include <lights_fragment_end>
  3201. #include <aomap_fragment>
  3202. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3203. #include <envmap_fragment>
  3204. #include <opaque_fragment>
  3205. #include <tonemapping_fragment>
  3206. #include <colorspace_fragment>
  3207. #include <fog_fragment>
  3208. #include <premultiplied_alpha_fragment>
  3209. #include <dithering_fragment>
  3210. }`,UPe=`#define STANDARD
  3211. varying vec3 vViewPosition;
  3212. #ifdef USE_TRANSMISSION
  3213. varying vec3 vWorldPosition;
  3214. #endif
  3215. #include <common>
  3216. #include <batching_pars_vertex>
  3217. #include <uv_pars_vertex>
  3218. #include <displacementmap_pars_vertex>
  3219. #include <color_pars_vertex>
  3220. #include <fog_pars_vertex>
  3221. #include <normal_pars_vertex>
  3222. #include <morphtarget_pars_vertex>
  3223. #include <skinning_pars_vertex>
  3224. #include <shadowmap_pars_vertex>
  3225. #include <logdepthbuf_pars_vertex>
  3226. #include <clipping_planes_pars_vertex>
  3227. void main() {
  3228. #include <uv_vertex>
  3229. #include <color_vertex>
  3230. #include <morphinstance_vertex>
  3231. #include <morphcolor_vertex>
  3232. #include <batching_vertex>
  3233. #include <beginnormal_vertex>
  3234. #include <morphnormal_vertex>
  3235. #include <skinbase_vertex>
  3236. #include <skinnormal_vertex>
  3237. #include <defaultnormal_vertex>
  3238. #include <normal_vertex>
  3239. #include <begin_vertex>
  3240. #include <morphtarget_vertex>
  3241. #include <skinning_vertex>
  3242. #include <displacementmap_vertex>
  3243. #include <project_vertex>
  3244. #include <logdepthbuf_vertex>
  3245. #include <clipping_planes_vertex>
  3246. vViewPosition = - mvPosition.xyz;
  3247. #include <worldpos_vertex>
  3248. #include <shadowmap_vertex>
  3249. #include <fog_vertex>
  3250. #ifdef USE_TRANSMISSION
  3251. vWorldPosition = worldPosition.xyz;
  3252. #endif
  3253. }`,zPe=`#define STANDARD
  3254. #ifdef PHYSICAL
  3255. #define IOR
  3256. #define USE_SPECULAR
  3257. #endif
  3258. uniform vec3 diffuse;
  3259. uniform vec3 emissive;
  3260. uniform float roughness;
  3261. uniform float metalness;
  3262. uniform float opacity;
  3263. #ifdef IOR
  3264. uniform float ior;
  3265. #endif
  3266. #ifdef USE_SPECULAR
  3267. uniform float specularIntensity;
  3268. uniform vec3 specularColor;
  3269. #ifdef USE_SPECULAR_COLORMAP
  3270. uniform sampler2D specularColorMap;
  3271. #endif
  3272. #ifdef USE_SPECULAR_INTENSITYMAP
  3273. uniform sampler2D specularIntensityMap;
  3274. #endif
  3275. #endif
  3276. #ifdef USE_CLEARCOAT
  3277. uniform float clearcoat;
  3278. uniform float clearcoatRoughness;
  3279. #endif
  3280. #ifdef USE_DISPERSION
  3281. uniform float dispersion;
  3282. #endif
  3283. #ifdef USE_IRIDESCENCE
  3284. uniform float iridescence;
  3285. uniform float iridescenceIOR;
  3286. uniform float iridescenceThicknessMinimum;
  3287. uniform float iridescenceThicknessMaximum;
  3288. #endif
  3289. #ifdef USE_SHEEN
  3290. uniform vec3 sheenColor;
  3291. uniform float sheenRoughness;
  3292. #ifdef USE_SHEEN_COLORMAP
  3293. uniform sampler2D sheenColorMap;
  3294. #endif
  3295. #ifdef USE_SHEEN_ROUGHNESSMAP
  3296. uniform sampler2D sheenRoughnessMap;
  3297. #endif
  3298. #endif
  3299. #ifdef USE_ANISOTROPY
  3300. uniform vec2 anisotropyVector;
  3301. #ifdef USE_ANISOTROPYMAP
  3302. uniform sampler2D anisotropyMap;
  3303. #endif
  3304. #endif
  3305. varying vec3 vViewPosition;
  3306. #include <common>
  3307. #include <packing>
  3308. #include <dithering_pars_fragment>
  3309. #include <color_pars_fragment>
  3310. #include <uv_pars_fragment>
  3311. #include <map_pars_fragment>
  3312. #include <alphamap_pars_fragment>
  3313. #include <alphatest_pars_fragment>
  3314. #include <alphahash_pars_fragment>
  3315. #include <aomap_pars_fragment>
  3316. #include <lightmap_pars_fragment>
  3317. #include <emissivemap_pars_fragment>
  3318. #include <iridescence_fragment>
  3319. #include <cube_uv_reflection_fragment>
  3320. #include <envmap_common_pars_fragment>
  3321. #include <envmap_physical_pars_fragment>
  3322. #include <fog_pars_fragment>
  3323. #include <lights_pars_begin>
  3324. #include <normal_pars_fragment>
  3325. #include <lights_physical_pars_fragment>
  3326. #include <transmission_pars_fragment>
  3327. #include <shadowmap_pars_fragment>
  3328. #include <bumpmap_pars_fragment>
  3329. #include <normalmap_pars_fragment>
  3330. #include <clearcoat_pars_fragment>
  3331. #include <iridescence_pars_fragment>
  3332. #include <roughnessmap_pars_fragment>
  3333. #include <metalnessmap_pars_fragment>
  3334. #include <logdepthbuf_pars_fragment>
  3335. #include <clipping_planes_pars_fragment>
  3336. void main() {
  3337. vec4 diffuseColor = vec4( diffuse, opacity );
  3338. #include <clipping_planes_fragment>
  3339. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3340. vec3 totalEmissiveRadiance = emissive;
  3341. #include <logdepthbuf_fragment>
  3342. #include <map_fragment>
  3343. #include <color_fragment>
  3344. #include <alphamap_fragment>
  3345. #include <alphatest_fragment>
  3346. #include <alphahash_fragment>
  3347. #include <roughnessmap_fragment>
  3348. #include <metalnessmap_fragment>
  3349. #include <normal_fragment_begin>
  3350. #include <normal_fragment_maps>
  3351. #include <clearcoat_normal_fragment_begin>
  3352. #include <clearcoat_normal_fragment_maps>
  3353. #include <emissivemap_fragment>
  3354. #include <lights_physical_fragment>
  3355. #include <lights_fragment_begin>
  3356. #include <lights_fragment_maps>
  3357. #include <lights_fragment_end>
  3358. #include <aomap_fragment>
  3359. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3360. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3361. #include <transmission_fragment>
  3362. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3363. #ifdef USE_SHEEN
  3364. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3365. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3366. #endif
  3367. #ifdef USE_CLEARCOAT
  3368. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3369. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3370. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3371. #endif
  3372. #include <opaque_fragment>
  3373. #include <tonemapping_fragment>
  3374. #include <colorspace_fragment>
  3375. #include <fog_fragment>
  3376. #include <premultiplied_alpha_fragment>
  3377. #include <dithering_fragment>
  3378. }`,BPe=`#define TOON
  3379. varying vec3 vViewPosition;
  3380. #include <common>
  3381. #include <batching_pars_vertex>
  3382. #include <uv_pars_vertex>
  3383. #include <displacementmap_pars_vertex>
  3384. #include <color_pars_vertex>
  3385. #include <fog_pars_vertex>
  3386. #include <normal_pars_vertex>
  3387. #include <morphtarget_pars_vertex>
  3388. #include <skinning_pars_vertex>
  3389. #include <shadowmap_pars_vertex>
  3390. #include <logdepthbuf_pars_vertex>
  3391. #include <clipping_planes_pars_vertex>
  3392. void main() {
  3393. #include <uv_vertex>
  3394. #include <color_vertex>
  3395. #include <morphinstance_vertex>
  3396. #include <morphcolor_vertex>
  3397. #include <batching_vertex>
  3398. #include <beginnormal_vertex>
  3399. #include <morphnormal_vertex>
  3400. #include <skinbase_vertex>
  3401. #include <skinnormal_vertex>
  3402. #include <defaultnormal_vertex>
  3403. #include <normal_vertex>
  3404. #include <begin_vertex>
  3405. #include <morphtarget_vertex>
  3406. #include <skinning_vertex>
  3407. #include <displacementmap_vertex>
  3408. #include <project_vertex>
  3409. #include <logdepthbuf_vertex>
  3410. #include <clipping_planes_vertex>
  3411. vViewPosition = - mvPosition.xyz;
  3412. #include <worldpos_vertex>
  3413. #include <shadowmap_vertex>
  3414. #include <fog_vertex>
  3415. }`,HPe=`#define TOON
  3416. uniform vec3 diffuse;
  3417. uniform vec3 emissive;
  3418. uniform float opacity;
  3419. #include <common>
  3420. #include <packing>
  3421. #include <dithering_pars_fragment>
  3422. #include <color_pars_fragment>
  3423. #include <uv_pars_fragment>
  3424. #include <map_pars_fragment>
  3425. #include <alphamap_pars_fragment>
  3426. #include <alphatest_pars_fragment>
  3427. #include <alphahash_pars_fragment>
  3428. #include <aomap_pars_fragment>
  3429. #include <lightmap_pars_fragment>
  3430. #include <emissivemap_pars_fragment>
  3431. #include <gradientmap_pars_fragment>
  3432. #include <fog_pars_fragment>
  3433. #include <bsdfs>
  3434. #include <lights_pars_begin>
  3435. #include <normal_pars_fragment>
  3436. #include <lights_toon_pars_fragment>
  3437. #include <shadowmap_pars_fragment>
  3438. #include <bumpmap_pars_fragment>
  3439. #include <normalmap_pars_fragment>
  3440. #include <logdepthbuf_pars_fragment>
  3441. #include <clipping_planes_pars_fragment>
  3442. void main() {
  3443. vec4 diffuseColor = vec4( diffuse, opacity );
  3444. #include <clipping_planes_fragment>
  3445. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3446. vec3 totalEmissiveRadiance = emissive;
  3447. #include <logdepthbuf_fragment>
  3448. #include <map_fragment>
  3449. #include <color_fragment>
  3450. #include <alphamap_fragment>
  3451. #include <alphatest_fragment>
  3452. #include <alphahash_fragment>
  3453. #include <normal_fragment_begin>
  3454. #include <normal_fragment_maps>
  3455. #include <emissivemap_fragment>
  3456. #include <lights_toon_fragment>
  3457. #include <lights_fragment_begin>
  3458. #include <lights_fragment_maps>
  3459. #include <lights_fragment_end>
  3460. #include <aomap_fragment>
  3461. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3462. #include <opaque_fragment>
  3463. #include <tonemapping_fragment>
  3464. #include <colorspace_fragment>
  3465. #include <fog_fragment>
  3466. #include <premultiplied_alpha_fragment>
  3467. #include <dithering_fragment>
  3468. }`,$Pe=`uniform float size;
  3469. uniform float scale;
  3470. #include <common>
  3471. #include <color_pars_vertex>
  3472. #include <fog_pars_vertex>
  3473. #include <morphtarget_pars_vertex>
  3474. #include <logdepthbuf_pars_vertex>
  3475. #include <clipping_planes_pars_vertex>
  3476. #ifdef USE_POINTS_UV
  3477. varying vec2 vUv;
  3478. uniform mat3 uvTransform;
  3479. #endif
  3480. void main() {
  3481. #ifdef USE_POINTS_UV
  3482. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3483. #endif
  3484. #include <color_vertex>
  3485. #include <morphinstance_vertex>
  3486. #include <morphcolor_vertex>
  3487. #include <begin_vertex>
  3488. #include <morphtarget_vertex>
  3489. #include <project_vertex>
  3490. gl_PointSize = size;
  3491. #ifdef USE_SIZEATTENUATION
  3492. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3493. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3494. #endif
  3495. #include <logdepthbuf_vertex>
  3496. #include <clipping_planes_vertex>
  3497. #include <worldpos_vertex>
  3498. #include <fog_vertex>
  3499. }`,VPe=`uniform vec3 diffuse;
  3500. uniform float opacity;
  3501. #include <common>
  3502. #include <color_pars_fragment>
  3503. #include <map_particle_pars_fragment>
  3504. #include <alphatest_pars_fragment>
  3505. #include <alphahash_pars_fragment>
  3506. #include <fog_pars_fragment>
  3507. #include <logdepthbuf_pars_fragment>
  3508. #include <clipping_planes_pars_fragment>
  3509. void main() {
  3510. vec4 diffuseColor = vec4( diffuse, opacity );
  3511. #include <clipping_planes_fragment>
  3512. vec3 outgoingLight = vec3( 0.0 );
  3513. #include <logdepthbuf_fragment>
  3514. #include <map_particle_fragment>
  3515. #include <color_fragment>
  3516. #include <alphatest_fragment>
  3517. #include <alphahash_fragment>
  3518. outgoingLight = diffuseColor.rgb;
  3519. #include <opaque_fragment>
  3520. #include <tonemapping_fragment>
  3521. #include <colorspace_fragment>
  3522. #include <fog_fragment>
  3523. #include <premultiplied_alpha_fragment>
  3524. }`,GPe=`#include <common>
  3525. #include <batching_pars_vertex>
  3526. #include <fog_pars_vertex>
  3527. #include <morphtarget_pars_vertex>
  3528. #include <skinning_pars_vertex>
  3529. #include <logdepthbuf_pars_vertex>
  3530. #include <shadowmap_pars_vertex>
  3531. void main() {
  3532. #include <batching_vertex>
  3533. #include <beginnormal_vertex>
  3534. #include <morphinstance_vertex>
  3535. #include <morphnormal_vertex>
  3536. #include <skinbase_vertex>
  3537. #include <skinnormal_vertex>
  3538. #include <defaultnormal_vertex>
  3539. #include <begin_vertex>
  3540. #include <morphtarget_vertex>
  3541. #include <skinning_vertex>
  3542. #include <project_vertex>
  3543. #include <logdepthbuf_vertex>
  3544. #include <worldpos_vertex>
  3545. #include <shadowmap_vertex>
  3546. #include <fog_vertex>
  3547. }`,WPe=`uniform vec3 color;
  3548. uniform float opacity;
  3549. #include <common>
  3550. #include <packing>
  3551. #include <fog_pars_fragment>
  3552. #include <bsdfs>
  3553. #include <lights_pars_begin>
  3554. #include <logdepthbuf_pars_fragment>
  3555. #include <shadowmap_pars_fragment>
  3556. #include <shadowmask_pars_fragment>
  3557. void main() {
  3558. #include <logdepthbuf_fragment>
  3559. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3560. #include <tonemapping_fragment>
  3561. #include <colorspace_fragment>
  3562. #include <fog_fragment>
  3563. }`,qPe=`uniform float rotation;
  3564. uniform vec2 center;
  3565. #include <common>
  3566. #include <uv_pars_vertex>
  3567. #include <fog_pars_vertex>
  3568. #include <logdepthbuf_pars_vertex>
  3569. #include <clipping_planes_pars_vertex>
  3570. void main() {
  3571. #include <uv_vertex>
  3572. vec4 mvPosition = modelViewMatrix[ 3 ];
  3573. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3574. #ifndef USE_SIZEATTENUATION
  3575. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3576. if ( isPerspective ) scale *= - mvPosition.z;
  3577. #endif
  3578. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3579. vec2 rotatedPosition;
  3580. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3581. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3582. mvPosition.xy += rotatedPosition;
  3583. gl_Position = projectionMatrix * mvPosition;
  3584. #include <logdepthbuf_vertex>
  3585. #include <clipping_planes_vertex>
  3586. #include <fog_vertex>
  3587. }`,KPe=`uniform vec3 diffuse;
  3588. uniform float opacity;
  3589. #include <common>
  3590. #include <uv_pars_fragment>
  3591. #include <map_pars_fragment>
  3592. #include <alphamap_pars_fragment>
  3593. #include <alphatest_pars_fragment>
  3594. #include <alphahash_pars_fragment>
  3595. #include <fog_pars_fragment>
  3596. #include <logdepthbuf_pars_fragment>
  3597. #include <clipping_planes_pars_fragment>
  3598. void main() {
  3599. vec4 diffuseColor = vec4( diffuse, opacity );
  3600. #include <clipping_planes_fragment>
  3601. vec3 outgoingLight = vec3( 0.0 );
  3602. #include <logdepthbuf_fragment>
  3603. #include <map_fragment>
  3604. #include <alphamap_fragment>
  3605. #include <alphatest_fragment>
  3606. #include <alphahash_fragment>
  3607. outgoingLight = diffuseColor.rgb;
  3608. #include <opaque_fragment>
  3609. #include <tonemapping_fragment>
  3610. #include <colorspace_fragment>
  3611. #include <fog_fragment>
  3612. }`,on={alphahash_fragment:gke,alphahash_pars_fragment:xke,alphamap_fragment:bke,alphamap_pars_fragment:yke,alphatest_fragment:vke,alphatest_pars_fragment:_ke,aomap_fragment:wke,aomap_pars_fragment:Ske,batching_pars_vertex:Mke,batching_vertex:Eke,begin_vertex:Ake,beginnormal_vertex:Tke,bsdfs:Cke,iridescence_fragment:Nke,bumpmap_pars_fragment:kke,clipping_planes_fragment:Pke,clipping_planes_pars_fragment:Rke,clipping_planes_pars_vertex:jke,clipping_planes_vertex:Dke,color_fragment:Oke,color_pars_fragment:Lke,color_pars_vertex:Ike,color_vertex:Fke,common:Uke,cube_uv_reflection_fragment:zke,defaultnormal_vertex:Bke,displacementmap_pars_vertex:Hke,displacementmap_vertex:$ke,emissivemap_fragment:Vke,emissivemap_pars_fragment:Gke,colorspace_fragment:Wke,colorspace_pars_fragment:qke,envmap_fragment:Kke,envmap_common_pars_fragment:Xke,envmap_pars_fragment:Yke,envmap_pars_vertex:Zke,envmap_physical_pars_fragment:l3e,envmap_vertex:Qke,fog_vertex:Jke,fog_pars_vertex:e3e,fog_fragment:t3e,fog_pars_fragment:n3e,gradientmap_pars_fragment:r3e,lightmap_pars_fragment:i3e,lights_lambert_fragment:a3e,lights_lambert_pars_fragment:s3e,lights_pars_begin:o3e,lights_toon_fragment:c3e,lights_toon_pars_fragment:u3e,lights_phong_fragment:d3e,lights_phong_pars_fragment:h3e,lights_physical_fragment:f3e,lights_physical_pars_fragment:m3e,lights_fragment_begin:p3e,lights_fragment_maps:g3e,lights_fragment_end:x3e,logdepthbuf_fragment:b3e,logdepthbuf_pars_fragment:y3e,logdepthbuf_pars_vertex:v3e,logdepthbuf_vertex:_3e,map_fragment:w3e,map_pars_fragment:S3e,map_particle_fragment:M3e,map_particle_pars_fragment:E3e,metalnessmap_fragment:A3e,metalnessmap_pars_fragment:T3e,morphinstance_vertex:C3e,morphcolor_vertex:N3e,morphnormal_vertex:k3e,morphtarget_pars_vertex:P3e,morphtarget_vertex:R3e,normal_fragment_begin:j3e,normal_fragment_maps:D3e,normal_pars_fragment:O3e,normal_pars_vertex:L3e,normal_vertex:I3e,normalmap_pars_fragment:F3e,clearcoat_normal_fragment_begin:U3e,clearcoat_normal_fragment_maps:z3e,clearcoat_pars_fragment:B3e,iridescence_pars_fragment:H3e,opaque_fragment:$3e,packing:V3e,premultiplied_alpha_fragment:G3e,project_vertex:W3e,dithering_fragment:q3e,dithering_pars_fragment:K3e,roughnessmap_fragment:X3e,roughnessmap_pars_fragment:Y3e,shadowmap_pars_fragment:Z3e,shadowmap_pars_vertex:Q3e,shadowmap_vertex:J3e,shadowmask_pars_fragment:ePe,skinbase_vertex:tPe,skinning_pars_vertex:nPe,skinning_vertex:rPe,skinnormal_vertex:iPe,specularmap_fragment:aPe,specularmap_pars_fragment:sPe,tonemapping_fragment:oPe,tonemapping_pars_fragment:lPe,transmission_fragment:cPe,transmission_pars_fragment:uPe,uv_pars_fragment:dPe,uv_pars_vertex:hPe,uv_vertex:fPe,worldpos_vertex:mPe,background_vert:pPe,background_frag:gPe,backgroundCube_vert:xPe,backgroundCube_frag:bPe,cube_vert:yPe,cube_frag:vPe,depth_vert:_Pe,depth_frag:wPe,distanceRGBA_vert:SPe,distanceRGBA_frag:MPe,equirect_vert:EPe,equirect_frag:APe,linedashed_vert:TPe,linedashed_frag:CPe,meshbasic_vert:NPe,meshbasic_frag:kPe,meshlambert_vert:PPe,meshlambert_frag:RPe,meshmatcap_vert:jPe,meshmatcap_frag:DPe,meshnormal_vert:OPe,meshnormal_frag:LPe,meshphong_vert:IPe,meshphong_frag:FPe,meshphysical_vert:UPe,meshphysical_frag:zPe,meshtoon_vert:BPe,meshtoon_frag:HPe,points_vert:$Pe,points_frag:VPe,shadow_vert:GPe,shadow_frag:WPe,sprite_vert:qPe,sprite_frag:KPe},Tt={common:{diffuse:{value:new _n(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new dn}},envmap:{envMap:{value:null},envMapRotation:{value:new dn},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 dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new dn},normalScale:{value:new cn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new dn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new dn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new dn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new dn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _n(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 _n(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0},uvTransform:{value:new dn}},sprite:{diffuse:{value:new _n(16777215)},opacity:{value:1},center:{value:new cn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}}},nl={basic:{uniforms:_a([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.fog]),vertexShader:on.meshbasic_vert,fragmentShader:on.meshbasic_frag},lambert:{uniforms:_a([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new _n(0)}}]),vertexShader:on.meshlambert_vert,fragmentShader:on.meshlambert_frag},phong:{uniforms:_a([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new _n(0)},specular:{value:new _n(1118481)},shininess:{value:30}}]),vertexShader:on.meshphong_vert,fragmentShader:on.meshphong_frag},standard:{uniforms:_a([Tt.common,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.roughnessmap,Tt.metalnessmap,Tt.fog,Tt.lights,{emissive:{value:new _n(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag},toon:{uniforms:_a([Tt.common,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.gradientmap,Tt.fog,Tt.lights,{emissive:{value:new _n(0)}}]),vertexShader:on.meshtoon_vert,fragmentShader:on.meshtoon_frag},matcap:{uniforms:_a([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,{matcap:{value:null}}]),vertexShader:on.meshmatcap_vert,fragmentShader:on.meshmatcap_frag},points:{uniforms:_a([Tt.points,Tt.fog]),vertexShader:on.points_vert,fragmentShader:on.points_frag},dashed:{uniforms:_a([Tt.common,Tt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:on.linedashed_vert,fragmentShader:on.linedashed_frag},depth:{uniforms:_a([Tt.common,Tt.displacementmap]),vertexShader:on.depth_vert,fragmentShader:on.depth_frag},normal:{uniforms:_a([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,{opacity:{value:1}}]),vertexShader:on.meshnormal_vert,fragmentShader:on.meshnormal_frag},sprite:{uniforms:_a([Tt.sprite,Tt.fog]),vertexShader:on.sprite_vert,fragmentShader:on.sprite_frag},background:{uniforms:{uvTransform:{value:new dn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:on.background_vert,fragmentShader:on.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new dn}},vertexShader:on.backgroundCube_vert,fragmentShader:on.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:on.cube_vert,fragmentShader:on.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:on.equirect_vert,fragmentShader:on.equirect_frag},distanceRGBA:{uniforms:_a([Tt.common,Tt.displacementmap,{referencePosition:{value:new et},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:on.distanceRGBA_vert,fragmentShader:on.distanceRGBA_frag},shadow:{uniforms:_a([Tt.lights,Tt.fog,{color:{value:new _n(0)},opacity:{value:1}}]),vertexShader:on.shadow_vert,fragmentShader:on.shadow_frag}};nl.physical={uniforms:_a([nl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new dn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new dn},clearcoatNormalScale:{value:new cn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new dn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new dn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new dn},sheen:{value:0},sheenColor:{value:new _n(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new dn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new dn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new dn},transmissionSamplerSize:{value:new cn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new dn},attenuationDistance:{value:0},attenuationColor:{value:new _n(0)},specularColor:{value:new _n(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new dn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new dn},anisotropyVector:{value:new cn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new dn}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag};const r_={r:0,b:0,g:0},Jd=new yd,XPe=new ii;function YPe(t,e,n,r,i,a,s){const o=new _n(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:e).get(A)),A}function v(w){let A=!1;const T=x(w);T===null?b(o,c):T&&T.isColor&&(b(T,1),A=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,s):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function y(w,A){const T=x(A);T&&(T.isCubeTexture||T.mapping===HM)?(d===void 0&&(d=new bl(new bO(1,1,1),new zc({name:"BackgroundCubeMaterial",uniforms:Dp(nl.backgroundCube.uniforms),vertexShader:nl.backgroundCube.vertexShader,fragmentShader:nl.backgroundCube.fragmentShader,side:Za,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,k,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Jd.copy(A.backgroundRotation),Jd.x*=-1,Jd.y*=-1,Jd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Jd.y*=-1,Jd.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(XPe.makeRotationFromEuler(Jd)),d.material.toneMapped=Nn.getTransfer(T.colorSpace)!==Kn,(f!==T||g!==T.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,g=T.version,p=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new bl(new vO(2,2),new zc({name:"BackgroundMaterial",uniforms:Dp(nl.background.uniforms),vertexShader:nl.background.vertexShader,fragmentShader:nl.background.fragmentShader,side:bd,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=T,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Nn.getTransfer(T.colorSpace)!==Kn,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||g!==T.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,g=T.version,p=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null))}function b(w,A){w.getRGB(r_,pZ(t)),r.buffers.color.setClear(r_.r,r_.g,r_.b,A,s)}function E(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,A=1){o.set(w),c=A,b(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,b(o,c)},render:v,addToRenderList:y,dispose:E}}function ZPe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function o(j,I,O,q,R){let W=!1;const K=f(q,O,I);a!==K&&(a=K,u(a.object)),W=p(j,q,O,R),W&&x(j,q,O,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(W||s)&&(s=!1,A(j,I,O,q),R!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(R).buffer))}function c(){return t.createVertexArray()}function u(j){return t.bindVertexArray(j)}function d(j){return t.deleteVertexArray(j)}function f(j,I,O){const q=O.wireframe===!0;let R=r[j.id];R===void 0&&(R={},r[j.id]=R);let W=R[I.id];W===void 0&&(W={},R[I.id]=W);let K=W[q];return K===void 0&&(K=g(c()),W[q]=K),K}function g(j){const I=[],O=[],q=[];for(let R=0;R<n;R++)I[R]=0,O[R]=0,q[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:O,attributeDivisors:q,object:j,attributes:{},index:null}}function p(j,I,O,q){const R=a.attributes,W=I.attributes;let K=0;const G=O.getAttributes();for(const te in G)if(G[te].location>=0){const J=R[te];let U=W[te];if(U===void 0&&(te==="instanceMatrix"&&j.instanceMatrix&&(U=j.instanceMatrix),te==="instanceColor"&&j.instanceColor&&(U=j.instanceColor)),J===void 0||J.attribute!==U||U&&J.data!==U.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function x(j,I,O,q){const R={},W=I.attributes;let K=0;const G=O.getAttributes();for(const te in G)if(G[te].location>=0){let J=W[te];J===void 0&&(te==="instanceMatrix"&&j.instanceMatrix&&(J=j.instanceMatrix),te==="instanceColor"&&j.instanceColor&&(J=j.instanceColor));const U={};U.attribute=J,J&&J.data&&(U.data=J.data),R[te]=U,K++}a.attributes=R,a.attributesNum=K,a.index=q}function v(){const j=a.newAttributes;for(let I=0,O=j.length;I<O;I++)j[I]=0}function y(j){b(j,0)}function b(j,I){const O=a.newAttributes,q=a.enabledAttributes,R=a.attributeDivisors;O[j]=1,q[j]===0&&(t.enableVertexAttribArray(j),q[j]=1),R[j]!==I&&(t.vertexAttribDivisor(j,I),R[j]=I)}function E(){const j=a.newAttributes,I=a.enabledAttributes;for(let O=0,q=I.length;O<q;O++)I[O]!==j[O]&&(t.disableVertexAttribArray(O),I[O]=0)}function w(j,I,O,q,R,W,K){K===!0?t.vertexAttribIPointer(j,I,O,R,W):t.vertexAttribPointer(j,I,O,q,R,W)}function A(j,I,O,q){v();const R=q.attributes,W=O.getAttributes(),K=I.defaultAttributeValues;for(const G in W){const te=W[G];if(te.location>=0){let Y=R[G];if(Y===void 0&&(G==="instanceMatrix"&&j.instanceMatrix&&(Y=j.instanceMatrix),G==="instanceColor"&&j.instanceColor&&(Y=j.instanceColor)),Y!==void 0){const J=Y.normalized,U=Y.itemSize,H=e.get(Y);if(H===void 0)continue;const ee=H.buffer,ie=H.type,pe=H.bytesPerElement,ue=ie===t.INT||ie===t.UNSIGNED_INT||Y.gpuType===lO;if(Y.isInterleavedBufferAttribute){const be=Y.data,Re=be.stride,Z=Y.offset;if(be.isInstancedInterleavedBuffer){for(let _e=0;_e<te.locationSize;_e++)b(te.location+_e,be.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=be.meshPerAttribute*be.count)}else for(let _e=0;_e<te.locationSize;_e++)y(te.location+_e);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let _e=0;_e<te.locationSize;_e++)w(te.location+_e,U/te.locationSize,ie,J,Re*pe,(Z+U/te.locationSize*_e)*pe,ue)}else{if(Y.isInstancedBufferAttribute){for(let be=0;be<te.locationSize;be++)b(te.location+be,Y.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let be=0;be<te.locationSize;be++)y(te.location+be);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let be=0;be<te.locationSize;be++)w(te.location+be,U/te.locationSize,ie,J,U*pe,U/te.locationSize*be*pe,ue)}}else if(K!==void 0){const J=K[G];if(J!==void 0)switch(J.length){case 2:t.vertexAttrib2fv(te.location,J);break;case 3:t.vertexAttrib3fv(te.location,J);break;case 4:t.vertexAttrib4fv(te.location,J);break;default:t.vertexAttrib1fv(te.location,J)}}}}E()}function T(){F();for(const j in r){const I=r[j];for(const O in I){const q=I[O];for(const R in q)d(q[R].object),delete q[R];delete I[O]}delete r[j]}}function C(j){if(r[j.id]===void 0)return;const I=r[j.id];for(const O in I){const q=I[O];for(const R in q)d(q[R].object),delete q[R];delete I[O]}delete r[j.id]}function k(j){for(const I in r){const O=r[I];if(O[j.id]===void 0)continue;const q=O[j.id];for(const R in q)d(q[R].object),delete q[R];delete O[j.id]}}function F(){N(),s=!0,a!==i&&(a=i,u(a.object))}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:F,resetDefaultState:N,dispose:T,releaseStatesOfGeometry:C,releaseStatesOfProgram:k,initAttributes:v,enableAttribute:y,disableUnusedAttributes:E}}function QPe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function s(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function o(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,g){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)s(u[x],d[x],g[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let v=0;v<f;v++)x+=d[v]*g[v];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function JPe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const k=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(k.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(k){return!(k!==jo&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(k){const F=k===ug&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(k!==xl&&r.convert(k)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&k!==bc&&!F)}function c(k){if(k==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";k="mediump"}return k==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(Yt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:o,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:y,maxAttributes:b,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:T,maxSamples:C}}function eRe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Lu,o=new dn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const E=a?0:r,w=E*4;let A=b.clippingState||null;c.value=A,A=d(x,g,w,p);for(let T=0;T!==w;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=p+v*4,E=g.matrixWorldInverse;o.getNormalMatrix(E),(y===null||y.length<b)&&(y=new Float32Array(b));for(let w=0,A=p;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(E,o),s.normal.toArray(y,A),y[A+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function tRe(t){let e=new WeakMap;function n(s,o){return o===Q3?s.mapping=Pp:o===J3&&(s.mapping=Rp),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===Q3||o===J3)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new YNe(c.height);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const qu=4,_H=[.125,.215,.35,.446,.526,.582],mh=20,nRe=256,Ax=new SZ,wH=new _n;let GC=null,WC=0,qC=0,KC=!1;const rRe=new et;let SH=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:s=256,position:o=rRe}=a;GC=this._renderer.getRenderTarget(),WC=this._renderer.getActiveCubeFace(),qC=this._renderer.getActiveMipmapLevel(),KC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,o),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=AH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=EH(),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(GC,WC,qC),this._renderer.xr.enabled=KC,e.scissorTest=!1,gm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Pp||e.mapping===Rp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),GC=this._renderer.getRenderTarget(),WC=this._renderer.getActiveCubeFace(),qC=this._renderer.getActiveMipmapLevel(),KC=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:io,minFilter:io,generateMipmaps:!1,type:ug,format:jo,colorSpace:jp,depthBuffer:!1},i=MH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=MH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=iRe(a)),this._blurMaterial=sRe(a,e,n),this._ggxMaterial=aRe(a,e,n)}return i}_compileMaterial(e){const n=new bl(new Al,e);this._renderer.compile(n,Ax)}_sceneToCubeUV(e,n,r,i,a){const c=new Zs(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,g=f.autoClear,p=f.toneMapping;f.getClearColor(wH),f.toneMapping=td,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new bl(new bO,new xO({name:"PMREM.Background",side:Za,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,y=v.material;let b=!1;const E=e.background;E?E.isColor&&(y.color.copy(E),e.background=null,b=!0):(y.color.copy(wH),b=!0);for(let w=0;w<6;w++){const A=w%3;A===0?(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[w],a.y,a.z)):A===1?(c.up.set(0,0,u[w]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[w],a.z)):(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[w]));const T=this._cubeSize;gm(i,A*T,w>2?T:0,T,T),f.setRenderTarget(i),b&&f.render(v,c),f.render(e,c)}f.toneMapping=p,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Pp||e.mapping===Rp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=AH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=EH());const a=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const o=a.uniforms;o.envMap.value=e;const c=this._cubeSize;gm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,Ax)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[r];o.material=s;const c=s.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,p=f*g,{_lodMax:x}=this,v=this._sizeLods[r],y=3*v*(r>x-qu?r-x+qu:0),b=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,gm(a,y,b,3*v,2*v),i.setRenderTarget(a),i.render(o,Ax),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,gm(e,y,b,3*v,2*v),i.setRenderTarget(e),i.render(o,Ax)}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&Hr("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*mh-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):mh;y>mh&&Yt(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${mh}`);const b=[];let E=0;for(let k=0;k<mh;++k){const F=k/v,N=Math.exp(-F*F/2);b.push(N),k===0?E+=N:k<y&&(E+=2*N)}for(let k=0;k<b.length;k++)b[k]=b[k]/E;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-qu?i-w+qu:0),C=4*(this._cubeSize-A);gm(n,T,C,3*A,2*A),c.setRenderTarget(n),c.render(f,Ax)}};function iRe(t){const e=[],n=[],r=[];let i=t;const a=t-qu+1+_H.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);e.push(o);let c=1/o;s>t-qu?c=_H[s-t+qu-1]:s===0&&(c=0),n.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,y=2,b=1,E=new Float32Array(v*x*p),w=new Float32Array(y*x*p),A=new Float32Array(b*x*p);for(let C=0;C<p;C++){const k=C%3*2/3-1,F=C>2?0:-1,N=[k,F,0,k+2/3,F,0,k+2/3,F+1,0,k,F,0,k+2/3,F+1,0,k,F+1,0];E.set(N,v*x*C),w.set(g,y*x*C);const j=[C,C,C,C,C,C];A.set(j,b*x*C)}const T=new Al;T.setAttribute("position",new ao(E,v)),T.setAttribute("uv",new ao(w,y)),T.setAttribute("faceIndex",new ao(A,b)),r.push(new bl(T,null)),i>qu&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function MH(t,e,n){const r=new af(t,e,n);return r.texture.mapping=HM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function gm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function aRe(t,e,n){return new zc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:nRe,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:VM(),fragmentShader:`
  3613. precision highp float;
  3614. precision highp int;
  3615. varying vec3 vOutputDirection;
  3616. uniform sampler2D envMap;
  3617. uniform float roughness;
  3618. uniform float mipInt;
  3619. #define ENVMAP_TYPE_CUBE_UV
  3620. #include <cube_uv_reflection_fragment>
  3621. #define PI 3.14159265359
  3622. // Van der Corput radical inverse
  3623. float radicalInverse_VdC(uint bits) {
  3624. bits = (bits << 16u) | (bits >> 16u);
  3625. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3626. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3627. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3628. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3629. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3630. }
  3631. // Hammersley sequence
  3632. vec2 hammersley(uint i, uint N) {
  3633. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3634. }
  3635. // GGX VNDF importance sampling (Eric Heitz 2018)
  3636. // "Sampling the GGX Distribution of Visible Normals"
  3637. // https://jcgt.org/published/0007/04/01/
  3638. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3639. float alpha = roughness * roughness;
  3640. // Section 3.2: Transform view direction to hemisphere configuration
  3641. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3642. // Section 4.1: Orthonormal basis
  3643. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3644. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3645. vec3 T2 = cross(Vh, T1);
  3646. // Section 4.2: Parameterization of projected area
  3647. float r = sqrt(Xi.x);
  3648. float phi = 2.0 * PI * Xi.y;
  3649. float t1 = r * cos(phi);
  3650. float t2 = r * sin(phi);
  3651. float s = 0.5 * (1.0 + Vh.z);
  3652. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3653. // Section 4.3: Reprojection onto hemisphere
  3654. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3655. // Section 3.4: Transform back to ellipsoid configuration
  3656. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3657. }
  3658. void main() {
  3659. vec3 N = normalize(vOutputDirection);
  3660. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3661. vec3 prefilteredColor = vec3(0.0);
  3662. float totalWeight = 0.0;
  3663. // For very low roughness, just sample the environment directly
  3664. if (roughness < 0.001) {
  3665. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3666. return;
  3667. }
  3668. // Tangent space basis for VNDF sampling
  3669. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3670. vec3 tangent = normalize(cross(up, N));
  3671. vec3 bitangent = cross(N, tangent);
  3672. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3673. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3674. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3675. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3676. // Transform H back to world space
  3677. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3678. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3679. float NdotL = max(dot(N, L), 0.0);
  3680. if(NdotL > 0.0) {
  3681. // Sample environment at fixed mip level
  3682. // VNDF importance sampling handles the distribution filtering
  3683. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3684. // Weight by NdotL for the split-sum approximation
  3685. // VNDF PDF naturally accounts for the visible microfacet distribution
  3686. prefilteredColor += sampleColor * NdotL;
  3687. totalWeight += NdotL;
  3688. }
  3689. }
  3690. if (totalWeight > 0.0) {
  3691. prefilteredColor = prefilteredColor / totalWeight;
  3692. }
  3693. gl_FragColor = vec4(prefilteredColor, 1.0);
  3694. }
  3695. `,blending:Ec,depthTest:!1,depthWrite:!1})}function sRe(t,e,n){const r=new Float32Array(mh),i=new et(0,1,0);return new zc({name:"SphericalGaussianBlur",defines:{n:mh,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:VM(),fragmentShader:`
  3696. precision mediump float;
  3697. precision mediump int;
  3698. varying vec3 vOutputDirection;
  3699. uniform sampler2D envMap;
  3700. uniform int samples;
  3701. uniform float weights[ n ];
  3702. uniform bool latitudinal;
  3703. uniform float dTheta;
  3704. uniform float mipInt;
  3705. uniform vec3 poleAxis;
  3706. #define ENVMAP_TYPE_CUBE_UV
  3707. #include <cube_uv_reflection_fragment>
  3708. vec3 getSample( float theta, vec3 axis ) {
  3709. float cosTheta = cos( theta );
  3710. // Rodrigues' axis-angle rotation
  3711. vec3 sampleDirection = vOutputDirection * cosTheta
  3712. + cross( axis, vOutputDirection ) * sin( theta )
  3713. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3714. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3715. }
  3716. void main() {
  3717. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3718. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3719. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3720. }
  3721. axis = normalize( axis );
  3722. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3723. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3724. for ( int i = 1; i < n; i++ ) {
  3725. if ( i >= samples ) {
  3726. break;
  3727. }
  3728. float theta = dTheta * float( i );
  3729. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3730. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3731. }
  3732. }
  3733. `,blending:Ec,depthTest:!1,depthWrite:!1})}function EH(){return new zc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:VM(),fragmentShader:`
  3734. precision mediump float;
  3735. precision mediump int;
  3736. varying vec3 vOutputDirection;
  3737. uniform sampler2D envMap;
  3738. #include <common>
  3739. void main() {
  3740. vec3 outputDirection = normalize( vOutputDirection );
  3741. vec2 uv = equirectUv( outputDirection );
  3742. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3743. }
  3744. `,blending:Ec,depthTest:!1,depthWrite:!1})}function AH(){return new zc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:VM(),fragmentShader:`
  3745. precision mediump float;
  3746. precision mediump int;
  3747. uniform float flipEnvMap;
  3748. varying vec3 vOutputDirection;
  3749. uniform samplerCube envMap;
  3750. void main() {
  3751. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3752. }
  3753. `,blending:Ec,depthTest:!1,depthWrite:!1})}function VM(){return`
  3754. precision mediump float;
  3755. precision mediump int;
  3756. attribute float faceIndex;
  3757. varying vec3 vOutputDirection;
  3758. // RH coordinate system; PMREM face-indexing convention
  3759. vec3 getDirection( vec2 uv, float face ) {
  3760. uv = 2.0 * uv - 1.0;
  3761. vec3 direction = vec3( uv, 1.0 );
  3762. if ( face == 0.0 ) {
  3763. direction = direction.zyx; // ( 1, v, u ) pos x
  3764. } else if ( face == 1.0 ) {
  3765. direction = direction.xzy;
  3766. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3767. } else if ( face == 2.0 ) {
  3768. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3769. } else if ( face == 3.0 ) {
  3770. direction = direction.zyx;
  3771. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3772. } else if ( face == 4.0 ) {
  3773. direction = direction.xzy;
  3774. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3775. } else if ( face == 5.0 ) {
  3776. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3777. }
  3778. return direction;
  3779. }
  3780. void main() {
  3781. vOutputDirection = getDirection( uv, faceIndex );
  3782. gl_Position = vec4( position, 1.0 );
  3783. }
  3784. `}function oRe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===Q3||c===J3,d=c===Pp||c===Rp;if(u||d){let f=e.get(o);const g=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new SH(t)),f=u?n.fromEquirectangular(o,f):n.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const p=o.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new SH(t)),f=u?n.fromEquirectangular(o):n.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",a),f.texture):null}}}return o}function i(o){let c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function a(o){const c=o.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function lRe(t){const e={};function n(r){if(e[r]!==void 0)return e[r];const i=t.getExtension(r);return e[r]=i,i}return{has:function(r){return n(r)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(r){const i=n(r);return i===null&&K0("WebGLRenderer: "+r+" extension not supported."),i}}}function cRe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",s),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const p in g)e.update(g[p],t.ARRAY_BUFFER)}function u(f){const g=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const E=p.array;v=p.version;for(let w=0,A=E.length;w<A;w+=3){const T=E[w+0],C=E[w+1],k=E[w+2];g.push(T,C,C,k,k,T)}}else if(x!==void 0){const E=x.array;v=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const T=w+0,C=w+1,k=w+2;g.push(T,C,C,k,k,T)}}else return;const y=new(nZ(g)?hZ:dZ)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:o,update:c,getWireframeAttribute:d}}function uRe(t,e,n){let r;function i(g){r=g}let a,s;function o(g){a=g.type,s=g.bytesPerElement}function c(g,p){t.drawElements(r,p,a,g*s),n.update(p,r,1)}function u(g,p,x){x!==0&&(t.drawElementsInstanced(r,p,a,g*s,x),n.update(p,r,x))}function d(g,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,g,0,x);let y=0;for(let b=0;b<x;b++)y+=p[b];n.update(y,r,1)}function f(g,p,x,v){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<g.length;b++)u(g[b]/s,p[b],v[b]);else{y.multiDrawElementsInstancedWEBGL(r,p,0,a,g,0,v,0,x);let b=0;for(let E=0;E<x;E++)b+=p[E]*v[E];n.update(b,r,1)}}this.setMode=i,this.setIndex=o,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function dRe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:Hr("WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function hRe(t,e,n){const r=new WeakMap,i=new ei;function a(s,o,c){const u=s.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(o);if(g===void 0||g.count!==f){let j=function(){F.dispose(),r.delete(o),o.removeEventListener("dispose",j)};var p=j;g!==void 0&&g.texture.dispose();const x=o.morphAttributes.position!==void 0,v=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,b=o.morphAttributes.position||[],E=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let A=0;x===!0&&(A=1),v===!0&&(A=2),y===!0&&(A=3);let T=o.attributes.position.count*A,C=1;T>e.maxTextureSize&&(C=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const k=new Float32Array(T*C*4*f),F=new oZ(k,T,C,f);F.type=bc,F.needsUpdate=!0;const N=A*4;for(let I=0;I<f;I++){const O=b[I],q=E[I],R=w[I],W=T*C*4*I;for(let K=0;K<O.count;K++){const G=K*N;x===!0&&(i.fromBufferAttribute(O,K),k[W+G+0]=i.x,k[W+G+1]=i.y,k[W+G+2]=i.z,k[W+G+3]=0),v===!0&&(i.fromBufferAttribute(q,K),k[W+G+4]=i.x,k[W+G+5]=i.y,k[W+G+6]=i.z,k[W+G+7]=0),y===!0&&(i.fromBufferAttribute(R,K),k[W+G+8]=i.x,k[W+G+9]=i.y,k[W+G+10]=i.z,k[W+G+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:F,size:new cn(T,C)},r.set(o,g),o.addEventListener("dispose",j)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let x=0;for(let y=0;y<u.length;y++)x+=u[y];const v=o.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:a}}function fRe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}const EZ=new $o,TH=new yZ(1,1),AZ=new oZ,TZ=new jNe,CZ=new xZ,CH=[],NH=[],kH=new Float32Array(16),PH=new Float32Array(9),RH=new Float32Array(4);function hg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=CH[i];if(a===void 0&&(a=new Float32Array(i),CH[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function mi(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 pi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function GM(t,e){let n=NH[e];n===void 0&&(n=new Int32Array(e),NH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function mRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function pRe(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(mi(n,e))return;t.uniform2fv(this.addr,e),pi(n,e)}}function gRe(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(mi(n,e))return;t.uniform3fv(this.addr,e),pi(n,e)}}function xRe(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(mi(n,e))return;t.uniform4fv(this.addr,e),pi(n,e)}}function bRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(mi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),pi(n,e)}else{if(mi(n,r))return;RH.set(r),t.uniformMatrix2fv(this.addr,!1,RH),pi(n,r)}}function yRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(mi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),pi(n,e)}else{if(mi(n,r))return;PH.set(r),t.uniformMatrix3fv(this.addr,!1,PH),pi(n,r)}}function vRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(mi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),pi(n,e)}else{if(mi(n,r))return;kH.set(r),t.uniformMatrix4fv(this.addr,!1,kH),pi(n,r)}}function _Re(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function wRe(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(mi(n,e))return;t.uniform2iv(this.addr,e),pi(n,e)}}function SRe(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(mi(n,e))return;t.uniform3iv(this.addr,e),pi(n,e)}}function MRe(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(mi(n,e))return;t.uniform4iv(this.addr,e),pi(n,e)}}function ERe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function ARe(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(mi(n,e))return;t.uniform2uiv(this.addr,e),pi(n,e)}}function TRe(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(mi(n,e))return;t.uniform3uiv(this.addr,e),pi(n,e)}}function CRe(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(mi(n,e))return;t.uniform4uiv(this.addr,e),pi(n,e)}}function NRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(TH.compareFunction=tZ,a=TH):a=EZ,n.setTexture2D(e||a,i)}function kRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||TZ,i)}function PRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||CZ,i)}function RRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||AZ,i)}function jRe(t){switch(t){case 5126:return mRe;case 35664:return pRe;case 35665:return gRe;case 35666:return xRe;case 35674:return bRe;case 35675:return yRe;case 35676:return vRe;case 5124:case 35670:return _Re;case 35667:case 35671:return wRe;case 35668:case 35672:return SRe;case 35669:case 35673:return MRe;case 5125:return ERe;case 36294:return ARe;case 36295:return TRe;case 36296:return CRe;case 35678:case 36198:case 36298:case 36306:case 35682:return NRe;case 35679:case 36299:case 36307:return kRe;case 35680:case 36300:case 36308:case 36293:return PRe;case 36289:case 36303:case 36311:case 36292:return RRe}}function DRe(t,e){t.uniform1fv(this.addr,e)}function ORe(t,e){const n=hg(e,this.size,2);t.uniform2fv(this.addr,n)}function LRe(t,e){const n=hg(e,this.size,3);t.uniform3fv(this.addr,n)}function IRe(t,e){const n=hg(e,this.size,4);t.uniform4fv(this.addr,n)}function FRe(t,e){const n=hg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function URe(t,e){const n=hg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function zRe(t,e){const n=hg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function BRe(t,e){t.uniform1iv(this.addr,e)}function HRe(t,e){t.uniform2iv(this.addr,e)}function $Re(t,e){t.uniform3iv(this.addr,e)}function VRe(t,e){t.uniform4iv(this.addr,e)}function GRe(t,e){t.uniform1uiv(this.addr,e)}function WRe(t,e){t.uniform2uiv(this.addr,e)}function qRe(t,e){t.uniform3uiv(this.addr,e)}function KRe(t,e){t.uniform4uiv(this.addr,e)}function XRe(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);mi(r,a)||(t.uniform1iv(this.addr,a),pi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||EZ,a[s])}function YRe(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);mi(r,a)||(t.uniform1iv(this.addr,a),pi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||TZ,a[s])}function ZRe(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);mi(r,a)||(t.uniform1iv(this.addr,a),pi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||CZ,a[s])}function QRe(t,e,n){const r=this.cache,i=e.length,a=GM(n,i);mi(r,a)||(t.uniform1iv(this.addr,a),pi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||AZ,a[s])}function JRe(t){switch(t){case 5126:return DRe;case 35664:return ORe;case 35665:return LRe;case 35666:return IRe;case 35674:return FRe;case 35675:return URe;case 35676:return zRe;case 5124:case 35670:return BRe;case 35667:case 35671:return HRe;case 35668:case 35672:return $Re;case 35669:case 35673:return VRe;case 5125:return GRe;case 36294:return WRe;case 36295:return qRe;case 36296:return KRe;case 35678:case 36198:case 36298:case 36306:case 35682:return XRe;case 35679:case 36299:case 36307:return YRe;case 35680:case 36300:case 36308:case 36293:return ZRe;case 36289:case 36303:case 36311:case 36292:return QRe}}let eje=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=jRe(n.type)}},tje=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=JRe(n.type)}},nje=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}};const XC=/(\w+)(\])?(\[|\.)?/g;function jH(t,e){t.seq.push(e),t.map[e.id]=e}function rje(t,e,n){const r=t.name,i=r.length;for(XC.lastIndex=0;;){const a=XC.exec(r),s=XC.lastIndex;let o=a[1];const c=a[2]==="]",u=a[3];if(c&&(o=o|0),u===void 0||u==="["&&s+2===i){jH(n,u===void 0?new eje(o,t,e):new tje(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new nje(o),jH(n,f)),n=f}}}let g1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),s=e.getUniformLocation(n,a.name);rje(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const o=n[a],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}};function DH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const ije=37297;let aje=0;function sje(t,e){const n=t.split(`
  3785. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  3786. `)}const OH=new dn;function oje(t){Nn._getMatrix(OH,Nn.workingColorSpace,t);const e=`mat3( ${OH.elements.map(n=>n.toFixed(4))} )`;switch(Nn.getTransfer(t)){case jw:return[e,"LinearTransferOETF"];case Kn:return[e,"sRGBTransferOETF"];default:return Yt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function LH(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
  3787. `+a+`
  3788. `+sje(t.getShaderSource(e),o)}else return a}function lje(t,e){const n=oje(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3789. `)}function cje(t,e){let n;switch(e){case sNe:n="Linear";break;case oNe:n="Reinhard";break;case lNe:n="Cineon";break;case cNe:n="ACESFilmic";break;case dNe:n="AgX";break;case hNe:n="Neutral";break;case uNe:n="Custom";break;default:Yt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const i_=new et;function uje(){Nn.getLuminanceCoefficients(i_);const t=i_.x.toFixed(4),e=i_.y.toFixed(4),n=i_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3790. `)}function dje(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Bx).join(`
  3791. `)}function hje(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3792. `)}function fje(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Bx(t){return t!==""}function IH(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 FH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const mje=/^[ \t]*#include +<([\w\d./]+)>/gm;function RP(t){return t.replace(mje,gje)}const pje=new Map;function gje(t,e){let n=on[e];if(n===void 0){const r=pje.get(e);if(r!==void 0)n=on[r],Yt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return RP(n)}const xje=/#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 UH(t){return t.replace(xje,bje)}function bje(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function zH(t){let e=`precision ${t.precision} float;
  3793. precision ${t.precision} int;
  3794. precision ${t.precision} sampler2D;
  3795. precision ${t.precision} samplerCube;
  3796. precision ${t.precision} sampler3D;
  3797. precision ${t.precision} sampler2DArray;
  3798. precision ${t.precision} sampler2DShadow;
  3799. precision ${t.precision} samplerCubeShadow;
  3800. precision ${t.precision} sampler2DArrayShadow;
  3801. precision ${t.precision} isampler2D;
  3802. precision ${t.precision} isampler3D;
  3803. precision ${t.precision} isamplerCube;
  3804. precision ${t.precision} isampler2DArray;
  3805. precision ${t.precision} usampler2D;
  3806. precision ${t.precision} usampler3D;
  3807. precision ${t.precision} usamplerCube;
  3808. precision ${t.precision} usampler2DArray;
  3809. `;return t.precision==="highp"?e+=`
  3810. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3811. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3812. #define LOW_PRECISION`),e}function yje(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===GY?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===UCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ac&&(e="SHADOWMAP_TYPE_VSM"),e}function vje(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Pp:case Rp:e="ENVMAP_TYPE_CUBE";break;case HM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function _je(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Rp:e="ENVMAP_MODE_REFRACTION";break}return e}function wje(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case oO:e="ENVMAP_BLENDING_MULTIPLY";break;case iNe:e="ENVMAP_BLENDING_MIX";break;case aNe:e="ENVMAP_BLENDING_ADD";break}return e}function Sje(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 Mje(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const c=yje(n),u=vje(n),d=_je(n),f=wje(n),g=Sje(n),p=dje(n),x=hje(a),v=i.createProgram();let y,b,E=n.glslVersion?"#version "+n.glslVersion+`
  3813. `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Bx).join(`
  3814. `),y.length>0&&(y+=`
  3815. `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Bx).join(`
  3816. `),b.length>0&&(b+=`
  3817. `)):(y=[zH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3818. `].filter(Bx).join(`
  3819. `),b=[zH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",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 "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==td?"#define TONE_MAPPING":"",n.toneMapping!==td?on.tonemapping_pars_fragment:"",n.toneMapping!==td?cje("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",on.colorspace_pars_fragment,lje("linearToOutputTexel",n.outputColorSpace),uje(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3820. `].filter(Bx).join(`
  3821. `)),s=RP(s),s=IH(s,n),s=FH(s,n),o=RP(o),o=IH(o,n),o=FH(o,n),s=UH(s),o=UH(o),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
  3822. `,y=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3823. `)+`
  3824. `+y,b=["#define varying in",n.glslVersion===q6?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===q6?"":"#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(`
  3825. `)+`
  3826. `+b);const w=E+y+s,A=E+b+o,T=DH(i,i.VERTEX_SHADER,w),C=DH(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function k(I){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(v)||"",q=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(C)||"",W=O.trim(),K=q.trim(),G=R.trim();let te=!0,Y=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(te=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,C);else{const J=LH(i,T,"vertex"),U=LH(i,C,"fragment");Hr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  3827. Material Name: `+I.name+`
  3828. Material Type: `+I.type+`
  3829. Program Info Log: `+W+`
  3830. `+J+`
  3831. `+U)}else W!==""?Yt("WebGLProgram: Program Info Log:",W):(K===""||G==="")&&(Y=!1);Y&&(I.diagnostics={runnable:te,programLog:W,vertexShader:{log:K,prefix:y},fragmentShader:{log:G,prefix:b}})}i.deleteShader(T),i.deleteShader(C),F=new g1(i,v),N=fje(i,v)}let F;this.getUniforms=function(){return F===void 0&&k(this),F};let N;this.getAttributes=function(){return N===void 0&&k(this),N};let j=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=i.getProgramParameter(v,ije)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=aje++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=C,this}let Eje=0,Aje=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Tje(e),n.set(e,r)),r}},Tje=class{constructor(e){this.id=Eje++,this.code=e,this.usedTimes=0}};function Cje(t,e,n,r,i,a,s){const o=new cZ,c=new Aje,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(N){return u.add(N),N===0?"uv":`uv${N}`}function y(N,j,I,O,q){const R=O.fog,W=q.geometry,K=N.isMeshStandardMaterial?O.environment:null,G=(N.isMeshStandardMaterial?n:e).get(N.envMap||K),te=G&&G.mapping===HM?G.image.height:null,Y=x[N.type];N.precision!==null&&(p=i.getMaxPrecision(N.precision),p!==N.precision&&Yt("WebGLProgram.getParameters:",N.precision,"not supported, using",p,"instead."));const J=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=J!==void 0?J.length:0;let H=0;W.morphAttributes.position!==void 0&&(H=1),W.morphAttributes.normal!==void 0&&(H=2),W.morphAttributes.color!==void 0&&(H=3);let ee,ie,pe,ue;if(Y){const Et=nl[Y];ee=Et.vertexShader,ie=Et.fragmentShader}else ee=N.vertexShader,ie=N.fragmentShader,c.update(N),pe=c.getVertexShaderID(N),ue=c.getFragmentShaderID(N);const be=t.getRenderTarget(),Re=t.state.buffers.depth.getReversed(),Z=q.isInstancedMesh===!0,_e=q.isBatchedMesh===!0,Le=!!N.map,ce=!!N.matcap,Ie=!!G,z=!!N.aoMap,B=!!N.lightMap,ne=!!N.bumpMap,V=!!N.normalMap,Q=!!N.displacementMap,se=!!N.emissiveMap,Me=!!N.metalnessMap,Ae=!!N.roughnessMap,Se=N.anisotropy>0,$=N.clearcoat>0,L=N.dispersion>0,re=N.iridescence>0,ye=N.sheen>0,we=N.transmission>0,xe=Se&&!!N.anisotropyMap,rt=$&&!!N.clearcoatMap,He=$&&!!N.clearcoatNormalMap,he=$&&!!N.clearcoatRoughnessMap,Ge=re&&!!N.iridescenceMap,Ue=re&&!!N.iridescenceThicknessMap,oe=ye&&!!N.sheenColorMap,tt=ye&&!!N.sheenRoughnessMap,$e=!!N.specularMap,Ye=!!N.specularColorMap,ut=!!N.specularIntensityMap,fe=we&&!!N.transmissionMap,Qe=we&&!!N.thicknessMap,ge=!!N.gradientMap,ze=!!N.alphaMap,ke=N.alphaTest>0,ve=!!N.alphaHash,de=!!N.extensions;let ot=td;N.toneMapped&&(be===null||be.isXRRenderTarget===!0)&&(ot=t.toneMapping);const xt={shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:ee,fragmentShader:ie,defines:N.defines,customVertexShaderID:pe,customFragmentShaderID:ue,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:p,batching:_e,batchingColor:_e&&q._colorsTexture!==null,instancing:Z,instancingColor:Z&&q.instanceColor!==null,instancingMorph:Z&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:be===null?t.outputColorSpace:be.isXRRenderTarget===!0?be.texture.colorSpace:jp,alphaToCoverage:!!N.alphaToCoverage,map:Le,matcap:ce,envMap:Ie,envMapMode:Ie&&G.mapping,envMapCubeUVHeight:te,aoMap:z,lightMap:B,bumpMap:ne,normalMap:V,displacementMap:g&&Q,emissiveMap:se,normalMapObjectSpace:V&&N.normalMapType===gNe,normalMapTangentSpace:V&&N.normalMapType===eZ,metalnessMap:Me,roughnessMap:Ae,anisotropy:Se,anisotropyMap:xe,clearcoat:$,clearcoatMap:rt,clearcoatNormalMap:He,clearcoatRoughnessMap:he,dispersion:L,iridescence:re,iridescenceMap:Ge,iridescenceThicknessMap:Ue,sheen:ye,sheenColorMap:oe,sheenRoughnessMap:tt,specularMap:$e,specularColorMap:Ye,specularIntensityMap:ut,transmission:we,transmissionMap:fe,thicknessMap:Qe,gradientMap:ge,opaque:N.transparent===!1&&N.blending===sp&&N.alphaToCoverage===!1,alphaMap:ze,alphaTest:ke,alphaHash:ve,combine:N.combine,mapUv:Le&&v(N.map.channel),aoMapUv:z&&v(N.aoMap.channel),lightMapUv:B&&v(N.lightMap.channel),bumpMapUv:ne&&v(N.bumpMap.channel),normalMapUv:V&&v(N.normalMap.channel),displacementMapUv:Q&&v(N.displacementMap.channel),emissiveMapUv:se&&v(N.emissiveMap.channel),metalnessMapUv:Me&&v(N.metalnessMap.channel),roughnessMapUv:Ae&&v(N.roughnessMap.channel),anisotropyMapUv:xe&&v(N.anisotropyMap.channel),clearcoatMapUv:rt&&v(N.clearcoatMap.channel),clearcoatNormalMapUv:He&&v(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:he&&v(N.clearcoatRoughnessMap.channel),iridescenceMapUv:Ge&&v(N.iridescenceMap.channel),iridescenceThicknessMapUv:Ue&&v(N.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&v(N.sheenColorMap.channel),sheenRoughnessMapUv:tt&&v(N.sheenRoughnessMap.channel),specularMapUv:$e&&v(N.specularMap.channel),specularColorMapUv:Ye&&v(N.specularColorMap.channel),specularIntensityMapUv:ut&&v(N.specularIntensityMap.channel),transmissionMapUv:fe&&v(N.transmissionMap.channel),thicknessMapUv:Qe&&v(N.thicknessMap.channel),alphaMapUv:ze&&v(N.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(V||Se),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Le||ze),fog:!!R,useFog:N.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:N.flatShading===!0&&N.wireframe===!1,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Re,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:H,numDirLights:j.directional.length,numPointLights:j.point.length,numSpotLights:j.spot.length,numSpotLightMaps:j.spotLightMap.length,numRectAreaLights:j.rectArea.length,numHemiLights:j.hemi.length,numDirLightShadows:j.directionalShadowMap.length,numPointLightShadows:j.pointShadowMap.length,numSpotLightShadows:j.spotShadowMap.length,numSpotLightShadowsWithMaps:j.numSpotLightShadowsWithMaps,numLightProbes:j.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&I.length>0,shadowMapType:t.shadowMap.type,toneMapping:ot,decodeVideoTexture:Le&&N.map.isVideoTexture===!0&&Nn.getTransfer(N.map.colorSpace)===Kn,decodeVideoTextureEmissive:se&&N.emissiveMap.isVideoTexture===!0&&Nn.getTransfer(N.emissiveMap.colorSpace)===Kn,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===rl,flipSided:N.side===Za,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionClipCullDistance:de&&N.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(de&&N.extensions.multiDraw===!0||_e)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()};return xt.vertexUv1s=u.has(1),xt.vertexUv2s=u.has(2),xt.vertexUv3s=u.has(3),u.clear(),xt}function b(N){const j=[];if(N.shaderID?j.push(N.shaderID):(j.push(N.customVertexShaderID),j.push(N.customFragmentShaderID)),N.defines!==void 0)for(const I in N.defines)j.push(I),j.push(N.defines[I]);return N.isRawShaderMaterial===!1&&(E(j,N),w(j,N),j.push(t.outputColorSpace)),j.push(N.customProgramCacheKey),j.join()}function E(N,j){N.push(j.precision),N.push(j.outputColorSpace),N.push(j.envMapMode),N.push(j.envMapCubeUVHeight),N.push(j.mapUv),N.push(j.alphaMapUv),N.push(j.lightMapUv),N.push(j.aoMapUv),N.push(j.bumpMapUv),N.push(j.normalMapUv),N.push(j.displacementMapUv),N.push(j.emissiveMapUv),N.push(j.metalnessMapUv),N.push(j.roughnessMapUv),N.push(j.anisotropyMapUv),N.push(j.clearcoatMapUv),N.push(j.clearcoatNormalMapUv),N.push(j.clearcoatRoughnessMapUv),N.push(j.iridescenceMapUv),N.push(j.iridescenceThicknessMapUv),N.push(j.sheenColorMapUv),N.push(j.sheenRoughnessMapUv),N.push(j.specularMapUv),N.push(j.specularColorMapUv),N.push(j.specularIntensityMapUv),N.push(j.transmissionMapUv),N.push(j.thicknessMapUv),N.push(j.combine),N.push(j.fogExp2),N.push(j.sizeAttenuation),N.push(j.morphTargetsCount),N.push(j.morphAttributeCount),N.push(j.numDirLights),N.push(j.numPointLights),N.push(j.numSpotLights),N.push(j.numSpotLightMaps),N.push(j.numHemiLights),N.push(j.numRectAreaLights),N.push(j.numDirLightShadows),N.push(j.numPointLightShadows),N.push(j.numSpotLightShadows),N.push(j.numSpotLightShadowsWithMaps),N.push(j.numLightProbes),N.push(j.shadowMapType),N.push(j.toneMapping),N.push(j.numClippingPlanes),N.push(j.numClipIntersection),N.push(j.depthPacking)}function w(N,j){o.disableAll(),j.supportsVertexTextures&&o.enable(0),j.instancing&&o.enable(1),j.instancingColor&&o.enable(2),j.instancingMorph&&o.enable(3),j.matcap&&o.enable(4),j.envMap&&o.enable(5),j.normalMapObjectSpace&&o.enable(6),j.normalMapTangentSpace&&o.enable(7),j.clearcoat&&o.enable(8),j.iridescence&&o.enable(9),j.alphaTest&&o.enable(10),j.vertexColors&&o.enable(11),j.vertexAlphas&&o.enable(12),j.vertexUv1s&&o.enable(13),j.vertexUv2s&&o.enable(14),j.vertexUv3s&&o.enable(15),j.vertexTangents&&o.enable(16),j.anisotropy&&o.enable(17),j.alphaHash&&o.enable(18),j.batching&&o.enable(19),j.dispersion&&o.enable(20),j.batchingColor&&o.enable(21),j.gradientMap&&o.enable(22),N.push(o.mask),o.disableAll(),j.fog&&o.enable(0),j.useFog&&o.enable(1),j.flatShading&&o.enable(2),j.logarithmicDepthBuffer&&o.enable(3),j.reversedDepthBuffer&&o.enable(4),j.skinning&&o.enable(5),j.morphTargets&&o.enable(6),j.morphNormals&&o.enable(7),j.morphColors&&o.enable(8),j.premultipliedAlpha&&o.enable(9),j.shadowMapEnabled&&o.enable(10),j.doubleSided&&o.enable(11),j.flipSided&&o.enable(12),j.useDepthPacking&&o.enable(13),j.dithering&&o.enable(14),j.transmission&&o.enable(15),j.sheen&&o.enable(16),j.opaque&&o.enable(17),j.pointsUvs&&o.enable(18),j.decodeVideoTexture&&o.enable(19),j.decodeVideoTextureEmissive&&o.enable(20),j.alphaToCoverage&&o.enable(21),N.push(o.mask)}function A(N){const j=x[N.type];let I;if(j){const O=nl[j];I=WNe.clone(O.uniforms)}else I=N.uniforms;return I}function T(N,j){let I;for(let O=0,q=d.length;O<q;O++){const R=d[O];if(R.cacheKey===j){I=R,++I.usedTimes;break}}return I===void 0&&(I=new Mje(t,j,N,a),d.push(I)),I}function C(N){if(--N.usedTimes===0){const j=d.indexOf(N);d[j]=d[d.length-1],d.pop(),N.destroy()}}function k(N){c.remove(N)}function F(){c.dispose()}return{getParameters:y,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:C,releaseShaderCache:k,programs:d,dispose:F}}function Nje(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function r(s){t.delete(s)}function i(s,o,c){t.get(s)[o]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function kje(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 BH(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 HH(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,p,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=p,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=v,b.group=y),e++,b}function o(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.push(b):p.transparent===!0?i.push(b):n.push(b)}function c(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.unshift(b):p.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||kje),r.length>1&&r.sort(g||BH),i.length>1&&i.sort(g||BH)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:c,finish:d,sort:u}}function Pje(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new HH,t.set(r,[s])):i>=a.length?(s=new HH,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function Rje(){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 et,color:new _n};break;case"SpotLight":n={position:new et,direction:new et,color:new _n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new et,color:new _n,distance:0,decay:0};break;case"HemisphereLight":n={direction:new et,skyColor:new _n,groundColor:new _n};break;case"RectAreaLight":n={color:new _n,position:new et,halfWidth:new et,halfHeight:new et};break}return t[e.id]=n,n}}}function jje(){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 cn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Dje=0;function Oje(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Lje(t){const e=new Rje,n=jje(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new et);const i=new et,a=new ii,s=new ii;function o(u){let d=0,f=0,g=0;for(let N=0;N<9;N++)r.probe[N].set(0,0,0);let p=0,x=0,v=0,y=0,b=0,E=0,w=0,A=0,T=0,C=0,k=0;u.sort(Oje);for(let N=0,j=u.length;N<j;N++){const I=u[N],O=I.color,q=I.intensity,R=I.distance,W=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=O.r*q,f+=O.g*q,g+=O.b*q;else if(I.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(I.sh.coefficients[K],q);k++}else if(I.isDirectionalLight){const K=e.get(I);if(K.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const G=I.shadow,te=n.get(I);te.shadowIntensity=G.intensity,te.shadowBias=G.bias,te.shadowNormalBias=G.normalBias,te.shadowRadius=G.radius,te.shadowMapSize=G.mapSize,r.directionalShadow[p]=te,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=I.shadow.matrix,E++}r.directional[p]=K,p++}else if(I.isSpotLight){const K=e.get(I);K.position.setFromMatrixPosition(I.matrixWorld),K.color.copy(O).multiplyScalar(q),K.distance=R,K.coneCos=Math.cos(I.angle),K.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),K.decay=I.decay,r.spot[v]=K;const G=I.shadow;if(I.map&&(r.spotLightMap[T]=I.map,T++,G.updateMatrices(I),I.castShadow&&C++),r.spotLightMatrix[v]=G.matrix,I.castShadow){const te=n.get(I);te.shadowIntensity=G.intensity,te.shadowBias=G.bias,te.shadowNormalBias=G.normalBias,te.shadowRadius=G.radius,te.shadowMapSize=G.mapSize,r.spotShadow[v]=te,r.spotShadowMap[v]=W,A++}v++}else if(I.isRectAreaLight){const K=e.get(I);K.color.copy(O).multiplyScalar(q),K.halfWidth.set(I.width*.5,0,0),K.halfHeight.set(0,I.height*.5,0),r.rectArea[y]=K,y++}else if(I.isPointLight){const K=e.get(I);if(K.color.copy(I.color).multiplyScalar(I.intensity),K.distance=I.distance,K.decay=I.decay,I.castShadow){const G=I.shadow,te=n.get(I);te.shadowIntensity=G.intensity,te.shadowBias=G.bias,te.shadowNormalBias=G.normalBias,te.shadowRadius=G.radius,te.shadowMapSize=G.mapSize,te.shadowCameraNear=G.camera.near,te.shadowCameraFar=G.camera.far,r.pointShadow[x]=te,r.pointShadowMap[x]=W,r.pointShadowMatrix[x]=I.shadow.matrix,w++}r.point[x]=K,x++}else if(I.isHemisphereLight){const K=e.get(I);K.skyColor.copy(I.color).multiplyScalar(q),K.groundColor.copy(I.groundColor).multiplyScalar(q),r.hemi[b]=K,b++}}y>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Tt.LTC_FLOAT_1,r.rectAreaLTC2=Tt.LTC_FLOAT_2):(r.rectAreaLTC1=Tt.LTC_HALF_1,r.rectAreaLTC2=Tt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const F=r.hash;(F.directionalLength!==p||F.pointLength!==x||F.spotLength!==v||F.rectAreaLength!==y||F.hemiLength!==b||F.numDirectionalShadows!==E||F.numPointShadows!==w||F.numSpotShadows!==A||F.numSpotMaps!==T||F.numLightProbes!==k)&&(r.directional.length=p,r.spot.length=v,r.rectArea.length=y,r.point.length=x,r.hemi.length=b,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=A+T-C,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=k,F.directionalLength=p,F.pointLength=x,F.spotLength=v,F.rectAreaLength=y,F.hemiLength=b,F.numDirectionalShadows=E,F.numPointShadows=w,F.numSpotShadows=A,F.numSpotMaps=T,F.numLightProbes=k,r.version=Dje++)}function c(u,d){let f=0,g=0,p=0,x=0,v=0;const y=d.matrixWorldInverse;for(let b=0,E=u.length;b<E;b++){const w=u[b];if(w.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(y),f++}else if(w.isSpotLight){const A=r.spot[p];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(y),A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(y),p++}else if(w.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(y),s.identity(),a.copy(w.matrixWorld),a.premultiply(y),s.extractRotation(a),A.halfWidth.set(w.width*.5,0,0),A.halfHeight.set(0,w.height*.5,0),A.halfWidth.applyMatrix4(s),A.halfHeight.applyMatrix4(s),x++}else if(w.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(y),g++}else if(w.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(y),v++}}}return{setup:o,setupView:c,state:r}}function $H(t){const e=new Lje(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function s(d){r.push(d)}function o(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:o,setupLightsView:c,pushLight:a,pushShadow:s}}function Ije(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let o;return s===void 0?(o=new $H(t),e.set(i,[o])):a>=s.length?(o=new $H(t),s.push(o)):o=s[a],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const Fje=`void main() {
  3832. gl_Position = vec4( position, 1.0 );
  3833. }`,Uje=`uniform sampler2D shadow_pass;
  3834. uniform vec2 resolution;
  3835. uniform float radius;
  3836. #include <packing>
  3837. void main() {
  3838. const float samples = float( VSM_SAMPLES );
  3839. float mean = 0.0;
  3840. float squared_mean = 0.0;
  3841. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3842. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3843. for ( float i = 0.0; i < samples; i ++ ) {
  3844. float uvOffset = uvStart + i * uvStride;
  3845. #ifdef HORIZONTAL_PASS
  3846. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3847. mean += distribution.x;
  3848. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3849. #else
  3850. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3851. mean += depth;
  3852. squared_mean += depth * depth;
  3853. #endif
  3854. }
  3855. mean = mean / samples;
  3856. squared_mean = squared_mean / samples;
  3857. float std_dev = sqrt( squared_mean - mean * mean );
  3858. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3859. }`;function zje(t,e,n){let r=new yO;const i=new cn,a=new cn,s=new ei,o=new ske({depthPacking:pNe}),c=new oke,u={},d=n.maxTextureSize,f={[bd]:Za,[Za]:bd,[rl]:rl},g=new zc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new cn},radius:{value:4}},vertexShader:Fje,fragmentShader:Uje}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Al;x.setAttribute("position",new ao(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new bl(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=GY;let b=this.type;this.render=function(C,k,F){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||C.length===0)return;const N=t.getRenderTarget(),j=t.getActiveCubeFace(),I=t.getActiveMipmapLevel(),O=t.state;O.setBlending(Ec),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=b!==ac&&this.type===ac,R=b===ac&&this.type!==ac;for(let W=0,K=C.length;W<K;W++){const G=C[W],te=G.shadow;if(te===void 0){Yt("WebGLShadowMap:",G,"has no shadow.");continue}if(te.autoUpdate===!1&&te.needsUpdate===!1)continue;i.copy(te.mapSize);const Y=te.getFrameExtents();if(i.multiply(Y),a.copy(te.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Y.x),i.x=a.x*Y.x,te.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Y.y),i.y=a.y*Y.y,te.mapSize.y=a.y)),te.map===null||q===!0||R===!0){const U=this.type!==ac?{minFilter:Es,magFilter:Es}:{};te.map!==null&&te.map.dispose(),te.map=new af(i.x,i.y,U),te.map.texture.name=G.name+".shadowMap",te.camera.updateProjectionMatrix()}t.setRenderTarget(te.map),t.clear();const J=te.getViewportCount();for(let U=0;U<J;U++){const H=te.getViewport(U);s.set(a.x*H.x,a.y*H.y,a.x*H.z,a.y*H.w),O.viewport(s),te.updateMatrices(G,U),r=te.getFrustum(),A(k,F,te.camera,G,this.type)}te.isPointLightShadow!==!0&&this.type===ac&&E(te,F),te.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(N,j,I)};function E(C,k){const F=e.update(v);g.defines.VSM_SAMPLES!==C.blurSamples&&(g.defines.VSM_SAMPLES=C.blurSamples,p.defines.VSM_SAMPLES=C.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new af(i.x,i.y)),g.uniforms.shadow_pass.value=C.map.texture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(k,null,F,g,v,null),p.uniforms.shadow_pass.value=C.mapPass.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(k,null,F,p,v,null)}function w(C,k,F,N){let j=null;const I=F.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(I!==void 0)j=I;else if(j=F.isPointLight===!0?c:o,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0||k.alphaToCoverage===!0){const O=j.uuid,q=k.uuid;let R=u[O];R===void 0&&(R={},u[O]=R);let W=R[q];W===void 0&&(W=j.clone(),R[q]=W,k.addEventListener("dispose",T)),j=W}if(j.visible=k.visible,j.wireframe=k.wireframe,N===ac?j.side=k.shadowSide!==null?k.shadowSide:k.side:j.side=k.shadowSide!==null?k.shadowSide:f[k.side],j.alphaMap=k.alphaMap,j.alphaTest=k.alphaToCoverage===!0?.5:k.alphaTest,j.map=k.map,j.clipShadows=k.clipShadows,j.clippingPlanes=k.clippingPlanes,j.clipIntersection=k.clipIntersection,j.displacementMap=k.displacementMap,j.displacementScale=k.displacementScale,j.displacementBias=k.displacementBias,j.wireframeLinewidth=k.wireframeLinewidth,j.linewidth=k.linewidth,F.isPointLight===!0&&j.isMeshDistanceMaterial===!0){const O=t.properties.get(j);O.light=F}return j}function A(C,k,F,N,j){if(C.visible===!1)return;if(C.layers.test(k.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&j===ac)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,C.matrixWorld);const q=e.update(C),R=C.material;if(Array.isArray(R)){const W=q.groups;for(let K=0,G=W.length;K<G;K++){const te=W[K],Y=R[te.materialIndex];if(Y&&Y.visible){const J=w(C,Y,N,j);C.onBeforeShadow(t,C,k,F,q,J,te),t.renderBufferDirect(F,null,q,J,C,te),C.onAfterShadow(t,C,k,F,q,J,te)}}}else if(R.visible){const W=w(C,R,N,j);C.onBeforeShadow(t,C,k,F,q,W,null),t.renderBufferDirect(F,null,q,W,C,null),C.onAfterShadow(t,C,k,F,q,W,null)}}const O=C.children;for(let q=0,R=O.length;q<R;q++)A(O[q],k,F,N,j)}function T(C){C.target.removeEventListener("dispose",T);for(const F in u){const N=u[F],j=C.target.uuid;j in N&&(N[j].dispose(),delete N[j])}}}const Bje={[G3]:W3,[q3]:Y3,[K3]:Z3,[kp]:X3,[W3]:G3,[Y3]:q3,[Z3]:K3,[X3]:kp};function Hje(t,e){function n(){let fe=!1;const Qe=new ei;let ge=null;const ze=new ei(0,0,0,0);return{setMask:function(ke){ge!==ke&&!fe&&(t.colorMask(ke,ke,ke,ke),ge=ke)},setLocked:function(ke){fe=ke},setClear:function(ke,ve,de,ot,xt){xt===!0&&(ke*=ot,ve*=ot,de*=ot),Qe.set(ke,ve,de,ot),ze.equals(Qe)===!1&&(t.clearColor(ke,ve,de,ot),ze.copy(Qe))},reset:function(){fe=!1,ge=null,ze.set(-1,0,0,0)}}}function r(){let fe=!1,Qe=!1,ge=null,ze=null,ke=null;return{setReversed:function(ve){if(Qe!==ve){const de=e.get("EXT_clip_control");ve?de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT):de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT),Qe=ve;const ot=ke;ke=null,this.setClear(ot)}},getReversed:function(){return Qe},setTest:function(ve){ve?be(t.DEPTH_TEST):Re(t.DEPTH_TEST)},setMask:function(ve){ge!==ve&&!fe&&(t.depthMask(ve),ge=ve)},setFunc:function(ve){if(Qe&&(ve=Bje[ve]),ze!==ve){switch(ve){case G3:t.depthFunc(t.NEVER);break;case W3:t.depthFunc(t.ALWAYS);break;case q3:t.depthFunc(t.LESS);break;case kp:t.depthFunc(t.LEQUAL);break;case K3:t.depthFunc(t.EQUAL);break;case X3:t.depthFunc(t.GEQUAL);break;case Y3:t.depthFunc(t.GREATER);break;case Z3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ze=ve}},setLocked:function(ve){fe=ve},setClear:function(ve){ke!==ve&&(Qe&&(ve=1-ve),t.clearDepth(ve),ke=ve)},reset:function(){fe=!1,ge=null,ze=null,ke=null,Qe=!1}}}function i(){let fe=!1,Qe=null,ge=null,ze=null,ke=null,ve=null,de=null,ot=null,xt=null;return{setTest:function(Et){fe||(Et?be(t.STENCIL_TEST):Re(t.STENCIL_TEST))},setMask:function(Et){Qe!==Et&&!fe&&(t.stencilMask(Et),Qe=Et)},setFunc:function(Et,Qt,Ot){(ge!==Et||ze!==Qt||ke!==Ot)&&(t.stencilFunc(Et,Qt,Ot),ge=Et,ze=Qt,ke=Ot)},setOp:function(Et,Qt,Ot){(ve!==Et||de!==Qt||ot!==Ot)&&(t.stencilOp(Et,Qt,Ot),ve=Et,de=Qt,ot=Ot)},setLocked:function(Et){fe=Et},setClear:function(Et){xt!==Et&&(t.clearStencil(Et),xt=Et)},reset:function(){fe=!1,Qe=null,ge=null,ze=null,ke=null,ve=null,de=null,ot=null,xt=null}}}const a=new n,s=new r,o=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,p=[],x=null,v=!1,y=null,b=null,E=null,w=null,A=null,T=null,C=null,k=new _n(0,0,0),F=0,N=!1,j=null,I=null,O=null,q=null,R=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const te=t.getParameter(t.VERSION);te.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(te)[1]),K=G>=1):te.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),K=G>=2);let Y=null,J={};const U=t.getParameter(t.SCISSOR_BOX),H=t.getParameter(t.VIEWPORT),ee=new ei().fromArray(U),ie=new ei().fromArray(H);function pe(fe,Qe,ge,ze){const ke=new Uint8Array(4),ve=t.createTexture();t.bindTexture(fe,ve),t.texParameteri(fe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(fe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let de=0;de<ge;de++)fe===t.TEXTURE_3D||fe===t.TEXTURE_2D_ARRAY?t.texImage3D(Qe,0,t.RGBA,1,1,ze,0,t.RGBA,t.UNSIGNED_BYTE,ke):t.texImage2D(Qe+de,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ke);return ve}const ue={};ue[t.TEXTURE_2D]=pe(t.TEXTURE_2D,t.TEXTURE_2D,1),ue[t.TEXTURE_CUBE_MAP]=pe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),ue[t.TEXTURE_2D_ARRAY]=pe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ue[t.TEXTURE_3D]=pe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),be(t.DEPTH_TEST),s.setFunc(kp),ne(!1),V(B6),be(t.CULL_FACE),z(Ec);function be(fe){d[fe]!==!0&&(t.enable(fe),d[fe]=!0)}function Re(fe){d[fe]!==!1&&(t.disable(fe),d[fe]=!1)}function Z(fe,Qe){return f[fe]!==Qe?(t.bindFramebuffer(fe,Qe),f[fe]=Qe,fe===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Qe),fe===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Qe),!0):!1}function _e(fe,Qe){let ge=p,ze=!1;if(fe){ge=g.get(Qe),ge===void 0&&(ge=[],g.set(Qe,ge));const ke=fe.textures;if(ge.length!==ke.length||ge[0]!==t.COLOR_ATTACHMENT0){for(let ve=0,de=ke.length;ve<de;ve++)ge[ve]=t.COLOR_ATTACHMENT0+ve;ge.length=ke.length,ze=!0}}else ge[0]!==t.BACK&&(ge[0]=t.BACK,ze=!0);ze&&t.drawBuffers(ge)}function Le(fe){return x!==fe?(t.useProgram(fe),x=fe,!0):!1}const ce={[fh]:t.FUNC_ADD,[BCe]:t.FUNC_SUBTRACT,[HCe]:t.FUNC_REVERSE_SUBTRACT};ce[$Ce]=t.MIN,ce[VCe]=t.MAX;const Ie={[GCe]:t.ZERO,[WCe]:t.ONE,[qCe]:t.SRC_COLOR,[$3]:t.SRC_ALPHA,[JCe]:t.SRC_ALPHA_SATURATE,[ZCe]:t.DST_COLOR,[XCe]:t.DST_ALPHA,[KCe]:t.ONE_MINUS_SRC_COLOR,[V3]:t.ONE_MINUS_SRC_ALPHA,[QCe]:t.ONE_MINUS_DST_COLOR,[YCe]:t.ONE_MINUS_DST_ALPHA,[eNe]:t.CONSTANT_COLOR,[tNe]:t.ONE_MINUS_CONSTANT_COLOR,[nNe]:t.CONSTANT_ALPHA,[rNe]:t.ONE_MINUS_CONSTANT_ALPHA};function z(fe,Qe,ge,ze,ke,ve,de,ot,xt,Et){if(fe===Ec){v===!0&&(Re(t.BLEND),v=!1);return}if(v===!1&&(be(t.BLEND),v=!0),fe!==zCe){if(fe!==y||Et!==N){if((b!==fh||A!==fh)&&(t.blendEquation(t.FUNC_ADD),b=fh,A=fh),Et)switch(fe){case sp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case H6:t.blendFunc(t.ONE,t.ONE);break;case $6:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case V6:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Hr("WebGLState: Invalid blending: ",fe);break}else switch(fe){case sp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case H6:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case $6:Hr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case V6:Hr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Hr("WebGLState: Invalid blending: ",fe);break}E=null,w=null,T=null,C=null,k.set(0,0,0),F=0,y=fe,N=Et}return}ke=ke||Qe,ve=ve||ge,de=de||ze,(Qe!==b||ke!==A)&&(t.blendEquationSeparate(ce[Qe],ce[ke]),b=Qe,A=ke),(ge!==E||ze!==w||ve!==T||de!==C)&&(t.blendFuncSeparate(Ie[ge],Ie[ze],Ie[ve],Ie[de]),E=ge,w=ze,T=ve,C=de),(ot.equals(k)===!1||xt!==F)&&(t.blendColor(ot.r,ot.g,ot.b,xt),k.copy(ot),F=xt),y=fe,N=!1}function B(fe,Qe){fe.side===rl?Re(t.CULL_FACE):be(t.CULL_FACE);let ge=fe.side===Za;Qe&&(ge=!ge),ne(ge),fe.blending===sp&&fe.transparent===!1?z(Ec):z(fe.blending,fe.blendEquation,fe.blendSrc,fe.blendDst,fe.blendEquationAlpha,fe.blendSrcAlpha,fe.blendDstAlpha,fe.blendColor,fe.blendAlpha,fe.premultipliedAlpha),s.setFunc(fe.depthFunc),s.setTest(fe.depthTest),s.setMask(fe.depthWrite),a.setMask(fe.colorWrite);const ze=fe.stencilWrite;o.setTest(ze),ze&&(o.setMask(fe.stencilWriteMask),o.setFunc(fe.stencilFunc,fe.stencilRef,fe.stencilFuncMask),o.setOp(fe.stencilFail,fe.stencilZFail,fe.stencilZPass)),se(fe.polygonOffset,fe.polygonOffsetFactor,fe.polygonOffsetUnits),fe.alphaToCoverage===!0?be(t.SAMPLE_ALPHA_TO_COVERAGE):Re(t.SAMPLE_ALPHA_TO_COVERAGE)}function ne(fe){j!==fe&&(fe?t.frontFace(t.CW):t.frontFace(t.CCW),j=fe)}function V(fe){fe!==ICe?(be(t.CULL_FACE),fe!==I&&(fe===B6?t.cullFace(t.BACK):fe===FCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Re(t.CULL_FACE),I=fe}function Q(fe){fe!==O&&(K&&t.lineWidth(fe),O=fe)}function se(fe,Qe,ge){fe?(be(t.POLYGON_OFFSET_FILL),(q!==Qe||R!==ge)&&(t.polygonOffset(Qe,ge),q=Qe,R=ge)):Re(t.POLYGON_OFFSET_FILL)}function Me(fe){fe?be(t.SCISSOR_TEST):Re(t.SCISSOR_TEST)}function Ae(fe){fe===void 0&&(fe=t.TEXTURE0+W-1),Y!==fe&&(t.activeTexture(fe),Y=fe)}function Se(fe,Qe,ge){ge===void 0&&(Y===null?ge=t.TEXTURE0+W-1:ge=Y);let ze=J[ge];ze===void 0&&(ze={type:void 0,texture:void 0},J[ge]=ze),(ze.type!==fe||ze.texture!==Qe)&&(Y!==ge&&(t.activeTexture(ge),Y=ge),t.bindTexture(fe,Qe||ue[fe]),ze.type=fe,ze.texture=Qe)}function $(){const fe=J[Y];fe!==void 0&&fe.type!==void 0&&(t.bindTexture(fe.type,null),fe.type=void 0,fe.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function re(){try{t.compressedTexImage3D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function ye(){try{t.texSubImage2D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function we(){try{t.texSubImage3D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function xe(){try{t.compressedTexSubImage2D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function rt(){try{t.compressedTexSubImage3D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function He(){try{t.texStorage2D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function he(){try{t.texStorage3D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function Ge(){try{t.texImage2D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function Ue(){try{t.texImage3D(...arguments)}catch(fe){fe("WebGLState:",fe)}}function oe(fe){ee.equals(fe)===!1&&(t.scissor(fe.x,fe.y,fe.z,fe.w),ee.copy(fe))}function tt(fe){ie.equals(fe)===!1&&(t.viewport(fe.x,fe.y,fe.z,fe.w),ie.copy(fe))}function $e(fe,Qe){let ge=u.get(Qe);ge===void 0&&(ge=new WeakMap,u.set(Qe,ge));let ze=ge.get(fe);ze===void 0&&(ze=t.getUniformBlockIndex(Qe,fe.name),ge.set(fe,ze))}function Ye(fe,Qe){const ze=u.get(Qe).get(fe);c.get(Qe)!==ze&&(t.uniformBlockBinding(Qe,ze,fe.__bindingPointIndex),c.set(Qe,ze))}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),s.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Y=null,J={},f={},g=new WeakMap,p=[],x=null,v=!1,y=null,b=null,E=null,w=null,A=null,T=null,C=null,k=new _n(0,0,0),F=0,N=!1,j=null,I=null,O=null,q=null,R=null,ee.set(0,0,t.canvas.width,t.canvas.height),ie.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:be,disable:Re,bindFramebuffer:Z,drawBuffers:_e,useProgram:Le,setBlending:z,setMaterial:B,setFlipSided:ne,setCullFace:V,setLineWidth:Q,setPolygonOffset:se,setScissorTest:Me,activeTexture:Ae,bindTexture:Se,unbindTexture:$,compressedTexImage2D:L,compressedTexImage3D:re,texImage2D:Ge,texImage3D:Ue,updateUBOMapping:$e,uniformBlockBinding:Ye,texStorage2D:He,texStorage3D:he,texSubImage2D:ye,texSubImage3D:we,compressedTexSubImage2D:xe,compressedTexSubImage3D:rt,scissor:oe,viewport:tt,reset:ut}}function $je(t,e,n,r,i,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new cn,d=new WeakMap;let f;const g=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x($,L){return p?new OffscreenCanvas($,L):Ow("canvas")}function v($,L,re){let ye=1;const we=Se($);if((we.width>re||we.height>re)&&(ye=re/Math.max(we.width,we.height)),ye<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const xe=Math.floor(ye*we.width),rt=Math.floor(ye*we.height);f===void 0&&(f=x(xe,rt));const He=L?x(xe,rt):f;return He.width=xe,He.height=rt,He.getContext("2d").drawImage($,0,0,xe,rt),Yt("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+xe+"x"+rt+")."),He}else return"data"in $&&Yt("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),$;return $}function y($){return $.generateMipmaps}function b($){t.generateMipmap($)}function E($){return $.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:$.isWebGL3DRenderTarget?t.TEXTURE_3D:$.isWebGLArrayRenderTarget||$.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w($,L,re,ye,we=!1){if($!==null){if(t[$]!==void 0)return t[$];Yt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let xe=L;if(L===t.RED&&(re===t.FLOAT&&(xe=t.R32F),re===t.HALF_FLOAT&&(xe=t.R16F),re===t.UNSIGNED_BYTE&&(xe=t.R8)),L===t.RED_INTEGER&&(re===t.UNSIGNED_BYTE&&(xe=t.R8UI),re===t.UNSIGNED_SHORT&&(xe=t.R16UI),re===t.UNSIGNED_INT&&(xe=t.R32UI),re===t.BYTE&&(xe=t.R8I),re===t.SHORT&&(xe=t.R16I),re===t.INT&&(xe=t.R32I)),L===t.RG&&(re===t.FLOAT&&(xe=t.RG32F),re===t.HALF_FLOAT&&(xe=t.RG16F),re===t.UNSIGNED_BYTE&&(xe=t.RG8)),L===t.RG_INTEGER&&(re===t.UNSIGNED_BYTE&&(xe=t.RG8UI),re===t.UNSIGNED_SHORT&&(xe=t.RG16UI),re===t.UNSIGNED_INT&&(xe=t.RG32UI),re===t.BYTE&&(xe=t.RG8I),re===t.SHORT&&(xe=t.RG16I),re===t.INT&&(xe=t.RG32I)),L===t.RGB_INTEGER&&(re===t.UNSIGNED_BYTE&&(xe=t.RGB8UI),re===t.UNSIGNED_SHORT&&(xe=t.RGB16UI),re===t.UNSIGNED_INT&&(xe=t.RGB32UI),re===t.BYTE&&(xe=t.RGB8I),re===t.SHORT&&(xe=t.RGB16I),re===t.INT&&(xe=t.RGB32I)),L===t.RGBA_INTEGER&&(re===t.UNSIGNED_BYTE&&(xe=t.RGBA8UI),re===t.UNSIGNED_SHORT&&(xe=t.RGBA16UI),re===t.UNSIGNED_INT&&(xe=t.RGBA32UI),re===t.BYTE&&(xe=t.RGBA8I),re===t.SHORT&&(xe=t.RGBA16I),re===t.INT&&(xe=t.RGBA32I)),L===t.RGB&&(re===t.UNSIGNED_INT_5_9_9_9_REV&&(xe=t.RGB9_E5),re===t.UNSIGNED_INT_10F_11F_11F_REV&&(xe=t.R11F_G11F_B10F)),L===t.RGBA){const rt=we?jw:Nn.getTransfer(ye);re===t.FLOAT&&(xe=t.RGBA32F),re===t.HALF_FLOAT&&(xe=t.RGBA16F),re===t.UNSIGNED_BYTE&&(xe=rt===Kn?t.SRGB8_ALPHA8:t.RGBA8),re===t.UNSIGNED_SHORT_4_4_4_4&&(xe=t.RGBA4),re===t.UNSIGNED_SHORT_5_5_5_1&&(xe=t.RGB5_A1)}return(xe===t.R16F||xe===t.R32F||xe===t.RG16F||xe===t.RG32F||xe===t.RGBA16F||xe===t.RGBA32F)&&e.get("EXT_color_buffer_float"),xe}function A($,L){let re;return $?L===null||L===nf||L===G0?re=t.DEPTH24_STENCIL8:L===bc?re=t.DEPTH32F_STENCIL8:L===V0&&(re=t.DEPTH24_STENCIL8,Yt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===nf||L===G0?re=t.DEPTH_COMPONENT24:L===bc?re=t.DEPTH_COMPONENT32F:L===V0&&(re=t.DEPTH_COMPONENT16),re}function T($,L){return y($)===!0||$.isFramebufferTexture&&$.minFilter!==Es&&$.minFilter!==io?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function C($){const L=$.target;L.removeEventListener("dispose",C),F(L),L.isVideoTexture&&d.delete(L)}function k($){const L=$.target;L.removeEventListener("dispose",k),j(L)}function F($){const L=r.get($);if(L.__webglInit===void 0)return;const re=$.source,ye=g.get(re);if(ye){const we=ye[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&N($),Object.keys(ye).length===0&&g.delete(re)}r.remove($)}function N($){const L=r.get($);t.deleteTexture(L.__webglTexture);const re=$.source,ye=g.get(re);delete ye[L.__cacheKey],s.memory.textures--}function j($){const L=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(L.__webglFramebuffer[ye]))for(let we=0;we<L.__webglFramebuffer[ye].length;we++)t.deleteFramebuffer(L.__webglFramebuffer[ye][we]);else t.deleteFramebuffer(L.__webglFramebuffer[ye]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ye])}else{if(Array.isArray(L.__webglFramebuffer))for(let ye=0;ye<L.__webglFramebuffer.length;ye++)t.deleteFramebuffer(L.__webglFramebuffer[ye]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ye=0;ye<L.__webglColorRenderbuffer.length;ye++)L.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ye]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const re=$.textures;for(let ye=0,we=re.length;ye<we;ye++){const xe=r.get(re[ye]);xe.__webglTexture&&(t.deleteTexture(xe.__webglTexture),s.memory.textures--),r.remove(re[ye])}r.remove($)}let I=0;function O(){I=0}function q(){const $=I;return $>=i.maxTextures&&Yt("WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+i.maxTextures),I+=1,$}function R($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function W($,L){const re=r.get($);if($.isVideoTexture&&Me($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&re.__version!==$.version){const ye=$.image;if(ye===null)Yt("WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)Yt("WebGLRenderer: Texture marked for update but image is incomplete");else{ue(re,$,L);return}}else $.isExternalTexture&&(re.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,re.__webglTexture,t.TEXTURE0+L)}function K($,L){const re=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&re.__version!==$.version){ue(re,$,L);return}else $.isExternalTexture&&(re.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,re.__webglTexture,t.TEXTURE0+L)}function G($,L){const re=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&re.__version!==$.version){ue(re,$,L);return}n.bindTexture(t.TEXTURE_3D,re.__webglTexture,t.TEXTURE0+L)}function te($,L){const re=r.get($);if($.version>0&&re.__version!==$.version){be(re,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,re.__webglTexture,t.TEXTURE0+L)}const Y={[eP]:t.REPEAT,[xc]:t.CLAMP_TO_EDGE,[tP]:t.MIRRORED_REPEAT},J={[Es]:t.NEAREST,[fNe]:t.NEAREST_MIPMAP_NEAREST,[Iv]:t.NEAREST_MIPMAP_LINEAR,[io]:t.LINEAR,[yC]:t.LINEAR_MIPMAP_NEAREST,[Sh]:t.LINEAR_MIPMAP_LINEAR},U={[xNe]:t.NEVER,[SNe]:t.ALWAYS,[bNe]:t.LESS,[tZ]:t.LEQUAL,[yNe]:t.EQUAL,[wNe]:t.GEQUAL,[vNe]:t.GREATER,[_Ne]:t.NOTEQUAL};function H($,L){if(L.type===bc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===io||L.magFilter===yC||L.magFilter===Iv||L.magFilter===Sh||L.minFilter===io||L.minFilter===yC||L.minFilter===Iv||L.minFilter===Sh)&&Yt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri($,t.TEXTURE_WRAP_S,Y[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,Y[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,Y[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,J[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,J[L.minFilter]),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,U[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===Es||L.minFilter!==Iv&&L.minFilter!==Sh||L.type===bc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const re=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,re.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ee($,L){let re=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",C));const ye=L.source;let we=g.get(ye);we===void 0&&(we={},g.set(ye,we));const xe=R(L);if(xe!==$.__cacheKey){we[xe]===void 0&&(we[xe]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,re=!0),we[xe].usedTimes++;const rt=we[$.__cacheKey];rt!==void 0&&(we[$.__cacheKey].usedTimes--,rt.usedTimes===0&&N(L)),$.__cacheKey=xe,$.__webglTexture=we[xe].texture}return re}function ie($,L,re){return Math.floor(Math.floor($/re)/L)}function pe($,L,re,ye){const xe=$.updateRanges;if(xe.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,re,ye,L.data);else{xe.sort((Ue,oe)=>Ue.start-oe.start);let rt=0;for(let Ue=1;Ue<xe.length;Ue++){const oe=xe[rt],tt=xe[Ue],$e=oe.start+oe.count,Ye=ie(tt.start,L.width,4),ut=ie(oe.start,L.width,4);tt.start<=$e+1&&Ye===ut&&ie(tt.start+tt.count-1,L.width,4)===Ye?oe.count=Math.max(oe.count,tt.start+tt.count-oe.start):(++rt,xe[rt]=tt)}xe.length=rt+1;const He=t.getParameter(t.UNPACK_ROW_LENGTH),he=t.getParameter(t.UNPACK_SKIP_PIXELS),Ge=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Ue=0,oe=xe.length;Ue<oe;Ue++){const tt=xe[Ue],$e=Math.floor(tt.start/4),Ye=Math.ceil(tt.count/4),ut=$e%L.width,fe=Math.floor($e/L.width),Qe=Ye,ge=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ut),t.pixelStorei(t.UNPACK_SKIP_ROWS,fe),n.texSubImage2D(t.TEXTURE_2D,0,ut,fe,Qe,ge,re,ye,L.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,He),t.pixelStorei(t.UNPACK_SKIP_PIXELS,he),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ge)}}function ue($,L,re){let ye=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ye=t.TEXTURE_3D);const we=ee($,L),xe=L.source;n.bindTexture(ye,$.__webglTexture,t.TEXTURE0+re);const rt=r.get(xe);if(xe.version!==rt.__version||we===!0){n.activeTexture(t.TEXTURE0+re);const He=Nn.getPrimaries(Nn.workingColorSpace),he=L.colorSpace===$u?null:Nn.getPrimaries(L.colorSpace),Ge=L.colorSpace===$u||He===he?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,Ge);let Ue=v(L.image,!1,i.maxTextureSize);Ue=Ae(L,Ue);const oe=a.convert(L.format,L.colorSpace),tt=a.convert(L.type);let $e=w(L.internalFormat,oe,tt,L.colorSpace,L.isVideoTexture);H(ye,L);let Ye;const ut=L.mipmaps,fe=L.isVideoTexture!==!0,Qe=rt.__version===void 0||we===!0,ge=xe.dataReady,ze=T(L,Ue);if(L.isDepthTexture)$e=A(L.format===q0,L.type),Qe&&(fe?n.texStorage2D(t.TEXTURE_2D,1,$e,Ue.width,Ue.height):n.texImage2D(t.TEXTURE_2D,0,$e,Ue.width,Ue.height,0,oe,tt,null));else if(L.isDataTexture)if(ut.length>0){fe&&Qe&&n.texStorage2D(t.TEXTURE_2D,ze,$e,ut[0].width,ut[0].height);for(let ke=0,ve=ut.length;ke<ve;ke++)Ye=ut[ke],fe?ge&&n.texSubImage2D(t.TEXTURE_2D,ke,0,0,Ye.width,Ye.height,oe,tt,Ye.data):n.texImage2D(t.TEXTURE_2D,ke,$e,Ye.width,Ye.height,0,oe,tt,Ye.data);L.generateMipmaps=!1}else fe?(Qe&&n.texStorage2D(t.TEXTURE_2D,ze,$e,Ue.width,Ue.height),ge&&pe(L,Ue,oe,tt)):n.texImage2D(t.TEXTURE_2D,0,$e,Ue.width,Ue.height,0,oe,tt,Ue.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){fe&&Qe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,$e,ut[0].width,ut[0].height,Ue.depth);for(let ke=0,ve=ut.length;ke<ve;ke++)if(Ye=ut[ke],L.format!==jo)if(oe!==null)if(fe){if(ge)if(L.layerUpdates.size>0){const de=vH(Ye.width,Ye.height,L.format,L.type);for(const ot of L.layerUpdates){const xt=Ye.data.subarray(ot*de/Ye.data.BYTES_PER_ELEMENT,(ot+1)*de/Ye.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ke,0,0,ot,Ye.width,Ye.height,1,oe,xt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ke,0,0,0,Ye.width,Ye.height,Ue.depth,oe,Ye.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ke,$e,Ye.width,Ye.height,Ue.depth,0,Ye.data,0,0);else Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else fe?ge&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,ke,0,0,0,Ye.width,Ye.height,Ue.depth,oe,tt,Ye.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ke,$e,Ye.width,Ye.height,Ue.depth,0,oe,tt,Ye.data)}else{fe&&Qe&&n.texStorage2D(t.TEXTURE_2D,ze,$e,ut[0].width,ut[0].height);for(let ke=0,ve=ut.length;ke<ve;ke++)Ye=ut[ke],L.format!==jo?oe!==null?fe?ge&&n.compressedTexSubImage2D(t.TEXTURE_2D,ke,0,0,Ye.width,Ye.height,oe,Ye.data):n.compressedTexImage2D(t.TEXTURE_2D,ke,$e,Ye.width,Ye.height,0,Ye.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):fe?ge&&n.texSubImage2D(t.TEXTURE_2D,ke,0,0,Ye.width,Ye.height,oe,tt,Ye.data):n.texImage2D(t.TEXTURE_2D,ke,$e,Ye.width,Ye.height,0,oe,tt,Ye.data)}else if(L.isDataArrayTexture)if(fe){if(Qe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,$e,Ue.width,Ue.height,Ue.depth),ge)if(L.layerUpdates.size>0){const ke=vH(Ue.width,Ue.height,L.format,L.type);for(const ve of L.layerUpdates){const de=Ue.data.subarray(ve*ke/Ue.data.BYTES_PER_ELEMENT,(ve+1)*ke/Ue.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ve,Ue.width,Ue.height,1,oe,tt,de)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ue.width,Ue.height,Ue.depth,oe,tt,Ue.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,$e,Ue.width,Ue.height,Ue.depth,0,oe,tt,Ue.data);else if(L.isData3DTexture)fe?(Qe&&n.texStorage3D(t.TEXTURE_3D,ze,$e,Ue.width,Ue.height,Ue.depth),ge&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ue.width,Ue.height,Ue.depth,oe,tt,Ue.data)):n.texImage3D(t.TEXTURE_3D,0,$e,Ue.width,Ue.height,Ue.depth,0,oe,tt,Ue.data);else if(L.isFramebufferTexture){if(Qe)if(fe)n.texStorage2D(t.TEXTURE_2D,ze,$e,Ue.width,Ue.height);else{let ke=Ue.width,ve=Ue.height;for(let de=0;de<ze;de++)n.texImage2D(t.TEXTURE_2D,de,$e,ke,ve,0,oe,tt,null),ke>>=1,ve>>=1}}else if(ut.length>0){if(fe&&Qe){const ke=Se(ut[0]);n.texStorage2D(t.TEXTURE_2D,ze,$e,ke.width,ke.height)}for(let ke=0,ve=ut.length;ke<ve;ke++)Ye=ut[ke],fe?ge&&n.texSubImage2D(t.TEXTURE_2D,ke,0,0,oe,tt,Ye):n.texImage2D(t.TEXTURE_2D,ke,$e,oe,tt,Ye);L.generateMipmaps=!1}else if(fe){if(Qe){const ke=Se(Ue);n.texStorage2D(t.TEXTURE_2D,ze,$e,ke.width,ke.height)}ge&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe,tt,Ue)}else n.texImage2D(t.TEXTURE_2D,0,$e,oe,tt,Ue);y(L)&&b(ye),rt.__version=xe.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function be($,L,re){if(L.image.length!==6)return;const ye=ee($,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+re);const xe=r.get(we);if(we.version!==xe.__version||ye===!0){n.activeTexture(t.TEXTURE0+re);const rt=Nn.getPrimaries(Nn.workingColorSpace),He=L.colorSpace===$u?null:Nn.getPrimaries(L.colorSpace),he=L.colorSpace===$u||rt===He?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,he);const Ge=L.isCompressedTexture||L.image[0].isCompressedTexture,Ue=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let ve=0;ve<6;ve++)!Ge&&!Ue?oe[ve]=v(L.image[ve],!0,i.maxCubemapSize):oe[ve]=Ue?L.image[ve].image:L.image[ve],oe[ve]=Ae(L,oe[ve]);const tt=oe[0],$e=a.convert(L.format,L.colorSpace),Ye=a.convert(L.type),ut=w(L.internalFormat,$e,Ye,L.colorSpace),fe=L.isVideoTexture!==!0,Qe=xe.__version===void 0||ye===!0,ge=we.dataReady;let ze=T(L,tt);H(t.TEXTURE_CUBE_MAP,L);let ke;if(Ge){fe&&Qe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ut,tt.width,tt.height);for(let ve=0;ve<6;ve++){ke=oe[ve].mipmaps;for(let de=0;de<ke.length;de++){const ot=ke[de];L.format!==jo?$e!==null?fe?ge&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,0,0,ot.width,ot.height,$e,ot.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,ut,ot.width,ot.height,0,ot.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):fe?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,0,0,ot.width,ot.height,$e,Ye,ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,ut,ot.width,ot.height,0,$e,Ye,ot.data)}}}else{if(ke=L.mipmaps,fe&&Qe){ke.length>0&&ze++;const ve=Se(oe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ut,ve.width,ve.height)}for(let ve=0;ve<6;ve++)if(Ue){fe?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,oe[ve].width,oe[ve].height,$e,Ye,oe[ve].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,ut,oe[ve].width,oe[ve].height,0,$e,Ye,oe[ve].data);for(let de=0;de<ke.length;de++){const xt=ke[de].image[ve].image;fe?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,0,0,xt.width,xt.height,$e,Ye,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,ut,xt.width,xt.height,0,$e,Ye,xt.data)}}else{fe?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,$e,Ye,oe[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,ut,$e,Ye,oe[ve]);for(let de=0;de<ke.length;de++){const ot=ke[de];fe?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,0,0,$e,Ye,ot.image[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,ut,$e,Ye,ot.image[ve])}}}y(L)&&b(t.TEXTURE_CUBE_MAP),xe.__version=we.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Re($,L,re,ye,we,xe){const rt=a.convert(re.format,re.colorSpace),He=a.convert(re.type),he=w(re.internalFormat,rt,He,re.colorSpace),Ge=r.get(L),Ue=r.get(re);if(Ue.__renderTarget=L,!Ge.__hasExternalTextures){const oe=Math.max(1,L.width>>xe),tt=Math.max(1,L.height>>xe);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,xe,he,oe,tt,L.depth,0,rt,He,null):n.texImage2D(we,xe,he,oe,tt,0,rt,He,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,we,Ue.__webglTexture,0,Q(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,we,Ue.__webglTexture,xe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function Z($,L,re){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer){const ye=L.depthTexture,we=ye&&ye.isDepthTexture?ye.type:null,xe=A(L.stencilBuffer,we),rt=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,He=Q(L);se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,He,xe,L.width,L.height):re?t.renderbufferStorageMultisample(t.RENDERBUFFER,He,xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,xe,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,rt,t.RENDERBUFFER,$)}else{const ye=L.textures;for(let we=0;we<ye.length;we++){const xe=ye[we],rt=a.convert(xe.format,xe.colorSpace),He=a.convert(xe.type),he=w(xe.internalFormat,rt,He,xe.colorSpace),Ge=Q(L);re&&se(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ge,he,L.width,L.height):se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ge,he,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,he,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function _e($,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ye=r.get(L.depthTexture);ye.__renderTarget=L,(!ye.__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),W(L.depthTexture,0);const we=ye.__webglTexture,xe=Q(L);if(L.depthTexture.format===W0)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0,xe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0);else if(L.depthTexture.format===q0)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0,xe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function Le($){const L=r.get($),re=$.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==$.depthTexture){const ye=$.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ye){const we=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ye.removeEventListener("dispose",we)};ye.addEventListener("dispose",we),L.__depthDisposeCallback=we}L.__boundDepthTexture=ye}if($.depthTexture&&!L.__autoAllocateDepthBuffer){if(re)throw new Error("target.depthTexture not supported in Cube render targets");const ye=$.texture.mipmaps;ye&&ye.length>0?_e(L.__webglFramebuffer[0],$):_e(L.__webglFramebuffer,$)}else if(re){L.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ye]),L.__webglDepthbuffer[ye]===void 0)L.__webglDepthbuffer[ye]=t.createRenderbuffer(),Z(L.__webglDepthbuffer[ye],$,!1);else{const we=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,xe=L.__webglDepthbuffer[ye];t.bindRenderbuffer(t.RENDERBUFFER,xe),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,xe)}}else{const ye=$.texture.mipmaps;if(ye&&ye.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),Z(L.__webglDepthbuffer,$,!1);else{const we=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,xe=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,xe),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,xe)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ce($,L,re){const ye=r.get($);L!==void 0&&Re(ye.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),re!==void 0&&Le($)}function Ie($){const L=$.texture,re=r.get($),ye=r.get(L);$.addEventListener("dispose",k);const we=$.textures,xe=$.isWebGLCubeRenderTarget===!0,rt=we.length>1;if(rt||(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=L.version,s.memory.textures++),xe){re.__webglFramebuffer=[];for(let He=0;He<6;He++)if(L.mipmaps&&L.mipmaps.length>0){re.__webglFramebuffer[He]=[];for(let he=0;he<L.mipmaps.length;he++)re.__webglFramebuffer[He][he]=t.createFramebuffer()}else re.__webglFramebuffer[He]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){re.__webglFramebuffer=[];for(let He=0;He<L.mipmaps.length;He++)re.__webglFramebuffer[He]=t.createFramebuffer()}else re.__webglFramebuffer=t.createFramebuffer();if(rt)for(let He=0,he=we.length;He<he;He++){const Ge=r.get(we[He]);Ge.__webglTexture===void 0&&(Ge.__webglTexture=t.createTexture(),s.memory.textures++)}if($.samples>0&&se($)===!1){re.__webglMultisampledFramebuffer=t.createFramebuffer(),re.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,re.__webglMultisampledFramebuffer);for(let He=0;He<we.length;He++){const he=we[He];re.__webglColorRenderbuffer[He]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,re.__webglColorRenderbuffer[He]);const Ge=a.convert(he.format,he.colorSpace),Ue=a.convert(he.type),oe=w(he.internalFormat,Ge,Ue,he.colorSpace,$.isXRRenderTarget===!0),tt=Q($);t.renderbufferStorageMultisample(t.RENDERBUFFER,tt,oe,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+He,t.RENDERBUFFER,re.__webglColorRenderbuffer[He])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(re.__webglDepthRenderbuffer=t.createRenderbuffer(),Z(re.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(xe){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),H(t.TEXTURE_CUBE_MAP,L);for(let He=0;He<6;He++)if(L.mipmaps&&L.mipmaps.length>0)for(let he=0;he<L.mipmaps.length;he++)Re(re.__webglFramebuffer[He][he],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+He,he);else Re(re.__webglFramebuffer[He],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+He,0);y(L)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(rt){for(let He=0,he=we.length;He<he;He++){const Ge=we[He],Ue=r.get(Ge);let oe=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(oe=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(oe,Ue.__webglTexture),H(oe,Ge),Re(re.__webglFramebuffer,$,Ge,t.COLOR_ATTACHMENT0+He,oe,0),y(Ge)&&b(oe)}n.unbindTexture()}else{let He=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(He=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(He,ye.__webglTexture),H(He,L),L.mipmaps&&L.mipmaps.length>0)for(let he=0;he<L.mipmaps.length;he++)Re(re.__webglFramebuffer[he],$,L,t.COLOR_ATTACHMENT0,He,he);else Re(re.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,He,0);y(L)&&b(He),n.unbindTexture()}$.depthBuffer&&Le($)}function z($){const L=$.textures;for(let re=0,ye=L.length;re<ye;re++){const we=L[re];if(y(we)){const xe=E($),rt=r.get(we).__webglTexture;n.bindTexture(xe,rt),b(xe),n.unbindTexture()}}}const B=[],ne=[];function V($){if($.samples>0){if(se($)===!1){const L=$.textures,re=$.width,ye=$.height;let we=t.COLOR_BUFFER_BIT;const xe=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,rt=r.get($),He=L.length>1;if(He)for(let Ge=0;Ge<L.length;Ge++)n.bindFramebuffer(t.FRAMEBUFFER,rt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,rt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,rt.__webglMultisampledFramebuffer);const he=$.texture.mipmaps;he&&he.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,rt.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,rt.__webglFramebuffer);for(let Ge=0;Ge<L.length;Ge++){if($.resolveDepthBuffer&&($.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),He){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,rt.__webglColorRenderbuffer[Ge]);const Ue=r.get(L[Ge]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ue,0)}t.blitFramebuffer(0,0,re,ye,0,0,re,ye,we,t.NEAREST),c===!0&&(B.length=0,ne.length=0,B.push(t.COLOR_ATTACHMENT0+Ge),$.depthBuffer&&$.resolveDepthBuffer===!1&&(B.push(xe),ne.push(xe),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ne)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,B))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),He)for(let Ge=0;Ge<L.length;Ge++){n.bindFramebuffer(t.FRAMEBUFFER,rt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.RENDERBUFFER,rt.__webglColorRenderbuffer[Ge]);const Ue=r.get(L[Ge]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,rt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.TEXTURE_2D,Ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,rt.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const L=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function Q($){return Math.min(i.maxSamples,$.samples)}function se($){const L=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Me($){const L=s.render.frame;d.get($)!==L&&(d.set($,L),$.update())}function Ae($,L){const re=$.colorSpace,ye=$.format,we=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||re!==jp&&re!==$u&&(Nn.getTransfer(re)===Kn?(ye!==jo||we!==xl)&&Yt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Hr("WebGLTextures: Unsupported texture color space:",re)),L}function Se($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=te,this.rebindTextures=ce,this.setupRenderTarget=Ie,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=V,this.setupDepthRenderbuffer=Le,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=se}function Vje(t,e){function n(r,i=$u){let a;const s=Nn.getTransfer(i);if(r===xl)return t.UNSIGNED_BYTE;if(r===cO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===uO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===XY)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===YY)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===qY)return t.BYTE;if(r===KY)return t.SHORT;if(r===V0)return t.UNSIGNED_SHORT;if(r===lO)return t.INT;if(r===nf)return t.UNSIGNED_INT;if(r===bc)return t.FLOAT;if(r===ug)return t.HALF_FLOAT;if(r===ZY)return t.ALPHA;if(r===QY)return t.RGB;if(r===jo)return t.RGBA;if(r===W0)return t.DEPTH_COMPONENT;if(r===q0)return t.DEPTH_STENCIL;if(r===JY)return t.RED;if(r===dO)return t.RED_INTEGER;if(r===hO)return t.RG;if(r===fO)return t.RG_INTEGER;if(r===mO)return t.RGBA_INTEGER;if(r===c1||r===u1||r===d1||r===h1)if(s===Kn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===c1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===u1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===d1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===h1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===c1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===u1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===d1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===h1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===nP||r===rP||r===iP||r===aP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===nP)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===rP)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===iP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===aP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===sP||r===oP||r===lP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===sP||r===oP)return s===Kn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===lP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===cP||r===uP||r===dP||r===hP||r===fP||r===mP||r===pP||r===gP||r===xP||r===bP||r===yP||r===vP||r===_P||r===wP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===cP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===uP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===dP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===hP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===fP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===mP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===pP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===gP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===xP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===bP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===yP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===vP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===_P)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===wP)return s===Kn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===SP||r===MP||r===EP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===SP)return s===Kn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===MP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===EP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===AP||r===TP||r===CP||r===NP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===AP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===TP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===CP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===NP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===G0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const Gje=`
  3860. void main() {
  3861. gl_Position = vec4( position, 1.0 );
  3862. }`,Wje=`
  3863. uniform sampler2DArray depthColor;
  3864. uniform float depthWidth;
  3865. uniform float depthHeight;
  3866. void main() {
  3867. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3868. if ( coord.x >= 1.0 ) {
  3869. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3870. } else {
  3871. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3872. }
  3873. }`;class qje{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new vZ(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 zc({vertexShader:Gje,fragmentShader:Wje,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new bl(new vO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let Kje=class extends xf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const v=typeof XRWebGLBinding<"u",y=new qje,b={},E=n.getContextAttributes();let w=null,A=null;const T=[],C=[],k=new cn;let F=null;const N=new Zs;N.viewport=new ei;const j=new Zs;j.viewport=new ei;const I=[N,j],O=new dke;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ue){let be=T[ue];return be===void 0&&(be=new BC,T[ue]=be),be.getTargetRaySpace()},this.getControllerGrip=function(ue){let be=T[ue];return be===void 0&&(be=new BC,T[ue]=be),be.getGripSpace()},this.getHand=function(ue){let be=T[ue];return be===void 0&&(be=new BC,T[ue]=be),be.getHandSpace()};function W(ue){const be=C.indexOf(ue.inputSource);if(be===-1)return;const Re=T[be];Re!==void 0&&(Re.update(ue.inputSource,ue.frame,u||s),Re.dispatchEvent({type:ue.type,data:ue.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",G);for(let ue=0;ue<T.length;ue++){const be=C[ue];be!==null&&(C[ue]=null,T[ue].disconnect(be))}q=null,R=null,y.reset();for(const ue in b)delete b[ue];e.setRenderTarget(w),p=null,g=null,f=null,i=null,A=null,pe.stop(),r.isPresenting=!1,e.setPixelRatio(F),e.setSize(k.width,k.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ue){a=ue,r.isPresenting===!0&&Yt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ue){o=ue,r.isPresenting===!0&&Yt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(ue){u=ue},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ue){if(i=ue,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",G),E.xrCompatible!==!0&&await n.makeXRCompatible(),F=e.getPixelRatio(),e.getSize(k),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Re=null,Z=null,_e=null;E.depth&&(_e=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Re=E.stencil?q0:W0,Z=E.stencil?G0:nf);const Le={colorFormat:n.RGBA8,depthFormat:_e,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(Le),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new af(g.textureWidth,g.textureHeight,{format:jo,type:xl,depthTexture:new yZ(g.textureWidth,g.textureHeight,Z,void 0,void 0,void 0,void 0,void 0,void 0,Re),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Re={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Re),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new af(p.framebufferWidth,p.framebufferHeight,{format:jo,type:xl,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(o),pe.setContext(i),pe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function G(ue){for(let be=0;be<ue.removed.length;be++){const Re=ue.removed[be],Z=C.indexOf(Re);Z>=0&&(C[Z]=null,T[Z].disconnect(Re))}for(let be=0;be<ue.added.length;be++){const Re=ue.added[be];let Z=C.indexOf(Re);if(Z===-1){for(let Le=0;Le<T.length;Le++)if(Le>=C.length){C.push(Re),Z=Le;break}else if(C[Le]===null){C[Le]=Re,Z=Le;break}if(Z===-1)break}const _e=T[Z];_e&&_e.connect(Re)}}const te=new et,Y=new et;function J(ue,be,Re){te.setFromMatrixPosition(be.matrixWorld),Y.setFromMatrixPosition(Re.matrixWorld);const Z=te.distanceTo(Y),_e=be.projectionMatrix.elements,Le=Re.projectionMatrix.elements,ce=_e[14]/(_e[10]-1),Ie=_e[14]/(_e[10]+1),z=(_e[9]+1)/_e[5],B=(_e[9]-1)/_e[5],ne=(_e[8]-1)/_e[0],V=(Le[8]+1)/Le[0],Q=ce*ne,se=ce*V,Me=Z/(-ne+V),Ae=Me*-ne;if(be.matrixWorld.decompose(ue.position,ue.quaternion,ue.scale),ue.translateX(Ae),ue.translateZ(Me),ue.matrixWorld.compose(ue.position,ue.quaternion,ue.scale),ue.matrixWorldInverse.copy(ue.matrixWorld).invert(),_e[10]===-1)ue.projectionMatrix.copy(be.projectionMatrix),ue.projectionMatrixInverse.copy(be.projectionMatrixInverse);else{const Se=ce+Me,$=Ie+Me,L=Q-Ae,re=se+(Z-Ae),ye=z*Ie/$*Se,we=B*Ie/$*Se;ue.projectionMatrix.makePerspective(L,re,ye,we,Se,$),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert()}}function U(ue,be){be===null?ue.matrixWorld.copy(ue.matrix):ue.matrixWorld.multiplyMatrices(be.matrixWorld,ue.matrix),ue.matrixWorldInverse.copy(ue.matrixWorld).invert()}this.updateCamera=function(ue){if(i===null)return;let be=ue.near,Re=ue.far;y.texture!==null&&(y.depthNear>0&&(be=y.depthNear),y.depthFar>0&&(Re=y.depthFar)),O.near=j.near=N.near=be,O.far=j.far=N.far=Re,(q!==O.near||R!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,R=O.far),O.layers.mask=ue.layers.mask|6,N.layers.mask=O.layers.mask&3,j.layers.mask=O.layers.mask&5;const Z=ue.parent,_e=O.cameras;U(O,Z);for(let Le=0;Le<_e.length;Le++)U(_e[Le],Z);_e.length===2?J(O,N,j):O.projectionMatrix.copy(N.projectionMatrix),H(ue,O,Z)};function H(ue,be,Re){Re===null?ue.matrix.copy(be.matrixWorld):(ue.matrix.copy(Re.matrixWorld),ue.matrix.invert(),ue.matrix.multiply(be.matrixWorld)),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.updateMatrixWorld(!0),ue.projectionMatrix.copy(be.projectionMatrix),ue.projectionMatrixInverse.copy(be.projectionMatrixInverse),ue.isPerspectiveCamera&&(ue.fov=kP*2*Math.atan(1/ue.projectionMatrix.elements[5]),ue.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(ue){c=ue,g!==null&&(g.fixedFoveation=ue),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ue)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(O)},this.getCameraTexture=function(ue){return b[ue]};let ee=null;function ie(ue,be){if(d=be.getViewerPose(u||s),x=be,d!==null){const Re=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let Z=!1;Re.length!==O.cameras.length&&(O.cameras.length=0,Z=!0);for(let Ie=0;Ie<Re.length;Ie++){const z=Re[Ie];let B=null;if(p!==null)B=p.getViewport(z);else{const V=f.getViewSubImage(g,z);B=V.viewport,Ie===0&&(e.setRenderTargetTextures(A,V.colorTexture,V.depthStencilTexture),e.setRenderTarget(A))}let ne=I[Ie];ne===void 0&&(ne=new Zs,ne.layers.enable(Ie),ne.viewport=new ei,I[Ie]=ne),ne.matrix.fromArray(z.transform.matrix),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.projectionMatrix.fromArray(z.projectionMatrix),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert(),ne.viewport.set(B.x,B.y,B.width,B.height),Ie===0&&(O.matrix.copy(ne.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),Z===!0&&O.cameras.push(ne)}const _e=i.enabledFeatures;if(_e&&_e.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const Ie=f.getDepthInformation(Re[0]);Ie&&Ie.isValid&&Ie.texture&&y.init(Ie,i.renderState)}if(_e&&_e.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let Ie=0;Ie<Re.length;Ie++){const z=Re[Ie].camera;if(z){let B=b[z];B||(B=new vZ,b[z]=B);const ne=f.getCameraImage(z);B.sourceTexture=ne}}}}for(let Re=0;Re<T.length;Re++){const Z=C[Re],_e=T[Re];Z!==null&&_e!==void 0&&_e.update(Z,be,u||s)}ee&&ee(ue,be),be.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:be}),x=null}const pe=new MZ;pe.setAnimationLoop(ie),this.setAnimationLoop=function(ue){ee=ue},this.dispose=function(){}}};const eh=new yd,Xje=new ii;function Yje(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,pZ(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,E,w,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&p(y,b,A)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&o(y,b)):b.isPointsMaterial?c(y,b,E,w):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===Za&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===Za&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const E=e.get(b),w=E.envMap,A=E.envMapRotation;w&&(y.envMap.value=w,eh.copy(A),eh.x*=-1,eh.y*=-1,eh.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(eh.y*=-1,eh.z*=-1),y.envMapRotation.value.setFromMatrix4(Xje.makeRotationFromEuler(eh)),y.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap&&(y.lightMap.value=b.lightMap,y.lightMapIntensity.value=b.lightMapIntensity,n(b.lightMap,y.lightMapTransform)),b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function o(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,E,w){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*E,y.scale.value=w*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),b.envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function p(y,b,E){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Za&&y.clearcoatNormalScale.value.negate())),b.dispersion>0&&(y.dispersion.value=b.dispersion),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=E.texture,y.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const E=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(E.matrixWorld),y.nearDistance.value=E.shadow.camera.near,y.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Zje(t,e,n,r){let i={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",y));const T=w.program;r.updateUBOMapping(E,T);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),T=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<o;E++)if(s.indexOf(E)===-1)return s.push(E),E;return Hr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,k=A.length;C<k;C++){const F=Array.isArray(A[C])?A[C]:[A[C]];for(let N=0,j=F.length;N<j;N++){const I=F[N];if(p(I,C,N,T)===!0){const O=I.__offset,q=Array.isArray(I.value)?I.value:[I.value];let R=0;for(let W=0;W<q.length;W++){const K=q[W],G=v(K);typeof K=="number"||typeof K=="boolean"?(I.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,O+R,I.__data)):K.isMatrix3?(I.__data[0]=K.elements[0],I.__data[1]=K.elements[1],I.__data[2]=K.elements[2],I.__data[3]=0,I.__data[4]=K.elements[3],I.__data[5]=K.elements[4],I.__data[6]=K.elements[5],I.__data[7]=0,I.__data[8]=K.elements[6],I.__data[9]=K.elements[7],I.__data[10]=K.elements[8],I.__data[11]=0):(K.toArray(I.__data,R),R+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,I.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,A,T){const C=E.value,k=w+"_"+A;if(T[k]===void 0)return typeof C=="number"||typeof C=="boolean"?T[k]=C:T[k]=C.clone(),!0;{const F=T[k];if(typeof C=="number"||typeof C=="boolean"){if(F!==C)return T[k]=C,!0}else if(F.equals(C)===!1)return F.copy(C),!0}return!1}function x(E){const w=E.uniforms;let A=0;const T=16;for(let k=0,F=w.length;k<F;k++){const N=Array.isArray(w[k])?w[k]:[w[k]];for(let j=0,I=N.length;j<I;j++){const O=N[j],q=Array.isArray(O.value)?O.value:[O.value];for(let R=0,W=q.length;R<W;R++){const K=q[R],G=v(K),te=A%T,Y=te%G.boundary,J=te+Y;A+=Y,J!==0&&T-J<G.storage&&(A+=T-J),O.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=A,A+=G.storage}}}const C=A%T;return C>0&&(A+=T-C),E.__size=A,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?Yt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Yt("WebGLRenderer: Unsupported uniform value type.",E),w}function y(E){const w=E.target;w.removeEventListener("dispose",y);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}const Qje=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 Yl=null;function Jje(){return Yl===null&&(Yl=new JNe(Qje,32,32,hO,ug),Yl.minFilter=io,Yl.magFilter=io,Yl.wrapS=xc,Yl.wrapT=xc,Yl.generateMipmaps=!1,Yl.needsUpdate=!0),Yl}let eDe=class{constructor(e={}){const{canvas:n=MNe(),context:r=null,depth:i=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=s;const x=new Set([mO,fO,dO]),v=new Set([xl,nf,V0,G0,cO,uO]),y=new Uint32Array(4),b=new Int32Array(4);let E=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=td,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let k=!1;this._outputColorSpace=Ks;let F=0,N=0,j=null,I=-1,O=null;const q=new ei,R=new ei;let W=null;const K=new _n(0);let G=0,te=n.width,Y=n.height,J=1,U=null,H=null;const ee=new ei(0,0,te,Y),ie=new ei(0,0,te,Y);let pe=!1;const ue=new yO;let be=!1,Re=!1;const Z=new ii,_e=new et,Le=new ei,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ie=!1;function z(){return j===null?J:1}let B=r;function ne(ae,Ee){return n.getContext(ae,Ee)}try{const ae={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${sO}`),n.addEventListener("webglcontextlost",ke,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",de,!1),B===null){const Ee="webgl2";if(B=ne(Ee,ae),B===null)throw ne(Ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ae){throw ae("WebGLRenderer: "+ae.message),ae}let V,Q,se,Me,Ae,Se,$,L,re,ye,we,xe,rt,He,he,Ge,Ue,oe,tt,$e,Ye,ut,fe,Qe;function ge(){V=new lRe(B),V.init(),ut=new Vje(B,V),Q=new JPe(B,V,e,ut),se=new Hje(B,V),Q.reversedDepthBuffer&&g&&se.buffers.depth.setReversed(!0),Me=new dRe(B),Ae=new Nje,Se=new $je(B,V,se,Ae,Q,ut,Me),$=new tRe(C),L=new oRe(C),re=new pke(B),fe=new ZPe(B,re),ye=new cRe(B,re,Me,fe),we=new fRe(B,ye,re,Me),tt=new hRe(B,Q,Se),Ge=new eRe(Ae),xe=new Cje(C,$,L,V,Q,fe,Ge),rt=new Yje(C,Ae),He=new Pje,he=new Ije(V),oe=new YPe(C,$,L,se,we,p,c),Ue=new zje(C,we,Q),Qe=new Zje(B,Me,Q,se),$e=new QPe(B,V,Me),Ye=new uRe(B,V,Me),Me.programs=xe.programs,C.capabilities=Q,C.extensions=V,C.properties=Ae,C.renderLists=He,C.shadowMap=Ue,C.state=se,C.info=Me}ge();const ze=new Kje(C,B);this.xr=ze,this.getContext=function(){return B},this.getContextAttributes=function(){return B.getContextAttributes()},this.forceContextLoss=function(){const ae=V.get("WEBGL_lose_context");ae&&ae.loseContext()},this.forceContextRestore=function(){const ae=V.get("WEBGL_lose_context");ae&&ae.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(ae){ae!==void 0&&(J=ae,this.setSize(te,Y,!1))},this.getSize=function(ae){return ae.set(te,Y)},this.setSize=function(ae,Ee,Fe=!0){if(ze.isPresenting){Yt("WebGLRenderer: Can't change size while VR device is presenting.");return}te=ae,Y=Ee,n.width=Math.floor(ae*J),n.height=Math.floor(Ee*J),Fe===!0&&(n.style.width=ae+"px",n.style.height=Ee+"px"),this.setViewport(0,0,ae,Ee)},this.getDrawingBufferSize=function(ae){return ae.set(te*J,Y*J).floor()},this.setDrawingBufferSize=function(ae,Ee,Fe){te=ae,Y=Ee,J=Fe,n.width=Math.floor(ae*Fe),n.height=Math.floor(Ee*Fe),this.setViewport(0,0,ae,Ee)},this.getCurrentViewport=function(ae){return ae.copy(q)},this.getViewport=function(ae){return ae.copy(ee)},this.setViewport=function(ae,Ee,Fe,Oe){ae.isVector4?ee.set(ae.x,ae.y,ae.z,ae.w):ee.set(ae,Ee,Fe,Oe),se.viewport(q.copy(ee).multiplyScalar(J).round())},this.getScissor=function(ae){return ae.copy(ie)},this.setScissor=function(ae,Ee,Fe,Oe){ae.isVector4?ie.set(ae.x,ae.y,ae.z,ae.w):ie.set(ae,Ee,Fe,Oe),se.scissor(R.copy(ie).multiplyScalar(J).round())},this.getScissorTest=function(){return pe},this.setScissorTest=function(ae){se.setScissorTest(pe=ae)},this.setOpaqueSort=function(ae){U=ae},this.setTransparentSort=function(ae){H=ae},this.getClearColor=function(ae){return ae.copy(oe.getClearColor())},this.setClearColor=function(){oe.setClearColor(...arguments)},this.getClearAlpha=function(){return oe.getClearAlpha()},this.setClearAlpha=function(){oe.setClearAlpha(...arguments)},this.clear=function(ae=!0,Ee=!0,Fe=!0){let Oe=0;if(ae){let Ne=!1;if(j!==null){const lt=j.texture.format;Ne=x.has(lt)}if(Ne){const lt=j.texture.type,ft=v.has(lt),wt=oe.getClearColor(),bt=oe.getClearAlpha(),Lt=wt.r,Ct=wt.g,pt=wt.b;ft?(y[0]=Lt,y[1]=Ct,y[2]=pt,y[3]=bt,B.clearBufferuiv(B.COLOR,0,y)):(b[0]=Lt,b[1]=Ct,b[2]=pt,b[3]=bt,B.clearBufferiv(B.COLOR,0,b))}else Oe|=B.COLOR_BUFFER_BIT}Ee&&(Oe|=B.DEPTH_BUFFER_BIT),Fe&&(Oe|=B.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B.clear(Oe)},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",ke,!1),n.removeEventListener("webglcontextrestored",ve,!1),n.removeEventListener("webglcontextcreationerror",de,!1),oe.dispose(),He.dispose(),he.dispose(),Ae.dispose(),$.dispose(),L.dispose(),we.dispose(),fe.dispose(),Qe.dispose(),xe.dispose(),ze.dispose(),ze.removeEventListener("sessionstart",On),ze.removeEventListener("sessionend",Mi),si.stop()};function ke(ae){ae.preventDefault(),X6("WebGLRenderer: Context Lost."),k=!0}function ve(){X6("WebGLRenderer: Context Restored."),k=!1;const ae=Me.autoReset,Ee=Ue.enabled,Fe=Ue.autoUpdate,Oe=Ue.needsUpdate,Ne=Ue.type;ge(),Me.autoReset=ae,Ue.enabled=Ee,Ue.autoUpdate=Fe,Ue.needsUpdate=Oe,Ue.type=Ne}function de(ae){Hr("WebGLRenderer: A WebGL context could not be created. Reason: ",ae.statusMessage)}function ot(ae){const Ee=ae.target;Ee.removeEventListener("dispose",ot),xt(Ee)}function xt(ae){Et(ae),Ae.remove(ae)}function Et(ae){const Ee=Ae.get(ae).programs;Ee!==void 0&&(Ee.forEach(function(Fe){xe.releaseProgram(Fe)}),ae.isShaderMaterial&&xe.releaseShaderCache(ae))}this.renderBufferDirect=function(ae,Ee,Fe,Oe,Ne,lt){Ee===null&&(Ee=ce);const ft=Ne.isMesh&&Ne.matrixWorld.determinant()<0,wt=me(ae,Ee,Fe,Oe,Ne);se.setMaterial(Oe,ft);let bt=Fe.index,Lt=1;if(Oe.wireframe===!0){if(bt=ye.getWireframeAttribute(Fe),bt===void 0)return;Lt=2}const Ct=Fe.drawRange,pt=Fe.attributes.position;let Xt=Ct.start*Lt,Ut=(Ct.start+Ct.count)*Lt;lt!==null&&(Xt=Math.max(Xt,lt.start*Lt),Ut=Math.min(Ut,(lt.start+lt.count)*Lt)),bt!==null?(Xt=Math.max(Xt,0),Ut=Math.min(Ut,bt.count)):pt!=null&&(Xt=Math.max(Xt,0),Ut=Math.min(Ut,pt.count));const an=Ut-Xt;if(an<0||an===1/0)return;fe.setup(Ne,Oe,wt,Fe,bt);let hn,bn=$e;if(bt!==null&&(hn=re.get(bt),bn=Ye,bn.setIndex(hn)),Ne.isMesh)Oe.wireframe===!0?(se.setLineWidth(Oe.wireframeLinewidth*z()),bn.setMode(B.LINES)):bn.setMode(B.TRIANGLES);else if(Ne.isLine){let Ft=Oe.linewidth;Ft===void 0&&(Ft=1),se.setLineWidth(Ft*z()),Ne.isLineSegments?bn.setMode(B.LINES):Ne.isLineLoop?bn.setMode(B.LINE_LOOP):bn.setMode(B.LINE_STRIP)}else Ne.isPoints?bn.setMode(B.POINTS):Ne.isSprite&&bn.setMode(B.TRIANGLES);if(Ne.isBatchedMesh)if(Ne._multiDrawInstances!==null)K0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bn.renderMultiDrawInstances(Ne._multiDrawStarts,Ne._multiDrawCounts,Ne._multiDrawCount,Ne._multiDrawInstances);else if(V.get("WEBGL_multi_draw"))bn.renderMultiDraw(Ne._multiDrawStarts,Ne._multiDrawCounts,Ne._multiDrawCount);else{const Ft=Ne._multiDrawStarts,Jt=Ne._multiDrawCounts,tn=Ne._multiDrawCount,Cr=bt?re.get(bt).bytesPerElement:1,Ir=Ae.get(Oe).currentProgram.getUniforms();for(let jn=0;jn<tn;jn++)Ir.setValue(B,"_gl_DrawID",jn),bn.render(Ft[jn]/Cr,Jt[jn])}else if(Ne.isInstancedMesh)bn.renderInstances(Xt,an,Ne.count);else if(Fe.isInstancedBufferGeometry){const Ft=Fe._maxInstanceCount!==void 0?Fe._maxInstanceCount:1/0,Jt=Math.min(Fe.instanceCount,Ft);bn.renderInstances(Xt,an,Jt)}else bn.render(Xt,an)};function Qt(ae,Ee,Fe){ae.transparent===!0&&ae.side===rl&&ae.forceSinglePass===!1?(ae.side=Za,ae.needsUpdate=!0,Lr(ae,Ee,Fe),ae.side=bd,ae.needsUpdate=!0,Lr(ae,Ee,Fe),ae.side=rl):Lr(ae,Ee,Fe)}this.compile=function(ae,Ee,Fe=null){Fe===null&&(Fe=ae),w=he.get(Fe),w.init(Ee),T.push(w),Fe.traverseVisible(function(Ne){Ne.isLight&&Ne.layers.test(Ee.layers)&&(w.pushLight(Ne),Ne.castShadow&&w.pushShadow(Ne))}),ae!==Fe&&ae.traverseVisible(function(Ne){Ne.isLight&&Ne.layers.test(Ee.layers)&&(w.pushLight(Ne),Ne.castShadow&&w.pushShadow(Ne))}),w.setupLights();const Oe=new Set;return ae.traverse(function(Ne){if(!(Ne.isMesh||Ne.isPoints||Ne.isLine||Ne.isSprite))return;const lt=Ne.material;if(lt)if(Array.isArray(lt))for(let ft=0;ft<lt.length;ft++){const wt=lt[ft];Qt(wt,Fe,Ne),Oe.add(wt)}else Qt(lt,Fe,Ne),Oe.add(lt)}),w=T.pop(),Oe},this.compileAsync=function(ae,Ee,Fe=null){const Oe=this.compile(ae,Ee,Fe);return new Promise(Ne=>{function lt(){if(Oe.forEach(function(ft){Ae.get(ft).currentProgram.isReady()&&Oe.delete(ft)}),Oe.size===0){Ne(ae);return}setTimeout(lt,10)}V.get("KHR_parallel_shader_compile")!==null?lt():setTimeout(lt,10)})};let Ot=null;function Vt(ae){Ot&&Ot(ae)}function On(){si.stop()}function Mi(){si.start()}const si=new MZ;si.setAnimationLoop(Vt),typeof self<"u"&&si.setContext(self),this.setAnimationLoop=function(ae){Ot=ae,ze.setAnimationLoop(ae),ae===null?si.stop():si.start()},ze.addEventListener("sessionstart",On),ze.addEventListener("sessionend",Mi),this.render=function(ae,Ee){if(Ee!==void 0&&Ee.isCamera!==!0){Hr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(k===!0)return;if(ae.matrixWorldAutoUpdate===!0&&ae.updateMatrixWorld(),Ee.parent===null&&Ee.matrixWorldAutoUpdate===!0&&Ee.updateMatrixWorld(),ze.enabled===!0&&ze.isPresenting===!0&&(ze.cameraAutoUpdate===!0&&ze.updateCamera(Ee),Ee=ze.getCamera()),ae.isScene===!0&&ae.onBeforeRender(C,ae,Ee,j),w=he.get(ae,T.length),w.init(Ee),T.push(w),Z.multiplyMatrices(Ee.projectionMatrix,Ee.matrixWorldInverse),ue.setFromProjectionMatrix(Z,ol,Ee.reversedDepth),Re=this.localClippingEnabled,be=Ge.init(this.clippingPlanes,Re),E=He.get(ae,A.length),E.init(),A.push(E),ze.enabled===!0&&ze.isPresenting===!0){const lt=C.xr.getDepthSensingMesh();lt!==null&&Ei(lt,Ee,-1/0,C.sortObjects)}Ei(ae,Ee,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(U,H),Ie=ze.enabled===!1||ze.isPresenting===!1||ze.hasDepthSensing()===!1,Ie&&oe.addToRenderList(E,ae),this.info.render.frame++,be===!0&&Ge.beginShadows();const Fe=w.state.shadowsArray;Ue.render(Fe,ae,Ee),be===!0&&Ge.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=E.opaque,Ne=E.transmissive;if(w.setupLights(),Ee.isArrayCamera){const lt=Ee.cameras;if(Ne.length>0)for(let ft=0,wt=lt.length;ft<wt;ft++){const bt=lt[ft];ra(Oe,Ne,ae,bt)}Ie&&oe.render(ae);for(let ft=0,wt=lt.length;ft<wt;ft++){const bt=lt[ft];zi(E,ae,bt,bt.viewport)}}else Ne.length>0&&ra(Oe,Ne,ae,Ee),Ie&&oe.render(ae),zi(E,ae,Ee);j!==null&&N===0&&(Se.updateMultisampleRenderTarget(j),Se.updateRenderTargetMipmap(j)),ae.isScene===!0&&ae.onAfterRender(C,ae,Ee),fe.resetDefaultState(),I=-1,O=null,T.pop(),T.length>0?(w=T[T.length-1],be===!0&&Ge.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Ei(ae,Ee,Fe,Oe){if(ae.visible===!1)return;if(ae.layers.test(Ee.layers)){if(ae.isGroup)Fe=ae.renderOrder;else if(ae.isLOD)ae.autoUpdate===!0&&ae.update(Ee);else if(ae.isLight)w.pushLight(ae),ae.castShadow&&w.pushShadow(ae);else if(ae.isSprite){if(!ae.frustumCulled||ue.intersectsSprite(ae)){Oe&&Le.setFromMatrixPosition(ae.matrixWorld).applyMatrix4(Z);const ft=we.update(ae),wt=ae.material;wt.visible&&E.push(ae,ft,wt,Fe,Le.z,null)}}else if((ae.isMesh||ae.isLine||ae.isPoints)&&(!ae.frustumCulled||ue.intersectsObject(ae))){const ft=we.update(ae),wt=ae.material;if(Oe&&(ae.boundingSphere!==void 0?(ae.boundingSphere===null&&ae.computeBoundingSphere(),Le.copy(ae.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),Le.copy(ft.boundingSphere.center)),Le.applyMatrix4(ae.matrixWorld).applyMatrix4(Z)),Array.isArray(wt)){const bt=ft.groups;for(let Lt=0,Ct=bt.length;Lt<Ct;Lt++){const pt=bt[Lt],Xt=wt[pt.materialIndex];Xt&&Xt.visible&&E.push(ae,ft,Xt,Fe,Le.z,pt)}}else wt.visible&&E.push(ae,ft,wt,Fe,Le.z,null)}}const lt=ae.children;for(let ft=0,wt=lt.length;ft<wt;ft++)Ei(lt[ft],Ee,Fe,Oe)}function zi(ae,Ee,Fe,Oe){const{opaque:Ne,transmissive:lt,transparent:ft}=ae;w.setupLightsView(Fe),be===!0&&Ge.setGlobalState(C.clippingPlanes,Fe),Oe&&se.viewport(q.copy(Oe)),Ne.length>0&&Wr(Ne,Ee,Fe),lt.length>0&&Wr(lt,Ee,Fe),ft.length>0&&Wr(ft,Ee,Fe),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function ra(ae,Ee,Fe,Oe){if((Fe.isScene===!0?Fe.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Oe.id]===void 0&&(w.state.transmissionRenderTarget[Oe.id]=new af(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")||V.has("EXT_color_buffer_float")?ug:xl,minFilter:Sh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Nn.workingColorSpace}));const lt=w.state.transmissionRenderTarget[Oe.id],ft=Oe.viewport||q;lt.setSize(ft.z*C.transmissionResolutionScale,ft.w*C.transmissionResolutionScale);const wt=C.getRenderTarget(),bt=C.getActiveCubeFace(),Lt=C.getActiveMipmapLevel();C.setRenderTarget(lt),C.getClearColor(K),G=C.getClearAlpha(),G<1&&C.setClearColor(16777215,.5),C.clear(),Ie&&oe.render(Fe);const Ct=C.toneMapping;C.toneMapping=td;const pt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),w.setupLightsView(Oe),be===!0&&Ge.setGlobalState(C.clippingPlanes,Oe),Wr(ae,Fe,Oe),Se.updateMultisampleRenderTarget(lt),Se.updateRenderTargetMipmap(lt),V.has("WEBGL_multisampled_render_to_texture")===!1){let Xt=!1;for(let Ut=0,an=Ee.length;Ut<an;Ut++){const hn=Ee[Ut],{object:bn,geometry:Ft,material:Jt,group:tn}=hn;if(Jt.side===rl&&bn.layers.test(Oe.layers)){const Cr=Jt.side;Jt.side=Za,Jt.needsUpdate=!0,yr(bn,Fe,Oe,Ft,Jt,tn),Jt.side=Cr,Jt.needsUpdate=!0,Xt=!0}}Xt===!0&&(Se.updateMultisampleRenderTarget(lt),Se.updateRenderTargetMipmap(lt))}C.setRenderTarget(wt,bt,Lt),C.setClearColor(K,G),pt!==void 0&&(Oe.viewport=pt),C.toneMapping=Ct}function Wr(ae,Ee,Fe){const Oe=Ee.isScene===!0?Ee.overrideMaterial:null;for(let Ne=0,lt=ae.length;Ne<lt;Ne++){const ft=ae[Ne],{object:wt,geometry:bt,group:Lt}=ft;let Ct=ft.material;Ct.allowOverride===!0&&Oe!==null&&(Ct=Oe),wt.layers.test(Fe.layers)&&yr(wt,Ee,Fe,bt,Ct,Lt)}}function yr(ae,Ee,Fe,Oe,Ne,lt){ae.onBeforeRender(C,Ee,Fe,Oe,Ne,lt),ae.modelViewMatrix.multiplyMatrices(Fe.matrixWorldInverse,ae.matrixWorld),ae.normalMatrix.getNormalMatrix(ae.modelViewMatrix),Ne.onBeforeRender(C,Ee,Fe,Oe,ae,lt),Ne.transparent===!0&&Ne.side===rl&&Ne.forceSinglePass===!1?(Ne.side=Za,Ne.needsUpdate=!0,C.renderBufferDirect(Fe,Ee,Oe,Ne,ae,lt),Ne.side=bd,Ne.needsUpdate=!0,C.renderBufferDirect(Fe,Ee,Oe,Ne,ae,lt),Ne.side=rl):C.renderBufferDirect(Fe,Ee,Oe,Ne,ae,lt),ae.onAfterRender(C,Ee,Fe,Oe,Ne,lt)}function Lr(ae,Ee,Fe){Ee.isScene!==!0&&(Ee=ce);const Oe=Ae.get(ae),Ne=w.state.lights,lt=w.state.shadowsArray,ft=Ne.state.version,wt=xe.getParameters(ae,Ne.state,lt,Ee,Fe),bt=xe.getProgramCacheKey(wt);let Lt=Oe.programs;Oe.environment=ae.isMeshStandardMaterial?Ee.environment:null,Oe.fog=Ee.fog,Oe.envMap=(ae.isMeshStandardMaterial?L:$).get(ae.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&ae.envMap===null?Ee.environmentRotation:ae.envMapRotation,Lt===void 0&&(ae.addEventListener("dispose",ot),Lt=new Map,Oe.programs=Lt);let Ct=Lt.get(bt);if(Ct!==void 0){if(Oe.currentProgram===Ct&&Oe.lightsStateVersion===ft)return Xc(ae,wt),Ct}else wt.uniforms=xe.getUniforms(ae),ae.onBeforeCompile(wt,C),Ct=xe.acquireProgram(wt,bt),Lt.set(bt,Ct),Oe.uniforms=wt.uniforms;const pt=Oe.uniforms;return(!ae.isShaderMaterial&&!ae.isRawShaderMaterial||ae.clipping===!0)&&(pt.clippingPlanes=Ge.uniform),Xc(ae,wt),Oe.needsLights=it(ae),Oe.lightsStateVersion=ft,Oe.needsLights&&(pt.ambientLightColor.value=Ne.state.ambient,pt.lightProbe.value=Ne.state.probe,pt.directionalLights.value=Ne.state.directional,pt.directionalLightShadows.value=Ne.state.directionalShadow,pt.spotLights.value=Ne.state.spot,pt.spotLightShadows.value=Ne.state.spotShadow,pt.rectAreaLights.value=Ne.state.rectArea,pt.ltc_1.value=Ne.state.rectAreaLTC1,pt.ltc_2.value=Ne.state.rectAreaLTC2,pt.pointLights.value=Ne.state.point,pt.pointLightShadows.value=Ne.state.pointShadow,pt.hemisphereLights.value=Ne.state.hemi,pt.directionalShadowMap.value=Ne.state.directionalShadowMap,pt.directionalShadowMatrix.value=Ne.state.directionalShadowMatrix,pt.spotShadowMap.value=Ne.state.spotShadowMap,pt.spotLightMatrix.value=Ne.state.spotLightMatrix,pt.spotLightMap.value=Ne.state.spotLightMap,pt.pointShadowMap.value=Ne.state.pointShadowMap,pt.pointShadowMatrix.value=Ne.state.pointShadowMatrix),Oe.currentProgram=Ct,Oe.uniformsList=null,Ct}function go(ae){if(ae.uniformsList===null){const Ee=ae.currentProgram.getUniforms();ae.uniformsList=g1.seqWithValue(Ee.seq,ae.uniforms)}return ae.uniformsList}function Xc(ae,Ee){const Fe=Ae.get(ae);Fe.outputColorSpace=Ee.outputColorSpace,Fe.batching=Ee.batching,Fe.batchingColor=Ee.batchingColor,Fe.instancing=Ee.instancing,Fe.instancingColor=Ee.instancingColor,Fe.instancingMorph=Ee.instancingMorph,Fe.skinning=Ee.skinning,Fe.morphTargets=Ee.morphTargets,Fe.morphNormals=Ee.morphNormals,Fe.morphColors=Ee.morphColors,Fe.morphTargetsCount=Ee.morphTargetsCount,Fe.numClippingPlanes=Ee.numClippingPlanes,Fe.numIntersection=Ee.numClipIntersection,Fe.vertexAlphas=Ee.vertexAlphas,Fe.vertexTangents=Ee.vertexTangents,Fe.toneMapping=Ee.toneMapping}function me(ae,Ee,Fe,Oe,Ne){Ee.isScene!==!0&&(Ee=ce),Se.resetTextureUnits();const lt=Ee.fog,ft=Oe.isMeshStandardMaterial?Ee.environment:null,wt=j===null?C.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:jp,bt=(Oe.isMeshStandardMaterial?L:$).get(Oe.envMap||ft),Lt=Oe.vertexColors===!0&&!!Fe.attributes.color&&Fe.attributes.color.itemSize===4,Ct=!!Fe.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),pt=!!Fe.morphAttributes.position,Xt=!!Fe.morphAttributes.normal,Ut=!!Fe.morphAttributes.color;let an=td;Oe.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(an=C.toneMapping);const hn=Fe.morphAttributes.position||Fe.morphAttributes.normal||Fe.morphAttributes.color,bn=hn!==void 0?hn.length:0,Ft=Ae.get(Oe),Jt=w.state.lights;if(be===!0&&(Re===!0||ae!==O)){const Ti=ae===O&&Oe.id===I;Ge.setState(Oe,ae,Ti)}let tn=!1;Oe.version===Ft.__version?(Ft.needsLights&&Ft.lightsStateVersion!==Jt.state.version||Ft.outputColorSpace!==wt||Ne.isBatchedMesh&&Ft.batching===!1||!Ne.isBatchedMesh&&Ft.batching===!0||Ne.isBatchedMesh&&Ft.batchingColor===!0&&Ne.colorTexture===null||Ne.isBatchedMesh&&Ft.batchingColor===!1&&Ne.colorTexture!==null||Ne.isInstancedMesh&&Ft.instancing===!1||!Ne.isInstancedMesh&&Ft.instancing===!0||Ne.isSkinnedMesh&&Ft.skinning===!1||!Ne.isSkinnedMesh&&Ft.skinning===!0||Ne.isInstancedMesh&&Ft.instancingColor===!0&&Ne.instanceColor===null||Ne.isInstancedMesh&&Ft.instancingColor===!1&&Ne.instanceColor!==null||Ne.isInstancedMesh&&Ft.instancingMorph===!0&&Ne.morphTexture===null||Ne.isInstancedMesh&&Ft.instancingMorph===!1&&Ne.morphTexture!==null||Ft.envMap!==bt||Oe.fog===!0&&Ft.fog!==lt||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==Ge.numPlanes||Ft.numIntersection!==Ge.numIntersection)||Ft.vertexAlphas!==Lt||Ft.vertexTangents!==Ct||Ft.morphTargets!==pt||Ft.morphNormals!==Xt||Ft.morphColors!==Ut||Ft.toneMapping!==an||Ft.morphTargetsCount!==bn)&&(tn=!0):(tn=!0,Ft.__version=Oe.version);let Cr=Ft.currentProgram;tn===!0&&(Cr=Lr(Oe,Ee,Ne));let Ir=!1,jn=!1,xo=!1;const Ln=Cr.getUniforms(),Ai=Ft.uniforms;if(se.useProgram(Cr.program)&&(Ir=!0,jn=!0,xo=!0),Oe.id!==I&&(I=Oe.id,jn=!0),Ir||O!==ae){se.buffers.depth.getReversed()&&ae.reversedDepth!==!0&&(ae._reversedDepth=!0,ae.updateProjectionMatrix()),Ln.setValue(B,"projectionMatrix",ae.projectionMatrix),Ln.setValue(B,"viewMatrix",ae.matrixWorldInverse);const Bi=Ln.map.cameraPosition;Bi!==void 0&&Bi.setValue(B,_e.setFromMatrixPosition(ae.matrixWorld)),Q.logarithmicDepthBuffer&&Ln.setValue(B,"logDepthBufFC",2/(Math.log(ae.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&Ln.setValue(B,"isOrthographic",ae.isOrthographicCamera===!0),O!==ae&&(O=ae,jn=!0,xo=!0)}if(Ne.isSkinnedMesh){Ln.setOptional(B,Ne,"bindMatrix"),Ln.setOptional(B,Ne,"bindMatrixInverse");const Ti=Ne.skeleton;Ti&&(Ti.boneTexture===null&&Ti.computeBoneTexture(),Ln.setValue(B,"boneTexture",Ti.boneTexture,Se))}Ne.isBatchedMesh&&(Ln.setOptional(B,Ne,"batchingTexture"),Ln.setValue(B,"batchingTexture",Ne._matricesTexture,Se),Ln.setOptional(B,Ne,"batchingIdTexture"),Ln.setValue(B,"batchingIdTexture",Ne._indirectTexture,Se),Ln.setOptional(B,Ne,"batchingColorTexture"),Ne._colorsTexture!==null&&Ln.setValue(B,"batchingColorTexture",Ne._colorsTexture,Se));const oi=Fe.morphAttributes;if((oi.position!==void 0||oi.normal!==void 0||oi.color!==void 0)&&tt.update(Ne,Fe,Cr),(jn||Ft.receiveShadow!==Ne.receiveShadow)&&(Ft.receiveShadow=Ne.receiveShadow,Ln.setValue(B,"receiveShadow",Ne.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Ai.envMap.value=bt,Ai.flipEnvMap.value=bt.isCubeTexture&&bt.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Ee.environment!==null&&(Ai.envMapIntensity.value=Ee.environmentIntensity),Ai.dfgLUT!==void 0&&(Ai.dfgLUT.value=Jje()),jn&&(Ln.setValue(B,"toneMappingExposure",C.toneMappingExposure),Ft.needsLights&&Ve(Ai,xo),lt&&Oe.fog===!0&&rt.refreshFogUniforms(Ai,lt),rt.refreshMaterialUniforms(Ai,Oe,J,Y,w.state.transmissionRenderTarget[ae.id]),g1.upload(B,go(Ft),Ai,Se)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(g1.upload(B,go(Ft),Ai,Se),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&Ln.setValue(B,"center",Ne.center),Ln.setValue(B,"modelViewMatrix",Ne.modelViewMatrix),Ln.setValue(B,"normalMatrix",Ne.normalMatrix),Ln.setValue(B,"modelMatrix",Ne.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Ti=Oe.uniformsGroups;for(let Bi=0,Vo=Ti.length;Bi<Vo;Bi++){const Tl=Ti[Bi];Qe.update(Tl,Cr),Qe.bind(Tl,Cr)}}return Cr}function Ve(ae,Ee){ae.ambientLightColor.needsUpdate=Ee,ae.lightProbe.needsUpdate=Ee,ae.directionalLights.needsUpdate=Ee,ae.directionalLightShadows.needsUpdate=Ee,ae.pointLights.needsUpdate=Ee,ae.pointLightShadows.needsUpdate=Ee,ae.spotLights.needsUpdate=Ee,ae.spotLightShadows.needsUpdate=Ee,ae.rectAreaLights.needsUpdate=Ee,ae.hemisphereLights.needsUpdate=Ee}function it(ae){return ae.isMeshLambertMaterial||ae.isMeshToonMaterial||ae.isMeshPhongMaterial||ae.isMeshStandardMaterial||ae.isShadowMaterial||ae.isShaderMaterial&&ae.lights===!0}this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return j},this.setRenderTargetTextures=function(ae,Ee,Fe){const Oe=Ae.get(ae);Oe.__autoAllocateDepthBuffer=ae.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),Ae.get(ae.texture).__webglTexture=Ee,Ae.get(ae.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Fe,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ae,Ee){const Fe=Ae.get(ae);Fe.__webglFramebuffer=Ee,Fe.__useDefaultFramebuffer=Ee===void 0};const at=B.createFramebuffer();this.setRenderTarget=function(ae,Ee=0,Fe=0){j=ae,F=Ee,N=Fe;let Oe=!0,Ne=null,lt=!1,ft=!1;if(ae){const bt=Ae.get(ae);if(bt.__useDefaultFramebuffer!==void 0)se.bindFramebuffer(B.FRAMEBUFFER,null),Oe=!1;else if(bt.__webglFramebuffer===void 0)Se.setupRenderTarget(ae);else if(bt.__hasExternalTextures)Se.rebindTextures(ae,Ae.get(ae.texture).__webglTexture,Ae.get(ae.depthTexture).__webglTexture);else if(ae.depthBuffer){const pt=ae.depthTexture;if(bt.__boundDepthTexture!==pt){if(pt!==null&&Ae.has(pt)&&(ae.width!==pt.image.width||ae.height!==pt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(ae)}}const Lt=ae.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(ft=!0);const Ct=Ae.get(ae).__webglFramebuffer;ae.isWebGLCubeRenderTarget?(Array.isArray(Ct[Ee])?Ne=Ct[Ee][Fe]:Ne=Ct[Ee],lt=!0):ae.samples>0&&Se.useMultisampledRTT(ae)===!1?Ne=Ae.get(ae).__webglMultisampledFramebuffer:Array.isArray(Ct)?Ne=Ct[Fe]:Ne=Ct,q.copy(ae.viewport),R.copy(ae.scissor),W=ae.scissorTest}else q.copy(ee).multiplyScalar(J).floor(),R.copy(ie).multiplyScalar(J).floor(),W=pe;if(Fe!==0&&(Ne=at),se.bindFramebuffer(B.FRAMEBUFFER,Ne)&&Oe&&se.drawBuffers(ae,Ne),se.viewport(q),se.scissor(R),se.setScissorTest(W),lt){const bt=Ae.get(ae.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,bt.__webglTexture,Fe)}else if(ft){const bt=Ee;for(let Lt=0;Lt<ae.textures.length;Lt++){const Ct=Ae.get(ae.textures[Lt]);B.framebufferTextureLayer(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0+Lt,Ct.__webglTexture,Fe,bt)}}else if(ae!==null&&Fe!==0){const bt=Ae.get(ae.texture);B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,bt.__webglTexture,Fe)}I=-1},this.readRenderTargetPixels=function(ae,Ee,Fe,Oe,Ne,lt,ft,wt=0){if(!(ae&&ae.isWebGLRenderTarget)){Hr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=Ae.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt){se.bindFramebuffer(B.FRAMEBUFFER,bt);try{const Lt=ae.textures[wt],Ct=Lt.format,pt=Lt.type;if(!Q.textureFormatReadable(Ct)){Hr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Q.textureTypeReadable(pt)){Hr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ee>=0&&Ee<=ae.width-Oe&&Fe>=0&&Fe<=ae.height-Ne&&(ae.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+wt),B.readPixels(Ee,Fe,Oe,Ne,ut.convert(Ct),ut.convert(pt),lt))}finally{const Lt=j!==null?Ae.get(j).__webglFramebuffer:null;se.bindFramebuffer(B.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(ae,Ee,Fe,Oe,Ne,lt,ft,wt=0){if(!(ae&&ae.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=Ae.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt)if(Ee>=0&&Ee<=ae.width-Oe&&Fe>=0&&Fe<=ae.height-Ne){se.bindFramebuffer(B.FRAMEBUFFER,bt);const Lt=ae.textures[wt],Ct=Lt.format,pt=Lt.type;if(!Q.textureFormatReadable(Ct))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Xt=B.createBuffer();B.bindBuffer(B.PIXEL_PACK_BUFFER,Xt),B.bufferData(B.PIXEL_PACK_BUFFER,lt.byteLength,B.STREAM_READ),ae.textures.length>1&&B.readBuffer(B.COLOR_ATTACHMENT0+wt),B.readPixels(Ee,Fe,Oe,Ne,ut.convert(Ct),ut.convert(pt),0);const Ut=j!==null?Ae.get(j).__webglFramebuffer:null;se.bindFramebuffer(B.FRAMEBUFFER,Ut);const an=B.fenceSync(B.SYNC_GPU_COMMANDS_COMPLETE,0);return B.flush(),await ENe(B,an,4),B.bindBuffer(B.PIXEL_PACK_BUFFER,Xt),B.getBufferSubData(B.PIXEL_PACK_BUFFER,0,lt),B.deleteBuffer(Xt),B.deleteSync(an),lt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ae,Ee=null,Fe=0){const Oe=Math.pow(2,-Fe),Ne=Math.floor(ae.image.width*Oe),lt=Math.floor(ae.image.height*Oe),ft=Ee!==null?Ee.x:0,wt=Ee!==null?Ee.y:0;Se.setTexture2D(ae,0),B.copyTexSubImage2D(B.TEXTURE_2D,Fe,0,0,ft,wt,Ne,lt),se.unbindTexture()};const nt=B.createFramebuffer(),At=B.createFramebuffer();this.copyTextureToTexture=function(ae,Ee,Fe=null,Oe=null,Ne=0,lt=null){lt===null&&(Ne!==0?(K0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),lt=Ne,Ne=0):lt=0);let ft,wt,bt,Lt,Ct,pt,Xt,Ut,an;const hn=ae.isCompressedTexture?ae.mipmaps[lt]:ae.image;if(Fe!==null)ft=Fe.max.x-Fe.min.x,wt=Fe.max.y-Fe.min.y,bt=Fe.isBox3?Fe.max.z-Fe.min.z:1,Lt=Fe.min.x,Ct=Fe.min.y,pt=Fe.isBox3?Fe.min.z:0;else{const oi=Math.pow(2,-Ne);ft=Math.floor(hn.width*oi),wt=Math.floor(hn.height*oi),ae.isDataArrayTexture?bt=hn.depth:ae.isData3DTexture?bt=Math.floor(hn.depth*oi):bt=1,Lt=0,Ct=0,pt=0}Oe!==null?(Xt=Oe.x,Ut=Oe.y,an=Oe.z):(Xt=0,Ut=0,an=0);const bn=ut.convert(Ee.format),Ft=ut.convert(Ee.type);let Jt;Ee.isData3DTexture?(Se.setTexture3D(Ee,0),Jt=B.TEXTURE_3D):Ee.isDataArrayTexture||Ee.isCompressedArrayTexture?(Se.setTexture2DArray(Ee,0),Jt=B.TEXTURE_2D_ARRAY):(Se.setTexture2D(Ee,0),Jt=B.TEXTURE_2D),B.pixelStorei(B.UNPACK_FLIP_Y_WEBGL,Ee.flipY),B.pixelStorei(B.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ee.premultiplyAlpha),B.pixelStorei(B.UNPACK_ALIGNMENT,Ee.unpackAlignment);const tn=B.getParameter(B.UNPACK_ROW_LENGTH),Cr=B.getParameter(B.UNPACK_IMAGE_HEIGHT),Ir=B.getParameter(B.UNPACK_SKIP_PIXELS),jn=B.getParameter(B.UNPACK_SKIP_ROWS),xo=B.getParameter(B.UNPACK_SKIP_IMAGES);B.pixelStorei(B.UNPACK_ROW_LENGTH,hn.width),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,hn.height),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Lt),B.pixelStorei(B.UNPACK_SKIP_ROWS,Ct),B.pixelStorei(B.UNPACK_SKIP_IMAGES,pt);const Ln=ae.isDataArrayTexture||ae.isData3DTexture,Ai=Ee.isDataArrayTexture||Ee.isData3DTexture;if(ae.isDepthTexture){const oi=Ae.get(ae),Ti=Ae.get(Ee),Bi=Ae.get(oi.__renderTarget),Vo=Ae.get(Ti.__renderTarget);se.bindFramebuffer(B.READ_FRAMEBUFFER,Bi.__webglFramebuffer),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,Vo.__webglFramebuffer);for(let Tl=0;Tl<bt;Tl++)Ln&&(B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Ae.get(ae).__webglTexture,Ne,pt+Tl),B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Ae.get(Ee).__webglTexture,lt,an+Tl)),B.blitFramebuffer(Lt,Ct,ft,wt,Xt,Ut,ft,wt,B.DEPTH_BUFFER_BIT,B.NEAREST);se.bindFramebuffer(B.READ_FRAMEBUFFER,null),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else if(Ne!==0||ae.isRenderTargetTexture||Ae.has(ae)){const oi=Ae.get(ae),Ti=Ae.get(Ee);se.bindFramebuffer(B.READ_FRAMEBUFFER,nt),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,At);for(let Bi=0;Bi<bt;Bi++)Ln?B.framebufferTextureLayer(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,oi.__webglTexture,Ne,pt+Bi):B.framebufferTexture2D(B.READ_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,oi.__webglTexture,Ne),Ai?B.framebufferTextureLayer(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,Ti.__webglTexture,lt,an+Bi):B.framebufferTexture2D(B.DRAW_FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_2D,Ti.__webglTexture,lt),Ne!==0?B.blitFramebuffer(Lt,Ct,ft,wt,Xt,Ut,ft,wt,B.COLOR_BUFFER_BIT,B.NEAREST):Ai?B.copyTexSubImage3D(Jt,lt,Xt,Ut,an+Bi,Lt,Ct,ft,wt):B.copyTexSubImage2D(Jt,lt,Xt,Ut,Lt,Ct,ft,wt);se.bindFramebuffer(B.READ_FRAMEBUFFER,null),se.bindFramebuffer(B.DRAW_FRAMEBUFFER,null)}else Ai?ae.isDataTexture||ae.isData3DTexture?B.texSubImage3D(Jt,lt,Xt,Ut,an,ft,wt,bt,bn,Ft,hn.data):Ee.isCompressedArrayTexture?B.compressedTexSubImage3D(Jt,lt,Xt,Ut,an,ft,wt,bt,bn,hn.data):B.texSubImage3D(Jt,lt,Xt,Ut,an,ft,wt,bt,bn,Ft,hn):ae.isDataTexture?B.texSubImage2D(B.TEXTURE_2D,lt,Xt,Ut,ft,wt,bn,Ft,hn.data):ae.isCompressedTexture?B.compressedTexSubImage2D(B.TEXTURE_2D,lt,Xt,Ut,hn.width,hn.height,bn,hn.data):B.texSubImage2D(B.TEXTURE_2D,lt,Xt,Ut,ft,wt,bn,Ft,hn);B.pixelStorei(B.UNPACK_ROW_LENGTH,tn),B.pixelStorei(B.UNPACK_IMAGE_HEIGHT,Cr),B.pixelStorei(B.UNPACK_SKIP_PIXELS,Ir),B.pixelStorei(B.UNPACK_SKIP_ROWS,jn),B.pixelStorei(B.UNPACK_SKIP_IMAGES,xo),lt===0&&Ee.generateMipmaps&&B.generateMipmap(Jt),se.unbindTexture()},this.initRenderTarget=function(ae){Ae.get(ae).__webglFramebuffer===void 0&&Se.setupRenderTarget(ae)},this.initTexture=function(ae){ae.isCubeTexture?Se.setTextureCube(ae,0):ae.isData3DTexture?Se.setTexture3D(ae,0):ae.isDataArrayTexture||ae.isCompressedArrayTexture?Se.setTexture2DArray(ae,0):Se.setTexture2D(ae,0),se.unbindTexture()},this.resetState=function(){F=0,N=0,j=null,se.reset(),fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ol}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Nn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Nn._getUnpackColorSpace()}};const VH={type:"change"},_O={type:"start"},NZ={type:"end"},a_=new gO,GH=new Lu,tDe=Math.cos(70*TNe.DEG2RAD),ci=new et,$a=2*Math.PI,Zn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},YC=1e-6;class nDe extends fke{constructor(e,n=null){super(e,n),this.state=Zn.NONE,this.target=new et,this.cursor=new et,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:ap.ROTATE,MIDDLE:ap.DOLLY,RIGHT:ap.PAN},this.touches={ONE:Ym.ROTATE,TWO:Ym.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new et,this._lastQuaternion=new rf,this._lastTargetPosition=new et,this._quat=new rf().setFromUnitVectors(e.up,new et(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new yH,this._sphericalDelta=new yH,this._scale=1,this._panOffset=new et,this._rotateStart=new cn,this._rotateEnd=new cn,this._rotateDelta=new cn,this._panStart=new cn,this._panEnd=new cn,this._panDelta=new cn,this._dollyStart=new cn,this._dollyEnd=new cn,this._dollyDelta=new cn,this._dollyDirection=new et,this._mouse=new cn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=iDe.bind(this),this._onPointerDown=rDe.bind(this),this._onPointerUp=aDe.bind(this),this._onContextMenu=hDe.bind(this),this._onMouseWheel=lDe.bind(this),this._onKeyDown=cDe.bind(this),this._onTouchStart=uDe.bind(this),this._onTouchMove=dDe.bind(this),this._onMouseDown=sDe.bind(this),this._onMouseMove=oDe.bind(this),this._interceptControlDown=fDe.bind(this),this._interceptControlUp=mDe.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(VH),this.update(),this.state=Zn.NONE}update(e=null){const n=this.object.position;ci.copy(n).sub(this.target),ci.applyQuaternion(this._quat),this._spherical.setFromVector3(ci),this.autoRotate&&this.state===Zn.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+=$a:r>Math.PI&&(r-=$a),i<-Math.PI?i+=$a:i>Math.PI&&(i-=$a),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=s!=this._spherical.radius}if(ci.setFromSpherical(this._spherical),ci.applyQuaternion(this._quatInverse),n.copy(this.target).add(ci),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){const o=ci.length();s=this._clampDistance(o*this._scale);const c=o-s;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const o=new et(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new et(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(o),this.object.updateMatrixWorld(),s=ci.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(a_.origin.copy(this.object.position),a_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(a_.direction))<tDe?this.object.lookAt(this.target):(GH.setFromNormalAndCoplanarPoint(this.object.up,this.target),a_.intersectPlane(GH,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>YC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>YC||this._lastTargetPosition.distanceToSquared(this.target)>YC?(this.dispatchEvent(VH),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?$a/60*this.autoRotateSpeed*e:$a/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){ci.setFromMatrixColumn(n,0),ci.multiplyScalar(-e),this._panOffset.add(ci)}_panUp(e,n){this.screenSpacePanning===!0?ci.setFromMatrixColumn(n,1):(ci.setFromMatrixColumn(n,0),ci.crossVectors(this.object.up,ci)),ci.multiplyScalar(e),this._panOffset.add(ci)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ci.copy(i).sub(this.target);let a=ci.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,s=r.width,o=r.height;this._mouse.x=i/s*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft($a*this._rotateDelta.x/n.clientHeight),this._rotateUp($a*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($a*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(-$a*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($a*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(-$a*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft($a*this._rotateDelta.x/n.clientHeight),this._rotateUp($a*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new cn,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 rDe(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 iDe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function aDe(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(NZ),this.state=Zn.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 sDe(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 ap.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Zn.DOLLY;break;case ap.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Zn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Zn.ROTATE}break;case ap.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Zn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Zn.PAN}break;default:this.state=Zn.NONE}this.state!==Zn.NONE&&this.dispatchEvent(_O)}function oDe(t){switch(this.state){case Zn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Zn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Zn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function lDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Zn.NONE||(t.preventDefault(),this.dispatchEvent(_O),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(NZ))}function cDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function uDe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Ym.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Zn.TOUCH_ROTATE;break;case Ym.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Zn.TOUCH_PAN;break;default:this.state=Zn.NONE}break;case 2:switch(this.touches.TWO){case Ym.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Zn.TOUCH_DOLLY_PAN;break;case Ym.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Zn.TOUCH_DOLLY_ROTATE;break;default:this.state=Zn.NONE}break;default:this.state=Zn.NONE}this.state!==Zn.NONE&&this.dispatchEvent(_O)}function dDe(t){switch(this._trackPointer(t),this.state){case Zn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Zn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Zn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Zn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Zn.NONE}}function hDe(t){this.enabled!==!1&&t.preventDefault()}function fDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function mDe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function pDe(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},s={},o=t[0].morphTargetsRelative,c=new Al;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),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!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;s[p]===void 0&&(s[p]=[]),s[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const p=t[g].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[g].attributes.position.count}c.setIndex(f)}for(const d in a){const f=WH(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in s){const f=s[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let g=0;g<f;++g){const p=[];for(let v=0;v<s[d].length;++v)p.push(s[d][v][g]);const x=WH(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function WH(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const s=new e(a),o=new ao(s,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let g=0,p=d.count;g<p;g++)for(let x=0;x<n;x++){const v=d.getComponent(g,x);o.setComponent(g+f,x,v)}}else s.set(d.array,c);c+=d.count*n}return i!==void 0&&(o.gpuType=i),o}function s_(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 ZC={exports:{}};var qH;function gDe(){return qH||(qH=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function s(u,d){if(!i[u]){if(!r[u]){var f=typeof s_=="function"&&s_;if(!d&&f)return f(u,!0);if(o)return o(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var v=r[u][1][x];return s(v||x)},p,p.exports,n,r,i,a)}return i[u].exports}for(var o=typeof s_=="function"&&s_,c=0;c<a.length;c++)s(a[c]);return s})({1:[function(n,r,i){var a=n("./utils"),s=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,p,x,v,y=[],b=0,E=c.length,w=E,A=a.getTypeOf(c)!=="string";b<c.length;)w=E-b,f=A?(u=c[b++],d=b<E?c[b++]:0,b<E?c[b++]:0):(u=c.charCodeAt(b++),d=b<E?c.charCodeAt(b++):0,b<E?c.charCodeAt(b++):0),g=u>>2,p=(3&u)<<4|d>>4,x=1<w?(15&d)<<2|f>>6:64,v=2<w?63&f:64,y.push(o.charAt(g)+o.charAt(p)+o.charAt(x)+o.charAt(v));return y.join("")},i.decode=function(c){var u,d,f,g,p,x,v=0,y=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var E,w=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&w--,c.charAt(c.length-2)===o.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=s.uint8array?new Uint8Array(0|w):new Array(0|w);v<c.length;)u=o.indexOf(c.charAt(v++))<<2|(g=o.indexOf(c.charAt(v++)))>>4,d=(15&g)<<4|(p=o.indexOf(c.charAt(v++)))>>2,f=(3&p)<<6|(x=o.indexOf(c.charAt(v++))),E[y++]=u,p!==64&&(E[y++]=d),x!==64&&(E[y++]=f);return E}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),s=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,g,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,g){return d.pipe(new o).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),s=(function(){for(var o,c=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;c[u]=o}return c})();r.exports=function(o,c){return o!==void 0&&o.length?a.getTypeOf(o)!=="string"?(function(u,d,f,g){var p=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^p[255&(u^d[v])];return-1^u})(0|c,o,o.length,0):(function(u,d,f,g){var p=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^p[255&(u^d.charCodeAt(v))];return-1^u})(0|c,o,o.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),o=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(p,x){var v,y="";for(v=0;v<x;v++)y+=String.fromCharCode(255&p),p>>>=8;return y}function s(p,x,v,y,b,E){var w,A,T=p.file,C=p.compression,k=E!==u.utf8encode,F=o.transformTo("string",E(T.name)),N=o.transformTo("string",u.utf8encode(T.name)),j=T.comment,I=o.transformTo("string",E(j)),O=o.transformTo("string",u.utf8encode(j)),q=N.length!==T.name.length,R=O.length!==j.length,W="",K="",G="",te=T.dir,Y=T.date,J={crc32:0,compressedSize:0,uncompressedSize:0};x&&!v||(J.crc32=p.crc32,J.compressedSize=p.compressedSize,J.uncompressedSize=p.uncompressedSize);var U=0;x&&(U|=8),k||!q&&!R||(U|=2048);var H=0,ee=0;te&&(H|=16),b==="UNIX"?(ee=798,H|=(function(pe,ue){var be=pe;return pe||(be=ue?16893:33204),(65535&be)<<16})(T.unixPermissions,te)):(ee=20,H|=(function(pe){return 63&(pe||0)})(T.dosPermissions)),w=Y.getUTCHours(),w<<=6,w|=Y.getUTCMinutes(),w<<=5,w|=Y.getUTCSeconds()/2,A=Y.getUTCFullYear()-1980,A<<=4,A|=Y.getUTCMonth()+1,A<<=5,A|=Y.getUTCDate(),q&&(K=a(1,1)+a(d(F),4)+N,W+="up"+a(K.length,2)+K),R&&(G=a(1,1)+a(d(I),4)+O,W+="uc"+a(G.length,2)+G);var ie="";return ie+=`
  3874. \0`,ie+=a(U,2),ie+=C.magic,ie+=a(w,2),ie+=a(A,2),ie+=a(J.crc32,4),ie+=a(J.compressedSize,4),ie+=a(J.uncompressedSize,4),ie+=a(F.length,2),ie+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ie+F+W,dirRecord:f.CENTRAL_FILE_HEADER+a(ee,2)+ie+a(I.length,2)+"\0\0\0\0"+a(H,4)+a(y,4)+F+W+I}}var o=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(p,x,v,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=v,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(g,c),g.prototype.push=function(p){var x=p.meta.percent||0,v=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:v?(x+100*(v-y-1))/v:100}}))},g.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var v=s(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,v=s(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),x)this.push({data:(function(y){return f.DATA_DESCRIPTOR+a(y.crc32,4)+a(y.compressedSize,4)+a(y.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var v=this.bytesWritten-p,y=(function(b,E,w,A,T){var C=o.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(b,2)+a(b,2)+a(E,4)+a(w,4)+a(C.length,2)+C})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:y,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(p){this._sources.push(p);var x=this;return p.on("data",function(v){x.processChunk(v)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(v){x.error(v)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var v=0;v<x.length;v++)try{x[v].error(p)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(o,c,u){var d=new s(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{o.forEach(function(g,p){f++;var x=(function(E,w){var A=E||w,T=a[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(p.options.compression,c.compression),v=p.options.compressionOptions||c.compressionOptions||{},y=p.dir,b=p.date;p._compressWorker(x,v).withStreamInfo("file",{name:g,dir:y,date:b,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,o){return new a().loadAsync(s,o)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),s=n("./external"),o=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new s.Promise(function(p,x){var v=g.decompressed.getContentWorker().pipe(new u);v.on("error",function(y){x(y)}).on("end",function(){v.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(g,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,p.optimizedBinaryString,p.base64).then(function(v){var y=new c(p);return y.load(v),y}).then(function(v){var y=[s.Promise.resolve(v)],b=v.files;if(p.checkCRC32)for(var E=0;E<b.length;E++)y.push(f(b[E]));return s.Promise.all(y)}).then(function(v){for(var y=v.shift(),b=y.files,E=0;E<b.length;E++){var w=b[E],A=w.fileNameStr,T=a.resolve(w.fileNameStr);x.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:p.createFolders}),w.dir||(x.file(T).unsafeOriginalName=A)}return y.zipComment.length&&(x.comment=y.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),s=n("../stream/GenericWorker");function o(c,u){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(o,s),o.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function s(o,c,u){a.call(this,c),this._helper=o;var d=this;o.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(T,C,k){var F,N=o.getTypeOf(C),j=o.extend(k||{},d);j.date=j.date||new Date,j.compression!==null&&(j.compression=j.compression.toUpperCase()),typeof j.unixPermissions=="string"&&(j.unixPermissions=parseInt(j.unixPermissions,8)),j.unixPermissions&&16384&j.unixPermissions&&(j.dir=!0),j.dosPermissions&&16&j.dosPermissions&&(j.dir=!0),j.dir&&(T=b(T)),j.createFolders&&(F=y(T))&&E.call(this,F,!0);var I=N==="string"&&j.binary===!1&&j.base64===!1;k&&k.binary!==void 0||(j.binary=!I),(C instanceof f&&C.uncompressedSize===0||j.dir||!C||C.length===0)&&(j.base64=!1,j.binary=!0,C="",j.compression="STORE",N="string");var O=null;O=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new v(T,C):o.prepareContent(T,C,j.binary,j.optimizedBinaryString,j.base64);var q=new g(T,O,j);this.files[T]=q}var s=n("./utf8"),o=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),y=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var C=T.lastIndexOf("/");return 0<C?T.substring(0,C):""},b=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},E=function(T,C){return C=C!==void 0?C:d.createFolders,T=b(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:C}),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 C,k,F;for(C in this.files)F=this.files[C],(k=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&T(k,F)},filter:function(T){var C=[];return this.forEach(function(k,F){T(k,F)&&C.push(F)}),C},file:function(T,C,k){if(arguments.length!==1)return T=this.root+T,a.call(this,T,C,k),this;if(w(T)){var F=T;return this.filter(function(j,I){return!I.dir&&F.test(j)})}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,j){return j.dir&&T.test(N)});var C=this.root+T,k=E.call(this,C),F=this.clone();return F.root=k.name,F},remove:function(T){T=this.root+T;var C=this.files[T];if(C||(T.slice(-1)!=="/"&&(T+="/"),C=this.files[T]),C&&!C.dir)delete this.files[T];else for(var k=this.filter(function(N,j){return j.name.slice(0,T.length)===T}),F=0;F<k.length;F++)delete this.files[k[F].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 C,k={};try{if((k=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=k.type.toLowerCase(),k.compression=k.compression.toUpperCase(),k.type==="binarystring"&&(k.type="string"),!k.type)throw new Error("No output type specified.");o.checkSupport(k.type),k.platform!=="darwin"&&k.platform!=="freebsd"&&k.platform!=="linux"&&k.platform!=="sunos"||(k.platform="UNIX"),k.platform==="win32"&&(k.platform="DOS");var F=k.comment||this.comment||"";C=p.generateWorker(this,k,F)}catch(N){(C=new c("error")).error(N)}return new u(C,k.type||"string",k.mimeType)},generateAsync:function(T,C){return this.generateInternalStream(T).accumulate(C)},generateNodeStream:function(T,C){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(C)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o);for(var c=0;c<this.data.length;c++)o[c]=255&o[c]}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.readData(4);return c===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var c,u=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=o,u},readString:function(o){return a.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),s=n("../support"),o=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=a.getTypeOf(f);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new u(f):s.uint8array?new d(a.transformTo("uint8array",f)):new o(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),s=n("../utils");function o(c){a.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(o,a),o.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),s=n("../crc32");function o(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,a),o.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(o,s),o.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}s.prototype.processChunk.call(this,c)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function o(c){s.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(c){o.processChunk(c)}),s.on("end",function(){o.end()}),s.on("error",function(c){o.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),s=n("./ConvertWorker"),o=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,v){return new d.Promise(function(y,b){var E=[],w=x._internalType,A=x._outputType,T=x._mimeType;x.on("data",function(C,k){E.push(C),v&&v(k)}).on("error",function(C){E=[],b(C)}).on("end",function(){try{var C=(function(k,F,N){switch(k){case"blob":return a.newBlob(a.transformTo("arraybuffer",F),N);case"base64":return c.encode(F);default:return a.transformTo(k,F)}})(A,(function(k,F){var N,j=0,I=null,O=0;for(N=0;N<F.length;N++)O+=F[N].length;switch(k){case"string":return F.join("");case"array":return Array.prototype.concat.apply([],F);case"uint8array":for(I=new Uint8Array(O),N=0;N<F.length;N++)I.set(F[N],j),j+=F[N].length;return I;case"nodebuffer":return Buffer.concat(F);default:throw new Error("concat : unsupported type '"+k+"'")}})(w,E),T);y(C)}catch(k){b(k)}E=[]}).resume()})}function p(x,v,y){var b=v;switch(v){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=v,this._mimeType=y,a.checkSupport(b),this._worker=x.pipe(new s(b)),x.lock()}catch(E){this._worker=new o("error"),this._worker.error(E)}}p.prototype={accumulate:function(x){return g(this,x)},on:function(x,v){var y=this;return x==="data"?this._worker.on(x,function(b){v.call(y,b.data,b.meta)}):this._worker.on(x,function(){a.delay(v,arguments,y)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),s=n("./support"),o=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return s.nodebuffer?o.newBufferFrom(p,"utf-8"):(function(x){var v,y,b,E,w,A=x.length,T=0;for(E=0;E<A;E++)(64512&(y=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),E++),T+=y<128?1:y<2048?2:y<65536?3:4;for(v=s.uint8array?new Uint8Array(T):new Array(T),E=w=0;w<T;E++)(64512&(y=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),E++),y<128?v[w++]=y:(y<2048?v[w++]=192|y>>>6:(y<65536?v[w++]=224|y>>>12:(v[w++]=240|y>>>18,v[w++]=128|y>>>12&63),v[w++]=128|y>>>6&63),v[w++]=128|63&y);return v})(p)},i.utf8decode=function(p){return s.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var v,y,b,E,w=x.length,A=new Array(2*w);for(v=y=0;v<w;)if((b=x[v++])<128)A[y++]=b;else if(4<(E=u[b]))A[y++]=65533,v+=E-1;else{for(b&=E===2?31:E===3?15:7;1<E&&v<w;)b=b<<6|63&x[v++],E--;1<E?A[y++]=65533:b<65536?A[y++]=b:(b-=65536,A[y++]=55296|b>>10&1023,A[y++]=56320|1023&b)}return A.length!==y&&(A.subarray?A=A.subarray(0,y):A.length=y),a.applyFromCharCode(A)})(p=a.transformTo(s.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var x=a.transformTo(s.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=x;(x=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),x.set(v,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var y=(function(E,w){var A;for((w=w||E.length)>E.length&&(w=E.length),A=w-1;0<=A&&(192&E[A])==128;)A--;return A<0||A===0?w:A+u[E[A]]>w?A:w})(x),b=x;y!==x.length&&(s.uint8array?(b=x.subarray(0,y),this.leftOver=x.subarray(y,x.length)):(b=x.slice(0,y),this.leftOver=x.slice(y,x.length))),this.push({data:i.utf8decode(b),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(g,c),g.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),s=n("./base64"),o=n("./nodejsUtils"),c=n("./external");function u(v){return v}function d(v,y){for(var b=0;b<v.length;++b)y[b]=255&v.charCodeAt(b);return y}n("setimmediate"),i.newBlob=function(v,y){i.checkSupport("blob");try{return new Blob([v],{type:y})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(v),b.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,y,b){var E=[],w=0,A=v.length;if(A<=b)return String.fromCharCode.apply(null,v);for(;w<A;)y==="array"||y==="nodebuffer"?E.push(String.fromCharCode.apply(null,v.slice(w,Math.min(w+b,A)))):E.push(String.fromCharCode.apply(null,v.subarray(w,Math.min(w+b,A)))),w+=b;return E.join("")},stringifyByChar:function(v){for(var y="",b=0;b<v.length;b++)y+=String.fromCharCode(v[b]);return y},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(v){var y=65536,b=i.getTypeOf(v),E=!0;if(b==="uint8array"?E=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<y;)try{return f.stringifyByChunk(v,b,y)}catch{y=Math.floor(y/2)}return f.stringifyByChar(v)}function p(v,y){for(var b=0;b<v.length;b++)y[b]=v[b];return y}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return x.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,o.allocBuffer(v.length))}},x.array={string:g,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(v)}},x.arraybuffer={string:function(v){return g(new Uint8Array(v))},array:function(v){return p(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return o.newBufferFrom(new Uint8Array(v))}},x.uint8array={string:g,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return o.newBufferFrom(v)}},x.nodebuffer={string:g,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return x.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,y){if(y=y||"",!v)return y;i.checkSupport(v);var b=i.getTypeOf(y);return x[b][v](y)},i.resolve=function(v){for(var y=v.split("/"),b=[],E=0;E<y.length;E++){var w=y[E];w==="."||w===""&&E!==0&&E!==y.length-1||(w===".."?b.pop():b.push(w))}return b.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var y,b,E="";for(b=0;b<(v||"").length;b++)E+="\\x"+((y=v.charCodeAt(b))<16?"0":"")+y.toString(16).toUpperCase();return E},i.delay=function(v,y,b){setImmediate(function(){v.apply(b||null,y||[])})},i.inherits=function(v,y){function b(){}b.prototype=y.prototype,v.prototype=new b},i.extend=function(){var v,y,b={};for(v=0;v<arguments.length;v++)for(y in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],y)&&b[y]===void 0&&(b[y]=arguments[v][y]);return b},i.prepareContent=function(v,y,b,E,w){return c.Promise.resolve(y).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(T,C){var k=new FileReader;k.onload=function(F){T(F.target.result)},k.onerror=function(F){C(F.target.error)},k.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(w?A=s.decode(A):b&&E!==!0&&(A=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(A))),A):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(f)+")")}},isSignature:function(f,g){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===g;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",p=s.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),g=this.reader.readInt(4),p=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=g-p;if(0<x)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(p,x){this.options=p,this.loadOptions=x}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,v;if(p.skip(22),this.fileNameLength=p.readInt(2),v=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(y){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===y)return d[b];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,v,y,b=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<b;)x=p.readInt(2),v=p.readInt(2),y=p.readData(v),this.extraFields[x]={id:x,length:v,value:y};p.setIndex(b)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var v=s.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var b=s.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,v,y){this.name=x,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=v,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var s=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var v=null,y="string";try{if(!x)throw new Error("No output type specified.");var b=(y=x.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),v=this._decompressWorker();var E=!this._dataBinary;E&&!b&&(v=v.pipe(new c.Utf8EncodeWorker)),!E&&b&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(w){(v=new d("error")).error(w)}return new s(v,y,"")},async:function(x,v){return this.internalStream(x).accumulate(v)},nodeStream:function(x,v){return this.internalStream(x||"nodebuffer").toNodejsStream(v)},_compressWorker:function(x,v){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,x,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)a.prototype[f[p]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var s,o,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),s=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var v=a.document.createElement("script");v.onreadystatechange=function(){x(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(x,0)};else{var g=new a.MessageChannel;g.port1.onmessage=x,s=function(){g.port2.postMessage(0)}}var p=[];function x(){var v,y;o=!0;for(var b=p.length;b;){for(y=p,p=[],v=-1;++v<b;)y[v]();b=p.length}o=!1}r.exports=function(v){p.push(v)!==1||o||s()}}).call(this,typeof mv<"u"?mv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function s(){}var o={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==s&&v(this,b)}function g(b,E,w){this.promise=b,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(b,E,w){a(function(){var A;try{A=E(w)}catch(T){return o.reject(b,T)}A===b?o.reject(b,new TypeError("Cannot resolve promise with itself")):o.resolve(b,A)})}function x(b){var E=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof E=="function")return function(){E.apply(b,arguments)}}function v(b,E){var w=!1;function A(k){w||(w=!0,o.reject(b,k))}function T(k){w||(w=!0,o.resolve(b,k))}var C=y(function(){E(T,A)});C.status==="error"&&A(C.value)}function y(b,E){var w={};try{w.value=b(E),w.status="success"}catch(A){w.status="error",w.value=A}return w}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(b()).then(function(){return w})},function(w){return E.resolve(b()).then(function(){throw w})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,E){if(typeof b!="function"&&this.state===u||typeof E!="function"&&this.state===c)return this;var w=new this.constructor(s);return this.state!==d?p(w,this.state===u?b:E,this.outcome):this.queue.push(new g(w,b,E)),w},g.prototype.callFulfilled=function(b){o.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){p(this.promise,this.onFulfilled,b)},g.prototype.callRejected=function(b){o.reject(this.promise,b)},g.prototype.otherCallRejected=function(b){p(this.promise,this.onRejected,b)},o.resolve=function(b,E){var w=y(x,E);if(w.status==="error")return o.reject(b,w.value);var A=w.value;if(A)v(b,A);else{b.state=u,b.outcome=E;for(var T=-1,C=b.queue.length;++T<C;)b.queue[T].callFulfilled(E)}return b},o.reject=function(b,E){b.state=c,b.outcome=E;for(var w=-1,A=b.queue.length;++w<A;)b.queue[w].callRejected(E);return b},f.resolve=function(b){return b instanceof this?b:o.resolve(new this(s),b)},f.reject=function(b){var E=new this(s);return o.reject(E,b)},f.all=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=b.length,A=!1;if(!w)return this.resolve([]);for(var T=new Array(w),C=0,k=-1,F=new this(s);++k<w;)N(b[k],k);return F;function N(j,I){E.resolve(j).then(function(O){T[I]=O,++C!==w||A||(A=!0,o.resolve(F,T))},function(O){A||(A=!0,o.reject(F,O))})}},f.race=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=b.length,A=!1;if(!w)return this.resolve([]);for(var T=-1,C=new this(s);++T<w;)k=b[T],E.resolve(k).then(function(F){A||(A=!0,o.resolve(C,F))},function(F){A||(A=!0,o.reject(C,F))});var k;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,p=0,x=8;function v(b){if(!(this instanceof v))return new v(b);this.options=s.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},b||{});var E=this.options;E.raw&&0<E.windowBits?E.windowBits=-E.windowBits:E.gzip&&0<E.windowBits&&E.windowBits<16&&(E.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(w!==f)throw new Error(c[w]);if(E.header&&a.deflateSetHeader(this.strm,E.header),E.dictionary){var A;if(A=typeof E.dictionary=="string"?o.string2buf(E.dictionary):d.call(E.dictionary)==="[object ArrayBuffer]"?new Uint8Array(E.dictionary):E.dictionary,(w=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[w]);this._dict_set=!0}}function y(b,E){var w=new v(E);if(w.push(b,!0),w.err)throw w.msg||c[w.err];return w.result}v.prototype.push=function(b,E){var w,A,T=this.strm,C=this.options.chunkSize;if(this.ended)return!1;A=E===~~E?E:E===!0?4:0,typeof b=="string"?T.input=o.string2buf(b):d.call(b)==="[object ArrayBuffer]"?T.input=new Uint8Array(b):T.input=b,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(C),T.next_out=0,T.avail_out=C),(w=a.deflate(T,A))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(T.output,T.next_out))):this.onData(s.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&w!==1);return A===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):A!==2||(this.onEnd(f),!(T.avail_out=0))},v.prototype.onData=function(b){this.chunks.push(b)},v.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Deflate=v,i.deflate=y,i.deflateRaw=function(b,E){return(E=E||{}).raw=!0,y(b,E)},i.gzip=function(b,E){return(E=E||{}).gzip=!0,y(b,E)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),s=n("./utils/common"),o=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function p(v){if(!(this instanceof p))return new p(v);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},v||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||v&&v.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=a.inflateInit2(this.strm,y.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(v,y){var b=new p(y);if(b.push(v,!0),b.err)throw b.msg||u[b.err];return b.result}p.prototype.push=function(v,y){var b,E,w,A,T,C,k=this.strm,F=this.options.chunkSize,N=this.options.dictionary,j=!1;if(this.ended)return!1;E=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?k.input=o.binstring2buf(v):g.call(v)==="[object ArrayBuffer]"?k.input=new Uint8Array(v):k.input=v,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new s.Buf8(F),k.next_out=0,k.avail_out=F),(b=a.inflate(k,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&N&&(C=typeof N=="string"?o.string2buf(N):g.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,b=a.inflateSetDictionary(this.strm,C)),b===c.Z_BUF_ERROR&&j===!0&&(b=c.Z_OK,j=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);k.next_out&&(k.avail_out!==0&&b!==c.Z_STREAM_END&&(k.avail_in!==0||E!==c.Z_FINISH&&E!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=o.utf8border(k.output,k.next_out),A=k.next_out-w,T=o.buf2string(k.output,w),k.next_out=A,k.avail_out=F-A,A&&s.arraySet(k.output,k.output,w,A,0),this.onData(T)):this.onData(s.shrinkBuf(k.output,k.next_out)))),k.avail_in===0&&k.avail_out===0&&(j=!0)}while((0<k.avail_in||k.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(b=a.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):E!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(k.avail_out=0))},p.prototype.onData=function(v){this.chunks.push(v)},p.prototype.onEnd=function(v){v===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Inflate=p,i.inflate=x,i.inflateRaw=function(v,y){return(y=y||{}).raw=!0,x(v,y)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var s={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){var u,d,f,g,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)p=c[u],x.set(p,g),g+=p.length;return x}},o={arraySet:function(c,u,d,f,g){for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&o||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var p="",x=0;x<g;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var g,p,x,v,y,b=f.length,E=0;for(v=0;v<b;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),E+=p<128?1:p<2048?2:p<65536?3:4;for(g=new a.Buf8(E),v=y=0;y<E;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),p<128?g[y++]=p:(p<2048?g[y++]=192|p>>>6:(p<65536?g[y++]=224|p>>>12:(g[y++]=240|p>>>18,g[y++]=128|p>>>12&63),g[y++]=128|p>>>6&63),g[y++]=128|63&p);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new a.Buf8(f.length),p=0,x=g.length;p<x;p++)g[p]=f.charCodeAt(p);return g},i.buf2string=function(f,g){var p,x,v,y,b=g||f.length,E=new Array(2*b);for(p=x=0;p<b;)if((v=f[p++])<128)E[x++]=v;else if(4<(y=c[v]))E[x++]=65533,p+=y-1;else{for(v&=y===2?31:y===3?15:7;1<y&&p<b;)v=v<<6|63&f[p++],y--;1<y?E[x++]=65533:v<65536?E[x++]=v:(v-=65536,E[x++]=55296|v>>10&1023,E[x++]=56320|1023&v)}return d(E,x)},i.utf8border=function(f,g){var p;for((g=g||f.length)>f.length&&(g=f.length),p=g-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?g:p+c[f[p]]>g?p:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,s,o,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;d=d+(u=u+s[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(function(){for(var s,o=[],c=0;c<256;c++){s=c;for(var u=0;u<8;u++)s=1&s?3988292384^s>>>1:s>>>1;o[c]=s}return o})();r.exports=function(s,o,c,u){var d=a,f=u+c;s^=-1;for(var g=u;g<f;g++)s=s>>>8^d[255&(s^o[g])];return-1^s}},{}],46:[function(n,r,i){var a,s=n("../utils/common"),o=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,p=0,x=-2,v=-1,y=4,b=2,E=8,w=9,A=286,T=30,C=19,k=2*A+1,F=15,N=3,j=258,I=j+N+1,O=42,q=113,R=1,W=2,K=3,G=4;function te(z,B){return z.msg=d[B],B}function Y(z){return(z<<1)-(4<z?9:0)}function J(z){for(var B=z.length;0<=--B;)z[B]=0}function U(z){var B=z.state,ne=B.pending;ne>z.avail_out&&(ne=z.avail_out),ne!==0&&(s.arraySet(z.output,B.pending_buf,B.pending_out,ne,z.next_out),z.next_out+=ne,B.pending_out+=ne,z.total_out+=ne,z.avail_out-=ne,B.pending-=ne,B.pending===0&&(B.pending_out=0))}function H(z,B){o._tr_flush_block(z,0<=z.block_start?z.block_start:-1,z.strstart-z.block_start,B),z.block_start=z.strstart,U(z.strm)}function ee(z,B){z.pending_buf[z.pending++]=B}function ie(z,B){z.pending_buf[z.pending++]=B>>>8&255,z.pending_buf[z.pending++]=255&B}function pe(z,B){var ne,V,Q=z.max_chain_length,se=z.strstart,Me=z.prev_length,Ae=z.nice_match,Se=z.strstart>z.w_size-I?z.strstart-(z.w_size-I):0,$=z.window,L=z.w_mask,re=z.prev,ye=z.strstart+j,we=$[se+Me-1],xe=$[se+Me];z.prev_length>=z.good_match&&(Q>>=2),Ae>z.lookahead&&(Ae=z.lookahead);do if($[(ne=B)+Me]===xe&&$[ne+Me-1]===we&&$[ne]===$[se]&&$[++ne]===$[se+1]){se+=2,ne++;do;while($[++se]===$[++ne]&&$[++se]===$[++ne]&&$[++se]===$[++ne]&&$[++se]===$[++ne]&&$[++se]===$[++ne]&&$[++se]===$[++ne]&&$[++se]===$[++ne]&&$[++se]===$[++ne]&&se<ye);if(V=j-(ye-se),se=ye-j,Me<V){if(z.match_start=B,Ae<=(Me=V))break;we=$[se+Me-1],xe=$[se+Me]}}while((B=re[B&L])>Se&&--Q!=0);return Me<=z.lookahead?Me:z.lookahead}function ue(z){var B,ne,V,Q,se,Me,Ae,Se,$,L,re=z.w_size;do{if(Q=z.window_size-z.lookahead-z.strstart,z.strstart>=re+(re-I)){for(s.arraySet(z.window,z.window,re,re,0),z.match_start-=re,z.strstart-=re,z.block_start-=re,B=ne=z.hash_size;V=z.head[--B],z.head[B]=re<=V?V-re:0,--ne;);for(B=ne=re;V=z.prev[--B],z.prev[B]=re<=V?V-re:0,--ne;);Q+=re}if(z.strm.avail_in===0)break;if(Me=z.strm,Ae=z.window,Se=z.strstart+z.lookahead,$=Q,L=void 0,L=Me.avail_in,$<L&&(L=$),ne=L===0?0:(Me.avail_in-=L,s.arraySet(Ae,Me.input,Me.next_in,L,Se),Me.state.wrap===1?Me.adler=c(Me.adler,Ae,L,Se):Me.state.wrap===2&&(Me.adler=u(Me.adler,Ae,L,Se)),Me.next_in+=L,Me.total_in+=L,L),z.lookahead+=ne,z.lookahead+z.insert>=N)for(se=z.strstart-z.insert,z.ins_h=z.window[se],z.ins_h=(z.ins_h<<z.hash_shift^z.window[se+1])&z.hash_mask;z.insert&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[se+N-1])&z.hash_mask,z.prev[se&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=se,se++,z.insert--,!(z.lookahead+z.insert<N)););}while(z.lookahead<I&&z.strm.avail_in!==0)}function be(z,B){for(var ne,V;;){if(z.lookahead<I){if(ue(z),z.lookahead<I&&B===f)return R;if(z.lookahead===0)break}if(ne=0,z.lookahead>=N&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+N-1])&z.hash_mask,ne=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),ne!==0&&z.strstart-ne<=z.w_size-I&&(z.match_length=pe(z,ne)),z.match_length>=N)if(V=o._tr_tally(z,z.strstart-z.match_start,z.match_length-N),z.lookahead-=z.match_length,z.match_length<=z.max_lazy_match&&z.lookahead>=N){for(z.match_length--;z.strstart++,z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+N-1])&z.hash_mask,ne=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart,--z.match_length!=0;);z.strstart++}else z.strstart+=z.match_length,z.match_length=0,z.ins_h=z.window[z.strstart],z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+1])&z.hash_mask;else V=o._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++;if(V&&(H(z,!1),z.strm.avail_out===0))return R}return z.insert=z.strstart<N-1?z.strstart:N-1,B===g?(H(z,!0),z.strm.avail_out===0?K:G):z.last_lit&&(H(z,!1),z.strm.avail_out===0)?R:W}function Re(z,B){for(var ne,V,Q;;){if(z.lookahead<I){if(ue(z),z.lookahead<I&&B===f)return R;if(z.lookahead===0)break}if(ne=0,z.lookahead>=N&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+N-1])&z.hash_mask,ne=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),z.prev_length=z.match_length,z.prev_match=z.match_start,z.match_length=N-1,ne!==0&&z.prev_length<z.max_lazy_match&&z.strstart-ne<=z.w_size-I&&(z.match_length=pe(z,ne),z.match_length<=5&&(z.strategy===1||z.match_length===N&&4096<z.strstart-z.match_start)&&(z.match_length=N-1)),z.prev_length>=N&&z.match_length<=z.prev_length){for(Q=z.strstart+z.lookahead-N,V=o._tr_tally(z,z.strstart-1-z.prev_match,z.prev_length-N),z.lookahead-=z.prev_length-1,z.prev_length-=2;++z.strstart<=Q&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+N-1])&z.hash_mask,ne=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),--z.prev_length!=0;);if(z.match_available=0,z.match_length=N-1,z.strstart++,V&&(H(z,!1),z.strm.avail_out===0))return R}else if(z.match_available){if((V=o._tr_tally(z,0,z.window[z.strstart-1]))&&H(z,!1),z.strstart++,z.lookahead--,z.strm.avail_out===0)return R}else z.match_available=1,z.strstart++,z.lookahead--}return z.match_available&&(V=o._tr_tally(z,0,z.window[z.strstart-1]),z.match_available=0),z.insert=z.strstart<N-1?z.strstart:N-1,B===g?(H(z,!0),z.strm.avail_out===0?K:G):z.last_lit&&(H(z,!1),z.strm.avail_out===0)?R:W}function Z(z,B,ne,V,Q){this.good_length=z,this.max_lazy=B,this.nice_length=ne,this.max_chain=V,this.func=Q}function _e(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=E,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*k),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*C+1)),J(this.dyn_ltree),J(this.dyn_dtree),J(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(F+1),this.heap=new s.Buf16(2*A+1),J(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*A+1),J(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 Le(z){var B;return z&&z.state?(z.total_in=z.total_out=0,z.data_type=b,(B=z.state).pending=0,B.pending_out=0,B.wrap<0&&(B.wrap=-B.wrap),B.status=B.wrap?O:q,z.adler=B.wrap===2?0:1,B.last_flush=f,o._tr_init(B),p):te(z,x)}function ce(z){var B=Le(z);return B===p&&(function(ne){ne.window_size=2*ne.w_size,J(ne.head),ne.max_lazy_match=a[ne.level].max_lazy,ne.good_match=a[ne.level].good_length,ne.nice_match=a[ne.level].nice_length,ne.max_chain_length=a[ne.level].max_chain,ne.strstart=0,ne.block_start=0,ne.lookahead=0,ne.insert=0,ne.match_length=ne.prev_length=N-1,ne.match_available=0,ne.ins_h=0})(z.state),B}function Ie(z,B,ne,V,Q,se){if(!z)return x;var Me=1;if(B===v&&(B=6),V<0?(Me=0,V=-V):15<V&&(Me=2,V-=16),Q<1||w<Q||ne!==E||V<8||15<V||B<0||9<B||se<0||y<se)return te(z,x);V===8&&(V=9);var Ae=new _e;return(z.state=Ae).strm=z,Ae.wrap=Me,Ae.gzhead=null,Ae.w_bits=V,Ae.w_size=1<<Ae.w_bits,Ae.w_mask=Ae.w_size-1,Ae.hash_bits=Q+7,Ae.hash_size=1<<Ae.hash_bits,Ae.hash_mask=Ae.hash_size-1,Ae.hash_shift=~~((Ae.hash_bits+N-1)/N),Ae.window=new s.Buf8(2*Ae.w_size),Ae.head=new s.Buf16(Ae.hash_size),Ae.prev=new s.Buf16(Ae.w_size),Ae.lit_bufsize=1<<Q+6,Ae.pending_buf_size=4*Ae.lit_bufsize,Ae.pending_buf=new s.Buf8(Ae.pending_buf_size),Ae.d_buf=1*Ae.lit_bufsize,Ae.l_buf=3*Ae.lit_bufsize,Ae.level=B,Ae.strategy=se,Ae.method=ne,ce(z)}a=[new Z(0,0,0,0,function(z,B){var ne=65535;for(ne>z.pending_buf_size-5&&(ne=z.pending_buf_size-5);;){if(z.lookahead<=1){if(ue(z),z.lookahead===0&&B===f)return R;if(z.lookahead===0)break}z.strstart+=z.lookahead,z.lookahead=0;var V=z.block_start+ne;if((z.strstart===0||z.strstart>=V)&&(z.lookahead=z.strstart-V,z.strstart=V,H(z,!1),z.strm.avail_out===0)||z.strstart-z.block_start>=z.w_size-I&&(H(z,!1),z.strm.avail_out===0))return R}return z.insert=0,B===g?(H(z,!0),z.strm.avail_out===0?K:G):(z.strstart>z.block_start&&(H(z,!1),z.strm.avail_out),R)}),new Z(4,4,8,4,be),new Z(4,5,16,8,be),new Z(4,6,32,32,be),new Z(4,4,16,16,Re),new Z(8,16,32,32,Re),new Z(8,16,128,128,Re),new Z(8,32,128,256,Re),new Z(32,128,258,1024,Re),new Z(32,258,258,4096,Re)],i.deflateInit=function(z,B){return Ie(z,B,E,15,8,0)},i.deflateInit2=Ie,i.deflateReset=ce,i.deflateResetKeep=Le,i.deflateSetHeader=function(z,B){return z&&z.state?z.state.wrap!==2?x:(z.state.gzhead=B,p):x},i.deflate=function(z,B){var ne,V,Q,se;if(!z||!z.state||5<B||B<0)return z?te(z,x):x;if(V=z.state,!z.output||!z.input&&z.avail_in!==0||V.status===666&&B!==g)return te(z,z.avail_out===0?-5:x);if(V.strm=z,ne=V.last_flush,V.last_flush=B,V.status===O)if(V.wrap===2)z.adler=0,ee(V,31),ee(V,139),ee(V,8),V.gzhead?(ee(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)),ee(V,255&V.gzhead.time),ee(V,V.gzhead.time>>8&255),ee(V,V.gzhead.time>>16&255),ee(V,V.gzhead.time>>24&255),ee(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),ee(V,255&V.gzhead.os),V.gzhead.extra&&V.gzhead.extra.length&&(ee(V,255&V.gzhead.extra.length),ee(V,V.gzhead.extra.length>>8&255)),V.gzhead.hcrc&&(z.adler=u(z.adler,V.pending_buf,V.pending,0)),V.gzindex=0,V.status=69):(ee(V,0),ee(V,0),ee(V,0),ee(V,0),ee(V,0),ee(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),ee(V,3),V.status=q);else{var Me=E+(V.w_bits-8<<4)<<8;Me|=(2<=V.strategy||V.level<2?0:V.level<6?1:V.level===6?2:3)<<6,V.strstart!==0&&(Me|=32),Me+=31-Me%31,V.status=q,ie(V,Me),V.strstart!==0&&(ie(V,z.adler>>>16),ie(V,65535&z.adler)),z.adler=1}if(V.status===69)if(V.gzhead.extra){for(Q=V.pending;V.gzindex<(65535&V.gzhead.extra.length)&&(V.pending!==V.pending_buf_size||(V.gzhead.hcrc&&V.pending>Q&&(z.adler=u(z.adler,V.pending_buf,V.pending-Q,Q)),U(z),Q=V.pending,V.pending!==V.pending_buf_size));)ee(V,255&V.gzhead.extra[V.gzindex]),V.gzindex++;V.gzhead.hcrc&&V.pending>Q&&(z.adler=u(z.adler,V.pending_buf,V.pending-Q,Q)),V.gzindex===V.gzhead.extra.length&&(V.gzindex=0,V.status=73)}else V.status=73;if(V.status===73)if(V.gzhead.name){Q=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>Q&&(z.adler=u(z.adler,V.pending_buf,V.pending-Q,Q)),U(z),Q=V.pending,V.pending===V.pending_buf_size)){se=1;break}se=V.gzindex<V.gzhead.name.length?255&V.gzhead.name.charCodeAt(V.gzindex++):0,ee(V,se)}while(se!==0);V.gzhead.hcrc&&V.pending>Q&&(z.adler=u(z.adler,V.pending_buf,V.pending-Q,Q)),se===0&&(V.gzindex=0,V.status=91)}else V.status=91;if(V.status===91)if(V.gzhead.comment){Q=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>Q&&(z.adler=u(z.adler,V.pending_buf,V.pending-Q,Q)),U(z),Q=V.pending,V.pending===V.pending_buf_size)){se=1;break}se=V.gzindex<V.gzhead.comment.length?255&V.gzhead.comment.charCodeAt(V.gzindex++):0,ee(V,se)}while(se!==0);V.gzhead.hcrc&&V.pending>Q&&(z.adler=u(z.adler,V.pending_buf,V.pending-Q,Q)),se===0&&(V.status=103)}else V.status=103;if(V.status===103&&(V.gzhead.hcrc?(V.pending+2>V.pending_buf_size&&U(z),V.pending+2<=V.pending_buf_size&&(ee(V,255&z.adler),ee(V,z.adler>>8&255),z.adler=0,V.status=q)):V.status=q),V.pending!==0){if(U(z),z.avail_out===0)return V.last_flush=-1,p}else if(z.avail_in===0&&Y(B)<=Y(ne)&&B!==g)return te(z,-5);if(V.status===666&&z.avail_in!==0)return te(z,-5);if(z.avail_in!==0||V.lookahead!==0||B!==f&&V.status!==666){var Ae=V.strategy===2?(function(Se,$){for(var L;;){if(Se.lookahead===0&&(ue(Se),Se.lookahead===0)){if($===f)return R;break}if(Se.match_length=0,L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++,L&&(H(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,$===g?(H(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&(H(Se,!1),Se.strm.avail_out===0)?R:W})(V,B):V.strategy===3?(function(Se,$){for(var L,re,ye,we,xe=Se.window;;){if(Se.lookahead<=j){if(ue(Se),Se.lookahead<=j&&$===f)return R;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=N&&0<Se.strstart&&(re=xe[ye=Se.strstart-1])===xe[++ye]&&re===xe[++ye]&&re===xe[++ye]){we=Se.strstart+j;do;while(re===xe[++ye]&&re===xe[++ye]&&re===xe[++ye]&&re===xe[++ye]&&re===xe[++ye]&&re===xe[++ye]&&re===xe[++ye]&&re===xe[++ye]&&ye<we);Se.match_length=j-(we-ye),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&&(H(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,$===g?(H(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&(H(Se,!1),Se.strm.avail_out===0)?R:W})(V,B):a[V.level].func(V,B);if(Ae!==K&&Ae!==G||(V.status=666),Ae===R||Ae===K)return z.avail_out===0&&(V.last_flush=-1),p;if(Ae===W&&(B===1?o._tr_align(V):B!==5&&(o._tr_stored_block(V,0,0,!1),B===3&&(J(V.head),V.lookahead===0&&(V.strstart=0,V.block_start=0,V.insert=0))),U(z),z.avail_out===0))return V.last_flush=-1,p}return B!==g?p:V.wrap<=0?1:(V.wrap===2?(ee(V,255&z.adler),ee(V,z.adler>>8&255),ee(V,z.adler>>16&255),ee(V,z.adler>>24&255),ee(V,255&z.total_in),ee(V,z.total_in>>8&255),ee(V,z.total_in>>16&255),ee(V,z.total_in>>24&255)):(ie(V,z.adler>>>16),ie(V,65535&z.adler)),U(z),0<V.wrap&&(V.wrap=-V.wrap),V.pending!==0?p:1)},i.deflateEnd=function(z){var B;return z&&z.state?(B=z.state.status)!==O&&B!==69&&B!==73&&B!==91&&B!==103&&B!==q&&B!==666?te(z,x):(z.state=null,B===q?te(z,-3):p):x},i.deflateSetDictionary=function(z,B){var ne,V,Q,se,Me,Ae,Se,$,L=B.length;if(!z||!z.state||(se=(ne=z.state).wrap)===2||se===1&&ne.status!==O||ne.lookahead)return x;for(se===1&&(z.adler=c(z.adler,B,L,0)),ne.wrap=0,L>=ne.w_size&&(se===0&&(J(ne.head),ne.strstart=0,ne.block_start=0,ne.insert=0),$=new s.Buf8(ne.w_size),s.arraySet($,B,L-ne.w_size,ne.w_size,0),B=$,L=ne.w_size),Me=z.avail_in,Ae=z.next_in,Se=z.input,z.avail_in=L,z.next_in=0,z.input=B,ue(ne);ne.lookahead>=N;){for(V=ne.strstart,Q=ne.lookahead-(N-1);ne.ins_h=(ne.ins_h<<ne.hash_shift^ne.window[V+N-1])&ne.hash_mask,ne.prev[V&ne.w_mask]=ne.head[ne.ins_h],ne.head[ne.ins_h]=V,V++,--Q;);ne.strstart=V,ne.lookahead=N-1,ue(ne)}return ne.strstart+=ne.lookahead,ne.block_start=ne.strstart,ne.insert=ne.lookahead,ne.lookahead=0,ne.match_length=ne.prev_length=N-1,ne.match_available=0,z.next_in=Ae,z.input=Se,z.avail_in=Me,ne.wrap=se,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,s){var o,c,u,d,f,g,p,x,v,y,b,E,w,A,T,C,k,F,N,j,I,O,q,R,W;o=a.state,c=a.next_in,R=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(s-a.avail_out),g=d+(a.avail_out-257),p=o.dmax,x=o.wsize,v=o.whave,y=o.wnext,b=o.window,E=o.hold,w=o.bits,A=o.lencode,T=o.distcode,C=(1<<o.lenbits)-1,k=(1<<o.distbits)-1;e:do{w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),F=A[E&C];t:for(;;){if(E>>>=N=F>>>24,w-=N,(N=F>>>16&255)===0)W[d++]=65535&F;else{if(!(16&N)){if((64&N)==0){F=A[(65535&F)+(E&(1<<N)-1)];continue t}if(32&N){o.mode=12;break e}a.msg="invalid literal/length code",o.mode=30;break e}j=65535&F,(N&=15)&&(w<N&&(E+=R[c++]<<w,w+=8),j+=E&(1<<N)-1,E>>>=N,w-=N),w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),F=T[E&k];n:for(;;){if(E>>>=N=F>>>24,w-=N,!(16&(N=F>>>16&255))){if((64&N)==0){F=T[(65535&F)+(E&(1<<N)-1)];continue n}a.msg="invalid distance code",o.mode=30;break e}if(I=65535&F,w<(N&=15)&&(E+=R[c++]<<w,(w+=8)<N&&(E+=R[c++]<<w,w+=8)),p<(I+=E&(1<<N)-1)){a.msg="invalid distance too far back",o.mode=30;break e}if(E>>>=N,w-=N,(N=d-f)<I){if(v<(N=I-N)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break e}if(q=b,(O=0)===y){if(O+=x-N,N<j){for(j-=N;W[d++]=b[O++],--N;);O=d-I,q=W}}else if(y<N){if(O+=x+y-N,(N-=y)<j){for(j-=N;W[d++]=b[O++],--N;);if(O=0,y<j){for(j-=N=y;W[d++]=b[O++],--N;);O=d-I,q=W}}}else if(O+=y-N,N<j){for(j-=N;W[d++]=b[O++],--N;);O=d-I,q=W}for(;2<j;)W[d++]=q[O++],W[d++]=q[O++],W[d++]=q[O++],j-=3;j&&(W[d++]=q[O++],1<j&&(W[d++]=q[O++]))}else{for(O=d-I;W[d++]=W[O++],W[d++]=W[O++],W[d++]=W[O++],2<(j-=3););j&&(W[d++]=W[O++],1<j&&(W[d++]=W[O++]))}break}}break}}while(c<u&&d<g);c-=j=w>>3,E&=(1<<(w-=j<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<g?g-d+257:257-(d-g),o.hold=E,o.bits=w}},{}],49:[function(n,r,i){var a=n("../utils/common"),s=n("./adler32"),o=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,p=-2,x=1,v=852,y=592;function b(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function E(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=x,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(v),q.distcode=q.distdyn=new a.Buf32(y),q.sane=1,q.back=-1,g):p}function A(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,w(O)):p}function T(O,q){var R,W;return O&&O.state?(W=O.state,q<0?(R=0,q=-q):(R=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=R,W.wbits=q,A(O))):p}function C(O,q){var R,W;return O?(W=new E,(O.state=W).window=null,(R=T(O,q))!==g&&(O.state=null),R):p}var k,F,N=!0;function j(O){if(N){var q;for(k=new a.Buf32(512),F=new a.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,k,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,F,0,O.work,{bits:5}),N=!1}O.lencode=k,O.lenbits=9,O.distcode=F,O.distbits=5}function I(O,q,R,W){var K,G=O.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),W>=G.wsize?(a.arraySet(G.window,q,R-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(K=G.wsize-G.wnext)&&(K=W),a.arraySet(G.window,q,R-W,K,G.wnext),(W-=K)?(a.arraySet(G.window,q,R-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=w,i.inflateInit=function(O){return C(O,15)},i.inflateInit2=C,i.inflate=function(O,q){var R,W,K,G,te,Y,J,U,H,ee,ie,pe,ue,be,Re,Z,_e,Le,ce,Ie,z,B,ne,V,Q=0,se=new a.Buf8(4),Me=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return p;(R=O.state).mode===12&&(R.mode=13),te=O.next_out,K=O.output,J=O.avail_out,G=O.next_in,W=O.input,Y=O.avail_in,U=R.hold,H=R.bits,ee=Y,ie=J,B=g;e:for(;;)switch(R.mode){case x:if(R.wrap===0){R.mode=13;break}for(;H<16;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(2&R.wrap&&U===35615){se[R.check=0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0),H=U=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&U)<<8)+(U>>8))%31){O.msg="incorrect header check",R.mode=30;break}if((15&U)!=8){O.msg="unknown compression method",R.mode=30;break}if(H-=4,z=8+(15&(U>>>=4)),R.wbits===0)R.wbits=z;else if(z>R.wbits){O.msg="invalid window size",R.mode=30;break}R.dmax=1<<z,O.adler=R.check=1,R.mode=512&U?10:12,H=U=0;break;case 2:for(;H<16;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(R.flags=U,(255&R.flags)!=8){O.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){O.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=U>>8&1),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),H=U=0,R.mode=3;case 3:for(;H<32;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}R.head&&(R.head.time=U),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,se[2]=U>>>16&255,se[3]=U>>>24&255,R.check=o(R.check,se,4,0)),H=U=0,R.mode=4;case 4:for(;H<16;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}R.head&&(R.head.xflags=255&U,R.head.os=U>>8),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),H=U=0,R.mode=5;case 5:if(1024&R.flags){for(;H<16;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}R.length=U,R.head&&(R.head.extra_len=U),512&R.flags&&(se[0]=255&U,se[1]=U>>>8&255,R.check=o(R.check,se,2,0)),H=U=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Y<(pe=R.length)&&(pe=Y),pe&&(R.head&&(z=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),a.arraySet(R.head.extra,W,G,pe,z)),512&R.flags&&(R.check=o(R.check,W,pe,G)),Y-=pe,G+=pe,R.length-=pe),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Y===0)break e;for(pe=0;z=W[G+pe++],R.head&&z&&R.length<65536&&(R.head.name+=String.fromCharCode(z)),z&&pe<Y;);if(512&R.flags&&(R.check=o(R.check,W,pe,G)),Y-=pe,G+=pe,z)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Y===0)break e;for(pe=0;z=W[G+pe++],R.head&&z&&R.length<65536&&(R.head.comment+=String.fromCharCode(z)),z&&pe<Y;);if(512&R.flags&&(R.check=o(R.check,W,pe,G)),Y-=pe,G+=pe,z)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;H<16;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(U!==(65535&R.check)){O.msg="header crc mismatch",R.mode=30;break}H=U=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),O.adler=R.check=0,R.mode=12;break;case 10:for(;H<32;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}O.adler=R.check=b(U),H=U=0,R.mode=11;case 11:if(R.havedict===0)return O.next_out=te,O.avail_out=J,O.next_in=G,O.avail_in=Y,R.hold=U,R.bits=H,2;O.adler=R.check=1,R.mode=12;case 12:if(q===5||q===6)break e;case 13:if(R.last){U>>>=7&H,H-=7&H,R.mode=27;break}for(;H<3;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}switch(R.last=1&U,H-=1,3&(U>>>=1)){case 0:R.mode=14;break;case 1:if(j(R),R.mode=20,q!==6)break;U>>>=2,H-=2;break e;case 2:R.mode=17;break;case 3:O.msg="invalid block type",R.mode=30}U>>>=2,H-=2;break;case 14:for(U>>>=7&H,H-=7&H;H<32;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if((65535&U)!=(U>>>16^65535)){O.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&U,H=U=0,R.mode=15,q===6)break e;case 15:R.mode=16;case 16:if(pe=R.length){if(Y<pe&&(pe=Y),J<pe&&(pe=J),pe===0)break e;a.arraySet(K,W,G,pe,te),Y-=pe,G+=pe,J-=pe,te+=pe,R.length-=pe;break}R.mode=12;break;case 17:for(;H<14;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(R.nlen=257+(31&U),U>>>=5,H-=5,R.ndist=1+(31&U),U>>>=5,H-=5,R.ncode=4+(15&U),U>>>=4,H-=4,286<R.nlen||30<R.ndist){O.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;H<3;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}R.lens[Me[R.have++]]=7&U,U>>>=3,H-=3}for(;R.have<19;)R.lens[Me[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ne={bits:R.lenbits},B=u(0,R.lens,0,19,R.lencode,0,R.work,ne),R.lenbits=ne.bits,B){O.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;Z=(Q=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,_e=65535&Q,!((Re=Q>>>24)<=H);){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(_e<16)U>>>=Re,H-=Re,R.lens[R.have++]=_e;else{if(_e===16){for(V=Re+2;H<V;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(U>>>=Re,H-=Re,R.have===0){O.msg="invalid bit length repeat",R.mode=30;break}z=R.lens[R.have-1],pe=3+(3&U),U>>>=2,H-=2}else if(_e===17){for(V=Re+3;H<V;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}H-=Re,z=0,pe=3+(7&(U>>>=Re)),U>>>=3,H-=3}else{for(V=Re+7;H<V;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}H-=Re,z=0,pe=11+(127&(U>>>=Re)),U>>>=7,H-=7}if(R.have+pe>R.nlen+R.ndist){O.msg="invalid bit length repeat",R.mode=30;break}for(;pe--;)R.lens[R.have++]=z}}if(R.mode===30)break;if(R.lens[256]===0){O.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,ne={bits:R.lenbits},B=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,ne),R.lenbits=ne.bits,B){O.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ne={bits:R.distbits},B=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ne),R.distbits=ne.bits,B){O.msg="invalid distances set",R.mode=30;break}if(R.mode=20,q===6)break e;case 20:R.mode=21;case 21:if(6<=Y&&258<=J){O.next_out=te,O.avail_out=J,O.next_in=G,O.avail_in=Y,R.hold=U,R.bits=H,c(O,ie),te=O.next_out,K=O.output,J=O.avail_out,G=O.next_in,W=O.input,Y=O.avail_in,U=R.hold,H=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;Z=(Q=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,_e=65535&Q,!((Re=Q>>>24)<=H);){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(Z&&(240&Z)==0){for(Le=Re,ce=Z,Ie=_e;Z=(Q=R.lencode[Ie+((U&(1<<Le+ce)-1)>>Le)])>>>16&255,_e=65535&Q,!(Le+(Re=Q>>>24)<=H);){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}U>>>=Le,H-=Le,R.back+=Le}if(U>>>=Re,H-=Re,R.back+=Re,R.length=_e,Z===0){R.mode=26;break}if(32&Z){R.back=-1,R.mode=12;break}if(64&Z){O.msg="invalid literal/length code",R.mode=30;break}R.extra=15&Z,R.mode=22;case 22:if(R.extra){for(V=R.extra;H<V;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}R.length+=U&(1<<R.extra)-1,U>>>=R.extra,H-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;Z=(Q=R.distcode[U&(1<<R.distbits)-1])>>>16&255,_e=65535&Q,!((Re=Q>>>24)<=H);){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if((240&Z)==0){for(Le=Re,ce=Z,Ie=_e;Z=(Q=R.distcode[Ie+((U&(1<<Le+ce)-1)>>Le)])>>>16&255,_e=65535&Q,!(Le+(Re=Q>>>24)<=H);){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}U>>>=Le,H-=Le,R.back+=Le}if(U>>>=Re,H-=Re,R.back+=Re,64&Z){O.msg="invalid distance code",R.mode=30;break}R.offset=_e,R.extra=15&Z,R.mode=24;case 24:if(R.extra){for(V=R.extra;H<V;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}R.offset+=U&(1<<R.extra)-1,U>>>=R.extra,H-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){O.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(J===0)break e;if(pe=ie-J,R.offset>pe){if((pe=R.offset-pe)>R.whave&&R.sane){O.msg="invalid distance too far back",R.mode=30;break}ue=pe>R.wnext?(pe-=R.wnext,R.wsize-pe):R.wnext-pe,pe>R.length&&(pe=R.length),be=R.window}else be=K,ue=te-R.offset,pe=R.length;for(J<pe&&(pe=J),J-=pe,R.length-=pe;K[te++]=be[ue++],--pe;);R.length===0&&(R.mode=21);break;case 26:if(J===0)break e;K[te++]=R.length,J--,R.mode=21;break;case 27:if(R.wrap){for(;H<32;){if(Y===0)break e;Y--,U|=W[G++]<<H,H+=8}if(ie-=J,O.total_out+=ie,R.total+=ie,ie&&(O.adler=R.check=R.flags?o(R.check,K,ie,te-ie):s(R.check,K,ie,te-ie)),ie=J,(R.flags?U:b(U))!==R.check){O.msg="incorrect data check",R.mode=30;break}H=U=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;H<32;){if(Y===0)break e;Y--,U+=W[G++]<<H,H+=8}if(U!==(4294967295&R.total)){O.msg="incorrect length check",R.mode=30;break}H=U=0}R.mode=29;case 29:B=1;break e;case 30:B=-3;break e;case 31:return-4;case 32:default:return p}return O.next_out=te,O.avail_out=J,O.next_in=G,O.avail_in=Y,R.hold=U,R.bits=H,(R.wsize||ie!==O.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&I(O,O.output,O.next_out,ie-O.avail_out)?(R.mode=31,-4):(ee-=O.avail_in,ie-=O.avail_out,O.total_in+=ee,O.total_out+=ie,R.total+=ie,R.wrap&&ie&&(O.adler=R.check=R.flags?o(R.check,K,ie,O.next_out-ie):s(R.check,K,ie,O.next_out-ie)),O.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ee==0&&ie===0||q===4)&&B===g&&(B=-5),B)},i.inflateEnd=function(O){if(!O||!O.state)return p;var q=O.state;return q.window&&(q.window=null),O.state=null,g},i.inflateGetHeader=function(O,q){var R;return O&&O.state?(2&(R=O.state).wrap)==0?p:((R.head=q).done=!1,g):p},i.inflateSetDictionary=function(O,q){var R,W=q.length;return O&&O.state?(R=O.state).wrap!==0&&R.mode!==11?p:R.mode===11&&s(1,q,W,0)!==R.check?-3:I(O,q,W,W)?(R.mode=31,-4):(R.havedict=1,g):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,p,x,v,y,b){var E,w,A,T,C,k,F,N,j,I=b.bits,O=0,q=0,R=0,W=0,K=0,G=0,te=0,Y=0,J=0,U=0,H=null,ee=0,ie=new a.Buf16(16),pe=new a.Buf16(16),ue=null,be=0;for(O=0;O<=15;O++)ie[O]=0;for(q=0;q<p;q++)ie[f[g+q]]++;for(K=I,W=15;1<=W&&ie[W]===0;W--);if(W<K&&(K=W),W===0)return x[v++]=20971520,x[v++]=20971520,b.bits=1,0;for(R=1;R<W&&ie[R]===0;R++);for(K<R&&(K=R),O=Y=1;O<=15;O++)if(Y<<=1,(Y-=ie[O])<0)return-1;if(0<Y&&(d===0||W!==1))return-1;for(pe[1]=0,O=1;O<15;O++)pe[O+1]=pe[O]+ie[O];for(q=0;q<p;q++)f[g+q]!==0&&(y[pe[f[g+q]]++]=q);if(k=d===0?(H=ue=y,19):d===1?(H=s,ee-=257,ue=o,be-=257,256):(H=c,ue=u,-1),O=R,C=v,te=q=U=0,A=-1,T=(J=1<<(G=K))-1,d===1&&852<J||d===2&&592<J)return 1;for(;;){for(F=O-te,j=y[q]<k?(N=0,y[q]):y[q]>k?(N=ue[be+y[q]],H[ee+y[q]]):(N=96,0),E=1<<O-te,R=w=1<<G;x[C+(U>>te)+(w-=E)]=F<<24|N<<16|j|0,w!==0;);for(E=1<<O-1;U&E;)E>>=1;if(E!==0?(U&=E-1,U+=E):U=0,q++,--ie[O]==0){if(O===W)break;O=f[g+y[q]]}if(K<O&&(U&T)!==A){for(te===0&&(te=K),C+=R,Y=1<<(G=O-te);G+te<W&&!((Y-=ie[G+te])<=0);)G++,Y<<=1;if(J+=1<<G,d===1&&852<J||d===2&&592<J)return 1;x[A=U&T]=K<<24|G<<16|C-v|0}}return U!==0&&(x[C+U]=O-te<<24|64<<16|0),b.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),s=0,o=1;function c(Q){for(var se=Q.length;0<=--se;)Q[se]=0}var u=0,d=29,f=256,g=f+1+d,p=30,x=19,v=2*g+1,y=15,b=16,E=7,w=256,A=16,T=17,C=18,k=[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],F=[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],j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],I=new Array(2*(g+2));c(I);var O=new Array(2*p);c(O);var q=new Array(512);c(q);var R=new Array(256);c(R);var W=new Array(d);c(W);var K,G,te,Y=new Array(p);function J(Q,se,Me,Ae,Se){this.static_tree=Q,this.extra_bits=se,this.extra_base=Me,this.elems=Ae,this.max_length=Se,this.has_stree=Q&&Q.length}function U(Q,se){this.dyn_tree=Q,this.max_code=0,this.stat_desc=se}function H(Q){return Q<256?q[Q]:q[256+(Q>>>7)]}function ee(Q,se){Q.pending_buf[Q.pending++]=255&se,Q.pending_buf[Q.pending++]=se>>>8&255}function ie(Q,se,Me){Q.bi_valid>b-Me?(Q.bi_buf|=se<<Q.bi_valid&65535,ee(Q,Q.bi_buf),Q.bi_buf=se>>b-Q.bi_valid,Q.bi_valid+=Me-b):(Q.bi_buf|=se<<Q.bi_valid&65535,Q.bi_valid+=Me)}function pe(Q,se,Me){ie(Q,Me[2*se],Me[2*se+1])}function ue(Q,se){for(var Me=0;Me|=1&Q,Q>>>=1,Me<<=1,0<--se;);return Me>>>1}function be(Q,se,Me){var Ae,Se,$=new Array(y+1),L=0;for(Ae=1;Ae<=y;Ae++)$[Ae]=L=L+Me[Ae-1]<<1;for(Se=0;Se<=se;Se++){var re=Q[2*Se+1];re!==0&&(Q[2*Se]=ue($[re]++,re))}}function Re(Q){var se;for(se=0;se<g;se++)Q.dyn_ltree[2*se]=0;for(se=0;se<p;se++)Q.dyn_dtree[2*se]=0;for(se=0;se<x;se++)Q.bl_tree[2*se]=0;Q.dyn_ltree[2*w]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function Z(Q){8<Q.bi_valid?ee(Q,Q.bi_buf):0<Q.bi_valid&&(Q.pending_buf[Q.pending++]=Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0}function _e(Q,se,Me,Ae){var Se=2*se,$=2*Me;return Q[Se]<Q[$]||Q[Se]===Q[$]&&Ae[se]<=Ae[Me]}function Le(Q,se,Me){for(var Ae=Q.heap[Me],Se=Me<<1;Se<=Q.heap_len&&(Se<Q.heap_len&&_e(se,Q.heap[Se+1],Q.heap[Se],Q.depth)&&Se++,!_e(se,Ae,Q.heap[Se],Q.depth));)Q.heap[Me]=Q.heap[Se],Me=Se,Se<<=1;Q.heap[Me]=Ae}function ce(Q,se,Me){var Ae,Se,$,L,re=0;if(Q.last_lit!==0)for(;Ae=Q.pending_buf[Q.d_buf+2*re]<<8|Q.pending_buf[Q.d_buf+2*re+1],Se=Q.pending_buf[Q.l_buf+re],re++,Ae===0?pe(Q,Se,se):(pe(Q,($=R[Se])+f+1,se),(L=k[$])!==0&&ie(Q,Se-=W[$],L),pe(Q,$=H(--Ae),Me),(L=F[$])!==0&&ie(Q,Ae-=Y[$],L)),re<Q.last_lit;);pe(Q,w,se)}function Ie(Q,se){var Me,Ae,Se,$=se.dyn_tree,L=se.stat_desc.static_tree,re=se.stat_desc.has_stree,ye=se.stat_desc.elems,we=-1;for(Q.heap_len=0,Q.heap_max=v,Me=0;Me<ye;Me++)$[2*Me]!==0?(Q.heap[++Q.heap_len]=we=Me,Q.depth[Me]=0):$[2*Me+1]=0;for(;Q.heap_len<2;)$[2*(Se=Q.heap[++Q.heap_len]=we<2?++we:0)]=1,Q.depth[Se]=0,Q.opt_len--,re&&(Q.static_len-=L[2*Se+1]);for(se.max_code=we,Me=Q.heap_len>>1;1<=Me;Me--)Le(Q,$,Me);for(Se=ye;Me=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],Le(Q,$,1),Ae=Q.heap[1],Q.heap[--Q.heap_max]=Me,Q.heap[--Q.heap_max]=Ae,$[2*Se]=$[2*Me]+$[2*Ae],Q.depth[Se]=(Q.depth[Me]>=Q.depth[Ae]?Q.depth[Me]:Q.depth[Ae])+1,$[2*Me+1]=$[2*Ae+1]=Se,Q.heap[1]=Se++,Le(Q,$,1),2<=Q.heap_len;);Q.heap[--Q.heap_max]=Q.heap[1],(function(xe,rt){var He,he,Ge,Ue,oe,tt,$e=rt.dyn_tree,Ye=rt.max_code,ut=rt.stat_desc.static_tree,fe=rt.stat_desc.has_stree,Qe=rt.stat_desc.extra_bits,ge=rt.stat_desc.extra_base,ze=rt.stat_desc.max_length,ke=0;for(Ue=0;Ue<=y;Ue++)xe.bl_count[Ue]=0;for($e[2*xe.heap[xe.heap_max]+1]=0,He=xe.heap_max+1;He<v;He++)ze<(Ue=$e[2*$e[2*(he=xe.heap[He])+1]+1]+1)&&(Ue=ze,ke++),$e[2*he+1]=Ue,Ye<he||(xe.bl_count[Ue]++,oe=0,ge<=he&&(oe=Qe[he-ge]),tt=$e[2*he],xe.opt_len+=tt*(Ue+oe),fe&&(xe.static_len+=tt*(ut[2*he+1]+oe)));if(ke!==0){do{for(Ue=ze-1;xe.bl_count[Ue]===0;)Ue--;xe.bl_count[Ue]--,xe.bl_count[Ue+1]+=2,xe.bl_count[ze]--,ke-=2}while(0<ke);for(Ue=ze;Ue!==0;Ue--)for(he=xe.bl_count[Ue];he!==0;)Ye<(Ge=xe.heap[--He])||($e[2*Ge+1]!==Ue&&(xe.opt_len+=(Ue-$e[2*Ge+1])*$e[2*Ge],$e[2*Ge+1]=Ue),he--)}})(Q,se),be($,we,Q.bl_count)}function z(Q,se,Me){var Ae,Se,$=-1,L=se[1],re=0,ye=7,we=4;for(L===0&&(ye=138,we=3),se[2*(Me+1)+1]=65535,Ae=0;Ae<=Me;Ae++)Se=L,L=se[2*(Ae+1)+1],++re<ye&&Se===L||(re<we?Q.bl_tree[2*Se]+=re:Se!==0?(Se!==$&&Q.bl_tree[2*Se]++,Q.bl_tree[2*A]++):re<=10?Q.bl_tree[2*T]++:Q.bl_tree[2*C]++,$=Se,we=(re=0)===L?(ye=138,3):Se===L?(ye=6,3):(ye=7,4))}function B(Q,se,Me){var Ae,Se,$=-1,L=se[1],re=0,ye=7,we=4;for(L===0&&(ye=138,we=3),Ae=0;Ae<=Me;Ae++)if(Se=L,L=se[2*(Ae+1)+1],!(++re<ye&&Se===L)){if(re<we)for(;pe(Q,Se,Q.bl_tree),--re!=0;);else Se!==0?(Se!==$&&(pe(Q,Se,Q.bl_tree),re--),pe(Q,A,Q.bl_tree),ie(Q,re-3,2)):re<=10?(pe(Q,T,Q.bl_tree),ie(Q,re-3,3)):(pe(Q,C,Q.bl_tree),ie(Q,re-11,7));$=Se,we=(re=0)===L?(ye=138,3):Se===L?(ye=6,3):(ye=7,4)}}c(Y);var ne=!1;function V(Q,se,Me,Ae){ie(Q,(u<<1)+(Ae?1:0),3),(function(Se,$,L,re){Z(Se),ee(Se,L),ee(Se,~L),a.arraySet(Se.pending_buf,Se.window,$,L,Se.pending),Se.pending+=L})(Q,se,Me)}i._tr_init=function(Q){ne||((function(){var se,Me,Ae,Se,$,L=new Array(y+1);for(Se=Ae=0;Se<d-1;Se++)for(W[Se]=Ae,se=0;se<1<<k[Se];se++)R[Ae++]=Se;for(R[Ae-1]=Se,Se=$=0;Se<16;Se++)for(Y[Se]=$,se=0;se<1<<F[Se];se++)q[$++]=Se;for($>>=7;Se<p;Se++)for(Y[Se]=$<<7,se=0;se<1<<F[Se]-7;se++)q[256+$++]=Se;for(Me=0;Me<=y;Me++)L[Me]=0;for(se=0;se<=143;)I[2*se+1]=8,se++,L[8]++;for(;se<=255;)I[2*se+1]=9,se++,L[9]++;for(;se<=279;)I[2*se+1]=7,se++,L[7]++;for(;se<=287;)I[2*se+1]=8,se++,L[8]++;for(be(I,g+1,L),se=0;se<p;se++)O[2*se+1]=5,O[2*se]=ue(se,5);K=new J(I,k,f+1,g,y),G=new J(O,F,0,p,y),te=new J(new Array(0),N,0,x,E)})(),ne=!0),Q.l_desc=new U(Q.dyn_ltree,K),Q.d_desc=new U(Q.dyn_dtree,G),Q.bl_desc=new U(Q.bl_tree,te),Q.bi_buf=0,Q.bi_valid=0,Re(Q)},i._tr_stored_block=V,i._tr_flush_block=function(Q,se,Me,Ae){var Se,$,L=0;0<Q.level?(Q.strm.data_type===2&&(Q.strm.data_type=(function(re){var ye,we=4093624447;for(ye=0;ye<=31;ye++,we>>>=1)if(1&we&&re.dyn_ltree[2*ye]!==0)return s;if(re.dyn_ltree[18]!==0||re.dyn_ltree[20]!==0||re.dyn_ltree[26]!==0)return o;for(ye=32;ye<f;ye++)if(re.dyn_ltree[2*ye]!==0)return o;return s})(Q)),Ie(Q,Q.l_desc),Ie(Q,Q.d_desc),L=(function(re){var ye;for(z(re,re.dyn_ltree,re.l_desc.max_code),z(re,re.dyn_dtree,re.d_desc.max_code),Ie(re,re.bl_desc),ye=x-1;3<=ye&&re.bl_tree[2*j[ye]+1]===0;ye--);return re.opt_len+=3*(ye+1)+5+5+4,ye})(Q),Se=Q.opt_len+3+7>>>3,($=Q.static_len+3+7>>>3)<=Se&&(Se=$)):Se=$=Me+5,Me+4<=Se&&se!==-1?V(Q,se,Me,Ae):Q.strategy===4||$===Se?(ie(Q,2+(Ae?1:0),3),ce(Q,I,O)):(ie(Q,4+(Ae?1:0),3),(function(re,ye,we,xe){var rt;for(ie(re,ye-257,5),ie(re,we-1,5),ie(re,xe-4,4),rt=0;rt<xe;rt++)ie(re,re.bl_tree[2*j[rt]+1],3);B(re,re.dyn_ltree,ye-1),B(re,re.dyn_dtree,we-1)})(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,L+1),ce(Q,Q.dyn_ltree,Q.dyn_dtree)),Re(Q),Ae&&Z(Q)},i._tr_tally=function(Q,se,Me){return Q.pending_buf[Q.d_buf+2*Q.last_lit]=se>>>8&255,Q.pending_buf[Q.d_buf+2*Q.last_lit+1]=255&se,Q.pending_buf[Q.l_buf+Q.last_lit]=255&Me,Q.last_lit++,se===0?Q.dyn_ltree[2*Me]++:(Q.matches++,se--,Q.dyn_ltree[2*(R[Me]+f+1)]++,Q.dyn_dtree[2*H(se)]++),Q.last_lit===Q.lit_bufsize-1},i._tr_align=function(Q){ie(Q,2,3),pe(Q,w,I),(function(se){se.bi_valid===16?(ee(se,se.bi_buf),se.bi_buf=0,se.bi_valid=0):8<=se.bi_valid&&(se.pending_buf[se.pending++]=255&se.bi_buf,se.bi_buf>>=8,se.bi_valid-=8)})(Q)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(s,o){if(!s.setImmediate){var c,u,d,f,g=1,p={},x=!1,v=s.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(s);y=y&&y.setTimeout?y:s,c={}.toString.call(s.process)==="[object process]"?function(A){process.nextTick(function(){E(A)})}:(function(){if(s.postMessage&&!s.importScripts){var A=!0,T=s.onmessage;return s.onmessage=function(){A=!1},s.postMessage("","*"),s.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(A){s.postMessage(f+A,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){E(A.data)},function(A){d.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(A){var T=v.createElement("script");T.onreadystatechange=function(){E(A),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(A){setTimeout(E,0,A)},y.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),C=0;C<T.length;C++)T[C]=arguments[C+1];var k={callback:A,args:T};return p[g]=k,c(g),g++},y.clearImmediate=b}function b(A){delete p[A]}function E(A){if(x)setTimeout(E,0,A);else{var T=p[A];if(T){x=!0;try{(function(C){var k=C.callback,F=C.args;switch(F.length){case 0:k();break;case 1:k(F[0]);break;case 2:k(F[0],F[1]);break;case 3:k(F[0],F[1],F[2]);break;default:k.apply(o,F)}})(T)}finally{b(A),x=!1}}}}function w(A){A.source===s&&typeof A.data=="string"&&A.data.indexOf(f)===0&&E(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof mv<"u"?mv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ZC)),ZC.exports}var xDe=gDe();const bDe=mo(xDe);function yDe(t){const e=new ii;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 KH=yDe;async function XH(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],a=[],s=[],o=i.getElementsByTagName("vertex");for(let u=0;u<o.length;u++){const d=o[u];a.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const c=i.getElementsByTagName("triangle");for(let u=0;u<c.length;u++){const d=c[u];s.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function vDe(t){const e=await bDe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(d){const f=d.startsWith("/")?d.slice(1):d,g=e.files[f];if(!g)return null;const p=await g.async("string");return i.parseFromString(p,"application/xml")}const s=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!s){const d=Object.keys(e.files).find(f=>f.endsWith(".model"));if(d){const f=await a(d);if(f){const g=await XH(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await a(s);if(!o)return{objects:n,buildItems:r};const c=o.getElementsByTagName("object");for(let d=0;d<c.length;d++){const f=c[d],g=f.getAttribute("id");if(!g)continue;const p=[],x=f.getElementsByTagName("mesh");for(let y=0;y<x.length;y++){const b=x[y],E=[],w=[],A=b.getElementsByTagName("vertex");for(let C=0;C<A.length;C++){const k=A[C];E.push(parseFloat(k.getAttribute("x")||"0"),parseFloat(k.getAttribute("y")||"0"),parseFloat(k.getAttribute("z")||"0"))}const T=b.getElementsByTagName("triangle");for(let C=0;C<T.length;C++){const k=T[C];w.push(parseInt(k.getAttribute("v1")||"0"),parseInt(k.getAttribute("v2")||"0"),parseInt(k.getAttribute("v3")||"0"))}E.length>0&&w.length>0&&p.push({vertices:E,triangles:w})}const v=f.getElementsByTagName("component");for(let y=0;y<v.length;y++){const b=v[y],E=b.getAttribute("p:path")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(E){const w=await a(E);if(w){const A=await XH(w),T=b.getAttribute("transform"),C=KH(T);for(const k of A)if(T){const F=[];for(let N=0;N<k.vertices.length;N+=3){const j=new et(k.vertices[N],k.vertices[N+1],k.vertices[N+2]);j.applyMatrix4(C),F.push(j.x,j.y,j.z)}p.push({vertices:F,triangles:k.triangles})}else p.push(k)}}}p.length>0&&n.set(g,{id:g,meshes:p})}const u=o.getElementsByTagName("build");if(u.length>0){const d=u[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const g=d[f],p=g.getAttribute("objectid");if(!p)continue;const x=KH(g.getAttribute("transform"));r.push({objectId:p,transform:x})}}return{objects:n,buildItems:r}}function YH(t){const e=new Al,n=new Float32Array(t.vertices.length);for(let r=0;r<t.vertices.length;r+=3)n[r]=t.vertices[r],n[r+1]=t.vertices[r+2],n[r+2]=t.vertices[r+1];return e.setAttribute("position",new ao(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function _De({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=M.useRef(null),i=M.useRef(null),a=M.useRef(null),s=M.useRef(null),o=M.useRef(null),[c,u]=M.useState(!0),[d,f]=M.useState(null);M.useEffect(()=>{if(!r.current)return;const x=r.current,v=x.clientWidth,y=x.clientHeight,b=new QNe;b.background=new _n(1710618),a.current=b;const E=new Zs(45,v/y,.1,1e4);E.position.set(150,150,150),s.current=E;const w=new eDe({antialias:!0});w.setSize(v,y),w.setPixelRatio(window.devicePixelRatio),x.appendChild(w.domElement),i.current=w;const A=new nDe(E,w.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new uke(16777215,.6);b.add(T);const C=new bH(16777215,.8);C.position.set(100,100,100),b.add(C);const k=new bH(16777215,.4);k.position.set(-100,50,-100),b.add(k);const F=Math.max(e.x,e.y),N=Math.ceil(F/16),j=new hke(F,N,4473924,3355443);b.add(j);const I=new vO(e.x,e.y),O=new xO({color:44610,transparent:!0,opacity:.15,side:rl}),q=new bl(I,O);q.rotation.x=-Math.PI/2,q.position.y=-.5,b.add(q);let R;const W=()=>{R=requestAnimationFrame(W),A.update(),w.render(b,E)};W(),fetch(t).then(G=>{if(!G.ok)throw new Error("Failed to load file");return G.arrayBuffer()}).then(vDe).then(({objects:G,buildItems:te})=>{if(G.size===0)throw new Error("No meshes found in 3MF file");const Y=new ake({color:44610,shininess:30,flatShading:!1}),J=new zx,U=[];if(te.length>0)for(const Z of te){const _e=G.get(Z.objectId);if(_e)for(const Le of _e.meshes){const ce=[];for(let z=0;z<Le.vertices.length;z+=3){const B=new et(Le.vertices[z],Le.vertices[z+1],Le.vertices[z+2]);B.applyMatrix4(Z.transform),ce.push(B.x,B.y,B.z)}const Ie=YH({vertices:ce,triangles:Le.triangles});U.push(Ie)}}else for(const Z of G.values())for(const _e of Z.meshes){const Le=YH(_e);U.push(Le)}if(U.length>0){const Z=U.length===1?U[0]:pDe(U,!1);if(Z){const _e=new bl(Z,Y);J.add(_e)}if(U.length>1)for(const _e of U)_e.dispose()}const H=new sf().setFromObject(J),ee=H.getCenter(new et);J.position.y=-H.min.y,te.length===0&&(J.position.x=-ee.x,J.position.z=-ee.z),b.add(J);const ie=new sf().setFromObject(J),pe=ie.getCenter(new et),ue=ie.getSize(new et),Re=Math.max(ue.x,ue.y,ue.z)*1.8;E.position.set(pe.x+Re*.7,pe.y+Re*.5,pe.z+Re*.7),A.target.copy(pe),A.update(),u(!1)}).catch(G=>{f(G.message),u(!1)});const K=()=>{if(!x)return;const G=x.clientWidth,te=x.clientHeight;E.aspect=G/te,E.updateProjectionMatrix(),w.setSize(G,te)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(R),A.dispose(),w.dispose(),x.removeChild(w.domElement)}},[t,e]);const g=()=>{s.current&&o.current&&(s.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},p=x=>{s.current&&s.current.position.multiplyScalar(x)};return l.jsxs("div",{className:`relative ${n}`,children:[l.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),c&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx("p",{className:"text-red-400",children:d})}),!c&&!d&&l.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[l.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>p(.8),children:l.jsx(Jue,{className:"w-4 h-4"})}),l.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>p(1.25),children:l.jsx(nde,{className:"w-4 h-4"})}),l.jsx(Pe,{variant:"secondary",size:"sm",onClick:g,children:l.jsx(Qp,{className:"w-4 h-4"})})]})]})}const WM="159",xm={ROTATE:0,DOLLY:1,PAN:2},bm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wDe=0,ZH=1,SDe=2,kZ=1,MDe=2,sc=3,vd=0,Qa=1,hc=2,nd=0,lp=1,QH=2,JH=3,e$=4,EDe=5,ph=100,ADe=101,TDe=102,t$=103,n$=104,CDe=200,NDe=201,kDe=202,PDe=203,jP=204,DP=205,RDe=206,jDe=207,DDe=208,ODe=209,LDe=210,IDe=211,FDe=212,UDe=213,zDe=214,BDe=0,HDe=1,$De=2,Fw=3,VDe=4,GDe=5,WDe=6,qDe=7,wO=0,KDe=1,XDe=2,rd=0,YDe=1,ZDe=2,QDe=3,JDe=4,eOe=5,PZ=300,Op=301,Lp=302,OP=303,LP=304,qM=306,IP=1e3,Po=1001,FP=1002,Zi=1003,r$=1004,QC=1005,Qs=1006,tOe=1007,X0=1008,id=1009,nOe=1010,rOe=1011,SO=1012,RZ=1013,Ku=1014,yc=1015,Y0=1016,jZ=1017,DZ=1018,Dh=1020,iOe=1021,Js=1023,aOe=1024,sOe=1025,Oh=1026,Ip=1027,oOe=1028,OZ=1029,lOe=1030,LZ=1031,IZ=1033,JC=33776,eN=33777,tN=33778,nN=33779,i$=35840,a$=35841,s$=35842,o$=35843,FZ=36196,l$=37492,c$=37496,u$=37808,d$=37809,h$=37810,f$=37811,m$=37812,p$=37813,g$=37814,x$=37815,b$=37816,y$=37817,v$=37818,_$=37819,w$=37820,S$=37821,rN=36492,M$=36494,E$=36495,cOe=36283,A$=36284,T$=36285,C$=36286,UZ=3e3,Lh=3001,uOe=3200,dOe=3201,zZ=0,hOe=1,eo="",Qi="srgb",Bc="srgb-linear",MO="display-p3",KM="display-p3-linear",Uw="linear",ur="srgb",zw="rec709",Bw="p3",ym=7680,N$=519,fOe=512,mOe=513,pOe=514,BZ=515,gOe=516,xOe=517,bOe=518,yOe=519,UP=35044,k$="300 es",zP=1035,ll=2e3,Z0=2001;class bf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const oa=["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 P$=1234567;const Qx=Math.PI/180,Q0=180/Math.PI;function Tc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(oa[t&255]+oa[t>>8&255]+oa[t>>16&255]+oa[t>>24&255]+"-"+oa[e&255]+oa[e>>8&255]+"-"+oa[e>>16&15|64]+oa[e>>24&255]+"-"+oa[n&63|128]+oa[n>>8&255]+"-"+oa[n>>16&255]+oa[n>>24&255]+oa[r&255]+oa[r>>8&255]+oa[r>>16&255]+oa[r>>24&255]).toLowerCase()}function Ji(t,e,n){return Math.max(e,Math.min(n,t))}function EO(t,e){return(t%e+e)%e}function vOe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function _Oe(t,e,n){return t!==e?(n-t)/(e-t):0}function Jx(t,e,n){return(1-n)*t+n*e}function wOe(t,e,n,r){return Jx(t,e,1-Math.exp(-n*r))}function SOe(t,e=1){return e-Math.abs(EO(t,e*2)-e)}function MOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function EOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function AOe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function TOe(t,e){return t+Math.random()*(e-t)}function COe(t){return t*(.5-Math.random())}function NOe(t){t!==void 0&&(P$=t);let e=P$+=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 kOe(t){return t*Qx}function POe(t){return t*Q0}function BP(t){return(t&t-1)===0&&t!==0}function ROe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Hw(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function jOe(t,e,n,r,i){const a=Math.cos,s=Math.sin,o=a(n/2),c=s(n/2),u=a((e+r)/2),d=s((e+r)/2),f=a((e-r)/2),g=s((e-r)/2),p=a((r-e)/2),x=s((r-e)/2);switch(i){case"XYX":t.set(o*d,c*f,c*g,o*u);break;case"YZY":t.set(c*g,o*d,c*f,o*u);break;case"ZXZ":t.set(c*f,c*g,o*d,o*u);break;case"XZX":t.set(o*d,c*x,c*p,o*u);break;case"YXY":t.set(c*p,o*d,c*x,o*u);break;case"ZYZ":t.set(c*x,c*p,o*d,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function il(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Xn(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 HZ={DEG2RAD:Qx,RAD2DEG:Q0,generateUUID:Tc,clamp:Ji,euclideanModulo:EO,mapLinear:vOe,inverseLerp:_Oe,lerp:Jx,damp:wOe,pingpong:SOe,smoothstep:MOe,smootherstep:EOe,randInt:AOe,randFloat:TOe,randFloatSpread:COe,seededRandom:NOe,degToRad:kOe,radToDeg:POe,isPowerOfTwo:BP,ceilPowerOfTwo:ROe,floorPowerOfTwo:Hw,setQuaternionFromProperEuler:jOe,normalize:Xn,denormalize:il};class Zt{constructor(e=0,n=0){Zt.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(Ji(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,n,r,i,a,s,o,c,u){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u)}set(e,n,r,i,a,s,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],v=i[0],y=i[3],b=i[6],E=i[1],w=i[4],A=i[7],T=i[2],C=i[5],k=i[8];return a[0]=s*v+o*E+c*T,a[3]=s*y+o*w+c*C,a[6]=s*b+o*A+c*k,a[1]=u*v+d*E+f*T,a[4]=u*y+d*w+f*C,a[7]=u*b+d*A+f*k,a[2]=g*v+p*E+x*T,a[5]=g*y+p*w+x*C,a[8]=g*b+p*A+x*k,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*o*u-r*a*d+r*o*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*s-o*u,g=o*c-d*a,p=u*a-s*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(o*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-o*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,o){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*o)+s+e,-i*u,i*c,-i*(-u*s+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(iN.makeScale(e,n)),this}rotate(e){return this.premultiply(iN.makeRotation(-e)),this}translate(e,n){return this.premultiply(iN.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 iN=new fn;function $Z(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function $w(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function DOe(){const t=$w("canvas");return t.style.display="block",t}const R$={};function e0(t){t in R$||(R$[t]=!0,console.warn(t))}const j$=new fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),D$=new fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),o_={[Bc]:{transfer:Uw,primaries:zw,toReference:t=>t,fromReference:t=>t},[Qi]:{transfer:ur,primaries:zw,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[KM]:{transfer:Uw,primaries:Bw,toReference:t=>t.applyMatrix3(D$),fromReference:t=>t.applyMatrix3(j$)},[MO]:{transfer:ur,primaries:Bw,toReference:t=>t.convertSRGBToLinear().applyMatrix3(D$),fromReference:t=>t.applyMatrix3(j$).convertLinearToSRGB()}},OOe=new Set([Bc,KM]),Yn={enabled:!0,_workingColorSpace:Bc,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(!OOe.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=o_[e].toReference,i=o_[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 o_[t].primaries},getTransfer:function(t){return t===eo?Uw:o_[t].transfer}};function cp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function aN(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let vm;class VZ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{vm===void 0&&(vm=$w("canvas")),vm.width=e.width,vm.height=e.height;const r=vm.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=vm}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=$w("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let s=0;s<a.length;s++)a[s]=cp(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(cp(n[r]/255)*255):n[r]=cp(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 LOe=0;class GZ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:LOe++}),this.uuid=Tc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,o=i.length;s<o;s++)i[s].isDataTexture?a.push(sN(i[s].image)):a.push(sN(i[s]))}else a=sN(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function sN(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?VZ.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 IOe=0;class Ja extends bf{constructor(e=Ja.DEFAULT_IMAGE,n=Ja.DEFAULT_MAPPING,r=Po,i=Po,a=Qs,s=X0,o=Js,c=id,u=Ja.DEFAULT_ANISOTROPY,d=eo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:IOe++}),this.uuid=Tc(),this.name="",this.source=new GZ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Zt(0,0),this.repeat=new Zt(1,1),this.center=new Zt(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:(e0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Lh?Qi:eo),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!==PZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case IP:e.x=e.x-Math.floor(e.x);break;case Po:e.x=e.x<0?0:1;break;case FP: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 IP:e.y=e.y-Math.floor(e.y);break;case Po:e.y=e.y<0?0:1;break;case FP: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 e0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Qi?Lh:UZ}set encoding(e){e0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Lh?Qi:eo}}Ja.DEFAULT_IMAGE=null;Ja.DEFAULT_MAPPING=PZ;Ja.DEFAULT_ANISOTROPY=1;class Qn{constructor(e=0,n=0,r=0,i=1){Qn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,T=(b+1)/2,C=(d+g)/4,k=(f+v)/4,F=(x+y)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=k/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=F/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=k/a,i=F/a),this.set(r,i,a,n),this}let E=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(y-x)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+b-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 FOe extends bf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Qn(0,0,e,n),this.scissorTest=!1,this.viewport=new Qn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(e0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Lh?Qi:eo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Qs,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Ja(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 GZ(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 of extends FOe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class WZ extends Ja{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=Zi,this.minFilter=Zi,this.wrapR=Po,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class UOe extends Ja{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=Zi,this.minFilter=Zi,this.wrapR=Po,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,o){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=a[s+0],p=a[s+1],x=a[s+2],v=a[s+3];if(o===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o===1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==x){let y=1-o;const b=c*g+u*p+d*x+f*v,E=b>=0?1:-1,w=1-b*b;if(w>Number.EPSILON){const T=Math.sqrt(w),C=Math.atan2(T,b*E);y=Math.sin(y*C)/T,o=Math.sin(o*C)/T}const A=o*E;if(c=c*y+g*A,u=u*y+p*A,d=d*y+x*A,f=f*y+v*A,y===1-o){const T=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=T,u*=T,d*=T,f*=T}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const o=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],p=a[s+2],x=a[s+3];return e[n]=o*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-o*p,e[n+2]=u*x+d*p+o*g-c*f,e[n+3]=d*x-o*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,s=e._order,o=Math.cos,c=Math.sin,u=o(r/2),d=o(i/2),f=o(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],o=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(s-i)*p}else if(r>o&&r>f){const p=2*Math.sqrt(1+r-o-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+s)/p,this._z=(a+u)/p}else if(o>f){const p=2*Math.sqrt(1+o-r-f);this._w=(a-u)/p,this._x=(i+s)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-o);this._w=(s-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ji(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*o+i*u-a*c,this._y=i*d+s*c+a*o-r*u,this._z=a*d+s*u+r*c-i*o,this._w=s*d-r*o-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,s=this._w;let o=s*e._w+r*e._x+i*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=r,this._y=i,this._z=a,this;const c=1-o*o;if(c<=Number.EPSILON){const p=1-n;return this._w=p*s+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,o),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=s*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=a*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class De{constructor(e=0,n=0,r=0){De.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(O$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(O$.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,o=e.z,c=e.w,u=2*(s*i-o*r),d=2*(o*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-o*d,this.y=r+c*d+o*u-a*f,this.z=i+c*f+a*d-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,o=n.y,c=n.z;return this.x=i*c-a*o,this.y=a*s-r*c,this.z=r*o-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return oN.copy(this).projectOnVector(e),this.sub(oN)}reflect(e){return this.sub(oN.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(Ji(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 oN=new De,O$=new lf;class so{constructor(e=new De(1/0,1/0,1/0),n=new De(-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(Mo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Mo.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=Mo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,Mo):Mo.fromBufferAttribute(a,s),Mo.applyMatrix4(e.matrixWorld),this.expandByPoint(Mo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),l_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),l_.copy(r.boundingBox)),l_.applyMatrix4(e.matrixWorld),this.union(l_)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Mo),Mo.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(Tx),c_.subVectors(this.max,Tx),_m.subVectors(e.a,Tx),wm.subVectors(e.b,Tx),Sm.subVectors(e.c,Tx),Eu.subVectors(wm,_m),Au.subVectors(Sm,wm),th.subVectors(_m,Sm);let n=[0,-Eu.z,Eu.y,0,-Au.z,Au.y,0,-th.z,th.y,Eu.z,0,-Eu.x,Au.z,0,-Au.x,th.z,0,-th.x,-Eu.y,Eu.x,0,-Au.y,Au.x,0,-th.y,th.x,0];return!lN(n,_m,wm,Sm,c_)||(n=[1,0,0,0,1,0,0,0,1],!lN(n,_m,wm,Sm,c_))?!1:(u_.crossVectors(Eu,Au),n=[u_.x,u_.y,u_.z],lN(n,_m,wm,Sm,c_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Mo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Mo).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:(Zl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zl),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 Zl=[new De,new De,new De,new De,new De,new De,new De,new De],Mo=new De,l_=new so,_m=new De,wm=new De,Sm=new De,Eu=new De,Au=new De,th=new De,Tx=new De,c_=new De,u_=new De,nh=new De;function lN(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){nh.fromArray(t,a);const o=i.x*Math.abs(nh.x)+i.y*Math.abs(nh.y)+i.z*Math.abs(nh.z),c=e.dot(nh),u=n.dot(nh),d=r.dot(nh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>o)return!1}return!0}const zOe=new so,Cx=new De,cN=new De;class dl{constructor(e=new De,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):zOe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Cx.subVectors(e,this.center);const n=Cx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Cx,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):(cN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Cx.copy(e.center).add(cN)),this.expandByPoint(Cx.copy(e.center).sub(cN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ql=new De,uN=new De,d_=new De,Tu=new De,dN=new De,h_=new De,hN=new De;class AO{constructor(e=new De,n=new De(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,Ql)),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=Ql.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ql.copy(this.origin).addScaledVector(this.direction,n),Ql.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){uN.copy(e).add(n).multiplyScalar(.5),d_.copy(n).sub(e).normalize(),Tu.copy(this.origin).sub(uN);const a=e.distanceTo(n)*.5,s=-this.direction.dot(d_),o=Tu.dot(this.direction),c=-Tu.dot(d_),u=Tu.lengthSq(),d=Math.abs(1-s*s);let f,g,p,x;if(d>0)if(f=s*c-o,g=s*o-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,p=f*(f+s*g+2*o)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+o)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+o)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+o)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(s*a+o)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+o)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(uN).addScaledVector(d_,g),p}intersectSphere(e,n){Ql.subVectors(e.center,this.origin);const r=Ql.dot(this.direction),i=Ql.dot(Ql)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),o=r-s,c=r+s;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(o=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Ql)!==null}intersectTriangle(e,n,r,i,a){dN.subVectors(n,e),h_.subVectors(r,e),hN.crossVectors(dN,h_);let s=this.direction.dot(hN),o;if(s>0){if(i)return null;o=1}else if(s<0)o=-1,s=-s;else return null;Tu.subVectors(this.origin,e);const c=o*this.direction.dot(h_.crossVectors(Tu,h_));if(c<0)return null;const u=o*this.direction.dot(dN.cross(Tu));if(u<0||c+u>s)return null;const d=-o*Tu.dot(hN);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class or{constructor(e,n,r,i,a,s,o,c,u,d,f,g,p,x,v,y){or.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,o,c,u,d,f,g,p,x,v,y)}set(e,n,r,i,a,s,o,c,u,d,f,g,p,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=o,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=p,b[7]=x,b[11]=v,b[15]=y,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 or().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/Mm.setFromMatrixColumn(e,0).length(),a=1/Mm.setFromMatrixColumn(e,1).length(),s=1/Mm.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),o=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,p=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-v*u,n[9]=-o*c,n[2]=v-g*u,n[6]=x+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g+v*o,n[4]=x*o-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=p*o-x,n[6]=v+g*o,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g-v*o,n[4]=-s*f,n[8]=x+p*o,n[1]=p+x*o,n[5]=s*d,n[9]=v-g*o,n[2]=-s*u,n[6]=o,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,p=s*f,x=o*d,v=o*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-x,n[2]=-u,n[6]=o*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+p,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,x=o*c,v=o*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=o*d,n[10]=v*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(BOe,e,HOe)}lookAt(e,n,r){const i=this.elements;return gs.subVectors(e,n),gs.lengthSq()===0&&(gs.z=1),gs.normalize(),Cu.crossVectors(r,gs),Cu.lengthSq()===0&&(Math.abs(r.z)===1?gs.x+=1e-4:gs.z+=1e-4,gs.normalize(),Cu.crossVectors(r,gs)),Cu.normalize(),f_.crossVectors(gs,Cu),i[0]=Cu.x,i[4]=f_.x,i[8]=gs.x,i[1]=Cu.y,i[5]=f_.y,i[9]=gs.y,i[2]=Cu.z,i[6]=f_.z,i[10]=gs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],o=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],v=r[6],y=r[10],b=r[14],E=r[3],w=r[7],A=r[11],T=r[15],C=i[0],k=i[4],F=i[8],N=i[12],j=i[1],I=i[5],O=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],te=i[3],Y=i[7],J=i[11],U=i[15];return a[0]=s*C+o*j+c*R+u*te,a[4]=s*k+o*I+c*W+u*Y,a[8]=s*F+o*O+c*K+u*J,a[12]=s*N+o*q+c*G+u*U,a[1]=d*C+f*j+g*R+p*te,a[5]=d*k+f*I+g*W+p*Y,a[9]=d*F+f*O+g*K+p*J,a[13]=d*N+f*q+g*G+p*U,a[2]=x*C+v*j+y*R+b*te,a[6]=x*k+v*I+y*W+b*Y,a[10]=x*F+v*O+y*K+b*J,a[14]=x*N+v*q+y*G+b*U,a[3]=E*C+w*j+A*R+T*te,a[7]=E*k+w*I+A*W+T*Y,a[11]=E*F+w*O+A*K+T*J,a[15]=E*N+w*q+A*G+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],o=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*o*g+r*u*g+i*o*p-r*c*p)+v*(+n*c*p-n*u*g+a*s*g-i*s*p+i*u*d-a*c*d)+y*(+n*u*f-n*o*p-a*s*f+r*s*p+a*o*d-r*u*d)+b*(-i*o*d-n*c*f+n*o*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],v=e[13],y=e[14],b=e[15],E=f*y*u-v*g*u+v*c*p-o*y*p-f*c*b+o*g*b,w=x*g*u-d*y*u-x*c*p+s*y*p+d*c*b-s*g*b,A=d*v*u-x*f*u+x*o*p-s*v*p-d*o*b+s*f*b,T=x*f*c-d*v*c-x*o*g+s*v*g+d*o*y-s*f*y,C=n*E+r*w+i*A+a*T;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/C;return e[0]=E*k,e[1]=(v*g*a-f*y*a-v*i*p+r*y*p+f*i*b-r*g*b)*k,e[2]=(o*y*a-v*c*a+v*i*u-r*y*u-o*i*b+r*c*b)*k,e[3]=(f*c*a-o*g*a-f*i*u+r*g*u+o*i*p-r*c*p)*k,e[4]=w*k,e[5]=(d*y*a-x*g*a+x*i*p-n*y*p-d*i*b+n*g*b)*k,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*k,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*p+n*c*p)*k,e[8]=A*k,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*b-n*f*b)*k,e[10]=(s*v*a-x*o*a+x*r*u-n*v*u-s*r*b+n*o*b)*k,e[11]=(d*o*a-s*f*a-d*r*u+n*f*u+s*r*p-n*o*p)*k,e[12]=T*k,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*k,e[14]=(x*o*i-s*v*i-x*r*c+n*v*c+s*r*y-n*o*y)*k,e[15]=(s*f*i-d*o*i+d*r*c-n*f*c-s*r*g+n*o*g)*k,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,o=e.y,c=e.z,u=a*s,d=a*o;return this.set(u*s+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*s,0,u*c-i*o,d*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,o=n._z,c=n._w,u=a+a,d=s+s,f=o+o,g=a*u,p=a*d,x=a*f,v=s*d,y=s*f,b=o*f,E=c*u,w=c*d,A=c*f,T=r.x,C=r.y,k=r.z;return i[0]=(1-(v+b))*T,i[1]=(p+A)*T,i[2]=(x-w)*T,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+b))*C,i[6]=(y+E)*C,i[7]=0,i[8]=(x+w)*k,i[9]=(y-E)*k,i[10]=(1-(g+v))*k,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Mm.set(i[0],i[1],i[2]).length();const s=Mm.set(i[4],i[5],i[6]).length(),o=Mm.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Eo.copy(this);const u=1/a,d=1/s,f=1/o;return Eo.elements[0]*=u,Eo.elements[1]*=u,Eo.elements[2]*=u,Eo.elements[4]*=d,Eo.elements[5]*=d,Eo.elements[6]*=d,Eo.elements[8]*=f,Eo.elements[9]*=f,Eo.elements[10]*=f,n.setFromRotationMatrix(Eo),r.x=a,r.y=s,r.z=o,this}makePerspective(e,n,r,i,a,s,o=ll){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let p,x;if(o===ll)p=-(s+a)/(s-a),x=-2*s*a/(s-a);else if(o===Z0)p=-s/(s-a),x=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,s,o=ll){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(s-a),g=(n+e)*u,p=(r+i)*d;let x,v;if(o===ll)x=(s+a)*f,v=-2*f;else if(o===Z0)x=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-g,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=v,c[14]=-x,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 Mm=new De,Eo=new or,BOe=new De(0,0,0),HOe=new De(1,1,1),Cu=new De,f_=new De,gs=new De,L$=new or,I$=new lf;class Xb{constructor(e=0,n=0,r=0,i=Xb.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],o=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(Ji(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Ji(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Ji(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Ji(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(Ji(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ji(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return L$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(L$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return I$.setFromEuler(this),this.setFromQuaternion(I$,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}}Xb.DEFAULT_ORDER="XYZ";class qZ{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 $Oe=0;const F$=new De,Em=new lf,Jl=new or,m_=new De,Nx=new De,VOe=new De,GOe=new lf,U$=new De(1,0,0),z$=new De(0,1,0),B$=new De(0,0,1),WOe={type:"added"},qOe={type:"removed"};class Ca extends bf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:$Oe++}),this.uuid=Tc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ca.DEFAULT_UP.clone();const e=new De,n=new Xb,r=new lf,i=new De(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new or},normalMatrix:{value:new fn}}),this.matrix=new or,this.matrixWorld=new or,this.matrixAutoUpdate=Ca.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ca.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qZ,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 Em.setFromAxisAngle(e,n),this.quaternion.multiply(Em),this}rotateOnWorldAxis(e,n){return Em.setFromAxisAngle(e,n),this.quaternion.premultiply(Em),this}rotateX(e){return this.rotateOnAxis(U$,e)}rotateY(e){return this.rotateOnAxis(z$,e)}rotateZ(e){return this.rotateOnAxis(B$,e)}translateOnAxis(e,n){return F$.copy(e).applyQuaternion(this.quaternion),this.position.add(F$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(U$,e)}translateY(e){return this.translateOnAxis(z$,e)}translateZ(e){return this.translateOnAxis(B$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Jl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?m_.copy(e):m_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Nx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Jl.lookAt(Nx,m_,this.up):Jl.lookAt(m_,Nx,this.up),this.quaternion.setFromRotationMatrix(Jl),i&&(Jl.extractRotation(i.matrixWorld),Em.setFromRotationMatrix(Jl),this.quaternion.premultiply(Em.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(WOe)):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(qOe)),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),Jl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Jl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Jl),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Nx,e,VOe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Nx,GOe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++){const o=i[a];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,u=this.material.length;c<u;c++)o.push(a(e.materials,this.material[c]));i.material=o}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(a(e.animations,c))}}if(n){const o=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),p=s(e.animations),x=s(e.nodes);o.length>0&&(r.geometries=o),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(o){const c=[];for(const u in o){const d=o[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Ca.DEFAULT_UP=new De(0,1,0);Ca.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ca.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ao=new De,ec=new De,fN=new De,tc=new De,Am=new De,Tm=new De,H$=new De,mN=new De,pN=new De,gN=new De;let p_=!1;class To{constructor(e=new De,n=new De,r=new De){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ao.subVectors(e,n),i.cross(Ao);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Ao.subVectors(i,n),ec.subVectors(r,n),fN.subVectors(e,n);const s=Ao.dot(Ao),o=Ao.dot(ec),c=Ao.dot(fN),u=ec.dot(ec),d=ec.dot(fN),f=s*u-o*o;if(f===0)return a.set(-2,-1,-1);const g=1/f,p=(u*c-o*d)*g,x=(s*d-o*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,tc),tc.x>=0&&tc.y>=0&&tc.x+tc.y<=1}static getUV(e,n,r,i,a,s,o,c){return p_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),p_=!0),this.getInterpolation(e,n,r,i,a,s,o,c)}static getInterpolation(e,n,r,i,a,s,o,c){return this.getBarycoord(e,n,r,i,tc),c.setScalar(0),c.addScaledVector(a,tc.x),c.addScaledVector(s,tc.y),c.addScaledVector(o,tc.z),c}static isFrontFacing(e,n,r,i){return Ao.subVectors(r,n),ec.subVectors(e,n),Ao.cross(ec).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 Ao.subVectors(this.c,this.b),ec.subVectors(this.a,this.b),Ao.cross(ec).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return To.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return To.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return p_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),p_=!0),To.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return To.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return To.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return To.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,o;Am.subVectors(i,r),Tm.subVectors(a,r),mN.subVectors(e,r);const c=Am.dot(mN),u=Tm.dot(mN);if(c<=0&&u<=0)return n.copy(r);pN.subVectors(e,i);const d=Am.dot(pN),f=Tm.dot(pN);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return s=c/(c-d),n.copy(r).addScaledVector(Am,s);gN.subVectors(e,a);const p=Am.dot(gN),x=Tm.dot(gN);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(Tm,o);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return H$.subVectors(a,i),o=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(H$,o);const b=1/(y+v+g);return s=v*b,o=g*b,n.copy(r).addScaledVector(Am,s).addScaledVector(Tm,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const KZ={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},Nu={h:0,s:0,l:0},g_={h:0,s:0,l:0};function xN(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,Yn.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Yn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Yn.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Yn.workingColorSpace){if(e=EO(e,1),n=Ji(n,0,1),r=Ji(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=xN(s,a,e+1/3),this.g=xN(s,a,e),this.b=xN(s,a,e-1/3)}return Yn.toWorkingColorSpace(this,i),this}setStyle(e,n=Qi){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],o=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Qi){const r=KZ[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=cp(e.r),this.g=cp(e.g),this.b=cp(e.b),this}copyLinearToSRGB(e){return this.r=aN(e.r),this.g=aN(e.g),this.b=aN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Qi){return Yn.fromWorkingColorSpace(la.copy(this),e),Math.round(Ji(la.r*255,0,255))*65536+Math.round(Ji(la.g*255,0,255))*256+Math.round(Ji(la.b*255,0,255))}getHexString(e=Qi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Yn.workingColorSpace){Yn.fromWorkingColorSpace(la.copy(this),n);const r=la.r,i=la.g,a=la.b,s=Math.max(r,i,a),o=Math.min(r,i,a);let c,u;const d=(o+s)/2;if(o===s)c=0,u=0;else{const f=s-o;switch(u=d<=.5?f/(s+o):f/(2-s-o),s){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Yn.workingColorSpace){return Yn.fromWorkingColorSpace(la.copy(this),n),e.r=la.r,e.g=la.g,e.b=la.b,e}getStyle(e=Qi){Yn.fromWorkingColorSpace(la.copy(this),e);const n=la.r,r=la.g,i=la.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(Nu),this.setHSL(Nu.h+e,Nu.s+n,Nu.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(Nu),e.getHSL(g_);const r=Jx(Nu.h,g_.h,n),i=Jx(Nu.s,g_.s,n),a=Jx(Nu.l,g_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const la=new $t;$t.NAMES=KZ;let KOe=0;class fg extends bf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:KOe++}),this.uuid=Tc(),this.name="",this.type="Material",this.blending=lp,this.side=vd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=jP,this.blendDst=DP,this.blendEquation=ph,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new $t(0,0,0),this.blendAlpha=0,this.depthFunc=Fw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=N$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ym,this.stencilZFail=ym,this.stencilZPass=ym,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!==lp&&(r.blending=this.blending),this.side!==vd&&(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!==jP&&(r.blendSrc=this.blendSrc),this.blendDst!==DP&&(r.blendDst=this.blendDst),this.blendEquation!==ph&&(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!==Fw&&(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!==N$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ym&&(r.stencilFail=this.stencilFail),this.stencilZFail!==ym&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==ym&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const o in a){const c=a[o];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class XZ extends fg{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=wO,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 Qr=new De,x_=new Zt;class As{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=UP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=yc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)x_.fromBufferAttribute(this,n),x_.applyMatrix3(e),this.setXY(n,x_.x,x_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Qr.fromBufferAttribute(this,n),Qr.applyMatrix3(e),this.setXYZ(n,Qr.x,Qr.y,Qr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Qr.fromBufferAttribute(this,n),Qr.applyMatrix4(e),this.setXYZ(n,Qr.x,Qr.y,Qr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Qr.fromBufferAttribute(this,n),Qr.applyNormalMatrix(e),this.setXYZ(n,Qr.x,Qr.y,Qr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Qr.fromBufferAttribute(this,n),Qr.transformDirection(e),this.setXYZ(n,Qr.x,Qr.y,Qr.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=il(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Xn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=il(n,this.array)),n}setX(e,n){return this.normalized&&(n=Xn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=il(n,this.array)),n}setY(e,n){return this.normalized&&(n=Xn(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=il(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Xn(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=il(n,this.array)),n}setW(e,n){return this.normalized&&(n=Xn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Xn(n,this.array),r=Xn(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=Xn(n,this.array),r=Xn(r,this.array),i=Xn(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Xn(n,this.array),r=Xn(r,this.array),i=Xn(i,this.array),a=Xn(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==UP&&(e.usage=this.usage),e}}class YZ extends As{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class ZZ extends As{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Vr extends As{constructor(e,n,r){super(new Float32Array(e),n,r)}}let XOe=0;const Hs=new or,bN=new Ca,Cm=new De,xs=new so,kx=new so,ki=new De;class xa extends bf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:XOe++}),this.uuid=Tc(),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($Z(e)?ZZ:YZ)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new fn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Hs.makeRotationFromQuaternion(e),this.applyMatrix4(Hs),this}rotateX(e){return Hs.makeRotationX(e),this.applyMatrix4(Hs),this}rotateY(e){return Hs.makeRotationY(e),this.applyMatrix4(Hs),this}rotateZ(e){return Hs.makeRotationZ(e),this.applyMatrix4(Hs),this}translate(e,n,r){return Hs.makeTranslation(e,n,r),this.applyMatrix4(Hs),this}scale(e,n,r){return Hs.makeScale(e,n,r),this.applyMatrix4(Hs),this}lookAt(e){return bN.lookAt(e),bN.updateMatrix(),this.applyMatrix4(bN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cm).negate(),this.translate(Cm.x,Cm.y,Cm.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new Vr(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new so);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 De(-1/0,-1/0,-1/0),new De(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];xs.setFromBufferAttribute(a),this.morphTargetsRelative?(ki.addVectors(this.boundingBox.min,xs.min),this.boundingBox.expandByPoint(ki),ki.addVectors(this.boundingBox.max,xs.max),this.boundingBox.expandByPoint(ki)):(this.boundingBox.expandByPoint(xs.min),this.boundingBox.expandByPoint(xs.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 dl);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 De,1/0);return}if(e){const r=this.boundingSphere.center;if(xs.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];kx.setFromBufferAttribute(o),this.morphTargetsRelative?(ki.addVectors(xs.min,kx.min),xs.expandByPoint(ki),ki.addVectors(xs.max,kx.max),xs.expandByPoint(ki)):(xs.expandByPoint(kx.min),xs.expandByPoint(kx.max))}xs.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)ki.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(ki));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)ki.fromBufferAttribute(o,u),c&&(Cm.fromBufferAttribute(e,u),ki.add(Cm)),i=Math.max(i,r.distanceToSquared(ki))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,s=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new As(new Float32Array(4*o),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let j=0;j<o;j++)u[j]=new De,d[j]=new De;const f=new De,g=new De,p=new De,x=new Zt,v=new Zt,y=new Zt,b=new De,E=new De;function w(j,I,O){f.fromArray(i,j*3),g.fromArray(i,I*3),p.fromArray(i,O*3),x.fromArray(s,j*2),v.fromArray(s,I*2),y.fromArray(s,O*2),g.sub(f),p.sub(f),v.sub(x),y.sub(x);const q=1/(v.x*y.y-y.x*v.y);isFinite(q)&&(b.copy(g).multiplyScalar(y.y).addScaledVector(p,-v.y).multiplyScalar(q),E.copy(p).multiplyScalar(v.x).addScaledVector(g,-y.x).multiplyScalar(q),u[j].add(b),u[I].add(b),u[O].add(b),d[j].add(E),d[I].add(E),d[O].add(E))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let j=0,I=A.length;j<I;++j){const O=A[j],q=O.start,R=O.count;for(let W=q,K=q+R;W<K;W+=3)w(r[W+0],r[W+1],r[W+2])}const T=new De,C=new De,k=new De,F=new De;function N(j){k.fromArray(a,j*3),F.copy(k);const I=u[j];T.copy(I),T.sub(k.multiplyScalar(k.dot(I))).normalize(),C.crossVectors(F,I);const q=C.dot(d[j])<0?-1:1;c[j*4]=T.x,c[j*4+1]=T.y,c[j*4+2]=T.z,c[j*4+3]=q}for(let j=0,I=A.length;j<I;++j){const O=A[j],q=O.start,R=O.count;for(let W=q,K=q+R;W<K;W+=3)N(r[W+0]),N(r[W+1]),N(r[W+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new As(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new De,a=new De,s=new De,o=new De,c=new De,u=new De,d=new De,f=new De;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),o.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),o.add(d),c.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),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++)ki.fromBufferAttribute(e,n),ki.normalize(),e.setXYZ(n,ki.x,ki.y,ki.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,y=c.length;v<y;v++){o.isInterleavedBufferAttribute?p=c[v]*o.data.stride+o.offset:p=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[p++]}return new As(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new xa,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const a=this.morphAttributes;for(const o in a){const c=[],u=a[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,c=s.length;o<c;o++){const u=s[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const $$=new or,rh=new AO,b_=new dl,V$=new De,Nm=new De,km=new De,Pm=new De,yN=new De,y_=new De,v_=new Zt,__=new Zt,w_=new Zt,G$=new De,W$=new De,q$=new De,S_=new De,M_=new De;class Do extends Ca{constructor(e=new xa,n=new XZ){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(a&&o){y_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=o[c],f=a[c];d!==0&&(yN.fromBufferAttribute(f,e),s?y_.addScaledVector(yN,d):y_.addScaledVector(yN.sub(n),d))}n.add(y_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),b_.copy(r.boundingSphere),b_.applyMatrix4(a),rh.copy(e.ray).recast(e.near),!(b_.containsPoint(rh.origin)===!1&&(rh.intersectSphere(b_,V$)===null||rh.origin.distanceToSquared(V$)>(e.far-e.near)**2))&&($$.copy(a).invert(),rh.copy(e.ray).applyMatrix4($$),!(r.boundingBox!==null&&rh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,rh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,o=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,p=a.drawRange;if(o!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(o.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=o.getX(A),k=o.getX(A+1),F=o.getX(A+2);i=E_(this,b,e,r,u,d,f,C,k,F),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=o.getX(y),w=o.getX(y+1),A=o.getX(y+2);i=E_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=A,k=A+1,F=A+2;i=E_(this,b,e,r,u,d,f,C,k,F),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=y,w=y+1,A=y+2;i=E_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}}function YOe(t,e,n,r,i,a,s,o){let c;if(e.side===Qa?c=r.intersectTriangle(s,a,i,!0,o):c=r.intersectTriangle(i,a,s,e.side===vd,o),c===null)return null;M_.copy(o),M_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(M_);return u<n.near||u>n.far?null:{distance:u,point:M_.clone(),object:t}}function E_(t,e,n,r,i,a,s,o,c,u){t.getVertexPosition(o,Nm),t.getVertexPosition(c,km),t.getVertexPosition(u,Pm);const d=YOe(t,e,n,r,Nm,km,Pm,S_);if(d){i&&(v_.fromBufferAttribute(i,o),__.fromBufferAttribute(i,c),w_.fromBufferAttribute(i,u),d.uv=To.getInterpolation(S_,Nm,km,Pm,v_,__,w_,new Zt)),a&&(v_.fromBufferAttribute(a,o),__.fromBufferAttribute(a,c),w_.fromBufferAttribute(a,u),d.uv1=To.getInterpolation(S_,Nm,km,Pm,v_,__,w_,new Zt),d.uv2=d.uv1),s&&(G$.fromBufferAttribute(s,o),W$.fromBufferAttribute(s,c),q$.fromBufferAttribute(s,u),d.normal=To.getInterpolation(S_,Nm,km,Pm,G$,W$,q$,new De),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:o,b:c,c:u,normal:new De,materialIndex:0};To.getNormal(Nm,km,Pm,f.normal),d.face=f}return d}class Yb extends xa{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const o=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Vr(u,3)),this.setAttribute("normal",new Vr(d,3)),this.setAttribute("uv",new Vr(f,2));function x(v,y,b,E,w,A,T,C,k,F,N){const j=A/k,I=T/F,O=A/2,q=T/2,R=C/2,W=k+1,K=F+1;let G=0,te=0;const Y=new De;for(let J=0;J<K;J++){const U=J*I-q;for(let H=0;H<W;H++){const ee=H*j-O;Y[v]=ee*E,Y[y]=U*w,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[v]=0,Y[y]=0,Y[b]=C>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push(H/k),f.push(1-J/F),G+=1}}for(let J=0;J<F;J++)for(let U=0;U<k;U++){const H=g+U+W*J,ee=g+U+W*(J+1),ie=g+(U+1)+W*(J+1),pe=g+(U+1)+W*J;c.push(H,ee,pe),c.push(ee,ie,pe),te+=6}o.addGroup(p,te,N),p+=te,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Yb(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Fp(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 wa(t){const e={};for(let n=0;n<t.length;n++){const r=Fp(t[n]);for(const i in r)e[i]=r[i]}return e}function ZOe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function QZ(t){return t.getRenderTarget()===null?t.outputColorSpace:Yn.workingColorSpace}const TO={clone:Fp,merge:wa};var QOe=`void main() {
  3875. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3876. }`,JOe=`void main() {
  3877. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3878. }`;class _d extends fg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=QOe,this.fragmentShader=JOe,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=Fp(e.uniforms),this.uniformsGroups=ZOe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class JZ extends Ca{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new or,this.projectionMatrix=new or,this.projectionMatrixInverse=new or,this.coordinateSystem=ll}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 ys extends JZ{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=Q0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Qx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Q0*2*Math.atan(Math.tan(Qx*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Qx*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const Rm=-90,jm=1;class eLe extends Ca{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ys(Rm,jm,e,n);i.layers=this.layers,this.add(i);const a=new ys(Rm,jm,e,n);a.layers=this.layers,this.add(a);const s=new ys(Rm,jm,e,n);s.layers=this.layers,this.add(s);const o=new ys(Rm,jm,e,n);o.layers=this.layers,this.add(o);const c=new ys(Rm,jm,e,n);c.layers=this.layers,this.add(c);const u=new ys(Rm,jm,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,o,c]=n;for(const u of n)this.remove(u);if(e===ll)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Z0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class eQ extends Ja{constructor(e,n,r,i,a,s,o,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Op,super(e,n,r,i,a,s,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class tLe extends of{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&&(e0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Lh?Qi:eo),this.texture=new eQ(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:Qs}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:`
  3879. varying vec3 vWorldDirection;
  3880. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3881. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3882. }
  3883. void main() {
  3884. vWorldDirection = transformDirection( position, modelMatrix );
  3885. #include <begin_vertex>
  3886. #include <project_vertex>
  3887. }
  3888. `,fragmentShader:`
  3889. uniform sampler2D tEquirect;
  3890. varying vec3 vWorldDirection;
  3891. #include <common>
  3892. void main() {
  3893. vec3 direction = normalize( vWorldDirection );
  3894. vec2 sampleUV = equirectUv( direction );
  3895. gl_FragColor = texture2D( tEquirect, sampleUV );
  3896. }
  3897. `},i=new Yb(5,5,5),a=new _d({name:"CubemapFromEquirect",uniforms:Fp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Qa,blending:nd});a.uniforms.tEquirect.value=n;const s=new Do(i,a),o=n.minFilter;return n.minFilter===X0&&(n.minFilter=Qs),new eLe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}}const vN=new De,nLe=new De,rLe=new fn;class Iu{constructor(e=new De(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=vN.subVectors(r,n).cross(nLe.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(vN),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||rLe.getNormalMatrix(e),i=this.coplanarPoint(vN).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ih=new dl,A_=new De;class XM{constructor(e=new Iu,n=new Iu,r=new Iu,i=new Iu,a=new Iu,s=new Iu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=ll){const r=this.planes,i=e.elements,a=i[0],s=i[1],o=i[2],c=i[3],u=i[4],d=i[5],f=i[6],g=i[7],p=i[8],x=i[9],v=i[10],y=i[11],b=i[12],E=i[13],w=i[14],A=i[15];if(r[0].setComponents(c-a,g-u,y-p,A-b).normalize(),r[1].setComponents(c+a,g+u,y+p,A+b).normalize(),r[2].setComponents(c+s,g+d,y+x,A+E).normalize(),r[3].setComponents(c-s,g-d,y-x,A-E).normalize(),r[4].setComponents(c-o,g-f,y-v,A-w).normalize(),n===ll)r[5].setComponents(c+o,g+f,y+v,A+w).normalize();else if(n===Z0)r[5].setComponents(o,f,v,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ih.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),ih.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ih)}intersectsSprite(e){return ih.center.set(0,0,0),ih.radius=.7071067811865476,ih.applyMatrix4(e.matrixWorld),this.intersectsSphere(ih)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(A_.x=i.normal.x>0?e.max.x:e.min.x,A_.y=i.normal.y>0?e.max.y:e.min.y,A_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(A_)<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 tQ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function iLe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,g),u.onUploadCallback();let v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const g=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,g),x.length!==0){for(let v=0,y=x.length;v<y;v++){const b=x[v];n?t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g,b.start,b.count):t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g.subarray(b.start,b.start+b.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g,p.offset,p.count):t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function s(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function o(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:s,remove:o,update:c}}class CO extends xa{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,o=Math.floor(r),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,p=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const E=b*g-s;for(let w=0;w<u;w++){const A=w*f-a;x.push(A,-E,0),v.push(0,0,1),y.push(w/o),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<o;E++){const w=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),C=E+1+u*b;p.push(w,A,C),p.push(A,T,C)}this.setIndex(p),this.setAttribute("position",new Vr(x,3)),this.setAttribute("normal",new Vr(v,3)),this.setAttribute("uv",new Vr(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new CO(e.width,e.height,e.widthSegments,e.heightSegments)}}var aLe=`#ifdef USE_ALPHAHASH
  3898. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3899. #endif`,sLe=`#ifdef USE_ALPHAHASH
  3900. const float ALPHA_HASH_SCALE = 0.05;
  3901. float hash2D( vec2 value ) {
  3902. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3903. }
  3904. float hash3D( vec3 value ) {
  3905. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3906. }
  3907. float getAlphaHashThreshold( vec3 position ) {
  3908. float maxDeriv = max(
  3909. length( dFdx( position.xyz ) ),
  3910. length( dFdy( position.xyz ) )
  3911. );
  3912. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3913. vec2 pixScales = vec2(
  3914. exp2( floor( log2( pixScale ) ) ),
  3915. exp2( ceil( log2( pixScale ) ) )
  3916. );
  3917. vec2 alpha = vec2(
  3918. hash3D( floor( pixScales.x * position.xyz ) ),
  3919. hash3D( floor( pixScales.y * position.xyz ) )
  3920. );
  3921. float lerpFactor = fract( log2( pixScale ) );
  3922. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3923. float a = min( lerpFactor, 1.0 - lerpFactor );
  3924. vec3 cases = vec3(
  3925. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3926. ( x - 0.5 * a ) / ( 1.0 - a ),
  3927. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3928. );
  3929. float threshold = ( x < ( 1.0 - a ) )
  3930. ? ( ( x < a ) ? cases.x : cases.y )
  3931. : cases.z;
  3932. return clamp( threshold , 1.0e-6, 1.0 );
  3933. }
  3934. #endif`,oLe=`#ifdef USE_ALPHAMAP
  3935. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3936. #endif`,lLe=`#ifdef USE_ALPHAMAP
  3937. uniform sampler2D alphaMap;
  3938. #endif`,cLe=`#ifdef USE_ALPHATEST
  3939. if ( diffuseColor.a < alphaTest ) discard;
  3940. #endif`,uLe=`#ifdef USE_ALPHATEST
  3941. uniform float alphaTest;
  3942. #endif`,dLe=`#ifdef USE_AOMAP
  3943. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3944. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3945. #if defined( USE_CLEARCOAT )
  3946. clearcoatSpecularIndirect *= ambientOcclusion;
  3947. #endif
  3948. #if defined( USE_SHEEN )
  3949. sheenSpecularIndirect *= ambientOcclusion;
  3950. #endif
  3951. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3952. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3953. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3954. #endif
  3955. #endif`,hLe=`#ifdef USE_AOMAP
  3956. uniform sampler2D aoMap;
  3957. uniform float aoMapIntensity;
  3958. #endif`,fLe=`#ifdef USE_BATCHING
  3959. attribute float batchId;
  3960. uniform highp sampler2D batchingTexture;
  3961. mat4 getBatchingMatrix( const in float i ) {
  3962. int size = textureSize( batchingTexture, 0 ).x;
  3963. int j = int( i ) * 4;
  3964. int x = j % size;
  3965. int y = j / size;
  3966. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3967. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3968. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3969. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3970. return mat4( v1, v2, v3, v4 );
  3971. }
  3972. #endif`,mLe=`#ifdef USE_BATCHING
  3973. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3974. #endif`,pLe=`vec3 transformed = vec3( position );
  3975. #ifdef USE_ALPHAHASH
  3976. vPosition = vec3( position );
  3977. #endif`,gLe=`vec3 objectNormal = vec3( normal );
  3978. #ifdef USE_TANGENT
  3979. vec3 objectTangent = vec3( tangent.xyz );
  3980. #endif`,xLe=`float G_BlinnPhong_Implicit( ) {
  3981. return 0.25;
  3982. }
  3983. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3984. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3985. }
  3986. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3987. vec3 halfDir = normalize( lightDir + viewDir );
  3988. float dotNH = saturate( dot( normal, halfDir ) );
  3989. float dotVH = saturate( dot( viewDir, halfDir ) );
  3990. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3991. float G = G_BlinnPhong_Implicit( );
  3992. float D = D_BlinnPhong( shininess, dotNH );
  3993. return F * ( G * D );
  3994. } // validated`,bLe=`#ifdef USE_IRIDESCENCE
  3995. const mat3 XYZ_TO_REC709 = mat3(
  3996. 3.2404542, -0.9692660, 0.0556434,
  3997. -1.5371385, 1.8760108, -0.2040259,
  3998. -0.4985314, 0.0415560, 1.0572252
  3999. );
  4000. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4001. vec3 sqrtF0 = sqrt( fresnel0 );
  4002. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4003. }
  4004. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4005. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4006. }
  4007. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4008. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4009. }
  4010. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4011. float phase = 2.0 * PI * OPD * 1.0e-9;
  4012. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4013. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4014. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4015. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4016. 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 ) );
  4017. xyz /= 1.0685e-7;
  4018. vec3 rgb = XYZ_TO_REC709 * xyz;
  4019. return rgb;
  4020. }
  4021. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4022. vec3 I;
  4023. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4024. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4025. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4026. if ( cosTheta2Sq < 0.0 ) {
  4027. return vec3( 1.0 );
  4028. }
  4029. float cosTheta2 = sqrt( cosTheta2Sq );
  4030. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4031. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4032. float T121 = 1.0 - R12;
  4033. float phi12 = 0.0;
  4034. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4035. float phi21 = PI - phi12;
  4036. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4037. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4038. vec3 phi23 = vec3( 0.0 );
  4039. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4040. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4041. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4042. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4043. vec3 phi = vec3( phi21 ) + phi23;
  4044. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4045. vec3 r123 = sqrt( R123 );
  4046. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4047. vec3 C0 = R12 + Rs;
  4048. I = C0;
  4049. vec3 Cm = Rs - T121;
  4050. for ( int m = 1; m <= 2; ++ m ) {
  4051. Cm *= r123;
  4052. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4053. I += Cm * Sm;
  4054. }
  4055. return max( I, vec3( 0.0 ) );
  4056. }
  4057. #endif`,yLe=`#ifdef USE_BUMPMAP
  4058. uniform sampler2D bumpMap;
  4059. uniform float bumpScale;
  4060. vec2 dHdxy_fwd() {
  4061. vec2 dSTdx = dFdx( vBumpMapUv );
  4062. vec2 dSTdy = dFdy( vBumpMapUv );
  4063. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4064. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4065. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4066. return vec2( dBx, dBy );
  4067. }
  4068. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4069. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4070. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4071. vec3 vN = surf_norm;
  4072. vec3 R1 = cross( vSigmaY, vN );
  4073. vec3 R2 = cross( vN, vSigmaX );
  4074. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4075. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4076. return normalize( abs( fDet ) * surf_norm - vGrad );
  4077. }
  4078. #endif`,vLe=`#if NUM_CLIPPING_PLANES > 0
  4079. vec4 plane;
  4080. #pragma unroll_loop_start
  4081. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4082. plane = clippingPlanes[ i ];
  4083. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4084. }
  4085. #pragma unroll_loop_end
  4086. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4087. bool clipped = true;
  4088. #pragma unroll_loop_start
  4089. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4090. plane = clippingPlanes[ i ];
  4091. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4092. }
  4093. #pragma unroll_loop_end
  4094. if ( clipped ) discard;
  4095. #endif
  4096. #endif`,_Le=`#if NUM_CLIPPING_PLANES > 0
  4097. varying vec3 vClipPosition;
  4098. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4099. #endif`,wLe=`#if NUM_CLIPPING_PLANES > 0
  4100. varying vec3 vClipPosition;
  4101. #endif`,SLe=`#if NUM_CLIPPING_PLANES > 0
  4102. vClipPosition = - mvPosition.xyz;
  4103. #endif`,MLe=`#if defined( USE_COLOR_ALPHA )
  4104. diffuseColor *= vColor;
  4105. #elif defined( USE_COLOR )
  4106. diffuseColor.rgb *= vColor;
  4107. #endif`,ELe=`#if defined( USE_COLOR_ALPHA )
  4108. varying vec4 vColor;
  4109. #elif defined( USE_COLOR )
  4110. varying vec3 vColor;
  4111. #endif`,ALe=`#if defined( USE_COLOR_ALPHA )
  4112. varying vec4 vColor;
  4113. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4114. varying vec3 vColor;
  4115. #endif`,TLe=`#if defined( USE_COLOR_ALPHA )
  4116. vColor = vec4( 1.0 );
  4117. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4118. vColor = vec3( 1.0 );
  4119. #endif
  4120. #ifdef USE_COLOR
  4121. vColor *= color;
  4122. #endif
  4123. #ifdef USE_INSTANCING_COLOR
  4124. vColor.xyz *= instanceColor.xyz;
  4125. #endif`,CLe=`#define PI 3.141592653589793
  4126. #define PI2 6.283185307179586
  4127. #define PI_HALF 1.5707963267948966
  4128. #define RECIPROCAL_PI 0.3183098861837907
  4129. #define RECIPROCAL_PI2 0.15915494309189535
  4130. #define EPSILON 1e-6
  4131. #ifndef saturate
  4132. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4133. #endif
  4134. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4135. float pow2( const in float x ) { return x*x; }
  4136. vec3 pow2( const in vec3 x ) { return x*x; }
  4137. float pow3( const in float x ) { return x*x*x; }
  4138. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4139. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4140. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4141. highp float rand( const in vec2 uv ) {
  4142. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4143. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4144. return fract( sin( sn ) * c );
  4145. }
  4146. #ifdef HIGH_PRECISION
  4147. float precisionSafeLength( vec3 v ) { return length( v ); }
  4148. #else
  4149. float precisionSafeLength( vec3 v ) {
  4150. float maxComponent = max3( abs( v ) );
  4151. return length( v / maxComponent ) * maxComponent;
  4152. }
  4153. #endif
  4154. struct IncidentLight {
  4155. vec3 color;
  4156. vec3 direction;
  4157. bool visible;
  4158. };
  4159. struct ReflectedLight {
  4160. vec3 directDiffuse;
  4161. vec3 directSpecular;
  4162. vec3 indirectDiffuse;
  4163. vec3 indirectSpecular;
  4164. };
  4165. #ifdef USE_ALPHAHASH
  4166. varying vec3 vPosition;
  4167. #endif
  4168. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4169. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4170. }
  4171. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4172. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4173. }
  4174. mat3 transposeMat3( const in mat3 m ) {
  4175. mat3 tmp;
  4176. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4177. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4178. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4179. return tmp;
  4180. }
  4181. float luminance( const in vec3 rgb ) {
  4182. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4183. return dot( weights, rgb );
  4184. }
  4185. bool isPerspectiveMatrix( mat4 m ) {
  4186. return m[ 2 ][ 3 ] == - 1.0;
  4187. }
  4188. vec2 equirectUv( in vec3 dir ) {
  4189. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4190. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4191. return vec2( u, v );
  4192. }
  4193. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4194. return RECIPROCAL_PI * diffuseColor;
  4195. }
  4196. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4197. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4198. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4199. }
  4200. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4201. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4202. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4203. } // validated`,NLe=`#ifdef ENVMAP_TYPE_CUBE_UV
  4204. #define cubeUV_minMipLevel 4.0
  4205. #define cubeUV_minTileSize 16.0
  4206. float getFace( vec3 direction ) {
  4207. vec3 absDirection = abs( direction );
  4208. float face = - 1.0;
  4209. if ( absDirection.x > absDirection.z ) {
  4210. if ( absDirection.x > absDirection.y )
  4211. face = direction.x > 0.0 ? 0.0 : 3.0;
  4212. else
  4213. face = direction.y > 0.0 ? 1.0 : 4.0;
  4214. } else {
  4215. if ( absDirection.z > absDirection.y )
  4216. face = direction.z > 0.0 ? 2.0 : 5.0;
  4217. else
  4218. face = direction.y > 0.0 ? 1.0 : 4.0;
  4219. }
  4220. return face;
  4221. }
  4222. vec2 getUV( vec3 direction, float face ) {
  4223. vec2 uv;
  4224. if ( face == 0.0 ) {
  4225. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4226. } else if ( face == 1.0 ) {
  4227. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4228. } else if ( face == 2.0 ) {
  4229. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4230. } else if ( face == 3.0 ) {
  4231. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4232. } else if ( face == 4.0 ) {
  4233. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4234. } else {
  4235. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4236. }
  4237. return 0.5 * ( uv + 1.0 );
  4238. }
  4239. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4240. float face = getFace( direction );
  4241. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4242. mipInt = max( mipInt, cubeUV_minMipLevel );
  4243. float faceSize = exp2( mipInt );
  4244. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4245. if ( face > 2.0 ) {
  4246. uv.y += faceSize;
  4247. face -= 3.0;
  4248. }
  4249. uv.x += face * faceSize;
  4250. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4251. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4252. uv.x *= CUBEUV_TEXEL_WIDTH;
  4253. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4254. #ifdef texture2DGradEXT
  4255. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4256. #else
  4257. return texture2D( envMap, uv ).rgb;
  4258. #endif
  4259. }
  4260. #define cubeUV_r0 1.0
  4261. #define cubeUV_v0 0.339
  4262. #define cubeUV_m0 - 2.0
  4263. #define cubeUV_r1 0.8
  4264. #define cubeUV_v1 0.276
  4265. #define cubeUV_m1 - 1.0
  4266. #define cubeUV_r4 0.4
  4267. #define cubeUV_v4 0.046
  4268. #define cubeUV_m4 2.0
  4269. #define cubeUV_r5 0.305
  4270. #define cubeUV_v5 0.016
  4271. #define cubeUV_m5 3.0
  4272. #define cubeUV_r6 0.21
  4273. #define cubeUV_v6 0.0038
  4274. #define cubeUV_m6 4.0
  4275. float roughnessToMip( float roughness ) {
  4276. float mip = 0.0;
  4277. if ( roughness >= cubeUV_r1 ) {
  4278. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4279. } else if ( roughness >= cubeUV_r4 ) {
  4280. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4281. } else if ( roughness >= cubeUV_r5 ) {
  4282. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4283. } else if ( roughness >= cubeUV_r6 ) {
  4284. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4285. } else {
  4286. mip = - 2.0 * log2( 1.16 * roughness ); }
  4287. return mip;
  4288. }
  4289. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4290. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4291. float mipF = fract( mip );
  4292. float mipInt = floor( mip );
  4293. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4294. if ( mipF == 0.0 ) {
  4295. return vec4( color0, 1.0 );
  4296. } else {
  4297. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4298. return vec4( mix( color0, color1, mipF ), 1.0 );
  4299. }
  4300. }
  4301. #endif`,kLe=`vec3 transformedNormal = objectNormal;
  4302. #ifdef USE_TANGENT
  4303. vec3 transformedTangent = objectTangent;
  4304. #endif
  4305. #ifdef USE_BATCHING
  4306. mat3 bm = mat3( batchingMatrix );
  4307. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4308. transformedNormal = bm * transformedNormal;
  4309. #ifdef USE_TANGENT
  4310. transformedTangent = bm * transformedTangent;
  4311. #endif
  4312. #endif
  4313. #ifdef USE_INSTANCING
  4314. mat3 im = mat3( instanceMatrix );
  4315. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4316. transformedNormal = im * transformedNormal;
  4317. #ifdef USE_TANGENT
  4318. transformedTangent = im * transformedTangent;
  4319. #endif
  4320. #endif
  4321. transformedNormal = normalMatrix * transformedNormal;
  4322. #ifdef FLIP_SIDED
  4323. transformedNormal = - transformedNormal;
  4324. #endif
  4325. #ifdef USE_TANGENT
  4326. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4327. #ifdef FLIP_SIDED
  4328. transformedTangent = - transformedTangent;
  4329. #endif
  4330. #endif`,PLe=`#ifdef USE_DISPLACEMENTMAP
  4331. uniform sampler2D displacementMap;
  4332. uniform float displacementScale;
  4333. uniform float displacementBias;
  4334. #endif`,RLe=`#ifdef USE_DISPLACEMENTMAP
  4335. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4336. #endif`,jLe=`#ifdef USE_EMISSIVEMAP
  4337. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4338. totalEmissiveRadiance *= emissiveColor.rgb;
  4339. #endif`,DLe=`#ifdef USE_EMISSIVEMAP
  4340. uniform sampler2D emissiveMap;
  4341. #endif`,OLe="gl_FragColor = linearToOutputTexel( gl_FragColor );",LLe=`
  4342. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4343. vec3( 0.8224621, 0.177538, 0.0 ),
  4344. vec3( 0.0331941, 0.9668058, 0.0 ),
  4345. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4346. );
  4347. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4348. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4349. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4350. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4351. );
  4352. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4353. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4354. }
  4355. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4356. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4357. }
  4358. vec4 LinearTransferOETF( in vec4 value ) {
  4359. return value;
  4360. }
  4361. vec4 sRGBTransferOETF( in vec4 value ) {
  4362. 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 );
  4363. }
  4364. vec4 LinearToLinear( in vec4 value ) {
  4365. return value;
  4366. }
  4367. vec4 LinearTosRGB( in vec4 value ) {
  4368. return sRGBTransferOETF( value );
  4369. }`,ILe=`#ifdef USE_ENVMAP
  4370. #ifdef ENV_WORLDPOS
  4371. vec3 cameraToFrag;
  4372. if ( isOrthographic ) {
  4373. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4374. } else {
  4375. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4376. }
  4377. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4378. #ifdef ENVMAP_MODE_REFLECTION
  4379. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4380. #else
  4381. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4382. #endif
  4383. #else
  4384. vec3 reflectVec = vReflect;
  4385. #endif
  4386. #ifdef ENVMAP_TYPE_CUBE
  4387. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4388. #else
  4389. vec4 envColor = vec4( 0.0 );
  4390. #endif
  4391. #ifdef ENVMAP_BLENDING_MULTIPLY
  4392. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4393. #elif defined( ENVMAP_BLENDING_MIX )
  4394. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4395. #elif defined( ENVMAP_BLENDING_ADD )
  4396. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4397. #endif
  4398. #endif`,FLe=`#ifdef USE_ENVMAP
  4399. uniform float envMapIntensity;
  4400. uniform float flipEnvMap;
  4401. #ifdef ENVMAP_TYPE_CUBE
  4402. uniform samplerCube envMap;
  4403. #else
  4404. uniform sampler2D envMap;
  4405. #endif
  4406. #endif`,ULe=`#ifdef USE_ENVMAP
  4407. uniform float reflectivity;
  4408. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4409. #define ENV_WORLDPOS
  4410. #endif
  4411. #ifdef ENV_WORLDPOS
  4412. varying vec3 vWorldPosition;
  4413. uniform float refractionRatio;
  4414. #else
  4415. varying vec3 vReflect;
  4416. #endif
  4417. #endif`,zLe=`#ifdef USE_ENVMAP
  4418. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4419. #define ENV_WORLDPOS
  4420. #endif
  4421. #ifdef ENV_WORLDPOS
  4422. varying vec3 vWorldPosition;
  4423. #else
  4424. varying vec3 vReflect;
  4425. uniform float refractionRatio;
  4426. #endif
  4427. #endif`,BLe=`#ifdef USE_ENVMAP
  4428. #ifdef ENV_WORLDPOS
  4429. vWorldPosition = worldPosition.xyz;
  4430. #else
  4431. vec3 cameraToVertex;
  4432. if ( isOrthographic ) {
  4433. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4434. } else {
  4435. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4436. }
  4437. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4438. #ifdef ENVMAP_MODE_REFLECTION
  4439. vReflect = reflect( cameraToVertex, worldNormal );
  4440. #else
  4441. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4442. #endif
  4443. #endif
  4444. #endif`,HLe=`#ifdef USE_FOG
  4445. vFogDepth = - mvPosition.z;
  4446. #endif`,$Le=`#ifdef USE_FOG
  4447. varying float vFogDepth;
  4448. #endif`,VLe=`#ifdef USE_FOG
  4449. #ifdef FOG_EXP2
  4450. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4451. #else
  4452. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4453. #endif
  4454. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4455. #endif`,GLe=`#ifdef USE_FOG
  4456. uniform vec3 fogColor;
  4457. varying float vFogDepth;
  4458. #ifdef FOG_EXP2
  4459. uniform float fogDensity;
  4460. #else
  4461. uniform float fogNear;
  4462. uniform float fogFar;
  4463. #endif
  4464. #endif`,WLe=`#ifdef USE_GRADIENTMAP
  4465. uniform sampler2D gradientMap;
  4466. #endif
  4467. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4468. float dotNL = dot( normal, lightDirection );
  4469. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4470. #ifdef USE_GRADIENTMAP
  4471. return vec3( texture2D( gradientMap, coord ).r );
  4472. #else
  4473. vec2 fw = fwidth( coord ) * 0.5;
  4474. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4475. #endif
  4476. }`,qLe=`#ifdef USE_LIGHTMAP
  4477. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4478. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4479. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4480. #endif`,KLe=`#ifdef USE_LIGHTMAP
  4481. uniform sampler2D lightMap;
  4482. uniform float lightMapIntensity;
  4483. #endif`,XLe=`LambertMaterial material;
  4484. material.diffuseColor = diffuseColor.rgb;
  4485. material.specularStrength = specularStrength;`,YLe=`varying vec3 vViewPosition;
  4486. struct LambertMaterial {
  4487. vec3 diffuseColor;
  4488. float specularStrength;
  4489. };
  4490. 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 ) {
  4491. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4492. vec3 irradiance = dotNL * directLight.color;
  4493. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4494. }
  4495. 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 ) {
  4496. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4497. }
  4498. #define RE_Direct RE_Direct_Lambert
  4499. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ZLe=`uniform bool receiveShadow;
  4500. uniform vec3 ambientLightColor;
  4501. #if defined( USE_LIGHT_PROBES )
  4502. uniform vec3 lightProbe[ 9 ];
  4503. #endif
  4504. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4505. float x = normal.x, y = normal.y, z = normal.z;
  4506. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4507. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4508. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4509. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4510. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4511. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4512. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4513. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4514. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4515. return result;
  4516. }
  4517. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4518. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4519. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4520. return irradiance;
  4521. }
  4522. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4523. vec3 irradiance = ambientLightColor;
  4524. return irradiance;
  4525. }
  4526. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4527. #if defined ( LEGACY_LIGHTS )
  4528. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4529. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4530. }
  4531. return 1.0;
  4532. #else
  4533. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4534. if ( cutoffDistance > 0.0 ) {
  4535. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4536. }
  4537. return distanceFalloff;
  4538. #endif
  4539. }
  4540. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4541. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4542. }
  4543. #if NUM_DIR_LIGHTS > 0
  4544. struct DirectionalLight {
  4545. vec3 direction;
  4546. vec3 color;
  4547. };
  4548. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4549. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4550. light.color = directionalLight.color;
  4551. light.direction = directionalLight.direction;
  4552. light.visible = true;
  4553. }
  4554. #endif
  4555. #if NUM_POINT_LIGHTS > 0
  4556. struct PointLight {
  4557. vec3 position;
  4558. vec3 color;
  4559. float distance;
  4560. float decay;
  4561. };
  4562. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4563. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4564. vec3 lVector = pointLight.position - geometryPosition;
  4565. light.direction = normalize( lVector );
  4566. float lightDistance = length( lVector );
  4567. light.color = pointLight.color;
  4568. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4569. light.visible = ( light.color != vec3( 0.0 ) );
  4570. }
  4571. #endif
  4572. #if NUM_SPOT_LIGHTS > 0
  4573. struct SpotLight {
  4574. vec3 position;
  4575. vec3 direction;
  4576. vec3 color;
  4577. float distance;
  4578. float decay;
  4579. float coneCos;
  4580. float penumbraCos;
  4581. };
  4582. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4583. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4584. vec3 lVector = spotLight.position - geometryPosition;
  4585. light.direction = normalize( lVector );
  4586. float angleCos = dot( light.direction, spotLight.direction );
  4587. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4588. if ( spotAttenuation > 0.0 ) {
  4589. float lightDistance = length( lVector );
  4590. light.color = spotLight.color * spotAttenuation;
  4591. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4592. light.visible = ( light.color != vec3( 0.0 ) );
  4593. } else {
  4594. light.color = vec3( 0.0 );
  4595. light.visible = false;
  4596. }
  4597. }
  4598. #endif
  4599. #if NUM_RECT_AREA_LIGHTS > 0
  4600. struct RectAreaLight {
  4601. vec3 color;
  4602. vec3 position;
  4603. vec3 halfWidth;
  4604. vec3 halfHeight;
  4605. };
  4606. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4607. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4608. #endif
  4609. #if NUM_HEMI_LIGHTS > 0
  4610. struct HemisphereLight {
  4611. vec3 direction;
  4612. vec3 skyColor;
  4613. vec3 groundColor;
  4614. };
  4615. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4616. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4617. float dotNL = dot( normal, hemiLight.direction );
  4618. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4619. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4620. return irradiance;
  4621. }
  4622. #endif`,QLe=`#ifdef USE_ENVMAP
  4623. vec3 getIBLIrradiance( const in vec3 normal ) {
  4624. #ifdef ENVMAP_TYPE_CUBE_UV
  4625. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4626. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4627. return PI * envMapColor.rgb * envMapIntensity;
  4628. #else
  4629. return vec3( 0.0 );
  4630. #endif
  4631. }
  4632. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4633. #ifdef ENVMAP_TYPE_CUBE_UV
  4634. vec3 reflectVec = reflect( - viewDir, normal );
  4635. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4636. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4637. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4638. return envMapColor.rgb * envMapIntensity;
  4639. #else
  4640. return vec3( 0.0 );
  4641. #endif
  4642. }
  4643. #ifdef USE_ANISOTROPY
  4644. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4645. #ifdef ENVMAP_TYPE_CUBE_UV
  4646. vec3 bentNormal = cross( bitangent, viewDir );
  4647. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4648. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4649. return getIBLRadiance( viewDir, bentNormal, roughness );
  4650. #else
  4651. return vec3( 0.0 );
  4652. #endif
  4653. }
  4654. #endif
  4655. #endif`,JLe=`ToonMaterial material;
  4656. material.diffuseColor = diffuseColor.rgb;`,e4e=`varying vec3 vViewPosition;
  4657. struct ToonMaterial {
  4658. vec3 diffuseColor;
  4659. };
  4660. 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 ) {
  4661. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4662. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4663. }
  4664. 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 ) {
  4665. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4666. }
  4667. #define RE_Direct RE_Direct_Toon
  4668. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,t4e=`BlinnPhongMaterial material;
  4669. material.diffuseColor = diffuseColor.rgb;
  4670. material.specularColor = specular;
  4671. material.specularShininess = shininess;
  4672. material.specularStrength = specularStrength;`,n4e=`varying vec3 vViewPosition;
  4673. struct BlinnPhongMaterial {
  4674. vec3 diffuseColor;
  4675. vec3 specularColor;
  4676. float specularShininess;
  4677. float specularStrength;
  4678. };
  4679. 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 ) {
  4680. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4681. vec3 irradiance = dotNL * directLight.color;
  4682. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4683. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4684. }
  4685. 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 ) {
  4686. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4687. }
  4688. #define RE_Direct RE_Direct_BlinnPhong
  4689. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,r4e=`PhysicalMaterial material;
  4690. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4691. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4692. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4693. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4694. material.roughness = min( material.roughness, 1.0 );
  4695. #ifdef IOR
  4696. material.ior = ior;
  4697. #ifdef USE_SPECULAR
  4698. float specularIntensityFactor = specularIntensity;
  4699. vec3 specularColorFactor = specularColor;
  4700. #ifdef USE_SPECULAR_COLORMAP
  4701. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4702. #endif
  4703. #ifdef USE_SPECULAR_INTENSITYMAP
  4704. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4705. #endif
  4706. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4707. #else
  4708. float specularIntensityFactor = 1.0;
  4709. vec3 specularColorFactor = vec3( 1.0 );
  4710. material.specularF90 = 1.0;
  4711. #endif
  4712. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4713. #else
  4714. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4715. material.specularF90 = 1.0;
  4716. #endif
  4717. #ifdef USE_CLEARCOAT
  4718. material.clearcoat = clearcoat;
  4719. material.clearcoatRoughness = clearcoatRoughness;
  4720. material.clearcoatF0 = vec3( 0.04 );
  4721. material.clearcoatF90 = 1.0;
  4722. #ifdef USE_CLEARCOATMAP
  4723. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4724. #endif
  4725. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4726. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4727. #endif
  4728. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4729. material.clearcoatRoughness += geometryRoughness;
  4730. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4731. #endif
  4732. #ifdef USE_IRIDESCENCE
  4733. material.iridescence = iridescence;
  4734. material.iridescenceIOR = iridescenceIOR;
  4735. #ifdef USE_IRIDESCENCEMAP
  4736. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4737. #endif
  4738. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4739. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4740. #else
  4741. material.iridescenceThickness = iridescenceThicknessMaximum;
  4742. #endif
  4743. #endif
  4744. #ifdef USE_SHEEN
  4745. material.sheenColor = sheenColor;
  4746. #ifdef USE_SHEEN_COLORMAP
  4747. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4748. #endif
  4749. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4750. #ifdef USE_SHEEN_ROUGHNESSMAP
  4751. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4752. #endif
  4753. #endif
  4754. #ifdef USE_ANISOTROPY
  4755. #ifdef USE_ANISOTROPYMAP
  4756. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4757. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4758. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4759. #else
  4760. vec2 anisotropyV = anisotropyVector;
  4761. #endif
  4762. material.anisotropy = length( anisotropyV );
  4763. if( material.anisotropy == 0.0 ) {
  4764. anisotropyV = vec2( 1.0, 0.0 );
  4765. } else {
  4766. anisotropyV /= material.anisotropy;
  4767. material.anisotropy = saturate( material.anisotropy );
  4768. }
  4769. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4770. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4771. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4772. #endif`,i4e=`struct PhysicalMaterial {
  4773. vec3 diffuseColor;
  4774. float roughness;
  4775. vec3 specularColor;
  4776. float specularF90;
  4777. #ifdef USE_CLEARCOAT
  4778. float clearcoat;
  4779. float clearcoatRoughness;
  4780. vec3 clearcoatF0;
  4781. float clearcoatF90;
  4782. #endif
  4783. #ifdef USE_IRIDESCENCE
  4784. float iridescence;
  4785. float iridescenceIOR;
  4786. float iridescenceThickness;
  4787. vec3 iridescenceFresnel;
  4788. vec3 iridescenceF0;
  4789. #endif
  4790. #ifdef USE_SHEEN
  4791. vec3 sheenColor;
  4792. float sheenRoughness;
  4793. #endif
  4794. #ifdef IOR
  4795. float ior;
  4796. #endif
  4797. #ifdef USE_TRANSMISSION
  4798. float transmission;
  4799. float transmissionAlpha;
  4800. float thickness;
  4801. float attenuationDistance;
  4802. vec3 attenuationColor;
  4803. #endif
  4804. #ifdef USE_ANISOTROPY
  4805. float anisotropy;
  4806. float alphaT;
  4807. vec3 anisotropyT;
  4808. vec3 anisotropyB;
  4809. #endif
  4810. };
  4811. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4812. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4813. vec3 sheenSpecularDirect = vec3( 0.0 );
  4814. vec3 sheenSpecularIndirect = vec3(0.0 );
  4815. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4816. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4817. float x2 = x * x;
  4818. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4819. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4820. }
  4821. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4822. float a2 = pow2( alpha );
  4823. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4824. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4825. return 0.5 / max( gv + gl, EPSILON );
  4826. }
  4827. float D_GGX( const in float alpha, const in float dotNH ) {
  4828. float a2 = pow2( alpha );
  4829. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4830. return RECIPROCAL_PI * a2 / pow2( denom );
  4831. }
  4832. #ifdef USE_ANISOTROPY
  4833. 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 ) {
  4834. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4835. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4836. float v = 0.5 / ( gv + gl );
  4837. return saturate(v);
  4838. }
  4839. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4840. float a2 = alphaT * alphaB;
  4841. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4842. highp float v2 = dot( v, v );
  4843. float w2 = a2 / v2;
  4844. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4845. }
  4846. #endif
  4847. #ifdef USE_CLEARCOAT
  4848. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4849. vec3 f0 = material.clearcoatF0;
  4850. float f90 = material.clearcoatF90;
  4851. float roughness = material.clearcoatRoughness;
  4852. float alpha = pow2( roughness );
  4853. vec3 halfDir = normalize( lightDir + viewDir );
  4854. float dotNL = saturate( dot( normal, lightDir ) );
  4855. float dotNV = saturate( dot( normal, viewDir ) );
  4856. float dotNH = saturate( dot( normal, halfDir ) );
  4857. float dotVH = saturate( dot( viewDir, halfDir ) );
  4858. vec3 F = F_Schlick( f0, f90, dotVH );
  4859. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4860. float D = D_GGX( alpha, dotNH );
  4861. return F * ( V * D );
  4862. }
  4863. #endif
  4864. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4865. vec3 f0 = material.specularColor;
  4866. float f90 = material.specularF90;
  4867. float roughness = material.roughness;
  4868. float alpha = pow2( roughness );
  4869. vec3 halfDir = normalize( lightDir + viewDir );
  4870. float dotNL = saturate( dot( normal, lightDir ) );
  4871. float dotNV = saturate( dot( normal, viewDir ) );
  4872. float dotNH = saturate( dot( normal, halfDir ) );
  4873. float dotVH = saturate( dot( viewDir, halfDir ) );
  4874. vec3 F = F_Schlick( f0, f90, dotVH );
  4875. #ifdef USE_IRIDESCENCE
  4876. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4877. #endif
  4878. #ifdef USE_ANISOTROPY
  4879. float dotTL = dot( material.anisotropyT, lightDir );
  4880. float dotTV = dot( material.anisotropyT, viewDir );
  4881. float dotTH = dot( material.anisotropyT, halfDir );
  4882. float dotBL = dot( material.anisotropyB, lightDir );
  4883. float dotBV = dot( material.anisotropyB, viewDir );
  4884. float dotBH = dot( material.anisotropyB, halfDir );
  4885. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4886. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4887. #else
  4888. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4889. float D = D_GGX( alpha, dotNH );
  4890. #endif
  4891. return F * ( V * D );
  4892. }
  4893. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4894. const float LUT_SIZE = 64.0;
  4895. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4896. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4897. float dotNV = saturate( dot( N, V ) );
  4898. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4899. uv = uv * LUT_SCALE + LUT_BIAS;
  4900. return uv;
  4901. }
  4902. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4903. float l = length( f );
  4904. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4905. }
  4906. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4907. float x = dot( v1, v2 );
  4908. float y = abs( x );
  4909. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4910. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4911. float v = a / b;
  4912. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4913. return cross( v1, v2 ) * theta_sintheta;
  4914. }
  4915. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4916. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4917. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4918. vec3 lightNormal = cross( v1, v2 );
  4919. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4920. vec3 T1, T2;
  4921. T1 = normalize( V - N * dot( V, N ) );
  4922. T2 = - cross( N, T1 );
  4923. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4924. vec3 coords[ 4 ];
  4925. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4926. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4927. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4928. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4929. coords[ 0 ] = normalize( coords[ 0 ] );
  4930. coords[ 1 ] = normalize( coords[ 1 ] );
  4931. coords[ 2 ] = normalize( coords[ 2 ] );
  4932. coords[ 3 ] = normalize( coords[ 3 ] );
  4933. vec3 vectorFormFactor = vec3( 0.0 );
  4934. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4935. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4936. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4937. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4938. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4939. return vec3( result );
  4940. }
  4941. #if defined( USE_SHEEN )
  4942. float D_Charlie( float roughness, float dotNH ) {
  4943. float alpha = pow2( roughness );
  4944. float invAlpha = 1.0 / alpha;
  4945. float cos2h = dotNH * dotNH;
  4946. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4947. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4948. }
  4949. float V_Neubelt( float dotNV, float dotNL ) {
  4950. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4951. }
  4952. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4953. vec3 halfDir = normalize( lightDir + viewDir );
  4954. float dotNL = saturate( dot( normal, lightDir ) );
  4955. float dotNV = saturate( dot( normal, viewDir ) );
  4956. float dotNH = saturate( dot( normal, halfDir ) );
  4957. float D = D_Charlie( sheenRoughness, dotNH );
  4958. float V = V_Neubelt( dotNV, dotNL );
  4959. return sheenColor * ( D * V );
  4960. }
  4961. #endif
  4962. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4963. float dotNV = saturate( dot( normal, viewDir ) );
  4964. float r2 = roughness * roughness;
  4965. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4966. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4967. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4968. return saturate( DG * RECIPROCAL_PI );
  4969. }
  4970. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4971. float dotNV = saturate( dot( normal, viewDir ) );
  4972. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4973. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4974. vec4 r = roughness * c0 + c1;
  4975. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4976. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4977. return fab;
  4978. }
  4979. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4980. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4981. return specularColor * fab.x + specularF90 * fab.y;
  4982. }
  4983. #ifdef USE_IRIDESCENCE
  4984. 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 ) {
  4985. #else
  4986. 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 ) {
  4987. #endif
  4988. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4989. #ifdef USE_IRIDESCENCE
  4990. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4991. #else
  4992. vec3 Fr = specularColor;
  4993. #endif
  4994. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4995. float Ess = fab.x + fab.y;
  4996. float Ems = 1.0 - Ess;
  4997. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4998. singleScatter += FssEss;
  4999. multiScatter += Fms * Ems;
  5000. }
  5001. #if NUM_RECT_AREA_LIGHTS > 0
  5002. 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 ) {
  5003. vec3 normal = geometryNormal;
  5004. vec3 viewDir = geometryViewDir;
  5005. vec3 position = geometryPosition;
  5006. vec3 lightPos = rectAreaLight.position;
  5007. vec3 halfWidth = rectAreaLight.halfWidth;
  5008. vec3 halfHeight = rectAreaLight.halfHeight;
  5009. vec3 lightColor = rectAreaLight.color;
  5010. float roughness = material.roughness;
  5011. vec3 rectCoords[ 4 ];
  5012. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5013. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5014. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5015. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5016. vec4 t1 = texture2D( ltc_1, uv );
  5017. vec4 t2 = texture2D( ltc_2, uv );
  5018. mat3 mInv = mat3(
  5019. vec3( t1.x, 0, t1.y ),
  5020. vec3( 0, 1, 0 ),
  5021. vec3( t1.z, 0, t1.w )
  5022. );
  5023. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5024. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5025. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5026. }
  5027. #endif
  5028. 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 ) {
  5029. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5030. vec3 irradiance = dotNL * directLight.color;
  5031. #ifdef USE_CLEARCOAT
  5032. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5033. vec3 ccIrradiance = dotNLcc * directLight.color;
  5034. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5035. #endif
  5036. #ifdef USE_SHEEN
  5037. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5038. #endif
  5039. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5040. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5041. }
  5042. 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 ) {
  5043. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5044. }
  5045. 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) {
  5046. #ifdef USE_CLEARCOAT
  5047. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5048. #endif
  5049. #ifdef USE_SHEEN
  5050. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5051. #endif
  5052. vec3 singleScattering = vec3( 0.0 );
  5053. vec3 multiScattering = vec3( 0.0 );
  5054. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5055. #ifdef USE_IRIDESCENCE
  5056. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5057. #else
  5058. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5059. #endif
  5060. vec3 totalScattering = singleScattering + multiScattering;
  5061. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5062. reflectedLight.indirectSpecular += radiance * singleScattering;
  5063. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5064. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5065. }
  5066. #define RE_Direct RE_Direct_Physical
  5067. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5068. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5069. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5070. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5071. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5072. }`,a4e=`
  5073. vec3 geometryPosition = - vViewPosition;
  5074. vec3 geometryNormal = normal;
  5075. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5076. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5077. #ifdef USE_CLEARCOAT
  5078. geometryClearcoatNormal = clearcoatNormal;
  5079. #endif
  5080. #ifdef USE_IRIDESCENCE
  5081. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5082. if ( material.iridescenceThickness == 0.0 ) {
  5083. material.iridescence = 0.0;
  5084. } else {
  5085. material.iridescence = saturate( material.iridescence );
  5086. }
  5087. if ( material.iridescence > 0.0 ) {
  5088. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5089. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5090. }
  5091. #endif
  5092. IncidentLight directLight;
  5093. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5094. PointLight pointLight;
  5095. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5096. PointLightShadow pointLightShadow;
  5097. #endif
  5098. #pragma unroll_loop_start
  5099. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5100. pointLight = pointLights[ i ];
  5101. getPointLightInfo( pointLight, geometryPosition, directLight );
  5102. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5103. pointLightShadow = pointLightShadows[ i ];
  5104. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5105. #endif
  5106. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5107. }
  5108. #pragma unroll_loop_end
  5109. #endif
  5110. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5111. SpotLight spotLight;
  5112. vec4 spotColor;
  5113. vec3 spotLightCoord;
  5114. bool inSpotLightMap;
  5115. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5116. SpotLightShadow spotLightShadow;
  5117. #endif
  5118. #pragma unroll_loop_start
  5119. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5120. spotLight = spotLights[ i ];
  5121. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5122. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5123. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5124. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5125. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5126. #else
  5127. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5128. #endif
  5129. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5130. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5131. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5132. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5133. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5134. #endif
  5135. #undef SPOT_LIGHT_MAP_INDEX
  5136. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5137. spotLightShadow = spotLightShadows[ i ];
  5138. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5139. #endif
  5140. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5141. }
  5142. #pragma unroll_loop_end
  5143. #endif
  5144. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5145. DirectionalLight directionalLight;
  5146. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5147. DirectionalLightShadow directionalLightShadow;
  5148. #endif
  5149. #pragma unroll_loop_start
  5150. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5151. directionalLight = directionalLights[ i ];
  5152. getDirectionalLightInfo( directionalLight, directLight );
  5153. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5154. directionalLightShadow = directionalLightShadows[ i ];
  5155. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5156. #endif
  5157. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5158. }
  5159. #pragma unroll_loop_end
  5160. #endif
  5161. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5162. RectAreaLight rectAreaLight;
  5163. #pragma unroll_loop_start
  5164. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5165. rectAreaLight = rectAreaLights[ i ];
  5166. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5167. }
  5168. #pragma unroll_loop_end
  5169. #endif
  5170. #if defined( RE_IndirectDiffuse )
  5171. vec3 iblIrradiance = vec3( 0.0 );
  5172. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5173. #if defined( USE_LIGHT_PROBES )
  5174. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5175. #endif
  5176. #if ( NUM_HEMI_LIGHTS > 0 )
  5177. #pragma unroll_loop_start
  5178. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5179. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5180. }
  5181. #pragma unroll_loop_end
  5182. #endif
  5183. #endif
  5184. #if defined( RE_IndirectSpecular )
  5185. vec3 radiance = vec3( 0.0 );
  5186. vec3 clearcoatRadiance = vec3( 0.0 );
  5187. #endif`,s4e=`#if defined( RE_IndirectDiffuse )
  5188. #ifdef USE_LIGHTMAP
  5189. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5190. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5191. irradiance += lightMapIrradiance;
  5192. #endif
  5193. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5194. iblIrradiance += getIBLIrradiance( geometryNormal );
  5195. #endif
  5196. #endif
  5197. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5198. #ifdef USE_ANISOTROPY
  5199. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5200. #else
  5201. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5202. #endif
  5203. #ifdef USE_CLEARCOAT
  5204. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5205. #endif
  5206. #endif`,o4e=`#if defined( RE_IndirectDiffuse )
  5207. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5208. #endif
  5209. #if defined( RE_IndirectSpecular )
  5210. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5211. #endif`,l4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5212. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5213. #endif`,c4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5214. uniform float logDepthBufFC;
  5215. varying float vFragDepth;
  5216. varying float vIsPerspective;
  5217. #endif`,u4e=`#ifdef USE_LOGDEPTHBUF
  5218. #ifdef USE_LOGDEPTHBUF_EXT
  5219. varying float vFragDepth;
  5220. varying float vIsPerspective;
  5221. #else
  5222. uniform float logDepthBufFC;
  5223. #endif
  5224. #endif`,d4e=`#ifdef USE_LOGDEPTHBUF
  5225. #ifdef USE_LOGDEPTHBUF_EXT
  5226. vFragDepth = 1.0 + gl_Position.w;
  5227. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5228. #else
  5229. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5230. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5231. gl_Position.z *= gl_Position.w;
  5232. }
  5233. #endif
  5234. #endif`,h4e=`#ifdef USE_MAP
  5235. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5236. #ifdef DECODE_VIDEO_TEXTURE
  5237. 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 );
  5238. #endif
  5239. diffuseColor *= sampledDiffuseColor;
  5240. #endif`,f4e=`#ifdef USE_MAP
  5241. uniform sampler2D map;
  5242. #endif`,m4e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5243. #if defined( USE_POINTS_UV )
  5244. vec2 uv = vUv;
  5245. #else
  5246. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5247. #endif
  5248. #endif
  5249. #ifdef USE_MAP
  5250. diffuseColor *= texture2D( map, uv );
  5251. #endif
  5252. #ifdef USE_ALPHAMAP
  5253. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5254. #endif`,p4e=`#if defined( USE_POINTS_UV )
  5255. varying vec2 vUv;
  5256. #else
  5257. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5258. uniform mat3 uvTransform;
  5259. #endif
  5260. #endif
  5261. #ifdef USE_MAP
  5262. uniform sampler2D map;
  5263. #endif
  5264. #ifdef USE_ALPHAMAP
  5265. uniform sampler2D alphaMap;
  5266. #endif`,g4e=`float metalnessFactor = metalness;
  5267. #ifdef USE_METALNESSMAP
  5268. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5269. metalnessFactor *= texelMetalness.b;
  5270. #endif`,x4e=`#ifdef USE_METALNESSMAP
  5271. uniform sampler2D metalnessMap;
  5272. #endif`,b4e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5273. vColor *= morphTargetBaseInfluence;
  5274. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5275. #if defined( USE_COLOR_ALPHA )
  5276. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5277. #elif defined( USE_COLOR )
  5278. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5279. #endif
  5280. }
  5281. #endif`,y4e=`#ifdef USE_MORPHNORMALS
  5282. objectNormal *= morphTargetBaseInfluence;
  5283. #ifdef MORPHTARGETS_TEXTURE
  5284. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5285. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5286. }
  5287. #else
  5288. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5289. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5290. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5291. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5292. #endif
  5293. #endif`,v4e=`#ifdef USE_MORPHTARGETS
  5294. uniform float morphTargetBaseInfluence;
  5295. #ifdef MORPHTARGETS_TEXTURE
  5296. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5297. uniform sampler2DArray morphTargetsTexture;
  5298. uniform ivec2 morphTargetsTextureSize;
  5299. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5300. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5301. int y = texelIndex / morphTargetsTextureSize.x;
  5302. int x = texelIndex - y * morphTargetsTextureSize.x;
  5303. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5304. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5305. }
  5306. #else
  5307. #ifndef USE_MORPHNORMALS
  5308. uniform float morphTargetInfluences[ 8 ];
  5309. #else
  5310. uniform float morphTargetInfluences[ 4 ];
  5311. #endif
  5312. #endif
  5313. #endif`,_4e=`#ifdef USE_MORPHTARGETS
  5314. transformed *= morphTargetBaseInfluence;
  5315. #ifdef MORPHTARGETS_TEXTURE
  5316. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5317. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5318. }
  5319. #else
  5320. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5321. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5322. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5323. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5324. #ifndef USE_MORPHNORMALS
  5325. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5326. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5327. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5328. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5329. #endif
  5330. #endif
  5331. #endif`,w4e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5332. #ifdef FLAT_SHADED
  5333. vec3 fdx = dFdx( vViewPosition );
  5334. vec3 fdy = dFdy( vViewPosition );
  5335. vec3 normal = normalize( cross( fdx, fdy ) );
  5336. #else
  5337. vec3 normal = normalize( vNormal );
  5338. #ifdef DOUBLE_SIDED
  5339. normal *= faceDirection;
  5340. #endif
  5341. #endif
  5342. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5343. #ifdef USE_TANGENT
  5344. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5345. #else
  5346. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5347. #if defined( USE_NORMALMAP )
  5348. vNormalMapUv
  5349. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5350. vClearcoatNormalMapUv
  5351. #else
  5352. vUv
  5353. #endif
  5354. );
  5355. #endif
  5356. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5357. tbn[0] *= faceDirection;
  5358. tbn[1] *= faceDirection;
  5359. #endif
  5360. #endif
  5361. #ifdef USE_CLEARCOAT_NORMALMAP
  5362. #ifdef USE_TANGENT
  5363. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5364. #else
  5365. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5366. #endif
  5367. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5368. tbn2[0] *= faceDirection;
  5369. tbn2[1] *= faceDirection;
  5370. #endif
  5371. #endif
  5372. vec3 nonPerturbedNormal = normal;`,S4e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5373. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5374. #ifdef FLIP_SIDED
  5375. normal = - normal;
  5376. #endif
  5377. #ifdef DOUBLE_SIDED
  5378. normal = normal * faceDirection;
  5379. #endif
  5380. normal = normalize( normalMatrix * normal );
  5381. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5382. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5383. mapN.xy *= normalScale;
  5384. normal = normalize( tbn * mapN );
  5385. #elif defined( USE_BUMPMAP )
  5386. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5387. #endif`,M4e=`#ifndef FLAT_SHADED
  5388. varying vec3 vNormal;
  5389. #ifdef USE_TANGENT
  5390. varying vec3 vTangent;
  5391. varying vec3 vBitangent;
  5392. #endif
  5393. #endif`,E4e=`#ifndef FLAT_SHADED
  5394. varying vec3 vNormal;
  5395. #ifdef USE_TANGENT
  5396. varying vec3 vTangent;
  5397. varying vec3 vBitangent;
  5398. #endif
  5399. #endif`,A4e=`#ifndef FLAT_SHADED
  5400. vNormal = normalize( transformedNormal );
  5401. #ifdef USE_TANGENT
  5402. vTangent = normalize( transformedTangent );
  5403. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5404. #endif
  5405. #endif`,T4e=`#ifdef USE_NORMALMAP
  5406. uniform sampler2D normalMap;
  5407. uniform vec2 normalScale;
  5408. #endif
  5409. #ifdef USE_NORMALMAP_OBJECTSPACE
  5410. uniform mat3 normalMatrix;
  5411. #endif
  5412. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5413. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5414. vec3 q0 = dFdx( eye_pos.xyz );
  5415. vec3 q1 = dFdy( eye_pos.xyz );
  5416. vec2 st0 = dFdx( uv.st );
  5417. vec2 st1 = dFdy( uv.st );
  5418. vec3 N = surf_norm;
  5419. vec3 q1perp = cross( q1, N );
  5420. vec3 q0perp = cross( N, q0 );
  5421. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5422. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5423. float det = max( dot( T, T ), dot( B, B ) );
  5424. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5425. return mat3( T * scale, B * scale, N );
  5426. }
  5427. #endif`,C4e=`#ifdef USE_CLEARCOAT
  5428. vec3 clearcoatNormal = nonPerturbedNormal;
  5429. #endif`,N4e=`#ifdef USE_CLEARCOAT_NORMALMAP
  5430. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5431. clearcoatMapN.xy *= clearcoatNormalScale;
  5432. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5433. #endif`,k4e=`#ifdef USE_CLEARCOATMAP
  5434. uniform sampler2D clearcoatMap;
  5435. #endif
  5436. #ifdef USE_CLEARCOAT_NORMALMAP
  5437. uniform sampler2D clearcoatNormalMap;
  5438. uniform vec2 clearcoatNormalScale;
  5439. #endif
  5440. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5441. uniform sampler2D clearcoatRoughnessMap;
  5442. #endif`,P4e=`#ifdef USE_IRIDESCENCEMAP
  5443. uniform sampler2D iridescenceMap;
  5444. #endif
  5445. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5446. uniform sampler2D iridescenceThicknessMap;
  5447. #endif`,R4e=`#ifdef OPAQUE
  5448. diffuseColor.a = 1.0;
  5449. #endif
  5450. #ifdef USE_TRANSMISSION
  5451. diffuseColor.a *= material.transmissionAlpha;
  5452. #endif
  5453. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,j4e=`vec3 packNormalToRGB( const in vec3 normal ) {
  5454. return normalize( normal ) * 0.5 + 0.5;
  5455. }
  5456. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5457. return 2.0 * rgb.xyz - 1.0;
  5458. }
  5459. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5460. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5461. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5462. const float ShiftRight8 = 1. / 256.;
  5463. vec4 packDepthToRGBA( const in float v ) {
  5464. vec4 r = vec4( fract( v * PackFactors ), v );
  5465. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5466. }
  5467. float unpackRGBAToDepth( const in vec4 v ) {
  5468. return dot( v, UnpackFactors );
  5469. }
  5470. vec2 packDepthToRG( in highp float v ) {
  5471. return packDepthToRGBA( v ).yx;
  5472. }
  5473. float unpackRGToDepth( const in highp vec2 v ) {
  5474. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5475. }
  5476. vec4 pack2HalfToRGBA( vec2 v ) {
  5477. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5478. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5479. }
  5480. vec2 unpackRGBATo2Half( vec4 v ) {
  5481. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5482. }
  5483. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5484. return ( viewZ + near ) / ( near - far );
  5485. }
  5486. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5487. return depth * ( near - far ) - near;
  5488. }
  5489. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5490. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5491. }
  5492. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5493. return ( near * far ) / ( ( far - near ) * depth - far );
  5494. }`,D4e=`#ifdef PREMULTIPLIED_ALPHA
  5495. gl_FragColor.rgb *= gl_FragColor.a;
  5496. #endif`,O4e=`vec4 mvPosition = vec4( transformed, 1.0 );
  5497. #ifdef USE_BATCHING
  5498. mvPosition = batchingMatrix * mvPosition;
  5499. #endif
  5500. #ifdef USE_INSTANCING
  5501. mvPosition = instanceMatrix * mvPosition;
  5502. #endif
  5503. mvPosition = modelViewMatrix * mvPosition;
  5504. gl_Position = projectionMatrix * mvPosition;`,L4e=`#ifdef DITHERING
  5505. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5506. #endif`,I4e=`#ifdef DITHERING
  5507. vec3 dithering( vec3 color ) {
  5508. float grid_position = rand( gl_FragCoord.xy );
  5509. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5510. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5511. return color + dither_shift_RGB;
  5512. }
  5513. #endif`,F4e=`float roughnessFactor = roughness;
  5514. #ifdef USE_ROUGHNESSMAP
  5515. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5516. roughnessFactor *= texelRoughness.g;
  5517. #endif`,U4e=`#ifdef USE_ROUGHNESSMAP
  5518. uniform sampler2D roughnessMap;
  5519. #endif`,z4e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5520. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5521. #endif
  5522. #if NUM_SPOT_LIGHT_MAPS > 0
  5523. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5524. #endif
  5525. #ifdef USE_SHADOWMAP
  5526. #if NUM_DIR_LIGHT_SHADOWS > 0
  5527. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5528. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5529. struct DirectionalLightShadow {
  5530. float shadowBias;
  5531. float shadowNormalBias;
  5532. float shadowRadius;
  5533. vec2 shadowMapSize;
  5534. };
  5535. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5536. #endif
  5537. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5538. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5539. struct SpotLightShadow {
  5540. float shadowBias;
  5541. float shadowNormalBias;
  5542. float shadowRadius;
  5543. vec2 shadowMapSize;
  5544. };
  5545. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5546. #endif
  5547. #if NUM_POINT_LIGHT_SHADOWS > 0
  5548. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5549. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5550. struct PointLightShadow {
  5551. float shadowBias;
  5552. float shadowNormalBias;
  5553. float shadowRadius;
  5554. vec2 shadowMapSize;
  5555. float shadowCameraNear;
  5556. float shadowCameraFar;
  5557. };
  5558. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5559. #endif
  5560. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5561. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5562. }
  5563. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5564. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5565. }
  5566. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5567. float occlusion = 1.0;
  5568. vec2 distribution = texture2DDistribution( shadow, uv );
  5569. float hard_shadow = step( compare , distribution.x );
  5570. if (hard_shadow != 1.0 ) {
  5571. float distance = compare - distribution.x ;
  5572. float variance = max( 0.00000, distribution.y * distribution.y );
  5573. 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 );
  5574. }
  5575. return occlusion;
  5576. }
  5577. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5578. float shadow = 1.0;
  5579. shadowCoord.xyz /= shadowCoord.w;
  5580. shadowCoord.z += shadowBias;
  5581. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5582. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5583. if ( frustumTest ) {
  5584. #if defined( SHADOWMAP_TYPE_PCF )
  5585. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5586. float dx0 = - texelSize.x * shadowRadius;
  5587. float dy0 = - texelSize.y * shadowRadius;
  5588. float dx1 = + texelSize.x * shadowRadius;
  5589. float dy1 = + texelSize.y * shadowRadius;
  5590. float dx2 = dx0 / 2.0;
  5591. float dy2 = dy0 / 2.0;
  5592. float dx3 = dx1 / 2.0;
  5593. float dy3 = dy1 / 2.0;
  5594. shadow = (
  5595. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5596. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5597. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5598. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5599. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5600. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5601. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5602. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5603. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5604. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5605. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5606. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5607. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5608. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5609. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5610. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5611. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5612. ) * ( 1.0 / 17.0 );
  5613. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5614. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5615. float dx = texelSize.x;
  5616. float dy = texelSize.y;
  5617. vec2 uv = shadowCoord.xy;
  5618. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5619. uv -= f * texelSize;
  5620. shadow = (
  5621. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5622. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5623. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5624. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5625. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5626. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5627. f.x ) +
  5628. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5629. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5630. f.x ) +
  5631. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5632. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5633. f.y ) +
  5634. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5635. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5636. f.y ) +
  5637. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5638. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5639. f.x ),
  5640. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5641. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5642. f.x ),
  5643. f.y )
  5644. ) * ( 1.0 / 9.0 );
  5645. #elif defined( SHADOWMAP_TYPE_VSM )
  5646. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5647. #else
  5648. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5649. #endif
  5650. }
  5651. return shadow;
  5652. }
  5653. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5654. vec3 absV = abs( v );
  5655. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5656. absV *= scaleToCube;
  5657. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5658. vec2 planar = v.xy;
  5659. float almostATexel = 1.5 * texelSizeY;
  5660. float almostOne = 1.0 - almostATexel;
  5661. if ( absV.z >= almostOne ) {
  5662. if ( v.z > 0.0 )
  5663. planar.x = 4.0 - v.x;
  5664. } else if ( absV.x >= almostOne ) {
  5665. float signX = sign( v.x );
  5666. planar.x = v.z * signX + 2.0 * signX;
  5667. } else if ( absV.y >= almostOne ) {
  5668. float signY = sign( v.y );
  5669. planar.x = v.x + 2.0 * signY + 2.0;
  5670. planar.y = v.z * signY - 2.0;
  5671. }
  5672. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5673. }
  5674. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5675. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5676. vec3 lightToPosition = shadowCoord.xyz;
  5677. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5678. vec3 bd3D = normalize( lightToPosition );
  5679. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5680. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5681. return (
  5682. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5683. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5684. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5685. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5686. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5687. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5688. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5689. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5690. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5691. ) * ( 1.0 / 9.0 );
  5692. #else
  5693. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5694. #endif
  5695. }
  5696. #endif`,B4e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5697. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5698. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5699. #endif
  5700. #ifdef USE_SHADOWMAP
  5701. #if NUM_DIR_LIGHT_SHADOWS > 0
  5702. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5703. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5704. struct DirectionalLightShadow {
  5705. float shadowBias;
  5706. float shadowNormalBias;
  5707. float shadowRadius;
  5708. vec2 shadowMapSize;
  5709. };
  5710. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5711. #endif
  5712. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5713. struct SpotLightShadow {
  5714. float shadowBias;
  5715. float shadowNormalBias;
  5716. float shadowRadius;
  5717. vec2 shadowMapSize;
  5718. };
  5719. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5720. #endif
  5721. #if NUM_POINT_LIGHT_SHADOWS > 0
  5722. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5723. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5724. struct PointLightShadow {
  5725. float shadowBias;
  5726. float shadowNormalBias;
  5727. float shadowRadius;
  5728. vec2 shadowMapSize;
  5729. float shadowCameraNear;
  5730. float shadowCameraFar;
  5731. };
  5732. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5733. #endif
  5734. #endif`,H4e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5735. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5736. vec4 shadowWorldPosition;
  5737. #endif
  5738. #if defined( USE_SHADOWMAP )
  5739. #if NUM_DIR_LIGHT_SHADOWS > 0
  5740. #pragma unroll_loop_start
  5741. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5742. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5743. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5744. }
  5745. #pragma unroll_loop_end
  5746. #endif
  5747. #if NUM_POINT_LIGHT_SHADOWS > 0
  5748. #pragma unroll_loop_start
  5749. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5750. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5751. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5752. }
  5753. #pragma unroll_loop_end
  5754. #endif
  5755. #endif
  5756. #if NUM_SPOT_LIGHT_COORDS > 0
  5757. #pragma unroll_loop_start
  5758. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5759. shadowWorldPosition = worldPosition;
  5760. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5761. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5762. #endif
  5763. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5764. }
  5765. #pragma unroll_loop_end
  5766. #endif`,$4e=`float getShadowMask() {
  5767. float shadow = 1.0;
  5768. #ifdef USE_SHADOWMAP
  5769. #if NUM_DIR_LIGHT_SHADOWS > 0
  5770. DirectionalLightShadow directionalLight;
  5771. #pragma unroll_loop_start
  5772. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5773. directionalLight = directionalLightShadows[ i ];
  5774. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5775. }
  5776. #pragma unroll_loop_end
  5777. #endif
  5778. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5779. SpotLightShadow spotLight;
  5780. #pragma unroll_loop_start
  5781. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5782. spotLight = spotLightShadows[ i ];
  5783. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5784. }
  5785. #pragma unroll_loop_end
  5786. #endif
  5787. #if NUM_POINT_LIGHT_SHADOWS > 0
  5788. PointLightShadow pointLight;
  5789. #pragma unroll_loop_start
  5790. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5791. pointLight = pointLightShadows[ i ];
  5792. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5793. }
  5794. #pragma unroll_loop_end
  5795. #endif
  5796. #endif
  5797. return shadow;
  5798. }`,V4e=`#ifdef USE_SKINNING
  5799. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5800. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5801. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5802. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5803. #endif`,G4e=`#ifdef USE_SKINNING
  5804. uniform mat4 bindMatrix;
  5805. uniform mat4 bindMatrixInverse;
  5806. uniform highp sampler2D boneTexture;
  5807. mat4 getBoneMatrix( const in float i ) {
  5808. int size = textureSize( boneTexture, 0 ).x;
  5809. int j = int( i ) * 4;
  5810. int x = j % size;
  5811. int y = j / size;
  5812. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5813. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5814. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5815. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5816. return mat4( v1, v2, v3, v4 );
  5817. }
  5818. #endif`,W4e=`#ifdef USE_SKINNING
  5819. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5820. vec4 skinned = vec4( 0.0 );
  5821. skinned += boneMatX * skinVertex * skinWeight.x;
  5822. skinned += boneMatY * skinVertex * skinWeight.y;
  5823. skinned += boneMatZ * skinVertex * skinWeight.z;
  5824. skinned += boneMatW * skinVertex * skinWeight.w;
  5825. transformed = ( bindMatrixInverse * skinned ).xyz;
  5826. #endif`,q4e=`#ifdef USE_SKINNING
  5827. mat4 skinMatrix = mat4( 0.0 );
  5828. skinMatrix += skinWeight.x * boneMatX;
  5829. skinMatrix += skinWeight.y * boneMatY;
  5830. skinMatrix += skinWeight.z * boneMatZ;
  5831. skinMatrix += skinWeight.w * boneMatW;
  5832. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5833. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5834. #ifdef USE_TANGENT
  5835. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5836. #endif
  5837. #endif`,K4e=`float specularStrength;
  5838. #ifdef USE_SPECULARMAP
  5839. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5840. specularStrength = texelSpecular.r;
  5841. #else
  5842. specularStrength = 1.0;
  5843. #endif`,X4e=`#ifdef USE_SPECULARMAP
  5844. uniform sampler2D specularMap;
  5845. #endif`,Y4e=`#if defined( TONE_MAPPING )
  5846. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5847. #endif`,Z4e=`#ifndef saturate
  5848. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5849. #endif
  5850. uniform float toneMappingExposure;
  5851. vec3 LinearToneMapping( vec3 color ) {
  5852. return saturate( toneMappingExposure * color );
  5853. }
  5854. vec3 ReinhardToneMapping( vec3 color ) {
  5855. color *= toneMappingExposure;
  5856. return saturate( color / ( vec3( 1.0 ) + color ) );
  5857. }
  5858. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5859. color *= toneMappingExposure;
  5860. color = max( vec3( 0.0 ), color - 0.004 );
  5861. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5862. }
  5863. vec3 RRTAndODTFit( vec3 v ) {
  5864. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5865. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5866. return a / b;
  5867. }
  5868. vec3 ACESFilmicToneMapping( vec3 color ) {
  5869. const mat3 ACESInputMat = mat3(
  5870. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5871. vec3( 0.04823, 0.01566, 0.83777 )
  5872. );
  5873. const mat3 ACESOutputMat = mat3(
  5874. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5875. vec3( -0.07367, -0.00605, 1.07602 )
  5876. );
  5877. color *= toneMappingExposure / 0.6;
  5878. color = ACESInputMat * color;
  5879. color = RRTAndODTFit( color );
  5880. color = ACESOutputMat * color;
  5881. return saturate( color );
  5882. }
  5883. vec3 CustomToneMapping( vec3 color ) { return color; }`,Q4e=`#ifdef USE_TRANSMISSION
  5884. material.transmission = transmission;
  5885. material.transmissionAlpha = 1.0;
  5886. material.thickness = thickness;
  5887. material.attenuationDistance = attenuationDistance;
  5888. material.attenuationColor = attenuationColor;
  5889. #ifdef USE_TRANSMISSIONMAP
  5890. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5891. #endif
  5892. #ifdef USE_THICKNESSMAP
  5893. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5894. #endif
  5895. vec3 pos = vWorldPosition;
  5896. vec3 v = normalize( cameraPosition - pos );
  5897. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5898. vec4 transmitted = getIBLVolumeRefraction(
  5899. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5900. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5901. material.attenuationColor, material.attenuationDistance );
  5902. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5903. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5904. #endif`,J4e=`#ifdef USE_TRANSMISSION
  5905. uniform float transmission;
  5906. uniform float thickness;
  5907. uniform float attenuationDistance;
  5908. uniform vec3 attenuationColor;
  5909. #ifdef USE_TRANSMISSIONMAP
  5910. uniform sampler2D transmissionMap;
  5911. #endif
  5912. #ifdef USE_THICKNESSMAP
  5913. uniform sampler2D thicknessMap;
  5914. #endif
  5915. uniform vec2 transmissionSamplerSize;
  5916. uniform sampler2D transmissionSamplerMap;
  5917. uniform mat4 modelMatrix;
  5918. uniform mat4 projectionMatrix;
  5919. varying vec3 vWorldPosition;
  5920. float w0( float a ) {
  5921. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5922. }
  5923. float w1( float a ) {
  5924. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5925. }
  5926. float w2( float a ){
  5927. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5928. }
  5929. float w3( float a ) {
  5930. return ( 1.0 / 6.0 ) * ( a * a * a );
  5931. }
  5932. float g0( float a ) {
  5933. return w0( a ) + w1( a );
  5934. }
  5935. float g1( float a ) {
  5936. return w2( a ) + w3( a );
  5937. }
  5938. float h0( float a ) {
  5939. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5940. }
  5941. float h1( float a ) {
  5942. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5943. }
  5944. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5945. uv = uv * texelSize.zw + 0.5;
  5946. vec2 iuv = floor( uv );
  5947. vec2 fuv = fract( uv );
  5948. float g0x = g0( fuv.x );
  5949. float g1x = g1( fuv.x );
  5950. float h0x = h0( fuv.x );
  5951. float h1x = h1( fuv.x );
  5952. float h0y = h0( fuv.y );
  5953. float h1y = h1( fuv.y );
  5954. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5955. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5956. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5957. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5958. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5959. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5960. }
  5961. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5962. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5963. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5964. vec2 fLodSizeInv = 1.0 / fLodSize;
  5965. vec2 cLodSizeInv = 1.0 / cLodSize;
  5966. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5967. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5968. return mix( fSample, cSample, fract( lod ) );
  5969. }
  5970. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5971. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5972. vec3 modelScale;
  5973. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5974. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5975. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5976. return normalize( refractionVector ) * thickness * modelScale;
  5977. }
  5978. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5979. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5980. }
  5981. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5982. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5983. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5984. }
  5985. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5986. if ( isinf( attenuationDistance ) ) {
  5987. return vec3( 1.0 );
  5988. } else {
  5989. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5990. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5991. }
  5992. }
  5993. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5994. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5995. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5996. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5997. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5998. vec3 refractedRayExit = position + transmissionRay;
  5999. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6000. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6001. refractionCoords += 1.0;
  6002. refractionCoords /= 2.0;
  6003. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6004. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6005. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6006. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6007. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6008. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6009. }
  6010. #endif`,eIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6011. varying vec2 vUv;
  6012. #endif
  6013. #ifdef USE_MAP
  6014. varying vec2 vMapUv;
  6015. #endif
  6016. #ifdef USE_ALPHAMAP
  6017. varying vec2 vAlphaMapUv;
  6018. #endif
  6019. #ifdef USE_LIGHTMAP
  6020. varying vec2 vLightMapUv;
  6021. #endif
  6022. #ifdef USE_AOMAP
  6023. varying vec2 vAoMapUv;
  6024. #endif
  6025. #ifdef USE_BUMPMAP
  6026. varying vec2 vBumpMapUv;
  6027. #endif
  6028. #ifdef USE_NORMALMAP
  6029. varying vec2 vNormalMapUv;
  6030. #endif
  6031. #ifdef USE_EMISSIVEMAP
  6032. varying vec2 vEmissiveMapUv;
  6033. #endif
  6034. #ifdef USE_METALNESSMAP
  6035. varying vec2 vMetalnessMapUv;
  6036. #endif
  6037. #ifdef USE_ROUGHNESSMAP
  6038. varying vec2 vRoughnessMapUv;
  6039. #endif
  6040. #ifdef USE_ANISOTROPYMAP
  6041. varying vec2 vAnisotropyMapUv;
  6042. #endif
  6043. #ifdef USE_CLEARCOATMAP
  6044. varying vec2 vClearcoatMapUv;
  6045. #endif
  6046. #ifdef USE_CLEARCOAT_NORMALMAP
  6047. varying vec2 vClearcoatNormalMapUv;
  6048. #endif
  6049. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6050. varying vec2 vClearcoatRoughnessMapUv;
  6051. #endif
  6052. #ifdef USE_IRIDESCENCEMAP
  6053. varying vec2 vIridescenceMapUv;
  6054. #endif
  6055. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6056. varying vec2 vIridescenceThicknessMapUv;
  6057. #endif
  6058. #ifdef USE_SHEEN_COLORMAP
  6059. varying vec2 vSheenColorMapUv;
  6060. #endif
  6061. #ifdef USE_SHEEN_ROUGHNESSMAP
  6062. varying vec2 vSheenRoughnessMapUv;
  6063. #endif
  6064. #ifdef USE_SPECULARMAP
  6065. varying vec2 vSpecularMapUv;
  6066. #endif
  6067. #ifdef USE_SPECULAR_COLORMAP
  6068. varying vec2 vSpecularColorMapUv;
  6069. #endif
  6070. #ifdef USE_SPECULAR_INTENSITYMAP
  6071. varying vec2 vSpecularIntensityMapUv;
  6072. #endif
  6073. #ifdef USE_TRANSMISSIONMAP
  6074. uniform mat3 transmissionMapTransform;
  6075. varying vec2 vTransmissionMapUv;
  6076. #endif
  6077. #ifdef USE_THICKNESSMAP
  6078. uniform mat3 thicknessMapTransform;
  6079. varying vec2 vThicknessMapUv;
  6080. #endif`,tIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6081. varying vec2 vUv;
  6082. #endif
  6083. #ifdef USE_MAP
  6084. uniform mat3 mapTransform;
  6085. varying vec2 vMapUv;
  6086. #endif
  6087. #ifdef USE_ALPHAMAP
  6088. uniform mat3 alphaMapTransform;
  6089. varying vec2 vAlphaMapUv;
  6090. #endif
  6091. #ifdef USE_LIGHTMAP
  6092. uniform mat3 lightMapTransform;
  6093. varying vec2 vLightMapUv;
  6094. #endif
  6095. #ifdef USE_AOMAP
  6096. uniform mat3 aoMapTransform;
  6097. varying vec2 vAoMapUv;
  6098. #endif
  6099. #ifdef USE_BUMPMAP
  6100. uniform mat3 bumpMapTransform;
  6101. varying vec2 vBumpMapUv;
  6102. #endif
  6103. #ifdef USE_NORMALMAP
  6104. uniform mat3 normalMapTransform;
  6105. varying vec2 vNormalMapUv;
  6106. #endif
  6107. #ifdef USE_DISPLACEMENTMAP
  6108. uniform mat3 displacementMapTransform;
  6109. varying vec2 vDisplacementMapUv;
  6110. #endif
  6111. #ifdef USE_EMISSIVEMAP
  6112. uniform mat3 emissiveMapTransform;
  6113. varying vec2 vEmissiveMapUv;
  6114. #endif
  6115. #ifdef USE_METALNESSMAP
  6116. uniform mat3 metalnessMapTransform;
  6117. varying vec2 vMetalnessMapUv;
  6118. #endif
  6119. #ifdef USE_ROUGHNESSMAP
  6120. uniform mat3 roughnessMapTransform;
  6121. varying vec2 vRoughnessMapUv;
  6122. #endif
  6123. #ifdef USE_ANISOTROPYMAP
  6124. uniform mat3 anisotropyMapTransform;
  6125. varying vec2 vAnisotropyMapUv;
  6126. #endif
  6127. #ifdef USE_CLEARCOATMAP
  6128. uniform mat3 clearcoatMapTransform;
  6129. varying vec2 vClearcoatMapUv;
  6130. #endif
  6131. #ifdef USE_CLEARCOAT_NORMALMAP
  6132. uniform mat3 clearcoatNormalMapTransform;
  6133. varying vec2 vClearcoatNormalMapUv;
  6134. #endif
  6135. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6136. uniform mat3 clearcoatRoughnessMapTransform;
  6137. varying vec2 vClearcoatRoughnessMapUv;
  6138. #endif
  6139. #ifdef USE_SHEEN_COLORMAP
  6140. uniform mat3 sheenColorMapTransform;
  6141. varying vec2 vSheenColorMapUv;
  6142. #endif
  6143. #ifdef USE_SHEEN_ROUGHNESSMAP
  6144. uniform mat3 sheenRoughnessMapTransform;
  6145. varying vec2 vSheenRoughnessMapUv;
  6146. #endif
  6147. #ifdef USE_IRIDESCENCEMAP
  6148. uniform mat3 iridescenceMapTransform;
  6149. varying vec2 vIridescenceMapUv;
  6150. #endif
  6151. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6152. uniform mat3 iridescenceThicknessMapTransform;
  6153. varying vec2 vIridescenceThicknessMapUv;
  6154. #endif
  6155. #ifdef USE_SPECULARMAP
  6156. uniform mat3 specularMapTransform;
  6157. varying vec2 vSpecularMapUv;
  6158. #endif
  6159. #ifdef USE_SPECULAR_COLORMAP
  6160. uniform mat3 specularColorMapTransform;
  6161. varying vec2 vSpecularColorMapUv;
  6162. #endif
  6163. #ifdef USE_SPECULAR_INTENSITYMAP
  6164. uniform mat3 specularIntensityMapTransform;
  6165. varying vec2 vSpecularIntensityMapUv;
  6166. #endif
  6167. #ifdef USE_TRANSMISSIONMAP
  6168. uniform mat3 transmissionMapTransform;
  6169. varying vec2 vTransmissionMapUv;
  6170. #endif
  6171. #ifdef USE_THICKNESSMAP
  6172. uniform mat3 thicknessMapTransform;
  6173. varying vec2 vThicknessMapUv;
  6174. #endif`,nIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6175. vUv = vec3( uv, 1 ).xy;
  6176. #endif
  6177. #ifdef USE_MAP
  6178. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6179. #endif
  6180. #ifdef USE_ALPHAMAP
  6181. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6182. #endif
  6183. #ifdef USE_LIGHTMAP
  6184. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6185. #endif
  6186. #ifdef USE_AOMAP
  6187. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6188. #endif
  6189. #ifdef USE_BUMPMAP
  6190. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6191. #endif
  6192. #ifdef USE_NORMALMAP
  6193. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6194. #endif
  6195. #ifdef USE_DISPLACEMENTMAP
  6196. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6197. #endif
  6198. #ifdef USE_EMISSIVEMAP
  6199. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6200. #endif
  6201. #ifdef USE_METALNESSMAP
  6202. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6203. #endif
  6204. #ifdef USE_ROUGHNESSMAP
  6205. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6206. #endif
  6207. #ifdef USE_ANISOTROPYMAP
  6208. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6209. #endif
  6210. #ifdef USE_CLEARCOATMAP
  6211. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6212. #endif
  6213. #ifdef USE_CLEARCOAT_NORMALMAP
  6214. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6215. #endif
  6216. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6217. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6218. #endif
  6219. #ifdef USE_IRIDESCENCEMAP
  6220. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6221. #endif
  6222. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6223. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6224. #endif
  6225. #ifdef USE_SHEEN_COLORMAP
  6226. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6227. #endif
  6228. #ifdef USE_SHEEN_ROUGHNESSMAP
  6229. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6230. #endif
  6231. #ifdef USE_SPECULARMAP
  6232. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6233. #endif
  6234. #ifdef USE_SPECULAR_COLORMAP
  6235. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6236. #endif
  6237. #ifdef USE_SPECULAR_INTENSITYMAP
  6238. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6239. #endif
  6240. #ifdef USE_TRANSMISSIONMAP
  6241. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6242. #endif
  6243. #ifdef USE_THICKNESSMAP
  6244. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6245. #endif`,rIe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6246. vec4 worldPosition = vec4( transformed, 1.0 );
  6247. #ifdef USE_BATCHING
  6248. worldPosition = batchingMatrix * worldPosition;
  6249. #endif
  6250. #ifdef USE_INSTANCING
  6251. worldPosition = instanceMatrix * worldPosition;
  6252. #endif
  6253. worldPosition = modelMatrix * worldPosition;
  6254. #endif`;const iIe=`varying vec2 vUv;
  6255. uniform mat3 uvTransform;
  6256. void main() {
  6257. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6258. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6259. }`,aIe=`uniform sampler2D t2D;
  6260. uniform float backgroundIntensity;
  6261. varying vec2 vUv;
  6262. void main() {
  6263. vec4 texColor = texture2D( t2D, vUv );
  6264. #ifdef DECODE_VIDEO_TEXTURE
  6265. 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 );
  6266. #endif
  6267. texColor.rgb *= backgroundIntensity;
  6268. gl_FragColor = texColor;
  6269. #include <tonemapping_fragment>
  6270. #include <colorspace_fragment>
  6271. }`,sIe=`varying vec3 vWorldDirection;
  6272. #include <common>
  6273. void main() {
  6274. vWorldDirection = transformDirection( position, modelMatrix );
  6275. #include <begin_vertex>
  6276. #include <project_vertex>
  6277. gl_Position.z = gl_Position.w;
  6278. }`,oIe=`#ifdef ENVMAP_TYPE_CUBE
  6279. uniform samplerCube envMap;
  6280. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6281. uniform sampler2D envMap;
  6282. #endif
  6283. uniform float flipEnvMap;
  6284. uniform float backgroundBlurriness;
  6285. uniform float backgroundIntensity;
  6286. varying vec3 vWorldDirection;
  6287. #include <cube_uv_reflection_fragment>
  6288. void main() {
  6289. #ifdef ENVMAP_TYPE_CUBE
  6290. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6291. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6292. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6293. #else
  6294. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6295. #endif
  6296. texColor.rgb *= backgroundIntensity;
  6297. gl_FragColor = texColor;
  6298. #include <tonemapping_fragment>
  6299. #include <colorspace_fragment>
  6300. }`,lIe=`varying vec3 vWorldDirection;
  6301. #include <common>
  6302. void main() {
  6303. vWorldDirection = transformDirection( position, modelMatrix );
  6304. #include <begin_vertex>
  6305. #include <project_vertex>
  6306. gl_Position.z = gl_Position.w;
  6307. }`,cIe=`uniform samplerCube tCube;
  6308. uniform float tFlip;
  6309. uniform float opacity;
  6310. varying vec3 vWorldDirection;
  6311. void main() {
  6312. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6313. gl_FragColor = texColor;
  6314. gl_FragColor.a *= opacity;
  6315. #include <tonemapping_fragment>
  6316. #include <colorspace_fragment>
  6317. }`,uIe=`#include <common>
  6318. #include <batching_pars_vertex>
  6319. #include <uv_pars_vertex>
  6320. #include <displacementmap_pars_vertex>
  6321. #include <morphtarget_pars_vertex>
  6322. #include <skinning_pars_vertex>
  6323. #include <logdepthbuf_pars_vertex>
  6324. #include <clipping_planes_pars_vertex>
  6325. varying vec2 vHighPrecisionZW;
  6326. void main() {
  6327. #include <uv_vertex>
  6328. #include <batching_vertex>
  6329. #include <skinbase_vertex>
  6330. #ifdef USE_DISPLACEMENTMAP
  6331. #include <beginnormal_vertex>
  6332. #include <morphnormal_vertex>
  6333. #include <skinnormal_vertex>
  6334. #endif
  6335. #include <begin_vertex>
  6336. #include <morphtarget_vertex>
  6337. #include <skinning_vertex>
  6338. #include <displacementmap_vertex>
  6339. #include <project_vertex>
  6340. #include <logdepthbuf_vertex>
  6341. #include <clipping_planes_vertex>
  6342. vHighPrecisionZW = gl_Position.zw;
  6343. }`,dIe=`#if DEPTH_PACKING == 3200
  6344. uniform float opacity;
  6345. #endif
  6346. #include <common>
  6347. #include <packing>
  6348. #include <uv_pars_fragment>
  6349. #include <map_pars_fragment>
  6350. #include <alphamap_pars_fragment>
  6351. #include <alphatest_pars_fragment>
  6352. #include <alphahash_pars_fragment>
  6353. #include <logdepthbuf_pars_fragment>
  6354. #include <clipping_planes_pars_fragment>
  6355. varying vec2 vHighPrecisionZW;
  6356. void main() {
  6357. #include <clipping_planes_fragment>
  6358. vec4 diffuseColor = vec4( 1.0 );
  6359. #if DEPTH_PACKING == 3200
  6360. diffuseColor.a = opacity;
  6361. #endif
  6362. #include <map_fragment>
  6363. #include <alphamap_fragment>
  6364. #include <alphatest_fragment>
  6365. #include <alphahash_fragment>
  6366. #include <logdepthbuf_fragment>
  6367. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6368. #if DEPTH_PACKING == 3200
  6369. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6370. #elif DEPTH_PACKING == 3201
  6371. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6372. #endif
  6373. }`,hIe=`#define DISTANCE
  6374. varying vec3 vWorldPosition;
  6375. #include <common>
  6376. #include <batching_pars_vertex>
  6377. #include <uv_pars_vertex>
  6378. #include <displacementmap_pars_vertex>
  6379. #include <morphtarget_pars_vertex>
  6380. #include <skinning_pars_vertex>
  6381. #include <clipping_planes_pars_vertex>
  6382. void main() {
  6383. #include <uv_vertex>
  6384. #include <batching_vertex>
  6385. #include <skinbase_vertex>
  6386. #ifdef USE_DISPLACEMENTMAP
  6387. #include <beginnormal_vertex>
  6388. #include <morphnormal_vertex>
  6389. #include <skinnormal_vertex>
  6390. #endif
  6391. #include <begin_vertex>
  6392. #include <morphtarget_vertex>
  6393. #include <skinning_vertex>
  6394. #include <displacementmap_vertex>
  6395. #include <project_vertex>
  6396. #include <worldpos_vertex>
  6397. #include <clipping_planes_vertex>
  6398. vWorldPosition = worldPosition.xyz;
  6399. }`,fIe=`#define DISTANCE
  6400. uniform vec3 referencePosition;
  6401. uniform float nearDistance;
  6402. uniform float farDistance;
  6403. varying vec3 vWorldPosition;
  6404. #include <common>
  6405. #include <packing>
  6406. #include <uv_pars_fragment>
  6407. #include <map_pars_fragment>
  6408. #include <alphamap_pars_fragment>
  6409. #include <alphatest_pars_fragment>
  6410. #include <alphahash_pars_fragment>
  6411. #include <clipping_planes_pars_fragment>
  6412. void main () {
  6413. #include <clipping_planes_fragment>
  6414. vec4 diffuseColor = vec4( 1.0 );
  6415. #include <map_fragment>
  6416. #include <alphamap_fragment>
  6417. #include <alphatest_fragment>
  6418. #include <alphahash_fragment>
  6419. float dist = length( vWorldPosition - referencePosition );
  6420. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6421. dist = saturate( dist );
  6422. gl_FragColor = packDepthToRGBA( dist );
  6423. }`,mIe=`varying vec3 vWorldDirection;
  6424. #include <common>
  6425. void main() {
  6426. vWorldDirection = transformDirection( position, modelMatrix );
  6427. #include <begin_vertex>
  6428. #include <project_vertex>
  6429. }`,pIe=`uniform sampler2D tEquirect;
  6430. varying vec3 vWorldDirection;
  6431. #include <common>
  6432. void main() {
  6433. vec3 direction = normalize( vWorldDirection );
  6434. vec2 sampleUV = equirectUv( direction );
  6435. gl_FragColor = texture2D( tEquirect, sampleUV );
  6436. #include <tonemapping_fragment>
  6437. #include <colorspace_fragment>
  6438. }`,gIe=`uniform float scale;
  6439. attribute float lineDistance;
  6440. varying float vLineDistance;
  6441. #include <common>
  6442. #include <uv_pars_vertex>
  6443. #include <color_pars_vertex>
  6444. #include <fog_pars_vertex>
  6445. #include <morphtarget_pars_vertex>
  6446. #include <logdepthbuf_pars_vertex>
  6447. #include <clipping_planes_pars_vertex>
  6448. void main() {
  6449. vLineDistance = scale * lineDistance;
  6450. #include <uv_vertex>
  6451. #include <color_vertex>
  6452. #include <morphcolor_vertex>
  6453. #include <begin_vertex>
  6454. #include <morphtarget_vertex>
  6455. #include <project_vertex>
  6456. #include <logdepthbuf_vertex>
  6457. #include <clipping_planes_vertex>
  6458. #include <fog_vertex>
  6459. }`,xIe=`uniform vec3 diffuse;
  6460. uniform float opacity;
  6461. uniform float dashSize;
  6462. uniform float totalSize;
  6463. varying float vLineDistance;
  6464. #include <common>
  6465. #include <color_pars_fragment>
  6466. #include <uv_pars_fragment>
  6467. #include <map_pars_fragment>
  6468. #include <fog_pars_fragment>
  6469. #include <logdepthbuf_pars_fragment>
  6470. #include <clipping_planes_pars_fragment>
  6471. void main() {
  6472. #include <clipping_planes_fragment>
  6473. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6474. discard;
  6475. }
  6476. vec3 outgoingLight = vec3( 0.0 );
  6477. vec4 diffuseColor = vec4( diffuse, opacity );
  6478. #include <logdepthbuf_fragment>
  6479. #include <map_fragment>
  6480. #include <color_fragment>
  6481. outgoingLight = diffuseColor.rgb;
  6482. #include <opaque_fragment>
  6483. #include <tonemapping_fragment>
  6484. #include <colorspace_fragment>
  6485. #include <fog_fragment>
  6486. #include <premultiplied_alpha_fragment>
  6487. }`,bIe=`#include <common>
  6488. #include <batching_pars_vertex>
  6489. #include <uv_pars_vertex>
  6490. #include <envmap_pars_vertex>
  6491. #include <color_pars_vertex>
  6492. #include <fog_pars_vertex>
  6493. #include <morphtarget_pars_vertex>
  6494. #include <skinning_pars_vertex>
  6495. #include <logdepthbuf_pars_vertex>
  6496. #include <clipping_planes_pars_vertex>
  6497. void main() {
  6498. #include <uv_vertex>
  6499. #include <color_vertex>
  6500. #include <morphcolor_vertex>
  6501. #include <batching_vertex>
  6502. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6503. #include <beginnormal_vertex>
  6504. #include <morphnormal_vertex>
  6505. #include <skinbase_vertex>
  6506. #include <skinnormal_vertex>
  6507. #include <defaultnormal_vertex>
  6508. #endif
  6509. #include <begin_vertex>
  6510. #include <morphtarget_vertex>
  6511. #include <skinning_vertex>
  6512. #include <project_vertex>
  6513. #include <logdepthbuf_vertex>
  6514. #include <clipping_planes_vertex>
  6515. #include <worldpos_vertex>
  6516. #include <envmap_vertex>
  6517. #include <fog_vertex>
  6518. }`,yIe=`uniform vec3 diffuse;
  6519. uniform float opacity;
  6520. #ifndef FLAT_SHADED
  6521. varying vec3 vNormal;
  6522. #endif
  6523. #include <common>
  6524. #include <dithering_pars_fragment>
  6525. #include <color_pars_fragment>
  6526. #include <uv_pars_fragment>
  6527. #include <map_pars_fragment>
  6528. #include <alphamap_pars_fragment>
  6529. #include <alphatest_pars_fragment>
  6530. #include <alphahash_pars_fragment>
  6531. #include <aomap_pars_fragment>
  6532. #include <lightmap_pars_fragment>
  6533. #include <envmap_common_pars_fragment>
  6534. #include <envmap_pars_fragment>
  6535. #include <fog_pars_fragment>
  6536. #include <specularmap_pars_fragment>
  6537. #include <logdepthbuf_pars_fragment>
  6538. #include <clipping_planes_pars_fragment>
  6539. void main() {
  6540. #include <clipping_planes_fragment>
  6541. vec4 diffuseColor = vec4( diffuse, opacity );
  6542. #include <logdepthbuf_fragment>
  6543. #include <map_fragment>
  6544. #include <color_fragment>
  6545. #include <alphamap_fragment>
  6546. #include <alphatest_fragment>
  6547. #include <alphahash_fragment>
  6548. #include <specularmap_fragment>
  6549. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6550. #ifdef USE_LIGHTMAP
  6551. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6552. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6553. #else
  6554. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6555. #endif
  6556. #include <aomap_fragment>
  6557. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6558. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6559. #include <envmap_fragment>
  6560. #include <opaque_fragment>
  6561. #include <tonemapping_fragment>
  6562. #include <colorspace_fragment>
  6563. #include <fog_fragment>
  6564. #include <premultiplied_alpha_fragment>
  6565. #include <dithering_fragment>
  6566. }`,vIe=`#define LAMBERT
  6567. varying vec3 vViewPosition;
  6568. #include <common>
  6569. #include <batching_pars_vertex>
  6570. #include <uv_pars_vertex>
  6571. #include <displacementmap_pars_vertex>
  6572. #include <envmap_pars_vertex>
  6573. #include <color_pars_vertex>
  6574. #include <fog_pars_vertex>
  6575. #include <normal_pars_vertex>
  6576. #include <morphtarget_pars_vertex>
  6577. #include <skinning_pars_vertex>
  6578. #include <shadowmap_pars_vertex>
  6579. #include <logdepthbuf_pars_vertex>
  6580. #include <clipping_planes_pars_vertex>
  6581. void main() {
  6582. #include <uv_vertex>
  6583. #include <color_vertex>
  6584. #include <morphcolor_vertex>
  6585. #include <batching_vertex>
  6586. #include <beginnormal_vertex>
  6587. #include <morphnormal_vertex>
  6588. #include <skinbase_vertex>
  6589. #include <skinnormal_vertex>
  6590. #include <defaultnormal_vertex>
  6591. #include <normal_vertex>
  6592. #include <begin_vertex>
  6593. #include <morphtarget_vertex>
  6594. #include <skinning_vertex>
  6595. #include <displacementmap_vertex>
  6596. #include <project_vertex>
  6597. #include <logdepthbuf_vertex>
  6598. #include <clipping_planes_vertex>
  6599. vViewPosition = - mvPosition.xyz;
  6600. #include <worldpos_vertex>
  6601. #include <envmap_vertex>
  6602. #include <shadowmap_vertex>
  6603. #include <fog_vertex>
  6604. }`,_Ie=`#define LAMBERT
  6605. uniform vec3 diffuse;
  6606. uniform vec3 emissive;
  6607. uniform float opacity;
  6608. #include <common>
  6609. #include <packing>
  6610. #include <dithering_pars_fragment>
  6611. #include <color_pars_fragment>
  6612. #include <uv_pars_fragment>
  6613. #include <map_pars_fragment>
  6614. #include <alphamap_pars_fragment>
  6615. #include <alphatest_pars_fragment>
  6616. #include <alphahash_pars_fragment>
  6617. #include <aomap_pars_fragment>
  6618. #include <lightmap_pars_fragment>
  6619. #include <emissivemap_pars_fragment>
  6620. #include <envmap_common_pars_fragment>
  6621. #include <envmap_pars_fragment>
  6622. #include <fog_pars_fragment>
  6623. #include <bsdfs>
  6624. #include <lights_pars_begin>
  6625. #include <normal_pars_fragment>
  6626. #include <lights_lambert_pars_fragment>
  6627. #include <shadowmap_pars_fragment>
  6628. #include <bumpmap_pars_fragment>
  6629. #include <normalmap_pars_fragment>
  6630. #include <specularmap_pars_fragment>
  6631. #include <logdepthbuf_pars_fragment>
  6632. #include <clipping_planes_pars_fragment>
  6633. void main() {
  6634. #include <clipping_planes_fragment>
  6635. vec4 diffuseColor = vec4( diffuse, opacity );
  6636. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6637. vec3 totalEmissiveRadiance = emissive;
  6638. #include <logdepthbuf_fragment>
  6639. #include <map_fragment>
  6640. #include <color_fragment>
  6641. #include <alphamap_fragment>
  6642. #include <alphatest_fragment>
  6643. #include <alphahash_fragment>
  6644. #include <specularmap_fragment>
  6645. #include <normal_fragment_begin>
  6646. #include <normal_fragment_maps>
  6647. #include <emissivemap_fragment>
  6648. #include <lights_lambert_fragment>
  6649. #include <lights_fragment_begin>
  6650. #include <lights_fragment_maps>
  6651. #include <lights_fragment_end>
  6652. #include <aomap_fragment>
  6653. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6654. #include <envmap_fragment>
  6655. #include <opaque_fragment>
  6656. #include <tonemapping_fragment>
  6657. #include <colorspace_fragment>
  6658. #include <fog_fragment>
  6659. #include <premultiplied_alpha_fragment>
  6660. #include <dithering_fragment>
  6661. }`,wIe=`#define MATCAP
  6662. varying vec3 vViewPosition;
  6663. #include <common>
  6664. #include <batching_pars_vertex>
  6665. #include <uv_pars_vertex>
  6666. #include <color_pars_vertex>
  6667. #include <displacementmap_pars_vertex>
  6668. #include <fog_pars_vertex>
  6669. #include <normal_pars_vertex>
  6670. #include <morphtarget_pars_vertex>
  6671. #include <skinning_pars_vertex>
  6672. #include <logdepthbuf_pars_vertex>
  6673. #include <clipping_planes_pars_vertex>
  6674. void main() {
  6675. #include <uv_vertex>
  6676. #include <color_vertex>
  6677. #include <morphcolor_vertex>
  6678. #include <batching_vertex>
  6679. #include <beginnormal_vertex>
  6680. #include <morphnormal_vertex>
  6681. #include <skinbase_vertex>
  6682. #include <skinnormal_vertex>
  6683. #include <defaultnormal_vertex>
  6684. #include <normal_vertex>
  6685. #include <begin_vertex>
  6686. #include <morphtarget_vertex>
  6687. #include <skinning_vertex>
  6688. #include <displacementmap_vertex>
  6689. #include <project_vertex>
  6690. #include <logdepthbuf_vertex>
  6691. #include <clipping_planes_vertex>
  6692. #include <fog_vertex>
  6693. vViewPosition = - mvPosition.xyz;
  6694. }`,SIe=`#define MATCAP
  6695. uniform vec3 diffuse;
  6696. uniform float opacity;
  6697. uniform sampler2D matcap;
  6698. varying vec3 vViewPosition;
  6699. #include <common>
  6700. #include <dithering_pars_fragment>
  6701. #include <color_pars_fragment>
  6702. #include <uv_pars_fragment>
  6703. #include <map_pars_fragment>
  6704. #include <alphamap_pars_fragment>
  6705. #include <alphatest_pars_fragment>
  6706. #include <alphahash_pars_fragment>
  6707. #include <fog_pars_fragment>
  6708. #include <normal_pars_fragment>
  6709. #include <bumpmap_pars_fragment>
  6710. #include <normalmap_pars_fragment>
  6711. #include <logdepthbuf_pars_fragment>
  6712. #include <clipping_planes_pars_fragment>
  6713. void main() {
  6714. #include <clipping_planes_fragment>
  6715. vec4 diffuseColor = vec4( diffuse, opacity );
  6716. #include <logdepthbuf_fragment>
  6717. #include <map_fragment>
  6718. #include <color_fragment>
  6719. #include <alphamap_fragment>
  6720. #include <alphatest_fragment>
  6721. #include <alphahash_fragment>
  6722. #include <normal_fragment_begin>
  6723. #include <normal_fragment_maps>
  6724. vec3 viewDir = normalize( vViewPosition );
  6725. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6726. vec3 y = cross( viewDir, x );
  6727. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6728. #ifdef USE_MATCAP
  6729. vec4 matcapColor = texture2D( matcap, uv );
  6730. #else
  6731. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6732. #endif
  6733. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6734. #include <opaque_fragment>
  6735. #include <tonemapping_fragment>
  6736. #include <colorspace_fragment>
  6737. #include <fog_fragment>
  6738. #include <premultiplied_alpha_fragment>
  6739. #include <dithering_fragment>
  6740. }`,MIe=`#define NORMAL
  6741. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6742. varying vec3 vViewPosition;
  6743. #endif
  6744. #include <common>
  6745. #include <batching_pars_vertex>
  6746. #include <uv_pars_vertex>
  6747. #include <displacementmap_pars_vertex>
  6748. #include <normal_pars_vertex>
  6749. #include <morphtarget_pars_vertex>
  6750. #include <skinning_pars_vertex>
  6751. #include <logdepthbuf_pars_vertex>
  6752. #include <clipping_planes_pars_vertex>
  6753. void main() {
  6754. #include <uv_vertex>
  6755. #include <batching_vertex>
  6756. #include <beginnormal_vertex>
  6757. #include <morphnormal_vertex>
  6758. #include <skinbase_vertex>
  6759. #include <skinnormal_vertex>
  6760. #include <defaultnormal_vertex>
  6761. #include <normal_vertex>
  6762. #include <begin_vertex>
  6763. #include <morphtarget_vertex>
  6764. #include <skinning_vertex>
  6765. #include <displacementmap_vertex>
  6766. #include <project_vertex>
  6767. #include <logdepthbuf_vertex>
  6768. #include <clipping_planes_vertex>
  6769. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6770. vViewPosition = - mvPosition.xyz;
  6771. #endif
  6772. }`,EIe=`#define NORMAL
  6773. uniform float opacity;
  6774. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6775. varying vec3 vViewPosition;
  6776. #endif
  6777. #include <packing>
  6778. #include <uv_pars_fragment>
  6779. #include <normal_pars_fragment>
  6780. #include <bumpmap_pars_fragment>
  6781. #include <normalmap_pars_fragment>
  6782. #include <logdepthbuf_pars_fragment>
  6783. #include <clipping_planes_pars_fragment>
  6784. void main() {
  6785. #include <clipping_planes_fragment>
  6786. #include <logdepthbuf_fragment>
  6787. #include <normal_fragment_begin>
  6788. #include <normal_fragment_maps>
  6789. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6790. #ifdef OPAQUE
  6791. gl_FragColor.a = 1.0;
  6792. #endif
  6793. }`,AIe=`#define PHONG
  6794. varying vec3 vViewPosition;
  6795. #include <common>
  6796. #include <batching_pars_vertex>
  6797. #include <uv_pars_vertex>
  6798. #include <displacementmap_pars_vertex>
  6799. #include <envmap_pars_vertex>
  6800. #include <color_pars_vertex>
  6801. #include <fog_pars_vertex>
  6802. #include <normal_pars_vertex>
  6803. #include <morphtarget_pars_vertex>
  6804. #include <skinning_pars_vertex>
  6805. #include <shadowmap_pars_vertex>
  6806. #include <logdepthbuf_pars_vertex>
  6807. #include <clipping_planes_pars_vertex>
  6808. void main() {
  6809. #include <uv_vertex>
  6810. #include <color_vertex>
  6811. #include <morphcolor_vertex>
  6812. #include <batching_vertex>
  6813. #include <beginnormal_vertex>
  6814. #include <morphnormal_vertex>
  6815. #include <skinbase_vertex>
  6816. #include <skinnormal_vertex>
  6817. #include <defaultnormal_vertex>
  6818. #include <normal_vertex>
  6819. #include <begin_vertex>
  6820. #include <morphtarget_vertex>
  6821. #include <skinning_vertex>
  6822. #include <displacementmap_vertex>
  6823. #include <project_vertex>
  6824. #include <logdepthbuf_vertex>
  6825. #include <clipping_planes_vertex>
  6826. vViewPosition = - mvPosition.xyz;
  6827. #include <worldpos_vertex>
  6828. #include <envmap_vertex>
  6829. #include <shadowmap_vertex>
  6830. #include <fog_vertex>
  6831. }`,TIe=`#define PHONG
  6832. uniform vec3 diffuse;
  6833. uniform vec3 emissive;
  6834. uniform vec3 specular;
  6835. uniform float shininess;
  6836. uniform float opacity;
  6837. #include <common>
  6838. #include <packing>
  6839. #include <dithering_pars_fragment>
  6840. #include <color_pars_fragment>
  6841. #include <uv_pars_fragment>
  6842. #include <map_pars_fragment>
  6843. #include <alphamap_pars_fragment>
  6844. #include <alphatest_pars_fragment>
  6845. #include <alphahash_pars_fragment>
  6846. #include <aomap_pars_fragment>
  6847. #include <lightmap_pars_fragment>
  6848. #include <emissivemap_pars_fragment>
  6849. #include <envmap_common_pars_fragment>
  6850. #include <envmap_pars_fragment>
  6851. #include <fog_pars_fragment>
  6852. #include <bsdfs>
  6853. #include <lights_pars_begin>
  6854. #include <normal_pars_fragment>
  6855. #include <lights_phong_pars_fragment>
  6856. #include <shadowmap_pars_fragment>
  6857. #include <bumpmap_pars_fragment>
  6858. #include <normalmap_pars_fragment>
  6859. #include <specularmap_pars_fragment>
  6860. #include <logdepthbuf_pars_fragment>
  6861. #include <clipping_planes_pars_fragment>
  6862. void main() {
  6863. #include <clipping_planes_fragment>
  6864. vec4 diffuseColor = vec4( diffuse, opacity );
  6865. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6866. vec3 totalEmissiveRadiance = emissive;
  6867. #include <logdepthbuf_fragment>
  6868. #include <map_fragment>
  6869. #include <color_fragment>
  6870. #include <alphamap_fragment>
  6871. #include <alphatest_fragment>
  6872. #include <alphahash_fragment>
  6873. #include <specularmap_fragment>
  6874. #include <normal_fragment_begin>
  6875. #include <normal_fragment_maps>
  6876. #include <emissivemap_fragment>
  6877. #include <lights_phong_fragment>
  6878. #include <lights_fragment_begin>
  6879. #include <lights_fragment_maps>
  6880. #include <lights_fragment_end>
  6881. #include <aomap_fragment>
  6882. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6883. #include <envmap_fragment>
  6884. #include <opaque_fragment>
  6885. #include <tonemapping_fragment>
  6886. #include <colorspace_fragment>
  6887. #include <fog_fragment>
  6888. #include <premultiplied_alpha_fragment>
  6889. #include <dithering_fragment>
  6890. }`,CIe=`#define STANDARD
  6891. varying vec3 vViewPosition;
  6892. #ifdef USE_TRANSMISSION
  6893. varying vec3 vWorldPosition;
  6894. #endif
  6895. #include <common>
  6896. #include <batching_pars_vertex>
  6897. #include <uv_pars_vertex>
  6898. #include <displacementmap_pars_vertex>
  6899. #include <color_pars_vertex>
  6900. #include <fog_pars_vertex>
  6901. #include <normal_pars_vertex>
  6902. #include <morphtarget_pars_vertex>
  6903. #include <skinning_pars_vertex>
  6904. #include <shadowmap_pars_vertex>
  6905. #include <logdepthbuf_pars_vertex>
  6906. #include <clipping_planes_pars_vertex>
  6907. void main() {
  6908. #include <uv_vertex>
  6909. #include <color_vertex>
  6910. #include <morphcolor_vertex>
  6911. #include <batching_vertex>
  6912. #include <beginnormal_vertex>
  6913. #include <morphnormal_vertex>
  6914. #include <skinbase_vertex>
  6915. #include <skinnormal_vertex>
  6916. #include <defaultnormal_vertex>
  6917. #include <normal_vertex>
  6918. #include <begin_vertex>
  6919. #include <morphtarget_vertex>
  6920. #include <skinning_vertex>
  6921. #include <displacementmap_vertex>
  6922. #include <project_vertex>
  6923. #include <logdepthbuf_vertex>
  6924. #include <clipping_planes_vertex>
  6925. vViewPosition = - mvPosition.xyz;
  6926. #include <worldpos_vertex>
  6927. #include <shadowmap_vertex>
  6928. #include <fog_vertex>
  6929. #ifdef USE_TRANSMISSION
  6930. vWorldPosition = worldPosition.xyz;
  6931. #endif
  6932. }`,NIe=`#define STANDARD
  6933. #ifdef PHYSICAL
  6934. #define IOR
  6935. #define USE_SPECULAR
  6936. #endif
  6937. uniform vec3 diffuse;
  6938. uniform vec3 emissive;
  6939. uniform float roughness;
  6940. uniform float metalness;
  6941. uniform float opacity;
  6942. #ifdef IOR
  6943. uniform float ior;
  6944. #endif
  6945. #ifdef USE_SPECULAR
  6946. uniform float specularIntensity;
  6947. uniform vec3 specularColor;
  6948. #ifdef USE_SPECULAR_COLORMAP
  6949. uniform sampler2D specularColorMap;
  6950. #endif
  6951. #ifdef USE_SPECULAR_INTENSITYMAP
  6952. uniform sampler2D specularIntensityMap;
  6953. #endif
  6954. #endif
  6955. #ifdef USE_CLEARCOAT
  6956. uniform float clearcoat;
  6957. uniform float clearcoatRoughness;
  6958. #endif
  6959. #ifdef USE_IRIDESCENCE
  6960. uniform float iridescence;
  6961. uniform float iridescenceIOR;
  6962. uniform float iridescenceThicknessMinimum;
  6963. uniform float iridescenceThicknessMaximum;
  6964. #endif
  6965. #ifdef USE_SHEEN
  6966. uniform vec3 sheenColor;
  6967. uniform float sheenRoughness;
  6968. #ifdef USE_SHEEN_COLORMAP
  6969. uniform sampler2D sheenColorMap;
  6970. #endif
  6971. #ifdef USE_SHEEN_ROUGHNESSMAP
  6972. uniform sampler2D sheenRoughnessMap;
  6973. #endif
  6974. #endif
  6975. #ifdef USE_ANISOTROPY
  6976. uniform vec2 anisotropyVector;
  6977. #ifdef USE_ANISOTROPYMAP
  6978. uniform sampler2D anisotropyMap;
  6979. #endif
  6980. #endif
  6981. varying vec3 vViewPosition;
  6982. #include <common>
  6983. #include <packing>
  6984. #include <dithering_pars_fragment>
  6985. #include <color_pars_fragment>
  6986. #include <uv_pars_fragment>
  6987. #include <map_pars_fragment>
  6988. #include <alphamap_pars_fragment>
  6989. #include <alphatest_pars_fragment>
  6990. #include <alphahash_pars_fragment>
  6991. #include <aomap_pars_fragment>
  6992. #include <lightmap_pars_fragment>
  6993. #include <emissivemap_pars_fragment>
  6994. #include <iridescence_fragment>
  6995. #include <cube_uv_reflection_fragment>
  6996. #include <envmap_common_pars_fragment>
  6997. #include <envmap_physical_pars_fragment>
  6998. #include <fog_pars_fragment>
  6999. #include <lights_pars_begin>
  7000. #include <normal_pars_fragment>
  7001. #include <lights_physical_pars_fragment>
  7002. #include <transmission_pars_fragment>
  7003. #include <shadowmap_pars_fragment>
  7004. #include <bumpmap_pars_fragment>
  7005. #include <normalmap_pars_fragment>
  7006. #include <clearcoat_pars_fragment>
  7007. #include <iridescence_pars_fragment>
  7008. #include <roughnessmap_pars_fragment>
  7009. #include <metalnessmap_pars_fragment>
  7010. #include <logdepthbuf_pars_fragment>
  7011. #include <clipping_planes_pars_fragment>
  7012. void main() {
  7013. #include <clipping_planes_fragment>
  7014. vec4 diffuseColor = vec4( diffuse, opacity );
  7015. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7016. vec3 totalEmissiveRadiance = emissive;
  7017. #include <logdepthbuf_fragment>
  7018. #include <map_fragment>
  7019. #include <color_fragment>
  7020. #include <alphamap_fragment>
  7021. #include <alphatest_fragment>
  7022. #include <alphahash_fragment>
  7023. #include <roughnessmap_fragment>
  7024. #include <metalnessmap_fragment>
  7025. #include <normal_fragment_begin>
  7026. #include <normal_fragment_maps>
  7027. #include <clearcoat_normal_fragment_begin>
  7028. #include <clearcoat_normal_fragment_maps>
  7029. #include <emissivemap_fragment>
  7030. #include <lights_physical_fragment>
  7031. #include <lights_fragment_begin>
  7032. #include <lights_fragment_maps>
  7033. #include <lights_fragment_end>
  7034. #include <aomap_fragment>
  7035. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7036. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7037. #include <transmission_fragment>
  7038. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7039. #ifdef USE_SHEEN
  7040. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7041. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7042. #endif
  7043. #ifdef USE_CLEARCOAT
  7044. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7045. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7046. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7047. #endif
  7048. #include <opaque_fragment>
  7049. #include <tonemapping_fragment>
  7050. #include <colorspace_fragment>
  7051. #include <fog_fragment>
  7052. #include <premultiplied_alpha_fragment>
  7053. #include <dithering_fragment>
  7054. }`,kIe=`#define TOON
  7055. varying vec3 vViewPosition;
  7056. #include <common>
  7057. #include <batching_pars_vertex>
  7058. #include <uv_pars_vertex>
  7059. #include <displacementmap_pars_vertex>
  7060. #include <color_pars_vertex>
  7061. #include <fog_pars_vertex>
  7062. #include <normal_pars_vertex>
  7063. #include <morphtarget_pars_vertex>
  7064. #include <skinning_pars_vertex>
  7065. #include <shadowmap_pars_vertex>
  7066. #include <logdepthbuf_pars_vertex>
  7067. #include <clipping_planes_pars_vertex>
  7068. void main() {
  7069. #include <uv_vertex>
  7070. #include <color_vertex>
  7071. #include <morphcolor_vertex>
  7072. #include <batching_vertex>
  7073. #include <beginnormal_vertex>
  7074. #include <morphnormal_vertex>
  7075. #include <skinbase_vertex>
  7076. #include <skinnormal_vertex>
  7077. #include <defaultnormal_vertex>
  7078. #include <normal_vertex>
  7079. #include <begin_vertex>
  7080. #include <morphtarget_vertex>
  7081. #include <skinning_vertex>
  7082. #include <displacementmap_vertex>
  7083. #include <project_vertex>
  7084. #include <logdepthbuf_vertex>
  7085. #include <clipping_planes_vertex>
  7086. vViewPosition = - mvPosition.xyz;
  7087. #include <worldpos_vertex>
  7088. #include <shadowmap_vertex>
  7089. #include <fog_vertex>
  7090. }`,PIe=`#define TOON
  7091. uniform vec3 diffuse;
  7092. uniform vec3 emissive;
  7093. uniform float opacity;
  7094. #include <common>
  7095. #include <packing>
  7096. #include <dithering_pars_fragment>
  7097. #include <color_pars_fragment>
  7098. #include <uv_pars_fragment>
  7099. #include <map_pars_fragment>
  7100. #include <alphamap_pars_fragment>
  7101. #include <alphatest_pars_fragment>
  7102. #include <alphahash_pars_fragment>
  7103. #include <aomap_pars_fragment>
  7104. #include <lightmap_pars_fragment>
  7105. #include <emissivemap_pars_fragment>
  7106. #include <gradientmap_pars_fragment>
  7107. #include <fog_pars_fragment>
  7108. #include <bsdfs>
  7109. #include <lights_pars_begin>
  7110. #include <normal_pars_fragment>
  7111. #include <lights_toon_pars_fragment>
  7112. #include <shadowmap_pars_fragment>
  7113. #include <bumpmap_pars_fragment>
  7114. #include <normalmap_pars_fragment>
  7115. #include <logdepthbuf_pars_fragment>
  7116. #include <clipping_planes_pars_fragment>
  7117. void main() {
  7118. #include <clipping_planes_fragment>
  7119. vec4 diffuseColor = vec4( diffuse, opacity );
  7120. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7121. vec3 totalEmissiveRadiance = emissive;
  7122. #include <logdepthbuf_fragment>
  7123. #include <map_fragment>
  7124. #include <color_fragment>
  7125. #include <alphamap_fragment>
  7126. #include <alphatest_fragment>
  7127. #include <alphahash_fragment>
  7128. #include <normal_fragment_begin>
  7129. #include <normal_fragment_maps>
  7130. #include <emissivemap_fragment>
  7131. #include <lights_toon_fragment>
  7132. #include <lights_fragment_begin>
  7133. #include <lights_fragment_maps>
  7134. #include <lights_fragment_end>
  7135. #include <aomap_fragment>
  7136. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7137. #include <opaque_fragment>
  7138. #include <tonemapping_fragment>
  7139. #include <colorspace_fragment>
  7140. #include <fog_fragment>
  7141. #include <premultiplied_alpha_fragment>
  7142. #include <dithering_fragment>
  7143. }`,RIe=`uniform float size;
  7144. uniform float scale;
  7145. #include <common>
  7146. #include <color_pars_vertex>
  7147. #include <fog_pars_vertex>
  7148. #include <morphtarget_pars_vertex>
  7149. #include <logdepthbuf_pars_vertex>
  7150. #include <clipping_planes_pars_vertex>
  7151. #ifdef USE_POINTS_UV
  7152. varying vec2 vUv;
  7153. uniform mat3 uvTransform;
  7154. #endif
  7155. void main() {
  7156. #ifdef USE_POINTS_UV
  7157. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7158. #endif
  7159. #include <color_vertex>
  7160. #include <morphcolor_vertex>
  7161. #include <begin_vertex>
  7162. #include <morphtarget_vertex>
  7163. #include <project_vertex>
  7164. gl_PointSize = size;
  7165. #ifdef USE_SIZEATTENUATION
  7166. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7167. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7168. #endif
  7169. #include <logdepthbuf_vertex>
  7170. #include <clipping_planes_vertex>
  7171. #include <worldpos_vertex>
  7172. #include <fog_vertex>
  7173. }`,jIe=`uniform vec3 diffuse;
  7174. uniform float opacity;
  7175. #include <common>
  7176. #include <color_pars_fragment>
  7177. #include <map_particle_pars_fragment>
  7178. #include <alphatest_pars_fragment>
  7179. #include <alphahash_pars_fragment>
  7180. #include <fog_pars_fragment>
  7181. #include <logdepthbuf_pars_fragment>
  7182. #include <clipping_planes_pars_fragment>
  7183. void main() {
  7184. #include <clipping_planes_fragment>
  7185. vec3 outgoingLight = vec3( 0.0 );
  7186. vec4 diffuseColor = vec4( diffuse, opacity );
  7187. #include <logdepthbuf_fragment>
  7188. #include <map_particle_fragment>
  7189. #include <color_fragment>
  7190. #include <alphatest_fragment>
  7191. #include <alphahash_fragment>
  7192. outgoingLight = diffuseColor.rgb;
  7193. #include <opaque_fragment>
  7194. #include <tonemapping_fragment>
  7195. #include <colorspace_fragment>
  7196. #include <fog_fragment>
  7197. #include <premultiplied_alpha_fragment>
  7198. }`,DIe=`#include <common>
  7199. #include <batching_pars_vertex>
  7200. #include <fog_pars_vertex>
  7201. #include <morphtarget_pars_vertex>
  7202. #include <skinning_pars_vertex>
  7203. #include <logdepthbuf_pars_vertex>
  7204. #include <shadowmap_pars_vertex>
  7205. void main() {
  7206. #include <batching_vertex>
  7207. #include <beginnormal_vertex>
  7208. #include <morphnormal_vertex>
  7209. #include <skinbase_vertex>
  7210. #include <skinnormal_vertex>
  7211. #include <defaultnormal_vertex>
  7212. #include <begin_vertex>
  7213. #include <morphtarget_vertex>
  7214. #include <skinning_vertex>
  7215. #include <project_vertex>
  7216. #include <logdepthbuf_vertex>
  7217. #include <worldpos_vertex>
  7218. #include <shadowmap_vertex>
  7219. #include <fog_vertex>
  7220. }`,OIe=`uniform vec3 color;
  7221. uniform float opacity;
  7222. #include <common>
  7223. #include <packing>
  7224. #include <fog_pars_fragment>
  7225. #include <bsdfs>
  7226. #include <lights_pars_begin>
  7227. #include <logdepthbuf_pars_fragment>
  7228. #include <shadowmap_pars_fragment>
  7229. #include <shadowmask_pars_fragment>
  7230. void main() {
  7231. #include <logdepthbuf_fragment>
  7232. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7233. #include <tonemapping_fragment>
  7234. #include <colorspace_fragment>
  7235. #include <fog_fragment>
  7236. }`,LIe=`uniform float rotation;
  7237. uniform vec2 center;
  7238. #include <common>
  7239. #include <uv_pars_vertex>
  7240. #include <fog_pars_vertex>
  7241. #include <logdepthbuf_pars_vertex>
  7242. #include <clipping_planes_pars_vertex>
  7243. void main() {
  7244. #include <uv_vertex>
  7245. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7246. vec2 scale;
  7247. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7248. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7249. #ifndef USE_SIZEATTENUATION
  7250. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7251. if ( isPerspective ) scale *= - mvPosition.z;
  7252. #endif
  7253. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7254. vec2 rotatedPosition;
  7255. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7256. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7257. mvPosition.xy += rotatedPosition;
  7258. gl_Position = projectionMatrix * mvPosition;
  7259. #include <logdepthbuf_vertex>
  7260. #include <clipping_planes_vertex>
  7261. #include <fog_vertex>
  7262. }`,IIe=`uniform vec3 diffuse;
  7263. uniform float opacity;
  7264. #include <common>
  7265. #include <uv_pars_fragment>
  7266. #include <map_pars_fragment>
  7267. #include <alphamap_pars_fragment>
  7268. #include <alphatest_pars_fragment>
  7269. #include <alphahash_pars_fragment>
  7270. #include <fog_pars_fragment>
  7271. #include <logdepthbuf_pars_fragment>
  7272. #include <clipping_planes_pars_fragment>
  7273. void main() {
  7274. #include <clipping_planes_fragment>
  7275. vec3 outgoingLight = vec3( 0.0 );
  7276. vec4 diffuseColor = vec4( diffuse, opacity );
  7277. #include <logdepthbuf_fragment>
  7278. #include <map_fragment>
  7279. #include <alphamap_fragment>
  7280. #include <alphatest_fragment>
  7281. #include <alphahash_fragment>
  7282. outgoingLight = diffuseColor.rgb;
  7283. #include <opaque_fragment>
  7284. #include <tonemapping_fragment>
  7285. #include <colorspace_fragment>
  7286. #include <fog_fragment>
  7287. }`,ln={alphahash_fragment:aLe,alphahash_pars_fragment:sLe,alphamap_fragment:oLe,alphamap_pars_fragment:lLe,alphatest_fragment:cLe,alphatest_pars_fragment:uLe,aomap_fragment:dLe,aomap_pars_fragment:hLe,batching_pars_vertex:fLe,batching_vertex:mLe,begin_vertex:pLe,beginnormal_vertex:gLe,bsdfs:xLe,iridescence_fragment:bLe,bumpmap_pars_fragment:yLe,clipping_planes_fragment:vLe,clipping_planes_pars_fragment:_Le,clipping_planes_pars_vertex:wLe,clipping_planes_vertex:SLe,color_fragment:MLe,color_pars_fragment:ELe,color_pars_vertex:ALe,color_vertex:TLe,common:CLe,cube_uv_reflection_fragment:NLe,defaultnormal_vertex:kLe,displacementmap_pars_vertex:PLe,displacementmap_vertex:RLe,emissivemap_fragment:jLe,emissivemap_pars_fragment:DLe,colorspace_fragment:OLe,colorspace_pars_fragment:LLe,envmap_fragment:ILe,envmap_common_pars_fragment:FLe,envmap_pars_fragment:ULe,envmap_pars_vertex:zLe,envmap_physical_pars_fragment:QLe,envmap_vertex:BLe,fog_vertex:HLe,fog_pars_vertex:$Le,fog_fragment:VLe,fog_pars_fragment:GLe,gradientmap_pars_fragment:WLe,lightmap_fragment:qLe,lightmap_pars_fragment:KLe,lights_lambert_fragment:XLe,lights_lambert_pars_fragment:YLe,lights_pars_begin:ZLe,lights_toon_fragment:JLe,lights_toon_pars_fragment:e4e,lights_phong_fragment:t4e,lights_phong_pars_fragment:n4e,lights_physical_fragment:r4e,lights_physical_pars_fragment:i4e,lights_fragment_begin:a4e,lights_fragment_maps:s4e,lights_fragment_end:o4e,logdepthbuf_fragment:l4e,logdepthbuf_pars_fragment:c4e,logdepthbuf_pars_vertex:u4e,logdepthbuf_vertex:d4e,map_fragment:h4e,map_pars_fragment:f4e,map_particle_fragment:m4e,map_particle_pars_fragment:p4e,metalnessmap_fragment:g4e,metalnessmap_pars_fragment:x4e,morphcolor_vertex:b4e,morphnormal_vertex:y4e,morphtarget_pars_vertex:v4e,morphtarget_vertex:_4e,normal_fragment_begin:w4e,normal_fragment_maps:S4e,normal_pars_fragment:M4e,normal_pars_vertex:E4e,normal_vertex:A4e,normalmap_pars_fragment:T4e,clearcoat_normal_fragment_begin:C4e,clearcoat_normal_fragment_maps:N4e,clearcoat_pars_fragment:k4e,iridescence_pars_fragment:P4e,opaque_fragment:R4e,packing:j4e,premultiplied_alpha_fragment:D4e,project_vertex:O4e,dithering_fragment:L4e,dithering_pars_fragment:I4e,roughnessmap_fragment:F4e,roughnessmap_pars_fragment:U4e,shadowmap_pars_fragment:z4e,shadowmap_pars_vertex:B4e,shadowmap_vertex:H4e,shadowmask_pars_fragment:$4e,skinbase_vertex:V4e,skinning_pars_vertex:G4e,skinning_vertex:W4e,skinnormal_vertex:q4e,specularmap_fragment:K4e,specularmap_pars_fragment:X4e,tonemapping_fragment:Y4e,tonemapping_pars_fragment:Z4e,transmission_fragment:Q4e,transmission_pars_fragment:J4e,uv_pars_fragment:eIe,uv_pars_vertex:tIe,uv_vertex:nIe,worldpos_vertex:rIe,background_vert:iIe,background_frag:aIe,backgroundCube_vert:sIe,backgroundCube_frag:oIe,cube_vert:lIe,cube_frag:cIe,depth_vert:uIe,depth_frag:dIe,distanceRGBA_vert:hIe,distanceRGBA_frag:fIe,equirect_vert:mIe,equirect_frag:pIe,linedashed_vert:gIe,linedashed_frag:xIe,meshbasic_vert:bIe,meshbasic_frag:yIe,meshlambert_vert:vIe,meshlambert_frag:_Ie,meshmatcap_vert:wIe,meshmatcap_frag:SIe,meshnormal_vert:MIe,meshnormal_frag:EIe,meshphong_vert:AIe,meshphong_frag:TIe,meshphysical_vert:CIe,meshphysical_frag:NIe,meshtoon_vert:kIe,meshtoon_frag:PIe,points_vert:RIe,points_frag:jIe,shadow_vert:DIe,shadow_frag:OIe,sprite_vert:LIe,sprite_frag:IIe},St={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 Zt(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 Zt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},qa={basic:{uniforms:wa([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:ln.meshbasic_vert,fragmentShader:ln.meshbasic_frag},lambert:{uniforms:wa([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 $t(0)}}]),vertexShader:ln.meshlambert_vert,fragmentShader:ln.meshlambert_frag},phong:{uniforms:wa([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 $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:ln.meshphong_vert,fragmentShader:ln.meshphong_frag},standard:{uniforms:wa([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 $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag},toon:{uniforms:wa([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new $t(0)}}]),vertexShader:ln.meshtoon_vert,fragmentShader:ln.meshtoon_frag},matcap:{uniforms:wa([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:ln.meshmatcap_vert,fragmentShader:ln.meshmatcap_frag},points:{uniforms:wa([St.points,St.fog]),vertexShader:ln.points_vert,fragmentShader:ln.points_frag},dashed:{uniforms:wa([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ln.linedashed_vert,fragmentShader:ln.linedashed_frag},depth:{uniforms:wa([St.common,St.displacementmap]),vertexShader:ln.depth_vert,fragmentShader:ln.depth_frag},normal:{uniforms:wa([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:ln.meshnormal_vert,fragmentShader:ln.meshnormal_frag},sprite:{uniforms:wa([St.sprite,St.fog]),vertexShader:ln.sprite_vert,fragmentShader:ln.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ln.background_vert,fragmentShader:ln.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ln.backgroundCube_vert,fragmentShader:ln.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ln.cube_vert,fragmentShader:ln.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ln.equirect_vert,fragmentShader:ln.equirect_frag},distanceRGBA:{uniforms:wa([St.common,St.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ln.distanceRGBA_vert,fragmentShader:ln.distanceRGBA_frag},shadow:{uniforms:wa([St.lights,St.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:ln.shadow_vert,fragmentShader:ln.shadow_frag}};qa.physical={uniforms:wa([qa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new Zt(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 Zt},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 Zt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag};const T_={r:0,b:0,g:0};function FIe(t,e,n,r,i,a,s){const o=new $t(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(y,b){let E=!1,w=b.isScene===!0?b.background:null;w&&w.isTexture&&(w=(b.backgroundBlurriness>0?n:e).get(w)),w===null?v(o,c):w&&w.isColor&&(v(w,1),E=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,s):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===qM)?(d===void 0&&(d=new Do(new Yb(1,1,1),new _d({name:"BackgroundCubeMaterial",uniforms:Fp(qa.backgroundCube.uniforms),vertexShader:qa.backgroundCube.vertexShader,fragmentShader:qa.backgroundCube.fragmentShader,side:Qa,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,C,k){this.matrixWorld.copyPosition(k.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=b.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,d.material.toneMapped=Yn.getTransfer(w.colorSpace)!==ur,(f!==w||g!==w.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new Do(new CO(2,2),new _d({name:"BackgroundMaterial",uniforms:Fp(qa.background.uniforms),vertexShader:qa.background.vertexShader,fragmentShader:qa.background.fragmentShader,side:vd,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=w,u.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,u.material.toneMapped=Yn.getTransfer(w.colorSpace)!==ur,w.matrixAutoUpdate===!0&&w.updateMatrix(),u.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||g!==w.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null))}function v(y,b){y.getRGB(T_,QZ(t)),r.buffers.color.setClear(T_.r,T_.g,T_.b,b,s)}return{getClearColor:function(){return o},setClearColor:function(y,b=1){o.set(y),c=b,v(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,v(o,c)},render:x}}function UIe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),s=r.isWebGL2||a!==null,o={},c=y(null);let u=c,d=!1;function f(R,W,K,G,te){let Y=!1;if(s){const J=v(G,K,W);u!==J&&(u=J,p(u.object)),Y=b(R,G,K,te),Y&&E(R,G,K,te)}else{const J=W.wireframe===!0;(u.geometry!==G.id||u.program!==K.id||u.wireframe!==J)&&(u.geometry=G.id,u.program=K.id,u.wireframe=J,Y=!0)}te!==null&&n.update(te,t.ELEMENT_ARRAY_BUFFER),(Y||d)&&(d=!1,F(R,W,K,G),te!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(te).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(R){return r.isWebGL2?t.bindVertexArray(R):a.bindVertexArrayOES(R)}function x(R){return r.isWebGL2?t.deleteVertexArray(R):a.deleteVertexArrayOES(R)}function v(R,W,K){const G=K.wireframe===!0;let te=o[R.id];te===void 0&&(te={},o[R.id]=te);let Y=te[W.id];Y===void 0&&(Y={},te[W.id]=Y);let J=Y[G];return J===void 0&&(J=y(g()),Y[G]=J),J}function y(R){const W=[],K=[],G=[];for(let te=0;te<i;te++)W[te]=0,K[te]=0,G[te]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:G,object:R,attributes:{},index:null}}function b(R,W,K,G){const te=u.attributes,Y=W.attributes;let J=0;const U=K.getAttributes();for(const H in U)if(U[H].location>=0){const ie=te[H];let pe=Y[H];if(pe===void 0&&(H==="instanceMatrix"&&R.instanceMatrix&&(pe=R.instanceMatrix),H==="instanceColor"&&R.instanceColor&&(pe=R.instanceColor)),ie===void 0||ie.attribute!==pe||pe&&ie.data!==pe.data)return!0;J++}return u.attributesNum!==J||u.index!==G}function E(R,W,K,G){const te={},Y=W.attributes;let J=0;const U=K.getAttributes();for(const H in U)if(U[H].location>=0){let ie=Y[H];ie===void 0&&(H==="instanceMatrix"&&R.instanceMatrix&&(ie=R.instanceMatrix),H==="instanceColor"&&R.instanceColor&&(ie=R.instanceColor));const pe={};pe.attribute=ie,ie&&ie.data&&(pe.data=ie.data),te[H]=pe,J++}u.attributes=te,u.attributesNum=J,u.index=G}function w(){const R=u.newAttributes;for(let W=0,K=R.length;W<K;W++)R[W]=0}function A(R){T(R,0)}function T(R,W){const K=u.newAttributes,G=u.enabledAttributes,te=u.attributeDivisors;K[R]=1,G[R]===0&&(t.enableVertexAttribArray(R),G[R]=1),te[R]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,W),te[R]=W)}function C(){const R=u.newAttributes,W=u.enabledAttributes;for(let K=0,G=W.length;K<G;K++)W[K]!==R[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function k(R,W,K,G,te,Y,J){J===!0?t.vertexAttribIPointer(R,W,K,te,Y):t.vertexAttribPointer(R,W,K,G,te,Y)}function F(R,W,K,G){if(r.isWebGL2===!1&&(R.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const te=G.attributes,Y=K.getAttributes(),J=W.defaultAttributeValues;for(const U in Y){const H=Y[U];if(H.location>=0){let ee=te[U];if(ee===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor)),ee!==void 0){const ie=ee.normalized,pe=ee.itemSize,ue=n.get(ee);if(ue===void 0)continue;const be=ue.buffer,Re=ue.type,Z=ue.bytesPerElement,_e=r.isWebGL2===!0&&(Re===t.INT||Re===t.UNSIGNED_INT||ee.gpuType===RZ);if(ee.isInterleavedBufferAttribute){const Le=ee.data,ce=Le.stride,Ie=ee.offset;if(Le.isInstancedInterleavedBuffer){for(let z=0;z<H.locationSize;z++)T(H.location+z,Le.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Le.meshPerAttribute*Le.count)}else for(let z=0;z<H.locationSize;z++)A(H.location+z);t.bindBuffer(t.ARRAY_BUFFER,be);for(let z=0;z<H.locationSize;z++)k(H.location+z,pe/H.locationSize,Re,ie,ce*Z,(Ie+pe/H.locationSize*z)*Z,_e)}else{if(ee.isInstancedBufferAttribute){for(let Le=0;Le<H.locationSize;Le++)T(H.location+Le,ee.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let Le=0;Le<H.locationSize;Le++)A(H.location+Le);t.bindBuffer(t.ARRAY_BUFFER,be);for(let Le=0;Le<H.locationSize;Le++)k(H.location+Le,pe/H.locationSize,Re,ie,pe*Z,pe/H.locationSize*Le*Z,_e)}}else if(J!==void 0){const ie=J[U];if(ie!==void 0)switch(ie.length){case 2:t.vertexAttrib2fv(H.location,ie);break;case 3:t.vertexAttrib3fv(H.location,ie);break;case 4:t.vertexAttrib4fv(H.location,ie);break;default:t.vertexAttrib1fv(H.location,ie)}}}}C()}function N(){O();for(const R in o){const W=o[R];for(const K in W){const G=W[K];for(const te in G)x(G[te].object),delete G[te];delete W[K]}delete o[R]}}function j(R){if(o[R.id]===void 0)return;const W=o[R.id];for(const K in W){const G=W[K];for(const te in G)x(G[te].object),delete G[te];delete W[K]}delete o[R.id]}function I(R){for(const W in o){const K=o[W];if(K[R.id]===void 0)continue;const G=K[R.id];for(const te in G)x(G[te].object),delete G[te];delete K[R.id]}}function O(){q(),d=!0,u!==c&&(u=c,p(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:O,resetDefaultState:q,dispose:N,releaseStatesOfGeometry:j,releaseStatesOfProgram:I,initAttributes:w,enableAttribute:A,disableUnusedAttributes:C}}function zIe(t,e,n,r){const i=r.isWebGL2;let a;function s(d){a=d}function o(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,g){if(g===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](a,d,f,g),n.update(f,a,g)}function u(d,f,g){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<g;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,g);let x=0;for(let v=0;v<g;v++)x+=f[v];n.update(x,a,1)}}this.setMode=s,this.render=o,this.renderInstances=c,this.renderMultiDraw=u}function BIe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const k=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(k.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(k){if(k==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";k="mediump"}return k==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const c=a(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);const u=s||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),y=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,A=s||e.has("OES_texture_float"),T=w&&A,C=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:p,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:y,maxVaryings:b,maxFragmentUniforms:E,vertexTextures:w,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:C}}function HIe(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Iu,o=new fn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const E=a?0:r,w=E*4;let A=b.clippingState||null;c.value=A,A=d(x,g,w,p);for(let T=0;T!==w;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=p+v*4,E=g.matrixWorldInverse;o.getNormalMatrix(E),(y===null||y.length<b)&&(y=new Float32Array(b));for(let w=0,A=p;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(E,o),s.normal.toArray(y,A),y[A+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function $Ie(t){let e=new WeakMap;function n(s,o){return o===OP?s.mapping=Op:o===LP&&(s.mapping=Lp),s}function r(s){if(s&&s.isTexture){const o=s.mapping;if(o===OP||o===LP)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new tLe(c.height/2);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const o=s.target;o.removeEventListener("dispose",i);const c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class VIe extends JZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,o=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Zm=4,K$=[.125,.215,.35,.446,.526,.582],gh=20,_N=new VIe,X$=new $t;let wN=null,SN=0,MN=0;const hh=(1+Math.sqrt(5))/2,Dm=1/hh,Y$=[new De(1,1,1),new De(-1,1,1),new De(1,1,-1),new De(-1,1,-1),new De(0,hh,Dm),new De(0,hh,-Dm),new De(Dm,0,hh),new De(-Dm,0,hh),new De(hh,Dm,0),new De(-hh,Dm,0)];class Z${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){wN=this._renderer.getRenderTarget(),SN=this._renderer.getActiveCubeFace(),MN=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=eV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=J$(),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(wN,SN,MN),e.scissorTest=!1,C_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Op||e.mapping===Lp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),wN=this._renderer.getRenderTarget(),SN=this._renderer.getActiveCubeFace(),MN=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:Qs,minFilter:Qs,generateMipmaps:!1,type:Y0,format:Js,colorSpace:Bc,depthBuffer:!1},i=Q$(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Q$(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=GIe(a)),this._blurMaterial=WIe(a,e,n)}return i}_compileMaterial(e){const n=new Do(this._lodPlanes[0],e);this._renderer.compile(n,_N)}_sceneToCubeUV(e,n,r,i){const o=new ys(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,g=d.toneMapping;d.getClearColor(X$),d.toneMapping=rd,d.autoClear=!1;const p=new XZ({name:"PMREM.Background",side:Qa,depthWrite:!1,depthTest:!1}),x=new Do(new Yb,p);let v=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,v=!0):(p.color.copy(X$),v=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(o.up.set(0,c[b],0),o.lookAt(u[b],0,0)):E===1?(o.up.set(0,0,c[b]),o.lookAt(0,u[b],0)):(o.up.set(0,c[b],0),o.lookAt(0,0,u[b]));const w=this._cubeSize;C_(i,E*w,b>2?w:0,w,w),d.setRenderTarget(i),v&&d.render(x,o),d.render(e,o)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=y}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Op||e.mapping===Lp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=eV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=J$());const a=i?this._cubemapMaterial:this._equirectMaterial,s=new Do(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;const c=this._cubeSize;C_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,_N)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),s=Y$[(i-1)%Y$.length];this._blur(e,i-1,i,a,s)}n.autoClear=r}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,o){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Do(this._lodPlanes[i],u),g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*gh-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):gh;y>gh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${gh}`);const b=[];let E=0;for(let k=0;k<gh;++k){const F=k/v,N=Math.exp(-F*F/2);b.push(N),k===0?E+=N:k<y&&(E+=2*N)}for(let k=0;k<b.length;k++)b[k]=b[k]/E;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-Zm?i-w+Zm:0),C=4*(this._cubeSize-A);C_(n,T,C,3*A,2*A),c.setRenderTarget(n),c.render(f,_N)}}function GIe(t){const e=[],n=[],r=[];let i=t;const a=t-Zm+1+K$.length;for(let s=0;s<a;s++){const o=Math.pow(2,i);n.push(o);let c=1/o;s>t-Zm?c=K$[s-t+Zm-1]:s===0&&(c=0),r.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,y=2,b=1,E=new Float32Array(v*x*p),w=new Float32Array(y*x*p),A=new Float32Array(b*x*p);for(let C=0;C<p;C++){const k=C%3*2/3-1,F=C>2?0:-1,N=[k,F,0,k+2/3,F,0,k+2/3,F+1,0,k,F,0,k+2/3,F+1,0,k,F+1,0];E.set(N,v*x*C),w.set(g,y*x*C);const j=[C,C,C,C,C,C];A.set(j,b*x*C)}const T=new xa;T.setAttribute("position",new As(E,v)),T.setAttribute("uv",new As(w,y)),T.setAttribute("faceIndex",new As(A,b)),e.push(T),i>Zm&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function Q$(t,e,n){const r=new of(t,e,n);return r.texture.mapping=qM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function C_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function WIe(t,e,n){const r=new Float32Array(gh),i=new De(0,1,0);return new _d({name:"SphericalGaussianBlur",defines:{n:gh,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:NO(),fragmentShader:`
  7288. precision mediump float;
  7289. precision mediump int;
  7290. varying vec3 vOutputDirection;
  7291. uniform sampler2D envMap;
  7292. uniform int samples;
  7293. uniform float weights[ n ];
  7294. uniform bool latitudinal;
  7295. uniform float dTheta;
  7296. uniform float mipInt;
  7297. uniform vec3 poleAxis;
  7298. #define ENVMAP_TYPE_CUBE_UV
  7299. #include <cube_uv_reflection_fragment>
  7300. vec3 getSample( float theta, vec3 axis ) {
  7301. float cosTheta = cos( theta );
  7302. // Rodrigues' axis-angle rotation
  7303. vec3 sampleDirection = vOutputDirection * cosTheta
  7304. + cross( axis, vOutputDirection ) * sin( theta )
  7305. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7306. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7307. }
  7308. void main() {
  7309. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7310. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7311. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7312. }
  7313. axis = normalize( axis );
  7314. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7315. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7316. for ( int i = 1; i < n; i++ ) {
  7317. if ( i >= samples ) {
  7318. break;
  7319. }
  7320. float theta = dTheta * float( i );
  7321. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7322. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7323. }
  7324. }
  7325. `,blending:nd,depthTest:!1,depthWrite:!1})}function J$(){return new _d({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:NO(),fragmentShader:`
  7326. precision mediump float;
  7327. precision mediump int;
  7328. varying vec3 vOutputDirection;
  7329. uniform sampler2D envMap;
  7330. #include <common>
  7331. void main() {
  7332. vec3 outputDirection = normalize( vOutputDirection );
  7333. vec2 uv = equirectUv( outputDirection );
  7334. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7335. }
  7336. `,blending:nd,depthTest:!1,depthWrite:!1})}function eV(){return new _d({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:NO(),fragmentShader:`
  7337. precision mediump float;
  7338. precision mediump int;
  7339. uniform float flipEnvMap;
  7340. varying vec3 vOutputDirection;
  7341. uniform samplerCube envMap;
  7342. void main() {
  7343. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7344. }
  7345. `,blending:nd,depthTest:!1,depthWrite:!1})}function NO(){return`
  7346. precision mediump float;
  7347. precision mediump int;
  7348. attribute float faceIndex;
  7349. varying vec3 vOutputDirection;
  7350. // RH coordinate system; PMREM face-indexing convention
  7351. vec3 getDirection( vec2 uv, float face ) {
  7352. uv = 2.0 * uv - 1.0;
  7353. vec3 direction = vec3( uv, 1.0 );
  7354. if ( face == 0.0 ) {
  7355. direction = direction.zyx; // ( 1, v, u ) pos x
  7356. } else if ( face == 1.0 ) {
  7357. direction = direction.xzy;
  7358. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7359. } else if ( face == 2.0 ) {
  7360. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7361. } else if ( face == 3.0 ) {
  7362. direction = direction.zyx;
  7363. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7364. } else if ( face == 4.0 ) {
  7365. direction = direction.xzy;
  7366. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7367. } else if ( face == 5.0 ) {
  7368. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7369. }
  7370. return direction;
  7371. }
  7372. void main() {
  7373. vOutputDirection = getDirection( uv, faceIndex );
  7374. gl_Position = vec4( position, 1.0 );
  7375. }
  7376. `}function qIe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===OP||c===LP,d=c===Op||c===Lp;if(u||d)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new Z$(t)),f=u?n.fromEquirectangular(o,f):n.fromCubemap(o,f),e.set(o,f),f.texture}else{if(e.has(o))return e.get(o).texture;{const f=o.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new Z$(t));const g=u?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,g),o.addEventListener("dispose",a),g.texture}else return null}}}return o}function i(o){let c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function a(o){const c=o.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function KIe(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 XIe(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const v=g.morphAttributes[x];for(let y=0,b=v.length;y<b;y++)e.remove(v[y])}g.removeEventListener("dispose",s),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const v=p[x];for(let y=0,b=v.length;y<b;y++)e.update(v[y],t.ARRAY_BUFFER)}}function u(f){const g=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const E=p.array;v=p.version;for(let w=0,A=E.length;w<A;w+=3){const T=E[w+0],C=E[w+1],k=E[w+2];g.push(T,C,C,k,k,T)}}else if(x!==void 0){const E=x.array;v=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const T=w+0,C=w+1,k=w+2;g.push(T,C,C,k,k,T)}}else return;const y=new($Z(g)?ZZ:YZ)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:o,update:c,getWireframeAttribute:d}}function YIe(t,e,n,r){const i=r.isWebGL2;let a;function s(p){a=p}let o,c;function u(p){o=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(a,x,o,p*c),n.update(x,a,1)}function f(p,x,v){if(v===0)return;let y,b;if(i)y=t,b="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[b](a,x,o,p*c,v),n.update(x,a,v)}function g(p,x,v){if(v===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<v;b++)this.render(p[b]/c,x[b]);else{y.multiDrawElementsWEBGL(a,x,0,o,p,0,v);let b=0;for(let E=0;E<v;E++)b+=x[E];n.update(b,a,1)}}this.setMode=s,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function ZIe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function QIe(t,e){return t[0]-e[0]}function JIe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function e5e(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,s=new Qn,o=[];for(let u=0;u<8;u++)o[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=x!==void 0?x.length:0;let y=a.get(d);if(y===void 0||y.count!==v){let W=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var p=W;y!==void 0&&y.texture.dispose();const w=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],k=d.morphAttributes.normal||[],F=d.morphAttributes.color||[];let N=0;w===!0&&(N=1),A===!0&&(N=2),T===!0&&(N=3);let j=d.attributes.position.count*N,I=1;j>e.maxTextureSize&&(I=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const O=new Float32Array(j*I*4*v),q=new WZ(O,j,I,v);q.type=yc,q.needsUpdate=!0;const R=N*4;for(let K=0;K<v;K++){const G=C[K],te=k[K],Y=F[K],J=j*I*4*K;for(let U=0;U<G.count;U++){const H=U*R;w===!0&&(s.fromBufferAttribute(G,U),O[J+H+0]=s.x,O[J+H+1]=s.y,O[J+H+2]=s.z,O[J+H+3]=0),A===!0&&(s.fromBufferAttribute(te,U),O[J+H+4]=s.x,O[J+H+5]=s.y,O[J+H+6]=s.z,O[J+H+7]=0),T===!0&&(s.fromBufferAttribute(Y,U),O[J+H+8]=s.x,O[J+H+9]=s.y,O[J+H+10]=s.z,O[J+H+11]=Y.itemSize===4?s.w:1)}}y={count:v,texture:q,size:new Zt(j,I)},a.set(d,y),d.addEventListener("dispose",W)}let b=0;for(let w=0;w<g.length;w++)b+=g[w];const E=d.morphTargetsRelative?1:1-b;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",y.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",y.size)}else{const x=g===void 0?0:g.length;let v=r[d.id];if(v===void 0||v.length!==x){v=[];for(let A=0;A<x;A++)v[A]=[A,0];r[d.id]=v}for(let A=0;A<x;A++){const T=v[A];T[0]=A,T[1]=g[A]}v.sort(JIe);for(let A=0;A<8;A++)A<x&&v[A][1]?(o[A][0]=v[A][0],o[A][1]=v[A][1]):(o[A][0]=Number.MAX_SAFE_INTEGER,o[A][1]=0);o.sort(QIe);const y=d.morphAttributes.position,b=d.morphAttributes.normal;let E=0;for(let A=0;A<8;A++){const T=o[A],C=T[0],k=T[1];C!==Number.MAX_SAFE_INTEGER&&k?(y&&d.getAttribute("morphTarget"+A)!==y[C]&&d.setAttribute("morphTarget"+A,y[C]),b&&d.getAttribute("morphNormal"+A)!==b[C]&&d.setAttribute("morphNormal"+A,b[C]),i[A]=k,E+=k):(y&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),b&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const w=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function t5e(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}class nQ extends Ja{constructor(e,n,r,i,a,s,o,c,u,d){if(d=d!==void 0?d:Oh,d!==Oh&&d!==Ip)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Oh&&(r=Ku),r===void 0&&d===Ip&&(r=Dh),super(null,i,a,s,o,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Zi,this.minFilter=c!==void 0?c:Zi,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 rQ=new Ja,iQ=new nQ(1,1);iQ.compareFunction=BZ;const aQ=new WZ,sQ=new UOe,oQ=new eQ,tV=[],nV=[],rV=new Float32Array(16),iV=new Float32Array(9),aV=new Float32Array(4);function mg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=tV[i];if(a===void 0&&(a=new Float32Array(i),tV[i]=a),e!==0){r.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function gi(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 xi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function YM(t,e){let n=nV[e];n===void 0&&(n=new Int32Array(e),nV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function n5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function r5e(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(gi(n,e))return;t.uniform2fv(this.addr,e),xi(n,e)}}function i5e(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(gi(n,e))return;t.uniform3fv(this.addr,e),xi(n,e)}}function a5e(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(gi(n,e))return;t.uniform4fv(this.addr,e),xi(n,e)}}function s5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;aV.set(r),t.uniformMatrix2fv(this.addr,!1,aV),xi(n,r)}}function o5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;iV.set(r),t.uniformMatrix3fv(this.addr,!1,iV),xi(n,r)}}function l5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;rV.set(r),t.uniformMatrix4fv(this.addr,!1,rV),xi(n,r)}}function c5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function u5e(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(gi(n,e))return;t.uniform2iv(this.addr,e),xi(n,e)}}function d5e(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(gi(n,e))return;t.uniform3iv(this.addr,e),xi(n,e)}}function h5e(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(gi(n,e))return;t.uniform4iv(this.addr,e),xi(n,e)}}function f5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function m5e(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(gi(n,e))return;t.uniform2uiv(this.addr,e),xi(n,e)}}function p5e(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(gi(n,e))return;t.uniform3uiv(this.addr,e),xi(n,e)}}function g5e(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(gi(n,e))return;t.uniform4uiv(this.addr,e),xi(n,e)}}function x5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?iQ:rQ;n.setTexture2D(e||a,i)}function b5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||sQ,i)}function y5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||oQ,i)}function v5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||aQ,i)}function _5e(t){switch(t){case 5126:return n5e;case 35664:return r5e;case 35665:return i5e;case 35666:return a5e;case 35674:return s5e;case 35675:return o5e;case 35676:return l5e;case 5124:case 35670:return c5e;case 35667:case 35671:return u5e;case 35668:case 35672:return d5e;case 35669:case 35673:return h5e;case 5125:return f5e;case 36294:return m5e;case 36295:return p5e;case 36296:return g5e;case 35678:case 36198:case 36298:case 36306:case 35682:return x5e;case 35679:case 36299:case 36307:return b5e;case 35680:case 36300:case 36308:case 36293:return y5e;case 36289:case 36303:case 36311:case 36292:return v5e}}function w5e(t,e){t.uniform1fv(this.addr,e)}function S5e(t,e){const n=mg(e,this.size,2);t.uniform2fv(this.addr,n)}function M5e(t,e){const n=mg(e,this.size,3);t.uniform3fv(this.addr,n)}function E5e(t,e){const n=mg(e,this.size,4);t.uniform4fv(this.addr,n)}function A5e(t,e){const n=mg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function T5e(t,e){const n=mg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function C5e(t,e){const n=mg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function N5e(t,e){t.uniform1iv(this.addr,e)}function k5e(t,e){t.uniform2iv(this.addr,e)}function P5e(t,e){t.uniform3iv(this.addr,e)}function R5e(t,e){t.uniform4iv(this.addr,e)}function j5e(t,e){t.uniform1uiv(this.addr,e)}function D5e(t,e){t.uniform2uiv(this.addr,e)}function O5e(t,e){t.uniform3uiv(this.addr,e)}function L5e(t,e){t.uniform4uiv(this.addr,e)}function I5e(t,e,n){const r=this.cache,i=e.length,a=YM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||rQ,a[s])}function F5e(t,e,n){const r=this.cache,i=e.length,a=YM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||sQ,a[s])}function U5e(t,e,n){const r=this.cache,i=e.length,a=YM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||oQ,a[s])}function z5e(t,e,n){const r=this.cache,i=e.length,a=YM(n,i);gi(r,a)||(t.uniform1iv(this.addr,a),xi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||aQ,a[s])}function B5e(t){switch(t){case 5126:return w5e;case 35664:return S5e;case 35665:return M5e;case 35666:return E5e;case 35674:return A5e;case 35675:return T5e;case 35676:return C5e;case 5124:case 35670:return N5e;case 35667:case 35671:return k5e;case 35668:case 35672:return P5e;case 35669:case 35673:return R5e;case 5125:return j5e;case 36294:return D5e;case 36295:return O5e;case 36296:return L5e;case 35678:case 36198:case 36298:case 36306:case 35682:return I5e;case 35679:case 36299:case 36307:return F5e;case 35680:case 36300:case 36308:case 36293:return U5e;case 36289:case 36303:case 36311:case 36292:return z5e}}class H5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=_5e(n.type)}}class $5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=B5e(n.type)}}class V5e{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const o=i[a];o.setValue(e,n[o.id],r)}}}const EN=/(\w+)(\])?(\[|\.)?/g;function sV(t,e){t.seq.push(e),t.map[e.id]=e}function G5e(t,e,n){const r=t.name,i=r.length;for(EN.lastIndex=0;;){const a=EN.exec(r),s=EN.lastIndex;let o=a[1];const c=a[2]==="]",u=a[3];if(c&&(o=o|0),u===void 0||u==="["&&s+2===i){sV(n,u===void 0?new H5e(o,t,e):new $5e(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new V5e(o),sV(n,f)),n=f}}}class x1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),s=e.getUniformLocation(n,a.name);G5e(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const o=n[a],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}}function oV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const W5e=37297;let q5e=0;function K5e(t,e){const n=t.split(`
  7377. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const o=s+1;r.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return r.join(`
  7378. `)}function X5e(t){const e=Yn.getPrimaries(Yn.workingColorSpace),n=Yn.getPrimaries(t);let r;switch(e===n?r="":e===Bw&&n===zw?r="LinearDisplayP3ToLinearSRGB":e===zw&&n===Bw&&(r="LinearSRGBToLinearDisplayP3"),t){case Bc:case KM:return[r,"LinearTransferOETF"];case Qi:case MO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function lV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const s=parseInt(a[1]);return n.toUpperCase()+`
  7379. `+i+`
  7380. `+K5e(t.getShaderSource(e),s)}else return i}function Y5e(t,e){const n=X5e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function Z5e(t,e){let n;switch(e){case YDe:n="Linear";break;case ZDe:n="Reinhard";break;case QDe:n="OptimizedCineon";break;case JDe:n="ACESFilmic";break;case eOe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Q5e(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(Hx).join(`
  7381. `)}function J5e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7382. `)}function eFe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Hx(t){return t!==""}function cV(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 uV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const tFe=/^[ \t]*#include +<([\w\d./]+)>/gm;function HP(t){return t.replace(tFe,rFe)}const nFe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function rFe(t,e){let n=ln[e];if(n===void 0){const r=nFe.get(e);if(r!==void 0)n=ln[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 HP(n)}const iFe=/#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 dV(t){return t.replace(iFe,aFe)}function aFe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function hV(t){let e="precision "+t.precision+` float;
  7383. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7384. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7385. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7386. #define LOW_PRECISION`),e}function sFe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===kZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===MDe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===sc&&(e="SHADOWMAP_TYPE_VSM"),e}function oFe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Op:case Lp:e="ENVMAP_TYPE_CUBE";break;case qM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function lFe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Lp:e="ENVMAP_MODE_REFRACTION";break}return e}function cFe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case wO:e="ENVMAP_BLENDING_MULTIPLY";break;case KDe:e="ENVMAP_BLENDING_MIX";break;case XDe:e="ENVMAP_BLENDING_ADD";break}return e}function uFe(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 dFe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const c=sFe(n),u=oFe(n),d=lFe(n),f=cFe(n),g=uFe(n),p=n.isWebGL2?"":Q5e(n),x=J5e(a),v=i.createProgram();let y,b,E=n.glslVersion?"#version "+n.glslVersion+`
  7387. `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Hx).join(`
  7388. `),y.length>0&&(y+=`
  7389. `),b=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Hx).join(`
  7390. `),b.length>0&&(b+=`
  7391. `)):(y=[hV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7392. `].filter(Hx).join(`
  7393. `),b=[p,hV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",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 "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==rd?"#define TONE_MAPPING":"",n.toneMapping!==rd?ln.tonemapping_pars_fragment:"",n.toneMapping!==rd?Z5e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ln.colorspace_pars_fragment,Y5e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7394. `].filter(Hx).join(`
  7395. `)),s=HP(s),s=cV(s,n),s=uV(s,n),o=HP(o),o=cV(o,n),o=uV(o,n),s=dV(s),o=dV(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
  7396. `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7397. `)+`
  7398. `+y,b=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===k$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===k$?"":"#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(`
  7399. `)+`
  7400. `+b);const w=E+y+s,A=E+b+o,T=oV(i,i.VERTEX_SHADER,w),C=oV(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function k(I){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(v).trim(),q=i.getShaderInfoLog(T).trim(),R=i.getShaderInfoLog(C).trim();let W=!0,K=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,C);else{const G=lV(i,T,"vertex"),te=lV(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  7401. Program Info Log: `+O+`
  7402. `+G+`
  7403. `+te)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||R==="")&&(K=!1);K&&(I.diagnostics={runnable:W,programLog:O,vertexShader:{log:q,prefix:y},fragmentShader:{log:R,prefix:b}})}i.deleteShader(T),i.deleteShader(C),F=new x1(i,v),N=eFe(i,v)}let F;this.getUniforms=function(){return F===void 0&&k(this),F};let N;this.getAttributes=function(){return N===void 0&&k(this),N};let j=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=i.getProgramParameter(v,W5e)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=q5e++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=C,this}let hFe=0;class fFe{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new mFe(e),n.set(e,r)),r}}class mFe{constructor(e){this.id=hFe++,this.code=e,this.usedTimes=0}}function pFe(t,e,n,r,i,a,s){const o=new qZ,c=new fFe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(N){return N===0?"uv":`uv${N}`}function y(N,j,I,O,q){const R=O.fog,W=q.geometry,K=N.isMeshStandardMaterial?O.environment:null,G=(N.isMeshStandardMaterial?n:e).get(N.envMap||K),te=G&&G.mapping===qM?G.image.height:null,Y=x[N.type];N.precision!==null&&(p=i.getMaxPrecision(N.precision),p!==N.precision&&console.warn("THREE.WebGLProgram.getParameters:",N.precision,"not supported, using",p,"instead."));const J=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=J!==void 0?J.length:0;let H=0;W.morphAttributes.position!==void 0&&(H=1),W.morphAttributes.normal!==void 0&&(H=2),W.morphAttributes.color!==void 0&&(H=3);let ee,ie,pe,ue;if(Y){const Qt=qa[Y];ee=Qt.vertexShader,ie=Qt.fragmentShader}else ee=N.vertexShader,ie=N.fragmentShader,c.update(N),pe=c.getVertexShaderID(N),ue=c.getFragmentShaderID(N);const be=t.getRenderTarget(),Re=q.isInstancedMesh===!0,Z=q.isBatchedMesh===!0,_e=!!N.map,Le=!!N.matcap,ce=!!G,Ie=!!N.aoMap,z=!!N.lightMap,B=!!N.bumpMap,ne=!!N.normalMap,V=!!N.displacementMap,Q=!!N.emissiveMap,se=!!N.metalnessMap,Me=!!N.roughnessMap,Ae=N.anisotropy>0,Se=N.clearcoat>0,$=N.iridescence>0,L=N.sheen>0,re=N.transmission>0,ye=Ae&&!!N.anisotropyMap,we=Se&&!!N.clearcoatMap,xe=Se&&!!N.clearcoatNormalMap,rt=Se&&!!N.clearcoatRoughnessMap,He=$&&!!N.iridescenceMap,he=$&&!!N.iridescenceThicknessMap,Ge=L&&!!N.sheenColorMap,Ue=L&&!!N.sheenRoughnessMap,oe=!!N.specularMap,tt=!!N.specularColorMap,$e=!!N.specularIntensityMap,Ye=re&&!!N.transmissionMap,ut=re&&!!N.thicknessMap,fe=!!N.gradientMap,Qe=!!N.alphaMap,ge=N.alphaTest>0,ze=!!N.alphaHash,ke=!!N.extensions,ve=!!W.attributes.uv1,de=!!W.attributes.uv2,ot=!!W.attributes.uv3;let xt=rd;return N.toneMapped&&(be===null||be.isXRRenderTarget===!0)&&(xt=t.toneMapping),{isWebGL2:d,shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:ee,fragmentShader:ie,defines:N.defines,customVertexShaderID:pe,customFragmentShaderID:ue,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:p,batching:Z,instancing:Re,instancingColor:Re&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:be===null?t.outputColorSpace:be.isXRRenderTarget===!0?be.texture.colorSpace:Bc,map:_e,matcap:Le,envMap:ce,envMapMode:ce&&G.mapping,envMapCubeUVHeight:te,aoMap:Ie,lightMap:z,bumpMap:B,normalMap:ne,displacementMap:g&&V,emissiveMap:Q,normalMapObjectSpace:ne&&N.normalMapType===hOe,normalMapTangentSpace:ne&&N.normalMapType===zZ,metalnessMap:se,roughnessMap:Me,anisotropy:Ae,anisotropyMap:ye,clearcoat:Se,clearcoatMap:we,clearcoatNormalMap:xe,clearcoatRoughnessMap:rt,iridescence:$,iridescenceMap:He,iridescenceThicknessMap:he,sheen:L,sheenColorMap:Ge,sheenRoughnessMap:Ue,specularMap:oe,specularColorMap:tt,specularIntensityMap:$e,transmission:re,transmissionMap:Ye,thicknessMap:ut,gradientMap:fe,opaque:N.transparent===!1&&N.blending===lp,alphaMap:Qe,alphaTest:ge,alphaHash:ze,combine:N.combine,mapUv:_e&&v(N.map.channel),aoMapUv:Ie&&v(N.aoMap.channel),lightMapUv:z&&v(N.lightMap.channel),bumpMapUv:B&&v(N.bumpMap.channel),normalMapUv:ne&&v(N.normalMap.channel),displacementMapUv:V&&v(N.displacementMap.channel),emissiveMapUv:Q&&v(N.emissiveMap.channel),metalnessMapUv:se&&v(N.metalnessMap.channel),roughnessMapUv:Me&&v(N.roughnessMap.channel),anisotropyMapUv:ye&&v(N.anisotropyMap.channel),clearcoatMapUv:we&&v(N.clearcoatMap.channel),clearcoatNormalMapUv:xe&&v(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:rt&&v(N.clearcoatRoughnessMap.channel),iridescenceMapUv:He&&v(N.iridescenceMap.channel),iridescenceThicknessMapUv:he&&v(N.iridescenceThicknessMap.channel),sheenColorMapUv:Ge&&v(N.sheenColorMap.channel),sheenRoughnessMapUv:Ue&&v(N.sheenRoughnessMap.channel),specularMapUv:oe&&v(N.specularMap.channel),specularColorMapUv:tt&&v(N.specularColorMap.channel),specularIntensityMapUv:$e&&v(N.specularIntensityMap.channel),transmissionMapUv:Ye&&v(N.transmissionMap.channel),thicknessMapUv:ut&&v(N.thicknessMap.channel),alphaMapUv:Qe&&v(N.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ne||Ae),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:ve,vertexUv2s:de,vertexUv3s:ot,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(_e||Qe),fog:!!R,useFog:N.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:N.flatShading===!0,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:H,numDirLights:j.directional.length,numPointLights:j.point.length,numSpotLights:j.spot.length,numSpotLightMaps:j.spotLightMap.length,numRectAreaLights:j.rectArea.length,numHemiLights:j.hemi.length,numDirLightShadows:j.directionalShadowMap.length,numPointLightShadows:j.pointShadowMap.length,numSpotLightShadows:j.spotShadowMap.length,numSpotLightShadowsWithMaps:j.numSpotLightShadowsWithMaps,numLightProbes:j.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&I.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:_e&&N.map.isVideoTexture===!0&&Yn.getTransfer(N.map.colorSpace)===ur,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===hc,flipSided:N.side===Qa,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionDerivatives:ke&&N.extensions.derivatives===!0,extensionFragDepth:ke&&N.extensions.fragDepth===!0,extensionDrawBuffers:ke&&N.extensions.drawBuffers===!0,extensionShaderTextureLOD:ke&&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 b(N){const j=[];if(N.shaderID?j.push(N.shaderID):(j.push(N.customVertexShaderID),j.push(N.customFragmentShaderID)),N.defines!==void 0)for(const I in N.defines)j.push(I),j.push(N.defines[I]);return N.isRawShaderMaterial===!1&&(E(j,N),w(j,N),j.push(t.outputColorSpace)),j.push(N.customProgramCacheKey),j.join()}function E(N,j){N.push(j.precision),N.push(j.outputColorSpace),N.push(j.envMapMode),N.push(j.envMapCubeUVHeight),N.push(j.mapUv),N.push(j.alphaMapUv),N.push(j.lightMapUv),N.push(j.aoMapUv),N.push(j.bumpMapUv),N.push(j.normalMapUv),N.push(j.displacementMapUv),N.push(j.emissiveMapUv),N.push(j.metalnessMapUv),N.push(j.roughnessMapUv),N.push(j.anisotropyMapUv),N.push(j.clearcoatMapUv),N.push(j.clearcoatNormalMapUv),N.push(j.clearcoatRoughnessMapUv),N.push(j.iridescenceMapUv),N.push(j.iridescenceThicknessMapUv),N.push(j.sheenColorMapUv),N.push(j.sheenRoughnessMapUv),N.push(j.specularMapUv),N.push(j.specularColorMapUv),N.push(j.specularIntensityMapUv),N.push(j.transmissionMapUv),N.push(j.thicknessMapUv),N.push(j.combine),N.push(j.fogExp2),N.push(j.sizeAttenuation),N.push(j.morphTargetsCount),N.push(j.morphAttributeCount),N.push(j.numDirLights),N.push(j.numPointLights),N.push(j.numSpotLights),N.push(j.numSpotLightMaps),N.push(j.numHemiLights),N.push(j.numRectAreaLights),N.push(j.numDirLightShadows),N.push(j.numPointLightShadows),N.push(j.numSpotLightShadows),N.push(j.numSpotLightShadowsWithMaps),N.push(j.numLightProbes),N.push(j.shadowMapType),N.push(j.toneMapping),N.push(j.numClippingPlanes),N.push(j.numClipIntersection),N.push(j.depthPacking)}function w(N,j){o.disableAll(),j.isWebGL2&&o.enable(0),j.supportsVertexTextures&&o.enable(1),j.instancing&&o.enable(2),j.instancingColor&&o.enable(3),j.matcap&&o.enable(4),j.envMap&&o.enable(5),j.normalMapObjectSpace&&o.enable(6),j.normalMapTangentSpace&&o.enable(7),j.clearcoat&&o.enable(8),j.iridescence&&o.enable(9),j.alphaTest&&o.enable(10),j.vertexColors&&o.enable(11),j.vertexAlphas&&o.enable(12),j.vertexUv1s&&o.enable(13),j.vertexUv2s&&o.enable(14),j.vertexUv3s&&o.enable(15),j.vertexTangents&&o.enable(16),j.anisotropy&&o.enable(17),j.alphaHash&&o.enable(18),j.batching&&o.enable(19),N.push(o.mask),o.disableAll(),j.fog&&o.enable(0),j.useFog&&o.enable(1),j.flatShading&&o.enable(2),j.logarithmicDepthBuffer&&o.enable(3),j.skinning&&o.enable(4),j.morphTargets&&o.enable(5),j.morphNormals&&o.enable(6),j.morphColors&&o.enable(7),j.premultipliedAlpha&&o.enable(8),j.shadowMapEnabled&&o.enable(9),j.useLegacyLights&&o.enable(10),j.doubleSided&&o.enable(11),j.flipSided&&o.enable(12),j.useDepthPacking&&o.enable(13),j.dithering&&o.enable(14),j.transmission&&o.enable(15),j.sheen&&o.enable(16),j.opaque&&o.enable(17),j.pointsUvs&&o.enable(18),j.decodeVideoTexture&&o.enable(19),N.push(o.mask)}function A(N){const j=x[N.type];let I;if(j){const O=qa[j];I=TO.clone(O.uniforms)}else I=N.uniforms;return I}function T(N,j){let I;for(let O=0,q=u.length;O<q;O++){const R=u[O];if(R.cacheKey===j){I=R,++I.usedTimes;break}}return I===void 0&&(I=new dFe(t,j,N,a),u.push(I)),I}function C(N){if(--N.usedTimes===0){const j=u.indexOf(N);u[j]=u[u.length-1],u.pop(),N.destroy()}}function k(N){c.remove(N)}function F(){c.dispose()}return{getParameters:y,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:C,releaseShaderCache:k,programs:u,dispose:F}}function gFe(){let t=new WeakMap;function e(a){let s=t.get(a);return s===void 0&&(s={},t.set(a,s)),s}function n(a){t.delete(a)}function r(a,s,o){t.get(a)[s]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function xFe(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 fV(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 mV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,p,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=p,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=v,b.group=y),e++,b}function o(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.push(b):p.transparent===!0?i.push(b):n.push(b)}function c(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.unshift(b):p.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||xFe),r.length>1&&r.sort(g||fV),i.length>1&&i.sort(g||fV)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:o,unshift:c,finish:d,sort:u}}function bFe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new mV,t.set(r,[s])):i>=a.length?(s=new mV,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function yFe(){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 De,color:new $t};break;case"SpotLight":n={position:new De,direction:new De,color:new $t,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new De,color:new $t,distance:0,decay:0};break;case"HemisphereLight":n={direction:new De,skyColor:new $t,groundColor:new $t};break;case"RectAreaLight":n={color:new $t,position:new De,halfWidth:new De,halfHeight:new De};break}return t[e.id]=n,n}}}function vFe(){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 Zt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let _Fe=0;function wFe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function SFe(t,e){const n=new yFe,r=vFe(),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 De);const a=new De,s=new or,o=new or;function c(d,f){let g=0,p=0,x=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let v=0,y=0,b=0,E=0,w=0,A=0,T=0,C=0,k=0,F=0,N=0;d.sort(wFe);const j=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const R=d[O],W=R.color,K=R.intensity,G=R.distance,te=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=W.r*K*j,p+=W.g*K*j,x+=W.b*K*j;else if(R.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(R.sh.coefficients[Y],K);N++}else if(R.isDirectionalLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*j),R.castShadow){const J=R.shadow,U=r.get(R);U.shadowBias=J.bias,U.shadowNormalBias=J.normalBias,U.shadowRadius=J.radius,U.shadowMapSize=J.mapSize,i.directionalShadow[v]=U,i.directionalShadowMap[v]=te,i.directionalShadowMatrix[v]=R.shadow.matrix,A++}i.directional[v]=Y,v++}else if(R.isSpotLight){const Y=n.get(R);Y.position.setFromMatrixPosition(R.matrixWorld),Y.color.copy(W).multiplyScalar(K*j),Y.distance=G,Y.coneCos=Math.cos(R.angle),Y.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Y.decay=R.decay,i.spot[b]=Y;const J=R.shadow;if(R.map&&(i.spotLightMap[k]=R.map,k++,J.updateMatrices(R),R.castShadow&&F++),i.spotLightMatrix[b]=J.matrix,R.castShadow){const U=r.get(R);U.shadowBias=J.bias,U.shadowNormalBias=J.normalBias,U.shadowRadius=J.radius,U.shadowMapSize=J.mapSize,i.spotShadow[b]=U,i.spotShadowMap[b]=te,C++}b++}else if(R.isRectAreaLight){const Y=n.get(R);Y.color.copy(W).multiplyScalar(K),Y.halfWidth.set(R.width*.5,0,0),Y.halfHeight.set(0,R.height*.5,0),i.rectArea[E]=Y,E++}else if(R.isPointLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*j),Y.distance=R.distance,Y.decay=R.decay,R.castShadow){const J=R.shadow,U=r.get(R);U.shadowBias=J.bias,U.shadowNormalBias=J.normalBias,U.shadowRadius=J.radius,U.shadowMapSize=J.mapSize,U.shadowCameraNear=J.camera.near,U.shadowCameraFar=J.camera.far,i.pointShadow[y]=U,i.pointShadowMap[y]=te,i.pointShadowMatrix[y]=R.shadow.matrix,T++}i.point[y]=Y,y++}else if(R.isHemisphereLight){const Y=n.get(R);Y.skyColor.copy(R.color).multiplyScalar(K*j),Y.groundColor.copy(R.groundColor).multiplyScalar(K*j),i.hemi[w]=Y,w++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=St.LTC_FLOAT_1,i.rectAreaLTC2=St.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=St.LTC_HALF_1,i.rectAreaLTC2=St.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=p,i.ambient[2]=x;const I=i.hash;(I.directionalLength!==v||I.pointLength!==y||I.spotLength!==b||I.rectAreaLength!==E||I.hemiLength!==w||I.numDirectionalShadows!==A||I.numPointShadows!==T||I.numSpotShadows!==C||I.numSpotMaps!==k||I.numLightProbes!==N)&&(i.directional.length=v,i.spot.length=b,i.rectArea.length=E,i.point.length=y,i.hemi.length=w,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=C+k-F,i.spotLightMap.length=k,i.numSpotLightShadowsWithMaps=F,i.numLightProbes=N,I.directionalLength=v,I.pointLength=y,I.spotLength=b,I.rectAreaLength=E,I.hemiLength=w,I.numDirectionalShadows=A,I.numPointShadows=T,I.numSpotShadows=C,I.numSpotMaps=k,I.numLightProbes=N,i.version=_Fe++)}function u(d,f){let g=0,p=0,x=0,v=0,y=0;const b=f.matrixWorldInverse;for(let E=0,w=d.length;E<w;E++){const A=d[E];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(b),g++}else if(A.isSpotLight){const T=i.spot[x];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(b),x++}else if(A.isRectAreaLight){const T=i.rectArea[v];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),o.identity(),s.copy(A.matrixWorld),s.premultiply(b),o.extractRotation(s),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),v++}else if(A.isPointLight){const T=i.point[p];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),p++}else if(A.isHemisphereLight){const T=i.hemi[y];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(b),y++}}}return{setup:c,setupView:u,state:i}}function pV(t,e){const n=new SFe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function s(f){r.push(f)}function o(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:s,pushShadow:o}}function MFe(t,e){let n=new WeakMap;function r(a,s=0){const o=n.get(a);let c;return o===void 0?(c=new pV(t,e),n.set(a,[c])):s>=o.length?(c=new pV(t,e),o.push(c)):c=o[s],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class EFe extends fg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=uOe,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 AFe extends fg{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 TFe=`void main() {
  7404. gl_Position = vec4( position, 1.0 );
  7405. }`,CFe=`uniform sampler2D shadow_pass;
  7406. uniform vec2 resolution;
  7407. uniform float radius;
  7408. #include <packing>
  7409. void main() {
  7410. const float samples = float( VSM_SAMPLES );
  7411. float mean = 0.0;
  7412. float squared_mean = 0.0;
  7413. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7414. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7415. for ( float i = 0.0; i < samples; i ++ ) {
  7416. float uvOffset = uvStart + i * uvStride;
  7417. #ifdef HORIZONTAL_PASS
  7418. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7419. mean += distribution.x;
  7420. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7421. #else
  7422. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7423. mean += depth;
  7424. squared_mean += depth * depth;
  7425. #endif
  7426. }
  7427. mean = mean / samples;
  7428. squared_mean = squared_mean / samples;
  7429. float std_dev = sqrt( squared_mean - mean * mean );
  7430. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7431. }`;function NFe(t,e,n){let r=new XM;const i=new Zt,a=new Zt,s=new Qn,o=new EFe({depthPacking:dOe}),c=new AFe,u={},d=n.maxTextureSize,f={[vd]:Qa,[Qa]:vd,[hc]:hc},g=new _d({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Zt},radius:{value:4}},vertexShader:TFe,fragmentShader:CFe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new xa;x.setAttribute("position",new As(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Do(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=kZ;let b=this.type;this.render=function(T,C,k){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||T.length===0)return;const F=t.getRenderTarget(),N=t.getActiveCubeFace(),j=t.getActiveMipmapLevel(),I=t.state;I.setBlending(nd),I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const O=b!==sc&&this.type===sc,q=b===sc&&this.type!==sc;for(let R=0,W=T.length;R<W;R++){const K=T[R],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 te=G.getFrameExtents();if(i.multiply(te),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/te.x),i.x=a.x*te.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/te.y),i.y=a.y*te.y,G.mapSize.y=a.y)),G.map===null||O===!0||q===!0){const J=this.type!==sc?{minFilter:Zi,magFilter:Zi}:{};G.map!==null&&G.map.dispose(),G.map=new of(i.x,i.y,J),G.map.texture.name=K.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const Y=G.getViewportCount();for(let J=0;J<Y;J++){const U=G.getViewport(J);s.set(a.x*U.x,a.y*U.y,a.x*U.z,a.y*U.w),I.viewport(s),G.updateMatrices(K,J),r=G.getFrustum(),A(C,k,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===sc&&E(G,k),G.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(F,N,j)};function E(T,C){const k=e.update(v);g.defines.VSM_SAMPLES!==T.blurSamples&&(g.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new of(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(C,null,k,g,v,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(C,null,k,p,v,null)}function w(T,C,k,F){let N=null;const j=k.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(j!==void 0)N=j;else if(N=k.isPointLight===!0?c: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){const I=N.uuid,O=C.uuid;let q=u[I];q===void 0&&(q={},u[I]=q);let R=q[O];R===void 0&&(R=N.clone(),q[O]=R),N=R}if(N.visible=C.visible,N.wireframe=C.wireframe,F===sc?N.side=C.shadowSide!==null?C.shadowSide:C.side:N.side=C.shadowSide!==null?C.shadowSide:f[C.side],N.alphaMap=C.alphaMap,N.alphaTest=C.alphaTest,N.map=C.map,N.clipShadows=C.clipShadows,N.clippingPlanes=C.clippingPlanes,N.clipIntersection=C.clipIntersection,N.displacementMap=C.displacementMap,N.displacementScale=C.displacementScale,N.displacementBias=C.displacementBias,N.wireframeLinewidth=C.wireframeLinewidth,N.linewidth=C.linewidth,k.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const I=t.properties.get(N);I.light=k}return N}function A(T,C,k,F,N){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&N===sc)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,T.matrixWorld);const O=e.update(T),q=T.material;if(Array.isArray(q)){const R=O.groups;for(let W=0,K=R.length;W<K;W++){const G=R[W],te=q[G.materialIndex];if(te&&te.visible){const Y=w(T,te,F,N);T.onBeforeShadow(t,T,C,k,O,Y,G),t.renderBufferDirect(k,null,O,Y,T,G),T.onAfterShadow(t,T,C,k,O,Y,G)}}}else if(q.visible){const R=w(T,q,F,N);T.onBeforeShadow(t,T,C,k,O,R,null),t.renderBufferDirect(k,null,O,R,T,null),T.onAfterShadow(t,T,C,k,O,R,null)}}const I=T.children;for(let O=0,q=I.length;O<q;O++)A(I[O],C,k,F,N)}}function kFe(t,e,n){const r=n.isWebGL2;function i(){let ge=!1;const ze=new Qn;let ke=null;const ve=new Qn(0,0,0,0);return{setMask:function(de){ke!==de&&!ge&&(t.colorMask(de,de,de,de),ke=de)},setLocked:function(de){ge=de},setClear:function(de,ot,xt,Et,Qt){Qt===!0&&(de*=Et,ot*=Et,xt*=Et),ze.set(de,ot,xt,Et),ve.equals(ze)===!1&&(t.clearColor(de,ot,xt,Et),ve.copy(ze))},reset:function(){ge=!1,ke=null,ve.set(-1,0,0,0)}}}function a(){let ge=!1,ze=null,ke=null,ve=null;return{setTest:function(de){de?Z(t.DEPTH_TEST):_e(t.DEPTH_TEST)},setMask:function(de){ze!==de&&!ge&&(t.depthMask(de),ze=de)},setFunc:function(de){if(ke!==de){switch(de){case BDe:t.depthFunc(t.NEVER);break;case HDe:t.depthFunc(t.ALWAYS);break;case $De:t.depthFunc(t.LESS);break;case Fw:t.depthFunc(t.LEQUAL);break;case VDe:t.depthFunc(t.EQUAL);break;case GDe:t.depthFunc(t.GEQUAL);break;case WDe:t.depthFunc(t.GREATER);break;case qDe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ke=de}},setLocked:function(de){ge=de},setClear:function(de){ve!==de&&(t.clearDepth(de),ve=de)},reset:function(){ge=!1,ze=null,ke=null,ve=null}}}function s(){let ge=!1,ze=null,ke=null,ve=null,de=null,ot=null,xt=null,Et=null,Qt=null;return{setTest:function(Ot){ge||(Ot?Z(t.STENCIL_TEST):_e(t.STENCIL_TEST))},setMask:function(Ot){ze!==Ot&&!ge&&(t.stencilMask(Ot),ze=Ot)},setFunc:function(Ot,Vt,On){(ke!==Ot||ve!==Vt||de!==On)&&(t.stencilFunc(Ot,Vt,On),ke=Ot,ve=Vt,de=On)},setOp:function(Ot,Vt,On){(ot!==Ot||xt!==Vt||Et!==On)&&(t.stencilOp(Ot,Vt,On),ot=Ot,xt=Vt,Et=On)},setLocked:function(Ot){ge=Ot},setClear:function(Ot){Qt!==Ot&&(t.clearStencil(Ot),Qt=Ot)},reset:function(){ge=!1,ze=null,ke=null,ve=null,de=null,ot=null,xt=null,Et=null,Qt=null}}}const o=new i,c=new a,u=new s,d=new WeakMap,f=new WeakMap;let g={},p={},x=new WeakMap,v=[],y=null,b=!1,E=null,w=null,A=null,T=null,C=null,k=null,F=null,N=new $t(0,0,0),j=0,I=!1,O=null,q=null,R=null,W=null,K=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let te=!1,Y=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(J)[1]),te=Y>=1):J.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),te=Y>=2);let U=null,H={};const ee=t.getParameter(t.SCISSOR_BOX),ie=t.getParameter(t.VIEWPORT),pe=new Qn().fromArray(ee),ue=new Qn().fromArray(ie);function be(ge,ze,ke,ve){const de=new Uint8Array(4),ot=t.createTexture();t.bindTexture(ge,ot),t.texParameteri(ge,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ge,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let xt=0;xt<ke;xt++)r&&(ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY)?t.texImage3D(ze,0,t.RGBA,1,1,ve,0,t.RGBA,t.UNSIGNED_BYTE,de):t.texImage2D(ze+xt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,de);return ot}const Re={};Re[t.TEXTURE_2D]=be(t.TEXTURE_2D,t.TEXTURE_2D,1),Re[t.TEXTURE_CUBE_MAP]=be(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Re[t.TEXTURE_2D_ARRAY]=be(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Re[t.TEXTURE_3D]=be(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),u.setClear(0),Z(t.DEPTH_TEST),c.setFunc(Fw),Q(!1),se(ZH),Z(t.CULL_FACE),ne(nd);function Z(ge){g[ge]!==!0&&(t.enable(ge),g[ge]=!0)}function _e(ge){g[ge]!==!1&&(t.disable(ge),g[ge]=!1)}function Le(ge,ze){return p[ge]!==ze?(t.bindFramebuffer(ge,ze),p[ge]=ze,r&&(ge===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=ze),ge===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=ze)),!0):!1}function ce(ge,ze){let ke=v,ve=!1;if(ge)if(ke=x.get(ze),ke===void 0&&(ke=[],x.set(ze,ke)),ge.isWebGLMultipleRenderTargets){const de=ge.texture;if(ke.length!==de.length||ke[0]!==t.COLOR_ATTACHMENT0){for(let ot=0,xt=de.length;ot<xt;ot++)ke[ot]=t.COLOR_ATTACHMENT0+ot;ke.length=de.length,ve=!0}}else ke[0]!==t.COLOR_ATTACHMENT0&&(ke[0]=t.COLOR_ATTACHMENT0,ve=!0);else ke[0]!==t.BACK&&(ke[0]=t.BACK,ve=!0);ve&&(n.isWebGL2?t.drawBuffers(ke):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ke))}function Ie(ge){return y!==ge?(t.useProgram(ge),y=ge,!0):!1}const z={[ph]:t.FUNC_ADD,[ADe]:t.FUNC_SUBTRACT,[TDe]:t.FUNC_REVERSE_SUBTRACT};if(r)z[t$]=t.MIN,z[n$]=t.MAX;else{const ge=e.get("EXT_blend_minmax");ge!==null&&(z[t$]=ge.MIN_EXT,z[n$]=ge.MAX_EXT)}const B={[CDe]:t.ZERO,[NDe]:t.ONE,[kDe]:t.SRC_COLOR,[jP]:t.SRC_ALPHA,[LDe]:t.SRC_ALPHA_SATURATE,[DDe]:t.DST_COLOR,[RDe]:t.DST_ALPHA,[PDe]:t.ONE_MINUS_SRC_COLOR,[DP]:t.ONE_MINUS_SRC_ALPHA,[ODe]:t.ONE_MINUS_DST_COLOR,[jDe]:t.ONE_MINUS_DST_ALPHA,[IDe]:t.CONSTANT_COLOR,[FDe]:t.ONE_MINUS_CONSTANT_COLOR,[UDe]:t.CONSTANT_ALPHA,[zDe]:t.ONE_MINUS_CONSTANT_ALPHA};function ne(ge,ze,ke,ve,de,ot,xt,Et,Qt,Ot){if(ge===nd){b===!0&&(_e(t.BLEND),b=!1);return}if(b===!1&&(Z(t.BLEND),b=!0),ge!==EDe){if(ge!==E||Ot!==I){if((w!==ph||C!==ph)&&(t.blendEquation(t.FUNC_ADD),w=ph,C=ph),Ot)switch(ge){case lp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case QH:t.blendFunc(t.ONE,t.ONE);break;case JH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case e$:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}else switch(ge){case lp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case QH:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case JH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case e$:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}A=null,T=null,k=null,F=null,N.set(0,0,0),j=0,E=ge,I=Ot}return}de=de||ze,ot=ot||ke,xt=xt||ve,(ze!==w||de!==C)&&(t.blendEquationSeparate(z[ze],z[de]),w=ze,C=de),(ke!==A||ve!==T||ot!==k||xt!==F)&&(t.blendFuncSeparate(B[ke],B[ve],B[ot],B[xt]),A=ke,T=ve,k=ot,F=xt),(Et.equals(N)===!1||Qt!==j)&&(t.blendColor(Et.r,Et.g,Et.b,Qt),N.copy(Et),j=Qt),E=ge,I=!1}function V(ge,ze){ge.side===hc?_e(t.CULL_FACE):Z(t.CULL_FACE);let ke=ge.side===Qa;ze&&(ke=!ke),Q(ke),ge.blending===lp&&ge.transparent===!1?ne(nd):ne(ge.blending,ge.blendEquation,ge.blendSrc,ge.blendDst,ge.blendEquationAlpha,ge.blendSrcAlpha,ge.blendDstAlpha,ge.blendColor,ge.blendAlpha,ge.premultipliedAlpha),c.setFunc(ge.depthFunc),c.setTest(ge.depthTest),c.setMask(ge.depthWrite),o.setMask(ge.colorWrite);const ve=ge.stencilWrite;u.setTest(ve),ve&&(u.setMask(ge.stencilWriteMask),u.setFunc(ge.stencilFunc,ge.stencilRef,ge.stencilFuncMask),u.setOp(ge.stencilFail,ge.stencilZFail,ge.stencilZPass)),Ae(ge.polygonOffset,ge.polygonOffsetFactor,ge.polygonOffsetUnits),ge.alphaToCoverage===!0?Z(t.SAMPLE_ALPHA_TO_COVERAGE):_e(t.SAMPLE_ALPHA_TO_COVERAGE)}function Q(ge){O!==ge&&(ge?t.frontFace(t.CW):t.frontFace(t.CCW),O=ge)}function se(ge){ge!==wDe?(Z(t.CULL_FACE),ge!==q&&(ge===ZH?t.cullFace(t.BACK):ge===SDe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):_e(t.CULL_FACE),q=ge}function Me(ge){ge!==R&&(te&&t.lineWidth(ge),R=ge)}function Ae(ge,ze,ke){ge?(Z(t.POLYGON_OFFSET_FILL),(W!==ze||K!==ke)&&(t.polygonOffset(ze,ke),W=ze,K=ke)):_e(t.POLYGON_OFFSET_FILL)}function Se(ge){ge?Z(t.SCISSOR_TEST):_e(t.SCISSOR_TEST)}function $(ge){ge===void 0&&(ge=t.TEXTURE0+G-1),U!==ge&&(t.activeTexture(ge),U=ge)}function L(ge,ze,ke){ke===void 0&&(U===null?ke=t.TEXTURE0+G-1:ke=U);let ve=H[ke];ve===void 0&&(ve={type:void 0,texture:void 0},H[ke]=ve),(ve.type!==ge||ve.texture!==ze)&&(U!==ke&&(t.activeTexture(ke),U=ke),t.bindTexture(ge,ze||Re[ge]),ve.type=ge,ve.texture=ze)}function re(){const ge=H[U];ge!==void 0&&ge.type!==void 0&&(t.bindTexture(ge.type,null),ge.type=void 0,ge.texture=void 0)}function ye(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function xe(){try{t.texSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function rt(){try{t.texSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function He(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function he(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ge(){try{t.texStorage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ue(){try{t.texStorage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function oe(){try{t.texImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function tt(){try{t.texImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function $e(ge){pe.equals(ge)===!1&&(t.scissor(ge.x,ge.y,ge.z,ge.w),pe.copy(ge))}function Ye(ge){ue.equals(ge)===!1&&(t.viewport(ge.x,ge.y,ge.z,ge.w),ue.copy(ge))}function ut(ge,ze){let ke=f.get(ze);ke===void 0&&(ke=new WeakMap,f.set(ze,ke));let ve=ke.get(ge);ve===void 0&&(ve=t.getUniformBlockIndex(ze,ge.name),ke.set(ge,ve))}function fe(ge,ze){const ve=f.get(ze).get(ge);d.get(ze)!==ve&&(t.uniformBlockBinding(ze,ve,ge.__bindingPointIndex),d.set(ze,ve))}function Qe(){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={},U=null,H={},p={},x=new WeakMap,v=[],y=null,b=!1,E=null,w=null,A=null,T=null,C=null,k=null,F=null,N=new $t(0,0,0),j=0,I=!1,O=null,q=null,R=null,W=null,K=null,pe.set(0,0,t.canvas.width,t.canvas.height),ue.set(0,0,t.canvas.width,t.canvas.height),o.reset(),c.reset(),u.reset()}return{buffers:{color:o,depth:c,stencil:u},enable:Z,disable:_e,bindFramebuffer:Le,drawBuffers:ce,useProgram:Ie,setBlending:ne,setMaterial:V,setFlipSided:Q,setCullFace:se,setLineWidth:Me,setPolygonOffset:Ae,setScissorTest:Se,activeTexture:$,bindTexture:L,unbindTexture:re,compressedTexImage2D:ye,compressedTexImage3D:we,texImage2D:oe,texImage3D:tt,updateUBOMapping:ut,uniformBlockBinding:fe,texStorage2D:Ge,texStorage3D:Ue,texSubImage2D:xe,texSubImage3D:rt,compressedTexSubImage2D:He,compressedTexSubImage3D:he,scissor:$e,viewport:Ye,reset:Qe}}function PFe(t,e,n,r,i,a,s){const o=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let v;const y=new WeakMap;let b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E($,L){return b?new OffscreenCanvas($,L):$w("canvas")}function w($,L,re,ye){let we=1;if(($.width>ye||$.height>ye)&&(we=ye/Math.max($.width,$.height)),we<1||L===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const xe=L?Hw:Math.floor,rt=xe(we*$.width),He=xe(we*$.height);v===void 0&&(v=E(rt,He));const he=re?E(rt,He):v;return he.width=rt,he.height=He,he.getContext("2d").drawImage($,0,0,rt,He),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+rt+"x"+He+")."),he}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function A($){return BP($.width)&&BP($.height)}function T($){return o?!1:$.wrapS!==Po||$.wrapT!==Po||$.minFilter!==Zi&&$.minFilter!==Qs}function C($,L){return $.generateMipmaps&&L&&$.minFilter!==Zi&&$.minFilter!==Qs}function k($){t.generateMipmap($)}function F($,L,re,ye,we=!1){if(o===!1)return L;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let xe=L;if(L===t.RED&&(re===t.FLOAT&&(xe=t.R32F),re===t.HALF_FLOAT&&(xe=t.R16F),re===t.UNSIGNED_BYTE&&(xe=t.R8)),L===t.RED_INTEGER&&(re===t.UNSIGNED_BYTE&&(xe=t.R8UI),re===t.UNSIGNED_SHORT&&(xe=t.R16UI),re===t.UNSIGNED_INT&&(xe=t.R32UI),re===t.BYTE&&(xe=t.R8I),re===t.SHORT&&(xe=t.R16I),re===t.INT&&(xe=t.R32I)),L===t.RG&&(re===t.FLOAT&&(xe=t.RG32F),re===t.HALF_FLOAT&&(xe=t.RG16F),re===t.UNSIGNED_BYTE&&(xe=t.RG8)),L===t.RGBA){const rt=we?Uw:Yn.getTransfer(ye);re===t.FLOAT&&(xe=t.RGBA32F),re===t.HALF_FLOAT&&(xe=t.RGBA16F),re===t.UNSIGNED_BYTE&&(xe=rt===ur?t.SRGB8_ALPHA8:t.RGBA8),re===t.UNSIGNED_SHORT_4_4_4_4&&(xe=t.RGBA4),re===t.UNSIGNED_SHORT_5_5_5_1&&(xe=t.RGB5_A1)}return(xe===t.R16F||xe===t.R32F||xe===t.RG16F||xe===t.RG32F||xe===t.RGBA16F||xe===t.RGBA32F)&&e.get("EXT_color_buffer_float"),xe}function N($,L,re){return C($,re)===!0||$.isFramebufferTexture&&$.minFilter!==Zi&&$.minFilter!==Qs?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function j($){return $===Zi||$===r$||$===QC?t.NEAREST:t.LINEAR}function I($){const L=$.target;L.removeEventListener("dispose",I),q(L),L.isVideoTexture&&x.delete(L)}function O($){const L=$.target;L.removeEventListener("dispose",O),W(L)}function q($){const L=r.get($);if(L.__webglInit===void 0)return;const re=$.source,ye=y.get(re);if(ye){const we=ye[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&R($),Object.keys(ye).length===0&&y.delete(re)}r.remove($)}function R($){const L=r.get($);t.deleteTexture(L.__webglTexture);const re=$.source,ye=y.get(re);delete ye[L.__cacheKey],s.memory.textures--}function W($){const L=$.texture,re=r.get($),ye=r.get(L);if(ye.__webglTexture!==void 0&&(t.deleteTexture(ye.__webglTexture),s.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(re.__webglFramebuffer[we]))for(let xe=0;xe<re.__webglFramebuffer[we].length;xe++)t.deleteFramebuffer(re.__webglFramebuffer[we][xe]);else t.deleteFramebuffer(re.__webglFramebuffer[we]);re.__webglDepthbuffer&&t.deleteRenderbuffer(re.__webglDepthbuffer[we])}else{if(Array.isArray(re.__webglFramebuffer))for(let we=0;we<re.__webglFramebuffer.length;we++)t.deleteFramebuffer(re.__webglFramebuffer[we]);else t.deleteFramebuffer(re.__webglFramebuffer);if(re.__webglDepthbuffer&&t.deleteRenderbuffer(re.__webglDepthbuffer),re.__webglMultisampledFramebuffer&&t.deleteFramebuffer(re.__webglMultisampledFramebuffer),re.__webglColorRenderbuffer)for(let we=0;we<re.__webglColorRenderbuffer.length;we++)re.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(re.__webglColorRenderbuffer[we]);re.__webglDepthRenderbuffer&&t.deleteRenderbuffer(re.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let we=0,xe=L.length;we<xe;we++){const rt=r.get(L[we]);rt.__webglTexture&&(t.deleteTexture(rt.__webglTexture),s.memory.textures--),r.remove(L[we])}r.remove(L),r.remove($)}let K=0;function G(){K=0}function te(){const $=K;return $>=c&&console.warn("THREE.WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+c),K+=1,$}function Y($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function J($,L){const re=r.get($);if($.isVideoTexture&&Ae($),$.isRenderTargetTexture===!1&&$.version>0&&re.__version!==$.version){const ye=$.image;if(ye===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Z(re,$,L);return}}n.bindTexture(t.TEXTURE_2D,re.__webglTexture,t.TEXTURE0+L)}function U($,L){const re=r.get($);if($.version>0&&re.__version!==$.version){Z(re,$,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,re.__webglTexture,t.TEXTURE0+L)}function H($,L){const re=r.get($);if($.version>0&&re.__version!==$.version){Z(re,$,L);return}n.bindTexture(t.TEXTURE_3D,re.__webglTexture,t.TEXTURE0+L)}function ee($,L){const re=r.get($);if($.version>0&&re.__version!==$.version){_e(re,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,re.__webglTexture,t.TEXTURE0+L)}const ie={[IP]:t.REPEAT,[Po]:t.CLAMP_TO_EDGE,[FP]:t.MIRRORED_REPEAT},pe={[Zi]:t.NEAREST,[r$]:t.NEAREST_MIPMAP_NEAREST,[QC]:t.NEAREST_MIPMAP_LINEAR,[Qs]:t.LINEAR,[tOe]:t.LINEAR_MIPMAP_NEAREST,[X0]:t.LINEAR_MIPMAP_LINEAR},ue={[fOe]:t.NEVER,[yOe]:t.ALWAYS,[mOe]:t.LESS,[BZ]:t.LEQUAL,[pOe]:t.EQUAL,[bOe]:t.GEQUAL,[gOe]:t.GREATER,[xOe]:t.NOTEQUAL};function be($,L,re){if(re?(t.texParameteri($,t.TEXTURE_WRAP_S,ie[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ie[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ie[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,pe[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,pe[L.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==Po||L.wrapT!==Po)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,j(L.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,j(L.minFilter)),L.minFilter!==Zi&&L.minFilter!==Qs&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,ue[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ye=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Zi||L.minFilter!==QC&&L.minFilter!==X0||L.type===yc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===Y0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf($,ye.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Re($,L){let re=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",I));const ye=L.source;let we=y.get(ye);we===void 0&&(we={},y.set(ye,we));const xe=Y(L);if(xe!==$.__cacheKey){we[xe]===void 0&&(we[xe]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,re=!0),we[xe].usedTimes++;const rt=we[$.__cacheKey];rt!==void 0&&(we[$.__cacheKey].usedTimes--,rt.usedTimes===0&&R(L)),$.__cacheKey=xe,$.__webglTexture=we[xe].texture}return re}function Z($,L,re){let ye=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ye=t.TEXTURE_3D);const we=Re($,L),xe=L.source;n.bindTexture(ye,$.__webglTexture,t.TEXTURE0+re);const rt=r.get(xe);if(xe.version!==rt.__version||we===!0){n.activeTexture(t.TEXTURE0+re);const He=Yn.getPrimaries(Yn.workingColorSpace),he=L.colorSpace===eo?null:Yn.getPrimaries(L.colorSpace),Ge=L.colorSpace===eo||He===he?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,Ge);const Ue=T(L)&&A(L.image)===!1;let oe=w(L.image,Ue,!1,d);oe=Se(L,oe);const tt=A(oe)||o,$e=a.convert(L.format,L.colorSpace);let Ye=a.convert(L.type),ut=F(L.internalFormat,$e,Ye,L.colorSpace,L.isVideoTexture);be(ye,L,tt);let fe;const Qe=L.mipmaps,ge=o&&L.isVideoTexture!==!0&&ut!==FZ,ze=rt.__version===void 0||we===!0,ke=N(L,oe,tt);if(L.isDepthTexture)ut=t.DEPTH_COMPONENT,o?L.type===yc?ut=t.DEPTH_COMPONENT32F:L.type===Ku?ut=t.DEPTH_COMPONENT24:L.type===Dh?ut=t.DEPTH24_STENCIL8:ut=t.DEPTH_COMPONENT16:L.type===yc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===Oh&&ut===t.DEPTH_COMPONENT&&L.type!==SO&&L.type!==Ku&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Ku,Ye=a.convert(L.type)),L.format===Ip&&ut===t.DEPTH_COMPONENT&&(ut=t.DEPTH_STENCIL,L.type!==Dh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Dh,Ye=a.convert(L.type))),ze&&(ge?n.texStorage2D(t.TEXTURE_2D,1,ut,oe.width,oe.height):n.texImage2D(t.TEXTURE_2D,0,ut,oe.width,oe.height,0,$e,Ye,null));else if(L.isDataTexture)if(Qe.length>0&&tt){ge&&ze&&n.texStorage2D(t.TEXTURE_2D,ke,ut,Qe[0].width,Qe[0].height);for(let ve=0,de=Qe.length;ve<de;ve++)fe=Qe[ve],ge?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,fe.width,fe.height,$e,Ye,fe.data):n.texImage2D(t.TEXTURE_2D,ve,ut,fe.width,fe.height,0,$e,Ye,fe.data);L.generateMipmaps=!1}else ge?(ze&&n.texStorage2D(t.TEXTURE_2D,ke,ut,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe.width,oe.height,$e,Ye,oe.data)):n.texImage2D(t.TEXTURE_2D,0,ut,oe.width,oe.height,0,$e,Ye,oe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ge&&ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ke,ut,Qe[0].width,Qe[0].height,oe.depth);for(let ve=0,de=Qe.length;ve<de;ve++)fe=Qe[ve],L.format!==Js?$e!==null?ge?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ve,0,0,0,fe.width,fe.height,oe.depth,$e,fe.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ve,ut,fe.width,fe.height,oe.depth,0,fe.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage3D(t.TEXTURE_2D_ARRAY,ve,0,0,0,fe.width,fe.height,oe.depth,$e,Ye,fe.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ve,ut,fe.width,fe.height,oe.depth,0,$e,Ye,fe.data)}else{ge&&ze&&n.texStorage2D(t.TEXTURE_2D,ke,ut,Qe[0].width,Qe[0].height);for(let ve=0,de=Qe.length;ve<de;ve++)fe=Qe[ve],L.format!==Js?$e!==null?ge?n.compressedTexSubImage2D(t.TEXTURE_2D,ve,0,0,fe.width,fe.height,$e,fe.data):n.compressedTexImage2D(t.TEXTURE_2D,ve,ut,fe.width,fe.height,0,fe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,fe.width,fe.height,$e,Ye,fe.data):n.texImage2D(t.TEXTURE_2D,ve,ut,fe.width,fe.height,0,$e,Ye,fe.data)}else if(L.isDataArrayTexture)ge?(ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ke,ut,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,$e,Ye,oe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ut,oe.width,oe.height,oe.depth,0,$e,Ye,oe.data);else if(L.isData3DTexture)ge?(ze&&n.texStorage3D(t.TEXTURE_3D,ke,ut,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,$e,Ye,oe.data)):n.texImage3D(t.TEXTURE_3D,0,ut,oe.width,oe.height,oe.depth,0,$e,Ye,oe.data);else if(L.isFramebufferTexture){if(ze)if(ge)n.texStorage2D(t.TEXTURE_2D,ke,ut,oe.width,oe.height);else{let ve=oe.width,de=oe.height;for(let ot=0;ot<ke;ot++)n.texImage2D(t.TEXTURE_2D,ot,ut,ve,de,0,$e,Ye,null),ve>>=1,de>>=1}}else if(Qe.length>0&&tt){ge&&ze&&n.texStorage2D(t.TEXTURE_2D,ke,ut,Qe[0].width,Qe[0].height);for(let ve=0,de=Qe.length;ve<de;ve++)fe=Qe[ve],ge?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,$e,Ye,fe):n.texImage2D(t.TEXTURE_2D,ve,ut,$e,Ye,fe);L.generateMipmaps=!1}else ge?(ze&&n.texStorage2D(t.TEXTURE_2D,ke,ut,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,$e,Ye,oe)):n.texImage2D(t.TEXTURE_2D,0,ut,$e,Ye,oe);C(L,tt)&&k(ye),rt.__version=xe.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function _e($,L,re){if(L.image.length!==6)return;const ye=Re($,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+re);const xe=r.get(we);if(we.version!==xe.__version||ye===!0){n.activeTexture(t.TEXTURE0+re);const rt=Yn.getPrimaries(Yn.workingColorSpace),He=L.colorSpace===eo?null:Yn.getPrimaries(L.colorSpace),he=L.colorSpace===eo||rt===He?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,he);const Ge=L.isCompressedTexture||L.image[0].isCompressedTexture,Ue=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let ve=0;ve<6;ve++)!Ge&&!Ue?oe[ve]=w(L.image[ve],!1,!0,u):oe[ve]=Ue?L.image[ve].image:L.image[ve],oe[ve]=Se(L,oe[ve]);const tt=oe[0],$e=A(tt)||o,Ye=a.convert(L.format,L.colorSpace),ut=a.convert(L.type),fe=F(L.internalFormat,Ye,ut,L.colorSpace),Qe=o&&L.isVideoTexture!==!0,ge=xe.__version===void 0||ye===!0;let ze=N(L,tt,$e);be(t.TEXTURE_CUBE_MAP,L,$e);let ke;if(Ge){Qe&&ge&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,fe,tt.width,tt.height);for(let ve=0;ve<6;ve++){ke=oe[ve].mipmaps;for(let de=0;de<ke.length;de++){const ot=ke[de];L.format!==Js?Ye!==null?Qe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,0,0,ot.width,ot.height,Ye,ot.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,fe,ot.width,ot.height,0,ot.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,0,0,ot.width,ot.height,Ye,ut,ot.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de,fe,ot.width,ot.height,0,Ye,ut,ot.data)}}}else{ke=L.mipmaps,Qe&&ge&&(ke.length>0&&ze++,n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,fe,oe[0].width,oe[0].height));for(let ve=0;ve<6;ve++)if(Ue){Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,oe[ve].width,oe[ve].height,Ye,ut,oe[ve].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,fe,oe[ve].width,oe[ve].height,0,Ye,ut,oe[ve].data);for(let de=0;de<ke.length;de++){const xt=ke[de].image[ve].image;Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,0,0,xt.width,xt.height,Ye,ut,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,fe,xt.width,xt.height,0,Ye,ut,xt.data)}}else{Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,Ye,ut,oe[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,fe,Ye,ut,oe[ve]);for(let de=0;de<ke.length;de++){const ot=ke[de];Qe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,0,0,Ye,ut,ot.image[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,de+1,fe,Ye,ut,ot.image[ve])}}}C(L,$e)&&k(t.TEXTURE_CUBE_MAP),xe.__version=we.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Le($,L,re,ye,we,xe){const rt=a.convert(re.format,re.colorSpace),He=a.convert(re.type),he=F(re.internalFormat,rt,He,re.colorSpace);if(!r.get(L).__hasExternalTextures){const Ue=Math.max(1,L.width>>xe),oe=Math.max(1,L.height>>xe);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,xe,he,Ue,oe,L.depth,0,rt,He,null):n.texImage2D(we,xe,he,Ue,oe,0,rt,He,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Me(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,we,r.get(re).__webglTexture,0,se(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,we,r.get(re).__webglTexture,xe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ce($,L,re){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer&&!L.stencilBuffer){let ye=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(re||Me(L)){const we=L.depthTexture;we&&we.isDepthTexture&&(we.type===yc?ye=t.DEPTH_COMPONENT32F:we.type===Ku&&(ye=t.DEPTH_COMPONENT24));const xe=se(L);Me(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,xe,ye,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,xe,ye,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ye,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(L.depthBuffer&&L.stencilBuffer){const ye=se(L);re&&Me(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,L.width,L.height):Me(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const ye=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let we=0;we<ye.length;we++){const xe=ye[we],rt=a.convert(xe.format,xe.colorSpace),He=a.convert(xe.type),he=F(xe.internalFormat,rt,He,xe.colorSpace),Ge=se(L);re&&Me(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ge,he,L.width,L.height):Me(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ge,he,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,he,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ie($,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),J(L.depthTexture,0);const ye=r.get(L.depthTexture).__webglTexture,we=se(L);if(L.depthTexture.format===Oh)Me(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(L.depthTexture.format===Ip)Me(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function z($){const L=r.get($),re=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!L.__autoAllocateDepthBuffer){if(re)throw new Error("target.depthTexture not supported in Cube render targets");Ie(L.__webglFramebuffer,$)}else if(re){L.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ye]),L.__webglDepthbuffer[ye]=t.createRenderbuffer(),ce(L.__webglDepthbuffer[ye],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),ce(L.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function B($,L,re){const ye=r.get($);L!==void 0&&Le(ye.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),re!==void 0&&z($)}function ne($){const L=$.texture,re=r.get($),ye=r.get(L);$.addEventListener("dispose",O),$.isWebGLMultipleRenderTargets!==!0&&(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=L.version,s.memory.textures++);const we=$.isWebGLCubeRenderTarget===!0,xe=$.isWebGLMultipleRenderTargets===!0,rt=A($)||o;if(we){re.__webglFramebuffer=[];for(let He=0;He<6;He++)if(o&&L.mipmaps&&L.mipmaps.length>0){re.__webglFramebuffer[He]=[];for(let he=0;he<L.mipmaps.length;he++)re.__webglFramebuffer[He][he]=t.createFramebuffer()}else re.__webglFramebuffer[He]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){re.__webglFramebuffer=[];for(let He=0;He<L.mipmaps.length;He++)re.__webglFramebuffer[He]=t.createFramebuffer()}else re.__webglFramebuffer=t.createFramebuffer();if(xe)if(i.drawBuffers){const He=$.texture;for(let he=0,Ge=He.length;he<Ge;he++){const Ue=r.get(He[he]);Ue.__webglTexture===void 0&&(Ue.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&$.samples>0&&Me($)===!1){const He=xe?L:[L];re.__webglMultisampledFramebuffer=t.createFramebuffer(),re.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,re.__webglMultisampledFramebuffer);for(let he=0;he<He.length;he++){const Ge=He[he];re.__webglColorRenderbuffer[he]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,re.__webglColorRenderbuffer[he]);const Ue=a.convert(Ge.format,Ge.colorSpace),oe=a.convert(Ge.type),tt=F(Ge.internalFormat,Ue,oe,Ge.colorSpace,$.isXRRenderTarget===!0),$e=se($);t.renderbufferStorageMultisample(t.RENDERBUFFER,$e,tt,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+he,t.RENDERBUFFER,re.__webglColorRenderbuffer[he])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(re.__webglDepthRenderbuffer=t.createRenderbuffer(),ce(re.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),be(t.TEXTURE_CUBE_MAP,L,rt);for(let He=0;He<6;He++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let he=0;he<L.mipmaps.length;he++)Le(re.__webglFramebuffer[He][he],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+He,he);else Le(re.__webglFramebuffer[He],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+He,0);C(L,rt)&&k(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(xe){const He=$.texture;for(let he=0,Ge=He.length;he<Ge;he++){const Ue=He[he],oe=r.get(Ue);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture),be(t.TEXTURE_2D,Ue,rt),Le(re.__webglFramebuffer,$,Ue,t.COLOR_ATTACHMENT0+he,t.TEXTURE_2D,0),C(Ue,rt)&&k(t.TEXTURE_2D)}n.unbindTexture()}else{let He=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(o?He=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(He,ye.__webglTexture),be(He,L,rt),o&&L.mipmaps&&L.mipmaps.length>0)for(let he=0;he<L.mipmaps.length;he++)Le(re.__webglFramebuffer[he],$,L,t.COLOR_ATTACHMENT0,He,he);else Le(re.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,He,0);C(L,rt)&&k(He),n.unbindTexture()}$.depthBuffer&&z($)}function V($){const L=A($)||o,re=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let ye=0,we=re.length;ye<we;ye++){const xe=re[ye];if(C(xe,L)){const rt=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,He=r.get(xe).__webglTexture;n.bindTexture(rt,He),k(rt),n.unbindTexture()}}}function Q($){if(o&&$.samples>0&&Me($)===!1){const L=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],re=$.width,ye=$.height;let we=t.COLOR_BUFFER_BIT;const xe=[],rt=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,He=r.get($),he=$.isWebGLMultipleRenderTargets===!0;if(he)for(let Ge=0;Ge<L.length;Ge++)n.bindFramebuffer(t.FRAMEBUFFER,He.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,He.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,He.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,He.__webglFramebuffer);for(let Ge=0;Ge<L.length;Ge++){xe.push(t.COLOR_ATTACHMENT0+Ge),$.depthBuffer&&xe.push(rt);const Ue=He.__ignoreDepthValues!==void 0?He.__ignoreDepthValues:!1;if(Ue===!1&&($.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),he&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,He.__webglColorRenderbuffer[Ge]),Ue===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[rt]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[rt])),he){const oe=r.get(L[Ge]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,oe,0)}t.blitFramebuffer(0,0,re,ye,0,0,re,ye,we,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,xe)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),he)for(let Ge=0;Ge<L.length;Ge++){n.bindFramebuffer(t.FRAMEBUFFER,He.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.RENDERBUFFER,He.__webglColorRenderbuffer[Ge]);const Ue=r.get(L[Ge]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,He.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.TEXTURE_2D,Ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,He.__webglMultisampledFramebuffer)}}function se($){return Math.min(f,$.samples)}function Me($){const L=r.get($);return o&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ae($){const L=s.render.frame;x.get($)!==L&&(x.set($,L),$.update())}function Se($,L){const re=$.colorSpace,ye=$.format,we=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===zP||re!==Bc&&re!==eo&&(Yn.getTransfer(re)===ur?o===!1?e.has("EXT_sRGB")===!0&&ye===Js?($.format=zP,$.minFilter=Qs,$.generateMipmaps=!1):L=VZ.sRGBToLinear(L):(ye!==Js||we!==id)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",re)),L}this.allocateTextureUnit=te,this.resetTextureUnits=G,this.setTexture2D=J,this.setTexture2DArray=U,this.setTexture3D=H,this.setTextureCube=ee,this.rebindTextures=B,this.setupRenderTarget=ne,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=Le,this.useMultisampledRTT=Me}function RFe(t,e,n){const r=n.isWebGL2;function i(a,s=eo){let o;const c=Yn.getTransfer(s);if(a===id)return t.UNSIGNED_BYTE;if(a===jZ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===DZ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===nOe)return t.BYTE;if(a===rOe)return t.SHORT;if(a===SO)return t.UNSIGNED_SHORT;if(a===RZ)return t.INT;if(a===Ku)return t.UNSIGNED_INT;if(a===yc)return t.FLOAT;if(a===Y0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===iOe)return t.ALPHA;if(a===Js)return t.RGBA;if(a===aOe)return t.LUMINANCE;if(a===sOe)return t.LUMINANCE_ALPHA;if(a===Oh)return t.DEPTH_COMPONENT;if(a===Ip)return t.DEPTH_STENCIL;if(a===zP)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===oOe)return t.RED;if(a===OZ)return t.RED_INTEGER;if(a===lOe)return t.RG;if(a===LZ)return t.RG_INTEGER;if(a===IZ)return t.RGBA_INTEGER;if(a===JC||a===eN||a===tN||a===nN)if(c===ur)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===JC)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===eN)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===tN)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===nN)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===JC)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===eN)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===tN)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===nN)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===i$||a===a$||a===s$||a===o$)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===i$)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===a$)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===s$)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===o$)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===FZ)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===l$||a===c$)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(a===l$)return c===ur?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===c$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===u$||a===d$||a===h$||a===f$||a===m$||a===p$||a===g$||a===x$||a===b$||a===y$||a===v$||a===_$||a===w$||a===S$)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(a===u$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===d$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===h$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===f$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===m$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===p$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===g$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===x$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===b$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===y$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===v$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===_$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===w$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===S$)return c===ur?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===rN||a===M$||a===E$)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(a===rN)return c===ur?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===M$)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===E$)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===cOe||a===A$||a===T$||a===C$)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(a===rN)return o.COMPRESSED_RED_RGTC1_EXT;if(a===A$)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===T$)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===C$)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Dh?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class jFe extends ys{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class $x extends Ca{constructor(){super(),this.isGroup=!0,this.type="Group"}}const DFe={type:"move"};class AN{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new $x,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 $x,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new De,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new De),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new $x,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new De,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new De),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const o=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(DFe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new $x;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class OFe extends bf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,o="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const v=n.getContextAttributes();let y=null,b=null;const E=[],w=[],A=new Zt;let T=null;const C=new ys;C.layers.enable(1),C.viewport=new Qn;const k=new ys;k.layers.enable(2),k.viewport=new Qn;const F=[C,k],N=new jFe;N.layers.enable(1),N.layers.enable(2);let j=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ie=E[ee];return ie===void 0&&(ie=new AN,E[ee]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(ee){let ie=E[ee];return ie===void 0&&(ie=new AN,E[ee]=ie),ie.getGripSpace()},this.getHand=function(ee){let ie=E[ee];return ie===void 0&&(ie=new AN,E[ee]=ie),ie.getHandSpace()};function O(ee){const ie=w.indexOf(ee.inputSource);if(ie===-1)return;const pe=E[ie];pe!==void 0&&(pe.update(ee.inputSource,ee.frame,u||s),pe.dispatchEvent({type:ee.type,data:ee.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let ee=0;ee<E.length;ee++){const ie=w[ee];ie!==null&&(w[ee]=null,E[ee].disconnect(ie))}j=null,I=null,e.setRenderTarget(y),p=null,g=null,f=null,i=null,b=null,H.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){a=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){o=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(ee){u=ee},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ee){if(i=ee,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",R),v.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ie={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ie),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),b=new of(p.framebufferWidth,p.framebufferHeight,{format:Js,type:id,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ie=null,pe=null,ue=null;v.depth&&(ue=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ie=v.stencil?Ip:Oh,pe=v.stencil?Dh:Ku);const be={colorFormat:n.RGBA8,depthFormat:ue,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(be),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),b=new of(g.textureWidth,g.textureHeight,{format:Js,type:id,depthTexture:new nQ(g.textureWidth,g.textureHeight,pe,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Re=e.properties.get(b);Re.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(o),H.setContext(i),H.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function R(ee){for(let ie=0;ie<ee.removed.length;ie++){const pe=ee.removed[ie],ue=w.indexOf(pe);ue>=0&&(w[ue]=null,E[ue].disconnect(pe))}for(let ie=0;ie<ee.added.length;ie++){const pe=ee.added[ie];let ue=w.indexOf(pe);if(ue===-1){for(let Re=0;Re<E.length;Re++)if(Re>=w.length){w.push(pe),ue=Re;break}else if(w[Re]===null){w[Re]=pe,ue=Re;break}if(ue===-1)break}const be=E[ue];be&&be.connect(pe)}}const W=new De,K=new De;function G(ee,ie,pe){W.setFromMatrixPosition(ie.matrixWorld),K.setFromMatrixPosition(pe.matrixWorld);const ue=W.distanceTo(K),be=ie.projectionMatrix.elements,Re=pe.projectionMatrix.elements,Z=be[14]/(be[10]-1),_e=be[14]/(be[10]+1),Le=(be[9]+1)/be[5],ce=(be[9]-1)/be[5],Ie=(be[8]-1)/be[0],z=(Re[8]+1)/Re[0],B=Z*Ie,ne=Z*z,V=ue/(-Ie+z),Q=V*-Ie;ie.matrixWorld.decompose(ee.position,ee.quaternion,ee.scale),ee.translateX(Q),ee.translateZ(V),ee.matrixWorld.compose(ee.position,ee.quaternion,ee.scale),ee.matrixWorldInverse.copy(ee.matrixWorld).invert();const se=Z+V,Me=_e+V,Ae=B-Q,Se=ne+(ue-Q),$=Le*_e/Me*se,L=ce*_e/Me*se;ee.projectionMatrix.makePerspective(Ae,Se,$,L,se,Me),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert()}function te(ee,ie){ie===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ie.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(i===null)return;N.near=k.near=C.near=ee.near,N.far=k.far=C.far=ee.far,(j!==N.near||I!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),j=N.near,I=N.far);const ie=ee.parent,pe=N.cameras;te(N,ie);for(let ue=0;ue<pe.length;ue++)te(pe[ue],ie);pe.length===2?G(N,C,k):N.projectionMatrix.copy(C.projectionMatrix),Y(ee,N,ie)};function Y(ee,ie,pe){pe===null?ee.matrix.copy(ie.matrixWorld):(ee.matrix.copy(pe.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ie.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ie.projectionMatrix),ee.projectionMatrixInverse.copy(ie.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=Q0*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(ee){c=ee,g!==null&&(g.fixedFoveation=ee),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ee)};let J=null;function U(ee,ie){if(d=ie.getViewerPose(u||s),x=ie,d!==null){const pe=d.views;p!==null&&(e.setRenderTargetFramebuffer(b,p.framebuffer),e.setRenderTarget(b));let ue=!1;pe.length!==N.cameras.length&&(N.cameras.length=0,ue=!0);for(let be=0;be<pe.length;be++){const Re=pe[be];let Z=null;if(p!==null)Z=p.getViewport(Re);else{const Le=f.getViewSubImage(g,Re);Z=Le.viewport,be===0&&(e.setRenderTargetTextures(b,Le.colorTexture,g.ignoreDepthValues?void 0:Le.depthStencilTexture),e.setRenderTarget(b))}let _e=F[be];_e===void 0&&(_e=new ys,_e.layers.enable(be),_e.viewport=new Qn,F[be]=_e),_e.matrix.fromArray(Re.transform.matrix),_e.matrix.decompose(_e.position,_e.quaternion,_e.scale),_e.projectionMatrix.fromArray(Re.projectionMatrix),_e.projectionMatrixInverse.copy(_e.projectionMatrix).invert(),_e.viewport.set(Z.x,Z.y,Z.width,Z.height),be===0&&(N.matrix.copy(_e.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),ue===!0&&N.cameras.push(_e)}}for(let pe=0;pe<E.length;pe++){const ue=w[pe],be=E[pe];ue!==null&&be!==void 0&&be.update(ue,ie,u||s)}J&&J(ee,ie),ie.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ie}),x=null}const H=new tQ;H.setAnimationLoop(U),this.setAnimationLoop=function(ee){J=ee},this.dispose=function(){}}}function LFe(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,QZ(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,E,w,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&p(y,b,A)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&o(y,b)):b.isPointsMaterial?c(y,b,E,w):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===Qa&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===Qa&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const E=e.get(b).envMap;if(E&&(y.envMap.value=E,y.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap){y.lightMap.value=b.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=b.lightMapIntensity*w,n(b.lightMap,y.lightMapTransform)}b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function o(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,E,w){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*E,y.scale.value=w*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),e.get(b).envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function p(y,b,E){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Qa&&y.clearcoatNormalScale.value.negate())),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=E.texture,y.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const E=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(E.matrixWorld),y.nearDistance.value=E.shadow.camera.near,y.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function IFe(t,e,n,r){let i={},a={},s=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",y));const T=w.program;r.updateUBOMapping(E,T);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),T=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<o;E++)if(s.indexOf(E)===-1)return s.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,k=A.length;C<k;C++){const F=A[C];if(p(F,C,T)===!0){const N=F.__offset,j=Array.isArray(F.value)?F.value:[F.value];let I=0;for(let O=0;O<j.length;O++){const q=j[O],R=v(q);typeof q=="number"?(F.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,N+I,F.__data)):q.isMatrix3?(F.__data[0]=q.elements[0],F.__data[1]=q.elements[1],F.__data[2]=q.elements[2],F.__data[3]=q.elements[0],F.__data[4]=q.elements[3],F.__data[5]=q.elements[4],F.__data[6]=q.elements[5],F.__data[7]=q.elements[0],F.__data[8]=q.elements[6],F.__data[9]=q.elements[7],F.__data[10]=q.elements[8],F.__data[11]=q.elements[0]):(q.toArray(F.__data,I),I+=R.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,N,F.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,A){const T=E.value;if(A[w]===void 0){if(typeof T=="number")A[w]=T;else{const C=Array.isArray(T)?T:[T],k=[];for(let F=0;F<C.length;F++)k.push(C[F].clone());A[w]=k}return!0}else if(typeof T=="number"){if(A[w]!==T)return A[w]=T,!0}else{const C=Array.isArray(A[w])?A[w]:[A[w]],k=Array.isArray(T)?T:[T];for(let F=0;F<C.length;F++){const N=C[F];if(N.equals(k[F])===!1)return N.copy(k[F]),!0}}return!1}function x(E){const w=E.uniforms;let A=0;const T=16;let C=0;for(let k=0,F=w.length;k<F;k++){const N=w[k],j={boundary:0,storage:0},I=Array.isArray(N.value)?N.value:[N.value];for(let O=0,q=I.length;O<q;O++){const R=I[O],W=v(R);j.boundary+=W.boundary,j.storage+=W.storage}if(N.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=A,k>0){C=A%T;const O=T-C;C!==0&&O-j.boundary<0&&(A+=T-C,N.__offset=A)}A+=j.storage}return C=A%T,C>0&&(A+=T-C),E.__size=A,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function y(E){const w=E.target;w.removeEventListener("dispose",y);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}class $P{constructor(e={}){const{canvas:n=DOe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=s;const p=new Uint32Array(4),x=new Int32Array(4);let v=null,y=null;const b=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Qi,this._useLegacyLights=!1,this.toneMapping=rd,this.toneMappingExposure=1;const w=this;let A=!1,T=0,C=0,k=null,F=-1,N=null;const j=new Qn,I=new Qn;let O=null;const q=new $t(0);let R=0,W=n.width,K=n.height,G=1,te=null,Y=null;const J=new Qn(0,0,W,K),U=new Qn(0,0,W,K);let H=!1;const ee=new XM;let ie=!1,pe=!1,ue=null;const be=new or,Re=new Zt,Z=new De,_e={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Le(){return k===null?G:1}let ce=r;function Ie(me,Ve){for(let it=0;it<me.length;it++){const at=me[it],nt=n.getContext(at,Ve);if(nt!==null)return nt}return null}try{const me={alpha:!0,depth:i,stencil:a,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${WM}`),n.addEventListener("webglcontextlost",Qe,!1),n.addEventListener("webglcontextrestored",ge,!1),n.addEventListener("webglcontextcreationerror",ze,!1),ce===null){const Ve=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ve.shift(),ce=Ie(Ve,me),ce===null)throw Ie(Ve)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ce instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ce.getShaderPrecisionFormat===void 0&&(ce.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(me){throw console.error("THREE.WebGLRenderer: "+me.message),me}let z,B,ne,V,Q,se,Me,Ae,Se,$,L,re,ye,we,xe,rt,He,he,Ge,Ue,oe,tt,$e,Ye;function ut(){z=new KIe(ce),B=new BIe(ce,z,e),z.init(B),tt=new RFe(ce,z,B),ne=new kFe(ce,z,B),V=new ZIe(ce),Q=new gFe,se=new PFe(ce,z,ne,Q,B,tt,V),Me=new $Ie(w),Ae=new qIe(w),Se=new iLe(ce,B),$e=new UIe(ce,z,Se,B),$=new XIe(ce,Se,V,$e),L=new t5e(ce,$,Se,V),Ge=new e5e(ce,B,se),rt=new HIe(Q),re=new pFe(w,Me,Ae,z,B,$e,rt),ye=new LFe(w,Q),we=new bFe,xe=new MFe(z,B),he=new FIe(w,Me,Ae,ne,L,g,c),He=new NFe(w,L,B),Ye=new IFe(ce,V,B,ne),Ue=new zIe(ce,z,V,B),oe=new YIe(ce,z,V,B),V.programs=re.programs,w.capabilities=B,w.extensions=z,w.properties=Q,w.renderLists=we,w.shadowMap=He,w.state=ne,w.info=V}ut();const fe=new OFe(w,ce);this.xr=fe,this.getContext=function(){return ce},this.getContextAttributes=function(){return ce.getContextAttributes()},this.forceContextLoss=function(){const me=z.get("WEBGL_lose_context");me&&me.loseContext()},this.forceContextRestore=function(){const me=z.get("WEBGL_lose_context");me&&me.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(me){me!==void 0&&(G=me,this.setSize(W,K,!1))},this.getSize=function(me){return me.set(W,K)},this.setSize=function(me,Ve,it=!0){if(fe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=me,K=Ve,n.width=Math.floor(me*G),n.height=Math.floor(Ve*G),it===!0&&(n.style.width=me+"px",n.style.height=Ve+"px"),this.setViewport(0,0,me,Ve)},this.getDrawingBufferSize=function(me){return me.set(W*G,K*G).floor()},this.setDrawingBufferSize=function(me,Ve,it){W=me,K=Ve,G=it,n.width=Math.floor(me*it),n.height=Math.floor(Ve*it),this.setViewport(0,0,me,Ve)},this.getCurrentViewport=function(me){return me.copy(j)},this.getViewport=function(me){return me.copy(J)},this.setViewport=function(me,Ve,it,at){me.isVector4?J.set(me.x,me.y,me.z,me.w):J.set(me,Ve,it,at),ne.viewport(j.copy(J).multiplyScalar(G).floor())},this.getScissor=function(me){return me.copy(U)},this.setScissor=function(me,Ve,it,at){me.isVector4?U.set(me.x,me.y,me.z,me.w):U.set(me,Ve,it,at),ne.scissor(I.copy(U).multiplyScalar(G).floor())},this.getScissorTest=function(){return H},this.setScissorTest=function(me){ne.setScissorTest(H=me)},this.setOpaqueSort=function(me){te=me},this.setTransparentSort=function(me){Y=me},this.getClearColor=function(me){return me.copy(he.getClearColor())},this.setClearColor=function(){he.setClearColor.apply(he,arguments)},this.getClearAlpha=function(){return he.getClearAlpha()},this.setClearAlpha=function(){he.setClearAlpha.apply(he,arguments)},this.clear=function(me=!0,Ve=!0,it=!0){let at=0;if(me){let nt=!1;if(k!==null){const At=k.texture.format;nt=At===IZ||At===LZ||At===OZ}if(nt){const At=k.texture.type,ae=At===id||At===Ku||At===SO||At===Dh||At===jZ||At===DZ,Ee=he.getClearColor(),Fe=he.getClearAlpha(),Oe=Ee.r,Ne=Ee.g,lt=Ee.b;ae?(p[0]=Oe,p[1]=Ne,p[2]=lt,p[3]=Fe,ce.clearBufferuiv(ce.COLOR,0,p)):(x[0]=Oe,x[1]=Ne,x[2]=lt,x[3]=Fe,ce.clearBufferiv(ce.COLOR,0,x))}else at|=ce.COLOR_BUFFER_BIT}Ve&&(at|=ce.DEPTH_BUFFER_BIT),it&&(at|=ce.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ce.clear(at)},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",Qe,!1),n.removeEventListener("webglcontextrestored",ge,!1),n.removeEventListener("webglcontextcreationerror",ze,!1),we.dispose(),xe.dispose(),Q.dispose(),Me.dispose(),Ae.dispose(),L.dispose(),$e.dispose(),Ye.dispose(),re.dispose(),fe.dispose(),fe.removeEventListener("sessionstart",Qt),fe.removeEventListener("sessionend",Ot),ue&&(ue.dispose(),ue=null),Vt.stop()};function Qe(me){me.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ge(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const me=V.autoReset,Ve=He.enabled,it=He.autoUpdate,at=He.needsUpdate,nt=He.type;ut(),V.autoReset=me,He.enabled=Ve,He.autoUpdate=it,He.needsUpdate=at,He.type=nt}function ze(me){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",me.statusMessage)}function ke(me){const Ve=me.target;Ve.removeEventListener("dispose",ke),ve(Ve)}function ve(me){de(me),Q.remove(me)}function de(me){const Ve=Q.get(me).programs;Ve!==void 0&&(Ve.forEach(function(it){re.releaseProgram(it)}),me.isShaderMaterial&&re.releaseShaderCache(me))}this.renderBufferDirect=function(me,Ve,it,at,nt,At){Ve===null&&(Ve=_e);const ae=nt.isMesh&&nt.matrixWorld.determinant()<0,Ee=Lr(me,Ve,it,at,nt);ne.setMaterial(at,ae);let Fe=it.index,Oe=1;if(at.wireframe===!0){if(Fe=$.getWireframeAttribute(it),Fe===void 0)return;Oe=2}const Ne=it.drawRange,lt=it.attributes.position;let ft=Ne.start*Oe,wt=(Ne.start+Ne.count)*Oe;At!==null&&(ft=Math.max(ft,At.start*Oe),wt=Math.min(wt,(At.start+At.count)*Oe)),Fe!==null?(ft=Math.max(ft,0),wt=Math.min(wt,Fe.count)):lt!=null&&(ft=Math.max(ft,0),wt=Math.min(wt,lt.count));const bt=wt-ft;if(bt<0||bt===1/0)return;$e.setup(nt,at,Ee,it,Fe);let Lt,Ct=Ue;if(Fe!==null&&(Lt=Se.get(Fe),Ct=oe,Ct.setIndex(Lt)),nt.isMesh)at.wireframe===!0?(ne.setLineWidth(at.wireframeLinewidth*Le()),Ct.setMode(ce.LINES)):Ct.setMode(ce.TRIANGLES);else if(nt.isLine){let pt=at.linewidth;pt===void 0&&(pt=1),ne.setLineWidth(pt*Le()),nt.isLineSegments?Ct.setMode(ce.LINES):nt.isLineLoop?Ct.setMode(ce.LINE_LOOP):Ct.setMode(ce.LINE_STRIP)}else nt.isPoints?Ct.setMode(ce.POINTS):nt.isSprite&&Ct.setMode(ce.TRIANGLES);if(nt.isBatchedMesh)Ct.renderMultiDraw(nt._multiDrawStarts,nt._multiDrawCounts,nt._multiDrawCount);else if(nt.isInstancedMesh)Ct.renderInstances(ft,bt,nt.count);else if(it.isInstancedBufferGeometry){const pt=it._maxInstanceCount!==void 0?it._maxInstanceCount:1/0,Xt=Math.min(it.instanceCount,pt);Ct.renderInstances(ft,bt,Xt)}else Ct.render(ft,bt)};function ot(me,Ve,it){me.transparent===!0&&me.side===hc&&me.forceSinglePass===!1?(me.side=Qa,me.needsUpdate=!0,ra(me,Ve,it),me.side=vd,me.needsUpdate=!0,ra(me,Ve,it),me.side=hc):ra(me,Ve,it)}this.compile=function(me,Ve,it=null){it===null&&(it=me),y=xe.get(it),y.init(),E.push(y),it.traverseVisible(function(nt){nt.isLight&&nt.layers.test(Ve.layers)&&(y.pushLight(nt),nt.castShadow&&y.pushShadow(nt))}),me!==it&&me.traverseVisible(function(nt){nt.isLight&&nt.layers.test(Ve.layers)&&(y.pushLight(nt),nt.castShadow&&y.pushShadow(nt))}),y.setupLights(w._useLegacyLights);const at=new Set;return me.traverse(function(nt){const At=nt.material;if(At)if(Array.isArray(At))for(let ae=0;ae<At.length;ae++){const Ee=At[ae];ot(Ee,it,nt),at.add(Ee)}else ot(At,it,nt),at.add(At)}),E.pop(),y=null,at},this.compileAsync=function(me,Ve,it=null){const at=this.compile(me,Ve,it);return new Promise(nt=>{function At(){if(at.forEach(function(ae){Q.get(ae).currentProgram.isReady()&&at.delete(ae)}),at.size===0){nt(me);return}setTimeout(At,10)}z.get("KHR_parallel_shader_compile")!==null?At():setTimeout(At,10)})};let xt=null;function Et(me){xt&&xt(me)}function Qt(){Vt.stop()}function Ot(){Vt.start()}const Vt=new tQ;Vt.setAnimationLoop(Et),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(me){xt=me,fe.setAnimationLoop(me),me===null?Vt.stop():Vt.start()},fe.addEventListener("sessionstart",Qt),fe.addEventListener("sessionend",Ot),this.render=function(me,Ve){if(Ve!==void 0&&Ve.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;me.matrixWorldAutoUpdate===!0&&me.updateMatrixWorld(),Ve.parent===null&&Ve.matrixWorldAutoUpdate===!0&&Ve.updateMatrixWorld(),fe.enabled===!0&&fe.isPresenting===!0&&(fe.cameraAutoUpdate===!0&&fe.updateCamera(Ve),Ve=fe.getCamera()),me.isScene===!0&&me.onBeforeRender(w,me,Ve,k),y=xe.get(me,E.length),y.init(),E.push(y),be.multiplyMatrices(Ve.projectionMatrix,Ve.matrixWorldInverse),ee.setFromProjectionMatrix(be),pe=this.localClippingEnabled,ie=rt.init(this.clippingPlanes,pe),v=we.get(me,b.length),v.init(),b.push(v),On(me,Ve,0,w.sortObjects),v.finish(),w.sortObjects===!0&&v.sort(te,Y),this.info.render.frame++,ie===!0&&rt.beginShadows();const it=y.state.shadowsArray;if(He.render(it,me,Ve),ie===!0&&rt.endShadows(),this.info.autoReset===!0&&this.info.reset(),he.render(v,me),y.setupLights(w._useLegacyLights),Ve.isArrayCamera){const at=Ve.cameras;for(let nt=0,At=at.length;nt<At;nt++){const ae=at[nt];Mi(v,me,ae,ae.viewport)}}else Mi(v,me,Ve);k!==null&&(se.updateMultisampleRenderTarget(k),se.updateRenderTargetMipmap(k)),me.isScene===!0&&me.onAfterRender(w,me,Ve),$e.resetDefaultState(),F=-1,N=null,E.pop(),E.length>0?y=E[E.length-1]:y=null,b.pop(),b.length>0?v=b[b.length-1]:v=null};function On(me,Ve,it,at){if(me.visible===!1)return;if(me.layers.test(Ve.layers)){if(me.isGroup)it=me.renderOrder;else if(me.isLOD)me.autoUpdate===!0&&me.update(Ve);else if(me.isLight)y.pushLight(me),me.castShadow&&y.pushShadow(me);else if(me.isSprite){if(!me.frustumCulled||ee.intersectsSprite(me)){at&&Z.setFromMatrixPosition(me.matrixWorld).applyMatrix4(be);const ae=L.update(me),Ee=me.material;Ee.visible&&v.push(me,ae,Ee,it,Z.z,null)}}else if((me.isMesh||me.isLine||me.isPoints)&&(!me.frustumCulled||ee.intersectsObject(me))){const ae=L.update(me),Ee=me.material;if(at&&(me.boundingSphere!==void 0?(me.boundingSphere===null&&me.computeBoundingSphere(),Z.copy(me.boundingSphere.center)):(ae.boundingSphere===null&&ae.computeBoundingSphere(),Z.copy(ae.boundingSphere.center)),Z.applyMatrix4(me.matrixWorld).applyMatrix4(be)),Array.isArray(Ee)){const Fe=ae.groups;for(let Oe=0,Ne=Fe.length;Oe<Ne;Oe++){const lt=Fe[Oe],ft=Ee[lt.materialIndex];ft&&ft.visible&&v.push(me,ae,ft,it,Z.z,lt)}}else Ee.visible&&v.push(me,ae,Ee,it,Z.z,null)}}const At=me.children;for(let ae=0,Ee=At.length;ae<Ee;ae++)On(At[ae],Ve,it,at)}function Mi(me,Ve,it,at){const nt=me.opaque,At=me.transmissive,ae=me.transparent;y.setupLightsView(it),ie===!0&&rt.setGlobalState(w.clippingPlanes,it),At.length>0&&si(nt,At,Ve,it),at&&ne.viewport(j.copy(at)),nt.length>0&&Ei(nt,Ve,it),At.length>0&&Ei(At,Ve,it),ae.length>0&&Ei(ae,Ve,it),ne.buffers.depth.setTest(!0),ne.buffers.depth.setMask(!0),ne.buffers.color.setMask(!0),ne.setPolygonOffset(!1)}function si(me,Ve,it,at){if((it.isScene===!0?it.overrideMaterial:null)!==null)return;const At=B.isWebGL2;ue===null&&(ue=new of(1,1,{generateMipmaps:!0,type:z.has("EXT_color_buffer_half_float")?Y0:id,minFilter:X0,samples:At?4:0})),w.getDrawingBufferSize(Re),At?ue.setSize(Re.x,Re.y):ue.setSize(Hw(Re.x),Hw(Re.y));const ae=w.getRenderTarget();w.setRenderTarget(ue),w.getClearColor(q),R=w.getClearAlpha(),R<1&&w.setClearColor(16777215,.5),w.clear();const Ee=w.toneMapping;w.toneMapping=rd,Ei(me,it,at),se.updateMultisampleRenderTarget(ue),se.updateRenderTargetMipmap(ue);let Fe=!1;for(let Oe=0,Ne=Ve.length;Oe<Ne;Oe++){const lt=Ve[Oe],ft=lt.object,wt=lt.geometry,bt=lt.material,Lt=lt.group;if(bt.side===hc&&ft.layers.test(at.layers)){const Ct=bt.side;bt.side=Qa,bt.needsUpdate=!0,zi(ft,it,at,wt,bt,Lt),bt.side=Ct,bt.needsUpdate=!0,Fe=!0}}Fe===!0&&(se.updateMultisampleRenderTarget(ue),se.updateRenderTargetMipmap(ue)),w.setRenderTarget(ae),w.setClearColor(q,R),w.toneMapping=Ee}function Ei(me,Ve,it){const at=Ve.isScene===!0?Ve.overrideMaterial:null;for(let nt=0,At=me.length;nt<At;nt++){const ae=me[nt],Ee=ae.object,Fe=ae.geometry,Oe=at===null?ae.material:at,Ne=ae.group;Ee.layers.test(it.layers)&&zi(Ee,Ve,it,Fe,Oe,Ne)}}function zi(me,Ve,it,at,nt,At){me.onBeforeRender(w,Ve,it,at,nt,At),me.modelViewMatrix.multiplyMatrices(it.matrixWorldInverse,me.matrixWorld),me.normalMatrix.getNormalMatrix(me.modelViewMatrix),nt.onBeforeRender(w,Ve,it,at,me,At),nt.transparent===!0&&nt.side===hc&&nt.forceSinglePass===!1?(nt.side=Qa,nt.needsUpdate=!0,w.renderBufferDirect(it,Ve,at,nt,me,At),nt.side=vd,nt.needsUpdate=!0,w.renderBufferDirect(it,Ve,at,nt,me,At),nt.side=hc):w.renderBufferDirect(it,Ve,at,nt,me,At),me.onAfterRender(w,Ve,it,at,nt,At)}function ra(me,Ve,it){Ve.isScene!==!0&&(Ve=_e);const at=Q.get(me),nt=y.state.lights,At=y.state.shadowsArray,ae=nt.state.version,Ee=re.getParameters(me,nt.state,At,Ve,it),Fe=re.getProgramCacheKey(Ee);let Oe=at.programs;at.environment=me.isMeshStandardMaterial?Ve.environment:null,at.fog=Ve.fog,at.envMap=(me.isMeshStandardMaterial?Ae:Me).get(me.envMap||at.environment),Oe===void 0&&(me.addEventListener("dispose",ke),Oe=new Map,at.programs=Oe);let Ne=Oe.get(Fe);if(Ne!==void 0){if(at.currentProgram===Ne&&at.lightsStateVersion===ae)return yr(me,Ee),Ne}else Ee.uniforms=re.getUniforms(me),me.onBuild(it,Ee,w),me.onBeforeCompile(Ee,w),Ne=re.acquireProgram(Ee,Fe),Oe.set(Fe,Ne),at.uniforms=Ee.uniforms;const lt=at.uniforms;return(!me.isShaderMaterial&&!me.isRawShaderMaterial||me.clipping===!0)&&(lt.clippingPlanes=rt.uniform),yr(me,Ee),at.needsLights=Xc(me),at.lightsStateVersion=ae,at.needsLights&&(lt.ambientLightColor.value=nt.state.ambient,lt.lightProbe.value=nt.state.probe,lt.directionalLights.value=nt.state.directional,lt.directionalLightShadows.value=nt.state.directionalShadow,lt.spotLights.value=nt.state.spot,lt.spotLightShadows.value=nt.state.spotShadow,lt.rectAreaLights.value=nt.state.rectArea,lt.ltc_1.value=nt.state.rectAreaLTC1,lt.ltc_2.value=nt.state.rectAreaLTC2,lt.pointLights.value=nt.state.point,lt.pointLightShadows.value=nt.state.pointShadow,lt.hemisphereLights.value=nt.state.hemi,lt.directionalShadowMap.value=nt.state.directionalShadowMap,lt.directionalShadowMatrix.value=nt.state.directionalShadowMatrix,lt.spotShadowMap.value=nt.state.spotShadowMap,lt.spotLightMatrix.value=nt.state.spotLightMatrix,lt.spotLightMap.value=nt.state.spotLightMap,lt.pointShadowMap.value=nt.state.pointShadowMap,lt.pointShadowMatrix.value=nt.state.pointShadowMatrix),at.currentProgram=Ne,at.uniformsList=null,Ne}function Wr(me){if(me.uniformsList===null){const Ve=me.currentProgram.getUniforms();me.uniformsList=x1.seqWithValue(Ve.seq,me.uniforms)}return me.uniformsList}function yr(me,Ve){const it=Q.get(me);it.outputColorSpace=Ve.outputColorSpace,it.batching=Ve.batching,it.instancing=Ve.instancing,it.instancingColor=Ve.instancingColor,it.skinning=Ve.skinning,it.morphTargets=Ve.morphTargets,it.morphNormals=Ve.morphNormals,it.morphColors=Ve.morphColors,it.morphTargetsCount=Ve.morphTargetsCount,it.numClippingPlanes=Ve.numClippingPlanes,it.numIntersection=Ve.numClipIntersection,it.vertexAlphas=Ve.vertexAlphas,it.vertexTangents=Ve.vertexTangents,it.toneMapping=Ve.toneMapping}function Lr(me,Ve,it,at,nt){Ve.isScene!==!0&&(Ve=_e),se.resetTextureUnits();const At=Ve.fog,ae=at.isMeshStandardMaterial?Ve.environment:null,Ee=k===null?w.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Bc,Fe=(at.isMeshStandardMaterial?Ae:Me).get(at.envMap||ae),Oe=at.vertexColors===!0&&!!it.attributes.color&&it.attributes.color.itemSize===4,Ne=!!it.attributes.tangent&&(!!at.normalMap||at.anisotropy>0),lt=!!it.morphAttributes.position,ft=!!it.morphAttributes.normal,wt=!!it.morphAttributes.color;let bt=rd;at.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(bt=w.toneMapping);const Lt=it.morphAttributes.position||it.morphAttributes.normal||it.morphAttributes.color,Ct=Lt!==void 0?Lt.length:0,pt=Q.get(at),Xt=y.state.lights;if(ie===!0&&(pe===!0||me!==N)){const Ir=me===N&&at.id===F;rt.setState(at,me,Ir)}let Ut=!1;at.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==Xt.state.version||pt.outputColorSpace!==Ee||nt.isBatchedMesh&&pt.batching===!1||!nt.isBatchedMesh&&pt.batching===!0||nt.isInstancedMesh&&pt.instancing===!1||!nt.isInstancedMesh&&pt.instancing===!0||nt.isSkinnedMesh&&pt.skinning===!1||!nt.isSkinnedMesh&&pt.skinning===!0||nt.isInstancedMesh&&pt.instancingColor===!0&&nt.instanceColor===null||nt.isInstancedMesh&&pt.instancingColor===!1&&nt.instanceColor!==null||pt.envMap!==Fe||at.fog===!0&&pt.fog!==At||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==rt.numPlanes||pt.numIntersection!==rt.numIntersection)||pt.vertexAlphas!==Oe||pt.vertexTangents!==Ne||pt.morphTargets!==lt||pt.morphNormals!==ft||pt.morphColors!==wt||pt.toneMapping!==bt||B.isWebGL2===!0&&pt.morphTargetsCount!==Ct)&&(Ut=!0):(Ut=!0,pt.__version=at.version);let an=pt.currentProgram;Ut===!0&&(an=ra(at,Ve,nt));let hn=!1,bn=!1,Ft=!1;const Jt=an.getUniforms(),tn=pt.uniforms;if(ne.useProgram(an.program)&&(hn=!0,bn=!0,Ft=!0),at.id!==F&&(F=at.id,bn=!0),hn||N!==me){Jt.setValue(ce,"projectionMatrix",me.projectionMatrix),Jt.setValue(ce,"viewMatrix",me.matrixWorldInverse);const Ir=Jt.map.cameraPosition;Ir!==void 0&&Ir.setValue(ce,Z.setFromMatrixPosition(me.matrixWorld)),B.logarithmicDepthBuffer&&Jt.setValue(ce,"logDepthBufFC",2/(Math.log(me.far+1)/Math.LN2)),(at.isMeshPhongMaterial||at.isMeshToonMaterial||at.isMeshLambertMaterial||at.isMeshBasicMaterial||at.isMeshStandardMaterial||at.isShaderMaterial)&&Jt.setValue(ce,"isOrthographic",me.isOrthographicCamera===!0),N!==me&&(N=me,bn=!0,Ft=!0)}if(nt.isSkinnedMesh){Jt.setOptional(ce,nt,"bindMatrix"),Jt.setOptional(ce,nt,"bindMatrixInverse");const Ir=nt.skeleton;Ir&&(B.floatVertexTextures?(Ir.boneTexture===null&&Ir.computeBoneTexture(),Jt.setValue(ce,"boneTexture",Ir.boneTexture,se)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}nt.isBatchedMesh&&(Jt.setOptional(ce,nt,"batchingTexture"),Jt.setValue(ce,"batchingTexture",nt._matricesTexture,se));const Cr=it.morphAttributes;if((Cr.position!==void 0||Cr.normal!==void 0||Cr.color!==void 0&&B.isWebGL2===!0)&&Ge.update(nt,it,an),(bn||pt.receiveShadow!==nt.receiveShadow)&&(pt.receiveShadow=nt.receiveShadow,Jt.setValue(ce,"receiveShadow",nt.receiveShadow)),at.isMeshGouraudMaterial&&at.envMap!==null&&(tn.envMap.value=Fe,tn.flipEnvMap.value=Fe.isCubeTexture&&Fe.isRenderTargetTexture===!1?-1:1),bn&&(Jt.setValue(ce,"toneMappingExposure",w.toneMappingExposure),pt.needsLights&&go(tn,Ft),At&&at.fog===!0&&ye.refreshFogUniforms(tn,At),ye.refreshMaterialUniforms(tn,at,G,K,ue),x1.upload(ce,Wr(pt),tn,se)),at.isShaderMaterial&&at.uniformsNeedUpdate===!0&&(x1.upload(ce,Wr(pt),tn,se),at.uniformsNeedUpdate=!1),at.isSpriteMaterial&&Jt.setValue(ce,"center",nt.center),Jt.setValue(ce,"modelViewMatrix",nt.modelViewMatrix),Jt.setValue(ce,"normalMatrix",nt.normalMatrix),Jt.setValue(ce,"modelMatrix",nt.matrixWorld),at.isShaderMaterial||at.isRawShaderMaterial){const Ir=at.uniformsGroups;for(let jn=0,xo=Ir.length;jn<xo;jn++)if(B.isWebGL2){const Ln=Ir[jn];Ye.update(Ln,an),Ye.bind(Ln,an)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return an}function go(me,Ve){me.ambientLightColor.needsUpdate=Ve,me.lightProbe.needsUpdate=Ve,me.directionalLights.needsUpdate=Ve,me.directionalLightShadows.needsUpdate=Ve,me.pointLights.needsUpdate=Ve,me.pointLightShadows.needsUpdate=Ve,me.spotLights.needsUpdate=Ve,me.spotLightShadows.needsUpdate=Ve,me.rectAreaLights.needsUpdate=Ve,me.hemisphereLights.needsUpdate=Ve}function Xc(me){return me.isMeshLambertMaterial||me.isMeshToonMaterial||me.isMeshPhongMaterial||me.isMeshStandardMaterial||me.isShadowMaterial||me.isShaderMaterial&&me.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(me,Ve,it){Q.get(me.texture).__webglTexture=Ve,Q.get(me.depthTexture).__webglTexture=it;const at=Q.get(me);at.__hasExternalTextures=!0,at.__hasExternalTextures&&(at.__autoAllocateDepthBuffer=it===void 0,at.__autoAllocateDepthBuffer||z.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),at.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(me,Ve){const it=Q.get(me);it.__webglFramebuffer=Ve,it.__useDefaultFramebuffer=Ve===void 0},this.setRenderTarget=function(me,Ve=0,it=0){k=me,T=Ve,C=it;let at=!0,nt=null,At=!1,ae=!1;if(me){const Fe=Q.get(me);Fe.__useDefaultFramebuffer!==void 0?(ne.bindFramebuffer(ce.FRAMEBUFFER,null),at=!1):Fe.__webglFramebuffer===void 0?se.setupRenderTarget(me):Fe.__hasExternalTextures&&se.rebindTextures(me,Q.get(me.texture).__webglTexture,Q.get(me.depthTexture).__webglTexture);const Oe=me.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(ae=!0);const Ne=Q.get(me).__webglFramebuffer;me.isWebGLCubeRenderTarget?(Array.isArray(Ne[Ve])?nt=Ne[Ve][it]:nt=Ne[Ve],At=!0):B.isWebGL2&&me.samples>0&&se.useMultisampledRTT(me)===!1?nt=Q.get(me).__webglMultisampledFramebuffer:Array.isArray(Ne)?nt=Ne[it]:nt=Ne,j.copy(me.viewport),I.copy(me.scissor),O=me.scissorTest}else j.copy(J).multiplyScalar(G).floor(),I.copy(U).multiplyScalar(G).floor(),O=H;if(ne.bindFramebuffer(ce.FRAMEBUFFER,nt)&&B.drawBuffers&&at&&ne.drawBuffers(me,nt),ne.viewport(j),ne.scissor(I),ne.setScissorTest(O),At){const Fe=Q.get(me.texture);ce.framebufferTexture2D(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,ce.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,Fe.__webglTexture,it)}else if(ae){const Fe=Q.get(me.texture),Oe=Ve||0;ce.framebufferTextureLayer(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,Fe.__webglTexture,it||0,Oe)}F=-1},this.readRenderTargetPixels=function(me,Ve,it,at,nt,At,ae){if(!(me&&me.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=Q.get(me).__webglFramebuffer;if(me.isWebGLCubeRenderTarget&&ae!==void 0&&(Ee=Ee[ae]),Ee){ne.bindFramebuffer(ce.FRAMEBUFFER,Ee);try{const Fe=me.texture,Oe=Fe.format,Ne=Fe.type;if(Oe!==Js&&tt.convert(Oe)!==ce.getParameter(ce.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const lt=Ne===Y0&&(z.has("EXT_color_buffer_half_float")||B.isWebGL2&&z.has("EXT_color_buffer_float"));if(Ne!==id&&tt.convert(Ne)!==ce.getParameter(ce.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ne===yc&&(B.isWebGL2||z.has("OES_texture_float")||z.has("WEBGL_color_buffer_float")))&&!lt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ve>=0&&Ve<=me.width-at&&it>=0&&it<=me.height-nt&&ce.readPixels(Ve,it,at,nt,tt.convert(Oe),tt.convert(Ne),At)}finally{const Fe=k!==null?Q.get(k).__webglFramebuffer:null;ne.bindFramebuffer(ce.FRAMEBUFFER,Fe)}}},this.copyFramebufferToTexture=function(me,Ve,it=0){const at=Math.pow(2,-it),nt=Math.floor(Ve.image.width*at),At=Math.floor(Ve.image.height*at);se.setTexture2D(Ve,0),ce.copyTexSubImage2D(ce.TEXTURE_2D,it,0,0,me.x,me.y,nt,At),ne.unbindTexture()},this.copyTextureToTexture=function(me,Ve,it,at=0){const nt=Ve.image.width,At=Ve.image.height,ae=tt.convert(it.format),Ee=tt.convert(it.type);se.setTexture2D(it,0),ce.pixelStorei(ce.UNPACK_FLIP_Y_WEBGL,it.flipY),ce.pixelStorei(ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,it.premultiplyAlpha),ce.pixelStorei(ce.UNPACK_ALIGNMENT,it.unpackAlignment),Ve.isDataTexture?ce.texSubImage2D(ce.TEXTURE_2D,at,me.x,me.y,nt,At,ae,Ee,Ve.image.data):Ve.isCompressedTexture?ce.compressedTexSubImage2D(ce.TEXTURE_2D,at,me.x,me.y,Ve.mipmaps[0].width,Ve.mipmaps[0].height,ae,Ve.mipmaps[0].data):ce.texSubImage2D(ce.TEXTURE_2D,at,me.x,me.y,ae,Ee,Ve.image),at===0&&it.generateMipmaps&&ce.generateMipmap(ce.TEXTURE_2D),ne.unbindTexture()},this.copyTextureToTexture3D=function(me,Ve,it,at,nt=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const At=me.max.x-me.min.x+1,ae=me.max.y-me.min.y+1,Ee=me.max.z-me.min.z+1,Fe=tt.convert(at.format),Oe=tt.convert(at.type);let Ne;if(at.isData3DTexture)se.setTexture3D(at,0),Ne=ce.TEXTURE_3D;else if(at.isDataArrayTexture)se.setTexture2DArray(at,0),Ne=ce.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ce.pixelStorei(ce.UNPACK_FLIP_Y_WEBGL,at.flipY),ce.pixelStorei(ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,at.premultiplyAlpha),ce.pixelStorei(ce.UNPACK_ALIGNMENT,at.unpackAlignment);const lt=ce.getParameter(ce.UNPACK_ROW_LENGTH),ft=ce.getParameter(ce.UNPACK_IMAGE_HEIGHT),wt=ce.getParameter(ce.UNPACK_SKIP_PIXELS),bt=ce.getParameter(ce.UNPACK_SKIP_ROWS),Lt=ce.getParameter(ce.UNPACK_SKIP_IMAGES),Ct=it.isCompressedTexture?it.mipmaps[0]:it.image;ce.pixelStorei(ce.UNPACK_ROW_LENGTH,Ct.width),ce.pixelStorei(ce.UNPACK_IMAGE_HEIGHT,Ct.height),ce.pixelStorei(ce.UNPACK_SKIP_PIXELS,me.min.x),ce.pixelStorei(ce.UNPACK_SKIP_ROWS,me.min.y),ce.pixelStorei(ce.UNPACK_SKIP_IMAGES,me.min.z),it.isDataTexture||it.isData3DTexture?ce.texSubImage3D(Ne,nt,Ve.x,Ve.y,Ve.z,At,ae,Ee,Fe,Oe,Ct.data):it.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ce.compressedTexSubImage3D(Ne,nt,Ve.x,Ve.y,Ve.z,At,ae,Ee,Fe,Ct.data)):ce.texSubImage3D(Ne,nt,Ve.x,Ve.y,Ve.z,At,ae,Ee,Fe,Oe,Ct),ce.pixelStorei(ce.UNPACK_ROW_LENGTH,lt),ce.pixelStorei(ce.UNPACK_IMAGE_HEIGHT,ft),ce.pixelStorei(ce.UNPACK_SKIP_PIXELS,wt),ce.pixelStorei(ce.UNPACK_SKIP_ROWS,bt),ce.pixelStorei(ce.UNPACK_SKIP_IMAGES,Lt),nt===0&&at.generateMipmaps&&ce.generateMipmap(Ne),ne.unbindTexture()},this.initTexture=function(me){me.isCubeTexture?se.setTextureCube(me,0):me.isData3DTexture?se.setTexture3D(me,0):me.isDataArrayTexture||me.isCompressedArrayTexture?se.setTexture2DArray(me,0):se.setTexture2D(me,0),ne.unbindTexture()},this.resetState=function(){T=0,C=0,k=null,ne.reset(),$e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ll}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===MO?"display-p3":"srgb",n.unpackColorSpace=Yn.workingColorSpace===KM?"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?Lh:UZ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Lh?Qi:Bc}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 FFe extends $P{}FFe.prototype.isWebGL1Renderer=!0;class kO{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 kO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class UFe extends Ca{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 zFe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=UP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Tc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Tc()),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=Tc()),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 va=new De;class Xu{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++)va.fromBufferAttribute(this,n),va.applyMatrix4(e),this.setXYZ(n,va.x,va.y,va.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)va.fromBufferAttribute(this,n),va.applyNormalMatrix(e),this.setXYZ(n,va.x,va.y,va.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)va.fromBufferAttribute(this,n),va.transformDirection(e),this.setXYZ(n,va.x,va.y,va.z);return this}setX(e,n){return this.normalized&&(n=Xn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Xn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Xn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Xn(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=il(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=il(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=il(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=il(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Xn(n,this.array),r=Xn(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=Xn(n,this.array),r=Xn(r,this.array),i=Xn(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=Xn(n,this.array),r=Xn(r,this.array),i=Xn(i,this.array),a=Xn(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new As(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 Xu(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class BFe extends Ja{constructor(e=null,n=1,r=1,i,a,s,o,c,u=Zi,d=Zi,f,g){super(null,s,o,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function HFe(t,e){return t.z-e.z}function $Fe(t,e){return e.z-t.z}class VFe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const Om="batchId",ku=new or,gV=new or,GFe=new or,xV=new or,TN=new XM,N_=new so,ah=new dl,Px=new De,CN=new VFe,ca=new Do,k_=[];function WFe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let s=0;s<r;s++)e.setComponent(a+n,s,t.getComponent(a,s))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class qFe extends Do{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new xa,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 BFe(n,e,e,Js,yc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const c=e.getAttribute(o),{array:u,itemSize:d,normalized:f}=c,g=new u.constructor(r*d),p=new c.constructor(g,d,f);p.setUsage(c.usage),n.setAttribute(o,p)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new As(o,1))}const s=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Om,new As(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Om))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Om}"`);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===Om)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new so);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,ku),this.getBoundingBoxAt(i,N_).applyMatrix4(ku),n.union(N_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new dl);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,ku),this.getBoundingSphereAt(i,ah).applyMatrix4(ku),n.union(ah))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const s=this._reservedRanges,o=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=s[s.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const v=this._geometryCount;this._geometryCount++,GFe.toArray(x,v*16),p.needsUpdate=!0,s.push(i),o.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new so,sphereInitialized:!1,sphere:new dl});const y=this.geometry.getAttribute(Om);for(let b=0;b<i.vertexCount;b++)y.setX(i.vertexStart+b,v);return y.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),s=n.getIndex(),o=this._reservedRanges[e];if(i&&s.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=o.vertexStart,u=o.vertexCount;for(const p in r.attributes){if(p===Om)continue;const x=n.getAttribute(p),v=r.getAttribute(p);WFe(x,v,c);const y=x.itemSize;for(let b=x.count,E=u;b<E;b++){const w=c+b;for(let A=0;A<y;A++)v.setComponent(w,A,0)}v.needsUpdate=!0}if(i){const p=o.indexStart;for(let x=0;x<s.count;x++)a.setX(p+x,c+s.getX(x));for(let x=s.count,v=o.indexCount;x<v;x++)a.setX(p+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?s.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,s=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const o=s.index,c=s.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let g=d;o&&(g=o.getX(g)),a.expandByPoint(Px.fromBufferAttribute(c,g))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,N_),N_.getCenter(a.center);const o=s.index,c=s.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,g=u.start+u.count;f<g;f++){let p=f;o&&(p=o.getX(p)),Px.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(Px))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,s=this._geometryCount,o=this.matrixWorld,c=this.geometry;ca.material=this.material,ca.geometry.index=c.index,ca.geometry.attributes=c.attributes,ca.geometry.boundingBox===null&&(ca.geometry.boundingBox=new so),ca.geometry.boundingSphere===null&&(ca.geometry.boundingSphere=new dl);for(let u=0;u<s;u++){if(!r[u]||!i[u])continue;const d=a[u];ca.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ca.matrixWorld).premultiply(o),this.getBoundingBoxAt(u,ca.geometry.boundingBox),this.getBoundingSphereAt(u,ca.geometry.boundingSphere),ca.raycast(e,k_);for(let f=0,g=k_.length;f<g;f++){const p=k_[f];p.object=this,p.batchId=u,n.push(p)}k_.length=0}ca.material=null,ca.geometry.index=null,ca.geometry.attributes={},ca.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(xV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),TN.setFromProjectionMatrix(xV,e.isWebGPURenderer?Z0:ll));let p=0;if(this.sortObjects){gV.copy(this.matrixWorld).invert(),Px.setFromMatrixPosition(r.matrixWorld).applyMatrix4(gV);for(let y=0,b=c.length;y<b;y++)if(c[y]){this.getMatrixAt(y,ku),this.getBoundingSphereAt(y,ah).applyMatrix4(ku);let E=!1;if(g&&(E=!TN.intersectsSphere(ah)),!E){const w=Px.distanceTo(ah.center);CN.push(f[y],w)}}const x=CN.list,v=this.customSort;v===null?x.sort(a.transparent?$Fe:HFe):v.call(this,x,r);for(let y=0,b=x.length;y<b;y++){const E=x[y];u[p]=E.start*o,d[p]=E.count,p++}CN.reset()}else for(let x=0,v=c.length;x<v;x++)if(c[x]){let y=!1;if(g&&(this.getMatrixAt(x,ku),this.getBoundingSphereAt(x,ah).applyMatrix4(ku),y=!TN.intersectsSphere(ah)),!y){const b=f[x];u[p]=b.start*o,d[p]=b.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,s){this.onBeforeRender(e,null,i,a,s)}}class Zb extends fg{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 bV=new De,yV=new De,vV=new or,NN=new AO,P_=new dl;class KFe extends Ca{constructor(e=new xa,n=new Zb){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)bV.fromBufferAttribute(n,i-1),yV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=bV.distanceTo(yV);e.setAttribute("lineDistance",new Vr(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),P_.copy(r.boundingSphere),P_.applyMatrix4(i),P_.radius+=a,e.ray.intersectsSphere(P_)===!1)return;vV.copy(i).invert(),NN.copy(e.ray).applyMatrix4(vV);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=new De,d=new De,f=new De,g=new De,p=this.isLineSegments?2:1,x=r.index,y=r.attributes.position;if(x!==null){const b=Math.max(0,s.start),E=Math.min(x.count,s.start+s.count);for(let w=b,A=E-1;w<A;w+=p){const T=x.getX(w),C=x.getX(w+1);if(u.fromBufferAttribute(y,T),d.fromBufferAttribute(y,C),NN.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const F=e.ray.origin.distanceTo(g);F<e.near||F>e.far||n.push({distance:F,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const b=Math.max(0,s.start),E=Math.min(y.count,s.start+s.count);for(let w=b,A=E-1;w<A;w+=p){if(u.fromBufferAttribute(y,w),d.fromBufferAttribute(y,w+1),NN.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(g);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const o=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}const _V=new De,wV=new De;class ZM extends KFe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)_V.fromBufferAttribute(n,i),wV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+_V.distanceTo(wV);e.setAttribute("lineDistance",new Vr(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class XFe extends xa{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new De,a=new De;if(e.index!==null){const s=e.attributes.position,o=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,p=f.count;for(let x=g,v=g+p;x<v;x+=3)for(let y=0;y<3;y++){const b=o.getX(x+y),E=o.getX(x+(y+1)%3);i.fromBufferAttribute(s,b),a.fromBufferAttribute(s,E),SV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let o=0,c=s.count/3;o<c;o++)for(let u=0;u<3;u++){const d=3*o+u,f=3*o+(u+1)%3;i.fromBufferAttribute(s,d),a.fromBufferAttribute(s,f),SV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Vr(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function SV(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 YFe extends fg{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=zZ,this.normalScale=new Zt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=wO,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 ZFe extends Zb{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 lQ extends Ca{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 kN=new or,MV=new De,EV=new De;class QFe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Zt(512,512),this.map=null,this.mapPass=null,this.matrix=new or,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new XM,this._frameExtents=new Zt(1,1),this._viewportCount=1,this._viewports=[new Qn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;MV.setFromMatrixPosition(e.matrixWorld),n.position.copy(MV),EV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(EV),n.updateMatrixWorld(),kN.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kN),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(kN)}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 AV=new or,Rx=new De,PN=new De;class JFe extends QFe{constructor(){super(new ys(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Zt(4,2),this._viewportCount=6,this._viewports=[new Qn(2,1,1,1),new Qn(0,1,1,1),new Qn(3,1,1,1),new Qn(1,1,1,1),new Qn(3,0,1,1),new Qn(1,0,1,1)],this._cubeDirections=[new De(1,0,0),new De(-1,0,0),new De(0,0,1),new De(0,0,-1),new De(0,1,0),new De(0,-1,0)],this._cubeUps=[new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,0,1),new De(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),Rx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Rx),PN.copy(r.position),PN.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(PN),r.updateMatrixWorld(),i.makeTranslation(-Rx.x,-Rx.y,-Rx.z),AV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(AV)}}class eUe extends lQ{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 JFe}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 tUe extends lQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class nUe extends xa{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 VP extends zFe{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 TV{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(Ji(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const CV=new De,R_=new De;class rUe{constructor(e=new De,n=new De){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){CV.subVectors(e,this.start),R_.subVectors(this.end,this.start);const r=R_.dot(R_);let a=R_.dot(CV)/r;return n&&(a=Ji(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class iUe extends ZM{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 xa;i.setAttribute("position",new Vr(n,3)),i.setAttribute("color",new Vr(r,3));const a=new Zb({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new $t,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:WM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=WM);class hl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),hl.nextNameID=hl.nextNameID||0,this.$name.id=`lil-gui-name-${++hl.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",s=>s.stopPropagation()),this.domElement.addEventListener("keyup",s=>s.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class aUe extends hl{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 GP(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 sUe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:GP,toHexString:GP},J0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},oUe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=J0.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 J0.toHexString(i)}},lUe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=J0.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 J0.toHexString(i)}},cUe=[sUe,J0,oUe,lUe];function uUe(t){return cUe.find(e=>e.match(t))}class dUe extends hl{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=uUe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=GP(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class RN extends hl{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 hUe extends hl{constructor(e,n,r,i,a,s){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const o=s!==void 0;this.step(o?s:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let E=parseFloat(this.$input.value);isNaN(E)||(this._stepExplicit&&(E=this._snap(E)),this.setValue(this._clamp(E)))},r=E=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},a=E=>{this._inputFocused&&(E.preventDefault(),r(this._step*this._normalizeMouseWheel(E)))};let s=!1,o,c,u,d,f;const g=5,p=E=>{o=E.clientX,c=u=E.clientY,s=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},x=E=>{if(s){const w=E.clientX-o,A=E.clientY-c;Math.abs(A)>g?(E.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&v()}if(!s){const w=E.clientY-u;f-=w*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)},y=()=>{this._inputFocused=!0},b=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",y),this.$input.addEventListener("blur",b)}_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=(b,E,w,A,T)=>(b-E)/(w-E)*(T-A)+A,n=b=>{const E=this.$slider.getBoundingClientRect();let w=e(b,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=b=>{n(b.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,o,c;const u=b=>{b.preventDefault(),this._setDraggingStyle(!0),n(b.touches[0].clientX),s=!1},d=b=>{b.touches.length>1||(this._hasScrollBar?(o=b.touches[0].clientX,c=b.touches[0].clientY,s=!0):u(b),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=b=>{if(s){const E=b.touches[0].clientX-o,w=b.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(b):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else b.preventDefault(),n(b.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},p=this._callOnFinishChange.bind(this),x=400;let v;const y=b=>{if(Math.abs(b.deltaX)<Math.abs(b.deltaY)&&this._hasScrollBar)return;b.preventDefault();const w=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",y,{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 fUe extends hl{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 mUe extends hl{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 pUe=`.lil-gui {
  7432. font-family: var(--font-family);
  7433. font-size: var(--font-size);
  7434. line-height: 1;
  7435. font-weight: normal;
  7436. font-style: normal;
  7437. text-align: left;
  7438. color: var(--text-color);
  7439. user-select: none;
  7440. -webkit-user-select: none;
  7441. touch-action: manipulation;
  7442. --background-color: #1f1f1f;
  7443. --text-color: #ebebeb;
  7444. --title-background-color: #111111;
  7445. --title-text-color: #ebebeb;
  7446. --widget-color: #424242;
  7447. --hover-color: #4f4f4f;
  7448. --focus-color: #595959;
  7449. --number-color: #2cc9ff;
  7450. --string-color: #a2db3c;
  7451. --font-size: 11px;
  7452. --input-font-size: 11px;
  7453. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7454. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7455. --padding: 4px;
  7456. --spacing: 4px;
  7457. --widget-height: 20px;
  7458. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7459. --name-width: 45%;
  7460. --slider-knob-width: 2px;
  7461. --slider-input-width: 27%;
  7462. --color-input-width: 27%;
  7463. --slider-input-min-width: 45px;
  7464. --color-input-min-width: 45px;
  7465. --folder-indent: 7px;
  7466. --widget-padding: 0 0 0 3px;
  7467. --widget-border-radius: 2px;
  7468. --checkbox-size: calc(0.75 * var(--widget-height));
  7469. --scrollbar-width: 5px;
  7470. }
  7471. .lil-gui, .lil-gui * {
  7472. box-sizing: border-box;
  7473. margin: 0;
  7474. padding: 0;
  7475. }
  7476. .lil-gui.root {
  7477. width: var(--width, 245px);
  7478. display: flex;
  7479. flex-direction: column;
  7480. background: var(--background-color);
  7481. }
  7482. .lil-gui.root > .title {
  7483. background: var(--title-background-color);
  7484. color: var(--title-text-color);
  7485. }
  7486. .lil-gui.root > .children {
  7487. overflow-x: hidden;
  7488. overflow-y: auto;
  7489. }
  7490. .lil-gui.root > .children::-webkit-scrollbar {
  7491. width: var(--scrollbar-width);
  7492. height: var(--scrollbar-width);
  7493. background: var(--background-color);
  7494. }
  7495. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7496. border-radius: var(--scrollbar-width);
  7497. background: var(--focus-color);
  7498. }
  7499. @media (pointer: coarse) {
  7500. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7501. --widget-height: 28px;
  7502. --padding: 6px;
  7503. --spacing: 6px;
  7504. --font-size: 13px;
  7505. --input-font-size: 16px;
  7506. --folder-indent: 10px;
  7507. --scrollbar-width: 7px;
  7508. --slider-input-min-width: 50px;
  7509. --color-input-min-width: 65px;
  7510. }
  7511. }
  7512. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7513. --widget-height: 28px;
  7514. --padding: 6px;
  7515. --spacing: 6px;
  7516. --font-size: 13px;
  7517. --input-font-size: 16px;
  7518. --folder-indent: 10px;
  7519. --scrollbar-width: 7px;
  7520. --slider-input-min-width: 50px;
  7521. --color-input-min-width: 65px;
  7522. }
  7523. .lil-gui.autoPlace {
  7524. max-height: 100%;
  7525. position: fixed;
  7526. top: 0;
  7527. right: 15px;
  7528. z-index: 1001;
  7529. }
  7530. .lil-gui .controller {
  7531. display: flex;
  7532. align-items: center;
  7533. padding: 0 var(--padding);
  7534. margin: var(--spacing) 0;
  7535. }
  7536. .lil-gui .controller.disabled {
  7537. opacity: 0.5;
  7538. }
  7539. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7540. pointer-events: none !important;
  7541. }
  7542. .lil-gui .controller > .name {
  7543. min-width: var(--name-width);
  7544. flex-shrink: 0;
  7545. white-space: pre;
  7546. padding-right: var(--spacing);
  7547. line-height: var(--widget-height);
  7548. }
  7549. .lil-gui .controller .widget {
  7550. position: relative;
  7551. display: flex;
  7552. align-items: center;
  7553. width: 100%;
  7554. min-height: var(--widget-height);
  7555. }
  7556. .lil-gui .controller.string input {
  7557. color: var(--string-color);
  7558. }
  7559. .lil-gui .controller.boolean {
  7560. cursor: pointer;
  7561. }
  7562. .lil-gui .controller.color .display {
  7563. width: 100%;
  7564. height: var(--widget-height);
  7565. border-radius: var(--widget-border-radius);
  7566. position: relative;
  7567. }
  7568. @media (hover: hover) {
  7569. .lil-gui .controller.color .display:hover:before {
  7570. content: " ";
  7571. display: block;
  7572. position: absolute;
  7573. border-radius: var(--widget-border-radius);
  7574. border: 1px solid #fff9;
  7575. top: 0;
  7576. right: 0;
  7577. bottom: 0;
  7578. left: 0;
  7579. }
  7580. }
  7581. .lil-gui .controller.color input[type=color] {
  7582. opacity: 0;
  7583. width: 100%;
  7584. height: 100%;
  7585. cursor: pointer;
  7586. }
  7587. .lil-gui .controller.color input[type=text] {
  7588. margin-left: var(--spacing);
  7589. font-family: var(--font-family-mono);
  7590. min-width: var(--color-input-min-width);
  7591. width: var(--color-input-width);
  7592. flex-shrink: 0;
  7593. }
  7594. .lil-gui .controller.option select {
  7595. opacity: 0;
  7596. position: absolute;
  7597. width: 100%;
  7598. max-width: 100%;
  7599. }
  7600. .lil-gui .controller.option .display {
  7601. position: relative;
  7602. pointer-events: none;
  7603. border-radius: var(--widget-border-radius);
  7604. height: var(--widget-height);
  7605. line-height: var(--widget-height);
  7606. max-width: 100%;
  7607. overflow: hidden;
  7608. word-break: break-all;
  7609. padding-left: 0.55em;
  7610. padding-right: 1.75em;
  7611. background: var(--widget-color);
  7612. }
  7613. @media (hover: hover) {
  7614. .lil-gui .controller.option .display.focus {
  7615. background: var(--focus-color);
  7616. }
  7617. }
  7618. .lil-gui .controller.option .display.active {
  7619. background: var(--focus-color);
  7620. }
  7621. .lil-gui .controller.option .display:after {
  7622. font-family: "lil-gui";
  7623. content: "↕";
  7624. position: absolute;
  7625. top: 0;
  7626. right: 0;
  7627. bottom: 0;
  7628. padding-right: 0.375em;
  7629. }
  7630. .lil-gui .controller.option .widget,
  7631. .lil-gui .controller.option select {
  7632. cursor: pointer;
  7633. }
  7634. @media (hover: hover) {
  7635. .lil-gui .controller.option .widget:hover .display {
  7636. background: var(--hover-color);
  7637. }
  7638. }
  7639. .lil-gui .controller.number input {
  7640. color: var(--number-color);
  7641. }
  7642. .lil-gui .controller.number.hasSlider input {
  7643. margin-left: var(--spacing);
  7644. width: var(--slider-input-width);
  7645. min-width: var(--slider-input-min-width);
  7646. flex-shrink: 0;
  7647. }
  7648. .lil-gui .controller.number .slider {
  7649. width: 100%;
  7650. height: var(--widget-height);
  7651. background: var(--widget-color);
  7652. border-radius: var(--widget-border-radius);
  7653. padding-right: var(--slider-knob-width);
  7654. overflow: hidden;
  7655. cursor: ew-resize;
  7656. touch-action: pan-y;
  7657. }
  7658. @media (hover: hover) {
  7659. .lil-gui .controller.number .slider:hover {
  7660. background: var(--hover-color);
  7661. }
  7662. }
  7663. .lil-gui .controller.number .slider.active {
  7664. background: var(--focus-color);
  7665. }
  7666. .lil-gui .controller.number .slider.active .fill {
  7667. opacity: 0.95;
  7668. }
  7669. .lil-gui .controller.number .fill {
  7670. height: 100%;
  7671. border-right: var(--slider-knob-width) solid var(--number-color);
  7672. box-sizing: content-box;
  7673. }
  7674. .lil-gui-dragging .lil-gui {
  7675. --hover-color: var(--widget-color);
  7676. }
  7677. .lil-gui-dragging * {
  7678. cursor: ew-resize !important;
  7679. }
  7680. .lil-gui-dragging.lil-gui-vertical * {
  7681. cursor: ns-resize !important;
  7682. }
  7683. .lil-gui .title {
  7684. height: var(--title-height);
  7685. line-height: calc(var(--title-height) - 4px);
  7686. font-weight: 600;
  7687. padding: 0 var(--padding);
  7688. -webkit-tap-highlight-color: transparent;
  7689. cursor: pointer;
  7690. outline: none;
  7691. text-decoration-skip: objects;
  7692. }
  7693. .lil-gui .title:before {
  7694. font-family: "lil-gui";
  7695. content: "▾";
  7696. padding-right: 2px;
  7697. display: inline-block;
  7698. }
  7699. .lil-gui .title:active {
  7700. background: var(--title-background-color);
  7701. opacity: 0.75;
  7702. }
  7703. @media (hover: hover) {
  7704. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7705. background: var(--title-background-color);
  7706. opacity: 0.85;
  7707. }
  7708. .lil-gui .title:focus {
  7709. text-decoration: underline var(--focus-color);
  7710. }
  7711. }
  7712. .lil-gui.root > .title:focus {
  7713. text-decoration: none !important;
  7714. }
  7715. .lil-gui.closed > .title:before {
  7716. content: "▸";
  7717. }
  7718. .lil-gui.closed > .children {
  7719. transform: translateY(-7px);
  7720. opacity: 0;
  7721. }
  7722. .lil-gui.closed:not(.transition) > .children {
  7723. display: none;
  7724. }
  7725. .lil-gui.transition > .children {
  7726. transition-duration: 300ms;
  7727. transition-property: height, opacity, transform;
  7728. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7729. overflow: hidden;
  7730. pointer-events: none;
  7731. }
  7732. .lil-gui .children:empty:before {
  7733. content: "Empty";
  7734. padding: 0 var(--padding);
  7735. margin: var(--spacing) 0;
  7736. display: block;
  7737. height: var(--widget-height);
  7738. font-style: italic;
  7739. line-height: var(--widget-height);
  7740. opacity: 0.5;
  7741. }
  7742. .lil-gui.root > .children > .lil-gui > .title {
  7743. border: 0 solid var(--widget-color);
  7744. border-width: 1px 0;
  7745. transition: border-color 300ms;
  7746. }
  7747. .lil-gui.root > .children > .lil-gui.closed > .title {
  7748. border-bottom-color: transparent;
  7749. }
  7750. .lil-gui + .controller {
  7751. border-top: 1px solid var(--widget-color);
  7752. margin-top: 0;
  7753. padding-top: var(--spacing);
  7754. }
  7755. .lil-gui .lil-gui .lil-gui > .title {
  7756. border: none;
  7757. }
  7758. .lil-gui .lil-gui .lil-gui > .children {
  7759. border: none;
  7760. margin-left: var(--folder-indent);
  7761. border-left: 2px solid var(--widget-color);
  7762. }
  7763. .lil-gui .lil-gui .controller {
  7764. border: none;
  7765. }
  7766. .lil-gui label, .lil-gui input, .lil-gui button {
  7767. -webkit-tap-highlight-color: transparent;
  7768. }
  7769. .lil-gui input {
  7770. border: 0;
  7771. outline: none;
  7772. font-family: var(--font-family);
  7773. font-size: var(--input-font-size);
  7774. border-radius: var(--widget-border-radius);
  7775. height: var(--widget-height);
  7776. background: var(--widget-color);
  7777. color: var(--text-color);
  7778. width: 100%;
  7779. }
  7780. @media (hover: hover) {
  7781. .lil-gui input:hover {
  7782. background: var(--hover-color);
  7783. }
  7784. .lil-gui input:active {
  7785. background: var(--focus-color);
  7786. }
  7787. }
  7788. .lil-gui input:disabled {
  7789. opacity: 1;
  7790. }
  7791. .lil-gui input[type=text],
  7792. .lil-gui input[type=number] {
  7793. padding: var(--widget-padding);
  7794. -moz-appearance: textfield;
  7795. }
  7796. .lil-gui input[type=text]:focus,
  7797. .lil-gui input[type=number]:focus {
  7798. background: var(--focus-color);
  7799. }
  7800. .lil-gui input[type=checkbox] {
  7801. appearance: none;
  7802. width: var(--checkbox-size);
  7803. height: var(--checkbox-size);
  7804. border-radius: var(--widget-border-radius);
  7805. text-align: center;
  7806. cursor: pointer;
  7807. }
  7808. .lil-gui input[type=checkbox]:checked:before {
  7809. font-family: "lil-gui";
  7810. content: "✓";
  7811. font-size: var(--checkbox-size);
  7812. line-height: var(--checkbox-size);
  7813. }
  7814. @media (hover: hover) {
  7815. .lil-gui input[type=checkbox]:focus {
  7816. box-shadow: inset 0 0 0 1px var(--focus-color);
  7817. }
  7818. }
  7819. .lil-gui button {
  7820. outline: none;
  7821. cursor: pointer;
  7822. font-family: var(--font-family);
  7823. font-size: var(--font-size);
  7824. color: var(--text-color);
  7825. width: 100%;
  7826. height: var(--widget-height);
  7827. text-transform: none;
  7828. background: var(--widget-color);
  7829. border-radius: var(--widget-border-radius);
  7830. border: none;
  7831. }
  7832. @media (hover: hover) {
  7833. .lil-gui button:hover {
  7834. background: var(--hover-color);
  7835. }
  7836. .lil-gui button:focus {
  7837. box-shadow: inset 0 0 0 1px var(--focus-color);
  7838. }
  7839. }
  7840. .lil-gui button:active {
  7841. background: var(--focus-color);
  7842. }
  7843. @font-face {
  7844. font-family: "lil-gui";
  7845. 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");
  7846. }`;function gUe(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 NV=!1;class Vw{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:s=!1,injectStyles:o=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!NV&&o&&(gUe(pUe),NV=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=s}add(e,n,r,i,a){if(Object(r)===r)return new fUe(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new hUe(this,e,n,r,i,a);case"boolean":return new aUe(this,e,n);case"string":return new mUe(this,e,n);case"function":return new RN(this,e,n)}console.error(`gui.add failed
  7847. property:`,n,`
  7848. object:`,e,`
  7849. value:`,s)}addColor(e,n,r=1){return new dUe(this,e,n,r)}addFolder(e){const n=new Vw({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof RN||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 RN)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function jN(t,e,n,r){return new(n||(n=Promise))((function(i,a){function s(u){try{c(r.next(u))}catch(d){a(d)}}function o(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(s,o)}c((r=r.apply(t,[])).next())}))}class PO{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 PO(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 RO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class kV extends RO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Pu extends RO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class PV{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class Gw{constructor(e){this.lines=[],this.preamble=new PV(-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(`
  7850. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,s]of Object.entries(i))this.metadata.thumbnails[a]=s;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],s=n&&i[1]||void 0,o=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",u=this.parseParams(o.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new kV(e,c,u,s);case"t0":return new Pu(e,c,s,0);case"t1":return new Pu(e,c,s,1);case"t2":return new Pu(e,c,s,2);case"t3":return new Pu(e,c,s,3);case"t4":return new Pu(e,c,s,4);case"t5":return new Pu(e,c,s,5);case"t6":return new Pu(e,c,s,6);case"t7":return new Pu(e,c,s,7);default:return new RO(e,c,u,s)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,a)=>{if(i%2==0)return n;let s=a[i-1];return s=s.toLowerCase(),this.isAlpha(s)&&(n[s]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof kV){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const s=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new PV(this.layers.length,[],r,s))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const s=a.indexOf("thumbnail begin"),o=a.indexOf("thumbnail end");s>-1?r=PO.parse(a.slice(s+15).trim()):r&&(o==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}Gw.prototype.parseGcode=Gw.prototype.parseGCode;const RV={type:"change"},DN={type:"start"},jV={type:"end"},j_=new AO,DV=new Iu,xUe=Math.cos(70*HZ.DEG2RAD);class bUe extends bf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new De,this.cursor=new De,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:xm.ROTATE,MIDDLE:xm.DOLLY,RIGHT:xm.PAN},this.touches={ONE:bm.ROTATE,TWO:bm.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(B){B.addEventListener("keydown",Le),this._domElementKeyEvents=B},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Le),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(RV),r.update(),a=i.NONE},this.update=(function(){const B=new De,ne=new lf().setFromUnitVectors(e.up,new De(0,1,0)),V=ne.clone().invert(),Q=new De,se=new lf,Me=new De,Ae=2*Math.PI;return function(Se=null){const $=r.object.position;B.copy($).sub(r.target),B.applyQuaternion(ne),o.setFromVector3(B),r.autoRotate&&a===i.NONE&&j((function(we){return we!==null?2*Math.PI/60*r.autoRotateSpeed*we:2*Math.PI/60/60*r.autoRotateSpeed})(Se)),r.enableDamping?(o.theta+=c.theta*r.dampingFactor,o.phi+=c.phi*r.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let L=r.minAzimuthAngle,re=r.maxAzimuthAngle;isFinite(L)&&isFinite(re)&&(L<-Math.PI?L+=Ae:L>Math.PI&&(L-=Ae),re<-Math.PI?re+=Ae:re>Math.PI&&(re-=Ae),o.theta=L<=re?Math.max(L,Math.min(re,o.theta)):o.theta>(L+re)/2?Math.max(L,o.theta):Math.min(re,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&&C||r.object.isOrthographicCamera?o.radius=te(o.radius):o.radius=te(o.radius*u),B.setFromSpherical(o),B.applyQuaternion(V),$.copy(r.target).add(B),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ye=!1;if(r.zoomToCursor&&C){let we=null;if(r.object.isPerspectiveCamera){const xe=B.length();we=te(xe*u);const rt=xe-we;r.object.position.addScaledVector(A,rt),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const xe=new De(T.x,T.y,0);xe.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0;const rt=new De(T.x,T.y,0);rt.unproject(r.object),r.object.position.sub(rt).add(xe),r.object.updateMatrixWorld(),we=B.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;we!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(we).add(r.object.position):(j_.origin.copy(r.object.position),j_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(j_.direction))<xUe?e.lookAt(r.target):(DV.setFromNormalAndCoplanarPoint(r.object.up,r.target),j_.intersectPlane(DV,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0);return u=1,C=!1,!!(ye||Q.distanceToSquared(r.object.position)>s||8*(1-se.dot(r.object.quaternion))>s||Me.distanceToSquared(r.target)>0)&&(r.dispatchEvent(RV),Q.copy(r.object.position),se.copy(r.object.quaternion),Me.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ce),r.domElement.removeEventListener("pointerdown",be),r.domElement.removeEventListener("pointercancel",Z),r.domElement.removeEventListener("wheel",_e),r.domElement.removeEventListener("pointermove",Re),r.domElement.removeEventListener("pointerup",Z),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Le),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const s=1e-6,o=new TV,c=new TV;let u=1;const d=new De,f=new Zt,g=new Zt,p=new Zt,x=new Zt,v=new Zt,y=new Zt,b=new Zt,E=new Zt,w=new Zt,A=new De,T=new Zt;let C=!1;const k=[],F={};function N(){return Math.pow(.95,r.zoomSpeed)}function j(B){c.theta-=B}function I(B){c.phi-=B}const O=(function(){const B=new De;return function(ne,V){B.setFromMatrixColumn(V,0),B.multiplyScalar(-ne),d.add(B)}})(),q=(function(){const B=new De;return function(ne,V){r.screenSpacePanning===!0?B.setFromMatrixColumn(V,1):(B.setFromMatrixColumn(V,0),B.crossVectors(r.object.up,B)),B.multiplyScalar(ne),d.add(B)}})(),R=(function(){const B=new De;return function(ne,V){const Q=r.domElement;if(r.object.isPerspectiveCamera){const se=r.object.position;B.copy(se).sub(r.target);let Me=B.length();Me*=Math.tan(r.object.fov/2*Math.PI/180),O(2*ne*Me/Q.clientHeight,r.object.matrix),q(2*V*Me/Q.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(ne*(r.object.right-r.object.left)/r.object.zoom/Q.clientWidth,r.object.matrix),q(V*(r.object.top-r.object.bottom)/r.object.zoom/Q.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(B){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(B){if(!r.zoomToCursor)return;C=!0;const ne=r.domElement.getBoundingClientRect(),V=B.clientX-ne.left,Q=B.clientY-ne.top,se=ne.width,Me=ne.height;T.x=V/se*2-1,T.y=-Q/Me*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function te(B){return Math.max(r.minDistance,Math.min(r.maxDistance,B))}function Y(B){f.set(B.clientX,B.clientY)}function J(B){x.set(B.clientX,B.clientY)}function U(){if(k.length===1)f.set(k[0].pageX,k[0].pageY);else{const B=.5*(k[0].pageX+k[1].pageX),ne=.5*(k[0].pageY+k[1].pageY);f.set(B,ne)}}function H(){if(k.length===1)x.set(k[0].pageX,k[0].pageY);else{const B=.5*(k[0].pageX+k[1].pageX),ne=.5*(k[0].pageY+k[1].pageY);x.set(B,ne)}}function ee(){const B=k[0].pageX-k[1].pageX,ne=k[0].pageY-k[1].pageY,V=Math.sqrt(B*B+ne*ne);b.set(0,V)}function ie(B){if(k.length==1)g.set(B.pageX,B.pageY);else{const V=z(B),Q=.5*(B.pageX+V.x),se=.5*(B.pageY+V.y);g.set(Q,se)}p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ne=r.domElement;j(2*Math.PI*p.x/ne.clientHeight),I(2*Math.PI*p.y/ne.clientHeight),f.copy(g)}function pe(B){if(k.length===1)v.set(B.pageX,B.pageY);else{const ne=z(B),V=.5*(B.pageX+ne.x),Q=.5*(B.pageY+ne.y);v.set(V,Q)}y.subVectors(v,x).multiplyScalar(r.panSpeed),R(y.x,y.y),x.copy(v)}function ue(B){const ne=z(B),V=B.pageX-ne.x,Q=B.pageY-ne.y,se=Math.sqrt(V*V+Q*Q);E.set(0,se),w.set(0,Math.pow(E.y/b.y,r.zoomSpeed)),W(w.y),b.copy(E)}function be(B){r.enabled!==!1&&(k.length===0&&(r.domElement.setPointerCapture(B.pointerId),r.domElement.addEventListener("pointermove",Re),r.domElement.addEventListener("pointerup",Z)),(function(ne){k.push(ne)})(B),B.pointerType==="touch"?(function(ne){switch(Ie(ne),k.length){case 1:switch(r.touches.ONE){case bm.ROTATE:if(r.enableRotate===!1)return;U(),a=i.TOUCH_ROTATE;break;case bm.PAN:if(r.enablePan===!1)return;H(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case bm.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ee(),r.enablePan&&H(),a=i.TOUCH_DOLLY_PAN;break;case bm.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ee(),r.enableRotate&&U(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(DN)})(B):(function(ne){let V;switch(ne.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 xm.DOLLY:if(r.enableZoom===!1)return;(function(Q){G(Q),b.set(Q.clientX,Q.clientY)})(ne),a=i.DOLLY;break;case xm.ROTATE:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(r.enablePan===!1)return;J(ne),a=i.PAN}else{if(r.enableRotate===!1)return;Y(ne),a=i.ROTATE}break;case xm.PAN:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(r.enableRotate===!1)return;Y(ne),a=i.ROTATE}else{if(r.enablePan===!1)return;J(ne),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(DN)})(B))}function Re(B){r.enabled!==!1&&(B.pointerType==="touch"?(function(ne){switch(Ie(ne),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ie(ne),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;pe(ne),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(V){r.enableZoom&&ue(V),r.enablePan&&pe(V)})(ne),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(V){r.enableZoom&&ue(V),r.enableRotate&&ie(V)})(ne),r.update();break;default:a=i.NONE}})(B):(function(ne){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(V){g.set(V.clientX,V.clientY),p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const Q=r.domElement;j(2*Math.PI*p.x/Q.clientHeight),I(2*Math.PI*p.y/Q.clientHeight),f.copy(g),r.update()})(ne);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(V){E.set(V.clientX,V.clientY),w.subVectors(E,b),w.y>0?W(N()):w.y<0&&K(N()),b.copy(E),r.update()})(ne);break;case i.PAN:if(r.enablePan===!1)return;(function(V){v.set(V.clientX,V.clientY),y.subVectors(v,x).multiplyScalar(r.panSpeed),R(y.x,y.y),x.copy(v),r.update()})(ne)}})(B))}function Z(B){(function(ne){delete F[ne.pointerId];for(let V=0;V<k.length;V++)if(k[V].pointerId==ne.pointerId)return void k.splice(V,1)})(B),k.length===0&&(r.domElement.releasePointerCapture(B.pointerId),r.domElement.removeEventListener("pointermove",Re),r.domElement.removeEventListener("pointerup",Z)),r.dispatchEvent(jV),a=i.NONE}function _e(B){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(B.preventDefault(),r.dispatchEvent(DN),(function(ne){G(ne),ne.deltaY<0?K(N()):ne.deltaY>0&&W(N()),r.update()})(B),r.dispatchEvent(jV))}function Le(B){r.enabled!==!1&&r.enablePan!==!1&&(function(ne){let V=!1;switch(ne.code){case r.keys.UP:ne.ctrlKey||ne.metaKey||ne.shiftKey?I(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),V=!0;break;case r.keys.BOTTOM:ne.ctrlKey||ne.metaKey||ne.shiftKey?I(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),V=!0;break;case r.keys.LEFT:ne.ctrlKey||ne.metaKey||ne.shiftKey?j(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),V=!0;break;case r.keys.RIGHT:ne.ctrlKey||ne.metaKey||ne.shiftKey?j(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),V=!0}V&&(ne.preventDefault(),r.update())})(B)}function ce(B){r.enabled!==!1&&B.preventDefault()}function Ie(B){let ne=F[B.pointerId];ne===void 0&&(ne=new Zt,F[B.pointerId]=ne),ne.set(B.pageX,B.pageY)}function z(B){const ne=B.pointerId===k[0].pointerId?k[1]:k[0];return F[ne.pointerId]}r.domElement.addEventListener("contextmenu",ce),r.domElement.addEventListener("pointerdown",be),r.domElement.addEventListener("pointercancel",Z),r.domElement.addEventListener("wheel",_e,{passive:!1}),this.update()}}St.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Zt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},qa.line={uniforms:TO.merge([St.common,St.fog,St.line]),vertexShader:`
  7851. #include <common>
  7852. #include <color_pars_vertex>
  7853. #include <fog_pars_vertex>
  7854. #include <logdepthbuf_pars_vertex>
  7855. #include <clipping_planes_pars_vertex>
  7856. uniform float linewidth;
  7857. uniform vec2 resolution;
  7858. attribute vec3 instanceStart;
  7859. attribute vec3 instanceEnd;
  7860. attribute vec3 instanceColorStart;
  7861. attribute vec3 instanceColorEnd;
  7862. #ifdef WORLD_UNITS
  7863. varying vec4 worldPos;
  7864. varying vec3 worldStart;
  7865. varying vec3 worldEnd;
  7866. #ifdef USE_DASH
  7867. varying vec2 vUv;
  7868. #endif
  7869. #else
  7870. varying vec2 vUv;
  7871. #endif
  7872. #ifdef USE_DASH
  7873. uniform float dashScale;
  7874. attribute float instanceDistanceStart;
  7875. attribute float instanceDistanceEnd;
  7876. varying float vLineDistance;
  7877. #endif
  7878. void trimSegment( const in vec4 start, inout vec4 end ) {
  7879. // trim end segment so it terminates between the camera plane and the near plane
  7880. // conservative estimate of the near plane
  7881. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7882. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7883. float nearEstimate = - 0.5 * b / a;
  7884. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7885. end.xyz = mix( start.xyz, end.xyz, alpha );
  7886. }
  7887. void main() {
  7888. #ifdef USE_COLOR
  7889. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7890. #endif
  7891. #ifdef USE_DASH
  7892. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7893. vUv = uv;
  7894. #endif
  7895. float aspect = resolution.x / resolution.y;
  7896. // camera space
  7897. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7898. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7899. #ifdef WORLD_UNITS
  7900. worldStart = start.xyz;
  7901. worldEnd = end.xyz;
  7902. #else
  7903. vUv = uv;
  7904. #endif
  7905. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7906. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7907. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7908. // perhaps there is a more elegant solution -- WestLangley
  7909. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7910. if ( perspective ) {
  7911. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7912. trimSegment( start, end );
  7913. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7914. trimSegment( end, start );
  7915. }
  7916. }
  7917. // clip space
  7918. vec4 clipStart = projectionMatrix * start;
  7919. vec4 clipEnd = projectionMatrix * end;
  7920. // ndc space
  7921. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7922. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7923. // direction
  7924. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7925. // account for clip-space aspect ratio
  7926. dir.x *= aspect;
  7927. dir = normalize( dir );
  7928. #ifdef WORLD_UNITS
  7929. // get the offset direction as perpendicular to the view vector
  7930. vec3 worldDir = normalize( end.xyz - start.xyz );
  7931. vec3 offset;
  7932. if ( position.y < 0.5 ) {
  7933. offset = normalize( cross( start.xyz, worldDir ) );
  7934. } else {
  7935. offset = normalize( cross( end.xyz, worldDir ) );
  7936. }
  7937. // sign flip
  7938. if ( position.x < 0.0 ) offset *= - 1.0;
  7939. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7940. // don't extend the line if we're rendering dashes because we
  7941. // won't be rendering the endcaps
  7942. #ifndef USE_DASH
  7943. // extend the line bounds to encompass endcaps
  7944. start.xyz += - worldDir * linewidth * 0.5;
  7945. end.xyz += worldDir * linewidth * 0.5;
  7946. // shift the position of the quad so it hugs the forward edge of the line
  7947. offset.xy -= dir * forwardOffset;
  7948. offset.z += 0.5;
  7949. #endif
  7950. // endcaps
  7951. if ( position.y > 1.0 || position.y < 0.0 ) {
  7952. offset.xy += dir * 2.0 * forwardOffset;
  7953. }
  7954. // adjust for linewidth
  7955. offset *= linewidth * 0.5;
  7956. // set the world position
  7957. worldPos = ( position.y < 0.5 ) ? start : end;
  7958. worldPos.xyz += offset;
  7959. // project the worldpos
  7960. vec4 clip = projectionMatrix * worldPos;
  7961. // shift the depth of the projected points so the line
  7962. // segments overlap neatly
  7963. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7964. clip.z = clipPose.z * clip.w;
  7965. #else
  7966. vec2 offset = vec2( dir.y, - dir.x );
  7967. // undo aspect ratio adjustment
  7968. dir.x /= aspect;
  7969. offset.x /= aspect;
  7970. // sign flip
  7971. if ( position.x < 0.0 ) offset *= - 1.0;
  7972. // endcaps
  7973. if ( position.y < 0.0 ) {
  7974. offset += - dir;
  7975. } else if ( position.y > 1.0 ) {
  7976. offset += dir;
  7977. }
  7978. // adjust for linewidth
  7979. offset *= linewidth;
  7980. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7981. offset /= resolution.y;
  7982. // select end
  7983. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7984. // back to clip space
  7985. offset *= clip.w;
  7986. clip.xy += offset;
  7987. #endif
  7988. gl_Position = clip;
  7989. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7990. #include <logdepthbuf_vertex>
  7991. #include <clipping_planes_vertex>
  7992. #include <fog_vertex>
  7993. }
  7994. `,fragmentShader:`
  7995. uniform vec3 diffuse;
  7996. uniform float opacity;
  7997. uniform float linewidth;
  7998. #ifdef USE_DASH
  7999. uniform float dashOffset;
  8000. uniform float dashSize;
  8001. uniform float gapSize;
  8002. #endif
  8003. varying float vLineDistance;
  8004. #ifdef WORLD_UNITS
  8005. varying vec4 worldPos;
  8006. varying vec3 worldStart;
  8007. varying vec3 worldEnd;
  8008. #ifdef USE_DASH
  8009. varying vec2 vUv;
  8010. #endif
  8011. #else
  8012. varying vec2 vUv;
  8013. #endif
  8014. #include <common>
  8015. #include <color_pars_fragment>
  8016. #include <fog_pars_fragment>
  8017. #include <logdepthbuf_pars_fragment>
  8018. #include <clipping_planes_pars_fragment>
  8019. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8020. float mua;
  8021. float mub;
  8022. vec3 p13 = p1 - p3;
  8023. vec3 p43 = p4 - p3;
  8024. vec3 p21 = p2 - p1;
  8025. float d1343 = dot( p13, p43 );
  8026. float d4321 = dot( p43, p21 );
  8027. float d1321 = dot( p13, p21 );
  8028. float d4343 = dot( p43, p43 );
  8029. float d2121 = dot( p21, p21 );
  8030. float denom = d2121 * d4343 - d4321 * d4321;
  8031. float numer = d1343 * d4321 - d1321 * d4343;
  8032. mua = numer / denom;
  8033. mua = clamp( mua, 0.0, 1.0 );
  8034. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8035. mub = clamp( mub, 0.0, 1.0 );
  8036. return vec2( mua, mub );
  8037. }
  8038. void main() {
  8039. #include <clipping_planes_fragment>
  8040. #ifdef USE_DASH
  8041. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8042. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8043. #endif
  8044. float alpha = opacity;
  8045. #ifdef WORLD_UNITS
  8046. // Find the closest points on the view ray and the line segment
  8047. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8048. vec3 lineDir = worldEnd - worldStart;
  8049. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8050. vec3 p1 = worldStart + lineDir * params.x;
  8051. vec3 p2 = rayEnd * params.y;
  8052. vec3 delta = p1 - p2;
  8053. float len = length( delta );
  8054. float norm = len / linewidth;
  8055. #ifndef USE_DASH
  8056. #ifdef USE_ALPHA_TO_COVERAGE
  8057. float dnorm = fwidth( norm );
  8058. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8059. #else
  8060. if ( norm > 0.5 ) {
  8061. discard;
  8062. }
  8063. #endif
  8064. #endif
  8065. #else
  8066. #ifdef USE_ALPHA_TO_COVERAGE
  8067. // artifacts appear on some hardware if a derivative is taken within a conditional
  8068. float a = vUv.x;
  8069. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8070. float len2 = a * a + b * b;
  8071. float dlen = fwidth( len2 );
  8072. if ( abs( vUv.y ) > 1.0 ) {
  8073. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8074. }
  8075. #else
  8076. if ( abs( vUv.y ) > 1.0 ) {
  8077. float a = vUv.x;
  8078. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8079. float len2 = a * a + b * b;
  8080. if ( len2 > 1.0 ) discard;
  8081. }
  8082. #endif
  8083. #endif
  8084. vec4 diffuseColor = vec4( diffuse, alpha );
  8085. #include <logdepthbuf_fragment>
  8086. #include <color_fragment>
  8087. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8088. #include <tonemapping_fragment>
  8089. #include <colorspace_fragment>
  8090. #include <fog_fragment>
  8091. #include <premultiplied_alpha_fragment>
  8092. }
  8093. `};class cQ extends _d{constructor(e){super({type:"LineMaterial",uniforms:TO.clone(qa.line.uniforms),vertexShader:qa.line.vertexShader,fragmentShader:qa.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 OV=new so,D_=new De;class uQ extends nUe{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 Vr([-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 Vr([-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 VP(n,6,1);return this.setAttribute("instanceStart",new Xu(r,3,0)),this.setAttribute("instanceEnd",new Xu(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 VP(n,6,1);return this.setAttribute("instanceColorStart",new Xu(r,3,0)),this.setAttribute("instanceColorEnd",new Xu(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 XFe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new so);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),OV.setFromBufferAttribute(n),this.boundingBox.union(OV))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new dl),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)D_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(D_)),D_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(D_));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 LV=new De,IV=new De,Wi=new Qn,qi=new Qn,Xo=new Qn,ON=new De,LN=new or,Ki=new rUe,FV=new De,O_=new so,L_=new dl,Yo=new Qn;let Zo,xh;function UV(t,e,n){return Yo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Yo.multiplyScalar(1/Yo.w),Yo.x=xh/n.width,Yo.y=xh/n.height,Yo.applyMatrix4(t.projectionMatrixInverse),Yo.multiplyScalar(1/Yo.w),Math.abs(Math.max(Yo.x,Yo.y))}class yUe extends Do{constructor(e=new uQ,n=new cQ({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let s=0,o=0,c=n.count;s<c;s++,o+=2)LV.fromBufferAttribute(n,s),IV.fromBufferAttribute(r,s),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+LV.distanceTo(IV);const a=new VP(i,2,1);return e.setAttribute("instanceDistanceStart",new Xu(a,1,0)),e.setAttribute("instanceDistanceEnd",new Xu(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Zo=e.ray;const s=this.matrixWorld,o=this.geometry,c=this.material;let u,d;xh=c.linewidth+a,o.boundingSphere===null&&o.computeBoundingSphere(),L_.copy(o.boundingSphere).applyMatrix4(s),r?u=.5*xh:u=UV(i,Math.max(i.near,L_.distanceToPoint(Zo.origin)),c.resolution),L_.radius+=u,Zo.intersectsSphere(L_)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),O_.copy(o.boundingBox).applyMatrix4(s),r?d=.5*xh:d=UV(i,Math.max(i.near,O_.distanceToPoint(Zo.origin)),c.resolution),O_.expandByScalar(d),Zo.intersectsBox(O_)!==!1&&(r?(function(f,g){const p=f.matrixWorld,x=f.geometry,v=x.attributes.instanceStart,y=x.attributes.instanceEnd;for(let b=0,E=Math.min(x.instanceCount,v.count);b<E;b++){Ki.start.fromBufferAttribute(v,b),Ki.end.fromBufferAttribute(y,b),Ki.applyMatrix4(p);const w=new De,A=new De;Zo.distanceSqToSegment(Ki.start,Ki.end,A,w),A.distanceTo(w)<.5*xh&&g.push({point:A,pointOnLine:w,distance:Zo.origin.distanceTo(A),object:f,face:null,faceIndex:b,uv:null,uv1:null})}})(this,n):(function(f,g,p){const x=g.projectionMatrix,v=f.material.resolution,y=f.matrixWorld,b=f.geometry,E=b.attributes.instanceStart,w=b.attributes.instanceEnd,A=Math.min(b.instanceCount,E.count),T=-g.near;Zo.at(1,Xo),Xo.w=1,Xo.applyMatrix4(g.matrixWorldInverse),Xo.applyMatrix4(x),Xo.multiplyScalar(1/Xo.w),Xo.x*=v.x/2,Xo.y*=v.y/2,Xo.z=0,ON.copy(Xo),LN.multiplyMatrices(g.matrixWorldInverse,y);for(let C=0,k=A;C<k;C++){if(Wi.fromBufferAttribute(E,C),qi.fromBufferAttribute(w,C),Wi.w=1,qi.w=1,Wi.applyMatrix4(LN),qi.applyMatrix4(LN),Wi.z>T&&qi.z>T)continue;if(Wi.z>T){const O=Wi.z-qi.z,q=(Wi.z-T)/O;Wi.lerp(qi,q)}else if(qi.z>T){const O=qi.z-Wi.z,q=(qi.z-T)/O;qi.lerp(Wi,q)}Wi.applyMatrix4(x),qi.applyMatrix4(x),Wi.multiplyScalar(1/Wi.w),qi.multiplyScalar(1/qi.w),Wi.x*=v.x/2,Wi.y*=v.y/2,qi.x*=v.x/2,qi.y*=v.y/2,Ki.start.copy(Wi),Ki.start.z=0,Ki.end.copy(qi),Ki.end.z=0;const F=Ki.closestPointToPointParameter(ON,!0);Ki.at(F,FV);const N=HZ.lerp(Wi.z,qi.z,F),j=N>=-1&&N<=1,I=ON.distanceTo(FV)<.5*xh;if(j&&I){Ki.start.fromBufferAttribute(E,C),Ki.end.fromBufferAttribute(w,C),Ki.start.applyMatrix4(y),Ki.end.applyMatrix4(y);const O=new De,q=new De;Zo.distanceSqToSegment(Ki.start,Ki.end,q,O),p.push({point:q,pointOnLine:O,distance:Zo.origin.distanceTo(q),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class vUe extends ZM{constructor(e,n,r,i,a=4473924,s=8947848){a=new $t(a),s=new $t(s);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){c.push(g,0,-1*r,g,0,r);const p=g===0?a:s;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let g=-1*r;g<=r;g+=i){c.push(-1*e,0,g,e,0,g);const p=g===0?a:s;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new xa;f.setAttribute("position",new Vr(c,3)),f.setAttribute("color",new Vr(u,3)),super(f,new Zb({vertexColors:!0,toneMapped:!1}))}}function _Ue(t,e,n,r){const i=(function(s,o,c){s*=.5,o*=.5,c*=.5;const u=new xa,d=[];return d.push(-s,-o,-c,-s,o,-c,-s,o,-c,s,o,-c,s,o,-c,s,-o,-c,s,-o,-c,-s,-o,-c,-s,-o,c,-s,o,c,-s,o,c,s,o,c,s,o,c,s,-o,c,s,-o,c,-s,-o,c,-s,-o,-c,-s,-o,c,-s,o,-c,-s,o,c,s,o,-c,s,o,c,s,-o,-c,s,-o,c),u.setAttribute("position",new Vr(d,3)),u})(t,e,n),a=new ZM(i,new ZFe({color:new $t(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var t0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,s=0,o=n(new t0.Panel("FPS","#0ff","#002")),c=n(new t0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new t0.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){s++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(o.update(1e3*s/(d-a),100),a=d,s=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};t0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,c=48*s,u=3*s,d=2*s,f=3*s,g=15*s,p=74*s,x=30*s,v=document.createElement("canvas");v.width=o,v.height=c,v.style.cssText="width:80px;height:48px";var y=v.getContext("2d");return y.font="bold "+9*s+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=n,y.fillRect(0,0,o,c),y.fillStyle=e,y.fillText(t,u,d),y.fillRect(f,g,p,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f,g,p,x),{dom:v,update:function(b,E){r=Math.min(r,b),i=Math.max(i,b),y.fillStyle=n,y.globalAlpha=1,y.fillRect(0,0,o,g),y.fillStyle=e,y.fillText(a(b)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),y.drawImage(v,f+s,g,p-s,x,f,g,p-s,x),y.fillRect(f+p-s,g,s,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f+p-s,g,s,a((1-b/E)*x))}}};var wUe=t0;class zV{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new Vw,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 Vw,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 SUe extends xa{constructor(e=[new De],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new De,s=new De,o=new Zt,c=[],u=[],d=[],f=[];function g(p){const[x,v,y]=(function(b){const E=e[b],w=new De,A=new De,T=new De,C=new De;w.copy(E).sub(e[b-1]||E).normalize().add((e[b+1]||E).clone().sub(E).normalize()).normalize();let k=Number.MAX_VALUE;const F=Math.abs(w.x),N=Math.abs(w.y),j=Math.abs(w.z);return F<=k&&(k=F,A.set(1,0,0)),N<=k&&(k=N,A.set(0,1,0)),j<=k&&A.set(0,0,1),C.crossVectors(w,A).normalize(),A.crossVectors(w,C),T.crossVectors(w,A),[E,A,T]})(p);for(let b=0;b<=i;b++){const E=b/i*Math.PI*2,w=Math.sin(E),A=-Math.cos(E);s.x=A*v.x+w*y.x,s.y=A*v.y+w*y.y,s.z=A*v.z+w*y.z,s.normalize(),u.push(s.x,s.y,s.z),a.x=x.x+n*s.x*.5,a.y=x.y+n*s.y*.5,a.z=x.z+r*s.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let p=0;p<e.length;p++)g(p);g(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)o.x=p/e.length,o.y=x/i,d.push(o.x,o.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const v=(i+1)*(p-1)+(x-1),y=(i+1)*p+(x-1),b=(i+1)*p+x,E=(i+1)*(p-1)+x;f.push(v,y,E),f.push(y,b,E)}})()})(),this.setIndex(f),this.setAttribute("position",new Vr(c,3)),this.setAttribute("normal",new Vr(u,3)),this.setAttribute("uv",new Vr(d,2))}}class n0{static get initial(){const e=new n0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const IN={h:0,s:0,l:0};class up{constructor(e){var n,r,i,a,s,o,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=n0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=up.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 Gw(this.minLayerThreshold),this.scene=new UFe,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=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(s=e.renderTravel)!==null&&s!==void 0?s:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new wUe: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[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new $t(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+WM),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 $P({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new $P({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new ys(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,g=.8*f;this.scene.fog=new kO(this._backgroundColor,g,f),this.resize(),this.controls=new bUe(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?up.defaultExtrusionColor:this._extrusionColor instanceof $t?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:up.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 iUe(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 tUe(13421772,.3*Math.PI),n=new eUe(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 $x;return n.name=e,n.quaternion.setFromEuler(new Xb(-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=n0.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 jN(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,s,o,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={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(f,e),f.extrusion=[];const p=g;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const p=g,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=p.params.e)!==null&&s!==void 0?s:this.state.e,i:(o=p.params.i)!==null&&o!==void 0?o:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const v=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,v,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,v))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const s=.1+.7*n/this.layers.length;a.getHSL(IN),a=new $t().setHSL(IN.h,IN.s,s)}if(n==this.layers.length-1){const s=(r=this._topLayerColor)!==null&&r!==void 0?r:a,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:s,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,s.getHex(),e.height),this.addTubeLine([...u,...c],o.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...u,...c],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new vUe(this.buildVolume.x,10,this.buildVolume.y,10));const e=_Ue(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 Gw(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=n0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const s=i?e.extrusion:e.travel,o=n.x,c=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let p=r.r,x=r.i,v=r.j;if(p){const W=d-o,K=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));p=Math.max(p,G);const te=Math.pow(W,2)+Math.pow(K,2),Y=Math.pow(p,2)-te/4;let J=Math.sqrt(Y/te);(a&&p<0||!a&&p>0)&&(J=-J),x=W/2+K*J,v=K/2-W*J}const y=o==d&&c==f,b=o+x,E=c+v,w=Math.sqrt(x*x+v*v),A=Math.atan2(-v,-x),T=Math.atan2(f-E,d-b);let C;y?C=2*Math.PI:(C=a?A-T:T-A,C<0&&(C+=2*Math.PI));let k=w*C/1.8;this.inches&&(k*=25),k<1&&(k=1);let F=C/k;F*=a?-1:1;const N=[];N.push({x:o,y:c,z:u});const j=(u-g)/k;let I=o,O=c,q=u,R=A;for(let W=0;W<k-1;W++)R+=F,I=b+w*Math.cos(R),O=E+w*Math.sin(R),q+=j,N.push({x:I,y:O,z:q});N.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<N.length-1;W++)s.push(N[W].x,N[W].y,N[W].z,N[W+1].x,N[W+1].y,N[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new xa;i.setAttribute("position",new Vr(e,3)),this.disposables.push(i);const a=new Zb({color:n});this.disposables.push(a);const s=new ZM(i,a);(r=this.group)===null||r===void 0||r.add(s)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let s=0;s<e.length;s+=6){const o=e.slice(s,s+9),c=new De(o[0],o[1],o[2]),u=new De(o[3],o[4],o[5]),d=new De(o[6],o[7],o[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((s=>{var o;const c=new SUe(s,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new uQ;this.disposables.push(i);const a=new cQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new yUe(i,a);(r=this.group)===null||r===void 0||r.add(s)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>jN(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 YFe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((o,c)=>3*c.attributes.position.count+o),0),s=new qFe(r.length,a,void 0,i);return this.disposables.push(s),(n=this.group)===null||n===void 0||n.add(s),s}_readFromStream(e){var n,r;return jN(this,void 0,void 0,(function*(){const i=e.getReader();let a,s="",o=0;do{console.debug("reading from stream"),a=yield i.read(),o+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
  8094. `),f=u.slice(0,d);this.parser.parseGCode(s+f),s=u.slice(d)}while(!a.done);var c;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new zV(this):typeof this.devMode=="object"&&(this.devGui=new zV(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())}}up.defaultExtrusionColor=new $t("hotpink");const MUe=function(t){return new up(t)};function EUe({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=M.useRef(null),a=M.useRef(null),s=M.useRef(null),[o,c]=M.useState(!0),[u,d]=M.useState(null),[f,g]=M.useState(!1),[p,x]=M.useState(0),[v,y]=M.useState(0);M.useEffect(()=>{if(!i.current)return;const w=i.current,A=n&&n.length>0,T=n&&n.length>1,C=A?n[0]:"#00ae42",k=MUe({canvas:w,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:T?n:C,...T?{}:{topLayerColor:C},...T?{disableGradient:!0}:{},lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=k,c(!0),d(null),g(!1),fetch(t).then(async N=>{if(!N.ok)throw N.status===404&&(await N.json().catch(()=>({}))).detail?.includes("sliced")?(g(!0),new Error("not_sliced")):new Error("Failed to load G-code");return N.text()}).then(N=>{let j=N;T&&(j=N.split(`
  8095. `).map(O=>{const q=O.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(q){const R=parseInt(q[2],10);if(R>15)return`${q[1]}; FILTERED: T${R}${q[3]||""}`}return O}).join(`
  8096. `),j=`T0
  8097. ${j}`),k.processGCode(j);const I=k.layers?.length||0;y(I),x(I),k.render(),c(!1)}).catch(N=>{d(N.message),c(!1)});const F=()=>{if(w.parentElement){const N=w.parentElement.getBoundingClientRect();w.width=N.width,w.height=N.height,k.resize()}};return F(),window.addEventListener("resize",F),()=>{window.removeEventListener("resize",F),s.current&&cancelAnimationFrame(s.current),k.dispose()}},[t,e,n]);const b=M.useCallback(w=>{if(!a.current)return;const A=Math.max(1,Math.min(w,v));x(A),s.current&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=A,a.current.render())})},[v]),E=w=>{b(parseInt(w.target.value,10))};return l.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[l.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[l.jsx("canvas",{ref:i,className:"w-full h-full"}),o&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsxs("div",{className:"text-center",children:[l.jsx(_t,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),l.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),f&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsxs("div",{className:"text-center max-w-sm px-4",children:[l.jsx(gle,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),l.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),l.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."})]})}),u&&!f&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx("div",{className:"text-center text-red-400",children:l.jsx("p",{className:"text-sm",children:u})})})]}),!o&&!u&&!f&&v>0&&l.jsx("div",{className:"mt-4 px-2",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(ud,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.jsx("button",{onClick:()=>b(p-1),disabled:p<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:l.jsx(Wh,{className:"w-4 h-4"})}),l.jsx("input",{type:"range",min:1,max:v,value:p,onChange:E,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),l.jsx("button",{onClick:()=>b(p+1),disabled:p>=v,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:l.jsx($c,{className:"w-4 h-4"})}),l.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[p," / ",v]})]})})]})}function AUe({archiveId:t,title:e,onClose:n}){const[r,i]=M.useState(null),[a,s]=M.useState(null),[o,c]=M.useState(!0);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),M.useEffect(()=>{Ce.getArchiveCapabilities(t).then(d=>{s(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{s({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${Ce.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:l.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:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:u,children:[l.jsx(Cs,{className:"w-4 h-4"}),"Open in Slicer"]}),l.jsx(Pe,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),a&&l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[l.jsx(pp,{className:"w-4 h-4"}),"3D Model",!a.has_model&&l.jsx("span",{className:"text-xs",children:"(not available)"})]}),l.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[l.jsx(Voe,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&l.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),l.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(_t,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?l.jsx(_De,{url:Ce.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):r==="gcode"&&a?l.jsx(EUe,{gcodeUrl:Ce.getArchiveGcode(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function TUe({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,a]=M.useState(null);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);const{data:s,isLoading:o}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),c=vt({mutationFn:()=>{if(!i)throw new Error("No printer selected");return Ce.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),u=s?.filter(d=>d.is_active)||[];return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:l.jsx(Mt,{className:"w-full max-w-md",children:l.jsxs(Nt,{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),l.jsx(Pe,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",l.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(_t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u.length===0?l.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):l.jsx("div",{className:"space-y-2 mb-6",children:u.map(d=>l.jsxs("button",{onClick:()=>a(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:[l.jsx("div",{className:`p-2 rounded-lg ${i===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:l.jsx(pa,{className:`w-5 h-5 ${i===d.id?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-white font-medium",children:d.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),c.isError&&l.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:c.error.message||"Failed to start print"}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Pe,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Pe,{onClick:()=>c.mutate(),disabled:!i||c.isPending,className:"flex-1",children:c.isPending?l.jsxs(l.Fragment,{children:[l.jsx(_t,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):l.jsxs(l.Fragment,{children:[l.jsx(pa,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function CUe({onClose:t,initialFiles:e}){const n=Mn(),{showToast:r}=Gr(),i=M.useRef(null),[a,s]=M.useState(()=>e?.filter(k=>k.name.endsWith(".3mf")).map(k=>({file:k,status:"pending"}))||[]),[o,c]=M.useState(!1),[u,d]=M.useState(),[f,g]=M.useState(null);M.useEffect(()=>{const k=F=>{F.key==="Escape"&&t()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t]);const{data:p}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),x=vt({mutationFn:k=>Ce.uploadArchivesBulk(k,u),onSuccess:k=>{g(k),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(F=>F.map(N=>{const j=k.results.find(O=>O.filename===N.file.name),I=k.errors.find(O=>O.filename===N.file.name);return j?{...N,status:"success",archiveId:j.id}:I?{...N,status:"error",error:I.error}:N})),k.failed===0?r(`${k.uploaded} file${k.uploaded!==1?"s":""} uploaded`):k.uploaded===0?r(`Failed to upload ${k.failed} file${k.failed!==1?"s":""}`,"error"):r(`${k.uploaded} uploaded, ${k.failed} failed`,"warning")},onError:()=>{s(k=>k.map(F=>({...F,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=M.useCallback(k=>{k.preventDefault(),c(!0)},[]),y=M.useCallback(k=>{k.preventDefault(),c(!1)},[]),b=M.useCallback(k=>{k.preventDefault(),c(!1);const F=Array.from(k.dataTransfer.files).filter(N=>N.name.endsWith(".3mf"));F.length>0&&s(N=>[...N,...F.map(j=>({file:j,status:"pending"}))])},[]),E=M.useCallback(k=>{const F=Array.from(k.target.files||[]).filter(N=>N.name.endsWith(".3mf"));F.length>0&&s(N=>[...N,...F.map(j=>({file:j,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=M.useCallback(k=>{s(F=>F.filter((N,j)=>j!==k))},[]),A=()=>{if(a.length===0)return;const k=a.filter(F=>F.status==="pending");k.length!==0&&(s(F=>F.map(N=>N.status==="pending"?{...N,status:"uploading"}:N)),x.mutate(k.map(F=>F.file)))},T=a.filter(k=>k.status==="pending").length,C=x.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Mt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:l.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4",children:l.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:v,onDragLeave:y,onDrop:b,children:[l.jsx(Ya,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),l.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),l.jsx(Pe,{variant:"secondary",onClick:()=>i.current?.click(),disabled:C,children:"Browse Files"}),l.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),l.jsxs("div",{className:"px-4 pb-4",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:k=>d(k.target.value?Number(k.target.value):void 0),disabled:C,children:[l.jsx("option",{value:"",children:"No printer"}),p?.map(k=>l.jsx("option",{value:k.id,children:k.name},k.id))]})]}),a.length>0&&l.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:l.jsx("div",{className:"space-y-2",children:a.map((k,F)=>l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[l.jsx(KR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"flex-1 text-white text-sm truncate",children:k.file.name}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[(k.file.size/(1024*1024)).toFixed(1)," MB"]}),k.status==="pending"&&l.jsx("button",{onClick:()=>w(F),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:C,children:l.jsx(Wt,{className:"w-4 h-4"})}),k.status==="uploading"&&l.jsx(_t,{className:"w-4 h-4 text-bambu-green animate-spin"}),k.status==="success"&&l.jsx(_r,{className:"w-4 h-4 text-bambu-green"}),k.status==="error"&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs text-red-400",children:k.error}),l.jsx(co,{className:"w-4 h-4 text-red-400"})]})]},`${k.file.name}-${F}`))})}),f&&l.jsx("div",{className:"px-4 pb-4",children:l.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:l.jsxs("p",{className:"text-sm text-white",children:[l.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&l.jsxs(l.Fragment,{children:[", ",l.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Pe,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&l.jsx(Pe,{onClick:A,disabled:T===0||C,className:"flex-1",children:C?l.jsxs(l.Fragment,{children:[l.jsx(_t,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Ya,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const NUe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],kUe=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function PUe({archive:t,onClose:e,existingTags:n=[]}){M.useEffect(()=>{const ee=ie=>{ie.key==="Escape"&&e()};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[e]);const r=Mn(),[i,a]=M.useState(t.print_name||""),[s,o]=M.useState(t.printer_id),[c,u]=M.useState(t.project_id??null),[d,f]=M.useState(t.notes||""),[g,p]=M.useState(t.tags||""),[x,v]=M.useState(t.failure_reason||""),[y,b]=M.useState(t.status),[E,w]=M.useState(t.photos||[]),[A,T]=M.useState(!1),[C,k]=M.useState(!1),F=M.useRef(null),N=M.useRef(null),j=M.useRef(null),{data:I}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:O}=yt({queryKey:["projects"],queryFn:()=>Ce.getProjects()}),{data:q}=yt({queryKey:["archives"],queryFn:()=>Ce.getArchives(void 0,1e3,0),enabled:n.length===0}),R=n.length>0?n:[...new Set(q?.flatMap(ee=>ee.tags?.split(",").map(ie=>ie.trim())||[]).filter(Boolean)||[])].sort(),W=g.split(",").map(ee=>ee.trim()).filter(Boolean),K=R.filter(ee=>!W.includes(ee)),G=ee=>{if(!W.includes(ee)){const ie=[...W,ee].join(", ");p(ie)}j.current!==null&&clearTimeout(j.current),F.current?.focus()},te=ee=>{const ie=W.filter(pe=>pe!==ee).join(", ");p(ie)},Y=vt({mutationFn:ee=>Ce.updateArchive(t.id,ee),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),J=async ee=>{const ie=ee.target.files?.[0];if(ie){T(!0);try{const pe=await Ce.uploadArchivePhoto(t.id,ie);w(pe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(pe){console.error("Failed to upload photo:",pe)}finally{T(!1),N.current&&(N.current.value="")}}},U=async ee=>{try{const ie=await Ce.deleteArchivePhoto(t.id,ee);w(ie.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(ie){console.error("Failed to delete photo:",ie)}},H=ee=>{ee.preventDefault();const ie={print_name:i||void 0,printer_id:s,project_id:c,notes:d||void 0,tags:g||void 0};y!==t.status&&(ie.status=y),y==="failed"||y==="aborted"?ie.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(ie.failure_reason=null),Y.mutate(ie)};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.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:ee=>ee.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:H,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.jsx("input",{type:"text",value:i,onChange:ee=>a(ee.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),l.jsxs("select",{value:s??"",onChange:ee=>o(ee.target.value?Number(ee.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:[l.jsx("option",{value:"",children:"No printer"}),I?.map(ee=>l.jsx("option",{value:ee.id,children:ee.name},ee.id))]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(cl,{className:"w-4 h-4 inline mr-1"}),"Project"]}),l.jsxs("select",{value:c??"",onChange:ee=>u(ee.target.value?Number(ee.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:[l.jsx("option",{value:"",children:"No project"}),O?.map(ee=>l.jsx("option",{value:ee.id,children:ee.name},ee.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),l.jsx("textarea",{value:d,onChange:ee=>f(ee.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..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),W.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:W.map(ee=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[l.jsx(vp,{className:"w-3 h-3"}),ee,l.jsx("button",{type:"button",onClick:()=>te(ee),className:"ml-0.5 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},ee))}),l.jsxs("div",{className:"relative",children:[l.jsx("input",{ref:F,type:"text",value:g,onChange:ee=>p(ee.target.value),onFocus:()=>{j.current!==null&&clearTimeout(j.current),k(!0)},onBlur:()=>{j.current=window.setTimeout(()=>k(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:W.length>0?"Add more tags...":"Add tags..."}),C&&K.length>0&&l.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:[l.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),l.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:K.map(ee=>l.jsx("button",{type:"button",onClick:()=>G(ee),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:ee},ee))})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),l.jsx("select",{value:y,onChange:ee=>{b(ee.target.value),ee.target.value==="completed"&&v("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:kUe.map(ee=>l.jsx("option",{value:ee.value,children:ee.label},ee.value))})]}),(y==="failed"||y==="aborted")&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),l.jsxs("select",{value:x,onChange:ee=>v(ee.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:[l.jsx("option",{value:"",children:"Select reason..."}),NUe.map(ee=>l.jsx("option",{value:ee,children:ee},ee))]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(w0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[E.map(ee=>l.jsxs("div",{className:"relative group",children:[l.jsx("img",{src:Ce.getArchivePhotoUrl(t.id,ee),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),l.jsx("button",{type:"button",onClick:()=>U(ee),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(An,{className:"w-3 h-3 text-white"})})]},ee)),l.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:[l.jsx("input",{ref:N,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:J,className:"hidden",disabled:A}),A?l.jsx(_t,{className:"w-6 h-6 text-bambu-gray animate-spin"}):l.jsx(tr,{className:"w-6 h-6 text-bambu-gray"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{type:"submit",disabled:Y.isPending,className:"flex-1",children:[l.jsx(no,{className:"w-4 h-4"}),Y.isPending?"Saving...":"Save"]})]})]})]})})}function RUe({x:t,y:e,items:n,onClose:r}){const i=M.useRef(null),[a,s]=M.useState(null),o=M.useRef(null),[c,u]=M.useState({x:t,y:e,visible:!1}),[d,f]=M.useState(!1);M.useEffect(()=>{const x=b=>{i.current&&!i.current.contains(b.target)&&r()},v=b=>{b.key==="Escape"&&r()},y=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),document.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v),document.removeEventListener("scroll",y,!0),o.current&&clearTimeout(o.current)}},[r]),M.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),v=window.innerWidth,y=window.innerHeight,b=8;let E=t,w=e;t+x.width>v-b&&(E=Math.max(b,v-x.width-b)),E<b&&(E=b),e+x.height>y-b&&(w=Math.max(b,y-x.height-b)),w<b&&(w=b);const A=180,T=v-E-x.width,C=E;f(T<A&&C>A),u({x:E,y:w,visible:!0})}},[t,e]);const g=x=>{o.current&&(clearTimeout(o.current),o.current=null),s(x)},p=()=>{o.current=window.setTimeout(()=>{s(null)},150)};return l.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,v)=>{if(x.divider)return l.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const y=x.submenu&&x.submenu.length>0;return l.jsxs("div",{className:"relative",onMouseEnter:()=>y&&g(v),onMouseLeave:()=>y&&p(),children:[l.jsxs("button",{onMouseEnter:()=>y&&g(v),onClick:()=>{y?s(a===v?null:v):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${y&&a===v?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),l.jsx("span",{className:"flex-1",children:x.label}),y&&l.jsx($c,{className:"w-4 h-4 text-bambu-gray"})]}),y&&a===v&&l.jsx("div",{className:`absolute top-0 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"}`,onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null)},onMouseLeave:()=>p(),children:x.submenu.map((b,E)=>l.jsxs("button",{onClick:()=>{b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[b.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),b.label]},E))})]},v)})})}function jUe({selectedIds:t,existingTags:e,onClose:n}){const r=Mn(),{showToast:i}=Gr(),[a,s]=M.useState(""),[o,c]=M.useState(new Set),[u,d]=M.useState("add");M.useEffect(()=>{const v=y=>{y.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=vt({mutationFn:async()=>{const v=Array.from(o);let y=0;for(const b of t)try{const E=await Ce.getArchive(b),w=E.tags?E.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...w,...v])]:A=w.filter(T=>!o.has(T)),await Ce.updateArchive(b,{tags:A.join(", ")}),y++}catch(E){throw console.error(`Failed to update archive ${b}:`,E),new Error(`Failed on archive ${b}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:y,mode:u,tags:v}},onSuccess:({count:v,mode:y,tags:b})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${y==="add"?"Added":"Removed"} ${b.length} tag${b.length!==1?"s":""} ${y==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),g=v=>{c(y=>{const b=new Set(y);return b.has(v)?b.delete(v):b.add(v),b})},p=()=>{a.trim()&&!o.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),s(""))},x=v=>{v.key==="Enter"&&(v.preventDefault(),p())};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Mt,{className:"w-full max-w-md",children:l.jsxs(Nt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(vp,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Pe,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),l.jsx(Pe,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:v=>s(v.target.value),onKeyDown:x}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:l.jsx(tr,{className:"w-4 h-4"})})]}),e.length>0&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(v=>l.jsx("button",{onClick:()=>g(v),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),o.size>0&&l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(v=>l.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[v,l.jsx("button",{onClick:()=>g(v),className:"hover:opacity-70",children:l.jsx(Wt,{className:"w-3 h-3"})})]},v))})]})]}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Pe,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Pe,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?l.jsxs(l.Fragment,{children:[l.jsx(_t,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vp,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function DUe(t,e){return new Date(t,e+1,0).getDate()}function OUe(t,e){return new Date(t,e,1).getDay()}const LUe=["January","February","March","April","May","June","July","August","September","October","November","December"],IUe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function FUe({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=M.useState(n.getMonth()),[a,s]=M.useState(n.getFullYear()),[o,c]=M.useState(null),u=M.useMemo(()=>{const b=new Map;return t.forEach(E=>{const w=new Date(E.completed_at||E.created_at),A=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,T=b.get(A)||[];T.push(E),b.set(A,T)}),b},[t]),d=DUe(a,r),f=OUe(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},p=()=>{r===11?(i(0),s(a+1)):i(r+1)},x=()=>{i(n.getMonth()),s(n.getFullYear())},v=[];for(let b=0;b<f;b++)v.push(null);for(let b=1;b<=d;b++)v.push(b);const y=o?u.get(o)||[]:[];return l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wh,{className:"w-5 h-5 text-bambu-gray"})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:[LUe[r]," ",a]}),l.jsx("button",{onClick:x,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"})]}),l.jsx("button",{onClick:p,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx($c,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:IUe.map(b=>l.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:b},b))}),l.jsx("div",{className:"grid grid-cols-7 gap-1",children:v.map((b,E)=>{if(b===null)return l.jsx("div",{className:"aspect-square"},`empty-${E}`);const w=`${a}-${String(r+1).padStart(2,"0")}-${String(b).padStart(2,"0")}`,A=u.get(w)||[],T=A.length>0,C=b===n.getDate()&&r===n.getMonth()&&a===n.getFullYear(),k=w===o,F=A.filter(j=>j.status==="completed").length,N=A.filter(j=>j.status==="failed").length;return l.jsxs("button",{onClick:()=>c(k?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${k?"bg-bambu-green text-white":C?"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:[l.jsx("span",{className:`text-sm font-medium ${C&&!k?"text-bambu-green":""}`,children:b}),T&&l.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[l.jsx("div",{className:`w-2 h-2 rounded-full ${N>0&&F===0?"bg-red-400":N>0?"bg-yellow-400":"bg-green-400"}`}),l.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},b)})}),l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a&&b.status==="completed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a&&b.status==="failed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),l.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?l.jsxs(l.Fragment,{children:[l.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"})}),y.length>0?l.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:y.map(b=>l.jsxs("button",{onClick:()=>e?.(b),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[b.thumbnail_path?l.jsx("img",{src:Ce.getArchiveThumbnail(b.id),alt:"",className:"w-12 h-12 rounded object-cover"}):l.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:l.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-white truncate",children:b.print_name||b.filename}),l.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[l.jsx("span",{className:b.status==="failed"?"text-red-400":"text-green-400",children:b.status==="failed"?"Failed":"Completed"}),b.filament_color&&l.jsx("div",{className:"flex gap-0.5",children:b.filament_color.split(",").map((E,w)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},w))})]})]})]},b.id))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):l.jsx("div",{className:"text-center py-8",children:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function UUe({archiveId:t,archiveName:e,onClose:n}){const r=Ce.getArchiveQRCodeUrl(t,300);M.useEffect(()=>{const a=s=>{s.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 flex flex-col items-center",children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),l.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:l.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),l.jsxs(Pe,{onClick:i,className:"w-full",children:[l.jsx(ts,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function zUe({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,s]=M.useState(0),[o,c]=M.useState(!1);if(M.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&s(v=>Math.max(0,v-1)),x.key==="ArrowRight"&&s(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),M.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=Ce.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},g=()=>{i&&c(!0)};return l.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[l.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:f,children:[l.jsx(ts,{className:"w-4 h-4"}),"Download"]}),i&&l.jsx(Pe,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:l.jsx(An,{className:"w-4 h-4"})}),l.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-6 h-6"})})]})]}),l.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&l.jsx("button",{onClick:()=>s(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:l.jsx(Wh,{className:"w-8 h-8 text-white"})}),l.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&l.jsx("button",{onClick:()=>s(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:l.jsx($c,{className:"w-8 h-8 text-white"})})]}),n.length>1&&l.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>l.jsx("button",{onClick:()=>s(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:l.jsx("img",{src:Ce.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),o&&l.jsx(fi,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Yi(t){this.content=t}Yi.prototype={constructor:Yi,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new Yi(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Yi(n)},addToStart:function(t,e){return new Yi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Yi(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new Yi(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=Yi.from(t),t.size?new Yi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Yi.from(t),t.size?new Yi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Yi.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}};Yi.from=function(t){if(t instanceof Yi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Yi(e)};function dQ(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=dQ(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function hQ(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),o=e.child(--a),c=s.nodeSize;if(s==o){n-=c,r-=c;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let u=0,d=Math.min(s.text.length,o.text.length);for(;u<d&&s.text[s.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let u=hQ(s.content,o.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class mt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let s=0,o=0;o<n;s++){let c=this.content[s],u=o+c.nodeSize;if(u>e&&r(c,i+o,a||null,s)!==!1&&c.content.size){let d=o+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,c)=>{let u=o.isText?o.text.slice(Math.max(e,c)-c,n-c):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new mt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,s=0;s<n;a++){let o=this.content[a],c=s+o.nodeSize;c>e&&((s<e||c>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=c}return new mt(r,i)}cutByIndex(e,n){return e==n?mt.empty:e==0&&n==this.content.length?this:new mt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new mt(i,a)}addToStart(e){return new mt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new mt(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 dQ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return hQ(this,e,n,r)}findIndex(e){if(e==0)return I_(0,e);if(e==this.size)return I_(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?I_(n+1,a):I_(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return mt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new mt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return mt.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new mt(n||e,r)}static from(e){if(!e)return mt.empty;if(e instanceof mt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new mt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}mt.empty=new mt([],0);const FN={index:0,offset:0};function I_(t,e){return FN.index=t,FN.offset=e,FN}function Ww(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(!Ww(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Ww(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let nr=class WP{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Ww(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 WP.none;if(e instanceof WP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};nr.none=[];class qw extends Error{}class Pt{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=mQ(this.content,e+this.openStart,n);return r&&new Pt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Pt(fQ(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 Pt.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 Pt(mt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Pt(e,r,i)}}Pt.empty=new Pt(mt.empty,0,0);function fQ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(fQ(a.content,e-i-1,n-i-1)))}function mQ(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=mQ(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function BUe(t,e,n){if(n.openStart>t.depth)throw new qw("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new qw("Inconsistent open depths");return pQ(t,e,n,0)}function pQ(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=pQ(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Fh(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=HUe(n,t);return Fh(a,xQ(t,s,o,e,r))}else return Fh(a,Kw(t,e,r))}function gQ(t,e){if(!e.type.compatibleContent(t.type))throw new qw("Cannot join "+e.type.name+" onto "+t.type.name)}function qP(t,e,n){let r=t.node(n);return gQ(r,e.node(n)),r}function Ih(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 r0(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Ih(t.nodeAfter,r),a++));for(let o=a;o<s;o++)Ih(i.child(o),r);e&&e.depth==n&&e.textOffset&&Ih(e.nodeBefore,r)}function Fh(t,e){return t.type.checkContent(e),t.copy(e)}function xQ(t,e,n,r,i){let a=t.depth>i&&qP(t,e,i+1),s=r.depth>i&&qP(n,r,i+1),o=[];return r0(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(gQ(a,s),Ih(Fh(a,xQ(t,e,n,r,i+1)),o)):(a&&Ih(Fh(a,Kw(t,e,i+1)),o),r0(e,n,i,o),s&&Ih(Fh(s,Kw(n,r,i+1)),o)),r0(r,null,i,o),new mt(o)}function Kw(t,e,n){let r=[];if(r0(null,t,n,r),t.depth>n){let i=qP(t,e,n+1);Ih(Fh(i,Kw(t,e,n+1)),r)}return r0(e,null,n,r),new mt(r)}function HUe(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(mt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class eb{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return nr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Xw(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let s=e;;){let{index:o,offset:c}=s.content.findIndex(a),u=a-c;if(r.push(s,o,i+c),!u||(s=s.child(o),s.isText))break;a=u-1,i+=c+1}return new eb(n,r,a)}static resolveCached(e,n){let r=BV.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else BV.set(e,r=new $Ue);let i=r.elts[r.i]=eb.resolve(e,n);return r.i=(r.i+1)%VUe,i}}class $Ue{constructor(){this.elts=[],this.i=0}}const VUe=12,BV=new WeakMap;class Xw{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 GUe=Object.create(null);let ad=class KP{constructor(e,n,r,i=nr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||mt.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&&Ww(this.attrs,n||e.defaultAttrs||GUe)&&nr.sameSet(this.marks,r||nr.none)}copy(e=null){return e==this.content?this:new KP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new KP(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 Pt.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),u=i.node(s).content.cut(i.pos-o,a.pos-o);return new Pt(u,i.depth-s,a.depth-s)}replace(e,n,r){return BUe(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 eb.resolveCached(this,e)}resolveNoCache(e){return eb.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),bQ(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=mt.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=nr.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(!nr.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=mt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};ad.prototype.text=void 0;class Yw extends ad{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):bQ(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 Yw(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Yw(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 bQ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class cf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new WUe(e,n);if(r.next==null)return cf.empty;let i=yQ(r);r.next&&r.err("Unexpected trailing text");let a=JUe(QUe(i));return eze(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,o){let c=s.matchFragment(e,r);if(c&&(!n||c.validEnd))return mt.from(o.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:d,next:f}=s.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=a(f,o.concat(d));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:c}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||c.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
  8098. `)}}cf.empty=new cf(!0);class WUe{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 yQ(t){let e=[];do e.push(qUe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function qUe(t){let e=[];do e.push(KUe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function KUe(t){let e=ZUe(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=XUe(t,e);else break;return e}function HV(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function XUe(t,e){let n=HV(t),r=n;return t.eat(",")&&(t.next!="}"?r=HV(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function YUe(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let s=n[a];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function ZUe(t){if(t.eat("(")){let e=yQ(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=YUe(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 QUe(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,c){let u={term:c,to:o};return e[s].push(u),u}function i(s,o){s.forEach(c=>c.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((c,u)=>c.concat(a(u,o)),[]);if(s.type=="seq")for(let c=0;;c++){let u=a(s.exprs[c],o);if(c==s.exprs.length-1)return u;i(u,o=n())}else if(s.type=="star"){let c=n();return r(o,c),i(a(s.expr,c),c),[r(c)]}else if(s.type=="plus"){let c=n();return i(a(s.expr,o),c),i(a(s.expr,c),c),[r(c)]}else{if(s.type=="opt")return[r(o)].concat(a(s.expr,o));if(s.type=="range"){let c=o;for(let u=0;u<s.min;u++){let d=n();i(a(s.expr,c),d),c=d}if(s.max==-1)i(a(s.expr,c),c);else for(let u=s.min;u<s.max;u++){let d=n();r(c,d),i(a(s.expr,c),d),c=d}return[r(c)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function vQ(t,e){return e-t}function $V(t,e){let n=[];return r(e),n.sort(vQ);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:o,to:c}=a[s];!o&&n.indexOf(c)==-1&&r(c)}}}function JUe(t){let e=Object.create(null);return n($V(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:o,to:c})=>{if(!o)return;let u;for(let d=0;d<i.length;d++)i[d][0]==o&&(u=i[d][1]);$V(t,c).forEach(d=>{u||i.push([o,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new cf(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let o=i[s][1].sort(vQ);a.next.push({type:i[s][0],next:e[o.join(",")]||n(o)})}return a}}function eze(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let o=0;o<i.next.length;o++){let{type:c,next:u}=i.next[o];s.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function _Q(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 wQ(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function SQ(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function MQ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new nze(t,r,e[r]);return n}let VV=class EQ{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=MQ(e,r.attrs),this.defaultAttrs=_Q(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==cf.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:wQ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ad(this,this.computeAttrs(e),mt.from(n),nr.setFrom(r))}createChecked(e=null,n,r){return n=mt.from(n),this.checkContent(n),new ad(this,this.computeAttrs(e),n,nr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=mt.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(mt.empty,!0);return a?new ad(this,e,n.append(a),nr.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){SQ(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:nr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new EQ(a,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function tze(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class nze{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?tze(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class QM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=MQ(e,i.attrs),this.excluded=null;let a=_Q(this.attrs);this.instance=a?new nr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new nr(this,wQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new QM(a,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){SQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class AQ{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=Yi.from(e.nodes),n.marks=Yi.from(e.marks||{}),this.nodes=VV.compile(this.spec.nodes,this),this.marks=QM.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=cf.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?GV(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:GV(this,s.split(" "))}this.nodeFromJSON=i=>ad.fromJSON(this,i),this.markFromJSON=i=>nr.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 VV){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 Yw(r,r.defaultAttrs,e,nr.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 GV(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let o in t.marks){let c=t.marks[o];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function rze(t){return t.tag!=null}function ize(t){return t.style!=null}let i0=class XP{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(rze(i))this.tags.push(i);else if(ize(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new qV(this,n,!1);return r.addAll(e,nr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new qV(this,n,!0);return r.addAll(e,nr.none,n.from,n.to),Pt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(oze(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let c=s.getAttrs(n);if(c===!1)continue;s.attrs=c||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=KV(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(s=>{r(s=KV(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new XP(e,XP.schemaRules(e)))}};const TQ={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},aze={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},CQ={ol:!0,ul:!0},tb=1,YP=2,a0=4;function WV(t,e,n){return e!=null?(e?tb:0)|(e==="full"?YP:0):t&&t.whitespace=="pre"?tb|YP:n&~a0}class F_{constructor(e,n,r,i,a,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=nr.none,this.match=a||(s&a0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(mt.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&tb)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=mt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(mt.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&&!TQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class qV{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,s=WV(null,n.preserveWhitespace,0)|(r?a0:0);i?a=new F_(i.type,i.attrs,nr.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new F_(null,null,nr.none,!0,null,s):a=new F_(e.schema.topNodeType,null,nr.none,!0,null,s),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&YP?"full":this.localPreserveWS||(i.options&tb)>0,{schema:s}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
  8099. `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(s.text(o[c]),n,!/\S/.test(o[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],c=e.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;CQ.hasOwnProperty(s)&&this.parser.normalizeLists&&sze(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(c?c.ignore:aze.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(TQ.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
  8100. `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],s=r.getPropertyValue(a);if(s)for(let o=void 0;;){let c=this.parser.matchStyle(a,s,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return n}addElementByRule(e,n,r,i){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(s,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,o=0;s>=0;s--){let c=this.nodes[s],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;o+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let s=nr.none;for(let o of i.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):XV(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=WV(e,a,s.options);s.options&a0&&s.content.length==0&&(o|=a0);let c=nr.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):XV(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new F_(e,n,c,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|=tb)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),s=(o,c)=>{for(;o>=0;o--){let u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;c>=a;c--)if(s(o-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function sze(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&CQ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function oze(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function KV(t){let e={};for(let n in t)e[n]=t[n];return e}function XV(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let c=0;c<o.edgeCount;c++){let{type:u,next:d}=o.edge(c);if(u==e||a.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class yf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=UN(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,c=0;for(;o<a.length&&c<s.marks.length;){let u=s.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[o][0])||u.type.spec.spanning===!1)break;o++,c++}for(;o<a.length;)i=a.pop()[1];for(;c<s.marks.length;){let u=s.marks[c++],d=this.serializeMark(u,s.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=b1(UN(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&b1(UN(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return b1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new yf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=YV(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return YV(e.marks)}}function YV(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function UN(t){return t.document||window.document}const ZV=new WeakMap;function lze(t){let e=ZV.get(t);return e===void 0&&ZV.set(t,e=cze(t)),e}function cze(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 b1(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=lze(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:x}=b1(t,g,n,r);if(c.appendChild(p),x){if(o)throw new RangeError("Multiple content holes");o=x}}}return{dom:c,contentDOM:o}}const NQ=65535,kQ=Math.pow(2,16);function uze(t,e){return t+e*kQ}function QV(t){return t&NQ}function dze(t){return(t-(t&NQ))/kQ}const PQ=1,RQ=2,y1=4,jQ=8;class ZP{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&jQ)>0}get deletedBefore(){return(this.delInfo&(PQ|y1))>0}get deletedAfter(){return(this.delInfo&(RQ|y1))>0}get deletedAcross(){return(this.delInfo&y1)>0}}class _s{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&_s.empty)return _s.empty}recover(e){let n=0,r=QV(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+dze(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[o+a],d=this.ranges[o+s],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,p=c+i+(g<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:uze(o/3,e-c),v=e==c?RQ:e==f?PQ:y1;return(n<0?e!=c:e!=f)&&(v|=jQ),new ZP(p,v,x)}i+=d-u}return r?e+i:new ZP(e+i,0,null)}touches(e,n){let r=0,i=QV(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[o+a],d=c+u;if(e<=d&&o==i*3)return!0;r+=this.ranges[o+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?a:0),c=s+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(o,o+u,c,c+d),a+=d-u}}invert(){return new _s(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?_s.empty:new _s(e<0?[0,-e,0]:[0,0,e])}}_s.empty=new _s([]);class nb{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 nb(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 nb;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new ZP(e,i,null)}}const zN=Object.create(null);class ba{getMap(){return _s.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=zN[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 zN)throw new RangeError("Duplicate use of step JSON ID "+e);return zN[e]=n,n.prototype.jsonID=e,n}}class ni{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ni(e,null)}static fail(e){return new ni(null,e)}static fromReplace(e,n,r,i){try{return ni.ok(e.replace(n,r,i))}catch(a){if(a instanceof qw)return ni.fail(a.message);throw a}}}function jO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(jO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return mt.fromArray(r)}class Yu extends ba{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new Pt(jO(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return ni.fromReplace(e,this.from,this.to,a)}invert(){return new Oo(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 Yu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Yu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Yu(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 Yu(n.from,n.to,e.markFromJSON(n.mark))}}ba.jsonID("addMark",Yu);class Oo extends ba{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 Pt(jO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ni.fromReplace(e,this.from,this.to,r)}invert(){return new Yu(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 Oo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Oo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Oo(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 Oo(n.from,n.to,e.markFromJSON(n.mark))}}ba.jsonID("removeMark",Oo);class Zu extends ba{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ni.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ni.fromReplace(e,this.pos,this.pos+1,new Pt(mt.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 Zu(this.pos,n.marks[i]);return new Zu(this.pos,this.mark)}}return new uf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zu(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 Zu(n.pos,e.markFromJSON(n.mark))}}ba.jsonID("addNodeMark",Zu);class uf extends ba{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ni.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ni.fromReplace(e,this.pos,this.pos+1,new Pt(mt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Zu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new uf(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 uf(n.pos,e.markFromJSON(n.mark))}}ba.jsonID("removeNodeMark",uf);class Oi extends ba{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&QP(e,this.from,this.to)?ni.fail("Structure replace would overwrite content"):ni.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new _s([this.from,this.to-this.from,this.slice.size])}invert(e){return new Oi(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 Oi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Oi)||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?Pt.empty:new Pt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Oi(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?Pt.empty:new Pt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Oi(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 Oi(n.from,n.to,Pt.fromJSON(e,n.slice),!!n.structure)}}ba.jsonID("replace",Oi);class Ii extends ba{constructor(e,n,r,i,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(QP(e,this.from,this.gapFrom)||QP(e,this.gapTo,this.to)))return ni.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ni.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ni.fromReplace(e,this.from,this.to,r):ni.fail("Content does not fit in gap")}getMap(){return new _s([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 Ii(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new Ii(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ii(n.from,n.to,n.gapFrom,n.gapTo,Pt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ba.jsonID("replaceAround",Ii);function QP(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let s=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function hze(t,e,n,r){let i=[],a=[],s,o;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(x)||(s&&s.to==g&&s.mark.eq(f[v])?s.to=p:i.push(s=new Oo(g,p,f[v])));o&&o.to==g?o.to=p:a.push(o=new Yu(g,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function fze(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let c=null;if(r instanceof QM){let u=s.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(s.marks)&&(c=[r]):c=s.marks;if(c&&c.length){let u=Math.min(o+s.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],g;for(let p=0;p<i.length;p++){let x=i[p];x.step==a-1&&f.eq(i[p].style)&&(g=x)}g?(g.to=u,g.step=a):i.push({style:f,from:Math.max(o,e),to:u,step:a})}}}),i.forEach(s=>t.step(new Oo(s.from,s.to,s.style)))}function DO(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=o+u.nodeSize,f=r.matchType(u.type);if(!f)s.push(new Oi(o,d,Pt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Oo(o,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,p=/\r?\n|\r/g,x;for(;g=p.exec(u.text);)x||(x=new Pt(mt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new Oi(o+g.index,o+g.index+g[0].length,x))}}o=d}if(!r.validEnd){let c=r.fillBefore(mt.empty,!0);t.replace(o,o,new Pt(c,0,0))}for(let c=s.length-1;c>=0;c--)t.step(s[c])}function mze(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function pg(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(o,c,n))return r;if(r==0||s.type.spec.isolating||!mze(s,o,c))break;o&&(i=1),c<s.childCount&&(a=1)}return null}function pze(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),o=i.after(a+1),c=s,u=o,d=mt.empty,f=0;for(let x=a,v=!1;x>n;x--)v||r.index(x)>0?(v=!0,d=mt.from(r.node(x).copy(d)),f++):c--;let g=mt.empty,p=0;for(let x=a,v=!1;x>n;x--)v||i.after(x+1)<i.end(x)?(v=!0,g=mt.from(i.node(x).copy(g)),p++):u++;t.step(new Ii(c,u,s,o,new Pt(d.append(g),f,p),d.size-f,!0))}function OO(t,e,n=null,r=t){let i=gze(t,e),a=i&&xze(r,e);return a?i.map(JV).concat({type:e,attrs:n}).concat(a.map(JV)):null}function JV(t){return{type:t,attrs:null}}function gze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(r,i,s)?a:null}function xze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let c=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:s}function bze(t,e,n){let r=mt.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=mt.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Ii(i,a,i,a,new Pt(r,0,0),n.length,!0))}function yze(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let c=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,c)&&vze(t.doc,t.mapping.slice(a).map(o),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&OQ(t,s,o,a),DO(t,t.mapping.slice(a).map(o,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(o,1),g=d.map(o+s.nodeSize,1);return t.step(new Ii(f,g,f+1,g-1,new Pt(mt.from(r.create(c,null,s.marks)),0,0),1,!0)),u===!0&&DQ(t,s,o,a),!1}})}function DQ(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function OQ(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
  8101. `))}})}function vze(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function _ze(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let s=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,s);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ii(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Pt(mt.from(s),0,0),1,!0))}function Cc(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,s=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let v=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!v.type.validContent(p))return!1}let o=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(o,o,c?c.type:i.node(a+1).type)}function wze(t,e,n=1,r){let i=t.doc.resolve(e),a=mt.empty,s=mt.empty;for(let o=i.depth,c=i.depth-n,u=n-1;o>c;o--,u--){a=mt.from(i.node(o).copy(a));let d=r&&r[u];s=mt.from(d?d.type.create(d.attrs,s):i.node(o).copy(s))}t.step(new Oi(e,e,new Pt(a.append(s),n,n),!0))}function kd(t,e){let n=t.resolve(e),r=n.index();return LQ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Sze(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),s=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function LQ(t,e){return!!(t&&e&&!t.isLeaf&&Sze(t,e))}function JM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,s,o=r.index(i);if(i==r.depth?(a=r.nodeBefore,s=r.nodeAfter):n>0?(a=r.node(i+1),o++,s=r.node(i).maybeChild(o)):(a=r.node(i).maybeChild(o-1),s=r.node(i+1)),a&&!a.isTextblock&&LQ(a,s)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function Mze(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),s=a.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);OQ(t,d.node(),d.before(),o)}s.inlineContent&&DO(t,e+n-1,s,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(o),u=c.map(e-n);if(t.step(new Oi(u,c.map(e+n,-1),Pt.empty,!0)),r===!0){let d=t.doc.resolve(u);DQ(t,d.node(),d.before(),t.steps.length)}return t}function Eze(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function IQ(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let s=r.depth;s>=0;s--){let o=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(o>0?1:0),u=r.node(s),d=!1;if(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return o==0?r.pos:o<0?r.before(s+1):r.after(s+1)}return null}function eE(t,e,n=e,r=Pt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return FQ(i,a,r)?new Oi(e,n,r):new Aze(i,a,r).fit()}function FQ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class Aze{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=mt.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=mt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,s=r.depth,o=i.depth;for(;s&&o&&a.childCount==1;)a=a.firstChild.content,s--,o--;let c=new Pt(a,s,o);return e>-1?new Ii(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Oi(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=BN(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let s=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:c,match:u}=this.frontier[o],d,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(mt.from(s),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:o,parent:a,inject:f};if(n==2&&s&&(d=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:o,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=BN(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Pt(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=BN(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Pt(Vx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Pt(Vx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let v=0;v<a.length;v++)this.openFrontierNode(a[v]);let s=this.unplaced,o=r?r.content:s.content,c=s.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let p=o.size+e-(s.content.size-s.openEnd);for(;u<o.childCount;){let v=o.child(u),y=f.matchType(v.type);if(!y)break;u++,(u>1||c==0||v.content.size)&&(f=y,d.push(UQ(v.mark(g.allowedMarks(v.marks)),u==1?c:0,u==o.childCount?p:-1)))}let x=u==o.childCount;x||(p=-1),this.placed=Gx(this.placed,n,mt.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,y=o;v<p;v++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=x?e==0?Pt.empty:new Pt(Vx(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Pt(Vx(s.content,e,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!HN(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=HN(e,n,i,r,a);if(s){for(let o=n-1;o>=0;o--){let{match:c,type:u}=this.frontier[o],d=HN(e,o,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Gx(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Gx(this.placed,this.depth,mt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(mt.empty,!0);n.childCount&&(this.placed=Gx(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 Gx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Gx(t.lastChild.content,e-1,n)))}function BN(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function UQ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,UQ(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(mt.empty,!0)))),t.copy(r)}function HN(t,e,n,r,i){let a=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==a.childCount&&!n.compatibleContent(a.type))return null;let o=r.fillBefore(a.content,!0,s);return o&&!Tze(n,a.content,s)?o:null}function Tze(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function Cze(t){return t.spec.defining||t.spec.definingForContent}function Nze(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(FQ(i,a,r))return t.step(new Oi(e,n,r));let s=BQ(i,a);s[s.length-1]==0&&s.pop();let o=-(i.depth+1);s.unshift(o);for(let g=i.depth,p=i.pos-1;g>0;g--,p--){let x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;s.indexOf(g)>-1?o=g:i.before(g)==p&&s.splice(1,0,-g)}let c=s.indexOf(o),u=[],d=r.openStart;for(let g=r.content,p=0;;p++){let x=g.firstChild;if(u.push(x),p==r.openStart)break;g=x.content}for(let g=d-1;g>=0;g--){let p=u[g],x=Cze(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(o)-1)))d=g;else if(x||!p.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let p=(g+d+1)%(r.openStart+1),x=u[p];if(x)for(let v=0;v<s.length;v++){let y=s[(v+c)%s.length],b=!0;y<0&&(b=!1,y=-y);let E=i.node(y-1),w=i.index(y-1);if(E.canReplaceWith(w,w,x.type,x.marks))return t.replace(i.before(y),b?a.after(y):n,new Pt(zQ(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let g=s.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let p=s[g];p<0||(e=i.before(p),n=a.after(p))}}function zQ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(zQ(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),s=a.fillBefore(t).append(t);t=s.append(a.matchFragment(s).fillBefore(mt.empty,!0))}return t}function kze(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=Eze(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Pt(mt.from(r),0,0))}function Pze(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=BQ(r,i);for(let s=0;s<a.length;s++){let o=a[s],c=s==a.length-1;if(c&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(c||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function BQ(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class dp extends ba{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 ni.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ni.fromReplace(e,this.pos,this.pos+1,new Pt(mt.from(i),0,n.isLeaf?0:1))}getMap(){return _s.empty}invert(e){return new dp(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 dp(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 dp(n.pos,n.attr,n.value)}}ba.jsonID("attr",dp);class rb extends ba{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 ni.ok(r)}getMap(){return _s.empty}invert(e){return new rb(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 rb(n.attr,n.value)}}ba.jsonID("docAttr",rb);let Up=class extends Error{};Up=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Up.prototype=Object.create(Error.prototype);Up.prototype.constructor=Up;Up.prototype.name="TransformError";class HQ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Up(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=Pt.empty){let i=eE(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Pt(mt.from(r),0,0))}delete(e,n){return this.replace(e,n,Pt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Nze(this,e,n,r),this}replaceRangeWith(e,n,r){return kze(this,e,n,r),this}deleteRange(e,n){return Pze(this,e,n),this}lift(e,n){return pze(this,e,n),this}join(e,n=1){return Mze(this,e,n),this}wrap(e,n){return bze(this,e,n),this}setBlockType(e,n=e,r,i=null){return yze(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return _ze(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new dp(e,n,r)),this}setDocAttribute(e,n){return this.step(new rb(e,n)),this}addNodeMark(e,n){return this.step(new Zu(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 nr)n.isInSet(r.marks)&&this.step(new uf(e,n));else{let i=r.marks,a,s=[];for(;a=n.isInSet(i);)s.push(new uf(e,a)),i=a.removeFromSet(i);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,r){return wze(this,e,n,r),this}addMark(e,n,r){return hze(this,e,n,r),this}removeMark(e,n,r){return fze(this,e,n,r),this}clearIncompatible(e,n,r){return DO(this,e,n,r),this}}const $N=Object.create(null);class un{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Rze(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=Pt.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let a=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:c,$to:u}=s[o],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),o?Pt.empty:n),o==0&&n7(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:s,$to:o}=i[a],c=e.mapping.slice(r),u=c.map(s.pos),d=c.map(o.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),n7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Kt(e):Hm(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let s=n<0?Hm(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Hm(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ts(e.node(0))}static atStart(e){return Hm(e,e,0,0,1)||new Ts(e)}static atEnd(e){return Hm(e,e,e.content.size,e.childCount,-1)||new Ts(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=$N[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 $N)throw new RangeError("Duplicate use of selection JSON ID "+e);return $N[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Kt.between(this.$anchor,this.$head).getBookmark()}}un.prototype.visible=!0;class Rze{constructor(e,n){this.$from=e,this.$to=n}}let e7=!1;function t7(t){!e7&&!t.parent.inlineContent&&(e7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Kt extends un{constructor(e,n=e){t7(e),t7(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 un.near(r);let i=e.resolve(n.map(this.anchor));return new Kt(i.parent.inlineContent?i:r,r)}replace(e,n=Pt.empty){if(super.replace(e,n),n==Pt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Kt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new tE(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 Kt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=un.findFrom(n,r,!0)||un.findFrom(n,-r,!0);if(a)n=a.$head;else return un.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(un.findFrom(e,-r,!0)||un.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Kt(e,n)}}un.jsonID("text",Kt);class tE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new tE(e.map(this.anchor),e.map(this.head))}resolve(e){return Kt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends un{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?un.near(a):new Ht(a)}content(){return new Pt(mt.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 LO(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;un.jsonID("node",Ht);class LO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new tE(r,r):new LO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ht.isSelectable(r)?new Ht(n):un.near(n)}}class Ts extends un{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Pt.empty){if(n==Pt.empty){e.delete(0,e.doc.content.size);let r=un.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ts(e)}map(e){return new Ts(e)}eq(e){return e instanceof Ts}getBookmark(){return jze}}un.jsonID("all",Ts);const jze={map(){return this},resolve(t){return new Ts(t)}};function Hm(t,e,n,r,i,a=!1){if(e.inlineContent)return Kt.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let o=e.child(s);if(o.isAtom){if(!a&&Ht.isSelectable(o))return Ht.create(t,n-(i<0?o.nodeSize:0))}else{let c=Hm(t,o,n+i,i<0?o.childCount:0,i,a);if(c)return c}n+=o.nodeSize*i}return null}function n7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Oi||i instanceof Ii))return;let a=t.mapping.maps[r],s;a.forEach((o,c,u,d)=>{s==null&&(s=d)}),t.setSelection(un.near(t.doc.resolve(s),n))}const r7=1,U_=2,i7=4;class Dze extends HQ{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|r7)&~U_,this.storedMarks=null,this}get selectionSet(){return(this.updated&r7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=U_,this}ensureMarks(e){return nr.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&U_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~U_,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)||nr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let s=this.doc.resolve(n);a=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(un.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|=i7,this}get scrolledIntoView(){return(this.updated&i7)>0}}function a7(t,e){return!e||!t?t:t.bind(e)}class Wx{constructor(e,n,r){this.name=e,this.init=a7(n.init,r),this.apply=a7(n.apply,r)}}const Oze=[new Wx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Wx("selection",{init(t,e){return t.selection||un.atStart(e.doc)},apply(t){return t.selection}}),new Wx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Wx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class VN{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Oze.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 Wx(r.key,r.spec.state,r))})}}class Qm{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let c=i?i[s].n:0,u=i?i[s].state:this,d=c<n.length&&o.spec.appendTransaction.call(o,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[s]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Qm(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new Dze(this)}static create(e){let n=new VN(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Qm(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 VN(this.schema,e.plugins),r=n.fields,i=new Qm(n);for(let a=0;a<r.length;a++){let s=r[a].name;i[s]=this.hasOwnProperty(s)?this[s]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new VN(e.schema,e.plugins),a=new Qm(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=ad.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=un.fromJSON(a.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let c=r[o],u=c.spec.state;if(c.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){a[s.name]=u.fromJSON.call(c,e,n[o],a);return}}a[s.name]=s.init(e,a)}}),a}}function $Q(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=$Q(i,e,{})),n[r]=i}return n}class Tr{constructor(e){this.spec=e,this.props={},e.props&&$Q(e.props,this,this.props),this.key=e.key?e.key.key:VQ("plugin")}getState(e){return e[this.key]}}const GN=Object.create(null);function VQ(t){return t in GN?t+"$"+ ++GN[t]:(GN[t]=0,t+"$")}class Si{constructor(e="key"){this.key=VQ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const IO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function GQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const WQ=(t,e,n)=>{let r=GQ(t,n);if(!r)return!1;let i=FO(r);if(!i){let s=r.blockRange(),o=s&&pg(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let a=i.nodeBefore;if(tJ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(zp(a,"end")||Ht.isSelectable(a)))for(let s=r.depth;;s--){let o=eE(t.doc,r.before(s),r.after(s),Pt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(zp(a,"end")?un.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Ht.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Lze=(t,e,n)=>{let r=GQ(t,n);if(!r)return!1;let i=FO(r);return i?qQ(t,i,e):!1},Ize=(t,e,n)=>{let r=XQ(t,n);if(!r)return!1;let i=UO(r);return i?qQ(t,i,e):!1};function qQ(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let s=e.nodeAfter,o=s,c=e.pos+1;for(;!o.isTextblock;c++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let u=eE(t.doc,a,c,Pt.empty);if(!u||u.from!=a||u instanceof Oi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(Kt.create(d.doc,a)),n(d.scrollIntoView())}return!0}function zp(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 KQ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=FO(r)}let s=a&&a.nodeBefore;return!s||!Ht.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function FO(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 XQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const YQ=(t,e,n)=>{let r=XQ(t,n);if(!r)return!1;let i=UO(r);if(!i)return!1;let a=i.nodeAfter;if(tJ(t,i,e,1))return!0;if(r.parent.content.size==0&&(zp(a,"start")||Ht.isSelectable(a))){let s=eE(t.doc,r.before(),r.after(),Pt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(zp(a,"start")?un.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 a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},ZQ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=UO(r)}let s=a&&a.nodeAfter;return!s||!Ht.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,a.pos)).scrollIntoView()),!0)};function UO(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 Fze=(t,e)=>{let n=t.selection,r=n instanceof Ht,i;if(r){if(n.node.isTextblock||!kd(t.doc,n.from))return!1;i=n.from}else if(i=JM(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Ht.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},Uze=(t,e)=>{let n=t.selection,r;if(n instanceof Ht){if(n.node.isTextblock||!kd(t.doc,n.to))return!1;r=n.to}else if(r=JM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},zze=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&pg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},QQ=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8102. `).scrollIntoView()),!0)};function zO(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 Bze=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),s=zO(i.contentMatchAt(a));if(!s||!i.canReplaceWith(a,a,s))return!1;if(e){let o=n.after(),c=t.tr.replaceWith(o,o,s.createAndFill());c.setSelection(un.near(c.doc.resolve(o),1)),e(c.scrollIntoView())}return!0},JQ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ts||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=zO(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(s,a.createAndFill());o.setSelection(Kt.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},eJ=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(Cc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&pg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Hze(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ht&&e.selection.node.isBlock)return!r.parentOffset||!Cc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],s,o,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),o=zO(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&o?{type:o}:null),s=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof Kt||e.selection instanceof Ts)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Cc(d.doc,f,a.length,a);if(g||(a[0]=o?{type:o}:null,g=Cc(d.doc,f,a.length,a)),!g)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(s).type!=o){let p=d.mapping.map(r.before(s)),x=d.doc.resolve(p);o&&r.node(s-1).canReplaceWith(x.index(),x.index()+1,o)&&d.setNodeMarkup(d.mapping.map(r.before(s)),o)}return n&&n(d.scrollIntoView()),!0}}const $ze=Hze(),Vze=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Ht.create(t.doc,i))),!0)};function Gze(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||kd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function tJ(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,o,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Gze(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(s=(o=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&o.matchType(s[0]||a.type).validEnd){if(n){let p=e.pos+a.nodeSize,x=mt.empty;for(let b=s.length-1;b>=0;b--)x=mt.from(s[b].create(null,x));x=mt.from(i.copy(x));let v=t.tr.step(new Ii(e.pos-1,p,e.pos,p,new Pt(x,1,0),s.length,!0)),y=v.doc.resolve(p+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&kd(v.doc,y.pos)&&v.join(y.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:un.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&pg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&zp(a,"start",!0)&&zp(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let v=a,y=1;for(;!v.isTextblock;v=v.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let b=mt.empty;for(let w=x.length-1;w>=0;w--)b=mt.from(x[w].copy(b));let E=t.tr.step(new Ii(e.pos-x.length,e.pos+a.nodeSize,e.pos+y,e.pos+a.nodeSize-y,new Pt(b,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function nJ(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(Kt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const Wze=nJ(-1),qze=nJ(1);function Kze(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),o=s&&OO(s,t,e);return o?(r&&r(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function s7(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[a];n.doc.nodesBetween(s,o,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[s];a.setBlockType(o,c,t,e)}r(a.scrollIntoView())}return!0}}function BO(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}BO(IO,WQ,KQ);BO(IO,YQ,ZQ);BO(QQ,JQ,eJ,$ze);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Xze(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a);if(!s)return!1;let o=r?n.tr:null;return Yze(o,s,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function Yze(t,e,n,r=null){let i=!1,a=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=s.resolve(e.start-2);a=new Xw(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new Xw(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=OO(a,n,r,e);return o?(t&&Zze(t,e,o,i,n),!0):!1}function Zze(t,e,n,r,i){let a=mt.empty;for(let d=n.length-1;d>=0;d--)a=mt.from(n[d].type.create(n[d].attrs,a));t.step(new Ii(e.start-(r?2:0),e.end,e.start,e.end,new Pt(a,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==i&&(s=d+1);let o=n.length-s,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&Cc(t.doc,c,o)&&(t.split(c,o),c+=2*o),c+=u.child(d).nodeSize;return t}function Qze(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?Jze(e,n,t,a):e8e(e,n,a):!0:!1}}function Jze(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new Ii(a-1,s,a,s,new Pt(mt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Xw(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const o=pg(r);if(o==null)return!1;i.lift(r,o);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return kd(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function e8e(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,v=n.startIndex;x>v;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let a=r.doc.resolve(n.start),s=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(o?0:1),d+1,s.content.append(c?mt.empty:mt.from(i))))return!1;let f=a.pos,g=f+s.nodeSize;return r.step(new Ii(f-(o?1:0),g+(c?1:0),f+1,g-1,new Pt((o?mt.empty:mt.from(i.copy(mt.empty))).append(c?mt.empty:mt.from(i.copy(mt.empty))),o?0:1,c?0:1),o?0:1)),e(r.scrollIntoView()),!0}function t8e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let s=a.startIndex;if(s==0)return!1;let o=a.parent,c=o.child(s-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==o.type,d=mt.from(u?t.create():null),f=new Pt(mt.from(t.create(null,mt.from(o.type.create(null,d)))),u?3:1,0),g=a.start,p=a.end;n(e.tr.step(new Ii(g-(u?3:1),p,g,p,f,1,!0)).scrollIntoView())}return!0}}const ea=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Bp=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let JP=null;const lc=function(t,e,n){let r=JP||(JP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},n8e=function(){JP=null},df=function(t,e,n,r){return n&&(o7(t,e,n,r,-1)||o7(t,e,n,r,1))},r8e=/^(img|br|input|textarea|hr)$/i;function o7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:to(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Qb(t)||r8e.test(t.nodeName)||t.contentEditable=="false")return!1;e=ea(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((a=s.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?to(t):0}else return!1}}function to(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function i8e(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=to(t)}else if(t.parentNode&&!Qb(t))e=ea(t),t=t.parentNode;else return null}}function a8e(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&&!Qb(t))e=ea(t)+1,t=t.parentNode;else return null}}function s8e(t,e,n){for(let r=e==0,i=e==to(t);r||i;){if(t==n)return!0;let a=ea(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==to(t)}}function Qb(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 nE=function(t){return t.focusNode&&df(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function bh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function o8e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function l8e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(to(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(to(r.startContainer),r.startOffset)}}}const yl=typeof navigator<"u"?navigator:null,l7=typeof document<"u"?document:null,Pd=yl&&yl.userAgent||"",eR=/Edge\/(\d+)/.exec(Pd),rJ=/MSIE \d/.exec(Pd),tR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pd),es=!!(rJ||tR||eR),sd=rJ?document.documentMode:tR?+tR[1]:eR?+eR[1]:0,oo=!es&&/gecko\/(\d+)/i.test(Pd);oo&&+(/Firefox\/(\d+)/.exec(Pd)||[0,0])[1];const nR=!es&&/Chrome\/(\d+)/.exec(Pd),fa=!!nR,iJ=nR?+nR[1]:0,Ra=!es&&!!yl&&/Apple Computer/.test(yl.vendor),Hp=Ra&&(/Mobile\/\w+/.test(Pd)||!!yl&&yl.maxTouchPoints>2),Xs=Hp||(yl?/Mac/.test(yl.platform):!1),c8e=yl?/Win/.test(yl.platform):!1,vc=/Android \d/.test(Pd),Jb=!!l7&&"webkitFontSmoothing"in l7.documentElement.style,u8e=Jb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function d8e(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 nc(t,e){return typeof t=="number"?t:t[e]}function h8e(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 c7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Bp(s);continue}let o=s,c=o==a.body,u=c?d8e(a):h8e(o),d=0,f=0;if(e.top<u.top+nc(r,"top")?f=-(u.top-e.top+nc(i,"top")):e.bottom>u.bottom-nc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+nc(i,"top")-u.top:e.bottom-u.bottom+nc(i,"bottom")),e.left<u.left+nc(r,"left")?d=-(u.left-e.left+nc(i,"left")):e.right>u.right-nc(r,"right")&&(d=e.right-u.right+nc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=o.scrollLeft,x=o.scrollTop;f&&(o.scrollTop+=f),d&&(o.scrollLeft+=d);let v=o.scrollLeft-p,y=o.scrollTop-x;e={left:e.left-v,top:e.top-y,right:e.right-v,bottom:e.bottom-y}}let g=c?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:Bp(s)}}function f8e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(a,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let c=o.getBoundingClientRect();if(c.top>=n-20){r=o,i=c.top;break}}return{refDOM:r,refTop:i,stack:aJ(t.dom)}}function aJ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Bp(r));return e}function m8e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;sJ(n,r==0?0:r-e)}function sJ(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let Lm=null;function p8e(t){if(t.setActive)return t.setActive();if(Lm)return t.focus(Lm);let e=aJ(t);t.focus(Lm==null?{get preventScroll(){return Lm={preventScroll:!0},!0}}:void 0),Lm||(Lm=!1,sJ(e,0))}function oJ(t,e){let n,r=2e8,i,a=0,s=e.top,o=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=lc(d).getClientRects();else continue;for(let p=0;p<g.length;p++){let x=g[p];if(x.top<=s&&x.bottom>=o){s=Math.max(x.bottom,s),o=Math.min(x.top,o);let v=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?g8e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:oJ(n,i)}function g8e(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=ju(r,1);if(a.top!=a.bottom&&HO(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function HO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function x8e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function b8e(t,e,n){let{node:r,offset:i}=oJ(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function y8e(t,e,n,r){let i=-1;for(let a=e,s=!1;a!=t.dom;){let o=t.docView.nearestDesc(a,!0),c;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((c=o.dom.getBoundingClientRect()).width||c.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&c.left>r.left||c.top>r.top?i=o.posBefore:(!s&&c.right<r.left||c.bottom<r.top)&&(i=o.posAfter),s=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?o.posBefore:o.posAfter;a=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function lJ(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let s=t.childNodes[a];if(s.nodeType==1){let o=s.getClientRects();for(let c=0;c<o.length;c++){let u=o[c];if(HO(e,u))return lJ(s,e,u)}}if((a=(a+1)%r)==i)break}return t}function v8e(t,e){let n=t.dom.ownerDocument,r,i=0,a=l8e(n,e.left,e.top);a&&({node:r,offset:i}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let u=t.dom.getBoundingClientRect();if(!HO(e,u)||(s=lJ(t.dom,e,u),!s))return null}if(Ra)for(let u=s;r&&u;u=Bp(u))u.draggable&&(r=void 0);if(s=x8e(s,e),r){if(oo&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;Jb&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(o=y8e(t,r,i,e))}o==null&&(o=b8e(t,s,e));let c=t.docView.nearestDesc(s,!0);return{pos:o,inside:c?c.posAtStart-c.border:-1}}function u7(t){return t.top<t.bottom||t.left<t.right}function ju(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(u7(r))return r}return Array.prototype.find.call(n,u7)||t.getBoundingClientRect()}const _8e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function cJ(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=Jb||oo;if(r.nodeType==3)if(s&&(_8e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=ju(lc(r,i,i),n);if(oo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=ju(lc(r,i-1,i-1),-1);if(u.top==c.top){let d=ju(lc(r,i,i+1),-1);if(d.top!=c.top)return jx(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,jx(ju(lc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==to(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return WN(c.getBoundingClientRect(),!1)}if(a==null&&i<to(r)){let c=r.childNodes[i];if(c.nodeType==1)return WN(c.getBoundingClientRect(),!0)}return WN(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==to(r))){let c=r.childNodes[i-1],u=c.nodeType==3?lc(c,to(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return jx(ju(u,1),!1)}if(a==null&&i<to(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?lc(c,0,s?0:1):c.nodeType==1?c:null:null;if(u)return jx(ju(u,-1),!0)}return jx(ju(r.nodeType==3?lc(r):r,-n),n>=0)}function jx(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 WN(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 uJ(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function w8e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return uJ(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(a,!0);if(!o)break;if(o.node.isBlock){a=o.contentDOM||o.dom;break}a=o.dom.parentNode}let s=cJ(t,i.pos,1);for(let o=a.firstChild;o;o=o.nextSibling){let c;if(o.nodeType==1)c=o.getClientRects();else if(o.nodeType==3)c=lc(o,0,o.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const S8e=/[\u0590-\u08ac]/;function M8e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,s=i==r.parent.content.size,o=t.domSelection();return o?!S8e.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:s:uJ(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:v}=t.domSelectionRange(),y=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==v;try{o.collapse(d,f),c&&(c!=d||u!=f)&&o.extend&&o.extend(c,u)}catch{}return g!=null&&(o.caretBidiLevel=g),y}):r.pos==r.start()||r.pos==r.end()}let d7=null,h7=null,f7=!1;function E8e(t,e,n){return d7==e&&h7==n?f7:(d7=e,h7=n,f7=n=="up"||n=="down"?w8e(t,e,n):M8e(t,e,n))}const lo=0,m7=1,Mh=2,vl=3;class ey{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=lo,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,s;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(s)+s.size:this.posAtStart}else{let a,s;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>ea(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),s;if(a&&(!n||a.node))if(r&&(s=a.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let o=i.children[s];if(o.size){i=o;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let s=this.children[r],o=a+s.size;if(o>e||s instanceof hJ){i=e-a;break}a=o}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof dJ&&a.side>=0;r--);if(n<=0){let a,s=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,s=!1);return a&&n&&s&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?ea(a.dom)+1:0}}else{let a,s=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,s=!1);return a&&s&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?ea(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let s=r,o=0;;o++){let c=this.children[o],u=s+c.size;if(i==-1&&e<=u){let d=s+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=s;for(let f=o;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=ea(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||o==this.children.length-1)){n=u;for(let d=o+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=ea(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}s=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),s=Math.max(e,n);for(let p=0,x=0;p<this.children.length;p++){let v=this.children[p],y=x+v.size;if(a>x&&s<y)return v.setSelection(e-x-v.border,n-x-v.border,r,i);x=y}let o=this.domFromPos(e,e?-1:1),c=n==e?o:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((oo||Ra)&&e==n){let{node:p,offset:x}=o;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
  8103. `),f&&x==p.nodeValue.length)for(let v=p,y;v;v=v.parentNode){if(y=v.nextSibling){y.nodeName=="BR"&&(o=c={node:y.parentNode,offset:ea(y)+1});break}let b=v.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let v=p.childNodes[x-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(oo&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ra)&&df(o.node,o.offset,d.anchorNode,d.anchorOffset)&&df(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&oo)){u.collapse(o.node,o.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let x=o;o=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],s=r+a.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let o=r+a.border,c=s-a.border;if(e>=o&&n<=c){this.dirty=e==r||n==s?Mh:m7,e==o&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=vl:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Mh:vl}r=s}this.dirty=Mh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Mh:m7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class dJ extends ey{constructor(e,n,r,i){let a,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==lo&&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 A8e extends ey{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 hf extends ey{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],s=a&&a(n,i,r);return(!s||!s.dom)&&(s=yf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new hf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&vl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=vl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=lo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=lo}}slice(e,n,r){let i=hf.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=iR(a,n,s,r)),e>0&&(a=iR(a,0,e,r));for(let o=0;o<a.length;o++)a[o].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class od extends ey{constructor(e,n,r,i,a,s,o,c,u){super(e,[],a,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,a,s){let o=a.nodeViews[n.type.name],c,u=o&&o(n,a,()=>{if(!c)return s;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=yf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let g=d;return d=pJ(d,r,n),u?c=new T8e(e,n,r,i,d,f||null,g,u,a,s+1):n.isText?new rE(e,n,r,i,d,g,a):new od(e,n,r,i,d,f||null,g,a,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>mt.empty)}return e}matchesNode(e,n,r){return this.dirty==lo&&e.eq(this.node)&&Zw(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,s=a&&a.pos>-1?a:null,o=a&&a.pos<0,c=new N8e(this,s&&s.node,e);R8e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?nr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,g)=>{c.syncToMarks(u.marks,r,e);let p;c.findNodeMatch(u,d,f,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,g,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Mh)&&(s&&this.protectLocalComposition(e,s),fJ(this.contentDOM,this.children,e),Hp&&j8e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Kt)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let s=a.nodeValue,o=D8e(this.node.content,s,r-n,i-n);return o<0?null:{node:a,pos:o,text:s}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let s=new A8e(this,a,n,i);e.input.compositionNodes.push(s),this.children=iR(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==vl||!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=lo}updateOuterDeco(e){if(Zw(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=mJ(this.dom,this.nodeDOM,rR(this.outerDeco,this.node,n),rR(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 p7(t,e,n,r,i){pJ(r,e,t);let a=new od(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class rE extends od{constructor(e,n,r,i,a,s,o){super(e,n,r,i,a,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==vl||this.dirty!=lo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=lo||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=lo,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new rE(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=vl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class hJ extends ey{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==lo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class T8e extends od{constructor(e,n,r,i,a,s,o,c,u,d){super(e,n,r,i,a,s,o,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==vl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function fJ(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let s=e[a],o=s.dom;if(o.parentNode==t){for(;o!=r;)r=g7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(s instanceof hf){let c=r?r.previousSibling:t.lastChild;fJ(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=g7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const s0=function(t){t&&(this.nodeName=t)};s0.prototype=Object.create(null);const Eh=[new s0];function rR(t,e,n){if(t.length==0)return Eh;let r=n?Eh[0]:new s0,i=[r];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&i.push(r=new s0(s.nodeName));for(let o in s){let c=s[o];c!=null&&(n&&i.length==1&&i.push(r=new s0(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+c:o=="style"?r.style=(r.style?r.style+";":"")+c:o!="nodeName"&&(r[o]=c))}}}return i}function mJ(t,e,n,r){if(n==Eh&&r==Eh)return e;let i=e;for(let a=0;a<r.length;a++){let s=r[a],o=n[a];if(a){let c;o&&o.nodeName==s.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||(c=document.createElement(s.nodeName),c.pmIsDeco=!0,c.appendChild(i),o=Eh[0]),i=c}C8e(i,o||Eh[0],s)}return i}function C8e(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function pJ(t,e,n){return mJ(t,t,Eh,rR(e,n,t.nodeType!=1))}function Zw(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 g7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class N8e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=k8e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,s=Math.min(a,e.length);for(;i<s&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=lo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){o=c;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let c=hf.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))a=this.top.children.indexOf(s,this.index);else for(let o=this.index,c=Math.min(this.top.children.length,o+5);o<c;o++){let u=this.top.children[o];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=o;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let s=this.top.children[i];return s.dirty==vl&&s.dom==s.contentDOM&&(s.dirty=Mh),s.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,s){for(let o=this.index;o<this.top.children.length;o++){let c=this.top.children[o];if(c instanceof od){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,g=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=vl&&Zw(n,c.outerDeco));if(!g&&c.update(e,n,r,i))return this.destroyBetween(this.index,o),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(c,e,n,r,i,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Mh,f.updateChildren(i,s+1),f.dirty=lo),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Zw(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=od.create(this.top,n,r,i,a,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let c of o.children)c.parent=o}return e.destroy(),o}addNode(e,n,r,i,a){let s=od.create(this.top,e,n,r,i,a);s.contentDOM&&s.updateChildren(i,a+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let a=new dJ(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof hf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof rE)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ra||fa)&&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 hJ(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 k8e(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,s=[];e:for(;i>0;){let o;for(;;)if(r){let u=n.children[r-1];if(u instanceof hf)n=u,r=u.children.length;else{o=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=o.node;if(c){if(c!=t.child(i-1))break;--i,a.set(o,i),s.push(o)}}return{index:i,matched:a,matches:s.reverse()}}function P8e(t,e){return t.type.side-e.type.side}function R8e(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let s=0,o=[],c=null;for(let u=0;;){let d,f;for(;s<i.length&&i[s].to==a;){let y=i[s++];y.widget&&(d?(f||(f=[d])).push(y):d=y)}if(d)if(f){f.sort(P8e);for(let y=0;y<f.length;y++)n(f[y],u,!!c)}else n(d,u,!!c);let g,p;if(c)p=-1,g=c,c=null;else if(u<t.childCount)p=u,g=t.child(u++);else break;for(let y=0;y<o.length;y++)o[y].to<=a&&o.splice(y--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)o.push(i[s++]);let x=a+g.nodeSize;if(g.isText){let y=x;s<i.length&&i[s].from<y&&(y=i[s].from);for(let b=0;b<o.length;b++)o[b].to<y&&(y=o[b].to);y<x&&(c=g.cut(y-a),g=g.cut(0,y-a),x=y,p=-1)}else for(;s<i.length&&i[s].to<x;)s++;let v=g.isInline&&!g.isLeaf?o.filter(y=>!y.inline):o.slice();r(g,v,e.forChild(a,g),p),a=x}}function j8e(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 D8e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let s=t.child(i++),o=a;if(a+=s.nodeSize,!s.isText)continue;let c=s.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-o,r-o)==e)return r-e.length;let u=o<r?c.lastIndexOf(e,r-o-1):-1;if(u>=0&&u+e.length+o>=n)return o+u;if(n==r&&c.length>=r+e.length-o&&c.slice(r-o,r-o+e.length)==e)return r}}return-1}function iR(t,e,n,r,i){let a=[];for(let s=0,o=0;s<t.length;s++){let c=t[s],u=o,d=o+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function $O(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=r.resolve(s),c,u;if(nE(n)){for(c=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ht.isSelectable(f)&&i.parent&&!(f.isInline&&s8e(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new Ht(s==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,g=s;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,s]=g==t.state.selection.anchor?[g,f]:[f,g],o=r.resolve(s)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<o.pos&&!a?1:-1;u=VO(t,d,o,f)}return u}function gJ(t){return t.editable?t.hasFocus():bJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Nc(t,e=!1){let n=t.state.selection;if(xJ(t,n),!!gJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&fa){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&df(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)L8e(t);else{let{anchor:r,head:i}=n,a,s;x7&&!(n instanceof Kt)&&(n.$from.parent.inlineContent||(a=b7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=b7(t,n.to))),t.docView.setSelection(r,i,t,e),x7&&(a&&y7(a),s&&y7(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&O8e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const x7=Ra||fa&&iJ<63;function b7(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(Ra&&i&&i.contentEditable=="false")return qN(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return qN(i);if(a)return qN(a)}}function qN(t){return t.contentEditable="true",Ra&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function y7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function O8e(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(()=>{(!gJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function L8e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ea(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&es&&sd<=11&&(n.disabled=!0,n.disabled=!1)}function xJ(t,e){if(e instanceof Ht){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(v7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else v7(t)}function v7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function VO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Kt.between(e,n,r)}function _7(t){return t.editable&&!t.hasFocus()?!1:bJ(t)}function bJ(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 I8e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return df(e.node,e.offset,n.anchorNode,n.anchorOffset)}function aR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&un.findFrom(a,e)}function Fu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function w7(t,e,n){let r=t.state.selection;if(r instanceof Kt)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Fu(t,new Kt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=aR(t.state,e);return i&&i instanceof Ht?Fu(t,i):!1}else if(!(Xs&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!a||a.isText)return!1;let o=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?Ht.isSelectable(a)?Fu(t,new Ht(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Jb?Fu(t,new Kt(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Fu(t,new Kt(e>0?r.$to:r.$from));{let i=aR(t.state,e);return i?Fu(t,i):!1}}}function Qw(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function o0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Im(t,e){return e<0?F8e(t):U8e(t)}function F8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(oo&&n.nodeType==1&&r<Qw(n)&&o0(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(o0(o,-1))i=n,a=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(yJ(n))break;{let o=n.previousSibling;for(;o&&o0(o,-1);)i=n.parentNode,a=ea(o),o=o.previousSibling;if(o)n=o,r=Qw(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?sR(t,n,r):i&&sR(t,i,a)}function U8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Qw(n),a,s;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(o0(o,1))a=n,s=++r;else break}else{if(yJ(n))break;{let o=n.nextSibling;for(;o&&o0(o,1);)a=o.parentNode,s=ea(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=Qw(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&sR(t,a,s)}function yJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function z8e(t,e){for(;t&&e==t.childNodes.length&&!Qb(t);)e=ea(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 B8e(t,e){for(;t&&!e&&!Qb(t);)e=ea(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 sR(t,e,n){if(e.nodeType!=3){let a,s;(s=z8e(e,n))?(e=s,n=0):(a=B8e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(nE(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Nc(t)},50)}function S7(t,e){let n=t.state.doc.resolve(e);if(!(fa||c8e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function M7(t,e,n){let r=t.state.selection;if(r instanceof Kt&&!r.empty||n.indexOf("s")>-1||Xs&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=aR(t.state,e);if(s&&s instanceof Ht)return Fu(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,o=r instanceof Ts?un.near(s,e):un.findFrom(s,e);return o?Fu(t,o):!1}return!1}function E7(t,e){if(!(t.state.selection instanceof Kt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let s=t.state.tr;return e<0?s.delete(n.pos-a.nodeSize,n.pos):s.delete(n.pos,n.pos+a.nodeSize),t.dispatch(s),!0}return!1}function A7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function H8e(t){if(!Ra||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;A7(t,r,"true"),setTimeout(()=>A7(t,r,"false"),20)}return!1}function $8e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function V8e(t,e){let n=e.keyCode,r=$8e(e);if(n==8||Xs&&n==72&&r=="c")return E7(t,-1)||Im(t,-1);if(n==46&&!e.shiftKey||Xs&&n==68&&r=="c")return E7(t,1)||Im(t,1);if(n==13||n==27)return!0;if(n==37||Xs&&n==66&&r=="c"){let i=n==37?S7(t,t.state.selection.from)=="ltr"?-1:1:-1;return w7(t,i,r)||Im(t,i)}else if(n==39||Xs&&n==70&&r=="c"){let i=n==39?S7(t,t.state.selection.from)=="ltr"?1:-1:1;return w7(t,i,r)||Im(t,i)}else{if(n==38||Xs&&n==80&&r=="c")return M7(t,-1,r)||Im(t,-1);if(n==40||Xs&&n==78&&r=="c")return H8e(t)||M7(t,1,r)||Im(t,1);if(r==(Xs?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function GO(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||yf.fromSchema(t.state.schema),o=EJ(),c=o.createElement("div");c.appendChild(s.serializeFragment(r,{document:o}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=MJ[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=o.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8104. `);return{dom:c,text:g,slice:e}}function vJ(t,e,n,r,i){let a=i.parent.type.spec.code,s,o;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return o=new Pt(mt.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8105. `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)o=f;else{let g=i.marks(),{schema:p}=t.state,x=yf.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let y=s.appendChild(document.createElement("p"));v&&y.appendChild(x.serializeNode(p.text(v,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=K8e(n),Jb&&X8e(s);let u=s&&s.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||i0.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!G8e.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=Y8e(T7(o,+d[1],+d[2]),d[4]);else if(o=Pt.maxOpen(W8e(o.content,i),!0),o.openStart||o.openEnd){let f=0,g=0;for(let p=o.content.firstChild;f<o.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=o.content.lastChild;g<o.openEnd&&!p.type.spec.isolating;g++,p=p.lastChild);o=T7(o,f,g)}return t.someProp("transformPasted",f=>{o=f(o,t,c)}),o}const G8e=/^(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 W8e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,s=[];if(t.forEach(o=>{if(!s)return;let c=i.findWrapping(o.type),u;if(!c)return s=null;if(u=s.length&&a.length&&wJ(c,a,o,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=SJ(s[s.length-1],a.length));let d=_J(o,c);s.push(d),i=i.matchType(d.type),a=c}}),s)return mt.from(s)}return t}function _J(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,mt.from(t));return t}function wJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=wJ(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(mt.from(_J(n,t,i+1))))}}function SJ(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,SJ(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(mt.empty,!0);return t.copy(n.append(r))}function oR(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,o=s.content;return t.childCount>1&&(a=0),i<r-1&&(o=oR(o,e,n,r,i+1,a)),i>=n&&(o=e<0?s.contentMatchAt(0).fillBefore(o,a<=i).append(o):o.append(s.contentMatchAt(s.childCount).fillBefore(mt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function T7(t,e,n){return e<t.openStart&&(t=new Pt(oR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Pt(oR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const MJ={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 C7=null;function EJ(){return C7||(C7=document.implementation.createHTMLDocument("title"))}let KN=null;function q8e(t){let e=window.trustedTypes;return e?(KN||(KN=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),KN.createHTML(t)):t}function K8e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=EJ().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&MJ[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=q8e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function X8e(t){let e=t.querySelectorAll(fa?"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 Y8e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:s}=t;for(let o=r.length-2;o>=0;o-=2){let c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;i=mt.from(c.create(r[o+1],i)),a++,s++}return new Pt(i,a,s)}const ja={},Da={},Z8e={touchstart:!0,touchmove:!0};class Q8e{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 J8e(t){for(let e in ja){let n=ja[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{tBe(t,r)&&!WO(t,r)&&(t.editable||!(r.type in Da))&&n(t,r)},Z8e[e]?{passive:!0}:void 0)}Ra&&t.dom.addEventListener("input",()=>null),lR(t)}function Qu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function eBe(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 lR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>WO(t,r))})}function WO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function tBe(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 nBe(t,e){!WO(t,e)&&ja[e.type]&&(t.editable||!(e.type in Da))&&ja[e.type](t,e)}Da.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!TJ(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(vc&&fa&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Hp&&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,bh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||V8e(t,n)?n.preventDefault():Qu(t,"key")};Da.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Da.keypress=(t,e)=>{let n=e;if(TJ(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Xs&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Kt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function iE(t){return{left:t.clientX,top:t.clientY}}function rBe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function qO(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,o=>s>a.depth?o(t,n,a.nodeAfter,a.before(s),i,!0):o(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function hp(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 iBe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ht.isSelectable(r)?(hp(t,new Ht(n)),!0):!1}function aBe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ht&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let o=s>a.depth?a.nodeAfter:a.node(s);if(Ht.isSelectable(o)){r&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(s);break}}return i!=null?(hp(t,Ht.create(t.state.doc,i)),!0):!1}function sBe(t,e,n,r,i){return qO(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?aBe(t,n):iBe(t,n))}function oBe(t,e,n,r){return qO(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function lBe(t,e,n,r){return qO(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||cBe(t,n,r)}function cBe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(hp(t,Kt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let s=a>i.depth?i.nodeAfter:i.node(a),o=i.before(a);if(s.inlineContent)hp(t,Kt.create(r,o+1,o+1+s.content.size));else if(Ht.isSelectable(s))hp(t,Ht.create(r,o));else continue;return!0}}function KO(t){return Jw(t)}const AJ=Xs?"metaKey":"ctrlKey";ja.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=KO(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&rBe(n,t.input.lastClick)&&!n[AJ]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let s=t.posAtCoords(iE(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new uBe(t,s,n,!!r)):(a=="doubleClick"?oBe:lBe)(t,s.pos,s.inside,n)?n.preventDefault():Qu(t,"pointer"))};class uBe{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[AJ],this.allowDefault=r.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,s=d.depth?d.before():0}const o=i?null:r.target,c=o?e.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof Ht&&u.from<=s&&u.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&oo&&!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)),Qu(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(()=>Nc(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(iE(e))),this.updateAllowDefault(e),this.allowDefault||!n?Qu(this.view,"pointer"):sBe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ra&&this.mightDrag&&!this.mightDrag.node.isAtom||fa&&!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)?(hp(this.view,un.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Qu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Qu(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)}}ja.touchstart=t=>{t.input.lastTouch=Date.now(),KO(t),Qu(t,"pointer")};ja.touchmove=t=>{t.input.lastTouch=Date.now(),Qu(t,"pointer")};ja.contextmenu=t=>KO(t);function TJ(t,e){return t.composing?!0:Ra&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const dBe=vc?5e3:-1;Da.compositionstart=Da.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Kt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Jw(t,!0),t.markCursor=null;else if(Jw(t,!e.selection.empty),oo&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let s=a<0?i.lastChild:i.childNodes[a-1];if(!s)break;if(s.nodeType==3){let o=t.domSelection();o&&o.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}CJ(t,dBe)};Da.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++,CJ(t,20))};function CJ(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Jw(t),e))}function NJ(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=fBe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function hBe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=i8e(e.focusNode,e.focusOffset),r=a8e(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function fBe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Jw(t,e=!1){if(!(vc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),NJ(t),e||t.docView&&t.docView.dirty){let n=$O(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 mBe(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 ib=es&&sd<15||Hp&&u8e<604;ja.copy=Da.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ib?null:n.clipboardData,s=r.content(),{dom:o,text:c}=GO(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",c)):mBe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function pBe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function gBe(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?ab(t,r.value,null,i,e):ab(t,r.textContent,r.innerHTML,i,e)},50)}function ab(t,e,n,r,i){let a=vJ(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Pt.empty)))return!0;if(!a)return!1;let s=pBe(a),o=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function kJ(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," "):""}Da.paste=(t,e)=>{let n=e;if(t.composing&&!vc)return;let r=ib?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ab(t,kJ(r),r.getData("text/html"),i,n)?n.preventDefault():gBe(t,n)};class PJ{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const xBe=Xs?"altKey":"ctrlKey";function RJ(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[xBe]}ja.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(iE(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Ht?i.to-1:i.to))){if(r&&r.mightDrag)s=Ht.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=Ht.create(t.state.doc,f.posBefore))}}let o=(s||t.state.selection).content(),{dom:c,text:u,slice:d}=GO(t,o);(!n.dataTransfer.files.length||!fa||iJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ib?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",ib||n.dataTransfer.setData("text/plain",u),t.dragging=new PJ(d,RJ(t,n),s)};ja.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Da.dragover=Da.dragenter=(t,e)=>e.preventDefault();Da.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(iE(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",x=>{s=x(s,t,!1)}):s=vJ(t,kJ(n.dataTransfer),ib?null:n.dataTransfer.getData("text/html"),!1,a);let o=!!(r&&RJ(t,n));if(t.someProp("handleDrop",x=>x(t,n,s||Pt.empty,o))){n.preventDefault();return}if(!s)return;n.preventDefault();let c=s?IQ(t.state.doc,a.pos,s):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(o){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,s.content.firstChild):u.replaceRange(d,d,s),u.doc.eq(g))return;let p=u.doc.resolve(d);if(f&&Ht.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new Ht(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,y,b,E)=>x=E),u.setSelection(VO(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};ja.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())&&Nc(t)},20))};ja.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)};ja.beforeinput=(t,e)=>{if(fa&&vc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,bh(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 Da)ja[t]=Da[t];function sb(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 eS{constructor(e,n){this.toDOM=e,this.spec=n||Uh,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Ta(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof eS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&sb(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ld{constructor(e,n){this.attrs=e,this.spec=n||Uh}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=s?null:new Ta(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ld&&sb(this.attrs,e.attrs)&&sb(this.spec,e.spec)}static is(e){return e.type instanceof ld}destroy(){}}class XO{constructor(e,n){this.attrs=e,this.spec=n||Uh}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=a.pos?null:new Ta(a.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof XO&&sb(this.attrs,e.attrs)&&sb(this.spec,e.spec)}destroy(){}}class Ta{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ta(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 Ta(e,e,new eS(n,r))}static inline(e,n,r,i){return new Ta(e,n,new ld(r,i))}static node(e,n,r,i){return new Ta(e,n,new XO(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ld}get widget(){return this.type instanceof eS}}const $m=[],Uh={};class vr{constructor(e,n){this.local=e.length?e:$m,this.children=n.length?n:$m}static create(e,n){return n.length?tS(n,e,0,Uh):da}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,n-o,r,i+o,a)}}map(e,n,r){return this==da||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Uh)}mapInner(e,n,r,i,a){let s;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(e,r,i);c&&c.type.valid(n,c)?(s||(s=[])).push(c):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?bBe(this.children,s||[],e,n,r,i,a):s?new vr(s.sort(zh),$m):da}add(e,n){return n.length?this==da?vr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((o,c)=>{let u=c+r,d;if(d=DJ(n,o,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(o,d,u+1):i.splice(a,0,c,c+o.nodeSize,tS(d,o,u+1,Uh)),a+=3}});let s=jJ(a?OJ(n):n,-r);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new vr(s.length?this.local.concat(s).sort(zh):this.local,i||this.children)}remove(e){return e.length==0||this==da?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let s,o=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>o&&f.to<c&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(s,o+1);u!=da?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let o=0;o<i.length;o++)i[o].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new vr(i,r):da}forChild(e,n){if(this==da)return this;if(n.isLeaf)return vr.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let a=e+1,s=a+n.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<s&&c.to>a&&c.type instanceof ld){let u=Math.max(a,c.from)-a,d=Math.min(s,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let o=new vr(i.sort(zh),$m);return r?new Vu([o,r]):o}return r||da}eq(e){if(this==e)return!0;if(!(e instanceof vr)||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 YO(this.localsInner(e))}localsInner(e){if(this==da)return $m;if(e.inlineContent||!this.local.some(ld.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ld||n.push(this.local[r]);return n}forEachSet(e){e(this)}}vr.empty=new vr([],[]);vr.removeOverlap=YO;const da=vr.empty;class Vu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Uh));return Vu.from(r)}forChild(e,n){if(n.isLeaf)return vr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=da&&(a instanceof Vu?r=r.concat(a.members):r.push(a))}return Vu.from(r)}eq(e){if(!(e instanceof Vu)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let s=0;s<a.length;s++)n.push(a[s])}}return n?YO(r?n:n.sort(zh)):$m}static from(e){switch(e.length){case 0:return da;case 1:return e[0];default:return new Vu(e.every(n=>n instanceof vr)?e:e.reduce((n,r)=>n.concat(r instanceof vr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function bBe(t,e,n,r,i,a,s){let o=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,p,x,v)=>{let y=v-x-(p-g);for(let b=0;b<o.length;b+=3){let E=o[b+1];if(E<0||g>E+d-f)continue;let w=o[b]+d-f;p>=w?o[b+1]=g<=w?-2:-1:g>=d&&y&&(o[b]+=y,o[b+1]+=y)}f+=y}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){c=!0,o[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let g=n.map(t[u+1]+a,-1),p=g-i,{index:x,offset:v}=r.content.findIndex(f),y=r.maybeChild(x);if(y&&v==f&&v+y.nodeSize==p){let b=o[u+2].mapInner(n,y,d+1,t[u]+a+1,s);b!=da?(o[u]=f,o[u+1]=p,o[u+2]=b):(o[u+1]=-2,c=!0)}else c=!0}if(c){let u=yBe(o,t,e,n,i,a,s),d=tS(u,r,0,s);e=d.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let p=d.children[f];for(;g<o.length&&o[g]<p;)g+=3;o.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new vr(e.sort(zh),o)}function jJ(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 Ta(i.from+e,i.to+e,i.type))}return n}function yBe(t,e,n,r,i,a,s){function o(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):s.onRemove&&s.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)o(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&o(t[c+2],e[c]+a+1);return n}function DJ(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,s;a<t.length;a++)(s=t[a])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[a]=null);return i}function OJ(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function tS(t,e,n,r){let i=[],a=!1;e.forEach((o,c)=>{let u=DJ(t,o,c+n);if(u){a=!0;let d=tS(u,o,n+c+1,r);d!=da&&i.push(c,c+o.nodeSize,d)}});let s=jJ(a?OJ(t):t,-n).sort(zh);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||(r.onRemove&&r.onRemove(s[o].spec),s.splice(o--,1));return s.length||i.length?new vr(s,i):da}function zh(t,e){return t.from-e.from||t.to-e.to}function YO(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),N7(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),N7(e,i,r.copy(a.from,r.to)));break}}}return e}function N7(t,e,n){for(;e<t.length&&zh(n,t[e])>0;)e++;t.splice(e,0,n)}function XN(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=da&&e.push(r)}),t.cursorWrapper&&e.push(vr.create(t.state.doc,[t.cursorWrapper.deco])),Vu.from(e)}const vBe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},_Be=es&&sd<=11;class wBe{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 SBe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new wBe,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]);es&&sd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),_Be&&(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,vBe)),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(_7(this.view)){if(this.suppressingSelectionUpdates)return Nc(this.view);if(es&&sd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&df(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=Bp(a))n.add(a);for(let a=e.anchorNode;a;a=Bp(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&_7(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,o=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(o=!0))}if(oo&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let p=g.parentNode;p&&p.nodeName=="LI"&&(!f||ABe(e,f)!=p)&&g.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&nE(r)&&(u=$O(e))&&u.eq(un.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Nc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),MBe(e)),this.handleDOMChange(a,s,o,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Nc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(es&&sd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:g}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(a=g)}let s=i&&i.parentNode==e.target?ea(i)+1:0,o=r.localPosFromDOM(e.target,s,-1),c=a&&a.parentNode==e.target?ea(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:o,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let k7=new WeakMap,P7=!1;function MBe(t){if(!k7.has(t)&&(k7.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=oo,P7)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."),P7=!0}}function R7(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return df(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function EBe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return R7(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?R7(t,n):null}function ABe(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 TBe(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:o}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],nE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),fa&&t.input.lastKeyCode===8)for(let y=a;y>i;y--){let b=r.childNodes[y-1],E=b.pmViewDesc;if(b.nodeName=="BR"&&!E){a=y;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||i0.fromSchema(t.state.schema),p=f.resolve(s),x=null,v=g.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:CBe,context:p});if(u&&u[0].pos!=null){let y=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=y),x={anchor:y+s,head:b+s}}return{doc:v,sel:x,from:s,to:o}}function CBe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ra&&/^(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||Ra&&/^(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 NBe=/^(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 kBe(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,F=$O(t,k);if(F&&!t.state.selection.eq(F)){if(fa&&vc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",j=>j(t,bh(13,"Enter"))))return;let N=t.state.tr.setSelection(F);k=="pointer"?N.setMeta("pointer",!0):k=="key"&&N.scrollIntoView(),a&&N.setMeta("composition",a),t.dispatch(N)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let c=t.state.selection,u=TBe(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),g,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,p="end"):(g=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=jBe(f.content,u.doc.content,u.from,g,p);if(x&&t.input.domChangeCount++,(Hp&&t.input.lastIOSEnter>Date.now()-225||vc)&&i.some(k=>k.nodeType==1&&!NBe.test(k.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",k=>k(t,bh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof Kt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let k=j7(t,t.state.doc,u.sel);if(k&&!k.eq(t.state.selection)){let F=t.state.tr.setSelection(k);a&&F.setMeta("composition",a),t.dispatch(F)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof Kt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),es&&sd<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)=="  "&&(x.start--,x.endA--,x.endB--);let v=u.doc.resolveNoCache(x.start-u.from),y=u.doc.resolveNoCache(x.endB-u.from),b=d.resolve(x.start),E=v.sameParent(y)&&v.parent.inlineContent&&b.end()>=x.endA;if((Hp&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!E&&v.pos<u.doc.content.size&&(!v.sameParent(y)||!v.parent.inlineContent)&&v.pos<y.pos&&!/\S/.test(u.doc.textBetween(v.pos,y.pos,"","")))&&t.someProp("handleKeyDown",k=>k(t,bh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&RBe(d,x.start,x.endA,v,y)&&t.someProp("handleKeyDown",k=>k(t,bh(8,"Backspace")))){vc&&fa&&t.domObserver.suppressSelectionUpdates();return}fa&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),vc&&!E&&v.start()!=y.start()&&y.parentOffset==0&&v.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,y=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,bh(13,"Enter"))})},20));let w=x.start,A=x.endA,T=k=>{let F=k||t.state.tr.replace(w,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let N=j7(t,F.doc,u.sel);N&&!(fa&&t.composing&&N.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==w||N.head==F.mapping.map(A)-1)||es&&N.empty&&N.head==w)&&F.setSelection(N)}return a&&F.setMeta("composition",a),F.scrollIntoView()},C;if(E)if(v.pos==y.pos){es&&sd<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Nc(t),20));let k=T(t.state.tr.delete(w,A)),F=d.resolve(x.start).marksAcross(d.resolve(x.endA));F&&k.ensureMarks(F),t.dispatch(k)}else if(x.endA==x.endB&&(C=PBe(v.parent.content.cut(v.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,x.endA-b.start())))){let k=T(t.state.tr);C.type=="add"?k.addMark(w,A,C.mark):k.removeMark(w,A,C.mark),t.dispatch(k)}else if(v.parent.child(v.index()).isText&&v.index()==y.index()-(y.textOffset?0:1)){let k=v.parent.textBetween(v.parentOffset,y.parentOffset),F=()=>T(t.state.tr.insertText(k,w,A));t.someProp("handleTextInput",N=>N(t,w,A,k,F))||t.dispatch(F())}else t.dispatch(T());else t.dispatch(T())}function j7(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:VO(t,e.resolve(n.anchor),e.resolve(n.head))}function PBe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,o,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)o=i[0],s="add",c=d=>d.mark(o.addToSet(d.marks));else if(i.length==0&&a.length==1)o=a[0],s="remove",c=d=>d.mark(o.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(mt.from(u).eq(t))return{mark:o,type:s}}function RBe(t,e,n,r,i){if(n-e<=i.pos-r.pos||YN(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(YN(a,!0,!0));return!s.parent.isTextblock||s.pos>n||YN(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function YN(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function jBe(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(s,o));r-=s+c-a}if(s<a&&t.size<e.size){let c=r<=a&&r>=s?a-r:0;a-=c,a&&a<e.size&&D7(e.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-s),s=a}else if(o<a){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<t.size&&D7(t.textBetween(a-1,a+1))&&(a+=c?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function D7(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 LJ{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 Q8e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(U7),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=I7(this),L7(this),this.nodeViews=F7(this),this.docView=p7(this.state.doc,O7(this),XN(this),this.dom,this),this.domObserver=new SBe(this,(r,i,a,s)=>kBe(this,r,i,a,s)),this.domObserver.start(),J8e(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&&lR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(U7),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,s=!1;e.storedMarks&&this.composing&&(NJ(this),s=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=F7(this);OBe(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&lR(this),this.editable=I7(this),L7(this);let c=XN(this),u=O7(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(s=!0);let g=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&f8e(this);if(s){this.domObserver.stop();let p=f&&(es||fa)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&DBe(i.selection,e.selection);if(f){let x=fa?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hBe(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=p7(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&I8e(this))?Nc(this,p):(xJ(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&&m8e(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&&c7(this,n.getBoundingClientRect(),e)}else c7(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new PJ(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 s=0;s<this.directPlugins.length;s++){let o=this.directPlugins[s].props[e];if(o!=null&&(i=n?n(o):o))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let o=a[s].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(es){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&&p8e(this.dom),Nc(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return v8e(this,e)}coordsAtPos(e,n=1){return cJ(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 E8e(this,n||this.state,e)}pasteHTML(e,n){return ab(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ab(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return GO(this,e)}destroy(){this.docView&&(eBe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],XN(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,n8e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return nBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ra&&this.root.nodeType===11&&o8e(this.dom.ownerDocument)==this.dom&&EBe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}LJ.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function O7(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"),[Ta.node(0,t.state.doc.content.size,e)]}function L7(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:Ta.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function I7(t){return!t.someProp("editable",e=>e(t.state)===!1)}function DBe(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 F7(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 OBe(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 U7(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 wd={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:"'"},nS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},LBe=typeof navigator<"u"&&/Mac/.test(navigator.platform),IBe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ta=0;ta<10;ta++)wd[48+ta]=wd[96+ta]=String(ta);for(var ta=1;ta<=24;ta++)wd[ta+111]="F"+ta;for(var ta=65;ta<=90;ta++)wd[ta]=String.fromCharCode(ta+32),nS[ta]=String.fromCharCode(ta);for(var ZN in wd)nS.hasOwnProperty(ZN)||(nS[ZN]=wd[ZN]);function FBe(t){var e=LBe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||IBe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?nS:wd)[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 UBe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),zBe=typeof navigator<"u"&&/Win/.test(navigator.platform);function BBe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o++){let c=e[o];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))UBe?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function HBe(t){let e=Object.create(null);for(let n in t)e[BBe(n)]=t[n];return e}function QN(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 $Be(t){return new Tr({props:{handleKeyDown:IJ(t)}})}function IJ(t){let e=HBe(t);return function(n,r){let i=FBe(r),a,s=e[QN(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[QN(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(zBe&&r.ctrlKey&&r.altKey)&&(a=wd[r.keyCode])&&a!=i){let o=e[QN(a,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var VBe=Object.defineProperty,ZO=(t,e)=>{for(var n in e)VBe(t,n,{get:e[n],enumerable:!0})};function aE(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var sE=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([s,o])=>[s,(...u)=>{const d=o(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s=[],o=!!t,c=t||i.tr,u=()=>(!o&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),s.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const v=this.buildProps(c,e),y=g(...x)(v);return s.push(y),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,c])=>[o,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s={tr:t,editor:r,view:a,state:aE({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,c])=>[o,(...u)=>c(...u)(s)]))}};return s}},FJ={};ZO(FJ,{blur:()=>GBe,clearContent:()=>WBe,clearNodes:()=>qBe,command:()=>KBe,createParagraphNear:()=>XBe,cut:()=>YBe,deleteCurrentNode:()=>ZBe,deleteNode:()=>QBe,deleteRange:()=>JBe,deleteSelection:()=>e6e,enter:()=>t6e,exitCode:()=>n6e,extendMarkRange:()=>r6e,first:()=>i6e,focus:()=>s6e,forEach:()=>o6e,insertContent:()=>l6e,insertContentAt:()=>d6e,joinBackward:()=>m6e,joinDown:()=>f6e,joinForward:()=>p6e,joinItemBackward:()=>g6e,joinItemForward:()=>x6e,joinTextblockBackward:()=>b6e,joinTextblockForward:()=>y6e,joinUp:()=>h6e,keyboardShortcut:()=>_6e,lift:()=>w6e,liftEmptyBlock:()=>S6e,liftListItem:()=>M6e,newlineInCode:()=>E6e,resetAttributes:()=>A6e,scrollIntoView:()=>T6e,selectAll:()=>C6e,selectNodeBackward:()=>N6e,selectNodeForward:()=>k6e,selectParentNode:()=>P6e,selectTextblockEnd:()=>R6e,selectTextblockStart:()=>j6e,setContent:()=>D6e,setMark:()=>Q6e,setMeta:()=>J6e,setNode:()=>eHe,setNodeSelection:()=>tHe,setTextDirection:()=>nHe,setTextSelection:()=>rHe,sinkListItem:()=>iHe,splitBlock:()=>aHe,splitListItem:()=>sHe,toggleList:()=>oHe,toggleMark:()=>lHe,toggleNode:()=>cHe,toggleWrap:()=>uHe,undoInputRule:()=>dHe,unsetAllMarks:()=>hHe,unsetMark:()=>fHe,unsetTextDirection:()=>mHe,updateAttributes:()=>pHe,wrapIn:()=>gHe,wrapInList:()=>xHe});var GBe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),WBe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),qBe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(o,c)=>{if(o.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+o.nodeSize)),p=f.blockRange(g);if(!p)return;const x=pg(p);if(o.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(x||x===0)&&e.lift(p,x)})}),!0},KBe=t=>e=>t(e),XBe=()=>({state:t,dispatch:e})=>JQ(t,e),YBe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,a.content),r.setSelection(new Kt(r.doc.resolve(Math.max(s-1,0)))),!0},ZBe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const o=i.before(a),c=i.after(a);t.delete(o,c).scrollIntoView()}return!0}return!1};function ai(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 QBe=t=>({tr:e,state:n,dispatch:r})=>{const i=ai(t,n.schema),a=e.selection.$anchor;for(let s=a.depth;s>0;s-=1)if(a.node(s).type===i){if(r){const c=a.before(s),u=a.after(s);e.delete(c,u).scrollIntoView()}return!0}return!1},JBe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},e6e=()=>({state:t,dispatch:e})=>IO(t,e),t6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),n6e=()=>({state:t,dispatch:e})=>Bze(t,e);function QO(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function rS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:QO(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function UJ(t,e,n={}){return t.find(r=>r.type===e&&rS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function z7(t,e,n={}){return!!UJ(t,e,n)}function JO(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),!UJ([...i.node.marks],e,n)))return;let s=i.index,o=t.start()+i.offset,c=s+1,u=o+i.node.nodeSize;for(;s>0&&z7([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;c<t.parent.childCount&&z7([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:o,to:u}}function Kc(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 r6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Kc(t,r.schema),{doc:s,selection:o}=n,{$from:c,from:u,to:d}=o;if(i){const f=JO(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=Kt.create(s,f.from,f.to);n.setSelection(g)}}return!0},i6e=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 zJ(t){return t instanceof Kt}function Ah(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function BJ(t,e=null){if(!e)return null;const n=un.atStart(t),r=un.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Kt.create(t,Ah(0,i,a),Ah(t.content.size,i,a)):Kt.create(t,Ah(e,i,a),Ah(e,i,a))}function a6e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function eL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var s6e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(eL()||a6e())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!zJ(n.state.selection))return s(),!0;const o=BJ(i.doc,t)||n.state.selection,c=n.state.selection.eq(o);return a&&(c||i.setSelection(o),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},o6e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),l6e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),HJ=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&&HJ(r)}return t};function z_(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 HJ(n)}function ob(t,e,n){if(t instanceof ad||t instanceof mt)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 mt.fromArray(t.map(o=>e.nodeFromJSON(o)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),ob("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,o="";const c=new AQ({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(s=!0,o=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?i0.fromSchema(c).parseSlice(z_(t),n.parseOptions):i0.fromSchema(c).parse(z_(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=i0.fromSchema(e);return n.slice?a.parseSlice(z_(t),n.parseOptions).content:a.parse(z_(t),n.parseOptions)}return ob("",e,n)}function c6e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Oi||i instanceof Ii))return;const a=t.mapping.maps[r];let s=0;a.forEach((o,c,u,d)=>{s===0&&(s=d)}),t.setSelection(un.near(t.doc.resolve(s),n))}var u6e=t=>!("type"in t),d6e=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var s;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const c=y=>{a.emit("contentError",{editor:a,error:y,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{ob(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{o=ob(e,a.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,p=!0;if((u6e(o)?o:[o]).forEach(y=>{y.check(),g=g?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),d===f&&p){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let v;if(g){if(Array.isArray(e))v=e.map(y=>y.text||"").join("");else if(e instanceof mt){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),v=y}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=o;const y=r.doc.resolve(d),b=y.node(),E=y.parentOffset===0,w=b.isText||b.isTextblock,A=b.content.size>0;E&&w&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&c6e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},h6e=()=>({state:t,dispatch:e})=>Fze(t,e),f6e=()=>({state:t,dispatch:e})=>Uze(t,e),m6e=()=>({state:t,dispatch:e})=>WQ(t,e),p6e=()=>({state:t,dispatch:e})=>YQ(t,e),g6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=JM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},x6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=JM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},b6e=()=>({state:t,dispatch:e})=>Lze(t,e),y6e=()=>({state:t,dispatch:e})=>Ize(t,e);function $J(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function v6e(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let o=0;o<e.length-1;o+=1){const c=e[o];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))eL()||$J()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var _6e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=v6e(t).split(/-(?!$)/),s=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),o=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,o))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Sd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?ai(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const p=Math.max(r,g),x=Math.min(i,g+f.nodeSize);o.push({node:f,from:p,to:x})});const c=i-r,u=o.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>rS(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var w6e=(t,e={})=>({state:n,dispatch:r})=>{const i=ai(t,n.schema);return Sd(n,i,e)?zze(n,r):!1},S6e=()=>({state:t,dispatch:e})=>eJ(t,e),M6e=t=>({state:e,dispatch:n})=>{const r=ai(t,e.schema);return Qze(r)(e,n)},E6e=()=>({state:t,dispatch:e})=>QQ(t,e);function oE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function B7(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 A6e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=oE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=ai(t,r.schema)),o==="mark"&&(s=Kc(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,B7(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(g=>{s===g.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,s.create(B7(g.attrs,e))))})})}),c},T6e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),C6e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ts(t.doc);t.setSelection(n)}return!0},N6e=()=>({state:t,dispatch:e})=>KQ(t,e),k6e=()=>({state:t,dispatch:e})=>ZQ(t,e),P6e=()=>({state:t,dispatch:e})=>Vze(t,e),R6e=()=>({state:t,dispatch:e})=>qze(t,e),j6e=()=>({state:t,dispatch:e})=>Wze(t,e);function cR(t,e,n={},r={}){return ob(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var D6e=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:o})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=cR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return s&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function VJ(t,e){const n=Kc(e,t.schema),{from:r,to:i,empty:a}=t.selection,s=[];a?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{s.push(...c.marks)});const o=s.find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function GJ(t,e){const n=new HQ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function O6e(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 L6e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function I6e(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 lE(t){return e=>I6e(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 tL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Bt(e,"addExtensions",n);return r?[e,...tL(r())]:e}).flat(10)}function nL(t,e){const n=yf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function WJ(t){return typeof t=="function"}function zn(t,e=void 0,...n){return WJ(t)?e?t.bind(e)(...n):t(...n):t}function F6e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function $p(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 qJ(t){const e=[],{nodeExtensions:n,markExtensions:r}=$p(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage,extensions:i},c=Bt(s,"addGlobalAttributes",o);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,p])=>{e.push({type:f,name:g,attribute:{...a,...p}})})})})}),i.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},c=Bt(s,"addAttributes",o);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const g={...a,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:s.name,name:d,attribute:g})})}),e}function Or(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const o=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=o.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const o=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),o.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function iS(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)=>Or(n,r),{})}function U6e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function H7(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,s)=>{const o=s.attribute.parseHTML?s.attribute.parseHTML(n):U6e(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...r,...i}}}}function $7(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&F6e(n)?!1:n!=null))}function V7(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 z6e(t,e){var n;const r=qJ(t),{nodeExtensions:i,markExtensions:a}=$p(t),s=(n=i.find(u=>Bt(u,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,E)=>{const w=Bt(E,"extendNodeSchema",f);return{...b,...w?w(u):{}}},{}),p=$7({...g,content:zn(Bt(u,"content",f)),marks:zn(Bt(u,"marks",f)),group:zn(Bt(u,"group",f)),inline:zn(Bt(u,"inline",f)),atom:zn(Bt(u,"atom",f)),selectable:zn(Bt(u,"selectable",f)),draggable:zn(Bt(u,"draggable",f)),code:zn(Bt(u,"code",f)),whitespace:zn(Bt(u,"whitespace",f)),linebreakReplacement:zn(Bt(u,"linebreakReplacement",f)),defining:zn(Bt(u,"defining",f)),isolating:zn(Bt(u,"isolating",f)),attrs:Object.fromEntries(d.map(V7))}),x=zn(Bt(u,"parseHTML",f));x&&(p.parseDOM=x.map(b=>H7(b,d)));const v=Bt(u,"renderHTML",f);v&&(p.toDOM=b=>v({node:b,HTMLAttributes:iS(b,d)}));const y=Bt(u,"renderText",f);return y&&(p.toText=y),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((y,b)=>{const E=Bt(b,"extendMarkSchema",f);return{...y,...E?E(u):{}}},{}),p=$7({...g,inclusive:zn(Bt(u,"inclusive",f)),excludes:zn(Bt(u,"excludes",f)),group:zn(Bt(u,"group",f)),spanning:zn(Bt(u,"spanning",f)),code:zn(Bt(u,"code",f)),attrs:Object.fromEntries(d.map(V7))}),x=zn(Bt(u,"parseHTML",f));x&&(p.parseDOM=x.map(y=>H7(y,d)));const v=Bt(u,"renderHTML",f);return v&&(p.toDOM=y=>v({mark:y,HTMLAttributes:iS(y,d)})),[u.name,p]}));return new AQ({topNode:s,nodes:o,marks:c})}function B6e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function rL(t){return t.sort((n,r)=>{const i=Bt(n,"priority")||100,a=Bt(r,"priority")||100;return i>a?-1:i<a?1:0})}function KJ(t){const e=rL(tL(t)),n=B6e(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 XJ(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8106. `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(r,i,(c,u,d,f)=>{var g;c.isBlock&&u>r&&(o+=a);const p=s?.[c.type.name];if(p)return d&&(o+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(o+=(g=c?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),o}function H6e(t,e){const n={from:0,to:t.content.size};return XJ(t,n,e)}function YJ(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function $6e(t,e){const n=ai(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function ZJ(t,e){const n=oE(typeof e=="string"?e:e.name,t.schema);return n==="node"?$6e(t,e):n==="mark"?VJ(t,e):{}}function V6e(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 G6e(t){const e=V6e(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,s)=>s!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function QJ(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((o,c)=>{s.push({from:o,to:c})});else{const{from:o,to:c}=n[a];if(o===void 0||c===void 0)return;s.push({from:o,to:c})}s.forEach(({from:o,to:c})=>{const u=e.slice(a).map(o,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),G6e(r)}function iL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=JO(a,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:a,to:a+i.nodeSize,mark:s})))}),r}var W6e=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const o=i.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function JN(t,e){return e.nodes[t]||e.marks[t]||null}function v1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var q6e=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,o)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:s,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function uR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Kc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>rS(f.attrs,n,{strict:!1}));let s=0;const o=[];if(i.forEach(({$from:f,$to:g})=>{const p=f.pos,x=g.pos;t.doc.nodesBetween(p,x,(v,y)=>{if(!v.isText&&!v.marks.length)return;const b=Math.max(p,y),E=Math.min(x,y+v.nodeSize),w=E-b;s+=w,o.push(...v.marks.map(A=>({mark:A,from:b,to:E})))})}),s===0)return!1;const c=o.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>rS(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=o.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=s}function K6e(t,e,n={}){if(!e)return Sd(t,null,n)||uR(t,null,n);const r=oE(e,t.schema);return r==="node"?Sd(t,e,n):r==="mark"?uR(t,e,n):!1}var X6e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=lE(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Y6e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function G7(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function W7(t,e){const{nodeExtensions:n}=$p(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=zn(Bt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function cE(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(cE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function JJ(t){return t instanceof Ht}function Z6e(t,e,n){var r;const{selection:i}=e;let a=null;if(zJ(i)&&(a=i.$cursor),a){const o=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(u=>u.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:o,$to:c})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const p=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=p&&x}return!u}),u})}var Q6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:o}=a,c=Kc(t,r.schema);if(i)if(s){const u=VJ(r,c);n.addStoredMark(c.create({...u,...e}))}else o.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,p)=>{const x=Math.max(p,d),v=Math.min(p+g.nodeSize,f);g.marks.find(b=>b.type===c)?g.marks.forEach(b=>{c===b.type&&n.addMark(x,v,c.create({...b.attrs,...e}))}):n.addMark(x,v,c.create(e))})});return Z6e(r,n,c)},J6e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),eHe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=ai(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:o})=>s7(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>s7(a,{...s,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},tHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Ah(t,0,r.content.size),a=Ht.create(r,i);e.setSelection(a)}return!0},nHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),i&&n.doc.nodesBetween(s,o,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},rHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Kt.atStart(r).from,o=Kt.atEnd(r).to,c=Ah(i,s,o),u=Ah(a,s,o),d=Kt.create(r,c,u);e.setSelection(d)}return!0},iHe=t=>({state:e,dispatch:n})=>{const r=ai(t,e.schema);return t8e(r)(e,n)};function q7(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 aHe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:o,$to:c}=a,u=i.extensionManager.attributes,d=v1(u,o.node().type.name,o.node().attrs);if(a instanceof Ht&&a.node.isBlock)return!o.parentOffset||!Cc(s,o.pos)?!1:(r&&(t&&q7(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=o.depth===0?void 0:O6e(o.node(-1).contentMatchAt(o.indexAfter(-1)));let p=f&&g?[{type:g,attrs:d}]:void 0,x=Cc(e.doc,e.mapping.map(o.pos),1,p);if(!p&&!x&&Cc(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(x=!0,p=g?[{type:g,attrs:d}]:void 0),r){if(x&&(a instanceof Kt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,p),g&&!f&&!o.parentOffset&&o.parent.type!==g)){const v=e.mapping.map(o.before()),y=e.doc.resolve(v);o.node(-1).canReplaceWith(y.index(),y.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&q7(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},sHe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const o=ai(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==o)return!1;const g=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let b=mt.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let F=c.depth-E;F>=c.depth-3;F-=1)b=mt.from(c.node(F).copy(b));const w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...v1(g,c.node().type.name,c.node().attrs),...e},T=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(A))||void 0;b=b.append(mt.from(o.createAndFill(null,T)||void 0));const C=c.before(c.depth-(E-1));n.replace(C,c.after(-w),new Pt(b,4-E,0));let k=-1;n.doc.nodesBetween(C,n.doc.content.size,(F,N)=>{if(k>-1)return!1;F.isTextblock&&F.content.size===0&&(k=N+1)}),k>-1&&n.setSelection(Kt.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...v1(g,f.type.name,f.attrs),...e},v={...v1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const y=p?[{type:o,attrs:x},{type:p,attrs:v}]:[{type:o,attrs:x}];if(!Cc(n.doc,c.pos,2))return!1;if(i){const{selection:b,storedMarks:E}=r,{splittableMarks:w}=a.extensionManager,A=E||b.$to.parentOffset&&b.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!A||!i)return!0;const T=A.filter(C=>w.includes(C.type.name));n.ensureMarks(T)}return!0},ek=(t,e)=>{const n=lE(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&kd(t.doc,n.pos)&&t.join(n.pos),!0},tk=(t,e)=>{const n=lE(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&kd(t.doc,r)&&t.join(r),!0},oHe=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:o,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,p=ai(t,s.schema),x=ai(e,s.schema),{selection:v,storedMarks:y}=s,{$from:b,$to:E}=v,w=b.blockRange(E),A=y||v.$to.parentOffset&&v.$from.marks();if(!w)return!1;const T=lE(C=>W7(C.type.name,f))(v);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===p)return u.liftListItem(x);if(W7(T.node.type.name,f)&&p.validContent(T.node.content)&&o)return c().command(()=>(a.setNodeMarkup(T.pos,p),!0)).command(()=>ek(a,p)).command(()=>tk(a,p)).run()}return!n||!A||!o?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>ek(a,p)).command(()=>tk(a,p)).run():c().command(()=>{const C=d().wrapInList(p,r),k=A.filter(F=>g.includes(F.type.name));return a.ensureMarks(k),C?!0:u.clearNodes()}).wrapInList(p,r).command(()=>ek(a,p)).command(()=>tk(a,p)).run()},lHe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=Kc(t,r.schema);return uR(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},cHe=(t,e,n={})=>({state:r,commands:i})=>{const a=ai(t,r.schema),s=ai(e,r.schema),o=Sd(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),o?i.setNode(s,c):i.setNode(a,{...c,...n})},uHe=(t,e={})=>({state:n,commands:r})=>{const i=ai(t,n.schema);return Sd(n,i,e)?r.lift(i):r.wrapIn(i,e)},dHe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const s=t.tr,o=a.transform;for(let c=o.steps.length-1;c>=0;c-=1)s.step(o.steps[c].invert(o.docs[c]));if(a.text){const c=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else s.delete(a.from,a.to)}return!0}}return!1},hHe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},fHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,c=Kc(t,r.schema),{$from:u,empty:d,ranges:f}=o;if(!i)return!0;if(d&&s){let{from:g,to:p}=o;const x=(a=u.marks().find(y=>y.type===c))==null?void 0:a.attrs,v=JO(u,c,x);v&&(g=v.from,p=v.to),n.removeMark(g,p,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},mHe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(o,c)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},pHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const o=oE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(a=ai(t,r.schema)),o==="mark"&&(s=Kc(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,p,x,v;n.selection.empty?r.doc.nodesBetween(d,f,(y,b)=>{a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,p=y)}):r.doc.nodesBetween(d,f,(y,b)=>{b<d&&a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,p=y),b>=d&&b<=f&&(a&&a===y.type&&(c=!0,i&&n.setNodeMarkup(b,void 0,{...y.attrs,...e})),s&&y.marks.length&&y.marks.forEach(E=>{if(s===E.type&&(c=!0,i)){const w=Math.max(b,d),A=Math.min(b+y.nodeSize,f);n.addMark(w,A,s.create({...E.attrs,...e}))}}))}),p&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...p.attrs,...e}),s&&p.marks.length&&p.marks.forEach(y=>{s===y.type&&i&&n.addMark(x,v,s.create({...y.attrs,...e}))}))}),c},gHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ai(t,n.schema);return Kze(i,e)(n,r)},xHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ai(t,n.schema);return Xze(i,e)(n,r)},bHe=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},uE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},yHe=(t,e)=>{if(QO(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 B_(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:o}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=q6e(u)+a;return s.forEach(g=>{if(d)return;const p=yHe(f,g.find);if(!p)return;const x=c.state.tr,v=aE({state:c.state,transaction:x}),y={from:r-(p[0].length-a.length),to:i},{commands:b,chain:E,can:w}=new sE({editor:n,state:v});g.handler({state:v,range:y,match:p,commands:b,chain:E,can:w})===null||!x.steps.length||(g.undoable&&x.setMeta(o,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function vHe(t){const{editor:e,rules:n}=t,r=new Tr({state:{init(){return null},apply(i,a,s){const o=i.getMeta(r);if(o)return o;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=nL(mt.from(d),s.schema);const{from:f}=c,g=f+d.length;B_({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,o){return B_({editor:e,from:a,to:s,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&B_({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?B_({editor:e,from:s.pos,to:s.pos,text:`
  8107. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function _He(t){return Object.prototype.toString.call(t).slice(8,-1)}function H_(t){return _He(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function eee(t,e){const n={...t};return H_(t)&&H_(e)&&Object.keys(e).forEach(r=>{H_(e[r])&&H_(t[r])?n[r]=eee(t[r],e[r]):n[r]=e[r]}),n}var aL=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{...zn(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...zn(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>eee(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}},Rd=class tee extends aL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new tee(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(u=>u?.type.name===n.name))return!1;const c=s.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function wHe(t){return typeof t=="number"}var SHe=class{constructor(t){this.find=t.find,this.handler=t.handler}},MHe=(t,e,n)=>{if(QO(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function EHe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:c,chain:u,can:d}=new sE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var v,y,b,E,w;if((y=(v=p.type)==null?void 0:v.spec)!=null&&y.code||!(p.isText||p.isTextblock||p.isInline))return;const A=(w=(E=(b=p.content)==null?void 0:b.size)!=null?E:p.nodeSize)!=null?w:0,T=Math.max(r,x),C=Math.min(i,x+A);if(T>=C)return;const k=p.isText?p.text||"":p.textBetween(T-x,C-x,void 0,"");MHe(k,a.find,s).forEach(N=>{if(N.index===void 0)return;const j=T+N.index+1,I=j+N[0].length,O={from:n.tr.mapping.map(j),to:n.tr.mapping.map(I)},q=a.handler({state:n,range:O,match:N,commands:c,chain:u,can:d,pasteEvent:s,dropEvent:o});f.push(q)})}),f.every(p=>p!==null)}var $_=null,AHe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function THe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const c=({state:d,from:f,to:g,rule:p,pasteEvt:x})=>{const v=d.tr,y=aE({state:d,transaction:v});if(!(!EHe({editor:e,state:y,from:Math.max(f-1,0),to:g.b-1,rule:p,pasteEvent:x,dropEvent:o})||!v.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Tr({view(f){const g=x=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(x.target)?f.dom.parentElement:null,r&&($_=e)},p=()=>{$_&&($_=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(a=r===f.dom.parentElement,o=g,!a){const p=$_;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var p;const x=(p=g.clipboardData)==null?void 0:p.getData("text/html");return s=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,p)=>{const x=f[0],v=x.getMeta("uiEvent")==="paste"&&!i,y=x.getMeta("uiEvent")==="drop"&&!a,b=x.getMeta("applyPasteRules"),E=!!b;if(!v&&!y&&!E)return;if(E){let{text:T}=b;typeof T=="string"?T=T:T=nL(mt.from(T),p.schema);const{from:C}=b,k=C+T.length,F=AHe(T);return c({rule:d,state:p,from:C,to:{b:k},pasteEvt:F})}const w=g.doc.content.findDiffStart(p.doc.content),A=g.doc.content.findDiffEnd(p.doc.content);if(!(!wHe(w)||!A||w===A.b))return c({rule:d,state:p,from:w,to:A,pasteEvt:s})}}))}var dE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=KJ(t),this.schema=z6e(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:JN(e.name,this.schema)},r=Bt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return rL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:JN(r.name,this.schema)},a=[],s=Bt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Bt(r,"exitable",i)&&(o.ArrowRight=()=>Rd.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([p,x])=>[p,()=>x({editor:t})]));o={...o,...g}}const c=$Be(o);a.push(c);const u=Bt(r,"addInputRules",i);if(G7(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const p=vHe({editor:t,rules:g}),x=Array.isArray(p)?p:[p];a.push(...x)}}const d=Bt(r,"addPasteRules",i);if(G7(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const p=THe({editor:t,rules:g});a.push(...p)}}const f=Bt(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return qJ(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=$p(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ai(n.name,this.schema)},a=Bt(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const o=(c,u,d,f,g)=>{const p=iS(c,r);return s({node:c,view:u,getPos:d,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:p})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=$p(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:Kc(n.name,this.schema)},a=Bt(n,"addMarkView",i);if(!a)return[];const s=(o,c,u)=>{const d=iS(o,r);return a()({mark:o,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{HHe(o,t,f)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:JN(e.name,this.schema)};e.type==="mark"&&((n=zn(Bt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Bt(e,"onBeforeCreate",r),a=Bt(e,"onCreate",r),s=Bt(e,"onUpdate",r),o=Bt(e,"onSelectionUpdate",r),c=Bt(e,"onTransaction",r),u=Bt(e,"onFocus",r),d=Bt(e,"onBlur",r),f=Bt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};dE.resolve=KJ;dE.sort=rL;dE.flatten=tL;var CHe={};ZO(CHe,{ClipboardTextSerializer:()=>ree,Commands:()=>iee,Delete:()=>aee,Drop:()=>see,Editable:()=>oee,FocusEvents:()=>cee,Keymap:()=>uee,Paste:()=>dee,Tabindex:()=>hee,TextDirection:()=>fee,focusEventsPluginKey:()=>lee});var Jn=class nee extends aL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new nee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},ree=Jn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Tr({key:new Si("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,s=Math.min(...a.map(d=>d.$from.pos)),o=Math.max(...a.map(d=>d.$to.pos)),c=YJ(n);return XJ(r,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),iee=Jn.create({name:"commands",addCommands(){return{...FJ}}}),aee=Jn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,o,c,u;if((u=(c=(o=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:o.filterTransaction)==null?void 0:c.call(o,t))!=null?u:t.getMeta("y-sync$"))return;const d=GJ(t.before,[t,...e]);QJ(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,v)=>{const y=v+x.nodeSize-2,b=p.oldRange.from<=v&&y<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:v,to:y,newFrom:d.mapping.map(v),newTo:d.mapping.map(y),deletedRange:p.oldRange,newRange:p.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((p,x)=>{var v,y;if(p instanceof Oo){const b=g.slice(x).map(p.from,-1),E=g.slice(x).map(p.to),w=g.invert().map(b,-1),A=g.invert().map(E),T=(v=d.doc.nodeAt(b-1))==null?void 0:v.marks.some(k=>k.eq(p.mark)),C=(y=d.doc.nodeAt(E))==null?void 0:y.marks.some(k=>k.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:w,to:A},newRange:{from:b,to:E},partial:!!(C||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(a,0):a()}}),see=Jn.create({name:"drop",addProseMirrorPlugins(){return[new Tr({key:new Si("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),oee=Jn.create({name:"editable",addProseMirrorPlugins(){return[new Tr({key:new Si("editable"),props:{editable:()=>this.editor.options.editable}})]}}),lee=new Si("focusEvents"),cee=Jn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Tr({key:lee,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}}}})]}}),uee=Jn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:o})=>{const{selection:c,doc:u}=o,{empty:d,$anchor:f}=c,{pos:g,parent:p}=f,x=f.parent.isTextblock&&g>0?o.doc.resolve(g-1):f,v=x.parent.type.spec.isolating,y=f.pos-f.parentOffset,b=v&&x.parent.childCount===1?y===f.pos:un.atStart(u).from===g;return!d||!p.type.isTextblock||p.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return eL()||$J()?a:i},addProseMirrorPlugins(){return[new Tr({key:new Si("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:o}=e.selection,c=un.atStart(e.doc).from,u=un.atEnd(e.doc).to;if(a||!(s===c&&o===u)||!cE(n.doc))return;const g=n.tr,p=aE({state:n,transaction:g}),{commands:x}=new sE({editor:this.editor,state:p});if(x.clearNodes(),!!g.steps.length)return g}})]}}),dee=Jn.create({name:"paste",addProseMirrorPlugins(){return[new Tr({key:new Si("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),hee=Jn.create({name:"tabindex",addProseMirrorPlugins(){return[new Tr({key:new Si("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),fee=Jn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=$p(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 Tr({key:new Si("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),NHe=class Vm{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 Vm(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 Vm(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 Vm(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,s=this.pos+r+(a?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const c=new Vm(o,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Vm(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,s=Object.keys(n);for(let o=0;o<s.length;o+=1){const c=s[o];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&a.every(c=>n[c]===s.node.attrs[c])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},kHe=`.ProseMirror {
  8108. position: relative;
  8109. }
  8110. .ProseMirror {
  8111. word-wrap: break-word;
  8112. white-space: pre-wrap;
  8113. white-space: break-spaces;
  8114. -webkit-font-variant-ligatures: none;
  8115. font-variant-ligatures: none;
  8116. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8117. }
  8118. .ProseMirror [contenteditable="false"] {
  8119. white-space: normal;
  8120. }
  8121. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8122. white-space: pre-wrap;
  8123. }
  8124. .ProseMirror pre {
  8125. white-space: pre-wrap;
  8126. }
  8127. img.ProseMirror-separator {
  8128. display: inline !important;
  8129. border: none !important;
  8130. margin: 0 !important;
  8131. width: 0 !important;
  8132. height: 0 !important;
  8133. }
  8134. .ProseMirror-gapcursor {
  8135. display: none;
  8136. pointer-events: none;
  8137. position: absolute;
  8138. margin: 0;
  8139. }
  8140. .ProseMirror-gapcursor:after {
  8141. content: "";
  8142. display: block;
  8143. position: absolute;
  8144. top: -2px;
  8145. width: 20px;
  8146. border-top: 1px solid black;
  8147. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8148. }
  8149. @keyframes ProseMirror-cursor-blink {
  8150. to {
  8151. visibility: hidden;
  8152. }
  8153. }
  8154. .ProseMirror-hideselection *::selection {
  8155. background: transparent;
  8156. }
  8157. .ProseMirror-hideselection *::-moz-selection {
  8158. background: transparent;
  8159. }
  8160. .ProseMirror-hideselection * {
  8161. caret-color: transparent;
  8162. }
  8163. .ProseMirror-focused .ProseMirror-gapcursor {
  8164. display: block;
  8165. }`;function PHe(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 RHe=class extends bHe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=BJ(e,this.options.autofocus);this.editorState=Qm.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=PHe(kHe,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=WJ(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(s=>!s.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[oee,ree.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),iee,cee,uee,hee,see,dee,aee,fee.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 dE(r,this)}createCommandManager(){this.commandManager=new sE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=cR(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=cR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new LJ(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),o=s?.getMeta("focus"),c=s?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:s}),c&&this.emit("blur",{editor:this,event:c.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return ZJ(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return K6e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return nL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8166. `,textSerializers:n={}}=t||{};return H6e(this.state.doc,{blockSeparator:e,textSerializers:{...YJ(this.schema),...n}})}get isEmpty(){return cE(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 NHe(e,this)}get $doc(){return this.$pos(0)}};function Vp(t){return new uE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=zn(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,s=r[r.length-1],o=r[0];if(s){const c=o.search(/\S/),u=n.from+o.indexOf(s),d=u+s.length;if(iL(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const g=n.from+c+s.length;a.addMark(n.from+c,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function mee(t){return new uE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=zn(t.getAttributes,void 0,r)||{},{tr:a}=e,s=n.from;let o=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=s+u;d>o?d=o:o=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,s+r[0].length-1),a.replaceWith(d,o,c)}else if(r[0]){const u=t.type.isInline?s:s-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(s),a.mapping.map(o))}a.scrollIntoView()},undoable:t.undoable})}function dR(t){return new uE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=zn(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function Gp(t){return new uE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=zn(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),c=s.doc.resolve(n.from).blockRange(),u=c&&OO(c,t.type,a);if(!u)return null;if(s.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:p}=t.editor.extensionManager,x=g||f.$to.parentOffset&&f.$from.marks();if(x){const v=x.filter(y=>p.includes(y.type.name));s.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&kd(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)},undoable:t.undoable})}var jHe=t=>"touches"in t,DHe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.clientX-this.startX,c=s.clientY-this.startY;this.handleResize(o,c)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.touches[0];if(!o)return;const c=o.clientX-this.startX,u=o.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(s,o),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,jHe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),s=t.includes("left"),o=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:s&&(r=this.startWidth-e),o?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,s;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let o=t,c=e;return o<this.minSize.width&&(o=this.minSize.width,c=o/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,o=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&o>this.maxSize.width&&(o=this.maxSize.width,c=o/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&c>this.maxSize.height&&(c=this.maxSize.height,o=c*this.aspectRatio),{width:o,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function OHe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ht){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var LHe={};ZO(LHe,{createAtomBlockMarkdownSpec:()=>IHe,createBlockMarkdownSpec:()=>FHe,createInlineMarkdownSpec:()=>BHe,parseAttributes:()=>sL,parseIndentedBlocks:()=>hR,renderNestedMarkdownContent:()=>lL,serializeAttributes:()=>oL});function sL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,u,d])=>{var f;const g=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[g];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function oL(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 IHe(t){const{nodeName:e,name:n,parseAttributes:r=sL,serializeAttributes:i=oL,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:o}=t,c=n||e,u=d=>{if(!o)return d;const f={};return o.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...a,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(g))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,g){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const v=x[1]||"",y=r(v);if(!s.find(E=>!(E in y)))return{type:e,raw:x[0],attributes:y}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),p=g?` {${g}}`:"";return`:::${c}${p} :::`}}}function FHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=sL,serializeAttributes:a=oL,defaultAttributes:s={},content:o="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const g={};return c.forEach(p=>{p in f&&(g[p]=f[p])}),g};return{parseMarkdown:(f,g)=>{let p;if(r){const v=r(f);p=typeof v=="string"?[{type:"text",text:v}]:v}else o==="block"?p=g.parseChildren(f.tokens||[]):p=g.parseInline(f.tokens||[]);const x={...s,...f.attributes};return g.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var g;const p=new RegExp(`^:::${u}`,"m"),x=(g=f.match(p))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(f,g,p){var x;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(v);if(!y)return;const[b,E=""]=y,w=i(E);let A=1;const T=b.length;let C="";const k=/^:::([\w-]*)(\s.*)?/gm,F=f.slice(T);for(k.lastIndex=0;;){const N=k.exec(F);if(N===null)break;const j=N.index,I=N[1];if(!((x=N[2])!=null&&x.endsWith(":::"))){if(I)A+=1;else if(A-=1,A===0){const O=F.slice(0,j);C=O.trim();const q=f.slice(0,T+j+N[0].length);let R=[];if(C)if(o==="block")for(R=p.blockTokens(O),R.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});R.length>0;){const W=R[R.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))R.pop();else break}else R=p.inlineTokens(C);return{type:e,raw:q,attributes:w,content:C,tokens:R}}}}}},renderMarkdown:(f,g)=>{const p=d(f.attrs||{}),x=a(p),v=x?` {${x}}`:"",y=g.renderChildren(f.content||[],`
  8167. `);return`:::${u}${v}
  8168. ${y}
  8169. :::`}}}function UHe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,s]=r;e[i]=a||s,r=n.exec(t)}return e}function zHe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function BHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=UHe,serializeAttributes:a=zHe,defaultAttributes:s={},selfClosing:o=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const p={};return c.forEach(x=>{x in g&&(p[x]=g[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,p)=>{const x={...s,...g.attributes};if(o)return p.createNode(e,x);const v=r?r(g):g.content||"";return v?p.createNode(e,x,[p.createTextNode(v)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const p=o?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=g.match(p),v=x?.index;return v!==void 0?v:-1},tokenize(g,p,x){const v=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=g.match(v);if(!y)return;let b="",E="";if(o){const[,A]=y;E=A}else{const[,A,T]=y;E=A,b=T||""}const w=i(E.trim());return{type:e,raw:y[0],content:b.trim(),attributes:w}}},renderMarkdown:g=>{let p="";r?p=r(g):g.content&&g.content.length>0&&(p=g.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const x=d(g.attrs||{}),v=a(x),y=v?` ${v}`:"";return o?`[${u}${y}]`:`[${u}${y}]${p}[/${u}]`}}}function hR(t,e,n){var r,i,a,s;const o=t.split(`
  8170. `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<o.length;){const g=o[d],p=g.match(e.itemPattern);if(!p){if(c.length>0)break;if(g.trim()===""){d+=1,u=`${u}${g}
  8171. `;continue}else return}const x=e.extractItemData(p),{indentLevel:v,mainContent:y}=x;u=`${u}${g}
  8172. `;const b=[y];for(d+=1;d<o.length;){const T=o[d];if(T.trim()===""){const k=o.slice(d+1).findIndex(j=>j.trim()!=="");if(k===-1)break;if((((i=(r=o[d+1+k].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){b.push(T),u=`${u}${T}
  8173. `,d+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>v)b.push(T),u=`${u}${T}
  8174. `,d+=1;else break}let E;const w=b.slice(1);if(w.length>0){const T=w.map(C=>C.slice(v+f)).join(`
  8175. `);T.trim()&&(e.customNestedParser?E=e.customNestedParser(T):E=n.blockTokens(T))}const A=e.createToken(x,E);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function lL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,o=e.renderChildren([a]),c=[`${i}${o}`];return s&&s.length>0&&s.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
  8176. `).map(g=>g?e.indent(g):"").join(`
  8177. `);c.push(f)}}),c.join(`
  8178. `)}function HHe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((o,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+o.nodeSize;let f=null;if(o.marks.forEach(p=>{if(p!==s)return!1;f=p}),!f)return;let g=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(g=!0)}),g){const p=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,p)}}),a.docChanged&&e.view.dispatch(a)}var is=class pee extends aL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new pee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function ff(t){return new SHe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=zn(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,o=r[r.length-1],c=r[0];let u=n.to;if(o){const d=c.search(/\S/),f=n.from+c.indexOf(o),g=f+o.length;if(iL(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(y=>y===t.type&&y!==x.mark.type)).filter(x=>x.to>f).length)return null;g<n.to&&s.delete(g,n.to),f>n.from&&s.delete(n.from+d,f),u=n.from+d+o.length,s.addMark(n.from+d,u,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var nk,K7;function $He(){return K7||(K7=1,nk=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var s=a[i];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),nk}var VHe=$He();const GHe=mo(VHe);var WHe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},qHe=({contentComponent:t})=>{const e=jR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return l.jsx(l.Fragment,{children:Object.values(e)})};function KHe(){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]:mse.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 XHe=class extends gr.Component{constructor(t){var e;super(t),this.editorContentRef=gr.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=KHe(),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 l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:WHe(e,this.editorContentRef),...n}),t?.contentComponent&&l.jsx(qHe,{contentComponent:t.contentComponent})]})}},YHe=M.forwardRef((t,e)=>{const n=gr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return gr.createElement(XHe,{key:n,innerRef:e,...t})}),ZHe=gr.memo(YHe),QHe=typeof window<"u"?M.useLayoutEffect:M.useEffect,JHe=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 e$e(t){var e;const[n]=M.useState(()=>new JHe(t.editor)),r=fW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:GHe);return QHe(()=>n.watch(t.editor),[t.editor,n]),M.useDebugValue(r),r}var t$e=!1,fR=typeof window>"u",n$e=fR||!!(typeof window<"u"&&window.next),r$e=class gee{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?fR||n$e?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new RHe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var s;return i===((s=n.extensions)==null?void 0:s[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?gee.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 i$e(t={},e=[]){const n=M.useRef(t);n.current=t;const[r]=M.useState(()=>new r$e(n)),i=jR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(i),M.useEffect(r.onRender(e)),e$e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var a$e=M.createContext({editor:null});a$e.Consumer;var s$e=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),o$e=()=>M.useContext(s$e);gr.forwardRef((t,e)=>{const{onDragStart:n}=o$e(),r=t.as||"div";return l.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});gr.createContext({markViewContentRef:()=>{}});var aS=(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]},l$e=/^\s*>\s$/,c$e=is.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return aS("blockquote",{...Or(this.options.HTMLAttributes,t),children:aS("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(`
  8179. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(o.join(`
  8180. `))}),r.join(`
  8181. ${n}
  8182. `)},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[Gp({find:l$e,type:this.type})]}}),u$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,d$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,h$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,f$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,m$e=Rd.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 aS("strong",{...Or(this.options.HTMLAttributes,t),children:aS("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[Vp({find:u$e,type:this.type}),Vp({find:h$e,type:this.type})]},addPasteRules(){return[ff({find:d$e,type:this.type}),ff({find:f$e,type:this.type})]}}),p$e=/(^|[^`])`([^`]+)`(?!`)$/,g$e=/(^|[^`])`([^`]+)`(?!`)/g,x$e=Rd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Or(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[Vp({find:p$e,type:this.type})]},addPasteRules(){return[ff({find:g$e,type:this.type})]}}),rk=4,b$e=/^```([a-z]+)?[\s\n]$/,y$e=/^~~~([a-z]+)?[\s\n]$/,v$e=is.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:rk,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Or(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(`
  8183. `):r=`\`\`\`${i}
  8184. \`\`\``,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:rk,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;if(a.parent.type!==this.type)return!1;const o=" ".repeat(n);return s?t.commands.insertContent(o):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,p=r.doc.textBetween(u,d,`
  8185. `,`
  8186. `).split(`
  8187. `).map(x=>o+x).join(`
  8188. `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:rk,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:o})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),p=r.doc.textBetween(d,f,`
  8189. `,`
  8190. `).split(`
  8191. `);let x=0,v=0;const y=u-d;for(let C=0;C<p.length;C+=1){if(v+p[C].length>=y){x=C;break}v+=p[C].length+1}const E=((c=p[x].match(/^ */))==null?void 0:c[0])||"",w=Math.min(E.length,n);if(w===0)return!0;let A=d;for(let C=0;C<x;C+=1)A+=p[C].length+1;return o.delete(A,A+w),u-A<=w&&o.setSelection(Kt.create(o.doc,A)),!0}):t.commands.command(({tr:o})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,u,`
  8192. `,`
  8193. `).split(`
  8194. `).map(p=>{var x;const v=((x=p.match(/^ */))==null?void 0:x[0])||"",y=Math.min(v.length,n);return p.slice(y)}).join(`
  8195. `);return o.replaceWith(c,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
  8196. `);return!a||!s?!1:t.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:u})=>(u.setSelection(un.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[dR({find:b$e,type:this.type,getAttributes:t=>({language:t[1]})}),dR({find:y$e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Tr({key:new Si("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:s,schema:o}=t.state,c=o.text(n.replace(/\r\n?/g,`
  8197. `));return s.replaceSelectionWith(this.type.create({language:a},c)),s.selection.$from.parent.type!==this.type&&s.setSelection(Kt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),_$e=is.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8198. `):""}),w$e=is.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",Or(this.options.HTMLAttributes,t)]},renderText(){return`
  8199. `},renderMarkdown:()=>`
  8200. `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:o}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&s){const f=c.filter(g=>o.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),S$e=is.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]}`,Or(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=>dR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),M$e=is.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Or(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!OHe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return JJ(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:s,dispatch:o})=>{if(o){const{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Kt.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(Ht.create(s.doc,c.pos)):s.setSelection(Kt.create(s.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(s.insert(u,f),s.setSelection(Kt.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[mee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),E$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,A$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,T$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,C$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,N$e=Rd.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",Or(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[Vp({find:E$e,type:this.type}),Vp({find:T$e,type:this.type})]},addPasteRules(){return[ff({find:A$e,type:this.type}),ff({find:C$e,type:this.type})]}});const k$e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",P$e="ελ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",mR="numeric",pR="ascii",gR="alpha",l0="asciinumeric",qx="alphanumeric",xR="domain",xee="emoji",R$e="scheme",j$e="slashscheme",ik="whitespace";function D$e(t,e){return t in e||(e[t]=[]),e[t]}function Th(t,e,n){e[mR]&&(e[l0]=!0,e[qx]=!0),e[pR]&&(e[l0]=!0,e[gR]=!0),e[l0]&&(e[qx]=!0),e[gR]&&(e[qx]=!0),e[qx]&&(e[xR]=!0),e[xee]&&(e[xR]=!0);for(const r in e){const i=D$e(r,n);i.indexOf(t)<0&&i.push(t)}}function O$e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ka(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ka.groups={};Ka.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Ka.groups;let i;return e&&e.j?i=e:(i=new Ka(e),n&&r&&Th(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let s=0;s<a-1;s++)i=i.tt(t[s]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||Ka.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let s,o=i.go(t);if(o?(s=new Ka,Object.assign(s.j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new Ka,a){if(r)if(s.t&&typeof s.t=="string"){const c=Object.assign(O$e(s.t,r),n);Th(a,c,r)}else n&&Th(a,n,r);s.t=a}return i.j[t]=s,s}};const sn=(t,e,n,r,i)=>t.ta(e,n,r,i),Pr=(t,e,n,r,i)=>t.tr(e,n,r,i),X7=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),oc="WORD",bR="UWORD",bee="ASCIINUMERICAL",yee="ALPHANUMERICAL",lb="LOCALHOST",yR="TLD",vR="UTLD",_1="SCHEME",Gm="SLASH_SCHEME",cL="NUM",_R="WS",uL="NL",c0="OPENBRACE",u0="CLOSEBRACE",sS="OPENBRACKET",oS="CLOSEBRACKET",lS="OPENPAREN",cS="CLOSEPAREN",uS="OPENANGLEBRACKET",dS="CLOSEANGLEBRACKET",hS="FULLWIDTHLEFTPAREN",fS="FULLWIDTHRIGHTPAREN",mS="LEFTCORNERBRACKET",pS="RIGHTCORNERBRACKET",gS="LEFTWHITECORNERBRACKET",xS="RIGHTWHITECORNERBRACKET",bS="FULLWIDTHLESSTHAN",yS="FULLWIDTHGREATERTHAN",vS="AMPERSAND",_S="APOSTROPHE",wS="ASTERISK",Uu="AT",SS="BACKSLASH",MS="BACKTICK",ES="CARET",Gu="COLON",dL="COMMA",AS="DOLLAR",Qo="DOT",TS="EQUALS",hL="EXCLAMATION",Ws="HYPHEN",d0="PERCENT",CS="PIPE",NS="PLUS",kS="POUND",h0="QUERY",fL="QUOTE",vee="FULLWIDTHMIDDLEDOT",mL="SEMI",Jo="SLASH",f0="TILDE",PS="UNDERSCORE",_ee="EMOJI",RS="SYM";var wee=Object.freeze({__proto__:null,ALPHANUMERICAL:yee,AMPERSAND:vS,APOSTROPHE:_S,ASCIINUMERICAL:bee,ASTERISK:wS,AT:Uu,BACKSLASH:SS,BACKTICK:MS,CARET:ES,CLOSEANGLEBRACKET:dS,CLOSEBRACE:u0,CLOSEBRACKET:oS,CLOSEPAREN:cS,COLON:Gu,COMMA:dL,DOLLAR:AS,DOT:Qo,EMOJI:_ee,EQUALS:TS,EXCLAMATION:hL,FULLWIDTHGREATERTHAN:yS,FULLWIDTHLEFTPAREN:hS,FULLWIDTHLESSTHAN:bS,FULLWIDTHMIDDLEDOT:vee,FULLWIDTHRIGHTPAREN:fS,HYPHEN:Ws,LEFTCORNERBRACKET:mS,LEFTWHITECORNERBRACKET:gS,LOCALHOST:lb,NL:uL,NUM:cL,OPENANGLEBRACKET:uS,OPENBRACE:c0,OPENBRACKET:sS,OPENPAREN:lS,PERCENT:d0,PIPE:CS,PLUS:NS,POUND:kS,QUERY:h0,QUOTE:fL,RIGHTCORNERBRACKET:pS,RIGHTWHITECORNERBRACKET:xS,SCHEME:_1,SEMI:mL,SLASH:Jo,SLASH_SCHEME:Gm,SYM:RS,TILDE:f0,TLD:yR,UNDERSCORE:PS,UTLD:vR,UWORD:bR,WORD:oc,WS:_R});const rc=/[a-z]/,Dx=new RegExp("\\p{L}","u"),ak=new RegExp("\\p{Emoji}","u"),ic=/\d/,sk=/\s/,Y7="\r",ok=`
  8201. `,L$e="️",I$e="‍",lk="";let V_=null,G_=null;function F$e(t=[]){const e={};Ka.groups=e;const n=new Ka;V_==null&&(V_=Z7(k$e)),G_==null&&(G_=Z7(P$e)),gt(n,"'",_S),gt(n,"{",c0),gt(n,"}",u0),gt(n,"[",sS),gt(n,"]",oS),gt(n,"(",lS),gt(n,")",cS),gt(n,"<",uS),gt(n,">",dS),gt(n,"(",hS),gt(n,")",fS),gt(n,"「",mS),gt(n,"」",pS),gt(n,"『",gS),gt(n,"』",xS),gt(n,"<",bS),gt(n,">",yS),gt(n,"&",vS),gt(n,"*",wS),gt(n,"@",Uu),gt(n,"`",MS),gt(n,"^",ES),gt(n,":",Gu),gt(n,",",dL),gt(n,"$",AS),gt(n,".",Qo),gt(n,"=",TS),gt(n,"!",hL),gt(n,"-",Ws),gt(n,"%",d0),gt(n,"|",CS),gt(n,"+",NS),gt(n,"#",kS),gt(n,"?",h0),gt(n,'"',fL),gt(n,"/",Jo),gt(n,";",mL),gt(n,"~",f0),gt(n,"_",PS),gt(n,"\\",SS),gt(n,"・",vee);const r=Pr(n,ic,cL,{[mR]:!0});Pr(r,ic,r);const i=Pr(r,rc,bee,{[l0]:!0}),a=Pr(r,Dx,yee,{[qx]:!0}),s=Pr(n,rc,oc,{[pR]:!0});Pr(s,ic,i),Pr(s,rc,s),Pr(i,ic,i),Pr(i,rc,i);const o=Pr(n,Dx,bR,{[gR]:!0});Pr(o,rc),Pr(o,ic,a),Pr(o,Dx,o),Pr(a,ic,a),Pr(a,rc),Pr(a,Dx,a);const c=gt(n,ok,uL,{[ik]:!0}),u=gt(n,Y7,_R,{[ik]:!0}),d=Pr(n,sk,_R,{[ik]:!0});gt(n,lk,d),gt(u,ok,c),gt(u,lk,d),Pr(u,sk,d),gt(d,Y7),gt(d,ok),Pr(d,sk,d),gt(d,lk,d);const f=Pr(n,ak,_ee,{[xee]:!0});gt(f,"#"),Pr(f,ak,f),gt(f,L$e,f);const g=gt(f,I$e);gt(g,"#"),Pr(g,ak,f);const p=[[rc,s],[ic,i]],x=[[rc,null],[Dx,o],[ic,a]];for(let v=0;v<V_.length;v++)Ru(n,V_[v],yR,oc,p);for(let v=0;v<G_.length;v++)Ru(n,G_[v],vR,bR,x);Th(yR,{tld:!0,ascii:!0},e),Th(vR,{utld:!0,alpha:!0},e),Ru(n,"file",_1,oc,p),Ru(n,"mailto",_1,oc,p),Ru(n,"http",Gm,oc,p),Ru(n,"https",Gm,oc,p),Ru(n,"ftp",Gm,oc,p),Ru(n,"ftps",Gm,oc,p),Th(_1,{scheme:!0,ascii:!0},e),Th(Gm,{slashscheme:!0,ascii:!0},e),t=t.sort((v,y)=>v[0]>y[0]?1:-1);for(let v=0;v<t.length;v++){const y=t[v][0],E=t[v][1]?{[R$e]:!0}:{[j$e]:!0};y.indexOf("-")>=0?E[xR]=!0:rc.test(y)?ic.test(y)?E[l0]=!0:E[pR]=!0:E[mR]=!0,X7(n,y,y,E)}return X7(n,"localhost",lb,{ascii:!0}),n.jd=new Ka(RS),{start:n,tokens:Object.assign({groups:e},wee)}}function See(t,e){const n=U$e(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let a=0,s=0;for(;s<r;){let o=t,c=null,u=0,d=null,f=-1,g=-1;for(;s<r&&(c=o.go(n[s]));)o=c,o.accepts()?(f=0,g=0,d=o):f>=0&&(f+=n[s].length,g++),u+=n[s].length,a+=n[s].length,s++;a-=f,s-=g,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function U$e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,s=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Ru(t,e,n,r,i){let a;const s=e.length;for(let o=0;o<s-1;o++){const c=e[o];t.j[c]?a=t.j[c]:(a=new Ka(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Ka(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function Z7(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+a),10);s>0;s--)n.pop();r+=a}else n.push(t[r]),r++}return e}const cb={defaultProtocol:"http",events:null,format:Q7,formatHref:Q7,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function pL(t,e=null){let n=Object.assign({},cb);t&&(n=Object.assign(n,t instanceof pL?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}pL.prototype={o:cb,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]:cb[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 Q7(t){return t}function Mee(t,e){this.t="token",this.v=t,this.tk=e}Mee.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=cb.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),s={},o=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,o&&(s.class=o),c&&(s.target=c),u&&(s.rel=u),d&&Object.assign(s,d),{tagName:i,attributes:s,content:a,eventListeners:f}}};function hE(t,e){class n extends Mee{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const J7=hE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),e9=hE("text"),z$e=hE("nl"),W_=hE("url",{isLink:!0,toHref(t=cb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==lb&&t[1].t===Gu}}),$s=t=>new Ka(t);function B$e({groups:t}){const e=t.domain.concat([vS,wS,Uu,SS,MS,ES,AS,TS,Ws,cL,d0,CS,NS,kS,Jo,RS,f0,PS]),n=[_S,Gu,dL,Qo,hL,d0,h0,fL,mL,uS,dS,c0,u0,oS,sS,lS,cS,hS,fS,mS,pS,gS,xS,bS,yS],r=[vS,_S,wS,SS,MS,ES,AS,TS,Ws,c0,u0,d0,CS,NS,kS,h0,Jo,RS,f0,PS],i=$s(),a=gt(i,f0);sn(a,r,a),sn(a,t.domain,a);const s=$s(),o=$s(),c=$s();sn(i,t.domain,s),sn(i,t.scheme,o),sn(i,t.slashscheme,c),sn(s,r,a),sn(s,t.domain,s);const u=gt(s,Uu);gt(a,Uu,u),gt(o,Uu,u),gt(c,Uu,u);const d=gt(a,Qo);sn(d,r,a),sn(d,t.domain,a);const f=$s();sn(u,t.domain,f),sn(f,t.domain,f);const g=gt(f,Qo);sn(g,t.domain,f);const p=$s(J7);sn(g,t.tld,p),sn(g,t.utld,p),gt(u,lb,p);const x=gt(f,Ws);gt(x,Ws,x),sn(x,t.domain,f),sn(p,t.domain,f),gt(p,Qo,g),gt(p,Ws,x);const v=gt(p,Gu);sn(v,t.numeric,J7);const y=gt(s,Ws),b=gt(s,Qo);gt(y,Ws,y),sn(y,t.domain,s),sn(b,r,a),sn(b,t.domain,s);const E=$s(W_);sn(b,t.tld,E),sn(b,t.utld,E),sn(E,t.domain,s),sn(E,r,a),gt(E,Qo,b),gt(E,Ws,y),gt(E,Uu,u);const w=gt(E,Gu),A=$s(W_);sn(w,t.numeric,A);const T=$s(W_),C=$s();sn(T,e,T),sn(T,n,C),sn(C,e,T),sn(C,n,C),gt(E,Jo,T),gt(A,Jo,T);const k=gt(o,Gu),F=gt(c,Gu),N=gt(F,Jo),j=gt(N,Jo);sn(o,t.domain,s),gt(o,Qo,b),gt(o,Ws,y),sn(c,t.domain,s),gt(c,Qo,b),gt(c,Ws,y),sn(k,t.domain,T),gt(k,Jo,T),gt(k,h0,T),sn(j,t.domain,T),sn(j,e,T),gt(j,Jo,T);const I=[[c0,u0],[sS,oS],[lS,cS],[uS,dS],[hS,fS],[mS,pS],[gS,xS],[bS,yS]];for(let O=0;O<I.length;O++){const[q,R]=I[O],W=gt(T,q);gt(C,q,W),gt(W,R,T);const K=$s(W_);sn(W,e,K);const G=$s();sn(W,n),sn(K,e,K),sn(K,n,G),sn(G,e,K),sn(G,n,G),gt(K,R,T),gt(G,R,T)}return gt(i,lb,E),gt(i,uL,z$e),{start:i,tokens:wee}}function H$e(t,e,n){let r=n.length,i=0,a=[],s=[];for(;i<r;){let o=t,c=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(c=o.go(n[i].t));)s.push(n[i++]);for(;i<r&&(u=c||o.go(n[i].t));)c=null,o=u,o.accepts()?(g=0,f=o):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(s.push(n[i]),i++);else{s.length>0&&(a.push(ck(e9,e,s)),s=[]),i-=g,d-=g;const p=f.t,x=n.slice(i-d,i);a.push(ck(p,e,x))}}return s.length>0&&a.push(ck(e9,e,s)),a}function ck(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const $$e=typeof console<"u"&&console&&console.warn||(()=>{}),V$e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",dr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function G$e(){return Ka.groups={},dr.scanner=null,dr.parser=null,dr.tokenQueue=[],dr.pluginQueue=[],dr.customSchemes=[],dr.initialized=!1,dr}function t9(t,e=!1){if(dr.initialized&&$$e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${V$e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8202. 1. Must only contain digits, lowercase ASCII letters or "-"
  8203. 2. Cannot start or end with "-"
  8204. 3. "-" cannot repeat`);dr.customSchemes.push([t,e])}function W$e(){dr.scanner=F$e(dr.customSchemes);for(let t=0;t<dr.tokenQueue.length;t++)dr.tokenQueue[t][1]({scanner:dr.scanner});dr.parser=B$e(dr.scanner.tokens);for(let t=0;t<dr.pluginQueue.length;t++)dr.pluginQueue[t][1]({scanner:dr.scanner,parser:dr.parser});return dr.initialized=!0,dr}function gL(t){return dr.initialized||W$e(),H$e(dr.parser.start,t,See(dr.scanner.start,t))}gL.scan=See;function Eee(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 pL(n),i=gL(t),a=[];for(let s=0;s<i.length;s++){const o=i[s];o.isLink&&(!e||o.t===e)&&r.check(o)&&a.push(o.toFormattedObject(r))}return a}var xL="[\0-   ᠎ -\u2029  ]",q$e=new RegExp(xL),K$e=new RegExp(`${xL}$`),X$e=new RegExp(xL,"g");function Y$e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Z$e(t){return new Tr({key:new Si("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:s}=r,o=GJ(n.doc,[...e]);if(QJ(o).forEach(({newRange:u})=>{const d=L6e(r.doc,u,p=>p.isTextblock);let f,g;if(d.length>1)f=d[0],g=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!K$e.test(p))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const p=g.split(q$e).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],v=f.pos+g.lastIndexOf(x);if(!x)return!1;const y=gL(x).map(b=>b.toObject(t.defaultProtocol));if(!Y$e(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:v+b.start+1,to:v+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{iL(b.from,b.to,r.doc).some(E=>E.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function Q$e(t){return new Tr({key:new Si("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;s=f.find(g=>g.nodeName==="A")}if(!s)return!1;const o=ZJ(e.state,t.type.name),c=(i=s?.href)!=null?i:o.href,u=(a=s?.target)!=null?a:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&c?(window.open(c,u),!0):!1}}})}function J$e(t){return new Tr({key:new Si("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:s}=a,{empty:o}=s;if(o)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Eee(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function sh(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(X$e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Aee=Rd.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"){t9(t);return}t9(t.scheme,t.optionalSlashes)})},onDestroy(){G$e()},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)=>!!sh(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=>!!sh(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=>!!sh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Or(this.options.HTMLAttributes,t),0]:["a",Or(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=>!!sh(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=>!!sh(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[ff({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Eee(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!sh(s,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Z$e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!sh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(Q$e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(J$e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),eVe=Aee,tVe=Object.defineProperty,nVe=(t,e)=>{for(var n in e)tVe(t,n,{get:e[n],enumerable:!0})},rVe="listItem",n9="textStyle",r9=/^\s*([-+*])\s$/,Tee=is.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",Or(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,`
  8205. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(rVe,this.editor.getAttributes(n9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Gp({find:r9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:r9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(n9),editor:this.editor})),[t]}}),Cee=is.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Or(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const s=t.tokens.slice(1),o=e.parseChildren(s);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>lL(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)}}}),iVe={};nVe(iVe,{findListItemPos:()=>ty,getNextListDepth:()=>bL,handleBackspace:()=>wR,handleDelete:()=>SR,hasListBefore:()=>Nee,hasListItemAfter:()=>aVe,hasListItemBefore:()=>kee,listItemHasSubList:()=>Pee,nextListIsDeeper:()=>Ree,nextListIsHigher:()=>jee});var ty=(t,e)=>{const{$from:n}=e.selection,r=ai(t,e.schema);let i=null,a=n.depth,s=n.pos,o=null;for(;a>0&&o===null;)i=n.node(a),i.type===r?o=a:(a-=1,s-=1);return o===null?null:{$pos:e.doc.resolve(s),depth:o}},bL=(t,e)=>{const n=ty(t,e);if(!n)return!1;const[,r]=W6e(e,t,n.$pos.pos+4);return r},Nee=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},kee=(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)},Pee=(t,e,n)=>{if(!n)return!1;const r=ai(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},wR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Sd(t.state,e)&&Nee(t.state,e,n)){const{$anchor:o}=t.state.selection,c=t.state.doc.resolve(o.before()-1),u=[];c.node().descendants((g,p)=>{g.type.name===e&&u.push({node:g,pos:p})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!Sd(t.state,e)||!Y6e(t.state))return!1;const r=ty(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=Pee(e,t.state,a);return kee(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Ree=(t,e)=>{const n=bL(t,e),r=ty(t,e);return!r||!n?!1:n>r.depth},jee=(t,e)=>{const n=bL(t,e),r=ty(t,e);return!r||!n?!1:n<r.depth},SR=(t,e)=>{if(!Sd(t.state,e)||!X6e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Ree(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():jee(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},aVe=(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)},Dee=Jn.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&&SR(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&&SR(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&&wR(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&&wR(t,n,r)&&(e=!0)}),e}}}}),i9=/^(\s*)(\d+)\.\s+(.*)$/,sVe=/^\s/;function oVe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(i9);if(!a)break;const[,s,o,c]=a,u=s.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const p=t[f];if(p.match(i9))break;if(p.trim()==="")g.push(p),d+=`
  8206. `,f+=1;else if(p.match(sVe))g.push(p),d+=`
  8207. ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(o,10),content:d.trim(),raw:g.join(`
  8208. `)}),r=f,n=f}return[e,r]}function Oee(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const o=s.content.split(`
  8209. `),c=((r=o[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=o.slice(1).join(`
  8210. `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const p=Math.min(...g.map(v=>v.indent)),x=Oee(g,p,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(v=>v.raw).join(`
  8211. `)})}i.push({type:"list_item",raw:s.raw,tokens:u}),a=f}else a+=1}return i}function lVe(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var cVe="listItem",a9="textStyle",s9=/^(\d+)\.\s$/,Lee=is.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",Or(this.options.HTMLAttributes,n),0]:["ol",Or(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?lVe(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,`
  8212. `):"",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(`
  8213. `),[a,s]=oVe(i);if(a.length===0)return;const o=Oee(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,s).join(`
  8214. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(cVe,this.editor.getAttributes(a9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Gp({find:s9,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=Gp({find:s9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(a9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),uVe=/^\s*(\[([( |x])?\])\s$/,dVe=is.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",Or(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 lL(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),s=document.createElement("span"),o=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,g;o.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.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:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const p=n();if(typeof p!="number")return!1;const x=g.doc.nodeAt(p);return g.setNodeMarkup(p,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Gp({find:uVe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),hVe=is.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",Or(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,`
  8215. `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=hR(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,c)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:c}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=hR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Jn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Tee.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Cee.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Dee.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Lee.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(dVe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(hVe.configure(this.options.taskList)),t}});var fVe=is.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Or(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()}}}),mVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,pVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,gVe=Rd.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",Or(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[Vp({find:mVe,type:this.type})]},addPasteRules(){return[ff({find:pVe,type:this.type})]}}),xVe=is.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Iee=Rd.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",Or(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),bVe=Iee;function yVe(t={}){return new Tr({view(e){return new vVe(e,t)}})}class vVe{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=s=>{this[i](s)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),s=a.width/i.offsetWidth,o=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),v=f?x.bottom:x.top;f&&g&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*o;r={left:x.left,right:x.right,top:v-y,bottom:v+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*s;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,d=f.top-c.scrollTop*p}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-d)/o+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=IQ(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class jr extends un{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return jr.valid(r)?new jr(r):un.near(r)}content(){return Pt.empty}eq(e){return e instanceof jr&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new jr(e.resolve(n.pos))}getBookmark(){return new yL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!_Ve(e)||!wVe(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&jr.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let c=e.doc.resolve(i);if(jr.valid(c))return c}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!Ht.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let o=e.doc.resolve(i);if(jr.valid(o))return o}return null}}}jr.prototype.visible=!1;jr.findFrom=jr.findGapCursorFrom;un.jsonID("gapcursor",jr);class yL{constructor(e){this.pos=e}map(e){return new yL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return jr.valid(n)?new jr(n):un.near(n)}}function Fee(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function _Ve(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||Fee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function wVe(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||Fee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function SVe(){return new Tr({props:{decorations:TVe,createSelectionBetween(t,e,n){return e.pos==n.pos&&jr.valid(n)?new jr(n):null},handleClick:EVe,handleKeyDown:MVe,handleDOMEvents:{beforeinput:AVe}}})}const MVe=IJ({ArrowLeft:q_("horiz",-1),ArrowRight:q_("horiz",1),ArrowUp:q_("vert",-1),ArrowDown:q_("vert",1)});function q_(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,o=e>0?s.$to:s.$from,c=s.empty;if(s instanceof Kt){if(!a.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=jr.findGapCursorFrom(o,e,c);return u?(i&&i(r.tr.setSelection(new jr(u))),!0):!1}}function EVe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!jr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ht.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new jr(r))),!0)}function AVe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof jr))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=mt.empty;for(let s=r.length-1;s>=0;s--)i=mt.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Pt(i,0,0));return a.setSelection(Kt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function TVe(t){if(!(t.selection instanceof jr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",vr.create(t.doc,[Ta.widget(t.selection.head,e,{key:"gapcursor"})])}var jS=200,Fi=function(){};Fi.prototype.append=function(e){return e.length?(e=Fi.from(e),!this.length&&e||e.length<jS&&this.leafAppend(e)||this.length<jS&&e.leafPrepend(this)||this.appendInner(e)):this};Fi.prototype.prepend=function(e){return e.length?Fi.from(e).append(this):this};Fi.prototype.appendInner=function(e){return new CVe(this,e)};Fi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Fi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Fi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Fi.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)};Fi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,s){return i.push(e(a,s))},n,r),i};Fi.from=function(e){return e instanceof Fi?e:e&&e.length?new Uee(e):Fi.empty};var Uee=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,s,o){for(var c=a;c<s;c++)if(i(this.values[c],o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,o){for(var c=a-1;c>=s;c--)if(i(this.values[c],o+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=jS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=jS)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})(Fi);Fi.empty=new Uee([]);var CVe=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,s){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(r,Math.min(i,o),a,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Fi);const NVe=500;class Ro{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let s=e.tr,o,c,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new el(f.map));let p=f.step.map(i.slice(a)),x;p&&s.maybeStep(p).doc&&(x=s.mapping.maps[s.mapping.maps.length-1],u.push(new el(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else s.maybeStep(f.step);if(f.selection)return o=i?f.selection.map(i.slice(a)):f.selection,c=new Ro(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:s,selection:o}}addTransform(e,n,r,i){let a=[],s=this.eventCount,o=this.items,c=!i&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new el(e.mapping.maps[d],f,n),p;(p=c&&c.merge(g))&&(g=p,d?a.pop():o=o.slice(0,o.length-1)),a.push(g),n&&(s++,n=void 0),i||(c=g)}let u=s-r.depth;return u>PVe&&(o=kVe(o,u),s-=u),new Ro(o.append(a),s)}remapping(e,n){let r=new nb;return this.items.forEach((i,a)=>{let s=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ro(this.items.append(e.map(n=>new el(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let c=n;this.items.forEach(g=>{let p=a.getMirror(--c);if(p==null)return;s=Math.min(s,p);let x=a.maps[p];if(g.step){let v=e.steps[p].invert(e.docs[p]),y=g.selection&&g.selection.map(a.slice(c+1,p));y&&o++,r.push(new el(x,v,y))}else r.push(new el(x))},i);let u=[];for(let g=n;g<s;g++)u.push(new el(a.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Ro(d,o);return f.emptyItemCount()>NVe&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((s,o)=>{if(o>=e)i.push(s),s.selection&&a++;else if(s.step){let c=s.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=s.selection&&s.selection.map(n.slice(r));d&&a++;let f=new el(u.invert(),c,d),g,p=i.length-1;(g=i.length&&i[p].merge(f))?i[p]=g:i.push(f)}}else s.map&&r--},this.items.length,0),new Ro(Fi.from(i.reverse()),a)}}Ro.empty=new Ro(Fi.empty,0);function kVe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class el{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 el(n.getMap().invert(),n,this.selection)}}}class zu{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const PVe=20;function RVe(t,e,n,r){let i=n.getMeta(Bh),a;if(i)return i.historyState;n.getMeta(OVe)&&(t=new zu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Bh))return s.getMeta(Bh).redo?new zu(t.done.addTransform(n,void 0,r,w1(e)),t.undone,o9(n.mapping.maps),t.prevTime,t.prevComposition):new zu(t.done,t.undone.addTransform(n,void 0,r,w1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!jVe(n,t.prevRanges)),u=s?uk(t.prevRanges,n.mapping):o9(n.mapping.maps);return new zu(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,w1(e)),Ro.empty,u,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new zu(t.done.rebased(n,a),t.undone.rebased(n,a),uk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new zu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),uk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function jVe(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function o9(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,s)=>e.push(a,s));return e}function uk(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function DVe(t,e,n){let r=w1(e),i=Bh.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new zu(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(Bh,{redo:n,historyState:c})}let dk=!1,l9=null;function w1(t){let e=t.plugins;if(l9!=e){dk=!1,l9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){dk=!0;break}}return dk}const Bh=new Si("history"),OVe=new Si("closeHistory");function LVe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Tr({key:Bh,state:{init(){return new zu(Ro.empty,Ro.empty,null,0,-1)},apply(e,n,r){return RVe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Bee:r=="historyRedo"?Hee:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function zee(t,e){return(n,r)=>{let i=Bh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=DVe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const Bee=zee(!1,!0),Hee=zee(!0,!0);Jn.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 Tr({key:new Si("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const s=a-i,o=0,c=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(o,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,c=a-r,u=o-c,d=o;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var IVe=Jn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[yVe(this.options)]}});Jn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Tr({key:new Si("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return vr.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(Ta.node(u,u+c.nodeSize,{class:this.options.className}))}),vr.create(t,a)}}})]}});var FVe=Jn.create({name:"gapCursor",addProseMirrorPlugins(){return[SVe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=zn(Bt(t,"allowGapCursor",n)))!=null?e:null}}});Jn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Tr({key:new Si("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((s,o)=>{const c=r>=o&&r<=o+s.nodeSize,u=!s.isLeaf&&cE(s);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ta.node(o,o+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:o,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),vr.create(t,i)}}})]}});Jn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Tr({key:new Si("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||JJ(n.selection)||t.view.dragging?null:vr.create(n.doc,[Ta.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function c9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var UVe=Jn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Si(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 Tr({key:e,appendTransaction:(i,a,s)=>{const{doc:o,tr:c,schema:u}=s,d=e.getState(s),f=o.content.size,g=u.nodes[n];if(d)return c.insert(f,g.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!c9({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!c9({node:s,types:r})}}})]}}),zVe=Jn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Bee(t,e),redo:()=>({state:t,dispatch:e})=>Hee(t,e)}},addProseMirrorPlugins(){return[LVe(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()}}}),BVe=Jn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(m$e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(c$e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Tee.configure(this.options.bulletList)),this.options.code!==!1&&i.push(x$e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(v$e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(_$e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(IVe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(FVe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(w$e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(S$e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(zVe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(M$e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(N$e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Cee.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Dee.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Aee.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Lee.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(fVe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(gVe.configure(this.options.strike)),this.options.text!==!1&&i.push(xVe.configure(this.options.text)),this.options.underline!==!1&&i.push(Iee.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(UVe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),HVe=BVe,$Ve=Jn.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")}}}),VVe=$Ve,GVe=20,$ee=(t,e=0)=>{const n=[];return!t.children.length||e>GVe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...$ee(r,e+1))}),n},WVe=t=>{if(!t.children.length)return;const e=$ee(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),s=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${s};${a}`)})},Vee=Rd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&WVe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Or(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),qVe=Jn.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Gee=Jn.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),KVe=Jn.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()}}}),XVe=Jn.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()}}}),YVe=Jn.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()}}});Jn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(qVe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Gee.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(KVe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(XVe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(YVe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Vee.configure(this.options.textStyle)),t}});var ZVe=Gee,QVe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,JVe=is.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",Or(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,s;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return u?`![${c}](${o} "${u}")`:`![${c}](${o})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:s})=>{const o=document.createElement("img");Object.entries(s).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:o.setAttribute(d,f);break}}),o.src=s.src;const c=new DHe({element:o,node:i,getPos:a,onResize:(d,f)=>{o.style.width=`${d}px`,o.style.height=`${f}px`},onCommit:(d,f)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",o.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[mee({find:QVe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),e7e=JVe;function MR({content:t,onChange:e,placeholder:n}){const r=i$e({extensions:[HVe.configure({heading:!1,codeBlock:!1,code:!1}),bVe,eVe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),VVe.configure({types:["paragraph"]}),Vee,ZVe,e7e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:s})=>{e(s.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:s,isActive:o=!1,children:c,title:u})=>l.jsx("button",{type:"button",onClick:s,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const s=window.prompt("Enter URL:");s&&r.chain().focus().setLink({href:s}).run()};return l.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[l.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[l.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:l.jsx(doe,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:l.jsx(Wle,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:l.jsx(Uue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:l.jsx(QR,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:l.jsx(xG,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:l.jsx(Pue,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:l.jsx(Tue,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:l.jsx(Nue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:l.jsx(VS,{className:"w-4 h-4"})}),r.isActive("link")&&l.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:l.jsx(MG,{className:"w-4 h-4"})})]}),l.jsx(ZHe,{editor:r})]})}function t7e({archiveId:t,archiveName:e,onClose:n}){const r=Mn(),[i,a]=M.useState(!1),[s,o]=M.useState(null),[c,u]=M.useState({}),{data:d,isLoading:f,error:g}=yt({queryKey:["archive-project-page",t],queryFn:()=>Ce.getArchiveProjectPage(t)}),p=vt({mutationFn:T=>Ce.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});M.useEffect(()=>{const T=C=>{C.key==="Escape"&&(s!==null?o(null):i?b():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},y=()=>{p.mutate(c)},b=()=>{a(!1),u({})},E=T=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],k=new DOMParser().parseFromString(T,"text/html"),F=N=>{if(N.nodeType===Node.TEXT_NODE)return N.textContent||"";if(N.nodeType===Node.ELEMENT_NODE){const j=N,I=j.tagName.toLowerCase();if(!C.includes(I))return Array.from(j.childNodes).map(F).join("");let O="";if(I==="a"&&j.getAttribute("href")){const R=j.getAttribute("href");R?.toLowerCase().startsWith("http")&&(O=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(I==="img"){const R=j.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";O=` src="${R}" style="max-width: 100%; height: auto;"`}const q=Array.from(j.childNodes).map(F).join("");return["br","img"].includes(I)?`<${I}${O} />`:`<${I}${O}>${q}</${I}>`}return""};return Array.from(k.body.childNodes).map(F).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=T=>{T.target===T.currentTarget&&n()};return l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(ws,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&l.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&l.jsxs(Pe,{variant:"ghost",size:"sm",onClick:v,children:[l.jsx(qh,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&l.jsxs(l.Fragment,{children:[l.jsx(Pe,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),l.jsxs(Pe,{variant:"primary",size:"sm",onClick:y,disabled:p.isPending,children:[l.jsx(no,{className:"w-4 h-4 mr-1"}),"Save"]})]}),l.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&l.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&l.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[l.jsx(ws,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No project page data found in this 3MF file."}),l.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-4",children:[i?l.jsx("input",{type:"text",value:c.title||"",onChange:T=>u({...c,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&&l.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),l.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Uk,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:c.designer||"",onChange:T=>u({...c,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(Uk,{className:"w-4 h-4"}),l.jsx("span",{children:d.designer}),d.designer_user_id&&l.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:l.jsx(Cs,{className:"w-3 h-3"})})]}),d.creation_date&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx($r,{className:"w-4 h-4"}),l.jsx("span",{children:d.creation_date})]}),i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ws,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:c.license||"",onChange:T=>u({...c,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(ws,{className:"w-4 h-4"}),l.jsx("span",{children:d.license})]}),d.origin&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?l.jsx(MR,{content:c.description||"",onChange:T=>u({...c,description:T}),placeholder:"Enter description..."}):l.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&l.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?l.jsxs("div",{className:"space-y-2",children:[l.jsx("input",{type:"text",value:c.profile_title||"",onChange:T=>u({...c,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"}),l.jsx(MR,{content:c.profile_description||"",onChange:T=>u({...c,profile_description:T}),placeholder:"Profile description..."})]}):l.jsxs(l.Fragment,{children:[d.profile_title&&l.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&l.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&l.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[l.jsx(bb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),l.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((T,C)=>l.jsx("button",{onClick:()=>o(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:l.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.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:[l.jsx(Cs,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&x[s]&&l.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,s-1))},disabled:s===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:l.jsx(Wh,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:x[s].url,alt:x[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(x.length-1,s+1))},disabled:s===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:l.jsx($c,{className:"w-6 h-6 text-white"})}),l.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:l.jsx(Wt,{className:"w-6 h-6 text-white"})}),l.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",x.length]})]})]})}const n7e=[.25,.5,.75,1,1.5,2,3,4];function r7e({src:t,title:e,downloadFilename:n,onClose:r}){const i=M.useRef(null),[a,s]=M.useState(!0),[o,c]=M.useState(2),[u,d]=M.useState(0),[f,g]=M.useState(0);M.useEffect(()=>{const w=i.current;w&&(w.playbackRate=o)},[o]),M.useEffect(()=>{const w=A=>{A.key==="Escape"&&r()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[r]),M.useEffect(()=>{const w=i.current;if(!w)return;const A=()=>d(w.currentTime),T=()=>g(w.duration),C=()=>s(!0),k=()=>s(!1);return w.addEventListener("timeupdate",A),w.addEventListener("durationchange",T),w.addEventListener("play",C),w.addEventListener("pause",k),()=>{w.removeEventListener("timeupdate",A),w.removeEventListener("durationchange",T),w.removeEventListener("play",C),w.removeEventListener("pause",k)}},[]);const p=()=>{const w=i.current;w&&(a?w.pause():w.play())},x=w=>{const A=i.current;A&&(A.currentTime=parseFloat(w.target.value))},v=()=>{const w=i.current;w&&(w.currentTime=Math.max(0,w.currentTime-5))},y=()=>{const w=i.current;w&&(w.currentTime=Math.min(f,w.currentTime+5))},b=w=>{const A=Math.floor(w/60),T=Math.floor(w%60);return`${A}:${T.toString().padStart(2,"0")}`},E=()=>{const w=document.createElement("a");w.href=t,w.download=n,w.click()};return l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:l.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Jm,{className:"w-5 h-5 text-bambu-green"}),e]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:E,children:[l.jsx(ts,{className:"w-4 h-4"}),"Download"]}),l.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"p-4",children:[l.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:p}),l.jsxs("div",{className:"mt-4 space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:b(u)}),l.jsx("input",{type:"range",min:0,max:f||100,value:u,onChange:x,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8216. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8217. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8218. [&::-webkit-slider-thumb]:cursor-pointer`}),l.jsx("span",{className:"text-xs text-bambu-gray w-12",children:b(f)})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:l.jsx(mue,{className:"w-5 h-5 text-bambu-gray"})}),l.jsx("button",{onClick:p,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:a?l.jsx(Oce,{className:"w-5 h-5 text-white"}):l.jsx(GS,{className:"w-5 h-5 text-white"})}),l.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:l.jsx(D1,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),l.jsx("div",{className:"flex gap-1",children:n7e.map(w=>l.jsxs("button",{onClick:()=>c(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 i7e({archiveId:t,archiveName:e,onClose:n}){const r=Mn(),{showToast:i}=Gr(),[a,s]=M.useState(null),[o,c]=M.useState("asap"),[u,d]=M.useState(""),[f,g]=M.useState(!1),[p,x]=M.useState(!1),{data:v}=yt({queryKey:["printers"],queryFn:()=>Ce.getPrinters()});M.useEffect(()=>{v?.length===1&&!a&&s(v[0].id)},[v,a]),M.useEffect(()=>{const w=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const y=vt({mutationFn:w=>Ce.addToQueue(w),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:w=>{i(w.message||"Failed to add to queue","error")}}),b=w=>{if(w.preventDefault(),!a){i("Please select a printer","error");return}const A={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:p};o==="scheduled"&&u&&(A.scheduled_time=new Date(u).toISOString()),y.mutate(A)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsx(Mt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:l.jsxs(Nt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx($r,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:e})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(co,{className:"w-4 h-4"}),"No printers configured"]}):l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:w=>s(w.target.value?Number(w.target.value):null),required:!0,children:[l.jsx("option",{value:"",children:"Select printer..."}),v?.map(w=>l.jsx("option",{value:w.id,children:w.name},w.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.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:()=>c("asap"),children:[l.jsx(sr,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.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:()=>c("scheduled"),children:[l.jsx($r,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:w=>d(w.target.value),min:E(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(Ed,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.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."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Pe,{type:"submit",className:"flex-1",disabled:y.isPending||!a||v?.length===0,children:y.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function a7e({archiveIds:t,onClose:e}){M.useEffect(()=>{const a=s=>{s.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=yt({queryKey:["archive-comparison",t],queryFn:()=>Ce.compareArchives(t)});return l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?l.jsxs("div",{className:"text-center py-12 text-red-400",children:[l.jsx(Sr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"Failed to load comparison"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?l.jsx(s7e,{comparison:n}):null}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Pe,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function s7e({comparison:t}){return l.jsxs("div",{className:"space-y-6",children:[l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>l.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[l.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),l.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),l.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>l.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[l.jsx("td",{className:"py-2 pr-4 text-sm",children:l.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&l.jsx(Sr,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),l.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>l.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??l.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&l.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&l.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[l.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[l.jsx(Sr,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),l.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>l.jsxs("li",{children:[l.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&l.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[l.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[l.jsx(Gh,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[l.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),l.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?l.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>l.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[l.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",l.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):l.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:l.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function ER(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ox(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function u9(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function o7e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a}){const s=Mn(),{showToast:o}=Gr(),c=NG(),[u,d]=M.useState(!1),[f,g]=M.useState(!1),[p,x]=M.useState(!1),[v,y]=M.useState(!1),[b,E]=M.useState(!1),[w,A]=M.useState(!1),[T,C]=M.useState([]),[k,F]=M.useState(!1),[N,j]=M.useState(!1),[I,O]=M.useState(!1),[q,R]=M.useState(!1),[W,K]=M.useState(!1),[G,te]=M.useState(null),Y=M.useRef(null),J=vt({mutationFn:Z=>Ce.uploadSource3mf(t.id,Z),onSuccess:Z=>{s.invalidateQueries({queryKey:["archives"]}),o(`Source 3MF attached: ${Z.filename}`)},onError:Z=>{o(Z.message||"Failed to upload source 3MF","error")}}),U=vt({mutationFn:()=>Ce.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),o("Source 3MF removed")},onError:Z=>{o(Z.message||"Failed to remove source 3MF","error")}}),H=vt({mutationFn:()=>Ce.scanArchiveTimelapse(t.id),onSuccess:Z=>{Z.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${Z.filename}`)):Z.status==="exists"?o("Timelapse already attached"):Z.status==="not_found"&&Z.available_files&&Z.available_files.length>0?(C(Z.available_files),A(!0)):o(Z.message||"No matching timelapse found","warning")},onError:Z=>{o(Z.message||"Failed to scan for timelapse","error")}}),ee=vt({mutationFn:Z=>Ce.selectArchiveTimelapse(t.id,Z),onSuccess:Z=>{s.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${Z.filename}`),A(!1),C([])},onError:Z=>{o(Z.message||"Failed to attach timelapse","error")}}),ie=vt({mutationFn:()=>Ce.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),o("Archive deleted")},onError:()=>{o("Failed to delete archive","error")}}),pe=vt({mutationFn:()=>Ce.toggleFavorite(t.id),onSuccess:Z=>{s.invalidateQueries({queryKey:["archives"]}),o(Z.is_favorite?"Added to favorites":"Removed from favorites")}}),ue=vt({mutationFn:Z=>Ce.updateArchive(t.id,{project_id:Z}),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),s.invalidateQueries({queryKey:["projects"]}),o("Project updated")},onError:()=>{o("Failed to update project","error")}}),be=Z=>{Z.preventDefault(),te({x:Z.clientX,y:Z.clientY})},Re=[{label:"Print",icon:l.jsx(pa,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"Schedule",icon:l.jsx($r,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"Open in Bambu Studio",icon:l.jsx(Cs,{className:"w-4 h-4"}),onClick:()=>{const Z=t.print_name||t.filename||"model",_e=`${window.location.origin}${Ce.getArchiveForSlicer(t.id,Z)}`;window.location.href=`bambustudioopen://${encodeURIComponent(_e)}`}},{label:"View on MakerWorld",icon:l.jsx(S0,{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:l.jsx(pp,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:l.jsx(Jm,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:l.jsx(tue,{className:"w-4 h-4"}),onClick:()=>H.mutate(),disabled:!t.printer_id||!!t.timelapse_path||H.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:l.jsx(iU,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const Z=document.createElement("a");Z.href=Ce.getSource3mfDownloadUrl(t.id),Z.download=`${t.print_name||t.filename}_source.3mf`,Z.click()}else Y.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:l.jsx(Ya,{className:"w-4 h-4"}),onClick:()=>Y.current?.click()},{label:"Remove Source 3MF",icon:l.jsx(An,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:l.jsx(ts,{className:"w-4 h-4"}),onClick:()=>{const Z=document.createElement("a");Z.href=Ce.getArchiveDownload(t.id),Z.download=`${t.print_name||t.filename}.3mf`,Z.click()}},{label:"Copy Download Link",icon:l.jsx(cd,{className:"w-4 h-4"}),onClick:()=>{const Z=`${window.location.origin}${Ce.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(Z).then(()=>{o("Link copied to clipboard")}).catch(()=>{o("Failed to copy link","error")})}},{label:"QR Code",icon:l.jsx(Kce,{className:"w-4 h-4"}),onClick:()=>F(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:l.jsx(w0,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:l.jsx(ws,{className:"w-4 h-4"}),onClick:()=>O(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:l.jsx(yp,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>pe.mutate()},{label:"Edit",icon:l.jsx(dd,{className:"w-4 h-4"}),onClick:()=>y(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:l.jsx(cl,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:l.jsx(cl,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const Z=[];if(t.project_id&&Z.push({label:"Remove from Project",icon:l.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>ue.mutate(null)}),!a)Z.push({label:"Loading...",icon:l.jsx(_t,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const _e=a.filter(Le=>Le.status==="active");_e.length===0?Z.push({label:"No projects available",icon:l.jsx(cl,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):_e.forEach(Le=>{Z.push({label:Le.name,icon:l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Le.color||"#888"}}),onClick:()=>ue.mutate(Le.id),disabled:t.project_id===Le.id})})}return Z})()},{label:n?"Deselect":"Select",icon:n?l.jsx(Kh,{className:"w-4 h-4"}):l.jsx(bp,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:l.jsx(An,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return l.jsxs(Mt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:be,onClick:i?()=>r(t.id):void 0,children:[i&&l.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:Z=>{Z.stopPropagation(),r(t.id)},children:n?l.jsx(Kh,{className:"w-5 h-5 text-bambu-green"}):l.jsx(bp,{className:"w-5 h-5 text-white"})}),l.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?l.jsx("img",{src:Ce.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(bb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),c&&l.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:Z=>{Z.stopPropagation();const _e=Z.currentTarget.getBoundingClientRect();te({x:_e.left,y:_e.bottom+4})},title:"Menu",children:l.jsx(WR,{className:"w-5 h-5 text-white"})}),l.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:Z=>{Z.stopPropagation(),pe.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:l.jsx(yp,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&l.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&l.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:[l.jsx(cd,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&l.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Z=>{Z.stopPropagation();const _e=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Le=`${window.location.origin}${Ce.getSource3mfForSlicer(t.id,_e)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Le)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:l.jsx(iU,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&l.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Z=>{Z.stopPropagation(),E(!0)},title:"View timelapse",children:l.jsx(Jm,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&l.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:Z=>{Z.stopPropagation(),j(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[l.jsx(w0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&l.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})]})]}),l.jsxs(Nt,{className:"p-4 flex-1 flex flex-col",children:[l.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:e}),t.project_name&&l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(Z=>Z.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(Z=>Z.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),l.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)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Ox(t.print_time_seconds||0)}
  8219. Actual: ${Ox(t.actual_time_seconds||0)}
  8220. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Ox(t.actual_time_seconds)}`:`Estimated: ${Ox(t.print_time_seconds||0)}`,children:[l.jsx(sr,{className:"w-3 h-3"}),Ox(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&l.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&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx(Pc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx(ud,{className:"w-3 h-3"}),t.total_layers&&l.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&l.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&l.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[l.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((Z,_e)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:Z},title:Z},_e))})]})]}),(t.tags||t.notes)&&l.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&l.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:l.jsx(yG,{className:"w-3 h-3"})}),t.tags?.split(",").map((Z,_e)=>l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:Z.trim()},_e))]}),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[l.jsx("span",{children:u9(t.created_at)}),l.jsx("span",{children:ER(t.file_size)})]}),l.jsxs("div",{className:"flex gap-1 mt-3",children:[l.jsxs(Pe,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[l.jsx(pa,{className:"w-3 h-3 flex-shrink-0"}),l.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),l.jsx(Pe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Z=t.print_name||t.filename||"model",_e=`${window.location.origin}${Ce.getArchiveForSlicer(t.id,Z)}`;window.location.href=`bambustudioopen://${encodeURIComponent(_e)}`},title:"Open in Bambu Studio",children:l.jsx(Cs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Pe,{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:l.jsx(S0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),l.jsx(Pe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:l.jsx(pp,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Pe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Z=document.createElement("a");Z.href=Ce.getArchiveDownload(t.id),Z.download=`${t.print_name||t.filename}.3mf`,Z.click()},title:"Download",children:l.jsx(ts,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Pe,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>y(!0),title:"Edit",children:l.jsx(dd,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Pe,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:l.jsx(An,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&l.jsx(PUe,{archive:t,onClose:()=>y(!1)}),u&&l.jsx(AUe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&l.jsx(TUe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),p&&l.jsx(fi,{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:()=>{ie.mutate(),x(!1)},onCancel:()=>x(!1)}),W&&l.jsx(fi,{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:()=>{U.mutate(),K(!1)},onCancel:()=>K(!1)}),G&&l.jsx(RUe,{x:G.x,y:G.y,items:Re,onClose:()=>te(null)}),b&&t.timelapse_path&&l.jsx(r7e,{src:Ce.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>E(!1)}),w&&T.length>0&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),l.jsx("button",{onClick:()=>{A(!1),C([])},className:"text-gray-400 hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(Z=>l.jsxs("button",{onClick:()=>ee.mutate(Z.name),disabled:ee.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:[l.jsx(Jm,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-white font-medium truncate",children:Z.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:[ER(Z.size),Z.mtime&&` • ${u9(Z.mtime)}`]})]})]},Z.name))}),l.jsx("div",{className:"p-4 border-t border-gray-700",children:l.jsx(Pe,{variant:"secondary",onClick:()=>{A(!1),C([])},className:"w-full",children:"Cancel"})})]})}),k&&l.jsx(UUe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>F(!1)}),N&&t.photos&&t.photos.length>0&&l.jsx(zUe,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async Z=>{try{await Ce.deleteArchivePhoto(t.id,Z),s.invalidateQueries({queryKey:["archives"]}),o("Photo deleted")}catch{o("Failed to delete photo","error")}}}),I&&l.jsx(t7e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),q&&l.jsx(i7e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),l.jsx("input",{ref:Y,type:"file",accept:".3mf",className:"hidden",onChange:Z=>{const _e=Z.target.files?.[0];_e&&J.mutate(_e),Z.target.value=""}})]})}const l7e=[{id:"all",label:"All Archives",icon:l.jsx(Ele,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:l.jsx(sr,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:l.jsx($r,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:l.jsx($r,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:l.jsx(yp,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:l.jsx(co,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:l.jsx(cd,{className:"w-4 h-4"})}];function c7e(){const t=Mn(),{showToast:e}=Gr(),n=M.useRef(null),[r,i]=M.useState(""),[a,s]=M.useState(null),[o,c]=M.useState(null),[u,d]=M.useState(new Set),[f,g]=M.useState("or"),[p,x]=M.useState(!1),[v,y]=M.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[b,E]=M.useState(null),[w,A]=M.useState(!1),[T,C]=M.useState([]),[k,F]=M.useState(!1),[N,j]=M.useState(new Set),[I,O]=M.useState(!1),[q,R]=M.useState(!1),[W,K]=M.useState(!1),[G,te]=M.useState("grid"),[Y,J]=M.useState("date-desc"),[U,H]=M.useState("all"),[ee,ie]=M.useState(!1),[pe,ue]=M.useState(!1),[be,Re]=M.useState(!1),{data:Z,isLoading:_e}=yt({queryKey:["archives",a],queryFn:()=>Ce.getArchives(a||void 0)}),{data:Le}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:ce}=yt({queryKey:["projects"],queryFn:()=>Ce.getProjects()}),Ie=vt({mutationFn:async he=>(await Promise.all(he.map(Ge=>Ce.deleteArchive(Ge))),he.length),onSuccess:he=>{t.invalidateQueries({queryKey:["archives"]}),j(new Set),e(`${he} archive${he!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});M.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]);const z=new Map(Le?.map(he=>[he.id,he.name])||[]),B=[...new Set(Z?.flatMap(he=>he.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ne=[...new Set(Z?.flatMap(he=>he.filament_color?.split(",")||[]).filter(Boolean)||[])],V=[...new Set(Z?.flatMap(he=>he.tags?.split(",").map(Ge=>Ge.trim())||[]).filter(Boolean)||[])].sort(),Q=Z?.filter(he=>{const Ge=new Date,Ue=new Date(he.created_at);let oe=!0;switch(U){case"recent":oe=Ge.getTime()-Ue.getTime()<1440*60*1e3;break;case"this-week":oe=Ge.getTime()-Ue.getTime()<10080*60*1e3;break;case"this-month":oe=Ue.getMonth()===Ge.getMonth()&&Ue.getFullYear()===Ge.getFullYear();break;case"favorites":oe=he.is_favorite===!0;break;case"failed":oe=he.status==="failed"||he.status==="aborted";break;case"duplicates":oe=he.duplicate_count>0;break}const tt=(he.print_name||he.filename).toLowerCase().includes(r.toLowerCase()),$e=!o||he.filament_type?.split(", ").includes(o),Ye=he.filament_color?.split(",")||[],ut=u.size===0||(f==="or"?Ye.some(ke=>u.has(ke)):[...u].every(ke=>Ye.includes(ke))),fe=U==="favorites"||!p||he.is_favorite,Qe=U==="failed"||!v||he.status!=="failed"&&he.status!=="aborted",ge=he.tags?.split(",").map(ke=>ke.trim())||[],ze=!b||ge.includes(b);return oe&&tt&&$e&&ut&&fe&&Qe&&ze}).sort((he,Ge)=>{switch(Y){case"date-desc":return new Date(Ge.created_at).getTime()-new Date(he.created_at).getTime();case"date-asc":return new Date(he.created_at).getTime()-new Date(Ge.created_at).getTime();case"name-asc":return(he.print_name||he.filename).localeCompare(Ge.print_name||Ge.filename);case"name-desc":return(Ge.print_name||Ge.filename).localeCompare(he.print_name||he.filename);case"size-desc":return Ge.file_size-he.file_size;case"size-asc":return he.file_size-Ge.file_size;default:return 0}}),se=I||N.size>0,Me=he=>{j(Ge=>{const Ue=new Set(Ge);return Ue.has(he)?Ue.delete(he):Ue.add(he),Ue})},Ae=()=>{Q&&j(new Set(Q.map(he=>he.id)))},Se=()=>{j(new Set),O(!1)},$=he=>{d(Ge=>{const Ue=new Set(Ge);return Ue.has(he)?Ue.delete(he):Ue.add(he),Ue})},L=()=>{d(new Set)},re=()=>{i(""),s(null),c(null),x(!1),y(!1),E(null)},ye=r||a||o||p||v||b,we=M.useCallback(he=>{he.preventDefault(),he.dataTransfer.types.includes("Files")&&F(!0)},[]),xe=M.useCallback(he=>{he.preventDefault(),he.currentTarget===he.target&&F(!1)},[]),rt=M.useCallback(he=>{he.preventDefault(),F(!1);const Ge=Array.from(he.dataTransfer.files).filter(Ue=>Ue.name.endsWith(".3mf"));Ge.length>0?(C(Ge),A(!0)):he.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),He=M.useCallback(he=>{const Ge=he.target;if(Ge.tagName==="INPUT"||Ge.tagName==="TEXTAREA"||Ge.isContentEditable){he.key==="Escape"&&Ge.blur();return}switch(he.key){case"/":he.preventDefault(),n.current?.focus();break;case"u":case"U":!he.metaKey&&!he.ctrlKey&&(he.preventDefault(),A(!0));break;case"Escape":se&&Se();break}},[se]);return M.useEffect(()=>(document.addEventListener("keydown",He),()=>document.removeEventListener("keydown",He)),[He]),l.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:we,onDragLeave:xe,onDrop:rt,children:[k&&l.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[l.jsx(Ya,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),l.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),se&&l.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:[l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:Se,children:[l.jsx(Wt,{className:"w-4 h-4"}),"Close"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("span",{className:"text-white font-medium",children:[N.size," selected"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsx(Pe,{variant:"secondary",size:"sm",onClick:Ae,children:"Select All"}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>K(!0),children:[l.jsx(vp,{className:"w-4 h-4"}),"Tags"]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>{const he=Array.from(N);Promise.all(he.map(Ge=>Ce.toggleFavorite(Ge))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${he.length} archive${he.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[l.jsx(yp,{className:"w-4 h-4"}),"Favorite"]}),l.jsxs(Pe,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>R(!0),children:[l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]}),l.jsxs("div",{className:"flex items-center justify-between mb-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),l.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:U,onChange:he=>H(he.target.value),children:l7e.map(he=>l.jsx("option",{value:he.id,children:he.label},he.id))})]}),l.jsxs("p",{className:"text-bambu-gray",children:[Q?.length||0," of ",Z?.length||0," prints"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsxs(Pe,{variant:"secondary",onClick:()=>ie(!ee),disabled:pe,children:[pe?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(P1,{className:"w-4 h-4"}),"Export"]}),ee&&l.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{ie(!1),ue(!0);try{const{blob:he,filename:Ge}=await Ce.exportArchives({format:"csv",printerId:a||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Ue=URL.createObjectURL(he),oe=document.createElement("a");oe.href=Ue,oe.download=Ge,oe.click(),URL.revokeObjectURL(Ue),e("Export downloaded")}catch{e("Export failed","error")}finally{ue(!1)}},children:[l.jsx(ws,{className:"w-4 h-4"}),"Export as CSV"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{ie(!1),ue(!0);try{const{blob:he,filename:Ge}=await Ce.exportArchives({format:"xlsx",printerId:a||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Ue=URL.createObjectURL(he),oe=document.createElement("a");oe.href=Ue,oe.download=Ge,oe.click(),URL.revokeObjectURL(Ue),e("Export downloaded")}catch{e("Export failed","error")}finally{ue(!1)}},children:[l.jsx(P1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),N.size>=2&&N.size<=5&&l.jsxs(Pe,{variant:"secondary",onClick:()=>Re(!0),children:[l.jsx(ep,{className:"w-4 h-4"}),"Compare (",N.size,")"]}),!se&&l.jsxs(Pe,{variant:"secondary",onClick:()=>O(!0),children:[l.jsx(Kh,{className:"w-4 h-4"}),"Select"]}),l.jsxs(Pe,{onClick:()=>A(!0),children:[l.jsx(Ya,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),l.jsx(Mt,{className:"mb-6",children:l.jsxs(Nt,{className:"py-4",children:[l.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[l.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[l.jsx(Rc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:he=>i(he.target.value)})]}),l.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(XR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:he=>s(he.target.value?Number(he.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),Le?.map(he=>l.jsx("option",{value:he.id,children:he.name},he.id))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(Pc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.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:he=>c(he.target.value||null),children:[l.jsx("option",{value:"",children:"All Materials"}),B.map(he=>l.jsx("option",{value:he,children:he},he))]})]}),l.jsxs("button",{onClick:()=>x(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[l.jsx(yp,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),l.jsxs("button",{onClick:()=>y(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[l.jsx(co,{className:"w-4 h-4 "}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),V.length>0&&l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(vp,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.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:b||"",onChange:he=>E(he.target.value||null),children:[l.jsx("option",{value:"",children:"All Tags"}),V.map(he=>l.jsx("option",{value:he,children:he},he))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(ooe,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.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:he=>J(he.target.value),children:[l.jsx("option",{value:"date-desc",children:"Newest first"}),l.jsx("option",{value:"date-asc",children:"Oldest first"}),l.jsx("option",{value:"name-asc",children:"Name A-Z"}),l.jsx("option",{value:"name-desc",children:"Name Z-A"}),l.jsx("option",{value:"size-desc",children:"Largest first"}),l.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),l.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[l.jsx("button",{className:`p-2 ${G==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>te("grid"),title:"Grid view",children:l.jsx(gG,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${G==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>te("list"),title:"List view",children:l.jsx(QR,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${G==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>te("calendar"),title:"Calendar view",children:l.jsx(voe,{className:"w-4 h-4"})})]})]}),ye&&l.jsxs(Pe,{variant:"ghost",size:"sm",onClick:re,className:"text-bambu-gray hover:text-white",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Reset"]})]}),ne.length>0&&l.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&l.jsx("button",{onClick:()=>g(he=>he==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),l.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ne.map(he=>l.jsx("button",{onClick:()=>$(he),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(he)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:he},title:he},he))}),u.size>0&&l.jsxs("button",{onClick:L,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[l.jsx(Wt,{className:"w-3 h-3"}),"Clear"]})]})]})}),_e?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):Q?.length===0?l.jsx(Mt,{children:l.jsxs(Nt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):G==="calendar"?l.jsx(Mt,{className:"p-6",children:l.jsx(FUe,{archives:Q||[],onArchiveClick:he=>{i(he.print_name||he.filename),te("grid")}})}):G==="grid"?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Q?.map(he=>l.jsx(o7e,{archive:he,printerName:he.printer_id?z.get(he.printer_id)||"Unknown":"No Printer",isSelected:N.has(he.id),onSelect:Me,selectionMode:se,projects:ce},he.id))}):G==="list"?l.jsx(Mt,{children:l.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[l.jsx("div",{className:"col-span-1"}),l.jsx("div",{className:"col-span-4",children:"Name"}),l.jsx("div",{className:"col-span-2",children:"Printer"}),l.jsx("div",{className:"col-span-2",children:"Date"}),l.jsx("div",{className:"col-span-1",children:"Size"}),l.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),Q?.map(he=>l.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${N.has(he.id)?"bg-bambu-green/10":""}`,children:[l.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[se&&l.jsx("button",{onClick:()=>Me(he.id),children:N.has(he.id)?l.jsx(Kh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(bp,{className:"w-4 h-4 text-bambu-gray"})}),he.thumbnail_path?l.jsx("img",{src:Ce.getArchiveThumbnail(he.id),alt:"",className:"w-10 h-10 object-cover rounded"}):l.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:l.jsx(bb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),l.jsxs("div",{className:"col-span-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white text-sm truncate",children:he.print_name||he.filename}),he.timelapse_path&&l.jsx("span",{title:"Has timelapse",children:l.jsx(Jm,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),he.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:he.filament_type}),he.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:he.filament_color.split(",").map((Ge,Ue)=>l.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Ge},title:Ge},Ue))})]})]}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:he.printer_id?z.get(he.printer_id)||"Unknown":"No Printer"}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(he.created_at).toLocaleDateString()}),l.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:ER(he.file_size)}),l.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[l.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>{const Ge=he.print_name||he.filename||"model",Ue=`${window.location.origin}${Ce.getArchiveForSlicer(he.id,Ge)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Ue)}`},title:"Open in Slicer",children:l.jsx(Cs,{className:"w-4 h-4"})}),he.makerworld_url&&l.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>window.open(he.makerworld_url,"_blank"),title:"MakerWorld",children:l.jsx(S0,{className:"w-4 h-4"})}),l.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>{const Ge=document.createElement("a");Ge.href=Ce.getArchiveDownload(he.id),Ge.download=`${he.print_name||he.filename}.3mf`,Ge.click()},title:"Download",children:l.jsx(ts,{className:"w-4 h-4"})})]})]},he.id))]})}):null,w&&l.jsx(CUe,{onClose:()=>{A(!1),C([])},initialFiles:T}),q&&l.jsx(fi,{title:"Delete Archives",message:`Are you sure you want to delete ${N.size} archive${N.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${N.size}`,variant:"danger",onConfirm:()=>{Ie.mutate(Array.from(N)),R(!1)},onCancel:()=>R(!1)}),W&&l.jsx(jUe,{selectedIds:Array.from(N),existingTags:V,onClose:()=>K(!1)}),be&&N.size>=2&&N.size<=5&&l.jsx(a7e,{archiveIds:Array.from(N),onClose:()=>{Re(!1),j(new Set),O(!1)}})]})}function u7e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const fE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function gg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function vL(t){return"nodeType"in t}function as(t){var e,n;return t?gg(t)?t:vL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function _L(t){const{Document:e}=as(t);return t instanceof e}function ny(t){return gg(t)?!1:t instanceof as(t).HTMLElement}function Wee(t){return t instanceof as(t).SVGElement}function xg(t){return t?gg(t)?t.document:vL(t)?_L(t)?t:ny(t)||Wee(t)?t.ownerDocument:document:document:document}const _l=fE?M.useLayoutEffect:M.useEffect;function wL(t){const e=M.useRef(t);return _l(()=>{e.current=t}),M.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 d7e(){const t=M.useRef(null),e=M.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=M.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function ub(t,e){e===void 0&&(e=[t]);const n=M.useRef(t);return _l(()=>{n.current!==t&&(n.current=t)},e),n}function ry(t,e){const n=M.useRef();return M.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function DS(t){const e=wL(t),n=M.useRef(null),r=M.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function AR(t){const e=M.useRef();return M.useEffect(()=>{e.current=t},[t]),e.current}let hk={};function iy(t,e){return M.useMemo(()=>{if(e)return e;const n=hk[t]==null?0:hk[t]+1;return hk[t]=n,t+"-"+n},[t,e])}function qee(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,s)=>{const o=Object.entries(s);for(const[c,u]of o){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const fp=qee(1),db=qee(-1);function h7e(t){return"clientX"in t&&"clientY"in t}function SL(t){if(!t)return!1;const{KeyboardEvent:e}=as(t.target);return e&&t instanceof e}function f7e(t){if(!t)return!1;const{TouchEvent:e}=as(t.target);return e&&t instanceof e}function TR(t){if(f7e(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 h7e(t)?{x:t.clientX,y:t.clientY}:null}const Wp=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[Wp.Translate.toString(t),Wp.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),d9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function m7e(t){return t.matches(d9)?t:t.querySelector(d9)}const p7e={display:"none"};function g7e(t){let{id:e,value:n}=t;return gr.createElement("div",{id:e,style:p7e},n)}function x7e(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 gr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function b7e(){const[t,e]=M.useState("");return{announce:M.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Kee=M.createContext(null);function y7e(t){const e=M.useContext(Kee);M.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function v7e(){const[t]=M.useState(()=>new Set),e=M.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[M.useCallback(r=>{let{type:i,event:a}=r;t.forEach(s=>{var o;return(o=s[i])==null?void 0:o.call(s,a)})},[t]),e]}const _7e={draggable:`
  8221. To pick up a draggable item, press the space bar.
  8222. While dragging, use the arrow keys to move the item.
  8223. Press space again to drop the item in its new position, or press escape to cancel.
  8224. `},w7e={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 S7e(t){let{announcements:e=w7e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=_7e}=t;const{announce:a,announcement:s}=b7e(),o=iy("DndLiveRegion"),[c,u]=M.useState(!1);if(M.useEffect(()=>{u(!0)},[]),y7e(M.useMemo(()=>({onDragStart(f){let{active:g}=f;a(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:p}=f;e.onDragMove&&a(e.onDragMove({active:g,over:p}))},onDragOver(f){let{active:g,over:p}=f;a(e.onDragOver({active:g,over:p}))},onDragEnd(f){let{active:g,over:p}=f;a(e.onDragEnd({active:g,over:p}))},onDragCancel(f){let{active:g,over:p}=f;a(e.onDragCancel({active:g,over:p}))}}),[a,e])),!c)return null;const d=gr.createElement(gr.Fragment,null,gr.createElement(g7e,{id:r,value:i.draggable}),gr.createElement(x7e,{id:o,announcement:s}));return n?mc.createPortal(d,n):d}var di;(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"})(di||(di={}));function OS(){}function LS(t,e){return M.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Xee(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const zo=Object.freeze({x:0,y:0});function Yee(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Zee(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function M7e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function h9(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 Qee(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function f9(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 Jee=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=f9(e,e.left,e.top),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=Yee(f9(c),i);a.push({id:o,data:{droppableContainer:s,value:u}})}}return a.sort(Zee)},E7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=h9(e),a=[];for(const s of r){const{id:o}=s,c=n.get(o);if(c){const u=h9(c),d=i.reduce((g,p,x)=>g+Yee(u[x],p),0),f=Number((d/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(Zee)};function A7e(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=i-r,o=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=s*o,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const T7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,o=n.get(s);if(o){const c=A7e(o,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(M7e)};function C7e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function ete(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:zo}function N7e(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((s,o)=>({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const k7e=N7e(1);function P7e(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 R7e(t,e,n){const r=P7e(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:o}=r,c=t.left-s-(1-i)*parseFloat(n),u=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const j7e={ignoreTransform:!1};function bg(t,e){e===void 0&&(e=j7e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=as(t).getComputedStyle(t);u&&(n=R7e(n,u,d))}const{top:r,left:i,width:a,height:s,bottom:o,right:c}=n;return{top:r,left:i,width:a,height:s,bottom:o,right:c}}function m9(t){return bg(t,{ignoreTransform:!0})}function D7e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function O7e(t,e){return e===void 0&&(e=as(t).getComputedStyle(t)),e.position==="fixed"}function L7e(t,e){e===void 0&&(e=as(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function mE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(_L(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!ny(i)||Wee(i)||n.includes(i))return n;const a=as(t).getComputedStyle(i);return i!==t&&L7e(i,a)&&n.push(i),O7e(i,a)?n:r(i.parentNode)}return t?r(t):n}function tte(t){const[e]=mE(t,1);return e??null}function fk(t){return!fE||!t?null:gg(t)?t:vL(t)?_L(t)||t===xg(t).scrollingElement?window:ny(t)?t:null:null}function nte(t){return gg(t)?t.scrollX:t.scrollLeft}function rte(t){return gg(t)?t.scrollY:t.scrollTop}function CR(t){return{x:nte(t),y:rte(t)}}var Di;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Di||(Di={}));function ite(t){return!fE||!t?!1:t===document.scrollingElement}function ate(t){const e={x:0,y:0},n=ite(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:o,maxScroll:r,minScroll:e}}const I7e={x:.2,y:.2};function F7e(t,e,n,r,i){let{top:a,left:s,right:o,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=I7e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=ate(t),p={x:0,y:0},x={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(p.y=Di.Backward,x.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(p.y=Di.Forward,x.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!g&&o>=e.right-v.width?(p.x=Di.Forward,x.x=r*Math.abs((e.right-v.width-o)/v.width)):!f&&s<=e.left+v.width&&(p.x=Di.Backward,x.x=r*Math.abs((e.left+v.width-s)/v.width)),{direction:p,speed:x}}function U7e(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function ste(t){return t.reduce((e,n)=>fp(e,CR(n)),zo)}function z7e(t){return t.reduce((e,n)=>e+nte(n),0)}function B7e(t){return t.reduce((e,n)=>e+rte(n),0)}function H7e(t,e){if(e===void 0&&(e=bg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);tte(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const $7e=[["x",["left","right"],z7e],["y",["top","bottom"],B7e]];class ML{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=mE(n),i=ste(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of $7e)for(const c of s)Object.defineProperty(this,c,{get:()=>{const u=o(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class m0{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 V7e(t){const{EventTarget:e}=as(t);return t instanceof e?t:xg(t)}function mk(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 Ys;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Ys||(Ys={}));function p9(t){t.preventDefault()}function G7e(t){t.stopPropagation()}var Sn;(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"})(Sn||(Sn={}));const ote={start:[Sn.Space,Sn.Enter],cancel:[Sn.Esc],end:[Sn.Space,Sn.Enter,Sn.Tab]},W7e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Sn.Right:return{...n,x:n.x+25};case Sn.Left:return{...n,x:n.x-25};case Sn.Down:return{...n,y:n.y+25};case Sn.Up:return{...n,y:n.y-25}}};class pE{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 m0(xg(n)),this.windowListeners=new m0(as(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ys.Resize,this.handleCancel),this.windowListeners.add(Ys.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ys.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&H7e(r),n(zo)}handleKeyDown(e){if(SL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=ote,coordinateGetter:s=W7e,scrollBehavior:o="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:zo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=s(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=db(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const v of x){const y=e.code,{isTop:b,isRight:E,isLeft:w,isBottom:A,maxScroll:T,minScroll:C}=ate(v),k=U7e(v),F={x:Math.min(y===Sn.Right?k.right-k.width/2:k.right,Math.max(y===Sn.Right?k.left:k.left+k.width/2,f.x)),y:Math.min(y===Sn.Down?k.bottom-k.height/2:k.bottom,Math.max(y===Sn.Down?k.top:k.top+k.height/2,f.y))},N=y===Sn.Right&&!E||y===Sn.Left&&!w,j=y===Sn.Down&&!A||y===Sn.Up&&!b;if(N&&F.x!==f.x){const I=v.scrollLeft+g.x,O=y===Sn.Right&&I<=T.x||y===Sn.Left&&I>=C.x;if(O&&!g.y){v.scrollTo({left:I,behavior:o});return}O?p.x=v.scrollLeft-I:p.x=y===Sn.Right?v.scrollLeft-T.x:v.scrollLeft-C.x,p.x&&v.scrollBy({left:-p.x,behavior:o});break}else if(j&&F.y!==f.y){const I=v.scrollTop+g.y,O=y===Sn.Down&&I<=T.y||y===Sn.Up&&I>=C.y;if(O&&!g.x){v.scrollTo({top:I,behavior:o});return}O?p.y=v.scrollTop-I:p.y=y===Sn.Down?v.scrollTop-T.y:v.scrollTop-C.y,p.y&&v.scrollBy({top:-p.y,behavior:o});break}}this.handleMove(e,fp(db(f,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}pE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=ote,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function g9(t){return!!(t&&"distance"in t)}function x9(t){return!!(t&&"delay"in t)}class EL{constructor(e,n,r){var i;r===void 0&&(r=V7e(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=xg(s),this.documentListeners=new m0(this.document),this.listeners=new m0(r),this.windowListeners=new m0(as(s)),this.initialCoordinates=(i=TR(a))!=null?i:zo,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(Ys.Resize,this.handleCancel),this.windowListeners.add(Ys.DragStart,p9),this.windowListeners.add(Ys.VisibilityChange,this.handleCancel),this.windowListeners.add(Ys.ContextMenu,p9),this.documentListeners.add(Ys.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(x9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(g9(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(Ys.Click,G7e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ys.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!i)return;const c=(n=TR(e))!=null?n:zo,u=db(i,c);if(!r&&o){if(g9(o)){if(o.tolerance!=null&&mk(u,o.tolerance))return this.handleCancel();if(mk(u,o.distance))return this.handleStart()}if(x9(o)&&mk(u,o.tolerance))return this.handleCancel();this.handlePending(o,u);return}e.cancelable&&e.preventDefault(),s(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Sn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const q7e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class gE extends EL{constructor(e){const{event:n}=e,r=xg(n.target);super(e,q7e,r)}}gE.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 K7e={move:{name:"mousemove"},end:{name:"mouseup"}};var NR;(function(t){t[t.RightClick=2]="RightClick"})(NR||(NR={}));class X7e extends EL{constructor(e){super(e,K7e,xg(e.event.target))}}X7e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===NR.RightClick?!1:(r?.({event:n}),!0)}}];const pk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Y7e extends EL{constructor(e){super(e,pk)}static setup(){return window.addEventListener(pk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(pk.move.name,e)};function e(){}}}Y7e.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 p0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(p0||(p0={}));var IS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(IS||(IS={}));function Z7e(t){let{acceleration:e,activator:n=p0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:o=IS.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const p=J7e({delta:f,disabled:!a}),[x,v]=d7e(),y=M.useRef({x:0,y:0}),b=M.useRef({x:0,y:0}),E=M.useMemo(()=>{switch(n){case p0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case p0.DraggableRect:return i}},[n,i,c]),w=M.useRef(null),A=M.useCallback(()=>{const C=w.current;if(!C)return;const k=y.current.x*b.current.x,F=y.current.y*b.current.y;C.scrollBy(k,F)},[]),T=M.useMemo(()=>o===IS.TreeOrder?[...u].reverse():u,[o,u]);M.useEffect(()=>{if(!a||!u.length||!E){v();return}for(const C of T){if(r?.(C)===!1)continue;const k=u.indexOf(C),F=d[k];if(!F)continue;const{direction:N,speed:j}=F7e(C,F,E,e,g);for(const I of["x","y"])p[I][N[I]]||(j[I]=0,N[I]=0);if(j.x>0||j.y>0){v(),w.current=C,x(A,s),y.current=j,b.current=N;return}}y.current={x:0,y:0},b.current={x:0,y:0},v()},[e,A,r,v,a,s,JSON.stringify(E),JSON.stringify(p),x,u,T,d,JSON.stringify(g)])}const Q7e={x:{[Di.Backward]:!1,[Di.Forward]:!1},y:{[Di.Backward]:!1,[Di.Forward]:!1}};function J7e(t){let{delta:e,disabled:n}=t;const r=AR(e);return ry(i=>{if(n||!r||!i)return Q7e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Di.Backward]:i.x[Di.Backward]||a.x===-1,[Di.Forward]:i.x[Di.Forward]||a.x===1},y:{[Di.Backward]:i.y[Di.Backward]||a.y===-1,[Di.Forward]:i.y[Di.Forward]||a.y===1}}},[n,e,r])}function e9e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ry(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function t9e(t,e){return M.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...a]},[]),[t,e])}var hb;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(hb||(hb={}));var kR;(function(t){t.Optimized="optimized"})(kR||(kR={}));const b9=new Map;function n9e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=M.useState(null),{frequency:o,measure:c,strategy:u}=i,d=M.useRef(t),f=y(),g=ub(f),p=M.useCallback(function(b){b===void 0&&(b=[]),!g.current&&s(E=>E===null?b:E.concat(b.filter(w=>!E.includes(w))))},[g]),x=M.useRef(null),v=ry(b=>{if(f&&!n)return b9;if(!b||b===b9||d.current!==t||a!=null){const E=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){E.set(w.id,w.rect.current);continue}const A=w.node.current,T=A?new ML(c(A),A):null;w.rect.current=T,T&&E.set(w.id,T)}return E}return b},[t,a,n,f,c]);return M.useEffect(()=>{d.current=t},[t]),M.useEffect(()=>{f||p()},[n,f]),M.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),M.useEffect(()=>{f||typeof o!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},o))},[o,f,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:a!=null};function y(){switch(u){case hb.Always:return!1;case hb.BeforeDragging:return n;default:return!n}}}function lte(t,e){return ry(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function r9e(t,e){return lte(t,e)}function i9e(t){let{callback:e,disabled:n}=t;const r=wL(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function xE(t){let{callback:e,disabled:n}=t;const r=wL(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function a9e(t){return new ML(bg(t),t)}function y9(t,e,n){e===void 0&&(e=a9e);const[r,i]=M.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const s=i9e({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),o=xE({callback:a});return _l(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),r}function s9e(t){const e=lte(t);return ete(t,e)}const v9=[];function o9e(t){const e=M.useRef(t),n=ry(r=>t?r&&r!==v9&&t&&e.current&&t.parentNode===e.current.parentNode?r:mE(t):v9,[t]);return M.useEffect(()=>{e.current=t},[t]),n}function l9e(t){const[e,n]=M.useState(null),r=M.useRef(t),i=M.useCallback(a=>{const s=fk(a.target);s&&n(o=>o?(o.set(s,CR(s)),new Map(o)):null)},[]);return M.useEffect(()=>{const a=r.current;if(t!==a){s(a);const o=t.map(c=>{const u=fk(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,CR(u)]):null}).filter(c=>c!=null);n(o.length?new Map(o):null),r.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(c=>{const u=fk(c);u?.removeEventListener("scroll",i)})}},[i,t]),M.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>fp(a,s),zo):ste(t):zo,[t,e])}function _9(t,e){e===void 0&&(e=[]);const n=M.useRef(null);return M.useEffect(()=>{n.current=null},e),M.useEffect(()=>{const r=t!==zo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?db(t,n.current):zo}function c9e(t){M.useEffect(()=>{if(!fE)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 u9e(t,e){return M.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function cte(t){return M.useMemo(()=>t?D7e(t):null,[t])}const w9=[];function d9e(t,e){e===void 0&&(e=bg);const[n]=t,r=cte(n?as(n):null),[i,a]=M.useState(w9);function s(){a(()=>t.length?t.map(c=>ite(c)?r:new ML(e(c),c)):w9)}const o=xE({callback:s});return _l(()=>{o?.disconnect(),s(),t.forEach(c=>o?.observe(c))},[t]),i}function h9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return ny(e)?e:t}function f9e(t){let{measure:e}=t;const[n,r]=M.useState(null),i=M.useCallback(u=>{for(const{target:d}of u)if(ny(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=xE({callback:i}),s=M.useCallback(u=>{const d=h9e(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[o,c]=DS(s);return M.useMemo(()=>({nodeRef:o,rect:n,setRef:c}),[n,o,c])}const m9e=[{sensor:gE,options:{}},{sensor:pE,options:{}}],p9e={current:{}},S1={draggable:{measure:m9},droppable:{measure:m9,strategy:hb.WhileDragging,frequency:kR.Optimized},dragOverlay:{measure:bg}};class g0 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 g9e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new g0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:OS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:S1,measureDroppableContainers:OS,windowRect:null,measuringScheduled:!1},x9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:OS,draggableNodes:new Map,over:null,measureDroppableContainers:OS},bE=M.createContext(x9e),ute=M.createContext(g9e);function b9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new g0}}}function y9e(t,e){switch(e.type){case di.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case di.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 di.DragEnd:case di.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case di.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new g0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case di.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const s=new g0(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case di.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new g0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function v9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=M.useContext(bE),a=AR(r),s=AR(n?.id);return M.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!SL(a)||document.activeElement===a.target)return;const o=i.get(s);if(!o)return;const{activatorNode:c,node:u}=o;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=m7e(d);if(f){f.focus();break}}})}},[r,e,i,s,a]),null}function _9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function w9e(t){return M.useMemo(()=>({draggable:{...S1.draggable,...t?.draggable},droppable:{...S1.droppable,...t?.droppable},dragOverlay:{...S1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function S9e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=M.useRef(!1),{x:s,y:o}=typeof i=="boolean"?{x:i,y:i}:i;_l(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=ete(d,r);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=tte(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,s,o,r,n])}const dte=M.createContext({...zo,scaleX:1,scaleY:1});var Bu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Bu||(Bu={}));const hte=M.memo(function(e){var n,r,i,a;let{id:s,accessibility:o,autoScroll:c=!0,children:u,sensors:d=m9e,collisionDetection:f=T7e,measuring:g,modifiers:p,...x}=e;const v=M.useReducer(y9e,void 0,b9e),[y,b]=v,[E,w]=v7e(),[A,T]=M.useState(Bu.Uninitialized),C=A===Bu.Initialized,{draggable:{active:k,nodes:F,translate:N},droppable:{containers:j}}=y,I=k!=null?F.get(k):null,O=M.useRef({initial:null,translated:null}),q=M.useMemo(()=>{var ze;return k!=null?{id:k,data:(ze=I?.data)!=null?ze:p9e,rect:O}:null},[k,I]),R=M.useRef(null),[W,K]=M.useState(null),[G,te]=M.useState(null),Y=ub(x,Object.values(x)),J=iy("DndDescribedBy",s),U=M.useMemo(()=>j.getEnabled(),[j]),H=w9e(g),{droppableRects:ee,measureDroppableContainers:ie,measuringScheduled:pe}=n9e(U,{dragging:C,dependencies:[N.x,N.y],config:H.droppable}),ue=e9e(F,k),be=M.useMemo(()=>G?TR(G):null,[G]),Re=ge(),Z=r9e(ue,H.draggable.measure);S9e({activeNode:k!=null?F.get(k):null,config:Re.layoutShiftCompensation,initialRect:Z,measure:H.draggable.measure});const _e=y9(ue,H.draggable.measure,Z),Le=y9(ue?ue.parentElement:null),ce=M.useRef({activatorEvent:null,active:null,activeNode:ue,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:F,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ie=j.getNodeFor((n=ce.current.over)==null?void 0:n.id),z=f9e({measure:H.dragOverlay.measure}),B=(r=z.nodeRef.current)!=null?r:ue,ne=C?(i=z.rect)!=null?i:_e:null,V=!!(z.nodeRef.current&&z.rect),Q=s9e(V?null:_e),se=cte(B?as(B):null),Me=o9e(C?Ie??ue:null),Ae=d9e(Me),Se=_9e(p,{transform:{x:N.x-Q.x,y:N.y-Q.y,scaleX:1,scaleY:1},activatorEvent:G,active:q,activeNodeRect:_e,containerNodeRect:Le,draggingNodeRect:ne,over:ce.current.over,overlayNodeRect:z.rect,scrollableAncestors:Me,scrollableAncestorRects:Ae,windowRect:se}),$=be?fp(be,N):null,L=l9e(Me),re=_9(L),ye=_9(L,[_e]),we=fp(Se,re),xe=ne?k7e(ne,Se):null,rt=q&&xe?f({active:q,collisionRect:xe,droppableRects:ee,droppableContainers:U,pointerCoordinates:$}):null,He=Qee(rt,"id"),[he,Ge]=M.useState(null),Ue=V?Se:fp(Se,ye),oe=C7e(Ue,(a=he?.rect)!=null?a:null,_e),tt=M.useRef(null),$e=M.useCallback((ze,ke)=>{let{sensor:ve,options:de}=ke;if(R.current==null)return;const ot=F.get(R.current);if(!ot)return;const xt=ze.nativeEvent,Et=new ve({active:R.current,activeNode:ot,event:xt,options:de,context:ce,onAbort(Ot){if(!F.get(Ot))return;const{onDragAbort:On}=Y.current,Mi={id:Ot};On?.(Mi),E({type:"onDragAbort",event:Mi})},onPending(Ot,Vt,On,Mi){if(!F.get(Ot))return;const{onDragPending:Ei}=Y.current,zi={id:Ot,constraint:Vt,initialCoordinates:On,offset:Mi};Ei?.(zi),E({type:"onDragPending",event:zi})},onStart(Ot){const Vt=R.current;if(Vt==null)return;const On=F.get(Vt);if(!On)return;const{onDragStart:Mi}=Y.current,si={activatorEvent:xt,active:{id:Vt,data:On.data,rect:O}};mc.unstable_batchedUpdates(()=>{Mi?.(si),T(Bu.Initializing),b({type:di.DragStart,initialCoordinates:Ot,active:Vt}),E({type:"onDragStart",event:si}),K(tt.current),te(xt)})},onMove(Ot){b({type:di.DragMove,coordinates:Ot})},onEnd:Qt(di.DragEnd),onCancel:Qt(di.DragCancel)});tt.current=Et;function Qt(Ot){return async function(){const{active:On,collisions:Mi,over:si,scrollAdjustedTranslate:Ei}=ce.current;let zi=null;if(On&&Ei){const{cancelDrop:ra}=Y.current;zi={activatorEvent:xt,active:On,collisions:Mi,delta:Ei,over:si},Ot===di.DragEnd&&typeof ra=="function"&&await Promise.resolve(ra(zi))&&(Ot=di.DragCancel)}R.current=null,mc.unstable_batchedUpdates(()=>{b({type:Ot}),T(Bu.Uninitialized),Ge(null),K(null),te(null),tt.current=null;const ra=Ot===di.DragEnd?"onDragEnd":"onDragCancel";if(zi){const Wr=Y.current[ra];Wr?.(zi),E({type:ra,event:zi})}})}}},[F]),Ye=M.useCallback((ze,ke)=>(ve,de)=>{const ot=ve.nativeEvent,xt=F.get(de);if(R.current!==null||!xt||ot.dndKit||ot.defaultPrevented)return;const Et={active:xt};ze(ve,ke.options,Et)===!0&&(ot.dndKit={capturedBy:ke.sensor},R.current=de,$e(ve,ke))},[F,$e]),ut=t9e(d,Ye);c9e(d),_l(()=>{_e&&A===Bu.Initializing&&T(Bu.Initialized)},[_e,A]),M.useEffect(()=>{const{onDragMove:ze}=Y.current,{active:ke,activatorEvent:ve,collisions:de,over:ot}=ce.current;if(!ke||!ve)return;const xt={active:ke,activatorEvent:ve,collisions:de,delta:{x:we.x,y:we.y},over:ot};mc.unstable_batchedUpdates(()=>{ze?.(xt),E({type:"onDragMove",event:xt})})},[we.x,we.y]),M.useEffect(()=>{const{active:ze,activatorEvent:ke,collisions:ve,droppableContainers:de,scrollAdjustedTranslate:ot}=ce.current;if(!ze||R.current==null||!ke||!ot)return;const{onDragOver:xt}=Y.current,Et=de.get(He),Qt=Et&&Et.rect.current?{id:Et.id,rect:Et.rect.current,data:Et.data,disabled:Et.disabled}:null,Ot={active:ze,activatorEvent:ke,collisions:ve,delta:{x:ot.x,y:ot.y},over:Qt};mc.unstable_batchedUpdates(()=>{Ge(Qt),xt?.(Ot),E({type:"onDragOver",event:Ot})})},[He]),_l(()=>{ce.current={activatorEvent:G,active:q,activeNode:ue,collisionRect:xe,collisions:rt,droppableRects:ee,draggableNodes:F,draggingNode:B,draggingNodeRect:ne,droppableContainers:j,over:he,scrollableAncestors:Me,scrollAdjustedTranslate:we},O.current={initial:ne,translated:xe}},[q,ue,rt,xe,F,B,ne,ee,j,he,Me,we]),Z7e({...Re,delta:N,draggingRect:xe,pointerCoordinates:$,scrollableAncestors:Me,scrollableAncestorRects:Ae});const fe=M.useMemo(()=>({active:q,activeNode:ue,activeNodeRect:_e,activatorEvent:G,collisions:rt,containerNodeRect:Le,dragOverlay:z,draggableNodes:F,droppableContainers:j,droppableRects:ee,over:he,measureDroppableContainers:ie,scrollableAncestors:Me,scrollableAncestorRects:Ae,measuringConfiguration:H,measuringScheduled:pe,windowRect:se}),[q,ue,_e,G,rt,Le,z,F,j,ee,he,ie,Me,Ae,H,pe,se]),Qe=M.useMemo(()=>({activatorEvent:G,activators:ut,active:q,activeNodeRect:_e,ariaDescribedById:{draggable:J},dispatch:b,draggableNodes:F,over:he,measureDroppableContainers:ie}),[G,ut,q,_e,b,J,F,he,ie]);return gr.createElement(Kee.Provider,{value:w},gr.createElement(bE.Provider,{value:Qe},gr.createElement(ute.Provider,{value:fe},gr.createElement(dte.Provider,{value:oe},u)),gr.createElement(v9e,{disabled:o?.restoreFocus===!1})),gr.createElement(S7e,{...o,hiddenTextDescribedById:J}));function ge(){const ze=W?.autoScrollEnabled===!1,ke=typeof c=="object"?c.enabled===!1:c===!1,ve=C&&!ze&&!ke;return typeof c=="object"?{...c,enabled:ve}:{enabled:ve}}}),M9e=M.createContext(null),S9="button",E9e="Draggable";function A9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=iy(E9e),{activators:s,activatorEvent:o,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=M.useContext(bE),{role:p=S9,roleDescription:x="draggable",tabIndex:v=0}=i??{},y=c?.id===e,b=M.useContext(y?dte:M9e),[E,w]=DS(),[A,T]=DS(),C=u9e(s,e),k=ub(n);_l(()=>(f.set(e,{id:e,key:a,node:E,activatorNode:A,data:k}),()=>{const N=f.get(e);N&&N.key===a&&f.delete(e)}),[f,e]);const F=M.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":y&&p===S9?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,v,y,x,d.draggable]);return{active:c,activatorEvent:o,activeNodeRect:u,attributes:F,isDragging:y,listeners:r?void 0:C,node:E,over:g,setNodeRef:w,setActivatorNodeRef:T,transform:b}}function T9e(){return M.useContext(ute)}const C9e="Droppable",N9e={timeout:25};function k9e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=iy(C9e),{active:s,dispatch:o,over:c,measureDroppableContainers:u}=M.useContext(bE),d=M.useRef({disabled:n}),f=M.useRef(!1),g=M.useRef(null),p=M.useRef(null),{disabled:x,updateMeasurementsFor:v,timeout:y}={...N9e,...i},b=ub(v??r),E=M.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(b.current)?b.current:[b.current]),p.current=null},y)},[y]),w=xE({callback:E,disabled:x||!s}),A=M.useCallback((F,N)=>{w&&(N&&(w.unobserve(N),f.current=!1),F&&w.observe(F))},[w]),[T,C]=DS(A),k=ub(e);return M.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),M.useEffect(()=>(o({type:di.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:g,data:k}}),()=>o({type:di.UnregisterDroppable,key:a,id:r})),[r]),M.useEffect(()=>{n!==d.current.disabled&&(o({type:di.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,o]),{active:s,rect:g,isOver:c?.id===r,node:T,over:c,setNodeRef:C}}function yE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function P9e(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function K_(t){return t!==null&&t>=0}function R9e(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 j9e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const AL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=yE(e,r,n),s=e[i],o=a[i];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},X_={scaleX:1,scaleY:1},D9e=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:s}=t;const o=(e=a[n])!=null?e:r;if(!o)return null;if(i===n){const u=a[s];return u?{x:0,y:n<s?u.top+u.height-(o.top+o.height):u.top-o.top,...X_}:null}const c=O9e(a,i,n);return i>n&&i<=s?{x:0,y:-o.height-c,...X_}:i<n&&i>=s?{x:0,y:o.height+c,...X_}:{x:0,y:0,...X_}};function O9e(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const fte="Sortable",mte=gr.createContext({activeIndex:-1,containerId:fte,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:AL,disabled:{draggable:!1,droppable:!1}});function pte(t){let{children:e,id:n,items:r,strategy:i=AL,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:c,over:u,measureDroppableContainers:d}=T9e(),f=iy(fte,n),g=o.rect!==null,p=M.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=s!=null,v=s?p.indexOf(s.id):-1,y=u?p.indexOf(u.id):-1,b=M.useRef(p),E=!R9e(p,b.current),w=y!==-1&&v===-1||E,A=j9e(a);_l(()=>{E&&x&&d(p)},[E,p,x,d]),M.useEffect(()=>{b.current=p},[p]);const T=M.useMemo(()=>({activeIndex:v,containerId:f,disabled:A,disableTransforms:w,items:p,overIndex:y,useDragOverlay:g,sortedRects:P9e(p,c),strategy:i}),[v,f,A.draggable,A.droppable,w,p,y,c,g,i]);return gr.createElement(mte.Provider,{value:T},e)}const L9e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return yE(n,r,i).indexOf(e)},I9e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:o,previousContainerId:c,transition:u}=t;return!u||!r||o!==a&&i===s?!1:n?!0:s!==i&&e===c},F9e={duration:200,easing:"ease"},gte="transform",U9e=Wp.Transition.toString({property:gte,duration:0,easing:"linear"}),z9e={roleDescription:"sortable"};function B9e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=M.useState(null),o=M.useRef(n);return _l(()=>{if(!e&&n!==o.current&&r.current){const c=i.current;if(c){const u=bg(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&s(d)}}n!==o.current&&(o.current=n)},[e,n,r,i]),M.useEffect(()=>{a&&s(null)},[a]),a}function xte(t){let{animateLayoutChanges:e=I9e,attributes:n,disabled:r,data:i,getNewIndex:a=L9e,id:s,strategy:o,resizeObserverConfig:c,transition:u=F9e}=t;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:x,sortedRects:v,overIndex:y,useDragOverlay:b,strategy:E}=M.useContext(mte),w=H9e(r,p),A=d.indexOf(s),T=M.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),C=M.useMemo(()=>d.slice(d.indexOf(s)),[d,s]),{rect:k,node:F,isOver:N,setNodeRef:j}=k9e({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:I,activatorEvent:O,activeNodeRect:q,attributes:R,setNodeRef:W,listeners:K,isDragging:G,over:te,setActivatorNodeRef:Y,transform:J}=A9e({id:s,data:T,attributes:{...z9e,...n},disabled:w.draggable}),U=u7e(j,W),H=!!I,ee=H&&!x&&K_(g)&&K_(y),ie=!b&&G,pe=ie&&ee?J:null,be=ee?pe??(o??E)({rects:v,activeNodeRect:q,activeIndex:g,overIndex:y,index:A}):null,Re=K_(g)&&K_(y)?a({id:s,items:d,activeIndex:g,overIndex:y}):A,Z=I?.id,_e=M.useRef({activeId:Z,items:d,newIndex:Re,containerId:f}),Le=d!==_e.current.items,ce=e({active:I,containerId:f,isDragging:G,isSorting:H,id:s,index:A,items:d,newIndex:_e.current.newIndex,previousItems:_e.current.items,previousContainerId:_e.current.containerId,transition:u,wasDragging:_e.current.activeId!=null}),Ie=B9e({disabled:!ce,index:A,node:F,rect:k});return M.useEffect(()=>{H&&_e.current.newIndex!==Re&&(_e.current.newIndex=Re),f!==_e.current.containerId&&(_e.current.containerId=f),d!==_e.current.items&&(_e.current.items=d)},[H,Re,f,d]),M.useEffect(()=>{if(Z===_e.current.activeId)return;if(Z!=null&&_e.current.activeId==null){_e.current.activeId=Z;return}const B=setTimeout(()=>{_e.current.activeId=Z},50);return()=>clearTimeout(B)},[Z]),{active:I,activeIndex:g,attributes:R,data:T,rect:k,index:A,newIndex:Re,items:d,isOver:N,isSorting:H,isDragging:G,listeners:K,node:F,overIndex:y,over:te,setNodeRef:U,setActivatorNodeRef:Y,setDroppableNodeRef:j,setDraggableNodeRef:W,transform:Ie??be,transition:z()};function z(){if(Ie||Le&&_e.current.newIndex===A)return U9e;if(!(ie&&!SL(O)||!u)&&(H||ce))return Wp.Transition.toString({...u,property:gte})}}function H9e(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 FS(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 $9e=[Sn.Down,Sn.Right,Sn.Up,Sn.Left],bte=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if($9e.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case Sn.Down:r.top<g.top&&c.push(f);break;case Sn.Up:r.top>g.top&&c.push(f);break;case Sn.Left:r.left>g.left&&c.push(f);break;case Sn.Right:r.left<g.left&&c.push(f);break}});const u=E7e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Qee(u,"id");if(d===s?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),g=a.get(d),p=g?i.get(g.id):null,x=g?.node.current;if(x&&p&&f&&g){const y=mE(x).some((C,k)=>o[k]!==C),b=yte(f,g),E=V9e(f,g),w=y||!b?{x:0,y:0}:{x:E?r.width-p.width:0,y:E?r.height-p.height:0},A={x:p.left,y:p.top};return w.x&&w.y?A:db(A,w)}}}};function yte(t,e){return!FS(t)||!FS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function V9e(t,e){return!FS(t)||!FS(e)||!yte(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function G9e({item:t,onClose:e}){const n=Mn(),{showToast:r}=Gr(),[i,a]=M.useState(t.printer_id),s=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,c]=M.useState(t.scheduled_time&&!s?"scheduled":"asap"),[u,d]=M.useState(()=>t.scheduled_time&&!s?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=M.useState(t.require_previous_success),[p,x]=M.useState(t.auto_off_after),{data:v}=yt({queryKey:["printers"],queryFn:()=>Ce.getPrinters()});M.useEffect(()=>{const w=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const y=vt({mutationFn:w=>Ce.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")}}),b=w=>{w.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:p};o==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,y.mutate(A)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsx(Mt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:l.jsxs(Nt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(dd,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(co,{className:"w-4 h-4"}),"No printers configured"]}):l.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=>a(Number(w.target.value)),required:!0,children:v?.map(w=>l.jsx("option",{value:w.id,children:w.name},w.id))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.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:()=>c("asap"),children:[l.jsx(sr,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.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:()=>c("scheduled"),children:[l.jsx($r,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:w=>d(w.target.value),min:E(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(Ed,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.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."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Pe,{type:"submit",className:"flex-1",disabled:y.isPending||v?.length===0,children:y.isPending?"Saving...":"Save Changes"})]})]})]})})})}function vte(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 W9e(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 q9e({status:t}){const e={pending:{icon:sr,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:GS,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:_r,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:Ea,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:D1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Wt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return l.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[l.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function gk({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:s}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=xte({id:t.id,disabled:t.status!=="pending"}),p={transform:Wp.Transform.toString(d),transition:f},x=t.status==="printing",v=t.status==="pending",y=["completed","failed","skipped","cancelled"].includes(t.status);return l.jsx("div",{ref:u,style:p,className:`
  8225. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8226. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8227. ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8228. ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8229. `,children:l.jsxs("div",{className:"flex items-center gap-4 p-4",children:[v?l.jsx("div",{...o,...c,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:l.jsx(M0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?l.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]}):l.jsx("div",{className:"w-8"}),l.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?l.jsx("img",{src:Ce.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:l.jsx(ud,{className:"w-6 h-6"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),l.jsx(fc,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:l.jsx(Cs,{className:"w-3.5 h-3.5"})})]}),l.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(pa,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Wu,{className:"w-3.5 h-3.5"}),vte(t.print_time_seconds)]}),v&&l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(sr,{className:"w-3.5 h-3.5"}),W9e(t.scheduled_time)]})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&l.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&&l.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:[l.jsx(Ed,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&l.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[l.jsx(co,{className:"w-3 h-3"}),t.error_message]})]}),l.jsx(q9e,{status:t.status}),l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(Pe,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Ioe,{className:"w-4 h-4"})}),v&&l.jsxs(l.Fragment,{children:[l.jsx(Pe,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:l.jsx(dd,{className:"w-4 h-4"})}),l.jsx(Pe,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),y&&l.jsxs(l.Fragment,{children:[l.jsx(Pe,{variant:"ghost",size:"sm",onClick:s,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:l.jsx(Na,{className:"w-4 h-4"})}),l.jsx(Pe,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:l.jsx(An,{className:"w-4 h-4"})})]})]})]})})}function K9e(){const t=Mn(),{showToast:e}=Gr(),[n,r]=M.useState(null),[i,a]=M.useState(""),[s,o]=M.useState(!1),[c,u]=M.useState(null),[d,f]=M.useState(null),[g,p]=M.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,v]=M.useState(()=>{const Y=localStorage.getItem("queue.historySortAsc");return Y!==null?Y==="true":!1}),[y,b]=M.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[E,w]=M.useState(()=>{const Y=localStorage.getItem("queue.pendingSortAsc");return Y!==null?Y==="true":!0});M.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),M.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",y)},[y]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(E))},[E]);const A=Xee(LS(gE,{activationConstraint:{distance:8}}),LS(pE,{coordinateGetter:bte})),{data:T,isLoading:C}=yt({queryKey:["queue",n,i],queryFn:()=>Ce.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:k}=yt({queryKey:["printers"],queryFn:()=>Ce.getPrinters()}),F=vt({mutationFn:Y=>Ce.cancelQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),N=vt({mutationFn:Y=>Ce.removeFromQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),j=vt({mutationFn:Y=>Ce.stopQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),I=vt({mutationFn:Y=>Ce.reorderQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),O=vt({mutationFn:Y=>{const J=new Date;return J.setFullYear(J.getFullYear()+1),Ce.addToQueue({printer_id:Y.printer_id,archive_id:Y.archive_id,scheduled_time:J.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),u(Y)},onError:Y=>e(Y.message||"Failed to re-queue item","error")}),q=vt({mutationFn:async()=>{const Y=T?.filter(J=>["completed","failed","skipped","cancelled"].includes(J.status))||[];for(const J of Y)await Ce.removeFromQueue(J.id);return Y.length},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Y} history item${Y!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),R=M.useMemo(()=>{const Y=T?.filter(U=>U.status==="pending")||[],J=U=>{if(!U.scheduled_time)return 0;const H=new Date(U.scheduled_time).getTime(),ee=Date.now()+4320*60*60*1e3;return H>ee?0:H};return[...Y].sort((U,H)=>{let ee;return y==="name"?ee=(U.archive_name||"").localeCompare(H.archive_name||""):y==="printer"?ee=(U.printer_name||"").localeCompare(H.printer_name||""):y==="time"?ee=J(U)-J(H):ee=U.position-H.position,E?ee:-ee})},[T,y,E]),W=T?.filter(Y=>Y.status==="printing")||[],K=M.useMemo(()=>[...T?.filter(J=>["completed","failed","skipped","cancelled"].includes(J.status))||[]].sort((J,U)=>{let H;return g==="name"?H=(J.archive_name||"").localeCompare(U.archive_name||""):g==="printer"?H=(J.printer_name||"").localeCompare(U.printer_name||""):H=new Date(U.completed_at||U.created_at).getTime()-new Date(J.completed_at||J.created_at).getTime(),x?-H:H}),[T,g,x]),G=M.useMemo(()=>R.reduce((Y,J)=>Y+(J.print_time_seconds||0),0),[R]),te=Y=>{const{active:J,over:U}=Y;if(!U||J.id===U.id)return;const H=R.findIndex(ie=>ie.id===J.id),ee=R.findIndex(ie=>ie.id===U.id);if(H!==-1&&ee!==-1){const pe=yE(R,H,ee).map((ue,be)=>({id:ue.id,position:be+1}));I.mutate(pe)}};return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsx("div",{className:"flex items-center justify-between mb-8",children:l.jsxs("div",{children:[l.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[l.jsx(xG,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),l.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[l.jsx(Mt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:l.jsx(Nt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:l.jsx(GS,{className:"w-5 h-5 text-blue-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),l.jsx(Mt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:l.jsx(Nt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:l.jsx(sr,{className:"w-5 h-5 text-yellow-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:R.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),l.jsx(Mt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:l.jsx(Nt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:l.jsx(Wu,{className:"w-5 h-5 text-bambu-green"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:vte(G)}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),l.jsx(Mt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:l.jsx(Nt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:l.jsx(_r,{className:"w-5 h-5 text-gray-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),l.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Y=>r(Y.target.value?Number(Y.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),k?.map(Y=>l.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),l.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:Y=>a(Y.target.value),children:[l.jsx("option",{value:"",children:"All Status"}),l.jsx("option",{value:"pending",children:"Pending"}),l.jsx("option",{value:"printing",children:"Printing"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"failed",children:"Failed"}),l.jsx("option",{value:"skipped",children:"Skipped"}),l.jsx("option",{value:"cancelled",children:"Cancelled"})]}),l.jsx("div",{className:"flex-1"}),K.length>0&&l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[l.jsx(An,{className:"w-4 h-4"}),"Clear History"]})]}),C?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?l.jsxs(Mt,{className:"p-12 text-center border-dashed",children:[l.jsx($r,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),l.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),l.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.'})]}):l.jsxs("div",{className:"space-y-8",children:[W.length>0&&l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),l.jsx("div",{className:"space-y-3",children:W.map(Y=>l.jsx(gk,{item:Y,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>f({type:"stop",item:Y}),onRequeue:()=>{}},Y.id))})]}),R.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(sr,{className:"w-5 h-5 text-yellow-400"}),"Queued",l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",R.length," item",R.length!==1?"s":"",")"]}),l.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)"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.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:y,onChange:Y=>b(Y.target.value),children:[l.jsx("option",{value:"position",children:"Sort by Position"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"}),l.jsx("option",{value:"time",children:"Sort by Schedule"})]}),l.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>w(!E),title:E?"Ascending":"Descending",className:"px-2",children:E?l.jsx(mp,{className:"w-4 h-4"}):l.jsx(_0,{className:"w-4 h-4"})})]})]}),l.jsx(hte,{sensors:A,collisionDetection:Jee,onDragEnd:te,children:l.jsx(pte,{items:R.map(Y=>Y.id),strategy:D9e,children:l.jsx("div",{className:"space-y-3",children:R.map((Y,J)=>l.jsx(gk,{item:Y,position:J+1,onEdit:()=>u(Y),onCancel:()=>f({type:"cancel",item:Y}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Y.id))})})})]}),K.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(_r,{className:"w-5 h-5 text-bambu-gray"}),"History",l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.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:Y=>p(Y.target.value),children:[l.jsx("option",{value:"date",children:"Sort by Date"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"})]}),l.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>v(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?l.jsx(mp,{className:"w-4 h-4"}):l.jsx(_0,{className:"w-4 h-4"})})]})]}),l.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Y,J)=>l.jsx(gk,{item:Y,position:J+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Y}),onStop:()=>{},onRequeue:()=>O.mutate(Y)},Y.id))})]})]}),c&&l.jsx(G9e,{item:c,onClose:()=>u(null)}),d&&l.jsx(fi,{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"?F.mutate(d.item.id):d.type==="stop"?j.mutate(d.item.id):N.mutate(d.item.id),f(null)},onCancel:()=>f(null)}),s&&l.jsx(fi,{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:()=>{q.mutate(),o(!1)},onCancel:()=>o(!1)})]})}function X9e({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=M.useMemo(()=>{const c={};t.forEach(b=>{const E=b.split("T")[0];c[E]=(c[E]||0)+1});const u=new Date,d=new Date(u);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const f=[],g=[];let p=[],x=-1;const v=new Date(d);let y=0;for(;v<=u;)v.getDay()===0&&p.length>0&&(f.push(p),p=[],y++),v.getMonth()!==x&&(g.push({month:v.toLocaleDateString("en-US",{month:"short"}),weekIndex:y}),x=v.getMonth()),p.push(new Date(v)),v.setDate(v.getDate()+1);return p.length>0&&f.push(p),{weeks:f,monthLabels:g,printCounts:c}},[t,e]),a=Math.max(1,...Object.values(i)),s=c=>{if(c===0)return"bg-bambu-dark";const u=c/a;return u<=.25?"bg-bambu-green/30":u<=.5?"bg-bambu-green/50":u<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return l.jsxs("div",{className:"overflow-x-auto",children:[l.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:c,weekIndex:u},d)=>l.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(u-(r[d-1]?.weekIndex||0))*14-24}px`},children:c},d))}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((c,u)=>l.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:u%2===1?"visible":"hidden"},children:c},c))}),n.map((c,u)=>l.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=c.find(v=>v.getDay()===d);if(!f)return l.jsx("div",{className:"w-3 h-3"},d);const g=f.toISOString().split("T")[0],p=i[g]||0,x=g===new Date().toISOString().split("T")[0];return l.jsx("div",{className:`w-3 h-3 rounded-sm ${s(p)} ${x?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${p} print${p!==1?"s":""}`},d)})},u))]}),l.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[l.jsx("span",{children:"Less"}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),l.jsx("span",{children:"More"})]})]})}const Y_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function Y9e(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 Z9e({archives:t,currency:e="$"}){const[n,r]=M.useState("30d"),i=M.useMemo(()=>{const g=Y9e(n);return t.filter(p=>new Date(p.completed_at||p.created_at)>=g)},[t,n]),a=M.useMemo(()=>{const g=new Map;return i.forEach(p=>{const v=new Date(p.completed_at||p.created_at).toISOString().split("T")[0],y=g.get(v)||{date:v,filament:0,cost:0,prints:0};y.filament+=p.filament_used_grams||0,y.cost+=p.cost||0,y.prints+=1,g.set(v,y)}),Array.from(g.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),s=M.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(p=>{const x=new Date(p.completed_at||p.created_at),v=new Date(x);v.setDate(x.getDate()-x.getDay());const y=v.toISOString().split("T")[0],b=g.get(y)||{week:y,filament:0,cost:0,prints:0};b.filament+=p.filament_used_grams||0,b.cost+=p.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),o=M.useMemo(()=>{const g=new Map;return i.forEach(p=>{const v=(p.filament_type||"Unknown").split(", ");v.forEach(y=>{const b=(p.filament_used_grams||0)/v.length;g.set(y,(g.get(y)||0)+b)})}),Array.from(g.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=M.useMemo(()=>{const g=new Date,p=[];for(let x=5;x>=0;x--){const v=new Date(g.getFullYear(),g.getMonth()-x,1),y=new Date(g.getFullYear(),g.getMonth()-x+1,0),b=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(w=>{const A=new Date(w.completed_at||w.created_at);return A>=v&&A<=y});p.push({month:b,filament:Math.round(E.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:E.reduce((w,A)=>w+(A.cost||0),0),prints:E.length})}return p},[t]),u=n==="7d"||n==="30d"?a:s,d=i.reduce((g,p)=>g+(p.filament_used_grams||0),0),f=i.reduce((g,p)=>g+(p.cost||0),0);return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),l.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>l.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))})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),l.jsx(a1,{width:"100%",height:250,children:l.jsxs(mCe,{data:u,children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),l.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),l.jsx(Tw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),l.jsx(Nw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),l.jsx(kw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(o1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),l.jsx(CY,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):l.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(a1,{width:160,height:160,children:l.jsxs(hCe,{children:[l.jsx(QX,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,p)=>l.jsx(Gb,{fill:Y_[p%Y_.length]},`cell-${p}`))}),l.jsx(o1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),l.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,p)=>{const x=o.reduce((y,b)=>y+b.value,0),v=x>0?(g.value/x*100).toFixed(0):0;return l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:Y_[p%Y_.length]}}),l.jsx("span",{className:"text-white truncate flex-1",children:g.name}),l.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},g.name)})})]}):l.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),l.jsx(a1,{width:"100%",height:200,children:l.jsxs(eCe,{data:c,children:[l.jsx(Tw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),l.jsx(Nw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),l.jsx(kw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(o1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,p)=>[p==="filament"?`${g}g`:p==="cost"?`${e}${g.toFixed(2)}`:g,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),l.jsx(kj,{}),l.jsx(iY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function Q9e({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:s}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=xte({id:t}),p={transform:Wp.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:l.jsxs("div",{ref:u,style:{...p,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:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{...o,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:l.jsx(M0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),l.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?l.jsx(Sce,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):l.jsx(pce,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),l.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:l.jsx(qR,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),l.jsx("div",{className:"p-4",children:n})]})}function J9e({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const s=()=>{const A={};return t.forEach(T=>{A[T.id]=T.defaultSize||4}),A},[o,c]=M.useState(()=>{const A=localStorage.getItem(e);if(A)try{const T=JSON.parse(A);return T.sizes||(T.sizes=s()),T}catch{}return{order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()}}),[u,d]=M.useState(!1);M.useEffect(()=>{const A=()=>d(T=>!T);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),M.useEffect(()=>{localStorage.setItem(e,JSON.stringify(o))},[o,e]),M.useEffect(()=>{const T=t.map(C=>C.id).filter(C=>!o.order.includes(C));T.length>0&&c(C=>({...C,order:[...C.order,...T]}))},[t,o.order]);const f=Xee(LS(gE,{activationConstraint:{distance:8}}),LS(pE,{coordinateGetter:bte})),g=A=>{const{active:T,over:C}=A;C&&T.id!==C.id&&c(k=>{const F=k.order.indexOf(T.id),N=k.order.indexOf(C.id);return{...k,order:yE(k.order,F,N)}})},p=A=>{c(T=>({...T,hidden:T.hidden.includes(A)?T.hidden.filter(C=>C!==A):[...T.hidden,A]}))},x=A=>{c(T=>{const C=T.sizes[A]||4,k=C===1?2:C===2?4:1;return{...T,sizes:{...T.sizes,[A]:k}}})},v=()=>{const A={order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()};c(A),i?.()},y=o.order.map(A=>t.find(T=>T.id===A)).filter(Boolean),b=y.filter(A=>!o.hidden.includes(A.id)),E=y.filter(A=>o.hidden.includes(A.id)),w=a?.({hiddenCount:E.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:v});return l.jsxs("div",{className:"space-y-4",children:[w,!r&&!a&&l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:v,children:[l.jsx(Qp,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[l.jsx(xp,{className:"w-4 h-4"}),E.length," Hidden"]})]}),u&&E.length>0&&l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(A=>l.jsxs("button",{onClick:()=>p(A.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[l.jsx(xp,{className:"w-3 h-3"}),A.title]},A.id))})]}),l.jsx(hte,{sensors:f,collisionDetection:Jee,onDragEnd:g,children:l.jsx(pte,{items:b.map(A=>A.id),strategy:AL,children:l.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(A=>l.jsx(Q9e,{id:A.id,title:A.title,isHidden:o.hidden.includes(A.id),size:o.sizes[A.id]||2,onToggleVisibility:()=>p(A.id),onToggleSize:()=>x(A.id),children:A.component},A.id))})})}),b.length===0&&l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx("p",{children:"All widgets are hidden."}),l.jsx(Pe,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function eGe({stats:t,currency:e}){return l.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:l.jsx(Pc,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),l.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:l.jsx(sr,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:l.jsx(Pc,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:l.jsx(k1,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:l.jsx(_p,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:l.jsx(k1,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function tGe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),l.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ea,{className:"w-4 h-4 text-red-400"}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),l.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function nGe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,s=(c=>c>=95&&c<=105?"#00ae42":c>105?"#3b82f6":"#f97316")(n),o=n-100;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),l.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[l.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),l.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),l.jsxs("div",{className:"space-y-2 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[l.jsx(vG,{className:"w-3 h-3"}),l.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([c,u])=>l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(c)||`Printer ${c}`}),l.jsxs("span",{className:`font-medium ${u>=95&&u<=105?"text-bambu-green":u>105?"text-blue-400":"text-orange-400"}`,children:[u.toFixed(0),"%"]})]},c))})]})]})}function rGe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return l.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 l.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-white",children:n}),l.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:l.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function iGe({printDates:t}){return l.jsx(X9e,{printDates:t,months:4})}function aGe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:l.jsx(pa,{className:"w-4 h-4 text-bambu-green"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function sGe({archives:t,currency:e}){return!t||t.length===0?l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):l.jsx(Z9e,{archives:t,currency:e})}function oGe(){const{data:t,isLoading:e}=yt({queryKey:["failureAnalysis"],queryFn:()=>Ce.getFailureAnalysis({days:30})});if(e)return l.jsx("div",{className:"flex justify-center py-4",children:l.jsx(_t,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!t||t.total_prints===0)return l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const n=Object.entries(t.failures_by_reason).sort(([,r],[,i])=>i-r).slice(0,5);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Sr,{className:`w-5 h-5 ${t.failure_rate>20?"text-red-400":t.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),l.jsxs("span",{className:"text-2xl font-bold text-white",children:[t.failure_rate.toFixed(1),"%"]}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"failure rate"})]}),l.jsxs("div",{className:"text-sm text-bambu-gray",children:[t.failed_prints," / ",t.total_prints," prints failed"]})]}),n.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray font-medium",children:"Top Failure Reasons"}),n.map(([r,i])=>l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("span",{className:"text-white truncate max-w-[200px]",children:r||"Unknown"}),l.jsx("span",{className:"text-bambu-gray",children:i})]},r))]}),t.trend&&t.trend.length>=2&&l.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(wG,{className:`w-4 h-4 ${t.trend[t.trend.length-1].failure_rate<t.trend[t.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),l.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",t.trend[t.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]})}function lGe(){const{showToast:t}=Gr(),[e,n]=M.useState(!1),[r,i]=M.useState(!1),[a,s]=M.useState(0),[o,c]=M.useState(0);M.useEffect(()=>{const w=()=>{try{const T=localStorage.getItem("bambusy-dashboard-layout");if(T){const C=JSON.parse(T);c(C.hidden?.length||0)}}catch{c(0)}};w(),window.addEventListener("storage",w);const A=setInterval(w,500);return()=>{window.removeEventListener("storage",w),clearInterval(A)}},[a]);const{data:u,isLoading:d}=yt({queryKey:["archiveStats"],queryFn:Ce.getArchiveStats}),{data:f}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:g}=yt({queryKey:["archives"],queryFn:()=>Ce.getArchives(void 0,void 0,1e3,0)}),{data:p}=yt({queryKey:["settings"],queryFn:Ce.getSettings}),x=async w=>{i(!1),n(!0);try{const{blob:A,filename:T}=await Ce.exportStats({format:w,days:90}),C=URL.createObjectURL(A),k=document.createElement("a");k.href=C,k.download=T,k.click(),URL.revokeObjectURL(C),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},v=p?.currency||"$",y=new Map(f?.map(w=>[String(w.id),w.name])||[]),b=g?.map(w=>w.created_at)||[];if(d)return l.jsx("div",{className:"p-4 md:p-8",children:l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:l.jsx(eGe,{stats:u,currency:v}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:l.jsx(tGe,{stats:u}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:l.jsx(nGe,{stats:u,printerMap:y}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:l.jsx(rGe,{stats:u}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:l.jsx(oGe,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:l.jsx(iGe,{printDates:b}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:l.jsx(aGe,{stats:u,printerMap:y}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:l.jsx(sGe,{archives:g||[],currency:v}),defaultSize:4}];return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),l.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&l.jsxs(Pe,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[l.jsx(xp,{className:"w-4 h-4"}),o," Hidden"]}),l.jsxs(Pe,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),s(w=>w+1),t("Layout reset")},children:[l.jsx(Qp,{className:"w-4 h-4"}),"Reset Layout"]}),l.jsxs("div",{className:"relative",children:[l.jsxs(Pe,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(P1,{className:"w-4 h-4"}),"Export Stats"]}),r&&l.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[l.jsx(ws,{className:"w-4 h-4"}),"Export as CSV"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[l.jsx(P1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),l.jsx(J9e,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function cGe({plug:t,onEdit:e}){const n=Mn(),[r,i]=M.useState(!1),[a,s]=M.useState(!1),[o,c]=M.useState(!1),[u,d]=M.useState(!1),{data:f,isLoading:g,refetch:p}=yt({queryKey:["smart-plug-status",t.id],queryFn:()=>Ce.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),v=x?.find(C=>C.id===t.printer_id),y=vt({mutationFn:C=>Ce.controlSmartPlug(t.id,C),onSuccess:()=>{p()}}),b=vt({mutationFn:C=>Ce.updateSmartPlug(t.id,C),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=vt({mutationFn:()=>Ce.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",A=f?.reachable??!1,T=y.isPending;return l.jsxs(l.Fragment,{children:[l.jsx(Mt,{className:"relative",children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:l.jsx(tp,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),l.jsx("div",{className:"flex items-center gap-2",children:g?l.jsx(_t,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?l.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[l.jsx(AG,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):l.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[l.jsx(rj,{className:"w-4 h-4"}),l.jsx("span",{children:"Offline"})]})})]}),v&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),l.jsx("span",{className:"text-sm text-white",children:v.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&l.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&l.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:[l.jsx(Ch,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&l.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:[l.jsx($r,{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}`]})]}),l.jsxs("div",{className:"flex gap-2 mb-3",children:[l.jsxs(Pe,{size:"sm",variant:w?"primary":"secondary",disabled:!A||T,onClick:()=>s(!0),className:"flex-1",children:[T?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(Ed,{className:"w-4 h-4"}),"On"]}),l.jsxs(Pe,{size:"sm",variant:w?"secondary":"primary",disabled:!A||T,onClick:()=>c(!0),className:"flex-1",children:[T?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(ej,{className:"w-4 h-4"}),"Off"]})]}),l.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(WS,{className:"w-4 h-4"}),"Automation Settings"]}),l.jsx("span",{children:u?"-":"+"})]}),u&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.enabled,onChange:C=>b.mutate({enabled:C.target.checked}),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto On"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:C=>b.mutate({auto_on:C.target.checked}),className:"sr-only peer"}),l.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"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:C=>b.mutate({auto_off:C.target.checked}),className:"sr-only peer"}),l.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&&l.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{onClick:()=>b.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:[l.jsx(sr,{className:"w-4 h-4"}),"Time"]}),l.jsxs("button",{onClick:()=>b.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:[l.jsx(qS,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),l.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:C=>b.mutate({off_delay_minutes:parseInt(C.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"})]}):l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),l.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:C=>b.mutate({off_temp_threshold:parseInt(C.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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(JR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(An,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(fi,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(),i(!1)},onCancel:()=>i(!1)}),a&&l.jsx(fi,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{y.mutate("on"),s(!1)},onCancel:()=>s(!1)}),o&&l.jsx(fi,{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:()=>{y.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function uGe({plug:t,onClose:e}){const n=Mn(),r=!!t,[i,a]=M.useState(t?.name||""),[s,o]=M.useState(t?.ip_address||""),[c,u]=M.useState(t?.username||""),[d,f]=M.useState(t?.password||""),[g,p]=M.useState(t?.printer_id||null),[x,v]=M.useState(null),[y,b]=M.useState(null),[E,w]=M.useState(t?.power_alert_enabled||!1),[A,T]=M.useState(t?.power_alert_high?.toString()||""),[C,k]=M.useState(t?.power_alert_low?.toString()||""),[F,N]=M.useState(t?.schedule_enabled||!1),[j,I]=M.useState(t?.schedule_on_time||""),[O,q]=M.useState(t?.schedule_off_time||""),{data:R}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:W}=yt({queryKey:["smart-plugs"],queryFn:Ce.getSmartPlugs});M.useEffect(()=>{const H=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[e]);const K=vt({mutationFn:()=>Ce.testSmartPlugConnection(s,c||null,d||null),onSuccess:H=>{v(H),b(null),!i&&H.device_name&&a(H.device_name)},onError:H=>{v(null),b(H.message)}}),G=vt({mutationFn:H=>Ce.createSmartPlug(H),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:H=>{b(H.message)}}),te=vt({mutationFn:H=>Ce.updateSmartPlug(t.id,H),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:H=>{b(H.message)}}),Y=R?.filter(H=>!W?.some(ie=>ie.printer_id===H.id&&ie.id!==t?.id)),J=H=>{if(H.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!s.trim()){b("IP address is required");return}const ee={name:i.trim(),ip_address:s.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:A?parseFloat(A):null,power_alert_low:C?parseFloat(C):null,schedule_enabled:F,schedule_on_time:j||null,schedule_off_time:O||null};r?te.mutate(ee):G.mutate(ee)},U=G.isPending||te.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:H=>H.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:J,className:"p-6 space-y-4",children:[y&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:y}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:s,onChange:H=>{o(H.target.value),v(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsxs(Pe,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!s.trim()||K.isPending,children:[K.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(AG,{className:"w-4 h-4"}),"Test"]})]})]}),x&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.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:x.success?l.jsxs(l.Fragment,{children:[l.jsx(_r,{className:"w-5 h-5"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-medium",children:"Connected!"}),l.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx(rj,{className:"w-5 h-5"}),l.jsx("span",{children:"Connection failed"})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:i,onChange:H=>a(H.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"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),l.jsx("input",{type:"text",value:c,onChange:H=>u(H.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),l.jsx("input",{type:"password",value:d,onChange:H=>f(H.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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),l.jsxs("select",{value:g??"",onChange:H=>p(H.target.value?Number(H.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"No printer (manual control only)"}),Y?.map(H=>l.jsx("option",{value:H.id,children:H.name},H.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ch,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:E,onChange:H=>w(H.target.checked),className:"sr-only peer"}),l.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"})]})]}),E&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),l.jsx("input",{type:"number",value:A,onChange:H=>T(H.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),l.jsx("input",{type:"number",value:C,onChange:H=>k(H.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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(sr,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:F,onChange:H=>N(H.target.checked),className:"sr-only peer"}),l.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"})]})]}),F&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),l.jsx("input",{type:"time",value:j,onChange:H=>I(H.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),l.jsx("input",{type:"time",value:O,onChange:H=>q(H.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),l.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."})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{type:"submit",disabled:U,className:"flex-1",children:[U?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(no,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Rn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return l.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:l.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const dGe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function hGe({provider:t,onEdit:e}){const n=Mn(),[r,i]=M.useState(!1),[a,s]=M.useState(!1),[o,c]=M.useState(null),{data:u}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=vt({mutationFn:v=>Ce.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=vt({mutationFn:()=>Ce.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=vt({mutationFn:()=>Ce.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),x=v=>v||"";return l.jsxs(l.Fragment,{children:[l.jsx(Mt,{className:"relative",children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:l.jsx(Ch,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:dGe[t.provider_type]||t.provider_type})]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&l.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",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))&&l.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),l.jsx(Rn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]})]}),d&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),l.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&l.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:l.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),l.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&l.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&l.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&l.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&l.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&l.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&l.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&l.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&&l.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&l.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&l.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&l.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&l.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&l.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[l.jsx(j1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&l.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[l.jsx($r,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),l.jsx("div",{className:"mb-3",children:l.jsxs(Pe,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(tj,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&l.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?l.jsx(_r,{className:"w-4 h-4"}):l.jsx(Ea,{className:"w-4 h-4"}),l.jsx("span",{children:o.message})]}),l.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(WS,{className:"w-4 h-4"}),"Event Settings"]}),a?l.jsx(HS,{className:"w-4 h-4"}):l.jsx(Hc,{className:"w-4 h-4"})]}),a&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),l.jsx(Rn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Started"}),l.jsx(Rn,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),l.jsx(Rn,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),l.jsx(Rn,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),l.jsx(Rn,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),l.jsx(Rn,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),l.jsx(Rn,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),l.jsx(Rn,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Rn,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),l.jsx(Rn,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),l.jsx(Rn,{checked:t.on_ams_humidity_high??!1,onChange:v=>f.mutate({on_ams_humidity_high:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),l.jsx(Rn,{checked:t.on_ams_temperature_high??!1,onChange:v=>f.mutate({on_ams_temperature_high:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),l.jsx(Rn,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>f.mutate({on_ams_ht_humidity_high:v})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),l.jsx(Rn,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>f.mutate({on_ams_ht_temperature_high:v})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(j1,{className:"w-4 h-4 text-purple-400"}),l.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),l.jsx(Rn,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),t.quiet_hours_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(sr,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx($r,{className:"w-4 h-4 text-emerald-400"}),l.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),l.jsx(Rn,{checked:t.daily_digest_enabled,onChange:v=>f.mutate({daily_digest_enabled:v})})]}),t.daily_digest_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(sr,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(JR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(An,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(fi,{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 M9=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function fGe({provider:t,onClose:e}){const n=Mn(),r=!!t,[i,a]=M.useState(t?.name||""),[s,o]=M.useState(t?.provider_type||"email"),[c,u]=M.useState(t?.printer_id||null),[d,f]=M.useState(t?.quiet_hours_enabled||!1),[g,p]=M.useState(t?.quiet_hours_start||"22:00"),[x,v]=M.useState(t?.quiet_hours_end||"07:00"),[y,b]=M.useState(t?.daily_digest_enabled||!1),[E,w]=M.useState(t?.daily_digest_time||"08:00"),[A,T]=M.useState(t?.on_print_start??!1),[C,k]=M.useState(t?.on_print_complete??!0),[F,N]=M.useState(t?.on_print_failed??!0),[j,I]=M.useState(t?.on_print_stopped??!0),[O,q]=M.useState(t?.on_print_progress??!1),[R,W]=M.useState(t?.on_printer_offline??!1),[K,G]=M.useState(t?.on_printer_error??!1),[te,Y]=M.useState(t?.on_filament_low??!1),[J,U]=M.useState(t?.on_maintenance_due??!1),[H,ee]=M.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([V,Q])=>[V,String(Q)])):{}),[ie,pe]=M.useState(null),[ue,be]=M.useState(null),{data:Re}=yt({queryKey:["printers"],queryFn:Ce.getPrinters});M.useEffect(()=>{const V=Q=>{Q.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[e]);const Z=vt({mutationFn:()=>Ce.testNotificationConfig({provider_type:s,config:H}),onSuccess:V=>{pe(V),be(null)},onError:V=>{pe({success:!1,message:V.message})}}),_e=vt({mutationFn:V=>Ce.createNotificationProvider(V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{be(V.message)}}),Le=vt({mutationFn:V=>Ce.updateNotificationProvider(t.id,V),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:V=>{be(V.message)}}),ce=V=>{if(V.preventDefault(),be(null),!i.trim()){be("Name is required");return}const Q=B(s);for(const Me of Q)if(!H[Me.key]?.trim()){be(`${Me.label} is required`);return}const se={name:i.trim(),provider_type:s,config:H,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:y,daily_digest_time:y?E:null,on_print_start:A,on_print_complete:C,on_print_failed:F,on_print_stopped:j,on_print_progress:O,on_printer_offline:R,on_printer_error:K,on_filament_low:te,on_maintenance_due:J};r?Le.mutate(se):_e.mutate(se)},Ie=_e.isPending||Le.isPending,z=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[]}},B=V=>z(V).filter(Q=>Q.required),ne=z(s);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:V=>V.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:ce,className:"p-6 space-y-4",children:[ue&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:ue}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:i,onChange:V=>a(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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),l.jsx("select",{value:s,onChange:V=>{o(V.target.value),ee({}),pe(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:M9.map(V=>l.jsx("option",{value:V.value,children:V.label},V.value))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:M9.find(V=>V.value===s)?.description})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ne.map(V=>l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[V.label," ",V.required&&"*"]}),V.type==="select"&&V.options?l.jsx("select",{value:H[V.key]||V.options[0]?.value||"",onChange:Q=>{ee({...H,[V.key]:Q.target.value}),pe(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(Q=>l.jsx("option",{value:Q.value,children:Q.label},Q.value))}):l.jsx("input",{type:V.type,value:H[V.key]||"",onChange:Q=>{ee({...H,[V.key]:Q.target.value}),pe(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))]}),l.jsx("div",{className:"flex gap-2",children:l.jsxs(Pe,{type:"button",variant:"secondary",onClick:()=>{pe(null),Z.mutate()},disabled:Z.isPending||!H[B(s)[0]?.key],className:"flex-1",children:[Z.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(tj,{className:"w-4 h-4"}),"Test Configuration"]})}),ie&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ie.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:ie.success?l.jsxs(l.Fragment,{children:[l.jsx(_r,{className:"w-5 h-5"}),l.jsx("span",{children:ie.message})]}):l.jsxs(l.Fragment,{children:[l.jsx(Ea,{className:"w-5 h-5"}),l.jsx("span",{children:ie.message})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),l.jsxs("select",{value:c??"",onChange:V=>u(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:[l.jsx("option",{value:"",children:"All printers"}),Re?.map(V=>l.jsx("option",{value:V.id,children:V.name},V.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),l.jsx(Rn,{checked:d,onChange:f})]}),d&&l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),l.jsx("input",{type:"time",value:g,onChange:V=>p(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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),l.jsx("input",{type:"time",value:x,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"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),l.jsx(Rn,{checked:y,onChange:b})]}),y&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),l.jsx("input",{type:"time",value:E,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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Start"}),l.jsx(Rn,{checked:A,onChange:T})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Complete"}),l.jsx(Rn,{checked:C,onChange:k})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Failed"}),l.jsx(Rn,{checked:F,onChange:N})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Stopped"}),l.jsx(Rn,{checked:j,onChange:I})]}),l.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-white",children:"Progress"}),l.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),l.jsx(Rn,{checked:O,onChange:q})]})]})]}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Offline"}),l.jsx(Rn,{checked:R,onChange:W})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Error"}),l.jsx(Rn,{checked:K,onChange:G})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Rn,{checked:te,onChange:Y})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),l.jsx(Rn,{checked:J,onChange:U})]})]})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{type:"submit",disabled:Ie,className:"flex-1",children:[Ie?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(no,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function mGe({template:t,onClose:e}){const n=Mn(),r=M.useRef(null),[i,a]=M.useState(t.title_template),[s,o]=M.useState(t.body_template),[c,u]=M.useState(null),[d,f]=M.useState(!0),{data:g}=yt({queryKey:["template-variables"],queryFn:Ce.getTemplateVariables}),p=g?.find(T=>T.event_type===t.event_type),{data:x,isLoading:v}=yt({queryKey:["template-preview",t.event_type,i,s],queryFn:()=>Ce.previewTemplate({event_type:t.event_type,title_template:i,body_template:s}),enabled:d&&i.length>0&&s.length>0});M.useEffect(()=>{const T=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const y=vt({mutationFn:T=>Ce.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),b=vt({mutationFn:()=>Ce.resetNotificationTemplate(t.id),onSuccess:T=>{a(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),E=T=>{if(T.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!s.trim()){u("Body is required");return}y.mutate({title_template:i,body_template:s})},w=T=>{const C=r.current;if(!C)return;const k=C.selectionStart,F=C.selectionEnd,N=s,j=N.substring(0,k),I=N.substring(F),O=j+`{${T}}`+I;o(O),setTimeout(()=>{C.focus();const q=k+T.length+2;C.setSelectionRange(q,q)},0)},A=i!==t.title_template||s!==t.body_template;return l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),l.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),l.jsx("input",{type:"text",value:i,onChange:T=>a(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..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),l.jsx("textarea",{ref:r,value:s,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..."})]}),p&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(T=>l.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:[l.jsx(tr,{className:"w-3 h-3"}),T]},T))}),l.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(xp,{className:"w-4 h-4"}),"Live Preview"]}),l.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&l.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:v?l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[l.jsx(_t,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),l.jsx("div",{className:"text-white font-medium",children:x.title})]}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),l.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):l.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[l.jsxs(Pe,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(Qp,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsxs(Pe,{onClick:E,disabled:y.isPending||!A,children:[y.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(no,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const pGe={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"},gGe={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 xGe({onClose:t}){const e=Mn(),{showToast:n}=Gr(),[r,i]=M.useState(7),[a,s]=M.useState(null),[o,c]=M.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=yt({queryKey:["notification-logs",r,o],queryFn:()=>Ce.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:p}=yt({queryKey:["notification-log-stats",r],queryFn:()=>Ce.getNotificationLogStats(r)}),x=vt({mutationFn:()=>Ce.clearNotificationLogs(30),onSuccess:y=>{n(y.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:y=>{n(`Failed to clear logs: ${y.message}`,"error")}}),v=y=>{const b=new Date(y),w=new Date().getTime()-b.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:b.toLocaleDateString()+" "+b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.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:[l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(R1,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),p&&l.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:l.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[l.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",l.jsx("span",{className:"text-white font-medium",children:p.total})," notifications"]}),l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(_r,{className:"w-4 h-4"}),p.success_count," sent"]}),p.failure_count>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(Ea,{className:"w-4 h-4"}),p.failure_count," failed"]})]})}),l.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[l.jsxs("select",{value:r,onChange:y=>i(Number(y.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:[l.jsx("option",{value:1,children:"Last 24 hours"}),l.jsx("option",{value:7,children:"Last 7 days"}),l.jsx("option",{value:30,children:"Last 30 days"}),l.jsx("option",{value:90,children:"Last 90 days"})]}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:o,onChange:y=>c(y.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),l.jsx("div",{className:"flex-1"}),l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(Na,{className:"w-4 h-4"}),"Refresh"]}),l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(An,{className:"w-4 h-4"}),"Clear Old"]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(_t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(y=>l.jsx(bGe,{log:y,isExpanded:a===y.id,onToggle:()=>s(a===y.id?null:y.id),formatDate:v},y.id))}):l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(R1,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function bGe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return l.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:[l.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?l.jsx(_r,{className:"w-4 h-4 text-bambu-green shrink-0"}):l.jsx(Ea,{className:"w-4 h-4 text-red-400 shrink-0"}),l.jsx("span",{className:`text-xs font-medium ${gGe[t.event_type]||"text-bambu-gray"}`,children:pGe[t.event_type]||t.event_type}),l.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&l.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),l.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?l.jsx(HS,{className:"w-4 h-4 text-bambu-gray shrink-0"}):l.jsx(Hc,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&l.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),l.jsx("p",{className:"text-sm text-white",children:t.title})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),l.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),l.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),l.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[l.jsxs("span",{children:["Provider: ",t.provider_type]}),l.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const Z_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:l.jsx(nj,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:l.jsx(Ch,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:l.jsx(ws,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:l.jsx(tp,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:l.jsx(pa,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:l.jsx(bG,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:l.jsx(hd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:l.jsx(wc,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function yGe({onClose:t,onExport:e}){const{t:n}=Kp(),[r,i]=M.useState(()=>{const x={};return Z_.forEach(v=>{x[v.id]=v.default}),x}),[a,s]=M.useState(!1),[o,c]=M.useState(!1);M.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(v=>({...v,[x]:!v[x]}))},d=()=>{const x={};Z_.forEach(v=>{x[v.id]=!0}),i(x)},f=()=>{const x={};Z_.forEach(v=>{x[v.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,p=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:l.jsx(Mt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:l.jsxs(Nt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:l.jsx(ts,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[l.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"})}),l.jsx("span",{className:"text-bambu-gray",children:"|"}),l.jsx("button",{onClick:f,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"})})]}),l.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:Z_.map(x=>l.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[l.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.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"}),l.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),l.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&l.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(wc,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[l.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),l.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&&l.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(Wm,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),l.jsx(Rn,{checked:a,onChange:s})]}),a&&l.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx(Sr,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Pe,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),l.jsx(Pe,{onClick:p,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?l.jsxs(l.Fragment,{children:[l.jsx(_t,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):l.jsxs(l.Fragment,{children:[l.jsx(ts,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const E9={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 vGe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=M.useState("options"),[a,s]=M.useState(!1),[o,c]=M.useState(null),[u,d]=M.useState(null),[f,g]=M.useState(new Set),p=M.useRef(null);M.useEffect(()=>{const w=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const x=w=>{const A=w.target.files?.[0];A&&c(A)},v=async()=>{if(o){i("restoring");try{const w=await e(o,a);d(w),i("result"),w.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},y=w=>{g(A=>{const T=new Set(A);return T.has(w)?T.delete(w):T.add(w),T})},b=u?.restored?Object.values(u.restored).reduce((w,A)=>w+A,0)+(u.files_restored||0):0,E=u?.total_skipped||0;return l.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:l.jsx(Mt,{className:"w-full max-w-lg",children:l.jsxs(Nt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?l.jsx(_r,{className:"w-5 h-5"}):r==="result"&&!u?.success?l.jsx(Sr,{className:"w-5 h-5"}):l.jsx(Ya,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),r==="options"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),l.jsx("button",{type:"button",onClick:()=>p.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?l.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[l.jsx(_r,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:o.name})]}):l.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[l.jsx(Ya,{className:"w-8 h-8"}),l.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),l.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(Sr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[l.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),l.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"Printers"})," - matched by serial number"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),l.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?l.jsx(Na,{className:"w-4 h-4 text-orange-400"}):l.jsx(D1,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),l.jsx(Rn,{checked:a,onChange:s})]})}),a&&l.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(Sr,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[l.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."]})]})})]}),l.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),l.jsxs(Pe,{type:"button",onClick:v,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[l.jsx(Ya,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&l.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[l.jsx(_t,{className:"w-12 h-12 text-bambu-green animate-spin"}),l.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[l.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:b}),l.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),l.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[l.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:E}),l.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,w])=>w>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),l.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,w])=>w>0).map(([w,A])=>l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:E9[w]||w}),l.jsx("span",{className:"text-bambu-green font-medium",children:A})]},w)),(u.files_restored||0)>0&&l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),l.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,w])=>w>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(D1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),l.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,w])=>w>0).map(([w,A])=>{const T=u.skipped_details?.[w]||[],C=f.has(w);return l.jsxs("div",{children:[l.jsxs("button",{onClick:()=>T.length>0&&y(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:[l.jsxs("span",{className:"text-white flex items-center gap-2",children:[E9[w]||w,T.length>0&&(C?l.jsx(HS,{className:"w-3 h-3"}):l.jsx(Hc,{className:"w-3 h-3"}))]}),l.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),C&&T.length>0&&l.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((k,F)=>l.jsx("div",{children:k},F)),T.length>10&&l.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},w)})})]}),b===0&&E===0&&l.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),l.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Pe,{onClick:t,children:"Close"})})]})]})})})}async function _Ge(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function wGe(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 SGe(){const t=Mn(),[e,n]=M.useState(!1),[r,i]=M.useState(""),[a,s]=M.useState("auto"),[o,c]=M.useState(!1),[u,d]=M.useState("all"),[f,g]=M.useState(!1),{data:p,isLoading:x}=yt({queryKey:["spoolman-settings"],queryFn:_Ge}),{data:v,isLoading:y,refetch:b}=yt({queryKey:["spoolman-status"],queryFn:Ce.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=yt({queryKey:["printers"],queryFn:Ce.getPrinters});M.useEffect(()=>{p&&(n(p.spoolman_enabled==="true"),i(p.spoolman_url||""),s(p.spoolman_sync_mode||"auto"),g(!0))},[p]),M.useEffect(()=>{if(!f||!p)return;if(p.spoolman_enabled==="true"!==e||(p.spoolman_url||"")!==r||(p.spoolman_sync_mode||"auto")!==a){const q=setTimeout(()=>{w.mutate()},500);return()=>clearTimeout(q)}},[e,r,a,f]);const w=vt({mutationFn:()=>wGe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),A=vt({mutationFn:Ce.connectSpoolman,onSuccess:()=>{b()}}),T=vt({mutationFn:Ce.disconnectSpoolman,onSuccess:()=>{b()}}),C=vt({mutationFn:Ce.syncAllPrintersAms,onSuccess:O=>{O.success}}),k=vt({mutationFn:O=>Ce.syncPrinterAms(O),onSuccess:O=>{O.success}}),F=()=>{u==="all"?C.mutate():k.mutate(u)},N=C.isPending||k.isPending,j=u==="all"?C.data:k.data,I=u==="all"?C.isSuccess:k.isSuccess;return x?l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(gp,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),l.jsx(Nt,{children:l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(_t,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(gp,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),w.isPending&&l.jsx(_t,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&l.jsx(Gh,{className:"w-4 h-4 text-bambu-green"})]})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Enable Spoolman"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:e,onChange:O=>n(O.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),l.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:O=>i(O.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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),l.jsxs("select",{value:a,onChange:O=>s(O.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:[l.jsx("option",{value:"auto",children:"Automatic"}),l.jsx("option",{value:"manual",children:"Manual Only"})]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&l.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),y?l.jsx(_t,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?l.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[l.jsx(Gh,{className:"w-4 h-4"}),"Connected"]}):l.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Disconnected"]})]}),l.jsx("div",{className:"flex gap-2",children:v?.connected?l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(ece,{className:"w-4 h-4"}),"Disconnect"]}):l.jsxs(Pe,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(Lk,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&l.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),v?.connected&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsxs("select",{value:u,onChange:O=>d(O.target.value==="all"?"all":Number(O.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:[l.jsx("option",{value:"all",children:"All Printers"}),E?.map(O=>l.jsx("option",{value:O.id,children:O.name},O.id))]}),l.jsx(Hc,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:F,disabled:N,children:[N?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(Na,{className:"w-4 h-4"}),"Sync"]})]})]}),I&&j&&l.jsx("div",{className:`mt-2 p-2 rounded text-sm ${j.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:j.success?`Synced ${j.synced_count} trays successfully`:`Synced ${j.synced_count} trays with ${j.errors.length} errors`})]})]})]})}function MGe({link:t,onClose:e}){const n=Mn(),{theme:r}=yb(),i=!!t,a=M.useRef(null),[s,o]=M.useState(t?.name||""),[c,u]=M.useState(t?.url||""),[d,f]=M.useState(t?.icon||"link"),[g,p]=M.useState(!!t?.custom_icon),[x,v]=M.useState(t?.custom_icon?Ce.getExternalLinkIconUrl(t.id):null),[y,b]=M.useState(null),[E,w]=M.useState(null);M.useEffect(()=>{const I=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[e]);const A=vt({mutationFn:async I=>{const O=await Ce.createExternalLink(I);return y?await Ce.uploadExternalLinkIcon(O.id,y):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{w(I.message)}}),T=vt({mutationFn:async I=>{let O=await Ce.updateExternalLink(t.id,I);return y?O=await Ce.uploadExternalLinkIcon(t.id,y):!g&&t?.custom_icon&&(O=await Ce.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{w(I.message)}}),C=I=>{const O=I.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){w("Image file must be less than 1MB");return}b(O),p(!0);const R=new FileReader;R.onload=W=>{v(W.target?.result)},R.readAsDataURL(O)}},k=()=>{b(null),v(null),p(!1),a.current&&(a.current.value="")},F=I=>{if(I.preventDefault(),w(null),!s.trim()){w("Name is required");return}if(!c.trim()){w("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){w("URL must start with http:// or https://");return}const O={name:s.trim(),url:c.trim(),icon:d};i?T.mutate(O):A.mutate(O)},N=A.isPending||T.isPending,j=KS(d);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:I=>I.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?l.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):l.jsx(j,{className:"w-5 h-5"})}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:F,className:"p-6 space-y-4",children:[E&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:s,onChange:I=>o(I.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),l.jsx("input",{type:"text",value:c,onChange:I=>u(I.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),l.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),l.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),g&&x?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),l.jsx("button",{type:"button",onClick:k,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:l.jsx(An,{className:"w-4 h-4"})})]}):l.jsxs(Pe,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[l.jsx(Ya,{className:"w-4 h-4"}),"Upload"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),l.jsx(sde,{value:d,onChange:f})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{type:"submit",disabled:N,className:"flex-1",children:[N?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(no,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function EGe(){const t=Mn(),[e,n]=M.useState(!1),[r,i]=M.useState(null),[a,s]=M.useState(null),[o,c]=M.useState(null),{data:u,isLoading:d}=yt({queryKey:["external-links"],queryFn:Ce.getExternalLinks}),f=vt({mutationFn:E=>Ce.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=vt({mutationFn:E=>Ce.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},v=(E,w)=>{if(E.preventDefault(),o===null||o===w||!u)return;const A=u.map(F=>F.id),T=A.indexOf(o),C=A.indexOf(w);if(T===-1||C===-1)return;const k=[...A];k.splice(T,1),k.splice(C,0,o),g.mutate(k),c(null)},y=E=>{s(E)},b=()=>{a&&(f.mutate(a.id),s(null))};return l.jsxs(l.Fragment,{children:[l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Lk,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),l.jsxs(Pe,{size:"sm",onClick:()=>n(!0),children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Link"]})]})}),l.jsxs(Nt,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(_t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(E=>{const w=KS(E.icon);return l.jsxs("div",{draggable:!0,onDragStart:A=>p(A,E.id),onDragOver:x,onDrop:A=>v(A,E.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${o===E.id?"opacity-50":""}`,children:[l.jsx(M0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:l.jsx(w,{className:"w-4 h-4"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-white font-medium truncate",children:E.name}),l.jsx(Cs,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),l.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),l.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:l.jsx(dd,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>y(E),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:l.jsx(An,{className:"w-4 h-4"})})]})]},E.id)})}):l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(Lk,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{children:"No external links configured"}),l.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&l.jsx(MGe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&l.jsx(fi,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:b,onCancel:()=>s(null)})]})}function AGe(){const t=Mn(),{t:e,i18n:n}=Kp(),{showToast:r,showPersistentToast:i,dismissToast:a}=Gr(),[s,o]=M.useState(null),[c,u]=M.useState(!1),[d,f]=M.useState(null),[g,p]=M.useState(!1),[x,v]=M.useState(null),[y,b]=M.useState(null),[E,w]=M.useState(!1),[A,T]=M.useState(kG()),[C,k]=M.useState("general"),[F,N]=M.useState(!1),[j,I]=M.useState(""),[O,q]=M.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[R,W]=M.useState(null),[K,G]=M.useState(null),[te,Y]=M.useState(!1),[J,U]=M.useState(!1),[H,ee]=M.useState(null),[ie,pe]=M.useState(!1),[ue,be]=M.useState(!1),[Re,Z]=M.useState(!1),[_e,Le]=M.useState(!1),ce=de=>{T(de),cde(de)},Ie=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:z,isLoading:B}=yt({queryKey:["settings"],queryFn:Ce.getSettings}),{data:ne,isLoading:V}=yt({queryKey:["smart-plugs"],queryFn:Ce.getSmartPlugs}),{data:Q,isLoading:se}=yt({queryKey:["smart-plugs-energy",ne?.map(de=>de.id)],queryFn:async()=>{if(!ne||ne.length===0)return null;const de=await Promise.all(ne.filter(Vt=>Vt.enabled).map(async Vt=>{try{const On=await Ce.getSmartPlugStatus(Vt.id);return{plug:Vt,status:On}}catch{return{plug:Vt,status:null}}}));let ot=0,xt=0,Et=0,Qt=0,Ot=0;for(const{status:Vt}of de)Vt?.reachable&&Vt.energy&&(Ot++,Vt.energy.power!=null&&(ot+=Vt.energy.power),Vt.energy.today!=null&&(xt+=Vt.energy.today),Vt.energy.yesterday!=null&&(Et+=Vt.energy.yesterday),Vt.energy.total!=null&&(Qt+=Vt.energy.total));return{totalPower:ot,totalToday:xt,totalYesterday:Et,totalLifetime:Qt,reachableCount:Ot,totalPlugs:ne.filter(Vt=>Vt.enabled).length}},enabled:C==="plugs"&&!!ne&&ne.length>0,refetchInterval:C==="plugs"?1e4:!1}),{data:Me,isLoading:Ae}=yt({queryKey:["notification-providers"],queryFn:Ce.getNotificationProviders}),{data:Se,isLoading:$}=yt({queryKey:["api-keys"],queryFn:Ce.getAPIKeys}),L=vt({mutationFn:de=>Ce.createAPIKey(de),onSuccess:de=>{W(de.key||null),N(!1),I(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:de=>{r(`Failed to create API key: ${de.message}`,"error")}}),re=vt({mutationFn:de=>Ce.deleteAPIKey(de),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:de=>{r(`Failed to delete API key: ${de.message}`,"error")}}),{data:ye}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:we,isLoading:xe}=yt({queryKey:["notification-templates"],queryFn:Ce.getNotificationTemplates}),{data:rt}=yt({queryKey:["ffmpeg-status"],queryFn:Ce.checkFfmpeg}),{data:He}=yt({queryKey:["version"],queryFn:Ce.getVersion}),{data:he,refetch:Ge,isRefetching:Ue}=yt({queryKey:["updateCheck"],queryFn:Ce.checkForUpdates,staleTime:300*1e3}),{data:oe,refetch:tt}=yt({queryKey:["updateStatus"],queryFn:Ce.getUpdateStatus,refetchInterval:de=>{const ot=de.state.data;return ot?.status==="downloading"||ot?.status==="installing"?1e3:!1}}),$e=vt({mutationFn:Ce.applyUpdate,onSuccess:()=>{tt()}}),[Ye,ut]=M.useState(null),fe=vt({mutationFn:Ce.testAllNotificationProviders,onSuccess:de=>{ut(de),t.invalidateQueries({queryKey:["notification-providers"]}),de.failed===0?r(`All ${de.tested} providers tested successfully!`,"success"):r(`${de.success}/${de.tested} providers succeeded`,de.failed>0?"error":"success")},onError:de=>{r(`Failed to test providers: ${de.message}`,"error")}}),Qe=vt({mutationFn:async de=>{if(!ne)return{success:0,failed:0};const ot=ne.filter(Et=>Et.enabled),xt=await Promise.all(ot.map(async Et=>{try{return await Ce.controlSmartPlug(Et.id,de),{success:!0}}catch{return{success:!1}}}));return{success:xt.filter(Et=>Et.success).length,failed:xt.filter(Et=>!Et.success).length}},onSuccess:(de,ot)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),de.failed===0?r(`All ${de.success} plugs turned ${ot}`,"success"):r(`${de.success} plugs turned ${ot}, ${de.failed} failed`,"error")},onError:de=>{r(`Failed: ${de.message}`,"error")}}),ge=M.useRef(null),ze=M.useRef(!0);M.useEffect(()=>{z&&!s&&(o(z),setTimeout(()=>{ze.current=!1},100))},[z,s]);const ke=vt({mutationFn:Ce.updateSettings,onSuccess:de=>{t.setQueryData(["settings"],de),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:de=>{r(`Failed to save: ${de.message}`,"error")}});M.useEffect(()=>{if(!(ze.current||!s||!z||!(z.auto_archive!==s.auto_archive||z.save_thumbnails!==s.save_thumbnails||z.capture_finish_photo!==s.capture_finish_photo||z.default_filament_cost!==s.default_filament_cost||z.currency!==s.currency||z.energy_cost_per_kwh!==s.energy_cost_per_kwh||z.energy_tracking_mode!==s.energy_tracking_mode||z.check_updates!==s.check_updates||z.notification_language!==s.notification_language||z.telemetry_enabled!==s.telemetry_enabled||z.ams_humidity_good!==s.ams_humidity_good||z.ams_humidity_fair!==s.ams_humidity_fair||z.ams_temp_good!==s.ams_temp_good||z.ams_temp_fair!==s.ams_temp_fair||z.ams_history_retention_days!==s.ams_history_retention_days||z.date_format!==s.date_format||z.time_format!==s.time_format||z.default_printer_id!==s.default_printer_id)))return ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{ke.mutate(s)},500),()=>{ge.current&&clearTimeout(ge.current)}},[s,z,ke]);const ve=M.useCallback((de,ot)=>{o(xt=>xt?{...xt,[de]:ot}:null)},[]);return B||!s?l.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-8",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),l.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),l.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>k("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${C==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),l.jsxs("button",{onClick:()=>k("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${C==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(tp,{className:"w-4 h-4"}),"Smart Plugs",ne&&ne.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ne.length})]}),l.jsxs("button",{onClick:()=>k("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${C==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Ch,{className:"w-4 h-4"}),"Notifications",Me&&Me.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Me.length})]}),l.jsxs("button",{onClick:()=>k("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${C==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Wm,{className:"w-4 h-4"}),"API Keys",Se&&Se.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Se.length})]})]}),C==="general"&&l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(S0,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),l.jsx("select",{value:n.language,onChange:de=>n.changeLanguage(de.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:UF.map(de=>l.jsxs("option",{value:de.code,children:[de.nativeName," (",de.name,")"]},de.code))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),l.jsx("select",{value:A,onChange:de=>ce(de.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:T0.map(de=>l.jsx("option",{value:de.to,children:e(de.labelKey)},de.id))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),l.jsxs("select",{value:s.date_format||"system",onChange:de=>ve("date_format",de.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:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),l.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),l.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),l.jsxs("select",{value:s.time_format||"system",onChange:de=>ve("time_format",de.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:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),l.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),l.jsxs("select",{value:s.default_printer_id??"",onChange:de=>ve("default_printer_id",de.target.value?Number(de.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:[l.jsx("option",{value:"",children:"No default (ask each time)"}),ye?.map(de=>l.jsx("option",{value:de.id,children:de.name},de.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Sidebar order"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:Ie,children:[l.jsx(Qp,{className:"w-4 h-4"}),"Reset"]})]})]})]}),l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Auto-archive prints"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.auto_archive,onChange:de=>ve("auto_archive",de.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Save thumbnails"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.save_thumbnails,onChange:de=>ve("save_thumbnails",de.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Capture finish photo"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.capture_finish_photo,onChange:de=>ve("capture_finish_photo",de.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.capture_finish_photo&&rt&&!rt.installed&&l.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[l.jsx(Sr,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"text-sm",children:[l.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),l.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:s.default_filament_cost,onChange:de=>ve("default_filament_cost",parseFloat(de.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),l.jsxs("select",{value:s.currency,onChange:de=>ve("currency",de.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:[l.jsx("option",{value:"USD",children:"USD ($)"}),l.jsx("option",{value:"EUR",children:"EUR (€)"}),l.jsx("option",{value:"GBP",children:"GBP (£)"}),l.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),l.jsx("option",{value:"JPY",children:"JPY (¥)"}),l.jsx("option",{value:"CNY",children:"CNY (¥)"}),l.jsx("option",{value:"CAD",children:"CAD ($)"}),l.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:s.energy_cost_per_kwh,onChange:de=>ve("energy_cost_per_kwh",parseFloat(de.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),l.jsxs("select",{value:s.energy_tracking_mode||"total",onChange:de=>ve("energy_tracking_mode",de.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:[l.jsx("option",{value:"print",children:"Prints Only"}),l.jsx("option",{value:"total",children:"Total Consumption"})]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(mG,{className:"w-4 h-4 text-blue-400"}),l.jsx("span",{className:"font-medium",children:"Humidity"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:s.ams_humidity_good??40,onChange:de=>ve("ams_humidity_good",parseInt(de.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"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:s.ams_humidity_fair??60,onChange:de=>ve("ams_humidity_fair",parseInt(de.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"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),l.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(qS,{className:"w-4 h-4 text-orange-400"}),l.jsx("span",{className:"font-medium",children:"Temperature"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:s.ams_temp_good??28,onChange:de=>ve("ams_temp_good",parseFloat(de.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"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:s.ams_temp_fair??35,onChange:de=>ve("ams_temp_fair",parseFloat(de.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"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),l.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(gp,{className:"w-4 h-4 text-purple-400"}),l.jsx("span",{className:"font-medium",children:"History Retention"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"1",max:"365",value:s.ams_history_retention_days??30,onChange:de=>ve("ams_history_retention_days",parseInt(de.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]}),l.jsx(SGe,{})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[l.jsx(EGe,{}),l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Check for updates"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.check_updates,onChange:de=>ve("check_updates",de.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white",children:e("settings.telemetry")}),l.jsxs("button",{onClick:()=>Z(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[l.jsx(E0,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:s.telemetry_enabled,onChange:de=>ve("telemetry_enabled",de.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Current version"}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",He?.version||"..."]})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>Ge(),disabled:Ue,children:[Ue?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(Na,{className:"w-4 h-4"}),"Check now"]})]}),he?.update_available?l.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",he.latest_version]}),he.release_name&&he.release_name!==he.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:he.release_name})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[he.release_notes&&l.jsx("button",{onClick:()=>Le(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),he.release_url&&l.jsx("a",{href:he.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:l.jsx(Cs,{className:"w-4 h-4"})})]})]}),oe?.status==="downloading"||oe?.status==="installing"?l.jsxs("div",{className:"mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[l.jsx(_t,{className:"w-4 h-4 animate-spin"}),l.jsx("span",{children:oe.message})]}),l.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:l.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${oe.progress}%`}})})]}):oe?.status==="complete"?l.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:oe.message}):oe?.status==="error"?l.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:oe.error||oe.message}):l.jsxs(Pe,{className:"mt-3",onClick:()=>$e.mutate(),disabled:$e.isPending,children:[$e.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(ts,{className:"w-4 h-4"}),"Install Update"]})]}):he?.error?l.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: ",he.error]}):he&&!he.update_available?l.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),l.jsxs(Mt,{children:[l.jsx(Ga,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Backup Data"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>pe(!0),children:[l.jsx(ts,{className:"w-4 h-4"}),"Export"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Restore Backup"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>be(!0),children:[l.jsx(Ya,{className:"w-4 h-4"}),"Restore"]})]}),l.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[l.jsx(An,{className:"w-4 h-4"}),"Clear"]})]})}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),l.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."})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>U(!0),children:[l.jsx(An,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),C==="plugs"&&l.jsxs("div",{className:"max-w-4xl",children:[l.jsxs("div",{className:"flex items-start justify-between mb-6",children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(tp,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),l.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."})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ne&&ne.filter(de=>de.enabled).length>1&&l.jsxs(l.Fragment,{children:[l.jsxs(Pe,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("on"),disabled:Qe.isPending,title:"Turn all plugs on",children:[Qe.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(Ed,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),l.jsxs(Pe,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("off"),disabled:Qe.isPending,title:"Turn all plugs off",children:[Qe.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(ej,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),l.jsxs(Pe,{className:"whitespace-nowrap",onClick:()=>{f(null),u(!0)},children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ne&&ne.length>0&&l.jsxs(Mt,{className:"mb-6",children:[l.jsx(Ga,{children:l.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[l.jsx(_p,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",se&&l.jsx(_t,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),l.jsx(Nt,{children:Q?l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(_p,{className:"w-3 h-3"}),"Current Power"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Q.totalPower.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Q.reachableCount,"/",Q.totalPlugs," plugs online"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx($r,{className:"w-3 h-3"}),"Today"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Q.totalToday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Q.totalToday*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(SG,{className:"w-3 h-3"}),"Yesterday"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Q.totalYesterday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Q.totalYesterday*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(k1,{className:"w-3 h-3"}),"Total"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Q.totalLifetime.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),s&&s.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Q.totalLifetime*s.energy_cost_per_kwh).toFixed(2)," ",s.currency]})]})]}):se?null:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),V?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ne&&ne.length>0?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ne.map(de=>l.jsx(cGe,{plug:de,onEdit:ot=>{f(ot),u(!0)}},de.id))}):l.jsx(Mt,{children:l.jsx(Nt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(tp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),l.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),l.jsxs(Pe,{onClick:()=>{f(null),u(!0)},children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),C==="notifications"&&l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Ch,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>w(!0),children:[l.jsx(R1,{className:"w-4 h-4"}),"Log"]}),Me&&Me.length>0&&l.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>{ut(null),fe.mutate()},disabled:fe.isPending,children:[fe.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(tj,{className:"w-4 h-4"}),"Test All"]}),l.jsxs(Pe,{size:"sm",onClick:()=>{v(null),p(!0)},children:[l.jsx(tr,{className:"w-4 h-4"}),"Add"]})]})]}),l.jsx(Mt,{className:"mb-4",children:l.jsx(Nt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),l.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),l.jsx("select",{value:s.notification_language||"en",onChange:de=>ve("notification_language",de.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:UF.map(de=>l.jsx("option",{value:de.code,children:de.nativeName},de.code))})]})})}),Ye&&l.jsx(Mt,{className:"mb-4",children:l.jsxs(Nt,{className:"py-3",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),l.jsx("button",{onClick:()=>ut(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(_r,{className:"w-4 h-4"}),Ye.success," passed"]}),Ye.failed>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(Ea,{className:"w-4 h-4"}),Ye.failed," failed"]})]}),Ye.results.filter(de=>!de.success).length>0&&l.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ye.results.filter(de=>!de.success).map(de=>l.jsxs("div",{className:"text-xs text-red-400",children:[l.jsxs("span",{className:"font-medium",children:[de.provider_name,":"]})," ",de.message]},de.provider_id))})]})}),Ae?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(_t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Me&&Me.length>0?l.jsx("div",{className:"space-y-3",children:Me.map(de=>l.jsx(hGe,{provider:de,onEdit:ot=>{v(ot),p(!0)}},de.id))}):l.jsx(Mt,{children:l.jsx(Nt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Ch,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),l.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),l.jsxs(Pe,{size:"sm",onClick:()=>{v(null),p(!0)},children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[l.jsx(ws,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),xe?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(_t,{className:"w-6 h-6 text-bambu-green animate-spin"})}):we&&we.length>0?l.jsx("div",{className:"space-y-2",children:we.map(de=>l.jsx(Mt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>b(de),children:l.jsx(Nt,{className:"py-2.5 px-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-white font-medium text-sm truncate",children:de.name}),l.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:de.title_template})]}),l.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:ot=>{ot.stopPropagation(),b(de)},children:l.jsx(JR,{className:"w-4 h-4 text-bambu-gray"})})]})})},de.id))}):l.jsx(Mt,{children:l.jsx(Nt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(ws,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),C==="apikeys"&&l.jsxs("div",{className:"max-w-3xl",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Wm,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks. Use these keys to control your printers from automation tools like Home Assistant."})]}),l.jsxs(Pe,{size:"sm",onClick:()=>N(!0),className:"flex-shrink-0",children:[l.jsx(tr,{className:"w-4 h-4"}),"Create Key"]})]}),R&&l.jsx(Mt,{className:"mb-6 border-bambu-green",children:l.jsx(Nt,{className:"py-4",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(_r,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),l.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[l.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:R}),l.jsx(Pe,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(R);else{const de=document.createElement("textarea");de.value=R,de.style.position="fixed",de.style.left="-999999px",document.body.appendChild(de),de.select(),document.execCommand("copy"),document.body.removeChild(de)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:l.jsx(cd,{className:"w-4 h-4"})})]}),l.jsx(Pe,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>W(null),children:"Dismiss"})]})]})})}),F&&l.jsxs(Mt,{className:"mb-6",children:[l.jsx(Ga,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),l.jsx("input",{type:"text",value:j,onChange:de=>I(de.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_read_status,onChange:de=>q(ot=>({...ot,can_read_status:de.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Read Status"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_queue,onChange:de=>q(ot=>({...ot,can_queue:de.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Manage Queue"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:O.can_control_printer,onChange:de=>q(ot=>({...ot,can_control_printer:de.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Control Printer"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.jsxs(Pe,{onClick:()=>L.mutate({name:j||"Unnamed Key",...O}),disabled:L.isPending,children:[L.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(tr,{className:"w-4 h-4"}),"Create Key"]}),l.jsx(Pe,{variant:"secondary",onClick:()=>N(!1),children:"Cancel"})]})]})]}),$?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Se&&Se.length>0?l.jsx("div",{className:"space-y-3",children:Se.map(de=>l.jsx(Mt,{children:l.jsx(Nt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Wm,{className:`w-5 h-5 ${de.enabled?"text-bambu-green":"text-bambu-gray"}`}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium",children:de.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[de.key_prefix,"••••••••",de.last_used&&` · Last used: ${new Date(de.last_used).toLocaleDateString()}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex gap-1 text-xs",children:[de.can_read_status&&l.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),de.can_queue&&l.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),de.can_control_printer&&l.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),l.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>G(de.id),children:l.jsx(An,{className:"w-4 h-4 text-red-400"})})]})]})})},de.id))}):l.jsx(Mt,{children:l.jsx(Nt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Wm,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),l.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),l.jsxs(Pe,{onClick:()=>N(!0),children:[l.jsx(tr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),l.jsxs(Mt,{className:"mt-6",children:[l.jsx(Ga,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),l.jsxs(Nt,{className:"space-y-3 text-sm",children:[l.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",l.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),l.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-green-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),l.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),l.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),l.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-red-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),l.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),K!==null&&l.jsx(fi,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{re.mutate(K),G(null)},onCancel:()=>G(null)}),c&&l.jsx(uGe,{plug:d,onClose:()=>{u(!1),f(null)}}),g&&l.jsx(fGe,{provider:x,onClose:()=>{p(!1),v(null)}}),y&&l.jsx(mGe,{template:y,onClose:()=>b(null)}),E&&l.jsx(xGe,{onClose:()=>w(!1)}),te&&l.jsx(fi,{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()=>{Y(!1);try{const de=await Ce.clearNotificationLogs(30);r(de.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>Y(!1)}),J&&l.jsx(fi,{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:()=>{U(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>U(!1)}),H&&l.jsx(fi,{title:`Turn All Plugs ${H==="on"?"On":"Off"}`,message:`This will turn ${H==="on"?"ON":"OFF"} all ${ne?.filter(de=>de.enabled).length||0} enabled smart plugs. ${H==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${H==="on"?"On":"Off"}`,variant:H==="off"?"danger":"warning",onConfirm:()=>{const de=H;ee(null),Qe.mutate(de)},onCancel:()=>ee(null)}),ie&&l.jsx(yGe,{onClose:()=>pe(!1),onExport:async de=>{pe(!1);const ot="backup-progress",xt=de.archives;xt&&i(ot,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:Et,filename:Qt}=await Ce.exportBackup(de);xt&&a(ot);const Ot=URL.createObjectURL(Et),Vt=document.createElement("a");Vt.href=Ot,Vt.download=Qt,Vt.click(),URL.revokeObjectURL(Ot),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{xt&&a(ot),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),ue&&l.jsx(vGe,{onClose:()=>be(!1),onRestore:async(de,ot)=>await Ce.importBackup(de,ot),onSuccess:()=>{t.invalidateQueries()}}),Re&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Z(!1),children:l.jsxs(Mt,{className:"w-full max-w-lg",onClick:de=>de.stopPropagation(),children:[l.jsxs(Ga,{className:"flex flex-row items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(lue,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),l.jsx("button",{onClick:()=>Z(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs(Nt,{className:"space-y-4",children:[l.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem3")})]})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(Ea,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(Ea,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(Ea,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(Ea,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),l.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),l.jsx(Pe,{onClick:()=>Z(!1),className:"w-full",children:e("common.close")})]})]})}),_e&&he?.release_notes&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Le(!1),children:l.jsxs(Mt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:de=>de.stopPropagation(),children:[l.jsxs(Ga,{className:"flex flex-row items-center justify-between shrink-0",children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",he.latest_version]}),he.release_name&&he.release_name!==he.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray",children:he.release_name})]}),l.jsx("button",{onClick:()=>Le(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx(Nt,{className:"overflow-y-auto flex-1",children:l.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:he.release_notes})}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[he.release_url&&l.jsx("a",{href:he.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:l.jsxs(Pe,{variant:"secondary",className:"w-full",children:[l.jsx(Cs,{className:"w-4 h-4"}),"View on GitHub"]})}),l.jsx(Pe,{onClick:()=>Le(!1),className:"flex-1",children:"Close"})]})]})})]})}const _te=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},TGe=t=>t.startsWith("HH")?"HF":"S",CGe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},PR=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 xk({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:s}){const o=TGe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return l.jsxs("div",{className:"flex items-center gap-2",children:[r&&l.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?l.jsx(Kh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(bp,{className:"w-4 h-4"})}),l.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:_te(t.k_value)}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),s&&l.jsx("span",{title:"Has note",children:l.jsx(yG,{className:"w-3 h-3 text-yellow-500"})}),l.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",c]})]}),s&&l.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:s,children:["Note: ",s.length>50?s.substring(0,50)+"...":s]})]}),!r&&n&&l.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:l.jsx(cd,{className:"w-4 h-4"})})]})}function bk({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:s=null,onClose:o,onSave:c,onSaveNote:u}){const{showToast:d}=Gr(),[f,g]=M.useState(t?.name||""),[p,x]=M.useState(t?.k_value?_te(t.k_value):"0.020"),[v,y]=M.useState(t?.filament_id||""),[b,E]=M.useState(t?.nozzle_id?CGe(t.nozzle_id):"HH00"),[w,A]=M.useState(t?.nozzle_diameter||n),[T,C]=M.useState(t?[t.extruder_id]:i?[0,1]:[0]),[k,F]=M.useState(!1),[N,j]=M.useState({current:0,total:0}),[I,O]=M.useState(a),q=gr.useMemo(()=>{const J=new Map;for(const U of r)if(U.filament_id&&!J.has(U.filament_id)){const H=PR(U.name||"");J.set(U.filament_id,{id:U.filament_id,name:H||U.filament_id})}return Array.from(J.values()).sort((U,H)=>U.name.localeCompare(H.name))},[r]),R=vt({mutationFn:J=>(console.log("[KProfile] Calling API..."),Ce.setKProfile(e,J)),onSuccess:J=>{if(console.log("[KProfile] Save success:",J),d("K-profile saved"),u&&I!==a){let U;I===""&&s?U=s:t&&t.slot_id>0?U=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:U=`name_${f}_${v}`,u(U,I)}F(!0),setTimeout(()=>{F(!1),c()},2500)},onError:J=>{console.error("[KProfile] Save error:",J),d(J.message,"error"),F(!1)}}),W=vt({mutationFn:J=>(console.log("[KProfile] Deleting profile..."),Ce.deleteKProfile(e,J)),onSuccess:J=>{console.log("[KProfile] Delete success:",J),d("K-profile deleted"),F(!0),setTimeout(()=>{F(!1),o()},4e3)},onError:J=>{console.error("[KProfile] Delete error:",J),d(J.message,"error"),F(!1)}}),[K,G]=M.useState(!1),te=()=>{t&&W.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Y=async J=>{if(J.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const U=parseFloat(p).toFixed(6),H=`${b}-${w}`;if(t||T.length===1){const ie={name:f,k_value:U,filament_id:v,nozzle_id:H,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:",ie),R.mutate(ie);return}F(!0),j({current:1,total:T.length});const ee=T.map(ie=>({name:f,k_value:U,filament_id:v,nozzle_id:H,nozzle_diameter:w,extruder_id:ie,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ee.length} profiles in batch:`,ee);try{if(await Ce.setKProfilesBatch(e,ee),d(`K-profile saved to ${T.length} extruders`),u&&I){const ie=`name_${f}_${v}`;u(ie,I)}}catch(ie){console.error("[KProfile] Failed to save batch:",ie),d("Failed to save K-profiles","error"),F(!1),j({current:0,total:0});return}j({current:T.length,total:T.length}),setTimeout(()=>{F(!1),j({current:0,total:0}),c()},3e3)};return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[l.jsxs(Mt,{className:"w-full max-w-md relative",children:[k&&l.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),l.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),l.jsxs(Nt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),l.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:k,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Y,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),l.jsx("input",{type:"text",value:f,onChange:J=>g(J.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),l.jsx("input",{type:"text",inputMode:"decimal",value:p,onChange:J=>{const U=J.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&x(U)},onBlur:J=>{const U=parseFloat(J.target.value);isNaN(U)||x((Math.trunc(U*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}),l.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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),l.jsxs("select",{value:v,onChange:J=>{const U=J.target.value;if(y(U),!t&&U&&!f){const H=q.find(ee=>ee.id===U);H&&g(`${b==="HH00"?"HF":"S"} ${H.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:[l.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&l.jsx("option",{value:t.filament_id,children:q.find(J=>J.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(J=>l.jsx("option",{value:J.id,children:J.name},J.id))]}),!t&&q.length===0&&l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),l.jsxs("select",{value:b,onChange:J=>{const U=J.target.value;if(E(U),!t&&v&&!f){const H=q.find(ee=>ee.id===v);H&&g(`${U==="HS00"?"HF":"S"} ${H.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:[l.jsx("option",{value:"HH00",children:"High Flow"}),l.jsx("option",{value:"HS00",children:"Standard"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),l.jsxs("select",{value:w,onChange:J=>A(J.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:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?l.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"}):l.jsxs("div",{className:"flex gap-4",children:[l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:J=>{J.target.checked?C([...T,1]):C(T.filter(U=>U!==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"}),l.jsx("span",{className:"text-white",children:"Left"})]}),l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:J=>{J.target.checked?C([...T,0]):C(T.filter(U=>U!==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"}),l.jsx("span",{className:"text-white",children:"Right"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),l.jsx("textarea",{value:I,onChange:J=>O(J.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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),l.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&l.jsx(Pe,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:W.isPending||k,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(An,{className:"w-4 h-4"})}),l.jsx(Pe,{type:"button",variant:"secondary",onClick:o,disabled:k,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{type:"submit",disabled:R.isPending||k,className:"flex-1",children:[R.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(YR,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:l.jsx(Mt,{className:"w-full max-w-sm",children:l.jsxs(Nt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(An,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Pe,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{onClick:()=>{G(!1),te()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const Q_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function NGe(){const{showToast:t}=Gr(),[e,n]=M.useState(null),[r,i]=M.useState(()=>localStorage.getItem(Q_.NOZZLE_DIAMETER)||"0.4"),[a,s]=M.useState(null),[o,c]=M.useState(!1),[u,d]=M.useState(null),[f,g]=M.useState(""),[p,x]=M.useState("all"),[v,y]=M.useState("all"),[b,E]=M.useState(()=>localStorage.getItem(Q_.SORT_OPTION)||"name"),[w,A]=M.useState(!1),[T,C]=M.useState(new Set),[k,F]=M.useState(!1),[N,j]=M.useState(!1),I=V=>`${V.slot_id}_${V.extruder_id}`;M.useEffect(()=>{localStorage.setItem(Q_.NOZZLE_DIAMETER,r)},[r]),M.useEffect(()=>{localStorage.setItem(Q_.SORT_OPTION,b)},[b]);const{data:O,isLoading:q}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:R,isLoading:W,isFetching:K,error:G,refetch:te}=yt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const V=await Ce.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:Y}=yt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Ce.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:J,refetch:U}=yt({queryKey:["kprofile-notes",e],queryFn:()=>Ce.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),H=G?.message?.includes("not connected");M.useEffect(()=>{if(!e&&O&&O.length>0){const V=O.find(Q=>Q.is_active);V&&n(V.id)}},[e,O]),M.useEffect(()=>{if(e){const V=setTimeout(()=>{te()},150);return()=>clearTimeout(V)}},[e,r]);const ee=O?.filter(V=>V.is_active)||[],ie=gr.useMemo(()=>R?.profiles?R.profiles.filter(Q=>{const se=f.toLowerCase(),Me=!se||Q.name.toLowerCase().includes(se)||Q.filament_id.toLowerCase().includes(se),Ae=p==="all"||p==="left"&&Q.extruder_id===1||p==="right"&&Q.extruder_id===0,Se=v==="all"||v==="hf"&&Q.nozzle_id.startsWith("HH")||v==="s"&&Q.nozzle_id.startsWith("HS");return Me&&Ae&&Se}).sort((Q,se)=>{switch(b){case"k_value":return parseFloat(Q.k_value)-parseFloat(se.k_value);case"filament":return PR(Q.name).localeCompare(PR(se.name));case"name":default:return Q.name.localeCompare(se.name)}}):[],[R?.profiles,f,p,v,b]),pe=O?.find(V=>V.id===e),ue=pe?.nozzle_count===2;M.useEffect(()=>{const V=Q=>{Q.target instanceof HTMLInputElement||Q.target instanceof HTMLTextAreaElement||Q.target instanceof HTMLSelectElement||a||o||u||(Q.key==="r"||Q.key==="R"?(Q.preventDefault(),te()):Q.key==="n"||Q.key==="N"?(Q.preventDefault(),c(!0)):Q.key==="Escape"&&w&&(Q.preventDefault(),A(!1),C(new Set)))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[a,o,u,w,te]);const be=M.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const V={version:1,exported_at:new Date().toISOString(),printer:pe?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Ae=>({name:Ae.name,k_value:Ae.k_value,filament_id:Ae.filament_id,nozzle_id:Ae.nozzle_id,nozzle_diameter:Ae.nozzle_diameter,extruder_id:Ae.extruder_id}))},Q=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),se=URL.createObjectURL(Q),Me=document.createElement("a");Me.href=se,Me.download=`kprofiles_${pe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),URL.revokeObjectURL(se),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,pe,r,t]),Re=M.useCallback(()=>{const V=document.createElement("input");V.type="file",V.accept=".json",V.onchange=async Q=>{const se=Q.target.files?.[0];if(se)try{const Me=await se.text(),Ae=JSON.parse(Me);if(!Ae.profiles||!Array.isArray(Ae.profiles)){t("Invalid file format","error");return}let Se=0;for(const $ of Ae.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await Ce.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),Se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",$.name,L)}t(`Imported ${Se} of ${Ae.profiles.length} profiles`),te()}catch(Me){console.error("Import error:",Me),t("Failed to parse import file","error")}},V.click()},[e,r,t,te]),Z=M.useCallback(V=>{C(Q=>{const se=new Set(Q);return se.has(V)?se.delete(V):se.add(V),se})},[]),_e=M.useCallback(()=>{C(new Set(ie.map(V=>I(V))))},[ie,I]),Le=M.useCallback(()=>{T.size!==0&&F(!0)},[T.size]),ce=M.useCallback(async()=>{const V=ie.filter(se=>T.has(I(se)));j(!0);let Q=0;for(const se of V)try{await Ce.deleteKProfile(e,{slot_id:se.slot_id,extruder_id:se.extruder_id,nozzle_id:se.nozzle_id,nozzle_diameter:se.nozzle_diameter,filament_id:se.filament_id,setting_id:se.setting_id}),Q++,await new Promise(Me=>setTimeout(Me,300))}catch(Me){console.error("Failed to delete profile:",se.name,Me)}t(`Deleted ${Q} profiles`),j(!1),F(!1),A(!1),C(new Set),te()},[e,T,ie,t,te,I]),Ie=M.useCallback(V=>{const Q=[];return V.setting_id&&Q.push(V.setting_id),Q.push(`slot_${V.slot_id}_${V.filament_id}_${V.extruder_id}`),Q.push(`name_${V.name}_${V.filament_id}`),Q},[]),z=M.useCallback(async(V,Q)=>{if(e)try{await Ce.setKProfileNote(e,V,Q),U()}catch(se){console.error("Failed to save note:",se),t("Failed to save note","error")}},[e,U,t]),B=M.useCallback(V=>{if(!J?.notes)return{note:"",key:null};const Q=Ie(V);for(const se of Q)if(J.notes[se])return{note:J.notes[se],key:se};return{note:"",key:null}},[J,Ie]),ne=M.useCallback(V=>B(V).note,[B]);return q?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!O||O.length===0?l.jsx(Mt,{children:l.jsxs(Nt,{className:"py-12 text-center",children:[l.jsx(co,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ee.length===0?l.jsx(Mt,{children:l.jsxs(Nt,{className:"py-12 text-center",children:[l.jsx(pa,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),l.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):l.jsxs(l.Fragment,{children:[K&&!W&&l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[l.jsx(_t,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),l.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[l.jsxs("div",{className:"flex-1 min-w-48",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),l.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:ee.map(V=>l.jsx("option",{value:V.id,children:V.name},V.id))})]}),l.jsxs("div",{className:"w-32",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),l.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:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs(Pe,{variant:"secondary",onClick:()=>te(),disabled:K,children:[l.jsx(Na,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Pe,{onClick:()=>c(!0),children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[l.jsxs("div",{className:"flex-1 min-w-48 relative",children:[l.jsx(Rc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:f,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"})]}),ue&&l.jsx("div",{className:"w-36",children:l.jsxs("select",{value:p,onChange:V=>x(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:[l.jsx("option",{value:"all",children:"All Extruders"}),l.jsx("option",{value:"left",children:"Left Only"}),l.jsx("option",{value:"right",children:"Right Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{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",children:[l.jsx("option",{value:"all",children:"All Flow"}),l.jsx("option",{value:"hf",children:"HF Only"}),l.jsx("option",{value:"s",children:"S Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{value:b,onChange:V=>E(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:[l.jsx("option",{value:"name",children:"Sort: Name"}),l.jsx("option",{value:"k_value",children:"Sort: K-Value"}),l.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[l.jsxs(Pe,{variant:"secondary",onClick:be,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[l.jsx(ts,{className:"w-4 h-4"}),"Export"]}),l.jsxs(Pe,{variant:"secondary",onClick:Re,title:"Import profiles from JSON",children:[l.jsx(Ya,{className:"w-4 h-4"}),"Import"]}),l.jsx("div",{className:"flex-1"}),w?l.jsxs(l.Fragment,{children:[l.jsxs(Pe,{variant:"secondary",onClick:_e,title:"Select all visible profiles",children:[l.jsx(Kh,{className:"w-4 h-4"}),"Select All"]}),l.jsxs(Pe,{variant:"secondary",onClick:Le,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[l.jsx(An,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),l.jsxs(Pe,{variant:"secondary",onClick:()=>{A(!1),C(new Set)},children:[l.jsx(Wt,{className:"w-4 h-4"}),"Cancel"]})]}):l.jsxs(Pe,{variant:"secondary",onClick:()=>A(!0),disabled:!ie.length,title:"Enter selection mode for bulk delete",children:[l.jsx(Kh,{className:"w-4 h-4"}),"Select"]})]}),W?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):H?l.jsx(Mt,{children:l.jsxs(Nt,{className:"py-12 text-center",children:[l.jsx(rj,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),l.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),l.jsxs(Pe,{variant:"secondary",onClick:()=>te(),children:[l.jsx(Na,{className:"w-4 h-4"}),"Retry"]})]})}):ie.length>0?ue?l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),l.jsx("div",{className:"space-y-1",children:ie.filter(V=>V.extruder_id===1).map(V=>l.jsx(xk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(I(V)),onToggleSelect:()=>Z(I(V)),note:ne(V)},I(V)))})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),l.jsx("div",{className:"space-y-1",children:ie.filter(V=>V.extruder_id===0).map(V=>l.jsx(xk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(I(V)),onToggleSelect:()=>Z(I(V)),note:ne(V)},I(V)))})]})]}):l.jsx("div",{className:"space-y-1",children:ie.map(V=>l.jsx(xk,{profile:V,onEdit:()=>s(V),onCopy:()=>d(V),selectionMode:w,isSelected:T.has(I(V)),onToggleSelect:()=>Z(I(V)),note:ne(V)},I(V)))}):f||p!=="all"||v!=="all"?l.jsx(Mt,{children:l.jsxs(Nt,{className:"py-12 text-center",children:[l.jsx(Rc,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):l.jsx(Mt,{children:l.jsxs(Nt,{className:"py-12 text-center",children:[l.jsx(YR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),l.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),l.jsxs(Pe,{onClick:()=>c(!0),children:[l.jsx(tr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:V,key:Q}=B(a);return l.jsx(bk,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:ue,initialNote:V,initialNoteKey:Q,onSaveNote:z,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),te()},onSave:()=>{s(null),te()}})})(),o&&e&&l.jsx(bk,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:ue,onSaveNote:z,onClose:()=>{c(!1),te()},onSave:()=>{c(!1),te()}}),u&&e&&l.jsx(bk,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:ue,onSaveNote:z,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),te()},onSave:()=>{d(null),te()}}),k&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Mt,{className:"w-full max-w-sm",children:l.jsxs(Nt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(An,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Pe,{variant:"secondary",onClick:()=>F(!1),disabled:N,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{onClick:ce,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function TL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),s=a?(a[1]||a[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=o?o[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:s,layerHeight:c,filamentType:d}}function fb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function kGe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),s=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:s<7?`${s}d ago`:e.toLocaleDateString()}function PGe({onSuccess:t}){const{showToast:e}=Gr(),[n,r]=M.useState("email"),[i,a]=M.useState(""),[s,o]=M.useState(""),[c,u]=M.useState(""),[d,f]=M.useState(""),[g,p]=M.useState("global"),x=vt({mutationFn:()=>Ce.cloudLogin(i,s,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=vt({mutationFn:()=>Ce.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=vt({mutationFn:()=>Ce.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),b=w=>{w.preventDefault(),n==="email"?x.mutate():n==="code"?v.mutate():n==="token"&&y.mutate()},E=x.isPending||v.isPending||y.isPending;return l.jsx(Mt,{className:"max-w-md mx-auto",children:l.jsxs(Nt,{children:[l.jsxs("div",{className:"text-center mb-6",children:[l.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:l.jsx($S,{className:"w-6 h-6 text-bambu-green"})}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),l.jsxs("form",{onSubmit:b,className:"space-y-4",children:[n==="email"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),l.jsx("input",{type:"email",value:i,onChange:w=>a(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),l.jsx("input",{type:"password",value:s,onChange:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),l.jsxs("select",{value:g,onChange:w=>p(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:[l.jsx("option",{value:"global",children:"Global"}),l.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),l.jsx("input",{type:"text",value:c,onChange:w=>u(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),l.jsx("textarea",{value:d,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),l.jsxs("div",{className:"flex gap-2",children:[n==="code"&&l.jsx(Pe,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),l.jsxs(Pe,{type:"submit",disabled:E,className:"flex-1",children:[E?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(sU,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[l.jsx(Wm,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[l.jsx(sU,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Fm({label:t,value:e,options:n,onChange:r}){const[i,a]=M.useState(!1),s=n.find(o=>o.value===e);return l.jsxs("div",{className:"relative",children:[l.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[l.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),l.jsx("span",{children:s?.label||"All"}),l.jsx(Hc,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),l.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=>l.jsxs("button",{onClick:()=>{r(o.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[l.jsx("span",{children:o.label}),o.count!==void 0&&l.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function RGe(){const[t,e]=M.useState(!1);M.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?l.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:l.jsx(mp,{className:"w-5 h-5"})}):null}function yk({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:s}){const o=TL(t.name),c=fb(t.setting_id);return l.jsxs("div",{className:"flex items-center gap-2 group",children:[l.jsx("button",{onClick:e,disabled:s,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":s?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!s?"cursor-pointer":""}`,children:l.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&l.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&c&&l.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),l.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:l.jsx(cd,{className:"w-4 h-4"})})]})}function RR(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(`
  8230. `)){const i=t.replace(/\\n/g,`
  8231. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8232. `);if(i.length>1)return`"""
  8233. `+i.map(a=>n+" "+a).join(`
  8234. `)+`
  8235. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8236. `+t.map(i=>n+" "+RR(i,e+1)).join(`,
  8237. `)+`
  8238. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8239. `+r.map(([a,s])=>n+" "+JSON.stringify(a)+": "+RR(s,e+1)).join(`,
  8240. `)+`
  8241. `+n+"}"}return String(t)}function jGe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Gr(),s=Mn(),[o,c]=M.useState(!1),{data:u,isLoading:d}=yt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Ce.getCloudSettingDetail(t.setting_id)}),f=vt({mutationFn:()=>Ce.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),s.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),g=fb(t.setting_id),p=TL(t.name,u?.setting?.inherits);return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Mt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:l.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&l.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[l.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"•"}),l.jsx("span",{children:p.printer})]})]})]}),l.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex items-center justify-center py-16",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?l.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:RR(u)}):l.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?l.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[l.jsx(Sr,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Pe,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]})]}):l.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Pe,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),l.jsxs(Pe,{variant:"secondary",onClick:r,children:[l.jsx(cd,{className:"w-4 h-4"}),"Duplicate"]}),g&&l.jsxs(l.Fragment,{children:[l.jsxs(Pe,{variant:"secondary",onClick:i,disabled:d||!u,children:[l.jsx(dd,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Pe,{variant:"danger",onClick:()=>c(!0),children:l.jsx(An,{className:"w-4 h-4"})})]})]})})]})})})}function wte(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Ste(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function DGe({onClose:t,onApply:e}){const{showToast:n}=Gr(),[r,i]=M.useState(wte),[a,s]=M.useState("all"),[o,c]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(""),[p,x]=M.useState("{}"),[v,y]=M.useState(null),[b,E]=M.useState(null),w=a==="all"?r:r.filter(O=>O.type===a),A=O=>{i(O),Ste(O)},T=O=>{const q=r.filter(R=>R.id!==O);A(q),E(null),n("Template deleted")},C=O=>{c(O.id),d(O.name),g(O.description),x(JSON.stringify(O.settings,null,2)),y(null)},k=()=>{if(!(!o||!u.trim()))try{const O=JSON.parse(p),q=r.map(R=>R.id===o?{...R,name:u.trim(),description:f.trim(),settings:O}:R);A(q),c(null),n("Template updated")}catch(O){y(O.message)}},F=()=>{c(null),d(""),g(""),x("{}"),y(null)},N=O=>{const q=r.map(R=>R.id===O?{...R,showInModal:!R.showInModal}:R);A(q)},j={filament:{label:"Filament",icon:GR,color:"text-amber-400"},print:{label:"Process",icon:WS,color:"text-blue-400"},printer:{label:"Printer",icon:pa,color:"text-purple-400"}},I=b?r.find(O=>O.id===b):null;return M.useEffect(()=>{const O=q=>{q.key==="Escape"&&(b?E(null):o?F():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[b,o,t]),l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[I&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:l.jsx(Mt,{className:"w-full max-w-md",children:l.jsxs(Nt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:l.jsx(Sr,{className:"w-6 h-6 text-red-400"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),l.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',l.jsx("span",{className:"font-medium",children:I.name}),'"?']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Pe,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{onClick:()=>T(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]})]})})}),l.jsx(Mt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:l.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(A0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>l.jsx("button",{onClick:()=>s(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":j[O].label},O))]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(A0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:"No templates yet"}),l.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):l.jsx("div",{className:"space-y-2",children:w.map(O=>{const q=j[O.type],R=q.icon;return o===O.id?l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[l.jsx("input",{type:"text",value:u,onChange:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:f,onChange:W=>g(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"mb-3",children:[l.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),l.jsx("textarea",{value:p,onChange:W=>{x(W.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&l.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Pe,{size:"sm",onClick:k,disabled:!u.trim(),children:[l.jsx(no,{className:"w-4 h-4"}),"Save"]}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:F,children:"Cancel"})]})]},O.id):l.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:[l.jsx(R,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:O.name}),l.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),l.jsx("button",{onClick:()=>N(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?l.jsx(xp,{className:"w-4 h-4"}):l.jsx(qR,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),l.jsx("button",{onClick:()=>C(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:l.jsx(dd,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>E(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:l.jsx(An,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function Mte({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,s]=M.useState("changes"),[o,c]=M.useState(""),u=M.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const v of p){if(v==="inherits"||v==="version")continue;const y=e[v],b=n[v],E=v in e,w=v in n;let A;!E&&w?A="added":E&&!w?A="removed":JSON.stringify(y)!==JSON.stringify(b)?A="changed":A="same",x.push({key:v,left:y,right:b,status:A})}return x.sort((v,y)=>{const b={changed:0,added:1,removed:2,same:3};return b[v.status]!==b[y.status]?b[v.status]-b[y.status]:v.key.localeCompare(y.key)})},[e,n]),d=M.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(x=>x.status!=="same")),o){const x=o.toLowerCase();p=p.filter(v=>v.key.toLowerCase().includes(x)||String(v.left).toLowerCase().includes(x)||String(v.right).toLowerCase().includes(x))}return p},[u,a,o]),f=M.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),g=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const v=x.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return M.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsx(Mt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:l.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(ep,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),l.jsx("p",{className:"text-white font-medium truncate",children:r})]}),l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),l.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[l.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[l.jsx(tr,{className:"w-3.5 h-3.5"}),f.added," added"]}),l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(Fk,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),l.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[l.jsx(Dk,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),l.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[l.jsx(IA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsx(Rc,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:o,onChange:p=>c(p.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&l.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>s("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),l.jsx("button",{onClick:()=>s("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(IA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:l.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[l.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),l.jsx("th",{className:"text-left p-3 w-1/3",children:r}),l.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),l.jsx("tbody",{children:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],v={added:l.jsx(tr,{className:"w-3.5 h-3.5 text-green-400"}),removed:l.jsx(Fk,{className:"w-3.5 h-3.5 text-red-400"}),changed:l.jsx(Dk,{className:"w-3.5 h-3.5 text-amber-400"}),same:l.jsx(IA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return l.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[l.jsx("td",{className:"p-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[v,l.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),l.jsx("td",{className:"p-3",children:l.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.left)})}),l.jsx("td",{className:"p-3",children:l.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.right)})})]},p.key)})})]})})]})})})}function OGe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Gr(),i=Mn(),a=!!e?.setting_id,[s,o]=M.useState("common"),[c,u]=M.useState(e?.type||"filament"),[d,f]=M.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,p]=M.useState(e?.base_id||""),[x,v]=M.useState(""),[y,b]=M.useState(e?.setting||{inherits:""}),[E,w]=M.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,T]=M.useState(null),[C,k]=M.useState(""),[F,N]=M.useState(!1),[j,I]=M.useState(""),[O,q]=M.useState(!1),[R,W]=M.useState(wte),[K,G]=M.useState(!1),[te,Y]=M.useState(""),[J,U]=M.useState(""),[H,ee]=M.useState(!0),[ie,pe]=M.useState(null),[ue,be]=M.useState(!1),Re=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),Z=M.useMemo(()=>Re.filter(oe=>fb(oe.setting_id)),[Re]),{data:_e}=yt({queryKey:["cloudFields",c],queryFn:()=>Ce.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Le}=yt({queryKey:["allPresetDetails",c,Z.map(oe=>oe.setting_id).join(",")],queryFn:async()=>{const oe={};for(let $e=0;$e<Z.length;$e+=5){const Ye=Z.slice($e,$e+5);(await Promise.all(Ye.map(async fe=>{try{const Qe=await Ce.getCloudSettingDetail(fe.setting_id);return{id:fe.setting_id,detail:Qe}}catch{return null}}))).forEach(fe=>{fe&&(oe[fe.id]=fe.detail)})}return oe},enabled:Z.length>0,staleTime:1e3*60*10}),{data:ce,isLoading:Ie}=yt({queryKey:["cloudSettingDetail",g],queryFn:()=>Ce.getCloudSettingDetail(g),enabled:!!g});M.useEffect(()=>{s!=="json"&&w(JSON.stringify(y,null,2))},[y,s]);const z=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(tt=>!fb(tt.setting_id)).sort((tt,$e)=>tt.name.localeCompare($e.name)),[n,c]);M.useEffect(()=>{if(!g)return;const oe=z.find(tt=>tt.setting_id===g);oe&&(v(oe.name),a||(b({inherits:oe.name}),w(JSON.stringify({inherits:oe.name},null,2))))},[g,z,a]);const B=M.useMemo(()=>{const oe=_e?.fields||[],tt=new Set(oe.map(fe=>fe.key)),$e=new Set,Ye=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Le&&Object.values(Le).forEach(fe=>{fe?.setting&&Object.keys(fe.setting).forEach(Qe=>{!tt.has(Qe)&&!Ye.has(Qe)&&$e.add(Qe)})}),Object.keys(y).forEach(fe=>{!tt.has(fe)&&!Ye.has(fe)&&$e.add(fe)});const ut=Array.from($e).sort().map(fe=>({key:fe,label:fe.replace(/_/g," ").replace(/\b\w/g,Qe=>Qe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...oe,...ut]},[_e,Le,y]),ne=B.filter(oe=>oe.label.toLowerCase().includes(C.toLowerCase())||oe.key.toLowerCase().includes(C.toLowerCase())),V=()=>{if(j.trim()){const oe=j.trim().toLowerCase().replace(/\s+/g,"_");Q(oe,""),I(""),q(!1),r(`Field "${oe}" added`)}},Q=(oe,tt)=>{b($e=>{const Ye={...$e};return tt===""||tt===void 0?delete Ye[oe]:Ye[oe]=tt,Ye})},se=oe=>{b(tt=>({...tt,...oe.settings})),pe(oe.name),r("Template applied")},Me=()=>{if(!te.trim())return;const oe={...y};if(delete oe.inherits,Object.keys(oe).length===0){r("No overrides to save","error");return}const tt={id:Date.now().toString(),name:te.trim(),description:J.trim()||"Custom template",type:c,settings:oe,showInModal:H},$e=[...R,tt];W($e),Ste($e),G(!1),Y(""),U(""),ee(!0),r("Template saved")},Ae=M.useMemo(()=>R.filter(oe=>oe.type===c&&oe.showInModal),[c,R]),Se=oe=>{w(oe);try{const tt=JSON.parse(oe);b(tt),T(null)}catch(tt){T(tt.message)}},$=oe=>{oe.preventDefault(),N(!1);const tt=oe.dataTransfer.files[0];if(tt&&tt.name.endsWith(".json")){const $e=new FileReader;$e.onload=Ye=>{try{const ut=Ye.target?.result,fe=JSON.parse(ut),Qe=fe.setting||fe;b(ge=>({...ge,...Qe})),w(JSON.stringify({...y,...Qe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},$e.readAsText(tt)}},L=vt({mutationFn:()=>{const oe={...y},tt=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";oe[tt]=`"${d}"`;const $e={type:c,name:d,base_id:g,setting:oe};return Ce.createCloudSetting($e)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),re=vt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return Ce.updateCloudSetting(e.setting_id,{name:d,setting:y})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),ye=a?re:L,we=ce?.setting?.inherits,xe=we?z.find(oe=>oe.name===we):void 0,{data:rt}=yt({queryKey:["cloudSettingDetail",xe?.setting_id],queryFn:()=>Ce.getCloudSettingDetail(xe.setting_id),enabled:!!xe?.setting_id}),He=M.useMemo(()=>{const oe=rt?.setting||{},tt=ce?.setting||{},$e=g&&Le?.[g]?.setting?Le[g].setting:{};return{...oe,...tt,...$e}},[g,ce,rt,Le]),he=oe=>{if(oe==null)return"";if(Array.isArray(oe)){const tt=[...new Set(oe.map($e=>String($e)))];return tt.length===1?tt[0]:oe.join(", ")}return String(oe)},Ge=oe=>{const tt=y[oe.key],$e=He[oe.key],Ye=he($e),ut=Ie?"Loading...":Ye||"",fe="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(oe.type==="boolean"){const Qe=tt==="1"||tt===void 0&&$e==="1";return l.jsx("button",{type:"button",onClick:()=>Q(oe.key,tt==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Qe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:l.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Qe?"translate-x-3.5":"translate-x-0.5"}`})})}return oe.type==="select"?l.jsxs("select",{value:tt||"",onChange:Qe=>Q(oe.key,Qe.target.value),className:fe,children:[l.jsx("option",{value:"",children:ut}),oe.options?.map(Qe=>l.jsx("option",{value:Qe.value,children:Qe.label},Qe.value))]}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:oe.type==="number"?"number":"text",value:tt!==void 0?String(tt):"",onChange:Qe=>Q(oe.key,Qe.target.value),step:oe.step,min:oe.min,max:oe.max,placeholder:ut,className:fe}),oe.unit&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:oe.unit})]})},Ue=M.useMemo(()=>ce?.setting?ce.setting:{},[ce]);return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:oe=>{oe.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:$,children:[ue&&g&&l.jsx(Mte,{onClose:()=>be(!1),leftPreset:Ue,rightPreset:y,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),l.jsx(Mt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:l.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[g&&l.jsxs("button",{onClick:()=>be(!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:[l.jsx(ep,{className:"w-4 h-4"}),"Compare"]}),l.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),F&&l.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:l.jsxs("div",{className:"text-center",children:[l.jsx(Ya,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),l.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),l.jsxs("select",{value:c,onChange:oe=>{u(oe.target.value),p("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"filament",children:"Filament"}),l.jsx("option",{value:"print",children:"Process"}),l.jsx("option",{value:"printer",children:"Printer"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),l.jsxs("select",{value:g,onChange:oe=>p(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"Select base preset..."}),z.map(oe=>l.jsx("option",{value:oe.setting_id,children:oe.name},oe.setting_id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),l.jsx("input",{type:"text",value:d,onChange:oe=>f(oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&l.jsx("div",{className:"text-xs text-bambu-gray",children:l.jsxs("p",{className:"flex items-center gap-1",children:[l.jsx(Gh,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",l.jsx("span",{className:"text-white",children:x}),Ie&&l.jsx(_t,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.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 ${s==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(oU,{className:"w-4 h-4"}),"Common"]}),l.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 ${s==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(QR,{className:"w-4 h-4"}),"All Fields"]}),l.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 ${s==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(fG,{className:"w-4 h-4"}),"JSON",A&&l.jsx(co,{className:"w-3 h-3 text-red-400"})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{const oe={name:d,type:c,base_id:g,setting:y},tt=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),$e=URL.createObjectURL(tt),Ye=document.createElement("a");Ye.href=$e,Ye.download=`${d||"preset"}.json`,document.body.appendChild(Ye),Ye.click(),document.body.removeChild(Ye),URL.revokeObjectURL($e),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:[l.jsx(ts,{className:"w-4 h-4"}),"Export"]}),l.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:[l.jsx(Ya,{className:"w-4 h-4"}),"Import"]}),l.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:oe=>{const tt=oe.target.files?.[0];if(tt){const $e=new FileReader;$e.onload=Ye=>{try{const ut=JSON.parse(Ye.target?.result),fe=ut.setting||ut;b(Qe=>({...Qe,...fe})),r("File imported")}catch{r("Invalid JSON","error")}},$e.readAsText(tt)}}})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[s==="common"&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(A0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(y).filter(oe=>oe!=="inherits").length>0&&l.jsxs("button",{onClick:()=>G(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[l.jsx(no,{className:"w-3 h-3"}),"Save as template"]})]}),K&&l.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[l.jsx("input",{type:"text",value:te,onChange:oe=>Y(oe.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:J,onChange:oe=>U(oe.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Pe,{size:"sm",onClick:Me,disabled:!te.trim(),children:[l.jsx(no,{className:"w-3 h-3"}),"Save"]}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),l.jsxs("button",{onClick:()=>ee(!H),className:`flex items-center gap-1.5 text-xs transition-colors ${H?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[H?l.jsx(xp,{className:"w-3.5 h-3.5"}):l.jsx(qR,{className:"w-3.5 h-3.5"}),H?"Show in modals":"Hidden in modals"]})]})]}),ie&&l.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:[l.jsx(Gh,{className:"w-4 h-4 text-bambu-green"}),l.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",l.jsx("span",{className:"font-medium",children:ie})]}),l.jsx("button",{onClick:()=>pe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ae.map(oe=>l.jsxs("button",{onClick:()=>se(oe),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:oe.name}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:oe.description})]},oe.id)),Ae.length===0&&l.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."})]}),l.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),l.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:B.slice(0,10).map(oe=>l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:oe.label}),l.jsx("div",{className:"w-48",children:Ge(oe)})]},oe.key))})]}),Object.keys(y).length>1&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([oe])=>oe!=="inherits").map(([oe,tt])=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[oe,": ",String(tt).slice(0,20),l.jsx("button",{onClick:()=>Q(oe,void 0),className:"hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},oe))})]})]}),s==="fields"&&l.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),l.jsx("span",{className:"text-xs text-bambu-gray",children:Le?`${B.length} fields`:"Loading..."})]}),l.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[l.jsx(Rc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:C,onChange:oe=>k(oe.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[ne.filter(oe=>!(oe.key in y)).map(oe=>{const tt=He[oe.key],$e=he(tt);return l.jsxs("div",{onClick:()=>{b(Ye=>({...Ye,[oe.key]:$e||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-sm text-white truncate",children:oe.label}),l.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:oe.key})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[$e&&l.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:$e,children:[$e.slice(0,20),$e.length>20?"...":""]}),l.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:l.jsx(tr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},oe.key)}),ne.filter(oe=>!(oe.key in y)).length===0&&l.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:C?"No matching fields":"All fields added"})]}),l.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:O?l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:j,onChange:oe=>I(oe.target.value),onKeyDown:oe=>oe.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}),l.jsx(Pe,{size:"sm",onClick:V,disabled:!j.trim(),children:l.jsx(tr,{className:"w-4 h-4"})}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>{q(!1),I("")},children:l.jsx(Wt,{className:"w-4 h-4"})})]}):l.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[l.jsx(tr,{className:"w-4 h-4"}),"Add custom field"]})})]}),l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(y).filter(oe=>oe!=="inherits").length," fields"]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([oe])=>oe!=="inherits").map(([oe,tt])=>{const $e=B.find(Ye=>Ye.key===oe);return l.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:$e?.label||oe}),l.jsx("p",{className:"text-xs text-bambu-gray-dark",children:oe})]}),l.jsx("button",{onClick:()=>Q(oe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),$e?Ge($e):l.jsx("input",{type:"text",value:String(tt),onChange:Ye=>Q(oe,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"})]},oe)}),Object.keys(y).filter(oe=>oe!=="inherits").length===0&&l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(oU,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{className:"text-sm",children:"No overrides yet"}),l.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(y).filter(oe=>oe!=="inherits").length>0&&l.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:l.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:[l.jsx(no,{className:"w-4 h-4"}),"Save as template"]})})]})]}),s==="json"&&l.jsxs("div",{className:"space-y-2",children:[A&&l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(co,{className:"w-4 h-4"}),A]}),l.jsx("textarea",{value:E,onChange:oe=>Se(oe.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[l.jsx(Pe,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsxs(Pe,{onClick:()=>ye.mutate(),disabled:ye.isPending||!d.trim()||!a&&!g||!!A,className:"flex-1",children:[ye.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):a?l.jsx(no,{className:"w-4 h-4"}):l.jsx(tr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function LGe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,s]=M.useState(""),[o,c]=M.useState("all"),[u,d]=M.useState("all"),[f,g]=M.useState("all"),[p,x]=M.useState("all"),[v,y]=M.useState("all"),[b,E]=M.useState("all"),[w,A]=M.useState(null),[T,C]=M.useState(!1),[k,F]=M.useState(!1),[N,j]=M.useState(null),[I,O]=M.useState(null),[q,R]=M.useState(null),[W,K]=M.useState(!1),[G,te]=M.useState([null,null]),[Y,J]=M.useState(!1),[U,H]=M.useState(null),ee=Mn(),ie=M.useMemo(()=>[...t.filament.map(ne=>({...ne,type:"filament"})),...t.printer.map(ne=>({...ne,type:"printer"})),...t.process.map(ne=>({...ne,type:"process"}))].map(ne=>({...ne,meta:TL(ne.name)})),[t]),pe=M.useMemo(()=>{const B=new Set,ne=new Set,V=new Set;return ie.forEach(Q=>{Q.meta.nozzle&&B.add(Q.meta.nozzle),Q.meta.filamentType&&ne.add(Q.meta.filamentType),Q.meta.layerHeight&&V.add(Q.meta.layerHeight)}),{printers:i.map(Q=>({id:Q.id.toString(),name:Q.name})),nozzles:Array.from(B).sort((Q,se)=>parseFloat(Q)-parseFloat(se)),filaments:Array.from(ne).sort(),layerHeights:Array.from(V).sort((Q,se)=>parseFloat(Q)-parseFloat(se))}},[ie,i]),ue=M.useMemo(()=>f==="all"?null:i.find(ne=>ne.id.toString()===f)?.model||null,[f,i]),be=M.useMemo(()=>ie.filter(B=>o==="all"||B.type===o).filter(B=>{if(u==="all")return!0;const ne=fb(B.setting_id);return u==="custom"?ne:!ne}).filter(B=>{if(f==="all"||!ue)return!0;const ne=B.meta.printer?.toLowerCase()||"",V=ue.toLowerCase();return ne.includes(V)||V.includes(ne)}).filter(B=>p==="all"||B.meta.nozzle===p).filter(B=>v==="all"||B.meta.filamentType===v).filter(B=>b==="all"||B.meta.layerHeight===b).filter(B=>a===""||B.name.toLowerCase().includes(a.toLowerCase())).sort((B,ne)=>B.name.localeCompare(ne.name)),[ie,o,u,f,ue,p,v,b,a]),Re=B=>{if(W){const ne=G[0]?.setting_id===B.setting_id,V=G[1]?.setting_id===B.setting_id;if(ne)te([G[1],null]);else if(V)te([G[0],null]);else if(!G[0])te([B,null]);else if(G[1]){if(G[0].type!==B.type)return;te([G[0],B])}else{if(G[0].type!==B.type)return;te([G[0],B])}}else A(B)},Z=B=>{if(G[0]?.setting_id===B.setting_id)return 0;if(G[1]?.setting_id===B.setting_id)return 1},_e=async B=>{try{const ne=await Ce.getCloudSettingDetail(B.setting_id),V=B.type==="process"?"print":B.type;j({type:V,name:B.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{}}),A(null)}catch(ne){console.error("Failed to fetch preset details for duplication:",ne)}},Le=async B=>{try{ee.removeQueries({queryKey:["cloudSettingDetail",B.setting_id]});const ne=await Ce.getCloudSettingDetail(B.setting_id),V=B.type==="process"?"print":B.type;O({type:V,name:B.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{},setting_id:B.setting_id}),A(null)}catch(ne){console.error("Failed to fetch preset details for editing:",ne)}},ce=()=>{c("all"),d("all"),g("all"),x("all"),y("all"),E("all"),s("")},Ie=o!=="all"||u!=="all"||f!=="all"||p!=="all"||v!=="all"||b!=="all"||a!=="",z=t.filament.length+t.printer.length+t.process.length;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-4 mb-6",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(Rc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:a,onChange:B=>s(B.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"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Pe,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),te([null,null])):K(!0)},children:[l.jsx(ep,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),l.jsxs(Pe,{variant:"secondary",onClick:()=>F(!0),children:[l.jsx(A0,{className:"w-4 h-4"}),"Templates"]}),l.jsxs(Pe,{variant:"secondary",onClick:n,disabled:r,children:[l.jsx(Na,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Pe,{onClick:()=>C(!0),children:[l.jsx(tr,{className:"w-4 h-4"}),"New Preset"]})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx(XR,{className:"w-4 h-4 text-bambu-gray"}),l.jsx(Fm,{label:"Type",value:o,options:[{value:"all",label:"All",count:z},{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:B=>c(B)}),l.jsx(Fm,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:B=>d(B)}),pe.printers.length>0&&l.jsx(Fm,{label:"Printer",value:f,options:[{value:"all",label:"All"},...pe.printers.map(B=>({value:B.id,label:B.name}))],onChange:g}),pe.nozzles.length>0&&l.jsx(Fm,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...pe.nozzles.map(B=>({value:B,label:B}))],onChange:x}),pe.filaments.length>0&&(o==="all"||o==="filament")&&l.jsx(Fm,{label:"Filament",value:v,options:[{value:"all",label:"All"},...pe.filaments.map(B=>({value:B,label:B}))],onChange:y}),pe.layerHeights.length>0&&(o==="all"||o==="process")&&l.jsx(Fm,{label:"Layer",value:b,options:[{value:"all",label:"All"},...pe.layerHeights.map(B=>({value:B,label:B}))],onChange:E}),Ie&&l.jsx("button",{onClick:ce,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&l.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(ep,{className:"w-5 h-5 text-blue-400"}),l.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),l.jsx("span",{className:"text-bambu-gray",children:G[0]?`Select another ${G[0].type} preset`:"Click two presets of the same type to compare"})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.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"}),l.jsx(Dk,{className:"w-4 h-4 text-bambu-gray"}),l.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]&&l.jsxs(Pe,{size:"sm",onClick:async()=>{try{const[B,ne]=await Promise.all([Ce.getCloudSettingDetail(G[0].setting_id),Ce.getCloudSettingDetail(G[1].setting_id)]);H([B.setting||{},ne.setting||{}]),J(!0)}catch{}},children:[l.jsx(ep,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),l.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(sr,{className:"w-3 h-3"}),"Last synced: ",kGe(e.toISOString())]}),l.jsxs("span",{children:["Showing ",be.length," of ",z," presets"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),l.jsx("span",{children:"= My preset (editable)"})]})]}),be.length===0?l.jsxs("div",{className:"text-center py-16",children:[l.jsx(ud,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),l.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Ie&&l.jsx("button",{onClick:ce,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(GR,{className:"w-4 h-4 text-amber-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",be.filter(B=>B.type==="filament").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[be.filter(B=>B.type==="filament").map(B=>l.jsx(yk,{setting:B,onClick:()=>Re(B),onDuplicate:()=>_e(B),compareMode:W,isCompareSelected:Z(B)!==void 0,compareIndex:Z(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),be.filter(B=>B.type==="filament").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(WS,{className:"w-4 h-4 text-blue-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",be.filter(B=>B.type==="process").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[be.filter(B=>B.type==="process").map(B=>l.jsx(yk,{setting:B,onClick:()=>Re(B),onDuplicate:()=>_e(B),compareMode:W,isCompareSelected:Z(B)!==void 0,compareIndex:Z(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),be.filter(B=>B.type==="process").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(pa,{className:"w-4 h-4 text-purple-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",be.filter(B=>B.type==="printer").length,")"]})]}),l.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[be.filter(B=>B.type==="printer").map(B=>l.jsx(yk,{setting:B,onClick:()=>Re(B),onDuplicate:()=>_e(B),compareMode:W,isCompareSelected:Z(B)!==void 0,compareIndex:Z(B),compareDisabled:W&&!!G[0]&&G[0].type!==B.type},B.setting_id)),be.filter(B=>B.type==="printer").length===0&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&l.jsx(jGe,{setting:w,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>_e(w),onEdit:()=>Le(w)}),(T||N||I||q)&&l.jsx(OGe,{onClose:()=>{C(!1),j(null),O(null),R(null)},initialData:I||N||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),k&&l.jsx(DGe,{onClose:()=>F(!1),onApply:B=>{R({type:B.type,setting:B.settings}),F(!1)}}),Y&&U&&G[0]&&G[1]&&l.jsx(Mte,{onClose:()=>{J(!1),H(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function IGe(){const t=Mn(),{showToast:e}=Gr(),[n,r]=M.useState("cloud"),[i,a]=M.useState(),{data:s,isLoading:o}=yt({queryKey:["cloudStatus"],queryFn:Ce.getCloudStatus}),{data:c=[]}=yt({queryKey:["printers"],queryFn:Ce.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=yt({queryKey:["cloudSettings"],queryFn:()=>Ce.getCloudSettings(),enabled:!!s?.is_authenticated,retry:!1,staleTime:1e3*60*5});M.useEffect(()=>{g&&a(new Date(g))},[g]);const p=vt({mutationFn:Ce.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?l.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-6 lg:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[l.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:[l.jsx($S,{className:"w-4 h-4"}),"Cloud Profiles"]}),l.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:[l.jsx(YR,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&l.jsxs(l.Fragment,{children:[s?.is_authenticated&&l.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",l.jsx("span",{className:"text-white",children:s.email})]})]}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[l.jsx(cce,{className:"w-4 h-4"}),"Logout"]})]}),s?.is_authenticated?d?l.jsx("div",{className:"flex items-center justify-center py-16",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?l.jsx(LGe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):l.jsxs("div",{className:"text-center py-16",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),l.jsx(Pe,{onClick:()=>f(),children:"Retry"})]}):l.jsx(PGe,{onSuccess:x})]}),n==="kprofiles"&&l.jsx(NGe,{}),l.jsx(RGe,{})]})}const Kx={Droplet:GR,Flame:wle,Ruler:Qce,Sparkles:A0,Square:bp,Cable:boe,Wrench:hd,Calendar:$r,Timer:Wu,Cog:Xoe,Fan:dle,Zap:_p,Wind:Xue,Thermometer:qS,Layers:ud,Box:pp,Target:vG,RefreshCw:Na,Settings:nj,Filter:XR,CircleDot:Ooe};function x0(t){return t&&Kx[t]||hd}function Um(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 vk(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 FGe({item:t,onPerform:e,onToggle:n}){const r=x0(t.maintenance_type_icon),i=t.interval_type||"hours",s=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),o=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${Um(Math.abs(f),"days")}`:t.is_warning?`Due in ${Um(f,"days")}`:`${Um(f,"days")} left`}else return t.is_due?`Overdue by ${Um(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Um(t.hours_until_due,"hours")}`:`${Um(t.hours_until_due,"hours")} left`};return l.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.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:[l.jsx(r,{className:`w-5 h-5 ${o()}`}),t.enabled&&(t.is_due||t.is_warning)&&l.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`})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&l.jsx("span",{title:"Time-based interval",children:l.jsx($r,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),l.jsx("div",{className:"mt-2 mb-1.5",children:l.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${s}%`}})})}),l.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&l.jsx(Sr,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&l.jsx(sr,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&l.jsx(Gh,{className:"w-3 h-3"}),d()]})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(Rn,{checked:t.enabled,onChange:f=>n(t.id,f)}),l.jsxs(Pe,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[l.jsx(Qp,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function UGe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=M.useState(!0),[s,o]=M.useState(!1),[c,u]=M.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,x)=>p.is_due&&!x.is_due?-1:!p.is_due&&x.is_due?1:p.is_warning&&!x.is_warning?-1:!p.is_warning&&x.is_warning?1:p.maintenance_type_id-x.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),g=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),o(!1))};return l.jsxs(Mt,{className:"overflow-hidden",children:[l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),l.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&l.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:[l.jsx(Sr,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&l.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:[l.jsx(sr,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&l.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:[l.jsx(Gh,{className:"w-3 h-3"}),"All good"]})]})]}),l.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?l.jsx(HS,{className:"w-4 h-4"}):l.jsx(Hc,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),l.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:l.jsx(Wu,{className:"w-4 h-4 text-bambu-gray"})}),s?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",value:c,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&g(),p.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}),l.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),l.jsx(Pe,{size:"sm",onClick:g,children:"Save"}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):l.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[l.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",l.jsx(qh,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),l.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=x0(f.maintenance_type_icon);return l.jsx(p,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),l.jsxs("div",{children:[l.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),l.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&l.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:l.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(p=>l.jsx(FGe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function zGe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:s,onRemoveItem:o}){const[c,u]=M.useState(null),[d,f]=M.useState(""),[g,p]=M.useState("hours"),[x,v]=M.useState(!1),[y,b]=M.useState(""),[E,w]=M.useState("100"),[A,T]=M.useState("hours"),[C,k]=M.useState("Wrench"),[F,N]=M.useState(new Set),[j,I]=M.useState(null),O=M.useMemo(()=>t?t.map(Ie=>({id:Ie.printer_id,name:Ie.printer_name})):[],[t]),q=Ie=>t?t.filter(z=>z.maintenance_items.some(B=>B.maintenance_type_id===Ie)).map(z=>({printerId:z.printer_id,printerName:z.printer_name,itemId:z.maintenance_items.find(B=>B.maintenance_type_id===Ie)?.id})):[],R=Ie=>{if(!t)return[];const z=new Set(q(Ie).map(B=>B.printerId));return O.filter(B=>!z.has(B.id))},[W,K]=M.useState(null),[G,te]=M.useState(""),[Y,J]=M.useState(""),[U,H]=M.useState("hours"),[ee,ie]=M.useState("Wrench"),pe=Ie=>{K(Ie),te(Ie.name),J(Ie.default_interval_hours.toString()),H(Ie.interval_type||"hours"),ie(Ie.icon||"Wrench")},ue=()=>{W&&G.trim()&&parseFloat(Y)>0&&(i(W.id,{name:G.trim(),default_interval_hours:parseFloat(Y),interval_type:U,icon:ee}),K(null))},be=(Ie,z,B)=>{const ne=parseFloat(d);if(!isNaN(ne)&&ne>0){const V=Math.abs(ne-z)<.01?null:ne;n(Ie,{custom_interval_hours:V,custom_interval_type:g!==B?g:null})}u(null)},Re=Ie=>{Ie.preventDefault(),y.trim()&&parseFloat(E)>0&&F.size>0&&(r({name:y.trim(),default_interval_hours:parseFloat(E),interval_type:A,icon:C},Array.from(F)),b(""),w("100"),T("hours"),N(new Set),v(!1))},Z=Ie=>{N(z=>{const B=new Set(z);return B.has(Ie)?B.delete(Ie):B.add(Ie),B})},_e=t?.map(Ie=>({printerId:Ie.printer_id,printerName:Ie.printer_name,items:Ie.maintenance_items.sort((z,B)=>z.maintenance_type_id-B.maintenance_type_id)})).sort((Ie,z)=>Ie.printerName.localeCompare(z.printerName))||[],Le=e.filter(Ie=>Ie.is_system),ce=e.filter(Ie=>!Ie.is_system);return l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),l.jsxs(Pe,{onClick:()=>v(!x),children:[l.jsx(tr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&l.jsx(Mt,{className:"mb-6",children:l.jsx(Nt,{className:"py-4",children:l.jsxs("form",{onSubmit:Re,children:[l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[l.jsxs("div",{className:"lg:col-span-2",children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),l.jsx("input",{type:"text",value:y,onChange:Ie=>b(Ie.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),l.jsxs("select",{value:A,onChange:Ie=>{T(Ie.target.value),Ie.target.value==="days"?w("30"):w("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",A==="days"?"days":"hours",")"]}),l.jsx("input",{type:"number",value:E,onChange:Ie=>w(Ie.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"})]})]}),l.jsx("div",{className:"mt-4 flex items-end justify-between",children:l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),l.jsx("div",{className:"flex gap-1",children:Object.keys(Kx).map(Ie=>{const z=Kx[Ie];return l.jsx("button",{type:"button",onClick:()=>k(Ie),className:`p-2 rounded-lg transition-colors ${C===Ie?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:l.jsx(z,{className:"w-4 h-4"})},Ie)})})]})}),l.jsxs("div",{className:"mt-4",children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:O.map(Ie=>l.jsx("button",{type:"button",onClick:()=>Z(Ie.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(Ie.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:Ie.name},Ie.id))}),F.size===0&&l.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),l.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:()=>{v(!1),N(new Set)},children:"Cancel"}),l.jsx(Pe,{type:"submit",disabled:!y.trim()||F.size===0,children:"Add Type"})]})]})})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[Le.map(Ie=>{const z=x0(Ie.icon),B=Ie.interval_type||"hours";return l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:l.jsx(z,{className:"w-5 h-5 text-bambu-gray"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-white truncate",children:Ie.name}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[B==="days"?l.jsx($r,{className:"w-3 h-3"}):l.jsx(Wu,{className:"w-3 h-3"}),vk(Ie.default_interval_hours,B)]})]})]})},Ie.id)}),ce.map(Ie=>{const z=x0(Ie.icon),B=Ie.interval_type||"hours";if(W?.id===Ie.id)return l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:l.jsxs("div",{className:"space-y-3",children:[l.jsx("input",{type:"text",value:G,onChange:Me=>te(Me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("select",{value:U,onChange:Me=>H(Me.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:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.jsx("input",{type:"number",value:Y,onChange:Me=>J(Me.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"})]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Kx).map(Me=>{const Ae=Kx[Me];return l.jsx("button",{type:"button",onClick:()=>ie(Me),className:`p-1.5 rounded transition-colors ${ee===Me?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:l.jsx(Ae,{className:"w-3.5 h-3.5"})},Me)})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Pe,{size:"sm",onClick:ue,disabled:!G.trim(),children:"Save"}),l.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>K(null),children:"Cancel"})]})]})},Ie.id);const V=q(Ie.id),Q=R(Ie.id),se=j===Ie.id;return l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:l.jsx(z,{className:"w-5 h-5 text-bambu-green"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-white truncate",children:Ie.name}),l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[B==="days"?l.jsx($r,{className:"w-3 h-3"}):l.jsx(Wu,{className:"w-3 h-3"}),vk(Ie.default_interval_hours,B)]})]}),l.jsxs("button",{onClick:()=>I(se?null:Ie.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${V.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:`${V.length} printer(s) assigned - click to manage`,children:[l.jsx(pa,{className:"w-3 h-3"}),l.jsx("span",{className:"text-xs font-medium",children:V.length}),l.jsx(Hc,{className:`w-3 h-3 transition-transform ${se?"rotate-180":""}`})]}),l.jsx("button",{onClick:()=>pe(Ie),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:l.jsx(qh,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>{confirm(`Delete "${Ie.name}"?`)&&a(Ie.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(An,{className:"w-4 h-4"})})]}),se&&l.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),V.length===0?l.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):l.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:V.map(Me=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[Me.printerName,l.jsx("button",{onClick:()=>Me.itemId&&o(Me.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},Me.printerId))}),Q.length>0&&l.jsxs("div",{className:"flex flex-wrap gap-1",children:[l.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Q.map(Me=>l.jsxs("button",{onClick:()=>s(Me.id,Ie.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",Me.name]},Me.id))]})]})]},Ie.id)})]})]}),_e.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),l.jsx("div",{className:"space-y-4",children:_e.map(Ie=>l.jsx(Mt,{children:l.jsxs(Nt,{className:"py-4",children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:Ie.printerName}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:Ie.items.map(z=>{const B=x0(z.maintenance_type_icon),ne=e.find(Ae=>Ae.id===z.maintenance_type_id),V=ne?.default_interval_hours||z.interval_hours,Q=ne?.interval_type||"hours",se=z.interval_type||"hours",Me=c===z.id;return l.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[l.jsx(B,{className:"w-4 h-4 text-bambu-gray shrink-0"}),l.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:z.maintenance_type_name}),Me?l.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?l.jsx($r,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):l.jsx(Wu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),l.jsxs("select",{value:g,onChange:Ae=>p(Ae.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.jsx("input",{type:"number",value:d,onChange:Ae=>f(Ae.target.value),onKeyDown:Ae=>{Ae.key==="Enter"&&be(z.id,V,Q),Ae.key==="Escape"&&u(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),l.jsx(Pe,{size:"sm",onClick:()=>be(z.id,V,Q),children:"OK"})]}):l.jsxs("button",{onClick:()=>{u(z.id),f(z.interval_hours.toString()),p(se)},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:[se==="days"?l.jsx($r,{className:"w-3 h-3"}):l.jsx(Wu,{className:"w-3 h-3"}),vk(z.interval_hours,se),l.jsx(qh,{className:"w-3 h-3 text-bambu-gray"})]})]},z.id)})})]})},Ie.printerId))})]}),_e.length===0&&l.jsx(Mt,{children:l.jsxs(Nt,{className:"text-center py-12",children:[l.jsx(sr,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),l.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function BGe(){const t=Mn(),{showToast:e}=Gr(),[n,r]=M.useState("status"),{data:i,isLoading:a}=yt({queryKey:["maintenanceOverview"],queryFn:Ce.getMaintenanceOverview}),{data:s}=yt({queryKey:["maintenanceTypes"],queryFn:Ce.getMaintenanceTypes}),o=vt({mutationFn:({id:w,notes:A})=>Ce.performMaintenance(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:w=>{e(w.message,"error")}}),c=vt({mutationFn:({id:w,data:A})=>Ce.updateMaintenanceItem(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:w=>{e(w.message,"error")}}),u=vt({mutationFn:({id:w,data:A})=>Ce.updateMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:w=>{e(w.message,"error")}}),d=vt({mutationFn:Ce.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:w=>{e(w.message,"error")}}),f=vt({mutationFn:({printerId:w,hours:A})=>Ce.setPrinterHours(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:w=>{e(w.message,"error")}}),g=vt({mutationFn:({printerId:w,typeId:A})=>Ce.assignMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:w=>{e(w.message,"error")}}),p=vt({mutationFn:Ce.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:w=>{e(w.message,"error")}}),x=w=>{o.mutate({id:w})},v=(w,A)=>{c.mutate({id:w,data:{enabled:A}})},y=(w,A)=>{f.mutate({printerId:w,hours:A})};if(a)return l.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})});const b=i?.reduce((w,A)=>w+A.due_count,0)||0,E=i?.reduce((w,A)=>w+A.warning_count,0)||0;return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?l.jsxs(l.Fragment,{children:[b>0&&l.jsxs("span",{className:"text-red-400",children:[b," task",b!==1?"s":""," overdue"]}),b>0&&E>0&&" · ",E>0&&l.jsxs("span",{className:"text-amber-400",children:[E," due soon"]}),b===0&&E===0&&l.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),l.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[l.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"}),l.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"?l.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((w,A)=>{const T=w.due_count*10+w.warning_count,C=A.due_count*10+A.warning_count;return T!==C?C-T:w.printer_name.localeCompare(A.printer_name)}).map(w=>l.jsx(UGe,{overview:w,onPerform:x,onToggle:v,onSetHours:y},w.printer_id)):l.jsx(Mt,{children:l.jsxs(Nt,{className:"text-center py-16",children:[l.jsx(hd,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):l.jsx(zGe,{overview:i,types:s||[],onUpdateInterval:(w,A)=>c.mutate({id:w,data:A}),onAddType:async(w,A)=>{const T=await Ce.createMaintenanceType(w);for(const C of A)await Ce.assignMaintenanceType(C,T.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(w,A)=>u.mutate({id:w,data:A}),onDeleteType:w=>d.mutate(w),onAssignType:(w,A)=>g.mutate({printerId:w,typeId:A}),onRemoveItem:w=>p.mutate(w)})]})}const A9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Ete({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=M.useState(t?.name||""),[s,o]=M.useState(t?.description||""),[c,u]=M.useState(t?.color||A9[0]),[d,f]=M.useState(t?.target_count?.toString()||""),[g,p]=M.useState(t?.status||"active"),[x,v]=M.useState(t?.tags||""),[y,b]=M.useState(t?.due_date?.split("T")[0]||""),[E,w]=M.useState(t?.priority||"normal"),A=T=>{T.preventDefault(),n({name:i.trim(),description:s.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,tags:x.trim()||void 0,due_date:y||void 0,priority:E,...t&&{status:g}})};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[l.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),l.jsxs("form",{onSubmit:A,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),l.jsx("input",{type:"text",value:i,onChange:T=>a(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),l.jsx("textarea",{value:s,onChange:T=>o(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:"Optional description...",rows:2})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:A9.map(T=>l.jsx("button",{type:"button",onClick:()=>u(T),className:`w-8 h-8 rounded-full transition-transform ${c===T?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:T}},T))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),l.jsx("input",{type:"number",value:d,onChange:T=>f(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 50 parts to print",min:"1"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),l.jsx("input",{type:"text",value:x,onChange:T=>v(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., voron, functional, gift"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),l.jsx("input",{type:"date",value:y,onChange:T=>b(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),l.jsxs("select",{value:E,onChange:T=>w(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[l.jsx("option",{value:"low",children:"Low"}),l.jsx("option",{value:"normal",children:"Normal"}),l.jsx("option",{value:"high",children:"High"}),l.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),l.jsxs("select",{value:g,onChange:T=>p(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"archived",children:"Archived"})]})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[l.jsx(Pe,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsx(Pe,{type:"submit",disabled:!i.trim()||r,children:r?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function HGe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,a=t.status==="completed",s=t.status==="archived",[o,c]=M.useState(!1),d=a?{icon:VR,color:"text-bambu-green",bg:"bg-bambu-green/10"}:s?{icon:wc,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:sr,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:cl,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return l.jsxs("div",{className:"group relative bg-bambu-card rounded-xl border border-bambu-dark-tertiary hover:border-bambu-gray/40 transition-all cursor-pointer overflow-hidden",onClick:e,children:[l.jsx("div",{className:"absolute top-0 left-0 w-1 h-full",style:{backgroundColor:t.color||"#6b7280"}}),l.jsxs("div",{className:"p-5 pl-6",children:[l.jsxs("div",{className:"flex items-start justify-between mb-4",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx("div",{className:`p-2 rounded-lg ${d.bg} flex-shrink-0`,children:l.jsx(d.icon,{className:`w-5 h-5 ${d.color}`})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),a&&l.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),s&&l.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description})]})]}),l.jsxs("div",{className:"relative",onClick:f=>f.stopPropagation(),children:[l.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>c(!o),children:l.jsx(WR,{className:"w-4 h-4"})}),o&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>c(!1)}),l.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[l.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),c(!1)},children:[l.jsx(qh,{className:"w-4 h-4"}),"Edit"]}),l.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),c(!1)},children:[l.jsx(An,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),t.target_count?l.jsxs("div",{className:"mb-4",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[l.jsx("span",{className:"text-bambu-gray",children:"Progress"}),l.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full",style:{width:`${Math.min(i,100)}%`,backgroundColor:i>=100?"#22c55e":t.color||"#6b7280"}})}),l.jsxs("div",{className:"text-right text-xs text-bambu-gray/60 mt-1",children:[i.toFixed(0),"% complete"]})]}):null,t.archives&&t.archives.length>0&&l.jsx("div",{className:"mb-4",children:l.jsxs("div",{className:"flex gap-1.5",children:[t.archives.slice(0,4).map(f=>l.jsxs("div",{className:"relative w-12 h-12 rounded-lg bg-bambu-dark flex-shrink-0 overflow-hidden border border-bambu-dark-tertiary",title:f.print_name||"Unknown",children:[f.thumbnail_path?l.jsx("img",{src:`/api/v1/archives/${f.id}/thumbnail`,alt:f.print_name||"",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:l.jsx(Pc,{className:"w-5 h-5"})}),f.status==="failed"&&l.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:l.jsx(Sr,{className:"w-4 h-4 text-white"})})]},f.id)),t.archive_count>4&&l.jsxs("div",{className:"w-12 h-12 rounded-lg bg-bambu-dark flex-shrink-0 flex items-center justify-center text-xs text-bambu-gray border border-bambu-dark-tertiary",children:["+",t.archive_count-4]})]})}),l.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[l.jsxs("div",{className:"flex items-center gap-1.5",title:"Completed prints",children:[l.jsx(wc,{className:"w-3.5 h-3.5"}),l.jsx("span",{children:t.archive_count})]}),t.queue_count>0&&l.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",title:"In queue",children:[l.jsx(Ik,{className:"w-3.5 h-3.5"}),l.jsx("span",{children:t.queue_count})]})]}),l.jsx($c,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function $Ge(){const t=gb(),e=Mn(),{showToast:n}=Gr(),[r,i]=M.useState(!1),[a,s]=M.useState(),[o,c]=M.useState("active"),[u,d]=M.useState(null),{data:f,isLoading:g}=yt({queryKey:["projects",o==="all"?void 0:o],queryFn:()=>Ce.getProjects(o==="all"?void 0:o)}),p=vt({mutationFn:C=>Ce.createProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:C=>{n(C.message,"error")}}),x=vt({mutationFn:({id:C,data:k})=>Ce.updateProject(C,k),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),s(void 0),n("Project updated","success")},onError:C=>{n(C.message,"error")}}),v=vt({mutationFn:C=>Ce.deleteProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),d(null),n("Project deleted","success")},onError:C=>{n(C.message,"error")}}),y=C=>{a?x.mutate({id:a.id,data:C}):p.mutate(C)},b=C=>{s(C),i(!0)},E=C=>{t(`/projects/${C.id}`)},w=C=>{d(C)},A=()=>{u!==null&&v.mutate(u)},T=f?.reduce((C,k)=>(C[k.status]=(C[k.status]||0)+1,C.all=(C.all||0)+1,C),{})||{};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[l.jsxs("div",{children:[l.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[l.jsx("div",{className:"p-2 bg-bambu-green/10 rounded-lg",children:l.jsx(cl,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-14",children:"Organize and track your 3D printing projects"})]}),l.jsxs(Pe,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[l.jsx(tr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),l.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:sr},{key:"completed",label:"Completed",icon:VR},{key:"archived",label:"Archived",icon:wc},{key:"all",label:"All",icon:cl}].map(({key:C,label:k,icon:F})=>l.jsxs("button",{onClick:()=>c(C),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${o===C?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[l.jsx(F,{className:"w-4 h-4"}),l.jsx("span",{children:k}),T[C]>0&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${o===C?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:T[C]})]},C))}),g?l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsx(_t,{className:"w-8 h-8 animate-spin text-bambu-green"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[l.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:l.jsx(cl,{className:"w-12 h-12 text-bambu-gray/50"})}),l.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:o==="all"?"No projects yet":`No ${o} projects`}),l.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:o==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${o} projects. Projects will appear here when their status changes.`}),o==="all"&&l.jsxs(Pe,{onClick:()=>i(!0),children:[l.jsx(tr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-5",children:f?.map(C=>l.jsx(HGe,{project:C,onClick:()=>E(C),onEdit:()=>b(C),onDelete:()=>w(C.id)},C.id))}),u!==null&&l.jsx(fi,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:A,onCancel:()=>d(null)}),r&&l.jsx(Ete,{project:a,onClose:()=>{i(!1),s(void 0)},onSave:y,isLoading:p.isPending||x.isPending})]})}function VGe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function GGe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function WGe({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return l.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function J_({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-gray"}){return l.jsx(Mt,{children:l.jsx(Nt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${i}`,children:l.jsx(t,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:e}),l.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&l.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function qGe({archives:t}){return t.length===0?l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(Pc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),l.jsx("p",{children:"No prints in this project yet"})]}):l.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>l.jsxs(fc,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?l.jsx("img",{src:`/api/v1/archives/${e.id}/thumbnail`,alt:e.print_name||"Print",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:l.jsx(Pc,{className:"w-8 h-8"})}),e.status==="failed"&&l.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:l.jsx(Ea,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&l.jsx("div",{className:"absolute top-1 right-1",children:l.jsx(_r,{className:"w-4 h-4 text-bambu-green"})}),l.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function KGe({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return l.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&l.jsx(Sr,{className:"w-3 h-3"}),r]})}function XGe(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}function _k(t){if(!t)return null;const e=new Date(t),n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function YGe(){const{id:t}=OR(),e=gb(),n=Mn(),{showToast:r}=Gr(),[i,a]=M.useState(!1),[s,o]=M.useState(!1),[c,u]=M.useState(""),[d,f]=M.useState(!1),g=M.useRef(null),p=parseInt(t||"0",10),{data:x,isLoading:v,error:y}=yt({queryKey:["project",p],queryFn:()=>Ce.getProject(p),enabled:p>0}),{data:b,isLoading:E}=yt({queryKey:["project-archives",p],queryFn:()=>Ce.getProjectArchives(p),enabled:p>0}),{data:w,isLoading:A}=yt({queryKey:["project-bom",p],queryFn:()=>Ce.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:C}=yt({queryKey:["project-timeline",p],queryFn:()=>Ce.getProjectTimeline(p,20),enabled:p>0}),k=vt({mutationFn:Z=>Ce.updateProject(p,Z),onSuccess:()=>{n.invalidateQueries({queryKey:["project",p]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),o(!1),r("Project updated","success")},onError:Z=>{r(Z.message,"error")}}),F=()=>{u(x?.notes||""),o(!0)},N=()=>{k.mutate({notes:c})},j=()=>{o(!1),u("")},I=async Z=>{const _e=Z.target.files?.[0];if(_e){f(!0);try{await Ce.uploadProjectAttachment(p,_e),n.invalidateQueries({queryKey:["project",p]}),r("Attachment uploaded","success")}catch(Le){r(Le.message,"error")}finally{f(!1),g.current&&(g.current.value="")}}},O=async Z=>{if(confirm("Delete this attachment?"))try{await Ce.deleteProjectAttachment(p,Z),n.invalidateQueries({queryKey:["project",p]}),r("Attachment deleted","success")}catch(_e){r(_e.message,"error")}},q=Z=>Z<1024?`${Z} B`:Z<1024*1024?`${(Z/1024).toFixed(1)} KB`:`${(Z/(1024*1024)).toFixed(1)} MB`,[R,W]=M.useState(""),[K,G]=M.useState(1),te=vt({mutationFn:Z=>Ce.createBOMItem(p,Z),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),W(""),G(1),r("BOM item added","success")},onError:Z=>r(Z.message,"error")}),Y=vt({mutationFn:({itemId:Z,data:_e})=>Ce.updateBOMItem(p,Z,_e),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]})},onError:Z=>r(Z.message,"error")}),J=vt({mutationFn:Z=>Ce.deleteBOMItem(p,Z),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),r("BOM item deleted","success")},onError:Z=>r(Z.message,"error")}),U=Z=>{Z.preventDefault(),R.trim()&&te.mutate({name:R.trim(),quantity_needed:K})},H=Z=>{Y.mutate({itemId:Z.id,data:{quantity_printed:Z.quantity_printed+1}})},ee=Z=>{confirm("Delete this BOM item?")&&J.mutate(Z)},ie=vt({mutationFn:()=>Ce.createTemplateFromProject(p),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:Z=>r(Z.message,"error")}),pe=Z=>new Date(Z).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(v)return l.jsx("div",{className:"flex items-center justify-center py-24",children:l.jsx(_t,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!x)return l.jsxs("div",{className:"text-center py-24",children:[l.jsx("p",{className:"text-bambu-gray",children:y?`Error: ${y.message}`:"Project not found"}),l.jsx(Pe,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const ue=x.stats,be=ue?.progress_percent??0,Re=ue&&ue.total_archives>0?(ue.completed_prints/ue.total_archives*100).toFixed(0):null;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[l.jsx(fc,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),l.jsx($c,{className:"w-4 h-4"}),l.jsx("span",{className:"text-white",children:x.name})]}),l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:l.jsx(ioe,{className:"w-5 h-5 text-bambu-gray"})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#6b7280"}}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:x.name}),x.description&&l.jsx("p",{className:"text-bambu-gray mt-1",children:x.description})]})]}),l.jsx(WGe,{status:x.status})]}),l.jsxs(Pe,{onClick:()=>a(!0),children:[l.jsx(qh,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),x.target_count&&l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Progress"}),l.jsxs("span",{className:"text-sm font-medium text-white",children:[ue?.completed_prints||0," / ",x.target_count," prints"]})]}),l.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(be,100)}%`,backgroundColor:be>=100?"#22c55e":x.color||"#6b7280"}})}),l.jsxs("div",{className:"flex justify-between mt-1",children:[l.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[be.toFixed(0),"% complete"]}),x.target_count-(ue?.completed_prints||0)>0&&l.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[x.target_count-(ue?.completed_prints||0)," remaining"]})]})]})}),ue&&l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsx(J_,{icon:Pc,label:"Total Prints",value:ue.total_archives,subValue:Re?`${Re}% success rate`:void 0,color:"text-bambu-green"}),l.jsx(J_,{icon:_r,label:"Completed",value:ue.completed_prints,subValue:ue.failed_prints>0?`${ue.failed_prints} failed`:void 0,color:"text-blue-400"}),l.jsx(J_,{icon:sr,label:"Print Time",value:VGe(ue.total_print_time_hours),color:"text-yellow-400"}),l.jsx(J_,{icon:pa,label:"Filament Used",value:GGe(ue.total_filament_grams),color:"text-purple-400"})]}),ue&&(ue.estimated_cost>0||x.budget)&&l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[l.jsx(k1,{className:"w-5 h-5"}),"Cost Tracking"]}),l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),l.jsxs("p",{className:"text-lg font-semibold text-white",children:["$",ue.estimated_cost.toFixed(2)]})]}),ue.total_energy_kwh>0&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),l.jsxs("p",{className:"text-lg font-semibold text-white",children:[ue.total_energy_kwh.toFixed(2)," kWh",ue.total_energy_cost>0&&l.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["($",ue.total_energy_cost.toFixed(2),")"]})]})]}),x.budget&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),l.jsxs("p",{className:"text-lg font-semibold text-white",children:["$",x.budget.toFixed(2)]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),l.jsxs("p",{className:`text-lg font-semibold ${x.budget-ue.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:["$",(x.budget-ue.estimated_cost).toFixed(2)]})]})]})]})]})}),x.children&&x.children.length>0&&l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[l.jsx(Tle,{className:"w-5 h-5"}),"Sub-projects (",x.children.length,")"]}),l.jsx("div",{className:"space-y-2",children:x.children.map(Z=>l.jsxs(fc,{to:`/projects/${Z.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Z.color||"#6b7280"}}),l.jsx("span",{className:"text-white",children:Z.name}),l.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Z.status==="completed"?"bg-bambu-green/20 text-bambu-green":Z.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Z.status})]}),Z.progress_percent!==null&&l.jsxs("span",{className:"text-sm text-bambu-gray",children:[Z.progress_percent.toFixed(0),"%"]})]},Z.id))})]})}),x.parent_id&&x.parent_name&&l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(ud,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),l.jsx(fc,{to:`/projects/${x.parent_id}`,className:"text-bambu-green hover:underline",children:x.parent_name})]}),(x.tags||x.due_date||x.priority!=="normal")&&l.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[x.priority&&x.priority!=="normal"&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),l.jsx(KGe,{priority:x.priority})]}),x.due_date&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx($r,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("span",{className:"text-sm text-white",children:XGe(x.due_date)}),_k(x.due_date)&&l.jsxs("span",{className:`text-xs ${_k(x.due_date).color}`,children:["(",_k(x.due_date).label,")"]})]}),x.tags&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(vp,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:x.tags.split(",").map((Z,_e)=>l.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Z.trim()},_e))})]})]}),l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(ws,{className:"w-5 h-5"}),"Notes"]}),s?l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:j,disabled:k.isPending,children:[l.jsx(Wt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),l.jsxs(Pe,{size:"sm",onClick:N,disabled:k.isPending,children:[k.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin mr-1"}):l.jsx(no,{className:"w-4 h-4 mr-1"}),"Save"]})]}):l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:F,children:[l.jsx(qh,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),s?l.jsx(MR,{content:c,onChange:u,placeholder:"Add notes about this project..."}):x.notes?l.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:x.notes}}):l.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(jce,{className:"w-5 h-5"}),"Attachments (",x.attachments?.length||0,")"]}),l.jsxs("div",{children:[l.jsx("input",{ref:g,type:"file",onChange:I,className:"hidden"}),l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>g.current?.click(),disabled:d,children:[d?l.jsx(_t,{className:"w-4 h-4 animate-spin mr-1"}):l.jsx(Ya,{className:"w-4 h-4 mr-1"}),"Upload"]})]})]}),x.attachments&&x.attachments.length>0?l.jsx("div",{className:"space-y-2",children:x.attachments.map(Z=>l.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[l.jsx(KR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("p",{className:"text-sm text-white truncate",children:Z.original_name}),l.jsx("p",{className:"text-xs text-bambu-gray",children:q(Z.size)})]})]}),l.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l.jsx("a",{href:Ce.getProjectAttachmentUrl(p,Z.filename),download:Z.original_name,className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Download",children:l.jsx(ts,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>O(Z.filename),className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-red-400",title:"Delete",children:l.jsx(An,{className:"w-4 h-4"})})]})]},Z.filename))}):l.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No attachments. Upload STL files, reference images, or other documents."})]})}),l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsx("div",{className:"flex items-center justify-between mb-3",children:l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(zoe,{className:"w-5 h-5"}),"Bill of Materials",ue&&ue.bom_total_items>0&&l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ue.bom_completed_items,"/",ue.bom_total_items," complete)"]})]})}),l.jsxs("form",{onSubmit:U,className:"flex gap-2 mb-4",children:[l.jsx("input",{type:"text",value:R,onChange:Z=>W(Z.target.value),className:"flex-1 bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name..."}),l.jsx("input",{type:"number",value:K,onChange:Z=>G(parseInt(Z.target.value)||1),className:"w-20 bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1"}),l.jsx(Pe,{type:"submit",size:"sm",disabled:!R.trim()||te.isPending,children:te.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin"}):l.jsx(tr,{className:"w-4 h-4"})})]}),A?l.jsx("div",{className:"flex items-center justify-center py-4",children:l.jsx(_t,{className:"w-6 h-6 animate-spin text-bambu-green"})}):w&&w.length>0?l.jsx("div",{className:"space-y-2",children:w.map(Z=>l.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg ${Z.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[l.jsx("button",{onClick:()=>H(Z),disabled:Y.isPending,className:`w-6 h-6 rounded border-2 flex items-center justify-center transition-colors ${Z.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:Z.is_complete&&l.jsx(_r,{className:"w-4 h-4"})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("p",{className:`text-sm ${Z.is_complete?"text-bambu-gray line-through":"text-white"}`,children:Z.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[Z.quantity_printed," / ",Z.quantity_needed," printed"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:()=>H(Z),disabled:Y.isPending,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary rounded hover:bg-bambu-green/20 text-bambu-gray hover:text-white transition-colors",children:"+1"}),l.jsx("button",{onClick:()=>ee(Z.id),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(An,{className:"w-4 h-4"})})]})]},Z.id))}):l.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add parts to track what needs to be printed."})]})}),l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsx("div",{className:"flex items-center justify-between mb-3",children:l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(R1,{className:"w-5 h-5"}),"Activity Timeline"]})}),C?l.jsx("div",{className:"flex items-center justify-center py-4",children:l.jsx(_t,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?l.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((Z,_e)=>l.jsxs("div",{className:"flex gap-3",children:[l.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Z.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":Z.event_type==="print_failed"?"bg-red-500/20 text-red-400":Z.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Z.event_type==="print_completed"&&l.jsx(_r,{className:"w-4 h-4"}),Z.event_type==="print_failed"&&l.jsx(Ea,{className:"w-4 h-4"}),Z.event_type==="print_started"&&l.jsx(pa,{className:"w-4 h-4"}),Z.event_type==="queued"&&l.jsx(Ik,{className:"w-4 h-4"}),Z.event_type==="project_created"&&l.jsx(tr,{className:"w-4 h-4"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-white",children:Z.title}),Z.description&&l.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Z.description}),l.jsx("p",{className:"text-xs text-bambu-gray/70",children:pe(Z.timestamp)})]})]},_e))}):l.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!x.is_template&&l.jsx("div",{className:"flex justify-end",children:l.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>ie.mutate(),disabled:ie.isPending,children:[ie.isPending?l.jsx(_t,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(cd,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),ue&&(ue.queued_prints>0||ue.in_progress_prints>0)&&l.jsx(Mt,{children:l.jsxs(Nt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Ik,{className:"w-5 h-5"}),"Queue"]}),l.jsx(fc,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[ue.in_progress_prints>0&&l.jsxs("span",{className:"text-yellow-400",children:[ue.in_progress_prints," printing"]}),ue.queued_prints>0&&l.jsxs("span",{className:"text-bambu-gray",children:[ue.queued_prints," queued"]})]})]})}),l.jsxs("div",{children:[l.jsx("div",{className:"flex items-center justify-between mb-4",children:l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Pc,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),E?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx(_t,{className:"w-6 h-6 animate-spin text-bambu-green"})}):l.jsx(qGe,{archives:b||[]})]}),i&&l.jsx(Ete,{project:{...x,archive_count:ue?.total_archives||0,queue_count:ue?.queued_prints||0,progress_percent:ue?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:Z=>k.mutate(Z),isLoading:k.isPending})]})}function ZGe(){const{printerId:t}=OR(),e=parseInt(t||"0",10),[n,r]=M.useState("stream"),[i,a]=M.useState(!1),[s,o]=M.useState(!0),[c,u]=M.useState(Date.now()),[d,f]=M.useState(!1),[g,p]=M.useState(!1),x=M.useRef(null),v=M.useRef(null),{data:y}=yt({queryKey:["printer",e],queryFn:()=>Ce.getPrinter(e),enabled:e>0});M.useEffect(()=>(y&&(document.title=`${y.name} - Camera`),()=>{document.title="Bambuddy"}),[y]),M.useEffect(()=>{const N=`/api/v1/printers/${e}/camera/stop`,j=()=>{e>0&&navigator.sendBeacon(N)},I=()=>{document.visibilityState==="hidden"&&e>0&&navigator.sendBeacon(N)};return window.addEventListener("beforeunload",j),document.addEventListener("visibilitychange",I),()=>{window.removeEventListener("beforeunload",j),document.removeEventListener("visibilitychange",I),x.current&&(x.current.src=""),e>0&&navigator.sendBeacon(N)}},[e]),M.useEffect(()=>{if(s&&!d){const j=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(j)}},[n,s,c,d]),M.useEffect(()=>{const N=()=>{p(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]);const b=()=>{a(!0),o(!1)},E=()=>{o(!1),a(!1)},w=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},A=N=>{n===N||d||(f(!0),o(!0),a(!1),x.current&&(x.current.src=""),n==="stream"&&w(),setTimeout(()=>{r(N),u(Date.now()),f(!1)},100))},T=()=>{d||(f(!0),o(!0),a(!1),x.current&&(x.current.src=""),n==="stream"&&w(),setTimeout(()=>{u(Date.now()),f(!1)},100))},C=()=>{v.current&&(document.fullscreenElement?document.exitFullscreen():v.current.requestFullscreen())},k=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,F=s||d;return e?l.jsxs("div",{ref:v,className:"min-h-screen bg-black flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[l.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(w0,{className:"w-4 h-4"}),y?.name||`Printer ${e}`]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[l.jsx("button",{onClick:()=>A("stream"),disabled:F,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"}),l.jsx("button",{onClick:()=>A("snapshot"),disabled:F,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"})]}),l.jsx("button",{onClick:T,disabled:F,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:l.jsx(Na,{className:`w-4 h-4 text-bambu-gray ${F?"animate-spin":""}`})}),l.jsx("button",{onClick:C,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?l.jsx(Ece,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(xce,{className:"w-4 h-4 text-bambu-gray"})})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:l.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(s||d)&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:l.jsxs("div",{className:"text-center",children:[l.jsx(Na,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:l.jsxs("div",{className:"text-center p-4",children:[l.jsx(Sr,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),l.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),l.jsx("button",{onClick:T,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),l.jsx("img",{ref:x,src:k,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:k?b:void 0,onLoad:k?E:void 0},c)]})})]}):l.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:l.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function QGe(){const{id:t}=OR(),{theme:e}=yb(),{data:n,isLoading:r,error:i}=yt({queryKey:["external-link",t],queryFn:()=>Ce.getExternalLink(Number(t)),enabled:!!t});return r?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[l.jsx(Sr,{className:"w-12 h-12"}),l.jsx("p",{children:"Link not found"})]}):l.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function zr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return l.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[l.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:l.jsx(t,{className:"w-5 h-5"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:e}),l.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&l.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function T9({percent:t,color:e="bg-bambu-green"}){return l.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function oh({title:t,icon:e,children:n}){return l.jsxs(Mt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(e,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function JGe(){const{t}=Kp(),{data:e,isLoading:n,refetch:r,isFetching:i}=yt({queryKey:["systemInfo"],queryFn:Ce.getSystemInfo,refetchInterval:3e4});if(n)return l.jsx("div",{className:"flex items-center justify-center h-64",children:l.jsx(_t,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!e)return l.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const a=e.storage.disk_percent_used>90?"bg-red-500":e.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",s=e.memory.percent_used>90?"bg-red-500":e.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return l.jsxs("div",{className:"p-6 space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),l.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),l.jsxs("button",{onClick:()=>r(),disabled:i,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[l.jsx(Na,{className:`w-4 h-4 ${i?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),l.jsx(oh,{title:t("system.application","Application"),icon:lh,children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[l.jsx(zr,{icon:lh,label:t("system.version","Version"),value:`v${e.app.version}`}),l.jsx(zr,{icon:sr,label:t("system.uptime","System Uptime"),value:e.system.uptime_formatted}),l.jsx(zr,{icon:lh,label:t("system.hostname","Hostname"),value:e.system.hostname})]})}),l.jsxs(oh,{title:t("system.database","Database"),icon:gp,children:[l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[l.jsx(zr,{icon:wc,label:t("system.totalArchives","Total Archives"),value:e.database.archives}),l.jsx(zr,{icon:VR,label:t("system.completed","Completed"),value:e.database.archives_completed,color:"text-green-500"}),l.jsx(zr,{icon:Ea,label:t("system.failed","Failed"),value:e.database.archives_failed,color:"text-red-500"}),l.jsx(zr,{icon:_t,label:t("system.printing","Printing"),value:e.database.archives_printing,color:"text-yellow-500"})]}),l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsx(zr,{icon:pa,label:t("system.printers","Printers"),value:e.database.printers}),l.jsx(zr,{icon:bG,label:t("system.filaments","Filaments"),value:e.database.filaments}),l.jsx(zr,{icon:cl,label:t("system.projects","Projects"),value:e.database.projects}),l.jsx(zr,{icon:tp,label:t("system.smartPlugs","Smart Plugs"),value:e.database.smart_plugs})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[l.jsx(zr,{icon:sr,label:t("system.totalPrintTime","Total Print Time"),value:e.database.total_print_time_formatted}),l.jsx(zr,{icon:wc,label:t("system.totalFilament","Total Filament Used"),value:`${e.database.total_filament_kg} kg`,subValue:`${e.database.total_filament_grams.toLocaleString()} g`})]})]}),l.jsxs(oh,{title:t("system.connectedPrinters","Connected Printers"),icon:pa,children:[l.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[l.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:e.printers.connected}),l.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:e.printers.total})})]}),e.printers.connected_list.length>0?l.jsx("div",{className:"space-y-2",children:e.printers.connected_list.map(o=>l.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),l.jsx("span",{className:"font-medium text-white",children:o.name})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[l.jsx("span",{children:o.model}),l.jsx("span",{className:`px-2 py-0.5 rounded ${o.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":o.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:o.state})]})]},o.id))}):l.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),l.jsx(oh,{title:t("system.storage","Storage"),icon:ZR,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),l.jsxs("span",{className:"text-white",children:[e.storage.disk_used_formatted," / ",e.storage.disk_total_formatted]})]}),l.jsx(T9,{percent:e.storage.disk_percent_used,color:a}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.storage.disk_free_formatted," ",t("system.free","free")," (",(100-e.storage.disk_percent_used).toFixed(1),"%)"]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsx(zr,{icon:wc,label:t("system.archiveStorage","Archive Storage"),value:e.storage.archive_size_formatted}),l.jsx(zr,{icon:gp,label:t("system.databaseSize","Database Size"),value:e.storage.database_size_formatted})]})]})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsx(oh,{title:t("system.memory","Memory"),icon:yce,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),l.jsxs("span",{className:"text-white",children:[e.memory.used_formatted," / ",e.memory.total_formatted]})]}),l.jsx(T9,{percent:e.memory.percent_used,color:s}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.memory.available_formatted," ",t("system.available","available")]})]})})}),l.jsx(oh,{title:t("system.cpu","CPU"),icon:bv,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx(zr,{icon:bv,label:t("system.cores","Cores"),value:e.cpu.count,subValue:`${e.cpu.count_logical} logical`}),l.jsx(zr,{icon:bv,label:t("system.usage","Usage"),value:`${e.cpu.percent}%`})]})})})]}),l.jsx(oh,{title:t("system.systemDetails","System Details"),icon:lh,children:l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsx(zr,{icon:lh,label:t("system.os","Operating System"),value:e.system.platform,subValue:e.system.platform_release}),l.jsx(zr,{icon:bv,label:t("system.architecture","Architecture"),value:e.system.architecture}),l.jsx(zr,{icon:lh,label:t("system.python","Python"),value:e.system.python_version}),l.jsx(zr,{icon:sr,label:t("system.bootTime","Boot Time"),value:new Date(e.system.boot_time).toLocaleString()})]})})]})}function eWe(){const t=M.useRef(null),e=M.useRef(null),n=Mn(),[r,i]=M.useState(!1),a=M.useRef(new Set),s=M.useRef(null),o=M.useRef(new Map),c=M.useRef(null),u=M.useRef([]),d=M.useRef(!1),f=M.useRef(()=>{}),g=M.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const E=()=>{const w=u.current.shift();w?requestAnimationFrame(()=>{f.current(w),u.current.length>0?setTimeout(E,16):d.current=!1}):d.current=!1};E()},[]),p=M.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(w);let T=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),T=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=C=>{try{const k=JSON.parse(C.data);k.type==="printer_status"&&k.printer_id!==void 0&&k.data?f.current(k):(u.current.push(k),g())}catch{}},A.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),T&&(clearInterval(T),T=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=C=>{console.error("[WebSocket] Error",C),A.close()},t.current=A},[]),x=M.useCallback((E,w)=>{const A=o.current.get(E)||{};o.current.set(E,{...A,...w}),c.current||(c.current=window.setTimeout(()=>{const T=new Map(o.current);o.current.clear(),c.current=null,requestAnimationFrame(()=>{T.forEach((C,k)=>{n.setQueryData(["printerStatus",k],F=>{const N={...F,...C};return N.wifi_signal==null&&F?.wifi_signal!=null&&(N.wifi_signal=F.wifi_signal),N})})})},100))},[n]),v=M.useCallback(E=>{a.current.add(E),s.current&&clearTimeout(s.current),s.current=window.setTimeout(()=>{const w=Array.from(a.current);a.current.clear(),s.current=null;let A=0;w.forEach(T=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[T]})})},A),A+=500})},3e3)},[n]),y=M.useCallback(E=>{switch(E.type){case"printer_status":E.printer_id!==void 0&&E.data&&x(E.printer_id,E.data);break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break}},[n,v,x]);M.useEffect(()=>{f.current=y},[y]),M.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),s.current&&clearTimeout(s.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const b=M.useCallback(E=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(E))},[]);return{isConnected:r,sendMessage:b}}const tWe=new Ise({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function nWe({children:t}){return eWe(),l.jsx(l.Fragment,{children:t})}function rWe(){return l.jsx(rde,{children:l.jsx(fde,{children:l.jsx(Fse,{client:tWe,children:l.jsx(nWe,{children:l.jsx(ase,{children:l.jsxs(Lae,{children:[l.jsx(Va,{path:"/camera/:printerId",element:l.jsx(ZGe,{})}),l.jsxs(Va,{path:"/",element:l.jsx(ude,{}),children:[l.jsx(Va,{index:!0,element:l.jsx(LCe,{})}),l.jsx(Va,{path:"archives",element:l.jsx(c7e,{})}),l.jsx(Va,{path:"queue",element:l.jsx(K9e,{})}),l.jsx(Va,{path:"stats",element:l.jsx(lGe,{})}),l.jsx(Va,{path:"profiles",element:l.jsx(IGe,{})}),l.jsx(Va,{path:"maintenance",element:l.jsx(BGe,{})}),l.jsx(Va,{path:"projects",element:l.jsx($Ge,{})}),l.jsx(Va,{path:"projects/:id",element:l.jsx(YGe,{})}),l.jsx(Va,{path:"settings",element:l.jsx(AGe,{})}),l.jsx(Va,{path:"system",element:l.jsx(JGe,{})}),l.jsx(Va,{path:"external/:id",element:l.jsx(QGe,{})})]})]})})})})})})}zre.createRoot(document.getElementById("root")).render(l.jsx(M.StrictMode,{children:l.jsx(rWe,{})}));