| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611 |
- function bne(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var Ub=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ja(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var OA={exports:{}},jg={};var sU;function yne(){if(sU)return jg;sU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var a=null;if(s!==void 0&&(a=""+s),i.key!==void 0&&(a=""+i.key),"key"in i){s={};for(var o in i)o!=="key"&&(s[o]=i[o])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:a,ref:i!==void 0?i:null,props:s}}return jg.Fragment=e,jg.jsx=n,jg.jsxs=n,jg}var aU;function _ne(){return aU||(aU=1,OA.exports=yne()),OA.exports}var f=_ne(),LA={exports:{}},Zt={};var oU;function Sne(){if(oU)return Zt;oU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function m(H){return H===null||typeof H!="object"?null:(H=g&&H[g]||H["@@iterator"],typeof H=="function"?H:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function x(H,Y,te){this.props=H,this.context=Y,this.refs=v,this.updater=te||b}x.prototype.isReactComponent={},x.prototype.setState=function(H,Y){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,Y,"setState")},x.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function M(){}M.prototype=x.prototype;function w(H,Y,te){this.props=H,this.context=Y,this.refs=v,this.updater=te||b}var T=w.prototype=new M;T.constructor=w,y(T,x.prototype),T.isPureReactComponent=!0;var A=Array.isArray;function P(){}var C={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function N(H,Y,te){var ae=te.ref;return{$$typeof:t,type:H,key:Y,ref:ae!==void 0?ae:null,props:te}}function k(H,Y){return N(H.type,Y,H.props)}function F(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function I(H){var Y={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(te){return Y[te]})}var W=/\/+/g;function D(H,Y){return typeof H=="object"&&H!==null&&H.key!=null?I(""+H.key):Y.toString(36)}function $(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(P,P):(H.status="pending",H.then(function(Y){H.status==="pending"&&(H.status="fulfilled",H.value=Y)},function(Y){H.status==="pending"&&(H.status="rejected",H.reason=Y)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function G(H,Y,te,ae,fe){var Q=typeof H;(Q==="undefined"||Q==="boolean")&&(H=null);var me=!1;if(H===null)me=!0;else switch(Q){case"bigint":case"string":case"number":me=!0;break;case"object":switch(H.$$typeof){case t:case e:me=!0;break;case u:return me=H._init,G(me(H._payload),Y,te,ae,fe)}}if(me)return fe=fe(H),me=ae===""?"."+D(H,0):ae,A(fe)?(te="",me!=null&&(te=me.replace(W,"$&/")+"/"),G(fe,Y,te,"",function(we){return we})):fe!=null&&(F(fe)&&(fe=k(fe,te+(fe.key==null||H&&H.key===fe.key?"":(""+fe.key).replace(W,"$&/")+"/")+me)),Y.push(fe)),1;me=0;var Ee=ae===""?".":ae+":";if(A(H))for(var he=0;he<H.length;he++)ae=H[he],Q=Ee+D(ae,he),me+=G(ae,Y,te,Q,fe);else if(he=m(H),typeof he=="function")for(H=he.call(H),he=0;!(ae=H.next()).done;)ae=ae.value,Q=Ee+D(ae,he++),me+=G(ae,Y,te,Q,fe);else if(Q==="object"){if(typeof H.then=="function")return G($(H),Y,te,ae,fe);throw Y=String(H),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return me}function V(H,Y,te){if(H==null)return H;var ae=[],fe=0;return G(H,ae,"","",function(Q){return Y.call(te,Q,fe++)}),ae}function Z(H){if(H._status===-1){var Y=H._result;Y=Y(),Y.then(function(te){(H._status===0||H._status===-1)&&(H._status=1,H._result=te)},function(te){(H._status===0||H._status===-1)&&(H._status=2,H._result=te)}),H._status===-1&&(H._status=0,H._result=Y)}if(H._status===1)return H._result.default;throw H._result}var K=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=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(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},ee={map:V,forEach:function(H,Y,te){V(H,function(){Y.apply(this,arguments)},te)},count:function(H){var Y=0;return V(H,function(){Y++}),Y},toArray:function(H){return V(H,function(Y){return Y})||[]},only:function(H){if(!F(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return Zt.Activity=h,Zt.Children=ee,Zt.Component=x,Zt.Fragment=n,Zt.Profiler=i,Zt.PureComponent=w,Zt.StrictMode=r,Zt.Suspense=l,Zt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,Zt.__COMPILER_RUNTIME={__proto__:null,c:function(H){return C.H.useMemoCache(H)}},Zt.cache=function(H){return function(){return H.apply(null,arguments)}},Zt.cacheSignal=function(){return null},Zt.cloneElement=function(H,Y,te){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ae=y({},H.props),fe=H.key;if(Y!=null)for(Q in Y.key!==void 0&&(fe=""+Y.key),Y)!j.call(Y,Q)||Q==="key"||Q==="__self"||Q==="__source"||Q==="ref"&&Y.ref===void 0||(ae[Q]=Y[Q]);var Q=arguments.length-2;if(Q===1)ae.children=te;else if(1<Q){for(var me=Array(Q),Ee=0;Ee<Q;Ee++)me[Ee]=arguments[Ee+2];ae.children=me}return N(H.type,fe,ae)},Zt.createContext=function(H){return H={$$typeof:a,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:s,_context:H},H},Zt.createElement=function(H,Y,te){var ae,fe={},Q=null;if(Y!=null)for(ae in Y.key!==void 0&&(Q=""+Y.key),Y)j.call(Y,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(fe[ae]=Y[ae]);var me=arguments.length-2;if(me===1)fe.children=te;else if(1<me){for(var Ee=Array(me),he=0;he<me;he++)Ee[he]=arguments[he+2];fe.children=Ee}if(H&&H.defaultProps)for(ae in me=H.defaultProps,me)fe[ae]===void 0&&(fe[ae]=me[ae]);return N(H,Q,fe)},Zt.createRef=function(){return{current:null}},Zt.forwardRef=function(H){return{$$typeof:o,render:H}},Zt.isValidElement=F,Zt.lazy=function(H){return{$$typeof:u,_payload:{_status:-1,_result:H},_init:Z}},Zt.memo=function(H,Y){return{$$typeof:c,type:H,compare:Y===void 0?null:Y}},Zt.startTransition=function(H){var Y=C.T,te={};C.T=te;try{var ae=H(),fe=C.S;fe!==null&&fe(te,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(P,K)}catch(Q){K(Q)}finally{Y!==null&&te.types!==null&&(Y.types=te.types),C.T=Y}},Zt.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},Zt.use=function(H){return C.H.use(H)},Zt.useActionState=function(H,Y,te){return C.H.useActionState(H,Y,te)},Zt.useCallback=function(H,Y){return C.H.useCallback(H,Y)},Zt.useContext=function(H){return C.H.useContext(H)},Zt.useDebugValue=function(){},Zt.useDeferredValue=function(H,Y){return C.H.useDeferredValue(H,Y)},Zt.useEffect=function(H,Y){return C.H.useEffect(H,Y)},Zt.useEffectEvent=function(H){return C.H.useEffectEvent(H)},Zt.useId=function(){return C.H.useId()},Zt.useImperativeHandle=function(H,Y,te){return C.H.useImperativeHandle(H,Y,te)},Zt.useInsertionEffect=function(H,Y){return C.H.useInsertionEffect(H,Y)},Zt.useLayoutEffect=function(H,Y){return C.H.useLayoutEffect(H,Y)},Zt.useMemo=function(H,Y){return C.H.useMemo(H,Y)},Zt.useOptimistic=function(H,Y){return C.H.useOptimistic(H,Y)},Zt.useReducer=function(H,Y,te){return C.H.useReducer(H,Y,te)},Zt.useRef=function(H){return C.H.useRef(H)},Zt.useState=function(H){return C.H.useState(H)},Zt.useSyncExternalStore=function(H,Y,te){return C.H.useSyncExternalStore(H,Y,te)},Zt.useTransition=function(){return C.H.useTransition()},Zt.version="19.2.0",Zt}var lU;function Mm(){return lU||(lU=1,LA.exports=Sne()),LA.exports}var E=Mm();const ur=Ja(E),wne=bne({__proto__:null,default:ur},[E]);var IA={exports:{}},Ug={},jA={exports:{}},UA={};var cU;function Mne(){return cU||(cU=1,(function(t){function e(G,V){var Z=G.length;G.push(V);e:for(;0<Z;){var K=Z-1>>>1,ee=G[K];if(0<i(ee,V))G[K]=V,G[Z]=ee,Z=K;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var V=G[0],Z=G.pop();if(Z!==V){G[0]=Z;e:for(var K=0,ee=G.length,H=ee>>>1;K<H;){var Y=2*(K+1)-1,te=G[Y],ae=Y+1,fe=G[ae];if(0>i(te,Z))ae<ee&&0>i(fe,te)?(G[K]=fe,G[ae]=Z,K=ae):(G[K]=te,G[Y]=Z,K=Y);else if(ae<ee&&0>i(fe,Z))G[K]=fe,G[ae]=Z,K=ae;else break e}}return V}function i(G,V){var Z=G.sortIndex-V.sortIndex;return Z!==0?Z:G.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var l=[],c=[],u=1,h=null,g=3,m=!1,b=!1,y=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function T(G){for(var V=n(c);V!==null;){if(V.callback===null)r(c);else if(V.startTime<=G)r(c),V.sortIndex=V.expirationTime,e(l,V);else break;V=n(c)}}function A(G){if(y=!1,T(G),!b)if(n(l)!==null)b=!0,P||(P=!0,I());else{var V=n(c);V!==null&&$(A,V.startTime-G)}}var P=!1,C=-1,j=5,N=-1;function k(){return v?!0:!(t.unstable_now()-N<j)}function F(){if(v=!1,P){var G=t.unstable_now();N=G;var V=!0;try{e:{b=!1,y&&(y=!1,M(C),C=-1),m=!0;var Z=g;try{t:{for(T(G),h=n(l);h!==null&&!(h.expirationTime>G&&k());){var K=h.callback;if(typeof K=="function"){h.callback=null,g=h.priorityLevel;var ee=K(h.expirationTime<=G);if(G=t.unstable_now(),typeof ee=="function"){h.callback=ee,T(G),V=!0;break t}h===n(l)&&r(l),T(G)}else r(l);h=n(l)}if(h!==null)V=!0;else{var H=n(c);H!==null&&$(A,H.startTime-G),V=!1}}break e}finally{h=null,g=Z,m=!1}V=void 0}}finally{V?I():P=!1}}}var I;if(typeof w=="function")I=function(){w(F)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,D=W.port2;W.port1.onmessage=F,I=function(){D.postMessage(null)}}else I=function(){x(F,0)};function $(G,V){C=x(function(){G(t.unstable_now())},V)}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(G){G.callback=null},t.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<G?Math.floor(1e3/G):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(G){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var Z=g;g=V;try{return G()}finally{g=Z}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(G,V){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var Z=g;g=G;try{return V()}finally{g=Z}},t.unstable_scheduleCallback=function(G,V,Z){var K=t.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?K+Z:K):Z=K,G){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=Z+ee,G={id:u++,callback:V,priorityLevel:G,startTime:Z,expirationTime:ee,sortIndex:-1},Z>K?(G.sortIndex=Z,e(c,G),n(l)===null&&G===n(c)&&(y?(M(C),C=-1):y=!0,$(A,Z-K))):(G.sortIndex=ee,e(l,G),b||m||(b=!0,P||(P=!0,I()))),G},t.unstable_shouldYield=k,t.unstable_wrapCallback=function(G){var V=g;return function(){var Z=g;g=V;try{return G.apply(this,arguments)}finally{g=Z}}}})(UA)),UA}var uU;function Ene(){return uU||(uU=1,jA.exports=Mne()),jA.exports}var FA={exports:{}},Zi={};var dU;function Ane(){if(dU)return Zi;dU=1;var t=Mm();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)c+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(l,c,u){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,children:l,containerInfo:c,implementation:u}}var a=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(l,c){if(l==="font")return"";if(typeof c=="string")return c==="use-credentials"?c:""}return Zi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Zi.createPortal=function(l,c){var u=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)throw Error(e(299));return s(l,c,null,u)},Zi.flushSync=function(l){var c=a.T,u=r.p;try{if(a.T=null,r.p=2,l)return l()}finally{a.T=c,r.p=u,r.d.f()}},Zi.preconnect=function(l,c){typeof l=="string"&&(c?(c=c.crossOrigin,c=typeof c=="string"?c==="use-credentials"?c:"":void 0):c=null,r.d.C(l,c))},Zi.prefetchDNS=function(l){typeof l=="string"&&r.d.D(l)},Zi.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var u=c.as,h=o(u,c.crossOrigin),g=typeof c.integrity=="string"?c.integrity:void 0,m=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;u==="style"?r.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:h,integrity:g,fetchPriority:m}):u==="script"&&r.d.X(l,{crossOrigin:h,integrity:g,fetchPriority:m,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},Zi.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var u=o(c.as,c.crossOrigin);r.d.M(l,{crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0})}}else c==null&&r.d.M(l)},Zi.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var u=c.as,h=o(u,c.crossOrigin);r.d.L(l,u,{crossOrigin:h,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0,type:typeof c.type=="string"?c.type:void 0,fetchPriority:typeof c.fetchPriority=="string"?c.fetchPriority:void 0,referrerPolicy:typeof c.referrerPolicy=="string"?c.referrerPolicy:void 0,imageSrcSet:typeof c.imageSrcSet=="string"?c.imageSrcSet:void 0,imageSizes:typeof c.imageSizes=="string"?c.imageSizes:void 0,media:typeof c.media=="string"?c.media:void 0})}},Zi.preloadModule=function(l,c){if(typeof l=="string")if(c){var u=o(c.as,c.crossOrigin);r.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else r.d.m(l)},Zi.requestFormReset=function(l){r.d.r(l)},Zi.unstable_batchedUpdates=function(l,c){return l(c)},Zi.useFormState=function(l,c,u){return a.H.useFormState(l,c,u)},Zi.useFormStatus=function(){return a.H.useHostTransitionStatus()},Zi.version="19.2.0",Zi}var fU;function SG(){if(fU)return FA.exports;fU=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(),FA.exports=Ane(),FA.exports}var hU;function Tne(){if(hU)return Ug;hU=1;var t=Ene(),e=Mm(),n=SG();function r(d){var p="https://react.dev/errors/"+d;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+d+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(d){return!(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)}function s(d){var p=d,_=d;if(d.alternate)for(;p.return;)p=p.return;else{d=p;do p=d,(p.flags&4098)!==0&&(_=p.return),d=p.return;while(d)}return p.tag===3?_:null}function a(d){if(d.tag===13){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function o(d){if(d.tag===31){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function l(d){if(s(d)!==d)throw Error(r(188))}function c(d){var p=d.alternate;if(!p){if(p=s(d),p===null)throw Error(r(188));return p!==d?null:d}for(var _=d,S=p;;){var R=_.return;if(R===null)break;var O=R.alternate;if(O===null){if(S=R.return,S!==null){_=S;continue}break}if(R.child===O.child){for(O=R.child;O;){if(O===_)return l(R),d;if(O===S)return l(R),p;O=O.sibling}throw Error(r(188))}if(_.return!==S.return)_=R,S=O;else{for(var q=!1,oe=R.child;oe;){if(oe===_){q=!0,_=R,S=O;break}if(oe===S){q=!0,S=R,_=O;break}oe=oe.sibling}if(!q){for(oe=O.child;oe;){if(oe===_){q=!0,_=O,S=R;break}if(oe===S){q=!0,S=O,_=R;break}oe=oe.sibling}if(!q)throw Error(r(189))}}if(_.alternate!==S)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?d:p}function u(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d;for(d=d.child;d!==null;){if(p=u(d),p!==null)return p;d=d.sibling}return null}var h=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),w=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),k=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function I(d){return d===null||typeof d!="object"?null:(d=F&&d[F]||d["@@iterator"],typeof d=="function"?d:null)}var W=Symbol.for("react.client.reference");function D(d){if(d==null)return null;if(typeof d=="function")return d.$$typeof===W?null:d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case y:return"Fragment";case x:return"Profiler";case v:return"StrictMode";case A:return"Suspense";case P:return"SuspenseList";case N:return"Activity"}if(typeof d=="object")switch(d.$$typeof){case b:return"Portal";case w:return d.displayName||"Context";case M:return(d._context.displayName||"Context")+".Consumer";case T:var p=d.render;return d=d.displayName,d||(d=p.displayName||p.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case C:return p=d.displayName||null,p!==null?p:D(d.type)||"Memo";case j:p=d._payload,d=d._init;try{return D(d(p))}catch{}}return null}var $=Array.isArray,G=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},K=[],ee=-1;function H(d){return{current:d}}function Y(d){0>ee||(d.current=K[ee],K[ee]=null,ee--)}function te(d,p){ee++,K[ee]=d.current,d.current=p}var ae=H(null),fe=H(null),Q=H(null),me=H(null);function Ee(d,p){switch(te(Q,p),te(fe,d),te(ae,null),p.nodeType){case 9:case 11:d=(d=p.documentElement)&&(d=d.namespaceURI)?C4(d):0;break;default:if(d=p.tagName,p=p.namespaceURI)p=C4(p),d=N4(p,d);else switch(d){case"svg":d=1;break;case"math":d=2;break;default:d=0}}Y(ae),te(ae,d)}function he(){Y(ae),Y(fe),Y(Q)}function we(d){d.memoizedState!==null&&te(me,d);var p=ae.current,_=N4(p,d.type);p!==_&&(te(fe,d),te(ae,_))}function De(d){fe.current===d&&(Y(ae),Y(fe)),me.current===d&&(Y(me),Dg._currentValue=Z)}var de,Le;function B(d){if(de===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);de=p&&p[1]||"",Le=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+de+d+Le}var z=!1;function ie(d,p){if(!d||z)return"";z=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(p){var ut=function(){throw Error()};if(Object.defineProperty(ut.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ut,[])}catch(rt){var qe=rt}Reflect.construct(d,[],ut)}else{try{ut.call()}catch(rt){qe=rt}d.call(ut.prototype)}}else{try{throw Error()}catch(rt){qe=rt}(ut=d())&&typeof ut.catch=="function"&&ut.catch(function(){})}}catch(rt){if(rt&&qe&&typeof rt.stack=="string")return[rt.stack,qe.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var R=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");R&&R.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=S.DetermineComponentFrameRoot(),q=O[0],oe=O[1];if(q&&oe){var Se=q.split(`
- `),$e=oe.split(`
- `);for(R=S=0;S<Se.length&&!Se[S].includes("DetermineComponentFrameRoot");)S++;for(;R<$e.length&&!$e[R].includes("DetermineComponentFrameRoot");)R++;if(S===Se.length||R===$e.length)for(S=Se.length-1,R=$e.length-1;1<=S&&0<=R&&Se[S]!==$e[R];)R--;for(;1<=S&&0<=R;S--,R--)if(Se[S]!==$e[R]){if(S!==1||R!==1)do if(S--,R--,0>R||Se[S]!==$e[R]){var at=`
- `+Se[S].replace(" at new "," at ");return d.displayName&&at.includes("<anonymous>")&&(at=at.replace("<anonymous>",d.displayName)),at}while(1<=S&&0<=R);break}}}finally{z=!1,Error.prepareStackTrace=_}return(_=d?d.displayName||d.name:"")?B(_):""}function X(d,p){switch(d.tag){case 26:case 27:case 5:return B(d.type);case 16:return B("Lazy");case 13:return d.child!==p&&p!==null?B("Suspense Fallback"):B("Suspense");case 19:return B("SuspenseList");case 0:case 15:return ie(d.type,!1);case 11:return ie(d.type.render,!1);case 1:return ie(d.type,!0);case 31:return B("Activity");default:return""}}function J(d){try{var p="",_=null;do p+=X(d,_),_=d,d=d.return;while(d);return p}catch(S){return`
- Error generating stack: `+S.message+`
- `+S.stack}}var le=Object.prototype.hasOwnProperty,Re=t.unstable_scheduleCallback,Ae=t.unstable_cancelCallback,se=t.unstable_shouldYield,U=t.unstable_requestPaint,L=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,ve=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,xe=t.unstable_NormalPriority,tt=t.unstable_LowPriority,je=t.unstable_IdlePriority,Ye=t.log,ot=t.unstable_setDisableYieldValue,Fe=null,ce=null;function Qe(d){if(typeof Ye=="function"&&ot(d),ce&&typeof ce.setStrictMode=="function")try{ce.setStrictMode(Fe,d)}catch{}}var Be=Math.clz32?Math.clz32:ue,Ke=Math.log,ct=Math.LN2;function ue(d){return d>>>=0,d===0?32:31-(Ke(d)/ct|0)|0}var Je=256,ge=262144,Ie=4194304;function Te(d){var p=d&42;if(p!==0)return p;switch(d&-d){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return d&261888;case 262144:case 524288:case 1048576:case 2097152:return d&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return d&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return d}}function be(d,p,_){var S=d.pendingLanes;if(S===0)return 0;var R=0,O=d.suspendedLanes,q=d.pingedLanes;d=d.warmLanes;var oe=S&134217727;return oe!==0?(S=oe&~O,S!==0?R=Te(S):(q&=oe,q!==0?R=Te(q):_||(_=oe&~d,_!==0&&(R=Te(_))))):(oe=S&~O,oe!==0?R=Te(oe):q!==0?R=Te(q):_||(_=S&~d,_!==0&&(R=Te(_)))),R===0?0:p!==0&&p!==R&&(p&O)===0&&(O=R&-R,_=p&-p,O>=_||O===32&&(_&4194048)!==0)?p:R}function Ve(d,p){return(d.pendingLanes&~(d.suspendedLanes&~d.pingedLanes)&p)===0}function ft(d,p){switch(d){case 1:case 2:case 4:case 8:case 64:return p+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return p+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function yt(){var d=Ie;return Ie<<=1,(Ie&62914560)===0&&(Ie=4194304),d}function Pt(d){for(var p=[],_=0;31>_;_++)p.push(d);return p}function cn(d,p){d.pendingLanes|=p,p!==268435456&&(d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0)}function Ot(d,p,_,S,R,O){var q=d.pendingLanes;d.pendingLanes=_,d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0,d.expiredLanes&=_,d.entangledLanes&=_,d.errorRecoveryDisabledLanes&=_,d.shellSuspendCounter=0;var oe=d.entanglements,Se=d.expirationTimes,$e=d.hiddenUpdates;for(_=q&~_;0<_;){var at=31-Be(_),ut=1<<at;oe[at]=0,Se[at]=-1;var qe=$e[at];if(qe!==null)for($e[at]=null,at=0;at<qe.length;at++){var rt=qe[at];rt!==null&&(rt.lane&=-536870913)}_&=~ut}S!==0&&Pn(d,S,0),O!==0&&R===0&&d.tag!==0&&(d.suspendedLanes|=O&~(q&~p))}function Pn(d,p,_){d.pendingLanes|=p,d.suspendedLanes&=~p;var S=31-Be(p);d.entangledLanes|=p,d.entanglements[S]=d.entanglements[S]|1073741824|_&261930}function qn(d,p){var _=d.entangledLanes|=p;for(d=d.entanglements;_;){var S=31-Be(_),R=1<<S;R&p|d[S]&p&&(d[S]|=p),_&=~R}}function gi(d,p){var _=p&-p;return _=(_&42)!==0?1:Jr(_),(_&(d.suspendedLanes|p))!==0?0:_}function Jr(d){switch(d){case 2:d=1;break;case 8:d=4;break;case 32:d=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:d=128;break;case 268435456:d=134217728;break;default:d=0}return d}function xi(d){return d&=-d,2<d?8<d?(d&134217727)!==0?32:268435456:8:2}function Di(){var d=V.p;return d!==0?d:(d=window.event,d===void 0?32:Q4(d.type))}function Yi(d,p){var _=V.p;try{return V.p=d,p()}finally{V.p=_}}var jr=Math.random().toString(36).slice(2),pr="__reactFiber$"+jr,Cr="__reactProps$"+jr,to="__reactContainer$"+jr,Oc="__reactEvents$"+jr,pe="__reactListeners$"+jr,ze="__reactHandles$"+jr,et="__reactResources$"+jr,nt="__reactMarker$"+jr;function Ze(d){delete d[pr],delete d[Cr],delete d[Oc],delete d[pe],delete d[ze]}function _t(d){var p=d[pr];if(p)return p;for(var _=d.parentNode;_;){if(p=_[to]||_[pr]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(d=I4(d);d!==null;){if(_=d[pr])return _;d=I4(d)}return p}d=_,_=d.parentNode}return null}function re(d){if(d=d[pr]||d[to]){var p=d.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return d}return null}function _e(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d.stateNode;throw Error(r(33))}function ke(d){var p=d[et];return p||(p=d[et]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Pe(d){d[nt]=!0}var Me=new Set,st={};function ht(d,p){vt(d,p),vt(d+"Capture",p)}function vt(d,p){for(st[d]=p,d=0;d<p.length;d++)Me.add(p[d])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),kt={},wt={};function mt(d){return le.call(wt,d)?!0:le.call(kt,d)?!1:xt.test(d)?wt[d]=!0:(kt[d]=!0,!1)}function qt(d,p,_){if(mt(p))if(_===null)d.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":d.removeAttribute(p);return;case"boolean":var S=p.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){d.removeAttribute(p);return}}d.setAttribute(p,""+_)}}function It(d,p,_){if(_===null)d.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(p);return}d.setAttribute(p,""+_)}}function nn(d,p,_,S){if(S===null)d.removeAttribute(_);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(_);return}d.setAttributeNS(p,_,""+S)}}function dn(d){switch(typeof d){case"bigint":case"boolean":case"number":case"string":case"undefined":return d;case"object":return d;default:return""}}function gn(d){var p=d.type;return(d=d.nodeName)&&d.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Lt(d,p,_){var S=Object.getOwnPropertyDescriptor(d.constructor.prototype,p);if(!d.hasOwnProperty(p)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var R=S.get,O=S.set;return Object.defineProperty(d,p,{configurable:!0,get:function(){return R.call(this)},set:function(q){_=""+q,O.call(this,q)}}),Object.defineProperty(d,p,{enumerable:S.enumerable}),{getValue:function(){return _},setValue:function(q){_=""+q},stopTracking:function(){d._valueTracker=null,delete d[p]}}}}function Yt(d){if(!d._valueTracker){var p=gn(d)?"checked":"value";d._valueTracker=Lt(d,p,""+d[p])}}function Qt(d){if(!d)return!1;var p=d._valueTracker;if(!p)return!0;var _=p.getValue(),S="";return d&&(S=gn(d)?d.checked?"true":"false":d.value),d=S,d!==_?(p.setValue(d),!0):!1}function yr(d){if(d=d||(typeof document<"u"?document:void 0),typeof d>"u")return null;try{return d.activeElement||d.body}catch{return d.body}}var Nr=/[\n"\\]/g;function Nn(d){return d.replace(Nr,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function no(d,p,_,S,R,O,q,oe){d.name="",q!=null&&typeof q!="function"&&typeof q!="symbol"&&typeof q!="boolean"?d.type=q:d.removeAttribute("type"),p!=null?q==="number"?(p===0&&d.value===""||d.value!=p)&&(d.value=""+dn(p)):d.value!==""+dn(p)&&(d.value=""+dn(p)):q!=="submit"&&q!=="reset"||d.removeAttribute("value"),p!=null?vi(d,q,dn(p)):_!=null?vi(d,q,dn(_)):S!=null&&d.removeAttribute("value"),R==null&&O!=null&&(d.defaultChecked=!!O),R!=null&&(d.checked=R&&typeof R!="function"&&typeof R!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?d.name=""+dn(oe):d.removeAttribute("name")}function kn(d,p,_,S,R,O,q,oe){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(d.type=O),p!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||p!=null)){Yt(d);return}_=_!=null?""+dn(_):"",p=p!=null?""+dn(p):_,oe||p===d.value||(d.value=p),d.defaultValue=p}S=S??R,S=typeof S!="function"&&typeof S!="symbol"&&!!S,d.checked=oe?d.checked:!!S,d.defaultChecked=!!S,q!=null&&typeof q!="function"&&typeof q!="symbol"&&typeof q!="boolean"&&(d.name=q),Yt(d)}function vi(d,p,_){p==="number"&&yr(d.ownerDocument)===d||d.defaultValue===""+_||(d.defaultValue=""+_)}function ei(d,p,_,S){if(d=d.options,p){p={};for(var R=0;R<_.length;R++)p["$"+_[R]]=!0;for(_=0;_<d.length;_++)R=p.hasOwnProperty("$"+d[_].value),d[_].selected!==R&&(d[_].selected=R),R&&S&&(d[_].defaultSelected=!0)}else{for(_=""+dn(_),p=null,R=0;R<d.length;R++){if(d[R].value===_){d[R].selected=!0,S&&(d[R].defaultSelected=!0);return}p!==null||d[R].disabled||(p=d[R])}p!==null&&(p.selected=!0)}}function bi(d,p,_){if(p!=null&&(p=""+dn(p),p!==d.value&&(d.value=p),_==null)){d.defaultValue!==p&&(d.defaultValue=p);return}d.defaultValue=_!=null?""+dn(_):""}function Oi(d,p,_,S){if(p==null){if(S!=null){if(_!=null)throw Error(r(92));if($(S)){if(1<S.length)throw Error(r(93));S=S[0]}_=S}_==null&&(_=""),p=_}_=dn(p),d.defaultValue=_,S=d.textContent,S===_&&S!==""&&S!==null&&(d.value=S),Yt(d)}function ko(d,p){if(p){var _=d.firstChild;if(_&&_===d.lastChild&&_.nodeType===3){_.nodeValue=p;return}}d.textContent=p}var hl=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 EL(d,p,_){var S=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?S?d.setProperty(p,""):p==="float"?d.cssFloat="":d[p]="":S?d.setProperty(p,_):typeof _!="number"||_===0||hl.has(p)?p==="float"?d.cssFloat=_:d[p]=(""+_).trim():d[p]=_+"px"}function AL(d,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(d=d.style,_!=null){for(var S in _)!_.hasOwnProperty(S)||p!=null&&p.hasOwnProperty(S)||(S.indexOf("--")===0?d.setProperty(S,""):S==="float"?d.cssFloat="":d[S]="");for(var R in p)S=p[R],p.hasOwnProperty(R)&&_[R]!==S&&EL(d,R,S)}else for(var O in p)p.hasOwnProperty(O)&&EL(d,O,p[O])}function RM(d){if(d.indexOf("-")===-1)return!1;switch(d){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var mee=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"]]),gee=/^[\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 Nv(d){return gee.test(""+d)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":d}function pl(){}var PM=null;function kM(d){return d=d.target||d.srcElement||window,d.correspondingUseElement&&(d=d.correspondingUseElement),d.nodeType===3?d.parentNode:d}var eh=null,th=null;function TL(d){var p=re(d);if(p&&(d=p.stateNode)){var _=d[Cr]||null;e:switch(d=p.stateNode,p.type){case"input":if(no(d,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=d;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Nn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var S=_[p];if(S!==d&&S.form===d.form){var R=S[Cr]||null;if(!R)throw Error(r(90));no(S,R.value,R.defaultValue,R.defaultValue,R.checked,R.defaultChecked,R.type,R.name)}}for(p=0;p<_.length;p++)S=_[p],S.form===d.form&&Qt(S)}break e;case"textarea":bi(d,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&ei(d,!!_.multiple,p,!1)}}}var DM=!1;function CL(d,p,_){if(DM)return d(p,_);DM=!0;try{var S=d(p);return S}finally{if(DM=!1,(eh!==null||th!==null)&&(gb(),eh&&(p=eh,d=th,th=eh=null,TL(p),d)))for(p=0;p<d.length;p++)TL(d[p])}}function Ym(d,p){var _=d.stateNode;if(_===null)return null;var S=_[Cr]||null;if(S===null)return null;_=S[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(d=d.type,S=!(d==="button"||d==="input"||d==="select"||d==="textarea")),d=!S;break e;default:d=!1}if(d)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var ml=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),OM=!1;if(ml)try{var Zm={};Object.defineProperty(Zm,"passive",{get:function(){OM=!0}}),window.addEventListener("test",Zm,Zm),window.removeEventListener("test",Zm,Zm)}catch{OM=!1}var Lc=null,LM=null,Rv=null;function NL(){if(Rv)return Rv;var d,p=LM,_=p.length,S,R="value"in Lc?Lc.value:Lc.textContent,O=R.length;for(d=0;d<_&&p[d]===R[d];d++);var q=_-d;for(S=1;S<=q&&p[_-S]===R[O-S];S++);return Rv=R.slice(d,1<S?1-S:void 0)}function Pv(d){var p=d.keyCode;return"charCode"in d?(d=d.charCode,d===0&&p===13&&(d=13)):d=p,d===10&&(d=13),32<=d||d===13?d:0}function kv(){return!0}function RL(){return!1}function Cs(d){function p(_,S,R,O,q){this._reactName=_,this._targetInst=R,this.type=S,this.nativeEvent=O,this.target=q,this.currentTarget=null;for(var oe in d)d.hasOwnProperty(oe)&&(_=d[oe],this[oe]=_?_(O):O[oe]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?kv:RL,this.isPropagationStopped=RL,this}return h(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=kv)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=kv)},persist:function(){},isPersistent:kv}),p}var md={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(d){return d.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Dv=Cs(md),Qm=h({},md,{view:0,detail:0}),xee=Cs(Qm),IM,jM,Jm,Ov=h({},Qm,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:FM,button:0,buttons:0,relatedTarget:function(d){return d.relatedTarget===void 0?d.fromElement===d.srcElement?d.toElement:d.fromElement:d.relatedTarget},movementX:function(d){return"movementX"in d?d.movementX:(d!==Jm&&(Jm&&d.type==="mousemove"?(IM=d.screenX-Jm.screenX,jM=d.screenY-Jm.screenY):jM=IM=0,Jm=d),IM)},movementY:function(d){return"movementY"in d?d.movementY:jM}}),PL=Cs(Ov),vee=h({},Ov,{dataTransfer:0}),bee=Cs(vee),yee=h({},Qm,{relatedTarget:0}),UM=Cs(yee),_ee=h({},md,{animationName:0,elapsedTime:0,pseudoElement:0}),See=Cs(_ee),wee=h({},md,{clipboardData:function(d){return"clipboardData"in d?d.clipboardData:window.clipboardData}}),Mee=Cs(wee),Eee=h({},md,{data:0}),kL=Cs(Eee),Aee={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Tee={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"},Cee={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Nee(d){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(d):(d=Cee[d])?!!p[d]:!1}function FM(){return Nee}var Ree=h({},Qm,{key:function(d){if(d.key){var p=Aee[d.key]||d.key;if(p!=="Unidentified")return p}return d.type==="keypress"?(d=Pv(d),d===13?"Enter":String.fromCharCode(d)):d.type==="keydown"||d.type==="keyup"?Tee[d.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:FM,charCode:function(d){return d.type==="keypress"?Pv(d):0},keyCode:function(d){return d.type==="keydown"||d.type==="keyup"?d.keyCode:0},which:function(d){return d.type==="keypress"?Pv(d):d.type==="keydown"||d.type==="keyup"?d.keyCode:0}}),Pee=Cs(Ree),kee=h({},Ov,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),DL=Cs(kee),Dee=h({},Qm,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:FM}),Oee=Cs(Dee),Lee=h({},md,{propertyName:0,elapsedTime:0,pseudoElement:0}),Iee=Cs(Lee),jee=h({},Ov,{deltaX:function(d){return"deltaX"in d?d.deltaX:"wheelDeltaX"in d?-d.wheelDeltaX:0},deltaY:function(d){return"deltaY"in d?d.deltaY:"wheelDeltaY"in d?-d.wheelDeltaY:"wheelDelta"in d?-d.wheelDelta:0},deltaZ:0,deltaMode:0}),Uee=Cs(jee),Fee=h({},md,{newState:0,oldState:0}),zee=Cs(Fee),Bee=[9,13,27,32],zM=ml&&"CompositionEvent"in window,eg=null;ml&&"documentMode"in document&&(eg=document.documentMode);var Hee=ml&&"TextEvent"in window&&!eg,OL=ml&&(!zM||eg&&8<eg&&11>=eg),LL=" ",IL=!1;function jL(d,p){switch(d){case"keyup":return Bee.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function UL(d){return d=d.detail,typeof d=="object"&&"data"in d?d.data:null}var nh=!1;function $ee(d,p){switch(d){case"compositionend":return UL(p);case"keypress":return p.which!==32?null:(IL=!0,LL);case"textInput":return d=p.data,d===LL&&IL?null:d;default:return null}}function Vee(d,p){if(nh)return d==="compositionend"||!zM&&jL(d,p)?(d=NL(),Rv=LM=Lc=null,nh=!1,d):null;switch(d){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return OL&&p.locale!=="ko"?null:p.data;default:return null}}var Gee={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 FL(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p==="input"?!!Gee[d.type]:p==="textarea"}function zL(d,p,_,S){eh?th?th.push(S):th=[S]:eh=S,p=wb(p,"onChange"),0<p.length&&(_=new Dv("onChange","change",null,_,S),d.push({event:_,listeners:p}))}var tg=null,ng=null;function Wee(d){S4(d,0)}function Lv(d){var p=_e(d);if(Qt(p))return d}function BL(d,p){if(d==="change")return p}var HL=!1;if(ml){var BM;if(ml){var HM="oninput"in document;if(!HM){var $L=document.createElement("div");$L.setAttribute("oninput","return;"),HM=typeof $L.oninput=="function"}BM=HM}else BM=!1;HL=BM&&(!document.documentMode||9<document.documentMode)}function VL(){tg&&(tg.detachEvent("onpropertychange",GL),ng=tg=null)}function GL(d){if(d.propertyName==="value"&&Lv(ng)){var p=[];zL(p,ng,d,kM(d)),CL(Wee,p)}}function qee(d,p,_){d==="focusin"?(VL(),tg=p,ng=_,tg.attachEvent("onpropertychange",GL)):d==="focusout"&&VL()}function Xee(d){if(d==="selectionchange"||d==="keyup"||d==="keydown")return Lv(ng)}function Kee(d,p){if(d==="click")return Lv(p)}function Yee(d,p){if(d==="input"||d==="change")return Lv(p)}function Zee(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var Ys=typeof Object.is=="function"?Object.is:Zee;function rg(d,p){if(Ys(d,p))return!0;if(typeof d!="object"||d===null||typeof p!="object"||p===null)return!1;var _=Object.keys(d),S=Object.keys(p);if(_.length!==S.length)return!1;for(S=0;S<_.length;S++){var R=_[S];if(!le.call(p,R)||!Ys(d[R],p[R]))return!1}return!0}function WL(d){for(;d&&d.firstChild;)d=d.firstChild;return d}function qL(d,p){var _=WL(d);d=0;for(var S;_;){if(_.nodeType===3){if(S=d+_.textContent.length,d<=p&&S>=p)return{node:_,offset:p-d};d=S}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=WL(_)}}function XL(d,p){return d&&p?d===p?!0:d&&d.nodeType===3?!1:p&&p.nodeType===3?XL(d,p.parentNode):"contains"in d?d.contains(p):d.compareDocumentPosition?!!(d.compareDocumentPosition(p)&16):!1:!1}function KL(d){d=d!=null&&d.ownerDocument!=null&&d.ownerDocument.defaultView!=null?d.ownerDocument.defaultView:window;for(var p=yr(d.document);p instanceof d.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)d=p.contentWindow;else break;p=yr(d.document)}return p}function $M(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p&&(p==="input"&&(d.type==="text"||d.type==="search"||d.type==="tel"||d.type==="url"||d.type==="password")||p==="textarea"||d.contentEditable==="true")}var Qee=ml&&"documentMode"in document&&11>=document.documentMode,rh=null,VM=null,ig=null,GM=!1;function YL(d,p,_){var S=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;GM||rh==null||rh!==yr(S)||(S=rh,"selectionStart"in S&&$M(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}),ig&&rg(ig,S)||(ig=S,S=wb(VM,"onSelect"),0<S.length&&(p=new Dv("onSelect","select",null,p,_),d.push({event:p,listeners:S}),p.target=rh)))}function gd(d,p){var _={};return _[d.toLowerCase()]=p.toLowerCase(),_["Webkit"+d]="webkit"+p,_["Moz"+d]="moz"+p,_}var ih={animationend:gd("Animation","AnimationEnd"),animationiteration:gd("Animation","AnimationIteration"),animationstart:gd("Animation","AnimationStart"),transitionrun:gd("Transition","TransitionRun"),transitionstart:gd("Transition","TransitionStart"),transitioncancel:gd("Transition","TransitionCancel"),transitionend:gd("Transition","TransitionEnd")},WM={},ZL={};ml&&(ZL=document.createElement("div").style,"AnimationEvent"in window||(delete ih.animationend.animation,delete ih.animationiteration.animation,delete ih.animationstart.animation),"TransitionEvent"in window||delete ih.transitionend.transition);function xd(d){if(WM[d])return WM[d];if(!ih[d])return d;var p=ih[d],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in ZL)return WM[d]=p[_];return d}var QL=xd("animationend"),JL=xd("animationiteration"),eI=xd("animationstart"),Jee=xd("transitionrun"),ete=xd("transitionstart"),tte=xd("transitioncancel"),tI=xd("transitionend"),nI=new Map,qM="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");qM.push("scrollEnd");function ro(d,p){nI.set(d,p),ht(p,[d])}var Iv=typeof reportError=="function"?reportError:function(d){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof d=="object"&&d!==null&&typeof d.message=="string"?String(d.message):String(d),error:d});if(!window.dispatchEvent(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",d);return}console.error(d)},va=[],sh=0,XM=0;function jv(){for(var d=sh,p=XM=sh=0;p<d;){var _=va[p];va[p++]=null;var S=va[p];va[p++]=null;var R=va[p];va[p++]=null;var O=va[p];if(va[p++]=null,S!==null&&R!==null){var q=S.pending;q===null?R.next=R:(R.next=q.next,q.next=R),S.pending=R}O!==0&&rI(_,R,O)}}function Uv(d,p,_,S){va[sh++]=d,va[sh++]=p,va[sh++]=_,va[sh++]=S,XM|=S,d.lanes|=S,d=d.alternate,d!==null&&(d.lanes|=S)}function KM(d,p,_,S){return Uv(d,p,_,S),Fv(d)}function vd(d,p){return Uv(d,null,null,p),Fv(d)}function rI(d,p,_){d.lanes|=_;var S=d.alternate;S!==null&&(S.lanes|=_);for(var R=!1,O=d.return;O!==null;)O.childLanes|=_,S=O.alternate,S!==null&&(S.childLanes|=_),O.tag===22&&(d=O.stateNode,d===null||d._visibility&1||(R=!0)),d=O,O=O.return;return d.tag===3?(O=d.stateNode,R&&p!==null&&(R=31-Be(_),d=O.hiddenUpdates,S=d[R],S===null?d[R]=[p]:S.push(p),p.lane=_|536870912),O):null}function Fv(d){if(50<Ag)throw Ag=0,iA=null,Error(r(185));for(var p=d.return;p!==null;)d=p,p=d.return;return d.tag===3?d.stateNode:null}var ah={};function nte(d,p,_,S){this.tag=d,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zs(d,p,_,S){return new nte(d,p,_,S)}function YM(d){return d=d.prototype,!(!d||!d.isReactComponent)}function gl(d,p){var _=d.alternate;return _===null?(_=Zs(d.tag,p,d.key,d.mode),_.elementType=d.elementType,_.type=d.type,_.stateNode=d.stateNode,_.alternate=d,d.alternate=_):(_.pendingProps=p,_.type=d.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=d.flags&65011712,_.childLanes=d.childLanes,_.lanes=d.lanes,_.child=d.child,_.memoizedProps=d.memoizedProps,_.memoizedState=d.memoizedState,_.updateQueue=d.updateQueue,p=d.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=d.sibling,_.index=d.index,_.ref=d.ref,_.refCleanup=d.refCleanup,_}function iI(d,p){d.flags&=65011714;var _=d.alternate;return _===null?(d.childLanes=0,d.lanes=p,d.child=null,d.subtreeFlags=0,d.memoizedProps=null,d.memoizedState=null,d.updateQueue=null,d.dependencies=null,d.stateNode=null):(d.childLanes=_.childLanes,d.lanes=_.lanes,d.child=_.child,d.subtreeFlags=0,d.deletions=null,d.memoizedProps=_.memoizedProps,d.memoizedState=_.memoizedState,d.updateQueue=_.updateQueue,d.type=_.type,p=_.dependencies,d.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),d}function zv(d,p,_,S,R,O){var q=0;if(S=d,typeof d=="function")YM(d)&&(q=1);else if(typeof d=="string")q=one(d,_,ae.current)?26:d==="html"||d==="head"||d==="body"?27:5;else e:switch(d){case N:return d=Zs(31,_,p,R),d.elementType=N,d.lanes=O,d;case y:return bd(_.children,R,O,p);case v:q=8,R|=24;break;case x:return d=Zs(12,_,p,R|2),d.elementType=x,d.lanes=O,d;case A:return d=Zs(13,_,p,R),d.elementType=A,d.lanes=O,d;case P:return d=Zs(19,_,p,R),d.elementType=P,d.lanes=O,d;default:if(typeof d=="object"&&d!==null)switch(d.$$typeof){case w:q=10;break e;case M:q=9;break e;case T:q=11;break e;case C:q=14;break e;case j:q=16,S=null;break e}q=29,_=Error(r(130,d===null?"null":typeof d,"")),S=null}return p=Zs(q,_,p,R),p.elementType=d,p.type=S,p.lanes=O,p}function bd(d,p,_,S){return d=Zs(7,d,S,p),d.lanes=_,d}function ZM(d,p,_){return d=Zs(6,d,null,p),d.lanes=_,d}function sI(d){var p=Zs(18,null,null,0);return p.stateNode=d,p}function QM(d,p,_){return p=Zs(4,d.children!==null?d.children:[],d.key,p),p.lanes=_,p.stateNode={containerInfo:d.containerInfo,pendingChildren:null,implementation:d.implementation},p}var aI=new WeakMap;function ba(d,p){if(typeof d=="object"&&d!==null){var _=aI.get(d);return _!==void 0?_:(p={value:d,source:p,stack:J(p)},aI.set(d,p),p)}return{value:d,source:p,stack:J(p)}}var oh=[],lh=0,Bv=null,sg=0,ya=[],_a=0,Ic=null,Do=1,Oo="";function xl(d,p){oh[lh++]=sg,oh[lh++]=Bv,Bv=d,sg=p}function oI(d,p,_){ya[_a++]=Do,ya[_a++]=Oo,ya[_a++]=Ic,Ic=d;var S=Do;d=Oo;var R=32-Be(S)-1;S&=~(1<<R),_+=1;var O=32-Be(p)+R;if(30<O){var q=R-R%5;O=(S&(1<<q)-1).toString(32),S>>=q,R-=q,Do=1<<32-Be(p)+R|_<<R|S,Oo=O+d}else Do=1<<O|_<<R|S,Oo=d}function JM(d){d.return!==null&&(xl(d,1),oI(d,1,0))}function eE(d){for(;d===Bv;)Bv=oh[--lh],oh[lh]=null,sg=oh[--lh],oh[lh]=null;for(;d===Ic;)Ic=ya[--_a],ya[_a]=null,Oo=ya[--_a],ya[_a]=null,Do=ya[--_a],ya[_a]=null}function lI(d,p){ya[_a++]=Do,ya[_a++]=Oo,ya[_a++]=Ic,Do=p.id,Oo=p.overflow,Ic=d}var Li=null,tr=null,yn=!1,jc=null,Sa=!1,tE=Error(r(519));function Uc(d){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ag(ba(p,d)),tE}function cI(d){var p=d.stateNode,_=d.type,S=d.memoizedProps;switch(p[pr]=d,p[Cr]=S,_){case"dialog":pn("cancel",p),pn("close",p);break;case"iframe":case"object":case"embed":pn("load",p);break;case"video":case"audio":for(_=0;_<Cg.length;_++)pn(Cg[_],p);break;case"source":pn("error",p);break;case"img":case"image":case"link":pn("error",p),pn("load",p);break;case"details":pn("toggle",p);break;case"input":pn("invalid",p),kn(p,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":pn("invalid",p);break;case"textarea":pn("invalid",p),Oi(p,S.value,S.defaultValue,S.children)}_=S.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||S.suppressHydrationWarning===!0||A4(p.textContent,_)?(S.popover!=null&&(pn("beforetoggle",p),pn("toggle",p)),S.onScroll!=null&&pn("scroll",p),S.onScrollEnd!=null&&pn("scrollend",p),S.onClick!=null&&(p.onclick=pl),p=!0):p=!1,p||Uc(d,!0)}function uI(d){for(Li=d.return;Li;)switch(Li.tag){case 5:case 31:case 13:Sa=!1;return;case 27:case 3:Sa=!0;return;default:Li=Li.return}}function ch(d){if(d!==Li)return!1;if(!yn)return uI(d),yn=!0,!1;var p=d.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=d.type,_=!(_!=="form"&&_!=="button")||bA(d.type,d.memoizedProps)),_=!_),_&&tr&&Uc(d),uI(d),p===13){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));tr=L4(d)}else if(p===31){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));tr=L4(d)}else p===27?(p=tr,Qc(d.type)?(d=MA,MA=null,tr=d):tr=p):tr=Li?Ma(d.stateNode.nextSibling):null;return!0}function yd(){tr=Li=null,yn=!1}function nE(){var d=jc;return d!==null&&(ks===null?ks=d:ks.push.apply(ks,d),jc=null),d}function ag(d){jc===null?jc=[d]:jc.push(d)}var rE=H(null),_d=null,vl=null;function Fc(d,p,_){te(rE,p._currentValue),p._currentValue=_}function bl(d){d._currentValue=rE.current,Y(rE)}function iE(d,p,_){for(;d!==null;){var S=d.alternate;if((d.childLanes&p)!==p?(d.childLanes|=p,S!==null&&(S.childLanes|=p)):S!==null&&(S.childLanes&p)!==p&&(S.childLanes|=p),d===_)break;d=d.return}}function sE(d,p,_,S){var R=d.child;for(R!==null&&(R.return=d);R!==null;){var O=R.dependencies;if(O!==null){var q=R.child;O=O.firstContext;e:for(;O!==null;){var oe=O;O=R;for(var Se=0;Se<p.length;Se++)if(oe.context===p[Se]){O.lanes|=_,oe=O.alternate,oe!==null&&(oe.lanes|=_),iE(O.return,_,d),S||(q=null);break e}O=oe.next}}else if(R.tag===18){if(q=R.return,q===null)throw Error(r(341));q.lanes|=_,O=q.alternate,O!==null&&(O.lanes|=_),iE(q,_,d),q=null}else q=R.child;if(q!==null)q.return=R;else for(q=R;q!==null;){if(q===d){q=null;break}if(R=q.sibling,R!==null){R.return=q.return,q=R;break}q=q.return}R=q}}function uh(d,p,_,S){d=null;for(var R=p,O=!1;R!==null;){if(!O){if((R.flags&524288)!==0)O=!0;else if((R.flags&262144)!==0)break}if(R.tag===10){var q=R.alternate;if(q===null)throw Error(r(387));if(q=q.memoizedProps,q!==null){var oe=R.type;Ys(R.pendingProps.value,q.value)||(d!==null?d.push(oe):d=[oe])}}else if(R===me.current){if(q=R.alternate,q===null)throw Error(r(387));q.memoizedState.memoizedState!==R.memoizedState.memoizedState&&(d!==null?d.push(Dg):d=[Dg])}R=R.return}d!==null&&sE(p,d,_,S),p.flags|=262144}function Hv(d){for(d=d.firstContext;d!==null;){if(!Ys(d.context._currentValue,d.memoizedValue))return!0;d=d.next}return!1}function Sd(d){_d=d,vl=null,d=d.dependencies,d!==null&&(d.firstContext=null)}function Ii(d){return dI(_d,d)}function $v(d,p){return _d===null&&Sd(d),dI(d,p)}function dI(d,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},vl===null){if(d===null)throw Error(r(308));vl=p,d.dependencies={lanes:0,firstContext:p},d.flags|=524288}else vl=vl.next=p;return _}var rte=typeof AbortController<"u"?AbortController:function(){var d=[],p=this.signal={aborted:!1,addEventListener:function(_,S){d.push(S)}};this.abort=function(){p.aborted=!0,d.forEach(function(_){return _()})}},ite=t.unstable_scheduleCallback,ste=t.unstable_NormalPriority,Ur={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function aE(){return{controller:new rte,data:new Map,refCount:0}}function og(d){d.refCount--,d.refCount===0&&ite(ste,function(){d.controller.abort()})}var lg=null,oE=0,dh=0,fh=null;function ate(d,p){if(lg===null){var _=lg=[];oE=0,dh=uA(),fh={status:"pending",value:void 0,then:function(S){_.push(S)}}}return oE++,p.then(fI,fI),p}function fI(){if(--oE===0&&lg!==null){fh!==null&&(fh.status="fulfilled");var d=lg;lg=null,dh=0,fh=null;for(var p=0;p<d.length;p++)(0,d[p])()}}function ote(d,p){var _=[],S={status:"pending",value:null,reason:null,then:function(R){_.push(R)}};return d.then(function(){S.status="fulfilled",S.value=p;for(var R=0;R<_.length;R++)(0,_[R])(p)},function(R){for(S.status="rejected",S.reason=R,R=0;R<_.length;R++)(0,_[R])(void 0)}),S}var hI=G.S;G.S=function(d,p){Yj=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&ate(d,p),hI!==null&&hI(d,p)};var wd=H(null);function lE(){var d=wd.current;return d!==null?d:Xn.pooledCache}function Vv(d,p){p===null?te(wd,wd.current):te(wd,p.pool)}function pI(){var d=lE();return d===null?null:{parent:Ur._currentValue,pool:d}}var hh=Error(r(460)),cE=Error(r(474)),Gv=Error(r(542)),Wv={then:function(){}};function mI(d){return d=d.status,d==="fulfilled"||d==="rejected"}function gI(d,p,_){switch(_=d[_],_===void 0?d.push(p):_!==p&&(p.then(pl,pl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,vI(d),d;default:if(typeof p.status=="string")p.then(pl,pl);else{if(d=Xn,d!==null&&100<d.shellSuspendCounter)throw Error(r(482));d=p,d.status="pending",d.then(function(S){if(p.status==="pending"){var R=p;R.status="fulfilled",R.value=S}},function(S){if(p.status==="pending"){var R=p;R.status="rejected",R.reason=S}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,vI(d),d}throw Ed=p,hh}}function Md(d){try{var p=d._init;return p(d._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Ed=_,hh):_}}var Ed=null;function xI(){if(Ed===null)throw Error(r(459));var d=Ed;return Ed=null,d}function vI(d){if(d===hh||d===Gv)throw Error(r(483))}var ph=null,cg=0;function qv(d){var p=cg;return cg+=1,ph===null&&(ph=[]),gI(ph,d,p)}function ug(d,p){p=p.props.ref,d.ref=p!==void 0?p:null}function Xv(d,p){throw p.$$typeof===g?Error(r(525)):(d=Object.prototype.toString.call(p),Error(r(31,d==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":d)))}function bI(d){function p(Oe,Ce){if(d){var He=Oe.deletions;He===null?(Oe.deletions=[Ce],Oe.flags|=16):He.push(Ce)}}function _(Oe,Ce){if(!d)return null;for(;Ce!==null;)p(Oe,Ce),Ce=Ce.sibling;return null}function S(Oe){for(var Ce=new Map;Oe!==null;)Oe.key!==null?Ce.set(Oe.key,Oe):Ce.set(Oe.index,Oe),Oe=Oe.sibling;return Ce}function R(Oe,Ce){return Oe=gl(Oe,Ce),Oe.index=0,Oe.sibling=null,Oe}function O(Oe,Ce,He){return Oe.index=He,d?(He=Oe.alternate,He!==null?(He=He.index,He<Ce?(Oe.flags|=67108866,Ce):He):(Oe.flags|=67108866,Ce)):(Oe.flags|=1048576,Ce)}function q(Oe){return d&&Oe.alternate===null&&(Oe.flags|=67108866),Oe}function oe(Oe,Ce,He,lt){return Ce===null||Ce.tag!==6?(Ce=ZM(He,Oe.mode,lt),Ce.return=Oe,Ce):(Ce=R(Ce,He),Ce.return=Oe,Ce)}function Se(Oe,Ce,He,lt){var jt=He.type;return jt===y?at(Oe,Ce,He.props.children,lt,He.key):Ce!==null&&(Ce.elementType===jt||typeof jt=="object"&&jt!==null&&jt.$$typeof===j&&Md(jt)===Ce.type)?(Ce=R(Ce,He.props),ug(Ce,He),Ce.return=Oe,Ce):(Ce=zv(He.type,He.key,He.props,null,Oe.mode,lt),ug(Ce,He),Ce.return=Oe,Ce)}function $e(Oe,Ce,He,lt){return Ce===null||Ce.tag!==4||Ce.stateNode.containerInfo!==He.containerInfo||Ce.stateNode.implementation!==He.implementation?(Ce=QM(He,Oe.mode,lt),Ce.return=Oe,Ce):(Ce=R(Ce,He.children||[]),Ce.return=Oe,Ce)}function at(Oe,Ce,He,lt,jt){return Ce===null||Ce.tag!==7?(Ce=bd(He,Oe.mode,lt,jt),Ce.return=Oe,Ce):(Ce=R(Ce,He),Ce.return=Oe,Ce)}function ut(Oe,Ce,He){if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number"||typeof Ce=="bigint")return Ce=ZM(""+Ce,Oe.mode,He),Ce.return=Oe,Ce;if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case m:return He=zv(Ce.type,Ce.key,Ce.props,null,Oe.mode,He),ug(He,Ce),He.return=Oe,He;case b:return Ce=QM(Ce,Oe.mode,He),Ce.return=Oe,Ce;case j:return Ce=Md(Ce),ut(Oe,Ce,He)}if($(Ce)||I(Ce))return Ce=bd(Ce,Oe.mode,He,null),Ce.return=Oe,Ce;if(typeof Ce.then=="function")return ut(Oe,qv(Ce),He);if(Ce.$$typeof===w)return ut(Oe,$v(Oe,Ce),He);Xv(Oe,Ce)}return null}function qe(Oe,Ce,He,lt){var jt=Ce!==null?Ce.key:null;if(typeof He=="string"&&He!==""||typeof He=="number"||typeof He=="bigint")return jt!==null?null:oe(Oe,Ce,""+He,lt);if(typeof He=="object"&&He!==null){switch(He.$$typeof){case m:return He.key===jt?Se(Oe,Ce,He,lt):null;case b:return He.key===jt?$e(Oe,Ce,He,lt):null;case j:return He=Md(He),qe(Oe,Ce,He,lt)}if($(He)||I(He))return jt!==null?null:at(Oe,Ce,He,lt,null);if(typeof He.then=="function")return qe(Oe,Ce,qv(He),lt);if(He.$$typeof===w)return qe(Oe,Ce,$v(Oe,He),lt);Xv(Oe,He)}return null}function rt(Oe,Ce,He,lt,jt){if(typeof lt=="string"&<!==""||typeof lt=="number"||typeof lt=="bigint")return Oe=Oe.get(He)||null,oe(Ce,Oe,""+lt,jt);if(typeof lt=="object"&<!==null){switch(lt.$$typeof){case m:return Oe=Oe.get(lt.key===null?He:lt.key)||null,Se(Ce,Oe,lt,jt);case b:return Oe=Oe.get(lt.key===null?He:lt.key)||null,$e(Ce,Oe,lt,jt);case j:return lt=Md(lt),rt(Oe,Ce,He,lt,jt)}if($(lt)||I(lt))return Oe=Oe.get(He)||null,at(Ce,Oe,lt,jt,null);if(typeof lt.then=="function")return rt(Oe,Ce,He,qv(lt),jt);if(lt.$$typeof===w)return rt(Oe,Ce,He,$v(Ce,lt),jt);Xv(Ce,lt)}return null}function Rt(Oe,Ce,He,lt){for(var jt=null,wn=null,Dt=Ce,en=Ce=0,vn=null;Dt!==null&&en<He.length;en++){Dt.index>en?(vn=Dt,Dt=null):vn=Dt.sibling;var Mn=qe(Oe,Dt,He[en],lt);if(Mn===null){Dt===null&&(Dt=vn);break}d&&Dt&&Mn.alternate===null&&p(Oe,Dt),Ce=O(Mn,Ce,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn,Dt=vn}if(en===He.length)return _(Oe,Dt),yn&&xl(Oe,en),jt;if(Dt===null){for(;en<He.length;en++)Dt=ut(Oe,He[en],lt),Dt!==null&&(Ce=O(Dt,Ce,en),wn===null?jt=Dt:wn.sibling=Dt,wn=Dt);return yn&&xl(Oe,en),jt}for(Dt=S(Dt);en<He.length;en++)vn=rt(Dt,Oe,en,He[en],lt),vn!==null&&(d&&vn.alternate!==null&&Dt.delete(vn.key===null?en:vn.key),Ce=O(vn,Ce,en),wn===null?jt=vn:wn.sibling=vn,wn=vn);return d&&Dt.forEach(function(ru){return p(Oe,ru)}),yn&&xl(Oe,en),jt}function Ht(Oe,Ce,He,lt){if(He==null)throw Error(r(151));for(var jt=null,wn=null,Dt=Ce,en=Ce=0,vn=null,Mn=He.next();Dt!==null&&!Mn.done;en++,Mn=He.next()){Dt.index>en?(vn=Dt,Dt=null):vn=Dt.sibling;var ru=qe(Oe,Dt,Mn.value,lt);if(ru===null){Dt===null&&(Dt=vn);break}d&&Dt&&ru.alternate===null&&p(Oe,Dt),Ce=O(ru,Ce,en),wn===null?jt=ru:wn.sibling=ru,wn=ru,Dt=vn}if(Mn.done)return _(Oe,Dt),yn&&xl(Oe,en),jt;if(Dt===null){for(;!Mn.done;en++,Mn=He.next())Mn=ut(Oe,Mn.value,lt),Mn!==null&&(Ce=O(Mn,Ce,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn);return yn&&xl(Oe,en),jt}for(Dt=S(Dt);!Mn.done;en++,Mn=He.next())Mn=rt(Dt,Oe,en,Mn.value,lt),Mn!==null&&(d&&Mn.alternate!==null&&Dt.delete(Mn.key===null?en:Mn.key),Ce=O(Mn,Ce,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn);return d&&Dt.forEach(function(vne){return p(Oe,vne)}),yn&&xl(Oe,en),jt}function Fn(Oe,Ce,He,lt){if(typeof He=="object"&&He!==null&&He.type===y&&He.key===null&&(He=He.props.children),typeof He=="object"&&He!==null){switch(He.$$typeof){case m:e:{for(var jt=He.key;Ce!==null;){if(Ce.key===jt){if(jt=He.type,jt===y){if(Ce.tag===7){_(Oe,Ce.sibling),lt=R(Ce,He.props.children),lt.return=Oe,Oe=lt;break e}}else if(Ce.elementType===jt||typeof jt=="object"&&jt!==null&&jt.$$typeof===j&&Md(jt)===Ce.type){_(Oe,Ce.sibling),lt=R(Ce,He.props),ug(lt,He),lt.return=Oe,Oe=lt;break e}_(Oe,Ce);break}else p(Oe,Ce);Ce=Ce.sibling}He.type===y?(lt=bd(He.props.children,Oe.mode,lt,He.key),lt.return=Oe,Oe=lt):(lt=zv(He.type,He.key,He.props,null,Oe.mode,lt),ug(lt,He),lt.return=Oe,Oe=lt)}return q(Oe);case b:e:{for(jt=He.key;Ce!==null;){if(Ce.key===jt)if(Ce.tag===4&&Ce.stateNode.containerInfo===He.containerInfo&&Ce.stateNode.implementation===He.implementation){_(Oe,Ce.sibling),lt=R(Ce,He.children||[]),lt.return=Oe,Oe=lt;break e}else{_(Oe,Ce);break}else p(Oe,Ce);Ce=Ce.sibling}lt=QM(He,Oe.mode,lt),lt.return=Oe,Oe=lt}return q(Oe);case j:return He=Md(He),Fn(Oe,Ce,He,lt)}if($(He))return Rt(Oe,Ce,He,lt);if(I(He)){if(jt=I(He),typeof jt!="function")throw Error(r(150));return He=jt.call(He),Ht(Oe,Ce,He,lt)}if(typeof He.then=="function")return Fn(Oe,Ce,qv(He),lt);if(He.$$typeof===w)return Fn(Oe,Ce,$v(Oe,He),lt);Xv(Oe,He)}return typeof He=="string"&&He!==""||typeof He=="number"||typeof He=="bigint"?(He=""+He,Ce!==null&&Ce.tag===6?(_(Oe,Ce.sibling),lt=R(Ce,He),lt.return=Oe,Oe=lt):(_(Oe,Ce),lt=ZM(He,Oe.mode,lt),lt.return=Oe,Oe=lt),q(Oe)):_(Oe,Ce)}return function(Oe,Ce,He,lt){try{cg=0;var jt=Fn(Oe,Ce,He,lt);return ph=null,jt}catch(Dt){if(Dt===hh||Dt===Gv)throw Dt;var wn=Zs(29,Dt,null,Oe.mode);return wn.lanes=lt,wn.return=Oe,wn}finally{}}}var Ad=bI(!0),yI=bI(!1),zc=!1;function uE(d){d.updateQueue={baseState:d.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function dE(d,p){d=d.updateQueue,p.updateQueue===d&&(p.updateQueue={baseState:d.baseState,firstBaseUpdate:d.firstBaseUpdate,lastBaseUpdate:d.lastBaseUpdate,shared:d.shared,callbacks:null})}function Bc(d){return{lane:d,tag:0,payload:null,callback:null,next:null}}function Hc(d,p,_){var S=d.updateQueue;if(S===null)return null;if(S=S.shared,(Cn&2)!==0){var R=S.pending;return R===null?p.next=p:(p.next=R.next,R.next=p),S.pending=p,p=Fv(d),rI(d,null,_),p}return Uv(d,S,p,_),Fv(d)}function dg(d,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var S=p.lanes;S&=d.pendingLanes,_|=S,p.lanes=_,qn(d,_)}}function fE(d,p){var _=d.updateQueue,S=d.alternate;if(S!==null&&(S=S.updateQueue,_===S)){var R=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var q={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?R=O=q:O=O.next=q,_=_.next}while(_!==null);O===null?R=O=p:O=O.next=p}else R=O=p;_={baseState:S.baseState,firstBaseUpdate:R,lastBaseUpdate:O,shared:S.shared,callbacks:S.callbacks},d.updateQueue=_;return}d=_.lastBaseUpdate,d===null?_.firstBaseUpdate=p:d.next=p,_.lastBaseUpdate=p}var hE=!1;function fg(){if(hE){var d=fh;if(d!==null)throw d}}function hg(d,p,_,S){hE=!1;var R=d.updateQueue;zc=!1;var O=R.firstBaseUpdate,q=R.lastBaseUpdate,oe=R.shared.pending;if(oe!==null){R.shared.pending=null;var Se=oe,$e=Se.next;Se.next=null,q===null?O=$e:q.next=$e,q=Se;var at=d.alternate;at!==null&&(at=at.updateQueue,oe=at.lastBaseUpdate,oe!==q&&(oe===null?at.firstBaseUpdate=$e:oe.next=$e,at.lastBaseUpdate=Se))}if(O!==null){var ut=R.baseState;q=0,at=$e=Se=null,oe=O;do{var qe=oe.lane&-536870913,rt=qe!==oe.lane;if(rt?(xn&qe)===qe:(S&qe)===qe){qe!==0&&qe===dh&&(hE=!0),at!==null&&(at=at.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var Rt=d,Ht=oe;qe=p;var Fn=_;switch(Ht.tag){case 1:if(Rt=Ht.payload,typeof Rt=="function"){ut=Rt.call(Fn,ut,qe);break e}ut=Rt;break e;case 3:Rt.flags=Rt.flags&-65537|128;case 0:if(Rt=Ht.payload,qe=typeof Rt=="function"?Rt.call(Fn,ut,qe):Rt,qe==null)break e;ut=h({},ut,qe);break e;case 2:zc=!0}}qe=oe.callback,qe!==null&&(d.flags|=64,rt&&(d.flags|=8192),rt=R.callbacks,rt===null?R.callbacks=[qe]:rt.push(qe))}else rt={lane:qe,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},at===null?($e=at=rt,Se=ut):at=at.next=rt,q|=qe;if(oe=oe.next,oe===null){if(oe=R.shared.pending,oe===null)break;rt=oe,oe=rt.next,rt.next=null,R.lastBaseUpdate=rt,R.shared.pending=null}}while(!0);at===null&&(Se=ut),R.baseState=Se,R.firstBaseUpdate=$e,R.lastBaseUpdate=at,O===null&&(R.shared.lanes=0),qc|=q,d.lanes=q,d.memoizedState=ut}}function _I(d,p){if(typeof d!="function")throw Error(r(191,d));d.call(p)}function SI(d,p){var _=d.callbacks;if(_!==null)for(d.callbacks=null,d=0;d<_.length;d++)_I(_[d],p)}var mh=H(null),Kv=H(0);function wI(d,p){d=Cl,te(Kv,d),te(mh,p),Cl=d|p.baseLanes}function pE(){te(Kv,Cl),te(mh,mh.current)}function mE(){Cl=Kv.current,Y(mh),Y(Kv)}var Qs=H(null),wa=null;function $c(d){var p=d.alternate;te(Rr,Rr.current&1),te(Qs,d),wa===null&&(p===null||mh.current!==null||p.memoizedState!==null)&&(wa=d)}function gE(d){te(Rr,Rr.current),te(Qs,d),wa===null&&(wa=d)}function MI(d){d.tag===22?(te(Rr,Rr.current),te(Qs,d),wa===null&&(wa=d)):Vc()}function Vc(){te(Rr,Rr.current),te(Qs,Qs.current)}function Js(d){Y(Qs),wa===d&&(wa=null),Y(Rr)}var Rr=H(0);function Yv(d){for(var p=d;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||SA(_)||wA(_)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var yl=0,Jt=null,jn=null,Fr=null,Zv=!1,gh=!1,Td=!1,Qv=0,pg=0,xh=null,lte=0;function _r(){throw Error(r(321))}function xE(d,p){if(p===null)return!1;for(var _=0;_<p.length&&_<d.length;_++)if(!Ys(d[_],p[_]))return!1;return!0}function vE(d,p,_,S,R,O){return yl=O,Jt=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,G.H=d===null||d.memoizedState===null?oj:DE,Td=!1,O=_(S,R),Td=!1,gh&&(O=AI(p,_,S,R)),EI(d),O}function EI(d){G.H=xg;var p=jn!==null&&jn.next!==null;if(yl=0,Fr=jn=Jt=null,Zv=!1,pg=0,xh=null,p)throw Error(r(300));d===null||zr||(d=d.dependencies,d!==null&&Hv(d)&&(zr=!0))}function AI(d,p,_,S){Jt=d;var R=0;do{if(gh&&(xh=null),pg=0,gh=!1,25<=R)throw Error(r(301));if(R+=1,Fr=jn=null,d.updateQueue!=null){var O=d.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}G.H=lj,O=p(_,S)}while(gh);return O}function cte(){var d=G.H,p=d.useState()[0];return p=typeof p.then=="function"?mg(p):p,d=d.useState()[0],(jn!==null?jn.memoizedState:null)!==d&&(Jt.flags|=1024),p}function bE(){var d=Qv!==0;return Qv=0,d}function yE(d,p,_){p.updateQueue=d.updateQueue,p.flags&=-2053,d.lanes&=~_}function _E(d){if(Zv){for(d=d.memoizedState;d!==null;){var p=d.queue;p!==null&&(p.pending=null),d=d.next}Zv=!1}yl=0,Fr=jn=Jt=null,gh=!1,pg=Qv=0,xh=null}function hs(){var d={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Fr===null?Jt.memoizedState=Fr=d:Fr=Fr.next=d,Fr}function Pr(){if(jn===null){var d=Jt.alternate;d=d!==null?d.memoizedState:null}else d=jn.next;var p=Fr===null?Jt.memoizedState:Fr.next;if(p!==null)Fr=p,jn=d;else{if(d===null)throw Jt.alternate===null?Error(r(467)):Error(r(310));jn=d,d={memoizedState:jn.memoizedState,baseState:jn.baseState,baseQueue:jn.baseQueue,queue:jn.queue,next:null},Fr===null?Jt.memoizedState=Fr=d:Fr=Fr.next=d}return Fr}function Jv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function mg(d){var p=pg;return pg+=1,xh===null&&(xh=[]),d=gI(xh,d,p),p=Jt,(Fr===null?p.memoizedState:Fr.next)===null&&(p=p.alternate,G.H=p===null||p.memoizedState===null?oj:DE),d}function eb(d){if(d!==null&&typeof d=="object"){if(typeof d.then=="function")return mg(d);if(d.$$typeof===w)return Ii(d)}throw Error(r(438,String(d)))}function SE(d){var p=null,_=Jt.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var S=Jt.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(p={data:S.data.map(function(R){return R.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=Jv(),Jt.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(d),S=0;S<d;S++)_[S]=k;return p.index++,_}function _l(d,p){return typeof p=="function"?p(d):p}function tb(d){var p=Pr();return wE(p,jn,d)}function wE(d,p,_){var S=d.queue;if(S===null)throw Error(r(311));S.lastRenderedReducer=_;var R=d.baseQueue,O=S.pending;if(O!==null){if(R!==null){var q=R.next;R.next=O.next,O.next=q}p.baseQueue=R=O,S.pending=null}if(O=d.baseState,R===null)d.memoizedState=O;else{p=R.next;var oe=q=null,Se=null,$e=p,at=!1;do{var ut=$e.lane&-536870913;if(ut!==$e.lane?(xn&ut)===ut:(yl&ut)===ut){var qe=$e.revertLane;if(qe===0)Se!==null&&(Se=Se.next={lane:0,revertLane:0,gesture:null,action:$e.action,hasEagerState:$e.hasEagerState,eagerState:$e.eagerState,next:null}),ut===dh&&(at=!0);else if((yl&qe)===qe){$e=$e.next,qe===dh&&(at=!0);continue}else ut={lane:0,revertLane:$e.revertLane,gesture:null,action:$e.action,hasEagerState:$e.hasEagerState,eagerState:$e.eagerState,next:null},Se===null?(oe=Se=ut,q=O):Se=Se.next=ut,Jt.lanes|=qe,qc|=qe;ut=$e.action,Td&&_(O,ut),O=$e.hasEagerState?$e.eagerState:_(O,ut)}else qe={lane:ut,revertLane:$e.revertLane,gesture:$e.gesture,action:$e.action,hasEagerState:$e.hasEagerState,eagerState:$e.eagerState,next:null},Se===null?(oe=Se=qe,q=O):Se=Se.next=qe,Jt.lanes|=ut,qc|=ut;$e=$e.next}while($e!==null&&$e!==p);if(Se===null?q=O:Se.next=oe,!Ys(O,d.memoizedState)&&(zr=!0,at&&(_=fh,_!==null)))throw _;d.memoizedState=O,d.baseState=q,d.baseQueue=Se,S.lastRenderedState=O}return R===null&&(S.lanes=0),[d.memoizedState,S.dispatch]}function ME(d){var p=Pr(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=d;var S=_.dispatch,R=_.pending,O=p.memoizedState;if(R!==null){_.pending=null;var q=R=R.next;do O=d(O,q.action),q=q.next;while(q!==R);Ys(O,p.memoizedState)||(zr=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),_.lastRenderedState=O}return[O,S]}function TI(d,p,_){var S=Jt,R=Pr(),O=yn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=p();var q=!Ys((jn||R).memoizedState,_);if(q&&(R.memoizedState=_,zr=!0),R=R.queue,TE(RI.bind(null,S,R,d),[d]),R.getSnapshot!==p||q||Fr!==null&&Fr.memoizedState.tag&1){if(S.flags|=2048,vh(9,{destroy:void 0},NI.bind(null,S,R,_,p),null),Xn===null)throw Error(r(349));O||(yl&127)!==0||CI(S,p,_)}return _}function CI(d,p,_){d.flags|=16384,d={getSnapshot:p,value:_},p=Jt.updateQueue,p===null?(p=Jv(),Jt.updateQueue=p,p.stores=[d]):(_=p.stores,_===null?p.stores=[d]:_.push(d))}function NI(d,p,_,S){p.value=_,p.getSnapshot=S,PI(p)&&kI(d)}function RI(d,p,_){return _(function(){PI(p)&&kI(d)})}function PI(d){var p=d.getSnapshot;d=d.value;try{var _=p();return!Ys(d,_)}catch{return!0}}function kI(d){var p=vd(d,2);p!==null&&Ds(p,d,2)}function EE(d){var p=hs();if(typeof d=="function"){var _=d;if(d=_(),Td){Qe(!0);try{_()}finally{Qe(!1)}}}return p.memoizedState=p.baseState=d,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:d},p}function DI(d,p,_,S){return d.baseState=_,wE(d,jn,typeof S=="function"?S:_l)}function ute(d,p,_,S,R){if(ib(d))throw Error(r(485));if(d=p.action,d!==null){var O={payload:R,action:d,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(q){O.listeners.push(q)}};G.T!==null?_(!0):O.isTransition=!1,S(O),_=p.pending,_===null?(O.next=p.pending=O,OI(p,O)):(O.next=_.next,p.pending=_.next=O)}}function OI(d,p){var _=p.action,S=p.payload,R=d.state;if(p.isTransition){var O=G.T,q={};G.T=q;try{var oe=_(R,S),Se=G.S;Se!==null&&Se(q,oe),LI(d,p,oe)}catch($e){AE(d,p,$e)}finally{O!==null&&q.types!==null&&(O.types=q.types),G.T=O}}else try{O=_(R,S),LI(d,p,O)}catch($e){AE(d,p,$e)}}function LI(d,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(S){II(d,p,S)},function(S){return AE(d,p,S)}):II(d,p,_)}function II(d,p,_){p.status="fulfilled",p.value=_,jI(p),d.state=_,p=d.pending,p!==null&&(_=p.next,_===p?d.pending=null:(_=_.next,p.next=_,OI(d,_)))}function AE(d,p,_){var S=d.pending;if(d.pending=null,S!==null){S=S.next;do p.status="rejected",p.reason=_,jI(p),p=p.next;while(p!==S)}d.action=null}function jI(d){d=d.listeners;for(var p=0;p<d.length;p++)(0,d[p])()}function UI(d,p){return p}function FI(d,p){if(yn){var _=Xn.formState;if(_!==null){e:{var S=Jt;if(yn){if(tr){t:{for(var R=tr,O=Sa;R.nodeType!==8;){if(!O){R=null;break t}if(R=Ma(R.nextSibling),R===null){R=null;break t}}O=R.data,R=O==="F!"||O==="F"?R:null}if(R){tr=Ma(R.nextSibling),S=R.data==="F!";break e}}Uc(S)}S=!1}S&&(p=_[0])}}return _=hs(),_.memoizedState=_.baseState=p,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:UI,lastRenderedState:p},_.queue=S,_=ij.bind(null,Jt,S),S.dispatch=_,S=EE(!1),O=kE.bind(null,Jt,!1,S.queue),S=hs(),R={state:p,dispatch:null,action:d,pending:null},S.queue=R,_=ute.bind(null,Jt,R,O,_),R.dispatch=_,S.memoizedState=d,[p,_,!1]}function zI(d){var p=Pr();return BI(p,jn,d)}function BI(d,p,_){if(p=wE(d,p,UI)[0],d=tb(_l)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var S=mg(p)}catch(q){throw q===hh?Gv:q}else S=p;p=Pr();var R=p.queue,O=R.dispatch;return _!==p.memoizedState&&(Jt.flags|=2048,vh(9,{destroy:void 0},dte.bind(null,R,_),null)),[S,O,d]}function dte(d,p){d.action=p}function HI(d){var p=Pr(),_=jn;if(_!==null)return BI(p,_,d);Pr(),p=p.memoizedState,_=Pr();var S=_.queue.dispatch;return _.memoizedState=d,[p,S,!1]}function vh(d,p,_,S){return d={tag:d,create:_,deps:S,inst:p,next:null},p=Jt.updateQueue,p===null&&(p=Jv(),Jt.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=d.next=d:(S=_.next,_.next=d,d.next=S,p.lastEffect=d),d}function $I(){return Pr().memoizedState}function nb(d,p,_,S){var R=hs();Jt.flags|=d,R.memoizedState=vh(1|p,{destroy:void 0},_,S===void 0?null:S)}function rb(d,p,_,S){var R=Pr();S=S===void 0?null:S;var O=R.memoizedState.inst;jn!==null&&S!==null&&xE(S,jn.memoizedState.deps)?R.memoizedState=vh(p,O,_,S):(Jt.flags|=d,R.memoizedState=vh(1|p,O,_,S))}function VI(d,p){nb(8390656,8,d,p)}function TE(d,p){rb(2048,8,d,p)}function fte(d){Jt.flags|=4;var p=Jt.updateQueue;if(p===null)p=Jv(),Jt.updateQueue=p,p.events=[d];else{var _=p.events;_===null?p.events=[d]:_.push(d)}}function GI(d){var p=Pr().memoizedState;return fte({ref:p,nextImpl:d}),function(){if((Cn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function WI(d,p){return rb(4,2,d,p)}function qI(d,p){return rb(4,4,d,p)}function XI(d,p){if(typeof p=="function"){d=d();var _=p(d);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return d=d(),p.current=d,function(){p.current=null}}function KI(d,p,_){_=_!=null?_.concat([d]):null,rb(4,4,XI.bind(null,p,d),_)}function CE(){}function YI(d,p){var _=Pr();p=p===void 0?null:p;var S=_.memoizedState;return p!==null&&xE(p,S[1])?S[0]:(_.memoizedState=[d,p],d)}function ZI(d,p){var _=Pr();p=p===void 0?null:p;var S=_.memoizedState;if(p!==null&&xE(p,S[1]))return S[0];if(S=d(),Td){Qe(!0);try{d()}finally{Qe(!1)}}return _.memoizedState=[S,p],S}function NE(d,p,_){return _===void 0||(yl&1073741824)!==0&&(xn&261930)===0?d.memoizedState=p:(d.memoizedState=_,d=Qj(),Jt.lanes|=d,qc|=d,_)}function QI(d,p,_,S){return Ys(_,p)?_:mh.current!==null?(d=NE(d,_,S),Ys(d,p)||(zr=!0),d):(yl&42)===0||(yl&1073741824)!==0&&(xn&261930)===0?(zr=!0,d.memoizedState=_):(d=Qj(),Jt.lanes|=d,qc|=d,p)}function JI(d,p,_,S,R){var O=V.p;V.p=O!==0&&8>O?O:8;var q=G.T,oe={};G.T=oe,kE(d,!1,p,_);try{var Se=R(),$e=G.S;if($e!==null&&$e(oe,Se),Se!==null&&typeof Se=="object"&&typeof Se.then=="function"){var at=ote(Se,S);gg(d,p,at,na(d))}else gg(d,p,S,na(d))}catch(ut){gg(d,p,{then:function(){},status:"rejected",reason:ut},na())}finally{V.p=O,q!==null&&oe.types!==null&&(q.types=oe.types),G.T=q}}function hte(){}function RE(d,p,_,S){if(d.tag!==5)throw Error(r(476));var R=ej(d).queue;JI(d,R,p,Z,_===null?hte:function(){return tj(d),_(S)})}function ej(d){var p=d.memoizedState;if(p!==null)return p;p={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:Z},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:_},next:null},d.memoizedState=p,d=d.alternate,d!==null&&(d.memoizedState=p),p}function tj(d){var p=ej(d);p.next===null&&(p=d.alternate.memoizedState),gg(d,p.next.queue,{},na())}function PE(){return Ii(Dg)}function nj(){return Pr().memoizedState}function rj(){return Pr().memoizedState}function pte(d){for(var p=d.return;p!==null;){switch(p.tag){case 24:case 3:var _=na();d=Bc(_);var S=Hc(p,d,_);S!==null&&(Ds(S,p,_),dg(S,p,_)),p={cache:aE()},d.payload=p;return}p=p.return}}function mte(d,p,_){var S=na();_={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},ib(d)?sj(p,_):(_=KM(d,p,_,S),_!==null&&(Ds(_,d,S),aj(_,p,S)))}function ij(d,p,_){var S=na();gg(d,p,_,S)}function gg(d,p,_,S){var R={lane:S,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(ib(d))sj(p,R);else{var O=d.alternate;if(d.lanes===0&&(O===null||O.lanes===0)&&(O=p.lastRenderedReducer,O!==null))try{var q=p.lastRenderedState,oe=O(q,_);if(R.hasEagerState=!0,R.eagerState=oe,Ys(oe,q))return Uv(d,p,R,0),Xn===null&&jv(),!1}catch{}finally{}if(_=KM(d,p,R,S),_!==null)return Ds(_,d,S),aj(_,p,S),!0}return!1}function kE(d,p,_,S){if(S={lane:2,revertLane:uA(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},ib(d)){if(p)throw Error(r(479))}else p=KM(d,_,S,2),p!==null&&Ds(p,d,2)}function ib(d){var p=d.alternate;return d===Jt||p!==null&&p===Jt}function sj(d,p){gh=Zv=!0;var _=d.pending;_===null?p.next=p:(p.next=_.next,_.next=p),d.pending=p}function aj(d,p,_){if((_&4194048)!==0){var S=p.lanes;S&=d.pendingLanes,_|=S,p.lanes=_,qn(d,_)}}var xg={readContext:Ii,use:eb,useCallback:_r,useContext:_r,useEffect:_r,useImperativeHandle:_r,useLayoutEffect:_r,useInsertionEffect:_r,useMemo:_r,useReducer:_r,useRef:_r,useState:_r,useDebugValue:_r,useDeferredValue:_r,useTransition:_r,useSyncExternalStore:_r,useId:_r,useHostTransitionStatus:_r,useFormState:_r,useActionState:_r,useOptimistic:_r,useMemoCache:_r,useCacheRefresh:_r};xg.useEffectEvent=_r;var oj={readContext:Ii,use:eb,useCallback:function(d,p){return hs().memoizedState=[d,p===void 0?null:p],d},useContext:Ii,useEffect:VI,useImperativeHandle:function(d,p,_){_=_!=null?_.concat([d]):null,nb(4194308,4,XI.bind(null,p,d),_)},useLayoutEffect:function(d,p){return nb(4194308,4,d,p)},useInsertionEffect:function(d,p){nb(4,2,d,p)},useMemo:function(d,p){var _=hs();p=p===void 0?null:p;var S=d();if(Td){Qe(!0);try{d()}finally{Qe(!1)}}return _.memoizedState=[S,p],S},useReducer:function(d,p,_){var S=hs();if(_!==void 0){var R=_(p);if(Td){Qe(!0);try{_(p)}finally{Qe(!1)}}}else R=p;return S.memoizedState=S.baseState=R,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:d,lastRenderedState:R},S.queue=d,d=d.dispatch=mte.bind(null,Jt,d),[S.memoizedState,d]},useRef:function(d){var p=hs();return d={current:d},p.memoizedState=d},useState:function(d){d=EE(d);var p=d.queue,_=ij.bind(null,Jt,p);return p.dispatch=_,[d.memoizedState,_]},useDebugValue:CE,useDeferredValue:function(d,p){var _=hs();return NE(_,d,p)},useTransition:function(){var d=EE(!1);return d=JI.bind(null,Jt,d.queue,!0,!1),hs().memoizedState=d,[!1,d]},useSyncExternalStore:function(d,p,_){var S=Jt,R=hs();if(yn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Xn===null)throw Error(r(349));(xn&127)!==0||CI(S,p,_)}R.memoizedState=_;var O={value:_,getSnapshot:p};return R.queue=O,VI(RI.bind(null,S,O,d),[d]),S.flags|=2048,vh(9,{destroy:void 0},NI.bind(null,S,O,_,p),null),_},useId:function(){var d=hs(),p=Xn.identifierPrefix;if(yn){var _=Oo,S=Do;_=(S&~(1<<32-Be(S)-1)).toString(32)+_,p="_"+p+"R_"+_,_=Qv++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=lte++,p="_"+p+"r_"+_.toString(32)+"_";return d.memoizedState=p},useHostTransitionStatus:PE,useFormState:FI,useActionState:FI,useOptimistic:function(d){var p=hs();p.memoizedState=p.baseState=d;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=kE.bind(null,Jt,!0,_),_.dispatch=p,[d,p]},useMemoCache:SE,useCacheRefresh:function(){return hs().memoizedState=pte.bind(null,Jt)},useEffectEvent:function(d){var p=hs(),_={impl:d};return p.memoizedState=_,function(){if((Cn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},DE={readContext:Ii,use:eb,useCallback:YI,useContext:Ii,useEffect:TE,useImperativeHandle:KI,useInsertionEffect:WI,useLayoutEffect:qI,useMemo:ZI,useReducer:tb,useRef:$I,useState:function(){return tb(_l)},useDebugValue:CE,useDeferredValue:function(d,p){var _=Pr();return QI(_,jn.memoizedState,d,p)},useTransition:function(){var d=tb(_l)[0],p=Pr().memoizedState;return[typeof d=="boolean"?d:mg(d),p]},useSyncExternalStore:TI,useId:nj,useHostTransitionStatus:PE,useFormState:zI,useActionState:zI,useOptimistic:function(d,p){var _=Pr();return DI(_,jn,d,p)},useMemoCache:SE,useCacheRefresh:rj};DE.useEffectEvent=GI;var lj={readContext:Ii,use:eb,useCallback:YI,useContext:Ii,useEffect:TE,useImperativeHandle:KI,useInsertionEffect:WI,useLayoutEffect:qI,useMemo:ZI,useReducer:ME,useRef:$I,useState:function(){return ME(_l)},useDebugValue:CE,useDeferredValue:function(d,p){var _=Pr();return jn===null?NE(_,d,p):QI(_,jn.memoizedState,d,p)},useTransition:function(){var d=ME(_l)[0],p=Pr().memoizedState;return[typeof d=="boolean"?d:mg(d),p]},useSyncExternalStore:TI,useId:nj,useHostTransitionStatus:PE,useFormState:HI,useActionState:HI,useOptimistic:function(d,p){var _=Pr();return jn!==null?DI(_,jn,d,p):(_.baseState=d,[d,_.queue.dispatch])},useMemoCache:SE,useCacheRefresh:rj};lj.useEffectEvent=GI;function OE(d,p,_,S){p=d.memoizedState,_=_(S,p),_=_==null?p:h({},p,_),d.memoizedState=_,d.lanes===0&&(d.updateQueue.baseState=_)}var LE={enqueueSetState:function(d,p,_){d=d._reactInternals;var S=na(),R=Bc(S);R.payload=p,_!=null&&(R.callback=_),p=Hc(d,R,S),p!==null&&(Ds(p,d,S),dg(p,d,S))},enqueueReplaceState:function(d,p,_){d=d._reactInternals;var S=na(),R=Bc(S);R.tag=1,R.payload=p,_!=null&&(R.callback=_),p=Hc(d,R,S),p!==null&&(Ds(p,d,S),dg(p,d,S))},enqueueForceUpdate:function(d,p){d=d._reactInternals;var _=na(),S=Bc(_);S.tag=2,p!=null&&(S.callback=p),p=Hc(d,S,_),p!==null&&(Ds(p,d,_),dg(p,d,_))}};function cj(d,p,_,S,R,O,q){return d=d.stateNode,typeof d.shouldComponentUpdate=="function"?d.shouldComponentUpdate(S,O,q):p.prototype&&p.prototype.isPureReactComponent?!rg(_,S)||!rg(R,O):!0}function uj(d,p,_,S){d=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,S),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,S),p.state!==d&&LE.enqueueReplaceState(p,p.state,null)}function Cd(d,p){var _=p;if("ref"in p){_={};for(var S in p)S!=="ref"&&(_[S]=p[S])}if(d=d.defaultProps){_===p&&(_=h({},_));for(var R in d)_[R]===void 0&&(_[R]=d[R])}return _}function dj(d){Iv(d)}function fj(d){console.error(d)}function hj(d){Iv(d)}function sb(d,p){try{var _=d.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(S){setTimeout(function(){throw S})}}function pj(d,p,_){try{var S=d.onCaughtError;S(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(R){setTimeout(function(){throw R})}}function IE(d,p,_){return _=Bc(_),_.tag=3,_.payload={element:null},_.callback=function(){sb(d,p)},_}function mj(d){return d=Bc(d),d.tag=3,d}function gj(d,p,_,S){var R=_.type.getDerivedStateFromError;if(typeof R=="function"){var O=S.value;d.payload=function(){return R(O)},d.callback=function(){pj(p,_,S)}}var q=_.stateNode;q!==null&&typeof q.componentDidCatch=="function"&&(d.callback=function(){pj(p,_,S),typeof R!="function"&&(Xc===null?Xc=new Set([this]):Xc.add(this));var oe=S.stack;this.componentDidCatch(S.value,{componentStack:oe!==null?oe:""})})}function gte(d,p,_,S,R){if(_.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(p=_.alternate,p!==null&&uh(p,_,R,!0),_=Qs.current,_!==null){switch(_.tag){case 31:case 13:return wa===null?xb():_.alternate===null&&Sr===0&&(Sr=3),_.flags&=-257,_.flags|=65536,_.lanes=R,S===Wv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([S]):p.add(S),oA(d,S,R)),!1;case 22:return _.flags|=65536,S===Wv?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([S])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([S]):_.add(S)),oA(d,S,R)),!1}throw Error(r(435,_.tag))}return oA(d,S,R),xb(),!1}if(yn)return p=Qs.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=R,S!==tE&&(d=Error(r(422),{cause:S}),ag(ba(d,_)))):(S!==tE&&(p=Error(r(423),{cause:S}),ag(ba(p,_))),d=d.current.alternate,d.flags|=65536,R&=-R,d.lanes|=R,S=ba(S,_),R=IE(d.stateNode,S,R),fE(d,R),Sr!==4&&(Sr=2)),!1;var O=Error(r(520),{cause:S});if(O=ba(O,_),Eg===null?Eg=[O]:Eg.push(O),Sr!==4&&(Sr=2),p===null)return!0;S=ba(S,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,d=R&-R,_.lanes|=d,d=IE(_.stateNode,S,d),fE(_,d),!1;case 1:if(p=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Xc===null||!Xc.has(O))))return _.flags|=65536,R&=-R,_.lanes|=R,R=mj(R),gj(R,d,_,S),fE(_,R),!1}_=_.return}while(_!==null);return!1}var jE=Error(r(461)),zr=!1;function ji(d,p,_,S){p.child=d===null?yI(p,null,_,S):Ad(p,d.child,_,S)}function xj(d,p,_,S,R){_=_.render;var O=p.ref;if("ref"in S){var q={};for(var oe in S)oe!=="ref"&&(q[oe]=S[oe])}else q=S;return Sd(p),S=vE(d,p,_,q,O,R),oe=bE(),d!==null&&!zr?(yE(d,p,R),Sl(d,p,R)):(yn&&oe&&JM(p),p.flags|=1,ji(d,p,S,R),p.child)}function vj(d,p,_,S,R){if(d===null){var O=_.type;return typeof O=="function"&&!YM(O)&&O.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=O,bj(d,p,O,S,R)):(d=zv(_.type,null,S,p,p.mode,R),d.ref=p.ref,d.return=p,p.child=d)}if(O=d.child,!GE(d,R)){var q=O.memoizedProps;if(_=_.compare,_=_!==null?_:rg,_(q,S)&&d.ref===p.ref)return Sl(d,p,R)}return p.flags|=1,d=gl(O,S),d.ref=p.ref,d.return=p,p.child=d}function bj(d,p,_,S,R){if(d!==null){var O=d.memoizedProps;if(rg(O,S)&&d.ref===p.ref)if(zr=!1,p.pendingProps=S=O,GE(d,R))(d.flags&131072)!==0&&(zr=!0);else return p.lanes=d.lanes,Sl(d,p,R)}return UE(d,p,_,S,R)}function yj(d,p,_,S){var R=S.children,O=d!==null?d.memoizedState:null;if(d===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((p.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,d!==null){for(S=p.child=d.child,R=0;S!==null;)R=R|S.lanes|S.childLanes,S=S.sibling;S=R&~O}else S=0,p.child=null;return _j(d,p,O,_,S)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},d!==null&&Vv(p,O!==null?O.cachePool:null),O!==null?wI(p,O):pE(),MI(p);else return S=p.lanes=536870912,_j(d,p,O!==null?O.baseLanes|_:_,_,S)}else O!==null?(Vv(p,O.cachePool),wI(p,O),Vc(),p.memoizedState=null):(d!==null&&Vv(p,null),pE(),Vc());return ji(d,p,R,_),p.child}function vg(d,p){return d!==null&&d.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function _j(d,p,_,S,R){var O=lE();return O=O===null?null:{parent:Ur._currentValue,pool:O},p.memoizedState={baseLanes:_,cachePool:O},d!==null&&Vv(p,null),pE(),MI(p),d!==null&&uh(d,p,S,!0),p.childLanes=R,null}function ab(d,p){return p=lb({mode:p.mode,children:p.children},d.mode),p.ref=d.ref,d.child=p,p.return=d,p}function Sj(d,p,_){return Ad(p,d.child,null,_),d=ab(p,p.pendingProps),d.flags|=2,Js(p),p.memoizedState=null,d}function xte(d,p,_){var S=p.pendingProps,R=(p.flags&128)!==0;if(p.flags&=-129,d===null){if(yn){if(S.mode==="hidden")return d=ab(p,S),p.lanes=536870912,vg(null,d);if(gE(p),(d=tr)?(d=O4(d,Sa),d=d!==null&&d.data==="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:Ic!==null?{id:Do,overflow:Oo}:null,retryLane:536870912,hydrationErrors:null},_=sI(d),_.return=p,p.child=_,Li=p,tr=null)):d=null,d===null)throw Uc(p);return p.lanes=536870912,null}return ab(p,S)}var O=d.memoizedState;if(O!==null){var q=O.dehydrated;if(gE(p),R)if(p.flags&256)p.flags&=-257,p=Sj(d,p,_);else if(p.memoizedState!==null)p.child=d.child,p.flags|=128,p=null;else throw Error(r(558));else if(zr||uh(d,p,_,!1),R=(_&d.childLanes)!==0,zr||R){if(S=Xn,S!==null&&(q=gi(S,_),q!==0&&q!==O.retryLane))throw O.retryLane=q,vd(d,q),Ds(S,d,q),jE;xb(),p=Sj(d,p,_)}else d=O.treeContext,tr=Ma(q.nextSibling),Li=p,yn=!0,jc=null,Sa=!1,d!==null&&lI(p,d),p=ab(p,S),p.flags|=4096;return p}return d=gl(d.child,{mode:S.mode,children:S.children}),d.ref=p.ref,p.child=d,d.return=p,d}function ob(d,p){var _=p.ref;if(_===null)d!==null&&d.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(d===null||d.ref!==_)&&(p.flags|=4194816)}}function UE(d,p,_,S,R){return Sd(p),_=vE(d,p,_,S,void 0,R),S=bE(),d!==null&&!zr?(yE(d,p,R),Sl(d,p,R)):(yn&&S&&JM(p),p.flags|=1,ji(d,p,_,R),p.child)}function wj(d,p,_,S,R,O){return Sd(p),p.updateQueue=null,_=AI(p,S,_,R),EI(d),S=bE(),d!==null&&!zr?(yE(d,p,O),Sl(d,p,O)):(yn&&S&&JM(p),p.flags|=1,ji(d,p,_,O),p.child)}function Mj(d,p,_,S,R){if(Sd(p),p.stateNode===null){var O=ah,q=_.contextType;typeof q=="object"&&q!==null&&(O=Ii(q)),O=new _(S,O),p.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=LE,p.stateNode=O,O._reactInternals=p,O=p.stateNode,O.props=S,O.state=p.memoizedState,O.refs={},uE(p),q=_.contextType,O.context=typeof q=="object"&&q!==null?Ii(q):ah,O.state=p.memoizedState,q=_.getDerivedStateFromProps,typeof q=="function"&&(OE(p,_,q,S),O.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(q=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),q!==O.state&&LE.enqueueReplaceState(O,O.state,null),hg(p,S,O,R),fg(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!0}else if(d===null){O=p.stateNode;var oe=p.memoizedProps,Se=Cd(_,oe);O.props=Se;var $e=O.context,at=_.contextType;q=ah,typeof at=="object"&&at!==null&&(q=Ii(at));var ut=_.getDerivedStateFromProps;at=typeof ut=="function"||typeof O.getSnapshotBeforeUpdate=="function",oe=p.pendingProps!==oe,at||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(oe||$e!==q)&&uj(p,O,S,q),zc=!1;var qe=p.memoizedState;O.state=qe,hg(p,S,O,R),fg(),$e=p.memoizedState,oe||qe!==$e||zc?(typeof ut=="function"&&(OE(p,_,ut,S),$e=p.memoizedState),(Se=zc||cj(p,_,Se,S,qe,$e,q))?(at||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(p.flags|=4194308)):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=S,p.memoizedState=$e),O.props=S,O.state=$e,O.context=q,S=Se):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!1)}else{O=p.stateNode,dE(d,p),q=p.memoizedProps,at=Cd(_,q),O.props=at,ut=p.pendingProps,qe=O.context,$e=_.contextType,Se=ah,typeof $e=="object"&&$e!==null&&(Se=Ii($e)),oe=_.getDerivedStateFromProps,($e=typeof oe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(q!==ut||qe!==Se)&&uj(p,O,S,Se),zc=!1,qe=p.memoizedState,O.state=qe,hg(p,S,O,R),fg();var rt=p.memoizedState;q!==ut||qe!==rt||zc||d!==null&&d.dependencies!==null&&Hv(d.dependencies)?(typeof oe=="function"&&(OE(p,_,oe,S),rt=p.memoizedState),(at=zc||cj(p,_,at,S,qe,rt,Se)||d!==null&&d.dependencies!==null&&Hv(d.dependencies))?($e||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(S,rt,Se),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(S,rt,Se)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||q===d.memoizedProps&&qe===d.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||q===d.memoizedProps&&qe===d.memoizedState||(p.flags|=1024),p.memoizedProps=S,p.memoizedState=rt),O.props=S,O.state=rt,O.context=Se,S=at):(typeof O.componentDidUpdate!="function"||q===d.memoizedProps&&qe===d.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||q===d.memoizedProps&&qe===d.memoizedState||(p.flags|=1024),S=!1)}return O=S,ob(d,p),S=(p.flags&128)!==0,O||S?(O=p.stateNode,_=S&&typeof _.getDerivedStateFromError!="function"?null:O.render(),p.flags|=1,d!==null&&S?(p.child=Ad(p,d.child,null,R),p.child=Ad(p,null,_,R)):ji(d,p,_,R),p.memoizedState=O.state,d=p.child):d=Sl(d,p,R),d}function Ej(d,p,_,S){return yd(),p.flags|=256,ji(d,p,_,S),p.child}var FE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function zE(d){return{baseLanes:d,cachePool:pI()}}function BE(d,p,_){return d=d!==null?d.childLanes&~_:0,p&&(d|=ta),d}function Aj(d,p,_){var S=p.pendingProps,R=!1,O=(p.flags&128)!==0,q;if((q=O)||(q=d!==null&&d.memoizedState===null?!1:(Rr.current&2)!==0),q&&(R=!0,p.flags&=-129),q=(p.flags&32)!==0,p.flags&=-33,d===null){if(yn){if(R?$c(p):Vc(),(d=tr)?(d=O4(d,Sa),d=d!==null&&d.data!=="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:Ic!==null?{id:Do,overflow:Oo}:null,retryLane:536870912,hydrationErrors:null},_=sI(d),_.return=p,p.child=_,Li=p,tr=null)):d=null,d===null)throw Uc(p);return wA(d)?p.lanes=32:p.lanes=536870912,null}var oe=S.children;return S=S.fallback,R?(Vc(),R=p.mode,oe=lb({mode:"hidden",children:oe},R),S=bd(S,R,_,null),oe.return=p,S.return=p,oe.sibling=S,p.child=oe,S=p.child,S.memoizedState=zE(_),S.childLanes=BE(d,q,_),p.memoizedState=FE,vg(null,S)):($c(p),HE(p,oe))}var Se=d.memoizedState;if(Se!==null&&(oe=Se.dehydrated,oe!==null)){if(O)p.flags&256?($c(p),p.flags&=-257,p=$E(d,p,_)):p.memoizedState!==null?(Vc(),p.child=d.child,p.flags|=128,p=null):(Vc(),oe=S.fallback,R=p.mode,S=lb({mode:"visible",children:S.children},R),oe=bd(oe,R,_,null),oe.flags|=2,S.return=p,oe.return=p,S.sibling=oe,p.child=S,Ad(p,d.child,null,_),S=p.child,S.memoizedState=zE(_),S.childLanes=BE(d,q,_),p.memoizedState=FE,p=vg(null,S));else if($c(p),wA(oe)){if(q=oe.nextSibling&&oe.nextSibling.dataset,q)var $e=q.dgst;q=$e,S=Error(r(419)),S.stack="",S.digest=q,ag({value:S,source:null,stack:null}),p=$E(d,p,_)}else if(zr||uh(d,p,_,!1),q=(_&d.childLanes)!==0,zr||q){if(q=Xn,q!==null&&(S=gi(q,_),S!==0&&S!==Se.retryLane))throw Se.retryLane=S,vd(d,S),Ds(q,d,S),jE;SA(oe)||xb(),p=$E(d,p,_)}else SA(oe)?(p.flags|=192,p.child=d.child,p=null):(d=Se.treeContext,tr=Ma(oe.nextSibling),Li=p,yn=!0,jc=null,Sa=!1,d!==null&&lI(p,d),p=HE(p,S.children),p.flags|=4096);return p}return R?(Vc(),oe=S.fallback,R=p.mode,Se=d.child,$e=Se.sibling,S=gl(Se,{mode:"hidden",children:S.children}),S.subtreeFlags=Se.subtreeFlags&65011712,$e!==null?oe=gl($e,oe):(oe=bd(oe,R,_,null),oe.flags|=2),oe.return=p,S.return=p,S.sibling=oe,p.child=S,vg(null,S),S=p.child,oe=d.child.memoizedState,oe===null?oe=zE(_):(R=oe.cachePool,R!==null?(Se=Ur._currentValue,R=R.parent!==Se?{parent:Se,pool:Se}:R):R=pI(),oe={baseLanes:oe.baseLanes|_,cachePool:R}),S.memoizedState=oe,S.childLanes=BE(d,q,_),p.memoizedState=FE,vg(d.child,S)):($c(p),_=d.child,d=_.sibling,_=gl(_,{mode:"visible",children:S.children}),_.return=p,_.sibling=null,d!==null&&(q=p.deletions,q===null?(p.deletions=[d],p.flags|=16):q.push(d)),p.child=_,p.memoizedState=null,_)}function HE(d,p){return p=lb({mode:"visible",children:p},d.mode),p.return=d,d.child=p}function lb(d,p){return d=Zs(22,d,null,p),d.lanes=0,d}function $E(d,p,_){return Ad(p,d.child,null,_),d=HE(p,p.pendingProps.children),d.flags|=2,p.memoizedState=null,d}function Tj(d,p,_){d.lanes|=p;var S=d.alternate;S!==null&&(S.lanes|=p),iE(d.return,p,_)}function VE(d,p,_,S,R,O){var q=d.memoizedState;q===null?d.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:S,tail:_,tailMode:R,treeForkCount:O}:(q.isBackwards=p,q.rendering=null,q.renderingStartTime=0,q.last=S,q.tail=_,q.tailMode=R,q.treeForkCount=O)}function Cj(d,p,_){var S=p.pendingProps,R=S.revealOrder,O=S.tail;S=S.children;var q=Rr.current,oe=(q&2)!==0;if(oe?(q=q&1|2,p.flags|=128):q&=1,te(Rr,q),ji(d,p,S,_),S=yn?sg:0,!oe&&d!==null&&(d.flags&128)!==0)e:for(d=p.child;d!==null;){if(d.tag===13)d.memoizedState!==null&&Tj(d,_,p);else if(d.tag===19)Tj(d,_,p);else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===p)break e;for(;d.sibling===null;){if(d.return===null||d.return===p)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}switch(R){case"forwards":for(_=p.child,R=null;_!==null;)d=_.alternate,d!==null&&Yv(d)===null&&(R=_),_=_.sibling;_=R,_===null?(R=p.child,p.child=null):(R=_.sibling,_.sibling=null),VE(p,!1,R,_,O,S);break;case"backwards":case"unstable_legacy-backwards":for(_=null,R=p.child,p.child=null;R!==null;){if(d=R.alternate,d!==null&&Yv(d)===null){p.child=R;break}d=R.sibling,R.sibling=_,_=R,R=d}VE(p,!0,_,null,O,S);break;case"together":VE(p,!1,null,null,void 0,S);break;default:p.memoizedState=null}return p.child}function Sl(d,p,_){if(d!==null&&(p.dependencies=d.dependencies),qc|=p.lanes,(_&p.childLanes)===0)if(d!==null){if(uh(d,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(d!==null&&p.child!==d.child)throw Error(r(153));if(p.child!==null){for(d=p.child,_=gl(d,d.pendingProps),p.child=_,_.return=p;d.sibling!==null;)d=d.sibling,_=_.sibling=gl(d,d.pendingProps),_.return=p;_.sibling=null}return p.child}function GE(d,p){return(d.lanes&p)!==0?!0:(d=d.dependencies,!!(d!==null&&Hv(d)))}function vte(d,p,_){switch(p.tag){case 3:Ee(p,p.stateNode.containerInfo),Fc(p,Ur,d.memoizedState.cache),yd();break;case 27:case 5:we(p);break;case 4:Ee(p,p.stateNode.containerInfo);break;case 10:Fc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,gE(p),null;break;case 13:var S=p.memoizedState;if(S!==null)return S.dehydrated!==null?($c(p),p.flags|=128,null):(_&p.child.childLanes)!==0?Aj(d,p,_):($c(p),d=Sl(d,p,_),d!==null?d.sibling:null);$c(p);break;case 19:var R=(d.flags&128)!==0;if(S=(_&p.childLanes)!==0,S||(uh(d,p,_,!1),S=(_&p.childLanes)!==0),R){if(S)return Cj(d,p,_);p.flags|=128}if(R=p.memoizedState,R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),te(Rr,Rr.current),S)break;return null;case 22:return p.lanes=0,yj(d,p,_,p.pendingProps);case 24:Fc(p,Ur,d.memoizedState.cache)}return Sl(d,p,_)}function Nj(d,p,_){if(d!==null)if(d.memoizedProps!==p.pendingProps)zr=!0;else{if(!GE(d,_)&&(p.flags&128)===0)return zr=!1,vte(d,p,_);zr=(d.flags&131072)!==0}else zr=!1,yn&&(p.flags&1048576)!==0&&oI(p,sg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var S=p.pendingProps;if(d=Md(p.elementType),p.type=d,typeof d=="function")YM(d)?(S=Cd(d,S),p.tag=1,p=Mj(null,p,d,S,_)):(p.tag=0,p=UE(null,p,d,S,_));else{if(d!=null){var R=d.$$typeof;if(R===T){p.tag=11,p=xj(null,p,d,S,_);break e}else if(R===C){p.tag=14,p=vj(null,p,d,S,_);break e}}throw p=D(d)||d,Error(r(306,p,""))}}return p;case 0:return UE(d,p,p.type,p.pendingProps,_);case 1:return S=p.type,R=Cd(S,p.pendingProps),Mj(d,p,S,R,_);case 3:e:{if(Ee(p,p.stateNode.containerInfo),d===null)throw Error(r(387));S=p.pendingProps;var O=p.memoizedState;R=O.element,dE(d,p),hg(p,S,null,_);var q=p.memoizedState;if(S=q.cache,Fc(p,Ur,S),S!==O.cache&&sE(p,[Ur],_,!0),fg(),S=q.element,O.isDehydrated)if(O={element:S,isDehydrated:!1,cache:q.cache},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){p=Ej(d,p,S,_);break e}else if(S!==R){R=ba(Error(r(424)),p),ag(R),p=Ej(d,p,S,_);break e}else{switch(d=p.stateNode.containerInfo,d.nodeType){case 9:d=d.body;break;default:d=d.nodeName==="HTML"?d.ownerDocument.body:d}for(tr=Ma(d.firstChild),Li=p,yn=!0,jc=null,Sa=!0,_=yI(p,null,S,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(yd(),S===R){p=Sl(d,p,_);break e}ji(d,p,S,_)}p=p.child}return p;case 26:return ob(d,p),d===null?(_=z4(p.type,null,p.pendingProps,null))?p.memoizedState=_:yn||(_=p.type,d=p.pendingProps,S=Mb(Q.current).createElement(_),S[pr]=p,S[Cr]=d,Ui(S,_,d),Pe(S),p.stateNode=S):p.memoizedState=z4(p.type,d.memoizedProps,p.pendingProps,d.memoizedState),null;case 27:return we(p),d===null&&yn&&(S=p.stateNode=j4(p.type,p.pendingProps,Q.current),Li=p,Sa=!0,R=tr,Qc(p.type)?(MA=R,tr=Ma(S.firstChild)):tr=R),ji(d,p,p.pendingProps.children,_),ob(d,p),d===null&&(p.flags|=4194304),p.child;case 5:return d===null&&yn&&((R=S=tr)&&(S=Xte(S,p.type,p.pendingProps,Sa),S!==null?(p.stateNode=S,Li=p,tr=Ma(S.firstChild),Sa=!1,R=!0):R=!1),R||Uc(p)),we(p),R=p.type,O=p.pendingProps,q=d!==null?d.memoizedProps:null,S=O.children,bA(R,O)?S=null:q!==null&&bA(R,q)&&(p.flags|=32),p.memoizedState!==null&&(R=vE(d,p,cte,null,null,_),Dg._currentValue=R),ob(d,p),ji(d,p,S,_),p.child;case 6:return d===null&&yn&&((d=_=tr)&&(_=Kte(_,p.pendingProps,Sa),_!==null?(p.stateNode=_,Li=p,tr=null,d=!0):d=!1),d||Uc(p)),null;case 13:return Aj(d,p,_);case 4:return Ee(p,p.stateNode.containerInfo),S=p.pendingProps,d===null?p.child=Ad(p,null,S,_):ji(d,p,S,_),p.child;case 11:return xj(d,p,p.type,p.pendingProps,_);case 7:return ji(d,p,p.pendingProps,_),p.child;case 8:return ji(d,p,p.pendingProps.children,_),p.child;case 12:return ji(d,p,p.pendingProps.children,_),p.child;case 10:return S=p.pendingProps,Fc(p,p.type,S.value),ji(d,p,S.children,_),p.child;case 9:return R=p.type._context,S=p.pendingProps.children,Sd(p),R=Ii(R),S=S(R),p.flags|=1,ji(d,p,S,_),p.child;case 14:return vj(d,p,p.type,p.pendingProps,_);case 15:return bj(d,p,p.type,p.pendingProps,_);case 19:return Cj(d,p,_);case 31:return xte(d,p,_);case 22:return yj(d,p,_,p.pendingProps);case 24:return Sd(p),S=Ii(Ur),d===null?(R=lE(),R===null&&(R=Xn,O=aE(),R.pooledCache=O,O.refCount++,O!==null&&(R.pooledCacheLanes|=_),R=O),p.memoizedState={parent:S,cache:R},uE(p),Fc(p,Ur,R)):((d.lanes&_)!==0&&(dE(d,p),hg(p,null,null,_),fg()),R=d.memoizedState,O=p.memoizedState,R.parent!==S?(R={parent:S,cache:S},p.memoizedState=R,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=R),Fc(p,Ur,S)):(S=O.cache,Fc(p,Ur,S),S!==R.cache&&sE(p,[Ur],_,!0))),ji(d,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function wl(d){d.flags|=4}function WE(d,p,_,S,R){if((p=(d.mode&32)!==0)&&(p=!1),p){if(d.flags|=16777216,(R&335544128)===R)if(d.stateNode.complete)d.flags|=8192;else if(n4())d.flags|=8192;else throw Ed=Wv,cE}else d.flags&=-16777217}function Rj(d,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)d.flags&=-16777217;else if(d.flags|=16777216,!G4(p))if(n4())d.flags|=8192;else throw Ed=Wv,cE}function cb(d,p){p!==null&&(d.flags|=4),d.flags&16384&&(p=d.tag!==22?yt():536870912,d.lanes|=p,Sh|=p)}function bg(d,p){if(!yn)switch(d.tailMode){case"hidden":p=d.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?d.tail=null:_.sibling=null;break;case"collapsed":_=d.tail;for(var S=null;_!==null;)_.alternate!==null&&(S=_),_=_.sibling;S===null?p||d.tail===null?d.tail=null:d.tail.sibling=null:S.sibling=null}}function nr(d){var p=d.alternate!==null&&d.alternate.child===d.child,_=0,S=0;if(p)for(var R=d.child;R!==null;)_|=R.lanes|R.childLanes,S|=R.subtreeFlags&65011712,S|=R.flags&65011712,R.return=d,R=R.sibling;else for(R=d.child;R!==null;)_|=R.lanes|R.childLanes,S|=R.subtreeFlags,S|=R.flags,R.return=d,R=R.sibling;return d.subtreeFlags|=S,d.childLanes=_,p}function bte(d,p,_){var S=p.pendingProps;switch(eE(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nr(p),null;case 1:return nr(p),null;case 3:return _=p.stateNode,S=null,d!==null&&(S=d.memoizedState.cache),p.memoizedState.cache!==S&&(p.flags|=2048),bl(Ur),he(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(d===null||d.child===null)&&(ch(p)?wl(p):d===null||d.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,nE())),nr(p),null;case 26:var R=p.type,O=p.memoizedState;return d===null?(wl(p),O!==null?(nr(p),Rj(p,O)):(nr(p),WE(p,R,null,S,_))):O?O!==d.memoizedState?(wl(p),nr(p),Rj(p,O)):(nr(p),p.flags&=-16777217):(d=d.memoizedProps,d!==S&&wl(p),nr(p),WE(p,R,d,S,_)),null;case 27:if(De(p),_=Q.current,R=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&wl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return nr(p),null}d=ae.current,ch(p)?cI(p):(d=j4(R,S,_),p.stateNode=d,wl(p))}return nr(p),null;case 5:if(De(p),R=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&wl(p);else{if(!S){if(p.stateNode===null)throw Error(r(166));return nr(p),null}if(O=ae.current,ch(p))cI(p);else{var q=Mb(Q.current);switch(O){case 1:O=q.createElementNS("http://www.w3.org/2000/svg",R);break;case 2:O=q.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;default:switch(R){case"svg":O=q.createElementNS("http://www.w3.org/2000/svg",R);break;case"math":O=q.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;case"script":O=q.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof S.is=="string"?q.createElement("select",{is:S.is}):q.createElement("select"),S.multiple?O.multiple=!0:S.size&&(O.size=S.size);break;default:O=typeof S.is=="string"?q.createElement(R,{is:S.is}):q.createElement(R)}}O[pr]=p,O[Cr]=S;e:for(q=p.child;q!==null;){if(q.tag===5||q.tag===6)O.appendChild(q.stateNode);else if(q.tag!==4&&q.tag!==27&&q.child!==null){q.child.return=q,q=q.child;continue}if(q===p)break e;for(;q.sibling===null;){if(q.return===null||q.return===p)break e;q=q.return}q.sibling.return=q.return,q=q.sibling}p.stateNode=O;e:switch(Ui(O,R,S),R){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&wl(p)}}return nr(p),WE(p,p.type,d===null?null:d.memoizedProps,p.pendingProps,_),null;case 6:if(d&&p.stateNode!=null)d.memoizedProps!==S&&wl(p);else{if(typeof S!="string"&&p.stateNode===null)throw Error(r(166));if(d=Q.current,ch(p)){if(d=p.stateNode,_=p.memoizedProps,S=null,R=Li,R!==null)switch(R.tag){case 27:case 5:S=R.memoizedProps}d[pr]=p,d=!!(d.nodeValue===_||S!==null&&S.suppressHydrationWarning===!0||A4(d.nodeValue,_)),d||Uc(p,!0)}else d=Mb(d).createTextNode(S),d[pr]=p,p.stateNode=d}return nr(p),null;case 31:if(_=p.memoizedState,d===null||d.memoizedState!==null){if(S=ch(p),_!==null){if(d===null){if(!S)throw Error(r(318));if(d=p.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(557));d[pr]=p}else yd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;nr(p),d=!1}else _=nE(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=_),d=!0;if(!d)return p.flags&256?(Js(p),p):(Js(p),null);if((p.flags&128)!==0)throw Error(r(558))}return nr(p),null;case 13:if(S=p.memoizedState,d===null||d.memoizedState!==null&&d.memoizedState.dehydrated!==null){if(R=ch(p),S!==null&&S.dehydrated!==null){if(d===null){if(!R)throw Error(r(318));if(R=p.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(r(317));R[pr]=p}else yd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;nr(p),R=!1}else R=nE(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=R),R=!0;if(!R)return p.flags&256?(Js(p),p):(Js(p),null)}return Js(p),(p.flags&128)!==0?(p.lanes=_,p):(_=S!==null,d=d!==null&&d.memoizedState!==null,_&&(S=p.child,R=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(R=S.alternate.memoizedState.cachePool.pool),O=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(O=S.memoizedState.cachePool.pool),O!==R&&(S.flags|=2048)),_!==d&&_&&(p.child.flags|=8192),cb(p,p.updateQueue),nr(p),null);case 4:return he(),d===null&&pA(p.stateNode.containerInfo),nr(p),null;case 10:return bl(p.type),nr(p),null;case 19:if(Y(Rr),S=p.memoizedState,S===null)return nr(p),null;if(R=(p.flags&128)!==0,O=S.rendering,O===null)if(R)bg(S,!1);else{if(Sr!==0||d!==null&&(d.flags&128)!==0)for(d=p.child;d!==null;){if(O=Yv(d),O!==null){for(p.flags|=128,bg(S,!1),d=O.updateQueue,p.updateQueue=d,cb(p,d),p.subtreeFlags=0,d=_,_=p.child;_!==null;)iI(_,d),_=_.sibling;return te(Rr,Rr.current&1|2),yn&&xl(p,S.treeForkCount),p.child}d=d.sibling}S.tail!==null&&L()>pb&&(p.flags|=128,R=!0,bg(S,!1),p.lanes=4194304)}else{if(!R)if(d=Yv(O),d!==null){if(p.flags|=128,R=!0,d=d.updateQueue,p.updateQueue=d,cb(p,d),bg(S,!0),S.tail===null&&S.tailMode==="hidden"&&!O.alternate&&!yn)return nr(p),null}else 2*L()-S.renderingStartTime>pb&&_!==536870912&&(p.flags|=128,R=!0,bg(S,!1),p.lanes=4194304);S.isBackwards?(O.sibling=p.child,p.child=O):(d=S.last,d!==null?d.sibling=O:p.child=O,S.last=O)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=L(),d.sibling=null,_=Rr.current,te(Rr,R?_&1|2:_&1),yn&&xl(p,S.treeForkCount),d):(nr(p),null);case 22:case 23:return Js(p),mE(),S=p.memoizedState!==null,d!==null?d.memoizedState!==null!==S&&(p.flags|=8192):S&&(p.flags|=8192),S?(_&536870912)!==0&&(p.flags&128)===0&&(nr(p),p.subtreeFlags&6&&(p.flags|=8192)):nr(p),_=p.updateQueue,_!==null&&cb(p,_.retryQueue),_=null,d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(_=d.memoizedState.cachePool.pool),S=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(S=p.memoizedState.cachePool.pool),S!==_&&(p.flags|=2048),d!==null&&Y(wd),null;case 24:return _=null,d!==null&&(_=d.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),bl(Ur),nr(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function yte(d,p){switch(eE(p),p.tag){case 1:return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 3:return bl(Ur),he(),d=p.flags,(d&65536)!==0&&(d&128)===0?(p.flags=d&-65537|128,p):null;case 26:case 27:case 5:return De(p),null;case 31:if(p.memoizedState!==null){if(Js(p),p.alternate===null)throw Error(r(340));yd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 13:if(Js(p),d=p.memoizedState,d!==null&&d.dehydrated!==null){if(p.alternate===null)throw Error(r(340));yd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 19:return Y(Rr),null;case 4:return he(),null;case 10:return bl(p.type),null;case 22:case 23:return Js(p),mE(),d!==null&&Y(wd),d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 24:return bl(Ur),null;case 25:return null;default:return null}}function Pj(d,p){switch(eE(p),p.tag){case 3:bl(Ur),he();break;case 26:case 27:case 5:De(p);break;case 4:he();break;case 31:p.memoizedState!==null&&Js(p);break;case 13:Js(p);break;case 19:Y(Rr);break;case 10:bl(p.type);break;case 22:case 23:Js(p),mE(),d!==null&&Y(wd);break;case 24:bl(Ur)}}function yg(d,p){try{var _=p.updateQueue,S=_!==null?_.lastEffect:null;if(S!==null){var R=S.next;_=R;do{if((_.tag&d)===d){S=void 0;var O=_.create,q=_.inst;S=O(),q.destroy=S}_=_.next}while(_!==R)}}catch(oe){On(p,p.return,oe)}}function Gc(d,p,_){try{var S=p.updateQueue,R=S!==null?S.lastEffect:null;if(R!==null){var O=R.next;S=O;do{if((S.tag&d)===d){var q=S.inst,oe=q.destroy;if(oe!==void 0){q.destroy=void 0,R=p;var Se=_,$e=oe;try{$e()}catch(at){On(R,Se,at)}}}S=S.next}while(S!==O)}}catch(at){On(p,p.return,at)}}function kj(d){var p=d.updateQueue;if(p!==null){var _=d.stateNode;try{SI(p,_)}catch(S){On(d,d.return,S)}}}function Dj(d,p,_){_.props=Cd(d.type,d.memoizedProps),_.state=d.memoizedState;try{_.componentWillUnmount()}catch(S){On(d,p,S)}}function _g(d,p){try{var _=d.ref;if(_!==null){switch(d.tag){case 26:case 27:case 5:var S=d.stateNode;break;case 30:S=d.stateNode;break;default:S=d.stateNode}typeof _=="function"?d.refCleanup=_(S):_.current=S}}catch(R){On(d,p,R)}}function Lo(d,p){var _=d.ref,S=d.refCleanup;if(_!==null)if(typeof S=="function")try{S()}catch(R){On(d,p,R)}finally{d.refCleanup=null,d=d.alternate,d!=null&&(d.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(R){On(d,p,R)}else _.current=null}function Oj(d){var p=d.type,_=d.memoizedProps,S=d.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&S.focus();break e;case"img":_.src?S.src=_.src:_.srcSet&&(S.srcset=_.srcSet)}}catch(R){On(d,d.return,R)}}function qE(d,p,_){try{var S=d.stateNode;Hte(S,d.type,_,p),S[Cr]=p}catch(R){On(d,d.return,R)}}function Lj(d){return d.tag===5||d.tag===3||d.tag===26||d.tag===27&&Qc(d.type)||d.tag===4}function XE(d){e:for(;;){for(;d.sibling===null;){if(d.return===null||Lj(d.return))return null;d=d.return}for(d.sibling.return=d.return,d=d.sibling;d.tag!==5&&d.tag!==6&&d.tag!==18;){if(d.tag===27&&Qc(d.type)||d.flags&2||d.child===null||d.tag===4)continue e;d.child.return=d,d=d.child}if(!(d.flags&2))return d.stateNode}}function KE(d,p,_){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(d,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(d),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=pl));else if(S!==4&&(S===27&&Qc(d.type)&&(_=d.stateNode,p=null),d=d.child,d!==null))for(KE(d,p,_),d=d.sibling;d!==null;)KE(d,p,_),d=d.sibling}function ub(d,p,_){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?_.insertBefore(d,p):_.appendChild(d);else if(S!==4&&(S===27&&Qc(d.type)&&(_=d.stateNode),d=d.child,d!==null))for(ub(d,p,_),d=d.sibling;d!==null;)ub(d,p,_),d=d.sibling}function Ij(d){var p=d.stateNode,_=d.memoizedProps;try{for(var S=d.type,R=p.attributes;R.length;)p.removeAttributeNode(R[0]);Ui(p,S,_),p[pr]=d,p[Cr]=_}catch(O){On(d,d.return,O)}}var Ml=!1,Br=!1,YE=!1,jj=typeof WeakSet=="function"?WeakSet:Set,yi=null;function _te(d,p){if(d=d.containerInfo,xA=Pb,d=KL(d),$M(d)){if("selectionStart"in d)var _={start:d.selectionStart,end:d.selectionEnd};else e:{_=(_=d.ownerDocument)&&_.defaultView||window;var S=_.getSelection&&_.getSelection();if(S&&S.rangeCount!==0){_=S.anchorNode;var R=S.anchorOffset,O=S.focusNode;S=S.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var q=0,oe=-1,Se=-1,$e=0,at=0,ut=d,qe=null;t:for(;;){for(var rt;ut!==_||R!==0&&ut.nodeType!==3||(oe=q+R),ut!==O||S!==0&&ut.nodeType!==3||(Se=q+S),ut.nodeType===3&&(q+=ut.nodeValue.length),(rt=ut.firstChild)!==null;)qe=ut,ut=rt;for(;;){if(ut===d)break t;if(qe===_&&++$e===R&&(oe=q),qe===O&&++at===S&&(Se=q),(rt=ut.nextSibling)!==null)break;ut=qe,qe=ut.parentNode}ut=rt}_=oe===-1||Se===-1?null:{start:oe,end:Se}}else _=null}_=_||{start:0,end:0}}else _=null;for(vA={focusedElem:d,selectionRange:_},Pb=!1,yi=p;yi!==null;)if(p=yi,d=p.child,(p.subtreeFlags&1028)!==0&&d!==null)d.return=p,yi=d;else for(;yi!==null;){switch(p=yi,O=p.alternate,d=p.flags,p.tag){case 0:if((d&4)!==0&&(d=p.updateQueue,d=d!==null?d.events:null,d!==null))for(_=0;_<d.length;_++)R=d[_],R.ref.impl=R.nextImpl;break;case 11:case 15:break;case 1:if((d&1024)!==0&&O!==null){d=void 0,_=p,R=O.memoizedProps,O=O.memoizedState,S=_.stateNode;try{var Rt=Cd(_.type,R);d=S.getSnapshotBeforeUpdate(Rt,O),S.__reactInternalSnapshotBeforeUpdate=d}catch(Ht){On(_,_.return,Ht)}}break;case 3:if((d&1024)!==0){if(d=p.stateNode.containerInfo,_=d.nodeType,_===9)_A(d);else if(_===1)switch(d.nodeName){case"HEAD":case"HTML":case"BODY":_A(d);break;default:d.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((d&1024)!==0)throw Error(r(163))}if(d=p.sibling,d!==null){d.return=p.return,yi=d;break}yi=p.return}}function Uj(d,p,_){var S=_.flags;switch(_.tag){case 0:case 11:case 15:Al(d,_),S&4&&yg(5,_);break;case 1:if(Al(d,_),S&4)if(d=_.stateNode,p===null)try{d.componentDidMount()}catch(q){On(_,_.return,q)}else{var R=Cd(_.type,p.memoizedProps);p=p.memoizedState;try{d.componentDidUpdate(R,p,d.__reactInternalSnapshotBeforeUpdate)}catch(q){On(_,_.return,q)}}S&64&&kj(_),S&512&&_g(_,_.return);break;case 3:if(Al(d,_),S&64&&(d=_.updateQueue,d!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{SI(d,p)}catch(q){On(_,_.return,q)}}break;case 27:p===null&&S&4&&Ij(_);case 26:case 5:Al(d,_),p===null&&S&4&&Oj(_),S&512&&_g(_,_.return);break;case 12:Al(d,_);break;case 31:Al(d,_),S&4&&Bj(d,_);break;case 13:Al(d,_),S&4&&Hj(d,_),S&64&&(d=_.memoizedState,d!==null&&(d=d.dehydrated,d!==null&&(_=Rte.bind(null,_),Yte(d,_))));break;case 22:if(S=_.memoizedState!==null||Ml,!S){p=p!==null&&p.memoizedState!==null||Br,R=Ml;var O=Br;Ml=S,(Br=p)&&!O?Tl(d,_,(_.subtreeFlags&8772)!==0):Al(d,_),Ml=R,Br=O}break;case 30:break;default:Al(d,_)}}function Fj(d){var p=d.alternate;p!==null&&(d.alternate=null,Fj(p)),d.child=null,d.deletions=null,d.sibling=null,d.tag===5&&(p=d.stateNode,p!==null&&Ze(p)),d.stateNode=null,d.return=null,d.dependencies=null,d.memoizedProps=null,d.memoizedState=null,d.pendingProps=null,d.stateNode=null,d.updateQueue=null}var lr=null,Ns=!1;function El(d,p,_){for(_=_.child;_!==null;)zj(d,p,_),_=_.sibling}function zj(d,p,_){if(ce&&typeof ce.onCommitFiberUnmount=="function")try{ce.onCommitFiberUnmount(Fe,_)}catch{}switch(_.tag){case 26:Br||Lo(_,p),El(d,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Br||Lo(_,p);var S=lr,R=Ns;Qc(_.type)&&(lr=_.stateNode,Ns=!1),El(d,p,_),Rg(_.stateNode),lr=S,Ns=R;break;case 5:Br||Lo(_,p);case 6:if(S=lr,R=Ns,lr=null,El(d,p,_),lr=S,Ns=R,lr!==null)if(Ns)try{(lr.nodeType===9?lr.body:lr.nodeName==="HTML"?lr.ownerDocument.body:lr).removeChild(_.stateNode)}catch(O){On(_,p,O)}else try{lr.removeChild(_.stateNode)}catch(O){On(_,p,O)}break;case 18:lr!==null&&(Ns?(d=lr,k4(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,_.stateNode),Rh(d)):k4(lr,_.stateNode));break;case 4:S=lr,R=Ns,lr=_.stateNode.containerInfo,Ns=!0,El(d,p,_),lr=S,Ns=R;break;case 0:case 11:case 14:case 15:Gc(2,_,p),Br||Gc(4,_,p),El(d,p,_);break;case 1:Br||(Lo(_,p),S=_.stateNode,typeof S.componentWillUnmount=="function"&&Dj(_,p,S)),El(d,p,_);break;case 21:El(d,p,_);break;case 22:Br=(S=Br)||_.memoizedState!==null,El(d,p,_),Br=S;break;default:El(d,p,_)}}function Bj(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null))){d=d.dehydrated;try{Rh(d)}catch(_){On(p,p.return,_)}}}function Hj(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null&&(d=d.dehydrated,d!==null))))try{Rh(d)}catch(_){On(p,p.return,_)}}function Ste(d){switch(d.tag){case 31:case 13:case 19:var p=d.stateNode;return p===null&&(p=d.stateNode=new jj),p;case 22:return d=d.stateNode,p=d._retryCache,p===null&&(p=d._retryCache=new jj),p;default:throw Error(r(435,d.tag))}}function db(d,p){var _=Ste(d);p.forEach(function(S){if(!_.has(S)){_.add(S);var R=Pte.bind(null,d,S);S.then(R,R)}})}function Rs(d,p){var _=p.deletions;if(_!==null)for(var S=0;S<_.length;S++){var R=_[S],O=d,q=p,oe=q;e:for(;oe!==null;){switch(oe.tag){case 27:if(Qc(oe.type)){lr=oe.stateNode,Ns=!1;break e}break;case 5:lr=oe.stateNode,Ns=!1;break e;case 3:case 4:lr=oe.stateNode.containerInfo,Ns=!0;break e}oe=oe.return}if(lr===null)throw Error(r(160));zj(O,q,R),lr=null,Ns=!1,O=R.alternate,O!==null&&(O.return=null),R.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)$j(p,d),p=p.sibling}var io=null;function $j(d,p){var _=d.alternate,S=d.flags;switch(d.tag){case 0:case 11:case 14:case 15:Rs(p,d),Ps(d),S&4&&(Gc(3,d,d.return),yg(3,d),Gc(5,d,d.return));break;case 1:Rs(p,d),Ps(d),S&512&&(Br||_===null||Lo(_,_.return)),S&64&&Ml&&(d=d.updateQueue,d!==null&&(S=d.callbacks,S!==null&&(_=d.shared.hiddenCallbacks,d.shared.hiddenCallbacks=_===null?S:_.concat(S))));break;case 26:var R=io;if(Rs(p,d),Ps(d),S&512&&(Br||_===null||Lo(_,_.return)),S&4){var O=_!==null?_.memoizedState:null;if(S=d.memoizedState,_===null)if(S===null)if(d.stateNode===null){e:{S=d.type,_=d.memoizedProps,R=R.ownerDocument||R;t:switch(S){case"title":O=R.getElementsByTagName("title")[0],(!O||O[nt]||O[pr]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=R.createElement(S),R.head.insertBefore(O,R.querySelector("head > title"))),Ui(O,S,_),O[pr]=d,Pe(O),S=O;break e;case"link":var q=$4("link","href",R).get(S+(_.href||""));if(q){for(var oe=0;oe<q.length;oe++)if(O=q[oe],O.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&O.getAttribute("rel")===(_.rel==null?null:_.rel)&&O.getAttribute("title")===(_.title==null?null:_.title)&&O.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){q.splice(oe,1);break t}}O=R.createElement(S),Ui(O,S,_),R.head.appendChild(O);break;case"meta":if(q=$4("meta","content",R).get(S+(_.content||""))){for(oe=0;oe<q.length;oe++)if(O=q[oe],O.getAttribute("content")===(_.content==null?null:""+_.content)&&O.getAttribute("name")===(_.name==null?null:_.name)&&O.getAttribute("property")===(_.property==null?null:_.property)&&O.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&O.getAttribute("charset")===(_.charSet==null?null:_.charSet)){q.splice(oe,1);break t}}O=R.createElement(S),Ui(O,S,_),R.head.appendChild(O);break;default:throw Error(r(468,S))}O[pr]=d,Pe(O),S=O}d.stateNode=S}else V4(R,d.type,d.stateNode);else d.stateNode=H4(R,S,d.memoizedProps);else O!==S?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,S===null?V4(R,d.type,d.stateNode):H4(R,S,d.memoizedProps)):S===null&&d.stateNode!==null&&qE(d,d.memoizedProps,_.memoizedProps)}break;case 27:Rs(p,d),Ps(d),S&512&&(Br||_===null||Lo(_,_.return)),_!==null&&S&4&&qE(d,d.memoizedProps,_.memoizedProps);break;case 5:if(Rs(p,d),Ps(d),S&512&&(Br||_===null||Lo(_,_.return)),d.flags&32){R=d.stateNode;try{ko(R,"")}catch(Rt){On(d,d.return,Rt)}}S&4&&d.stateNode!=null&&(R=d.memoizedProps,qE(d,R,_!==null?_.memoizedProps:R)),S&1024&&(YE=!0);break;case 6:if(Rs(p,d),Ps(d),S&4){if(d.stateNode===null)throw Error(r(162));S=d.memoizedProps,_=d.stateNode;try{_.nodeValue=S}catch(Rt){On(d,d.return,Rt)}}break;case 3:if(Tb=null,R=io,io=Eb(p.containerInfo),Rs(p,d),io=R,Ps(d),S&4&&_!==null&&_.memoizedState.isDehydrated)try{Rh(p.containerInfo)}catch(Rt){On(d,d.return,Rt)}YE&&(YE=!1,Vj(d));break;case 4:S=io,io=Eb(d.stateNode.containerInfo),Rs(p,d),Ps(d),io=S;break;case 12:Rs(p,d),Ps(d);break;case 31:Rs(p,d),Ps(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,db(d,S)));break;case 13:Rs(p,d),Ps(d),d.child.flags&8192&&d.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(hb=L()),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,db(d,S)));break;case 22:R=d.memoizedState!==null;var Se=_!==null&&_.memoizedState!==null,$e=Ml,at=Br;if(Ml=$e||R,Br=at||Se,Rs(p,d),Br=at,Ml=$e,Ps(d),S&8192)e:for(p=d.stateNode,p._visibility=R?p._visibility&-2:p._visibility|1,R&&(_===null||Se||Ml||Br||Nd(d)),_=null,p=d;;){if(p.tag===5||p.tag===26){if(_===null){Se=_=p;try{if(O=Se.stateNode,R)q=O.style,typeof q.setProperty=="function"?q.setProperty("display","none","important"):q.display="none";else{oe=Se.stateNode;var ut=Se.memoizedProps.style,qe=ut!=null&&ut.hasOwnProperty("display")?ut.display:null;oe.style.display=qe==null||typeof qe=="boolean"?"":(""+qe).trim()}}catch(Rt){On(Se,Se.return,Rt)}}}else if(p.tag===6){if(_===null){Se=p;try{Se.stateNode.nodeValue=R?"":Se.memoizedProps}catch(Rt){On(Se,Se.return,Rt)}}}else if(p.tag===18){if(_===null){Se=p;try{var rt=Se.stateNode;R?D4(rt,!0):D4(Se.stateNode,!1)}catch(Rt){On(Se,Se.return,Rt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===d)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break e;for(;p.sibling===null;){if(p.return===null||p.return===d)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}S&4&&(S=d.updateQueue,S!==null&&(_=S.retryQueue,_!==null&&(S.retryQueue=null,db(d,_))));break;case 19:Rs(p,d),Ps(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,db(d,S)));break;case 30:break;case 21:break;default:Rs(p,d),Ps(d)}}function Ps(d){var p=d.flags;if(p&2){try{for(var _,S=d.return;S!==null;){if(Lj(S)){_=S;break}S=S.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var R=_.stateNode,O=XE(d);ub(d,O,R);break;case 5:var q=_.stateNode;_.flags&32&&(ko(q,""),_.flags&=-33);var oe=XE(d);ub(d,oe,q);break;case 3:case 4:var Se=_.stateNode.containerInfo,$e=XE(d);KE(d,$e,Se);break;default:throw Error(r(161))}}catch(at){On(d,d.return,at)}d.flags&=-3}p&4096&&(d.flags&=-4097)}function Vj(d){if(d.subtreeFlags&1024)for(d=d.child;d!==null;){var p=d;Vj(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),d=d.sibling}}function Al(d,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)Uj(d,p.alternate,p),p=p.sibling}function Nd(d){for(d=d.child;d!==null;){var p=d;switch(p.tag){case 0:case 11:case 14:case 15:Gc(4,p,p.return),Nd(p);break;case 1:Lo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&Dj(p,p.return,_),Nd(p);break;case 27:Rg(p.stateNode);case 26:case 5:Lo(p,p.return),Nd(p);break;case 22:p.memoizedState===null&&Nd(p);break;case 30:Nd(p);break;default:Nd(p)}d=d.sibling}}function Tl(d,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var S=p.alternate,R=d,O=p,q=O.flags;switch(O.tag){case 0:case 11:case 15:Tl(R,O,_),yg(4,O);break;case 1:if(Tl(R,O,_),S=O,R=S.stateNode,typeof R.componentDidMount=="function")try{R.componentDidMount()}catch($e){On(S,S.return,$e)}if(S=O,R=S.updateQueue,R!==null){var oe=S.stateNode;try{var Se=R.shared.hiddenCallbacks;if(Se!==null)for(R.shared.hiddenCallbacks=null,R=0;R<Se.length;R++)_I(Se[R],oe)}catch($e){On(S,S.return,$e)}}_&&q&64&&kj(O),_g(O,O.return);break;case 27:Ij(O);case 26:case 5:Tl(R,O,_),_&&S===null&&q&4&&Oj(O),_g(O,O.return);break;case 12:Tl(R,O,_);break;case 31:Tl(R,O,_),_&&q&4&&Bj(R,O);break;case 13:Tl(R,O,_),_&&q&4&&Hj(R,O);break;case 22:O.memoizedState===null&&Tl(R,O,_),_g(O,O.return);break;case 30:break;default:Tl(R,O,_)}p=p.sibling}}function ZE(d,p){var _=null;d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(_=d.memoizedState.cachePool.pool),d=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(d=p.memoizedState.cachePool.pool),d!==_&&(d!=null&&d.refCount++,_!=null&&og(_))}function QE(d,p){d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&og(d))}function so(d,p,_,S){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)Gj(d,p,_,S),p=p.sibling}function Gj(d,p,_,S){var R=p.flags;switch(p.tag){case 0:case 11:case 15:so(d,p,_,S),R&2048&&yg(9,p);break;case 1:so(d,p,_,S);break;case 3:so(d,p,_,S),R&2048&&(d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&og(d)));break;case 12:if(R&2048){so(d,p,_,S),d=p.stateNode;try{var O=p.memoizedProps,q=O.id,oe=O.onPostCommit;typeof oe=="function"&&oe(q,p.alternate===null?"mount":"update",d.passiveEffectDuration,-0)}catch(Se){On(p,p.return,Se)}}else so(d,p,_,S);break;case 31:so(d,p,_,S);break;case 13:so(d,p,_,S);break;case 23:break;case 22:O=p.stateNode,q=p.alternate,p.memoizedState!==null?O._visibility&2?so(d,p,_,S):Sg(d,p):O._visibility&2?so(d,p,_,S):(O._visibility|=2,bh(d,p,_,S,(p.subtreeFlags&10256)!==0||!1)),R&2048&&ZE(q,p);break;case 24:so(d,p,_,S),R&2048&&QE(p.alternate,p);break;default:so(d,p,_,S)}}function bh(d,p,_,S,R){for(R=R&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=d,q=p,oe=_,Se=S,$e=q.flags;switch(q.tag){case 0:case 11:case 15:bh(O,q,oe,Se,R),yg(8,q);break;case 23:break;case 22:var at=q.stateNode;q.memoizedState!==null?at._visibility&2?bh(O,q,oe,Se,R):Sg(O,q):(at._visibility|=2,bh(O,q,oe,Se,R)),R&&$e&2048&&ZE(q.alternate,q);break;case 24:bh(O,q,oe,Se,R),R&&$e&2048&&QE(q.alternate,q);break;default:bh(O,q,oe,Se,R)}p=p.sibling}}function Sg(d,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=d,S=p,R=S.flags;switch(S.tag){case 22:Sg(_,S),R&2048&&ZE(S.alternate,S);break;case 24:Sg(_,S),R&2048&&QE(S.alternate,S);break;default:Sg(_,S)}p=p.sibling}}var wg=8192;function yh(d,p,_){if(d.subtreeFlags&wg)for(d=d.child;d!==null;)Wj(d,p,_),d=d.sibling}function Wj(d,p,_){switch(d.tag){case 26:yh(d,p,_),d.flags&wg&&d.memoizedState!==null&&lne(_,io,d.memoizedState,d.memoizedProps);break;case 5:yh(d,p,_);break;case 3:case 4:var S=io;io=Eb(d.stateNode.containerInfo),yh(d,p,_),io=S;break;case 22:d.memoizedState===null&&(S=d.alternate,S!==null&&S.memoizedState!==null?(S=wg,wg=16777216,yh(d,p,_),wg=S):yh(d,p,_));break;default:yh(d,p,_)}}function qj(d){var p=d.alternate;if(p!==null&&(d=p.child,d!==null)){p.child=null;do p=d.sibling,d.sibling=null,d=p;while(d!==null)}}function Mg(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];yi=S,Kj(S,d)}qj(d)}if(d.subtreeFlags&10256)for(d=d.child;d!==null;)Xj(d),d=d.sibling}function Xj(d){switch(d.tag){case 0:case 11:case 15:Mg(d),d.flags&2048&&Gc(9,d,d.return);break;case 3:Mg(d);break;case 12:Mg(d);break;case 22:var p=d.stateNode;d.memoizedState!==null&&p._visibility&2&&(d.return===null||d.return.tag!==13)?(p._visibility&=-3,fb(d)):Mg(d);break;default:Mg(d)}}function fb(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var S=p[_];yi=S,Kj(S,d)}qj(d)}for(d=d.child;d!==null;){switch(p=d,p.tag){case 0:case 11:case 15:Gc(8,p,p.return),fb(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,fb(p));break;default:fb(p)}d=d.sibling}}function Kj(d,p){for(;yi!==null;){var _=yi;switch(_.tag){case 0:case 11:case 15:Gc(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var S=_.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:og(_.memoizedState.cache)}if(S=_.child,S!==null)S.return=_,yi=S;else e:for(_=d;yi!==null;){S=yi;var R=S.sibling,O=S.return;if(Fj(S),S===_){yi=null;break e}if(R!==null){R.return=O,yi=R;break e}yi=O}}}var wte={getCacheForType:function(d){var p=Ii(Ur),_=p.data.get(d);return _===void 0&&(_=d(),p.data.set(d,_)),_},cacheSignal:function(){return Ii(Ur).controller.signal}},Mte=typeof WeakMap=="function"?WeakMap:Map,Cn=0,Xn=null,hn=null,xn=0,Dn=0,ea=null,Wc=!1,_h=!1,JE=!1,Cl=0,Sr=0,qc=0,Rd=0,eA=0,ta=0,Sh=0,Eg=null,ks=null,tA=!1,hb=0,Yj=0,pb=1/0,mb=null,Xc=null,ti=0,Kc=null,wh=null,Nl=0,nA=0,rA=null,Zj=null,Ag=0,iA=null;function na(){return(Cn&2)!==0&&xn!==0?xn&-xn:G.T!==null?uA():Di()}function Qj(){if(ta===0)if((xn&536870912)===0||yn){var d=ge;ge<<=1,(ge&3932160)===0&&(ge=262144),ta=d}else ta=536870912;return d=Qs.current,d!==null&&(d.flags|=32),ta}function Ds(d,p,_){(d===Xn&&(Dn===2||Dn===9)||d.cancelPendingCommit!==null)&&(Mh(d,0),Yc(d,xn,ta,!1)),cn(d,_),((Cn&2)===0||d!==Xn)&&(d===Xn&&((Cn&2)===0&&(Rd|=_),Sr===4&&Yc(d,xn,ta,!1)),Io(d))}function Jj(d,p,_){if((Cn&6)!==0)throw Error(r(327));var S=!_&&(p&127)===0&&(p&d.expiredLanes)===0||Ve(d,p),R=S?Tte(d,p):aA(d,p,!0),O=S;do{if(R===0){_h&&!S&&Yc(d,p,0,!1);break}else{if(_=d.current.alternate,O&&!Ete(_)){R=aA(d,p,!1),O=!1;continue}if(R===2){if(O=p,d.errorRecoveryDisabledLanes&O)var q=0;else q=d.pendingLanes&-536870913,q=q!==0?q:q&536870912?536870912:0;if(q!==0){p=q;e:{var oe=d;R=Eg;var Se=oe.current.memoizedState.isDehydrated;if(Se&&(Mh(oe,q).flags|=256),q=aA(oe,q,!1),q!==2){if(JE&&!Se){oe.errorRecoveryDisabledLanes|=O,Rd|=O,R=4;break e}O=ks,ks=R,O!==null&&(ks===null?ks=O:ks.push.apply(ks,O))}R=q}if(O=!1,R!==2)continue}}if(R===1){Mh(d,0),Yc(d,p,0,!0);break}e:{switch(S=d,O=R,O){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:Yc(S,p,ta,!Wc);break e;case 2:ks=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(R=hb+300-L(),10<R)){if(Yc(S,p,ta,!Wc),be(S,0,!0)!==0)break e;Nl=p,S.timeoutHandle=R4(e4.bind(null,S,_,ks,mb,tA,p,ta,Rd,Sh,Wc,O,"Throttled",-0,0),R);break e}e4(S,_,ks,mb,tA,p,ta,Rd,Sh,Wc,O,null,-0,0)}}break}while(!0);Io(d)}function e4(d,p,_,S,R,O,q,oe,Se,$e,at,ut,qe,rt){if(d.timeoutHandle=-1,ut=p.subtreeFlags,ut&8192||(ut&16785408)===16785408){ut={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pl},Wj(p,O,ut);var Rt=(O&62914560)===O?hb-L():(O&4194048)===O?Yj-L():0;if(Rt=cne(ut,Rt),Rt!==null){Nl=O,d.cancelPendingCommit=Rt(l4.bind(null,d,p,O,_,S,R,q,oe,Se,at,ut,null,qe,rt)),Yc(d,O,q,!$e);return}}l4(d,p,O,_,S,R,q,oe,Se)}function Ete(d){for(var p=d;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var S=0;S<_.length;S++){var R=_[S],O=R.getSnapshot;R=R.value;try{if(!Ys(O(),R))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function Yc(d,p,_,S){p&=~eA,p&=~Rd,d.suspendedLanes|=p,d.pingedLanes&=~p,S&&(d.warmLanes|=p),S=d.expirationTimes;for(var R=p;0<R;){var O=31-Be(R),q=1<<O;S[O]=-1,R&=~q}_!==0&&Pn(d,_,p)}function gb(){return(Cn&6)===0?(Tg(0),!1):!0}function sA(){if(hn!==null){if(Dn===0)var d=hn.return;else d=hn,vl=_d=null,_E(d),ph=null,cg=0,d=hn;for(;d!==null;)Pj(d.alternate,d),d=d.return;hn=null}}function Mh(d,p){var _=d.timeoutHandle;_!==-1&&(d.timeoutHandle=-1,Gte(_)),_=d.cancelPendingCommit,_!==null&&(d.cancelPendingCommit=null,_()),Nl=0,sA(),Xn=d,hn=_=gl(d.current,null),xn=p,Dn=0,ea=null,Wc=!1,_h=Ve(d,p),JE=!1,Sh=ta=eA=Rd=qc=Sr=0,ks=Eg=null,tA=!1,(p&8)!==0&&(p|=p&32);var S=d.entangledLanes;if(S!==0)for(d=d.entanglements,S&=p;0<S;){var R=31-Be(S),O=1<<R;p|=d[R],S&=~O}return Cl=p,jv(),_}function t4(d,p){Jt=null,G.H=xg,p===hh||p===Gv?(p=xI(),Dn=3):p===cE?(p=xI(),Dn=4):Dn=p===jE?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,ea=p,hn===null&&(Sr=1,sb(d,ba(p,d.current)))}function n4(){var d=Qs.current;return d===null?!0:(xn&4194048)===xn?wa===null:(xn&62914560)===xn||(xn&536870912)!==0?d===wa:!1}function r4(){var d=G.H;return G.H=xg,d===null?xg:d}function i4(){var d=G.A;return G.A=wte,d}function xb(){Sr=4,Wc||(xn&4194048)!==xn&&Qs.current!==null||(_h=!0),(qc&134217727)===0&&(Rd&134217727)===0||Xn===null||Yc(Xn,xn,ta,!1)}function aA(d,p,_){var S=Cn;Cn|=2;var R=r4(),O=i4();(Xn!==d||xn!==p)&&(mb=null,Mh(d,p)),p=!1;var q=Sr;e:do try{if(Dn!==0&&hn!==null){var oe=hn,Se=ea;switch(Dn){case 8:sA(),q=6;break e;case 3:case 2:case 9:case 6:Qs.current===null&&(p=!0);var $e=Dn;if(Dn=0,ea=null,Eh(d,oe,Se,$e),_&&_h){q=0;break e}break;default:$e=Dn,Dn=0,ea=null,Eh(d,oe,Se,$e)}}Ate(),q=Sr;break}catch(at){t4(d,at)}while(!0);return p&&d.shellSuspendCounter++,vl=_d=null,Cn=S,G.H=R,G.A=O,hn===null&&(Xn=null,xn=0,jv()),q}function Ate(){for(;hn!==null;)s4(hn)}function Tte(d,p){var _=Cn;Cn|=2;var S=r4(),R=i4();Xn!==d||xn!==p?(mb=null,pb=L()+500,Mh(d,p)):_h=Ve(d,p);e:do try{if(Dn!==0&&hn!==null){p=hn;var O=ea;t:switch(Dn){case 1:Dn=0,ea=null,Eh(d,p,O,1);break;case 2:case 9:if(mI(O)){Dn=0,ea=null,a4(p);break}p=function(){Dn!==2&&Dn!==9||Xn!==d||(Dn=7),Io(d)},O.then(p,p);break e;case 3:Dn=7;break e;case 4:Dn=5;break e;case 7:mI(O)?(Dn=0,ea=null,a4(p)):(Dn=0,ea=null,Eh(d,p,O,7));break;case 5:var q=null;switch(hn.tag){case 26:q=hn.memoizedState;case 5:case 27:var oe=hn;if(q?G4(q):oe.stateNode.complete){Dn=0,ea=null;var Se=oe.sibling;if(Se!==null)hn=Se;else{var $e=oe.return;$e!==null?(hn=$e,vb($e)):hn=null}break t}}Dn=0,ea=null,Eh(d,p,O,5);break;case 6:Dn=0,ea=null,Eh(d,p,O,6);break;case 8:sA(),Sr=6;break e;default:throw Error(r(462))}}Cte();break}catch(at){t4(d,at)}while(!0);return vl=_d=null,G.H=S,G.A=R,Cn=_,hn!==null?0:(Xn=null,xn=0,jv(),Sr)}function Cte(){for(;hn!==null&&!se();)s4(hn)}function s4(d){var p=Nj(d.alternate,d,Cl);d.memoizedProps=d.pendingProps,p===null?vb(d):hn=p}function a4(d){var p=d,_=p.alternate;switch(p.tag){case 15:case 0:p=wj(_,p,p.pendingProps,p.type,void 0,xn);break;case 11:p=wj(_,p,p.pendingProps,p.type.render,p.ref,xn);break;case 5:_E(p);default:Pj(_,p),p=hn=iI(p,Cl),p=Nj(_,p,Cl)}d.memoizedProps=d.pendingProps,p===null?vb(d):hn=p}function Eh(d,p,_,S){vl=_d=null,_E(p),ph=null,cg=0;var R=p.return;try{if(gte(d,R,p,_,xn)){Sr=1,sb(d,ba(_,d.current)),hn=null;return}}catch(O){if(R!==null)throw hn=R,O;Sr=1,sb(d,ba(_,d.current)),hn=null;return}p.flags&32768?(yn||S===1?d=!0:_h||(xn&536870912)!==0?d=!1:(Wc=d=!0,(S===2||S===9||S===3||S===6)&&(S=Qs.current,S!==null&&S.tag===13&&(S.flags|=16384))),o4(p,d)):vb(p)}function vb(d){var p=d;do{if((p.flags&32768)!==0){o4(p,Wc);return}d=p.return;var _=bte(p.alternate,p,Cl);if(_!==null){hn=_;return}if(p=p.sibling,p!==null){hn=p;return}hn=p=d}while(p!==null);Sr===0&&(Sr=5)}function o4(d,p){do{var _=yte(d.alternate,d);if(_!==null){_.flags&=32767,hn=_;return}if(_=d.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(d=d.sibling,d!==null)){hn=d;return}hn=d=_}while(d!==null);Sr=6,hn=null}function l4(d,p,_,S,R,O,q,oe,Se){d.cancelPendingCommit=null;do bb();while(ti!==0);if((Cn&6)!==0)throw Error(r(327));if(p!==null){if(p===d.current)throw Error(r(177));if(O=p.lanes|p.childLanes,O|=XM,Ot(d,_,O,q,oe,Se),d===Xn&&(hn=Xn=null,xn=0),wh=p,Kc=d,Nl=_,nA=O,rA=R,Zj=S,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(d.callbackNode=null,d.callbackPriority=0,kte(xe,function(){return h4(),null})):(d.callbackNode=null,d.callbackPriority=0),S=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||S){S=G.T,G.T=null,R=V.p,V.p=2,q=Cn,Cn|=4;try{_te(d,p,_)}finally{Cn=q,V.p=R,G.T=S}}ti=1,c4(),u4(),d4()}}function c4(){if(ti===1){ti=0;var d=Kc,p=wh,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=G.T,G.T=null;var S=V.p;V.p=2;var R=Cn;Cn|=4;try{$j(p,d);var O=vA,q=KL(d.containerInfo),oe=O.focusedElem,Se=O.selectionRange;if(q!==oe&&oe&&oe.ownerDocument&&XL(oe.ownerDocument.documentElement,oe)){if(Se!==null&&$M(oe)){var $e=Se.start,at=Se.end;if(at===void 0&&(at=$e),"selectionStart"in oe)oe.selectionStart=$e,oe.selectionEnd=Math.min(at,oe.value.length);else{var ut=oe.ownerDocument||document,qe=ut&&ut.defaultView||window;if(qe.getSelection){var rt=qe.getSelection(),Rt=oe.textContent.length,Ht=Math.min(Se.start,Rt),Fn=Se.end===void 0?Ht:Math.min(Se.end,Rt);!rt.extend&&Ht>Fn&&(q=Fn,Fn=Ht,Ht=q);var Oe=qL(oe,Ht),Ce=qL(oe,Fn);if(Oe&&Ce&&(rt.rangeCount!==1||rt.anchorNode!==Oe.node||rt.anchorOffset!==Oe.offset||rt.focusNode!==Ce.node||rt.focusOffset!==Ce.offset)){var He=ut.createRange();He.setStart(Oe.node,Oe.offset),rt.removeAllRanges(),Ht>Fn?(rt.addRange(He),rt.extend(Ce.node,Ce.offset)):(He.setEnd(Ce.node,Ce.offset),rt.addRange(He))}}}}for(ut=[],rt=oe;rt=rt.parentNode;)rt.nodeType===1&&ut.push({element:rt,left:rt.scrollLeft,top:rt.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oe<ut.length;oe++){var lt=ut[oe];lt.element.scrollLeft=lt.left,lt.element.scrollTop=lt.top}}Pb=!!xA,vA=xA=null}finally{Cn=R,V.p=S,G.T=_}}d.current=p,ti=2}}function u4(){if(ti===2){ti=0;var d=Kc,p=wh,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=G.T,G.T=null;var S=V.p;V.p=2;var R=Cn;Cn|=4;try{Uj(d,p.alternate,p)}finally{Cn=R,V.p=S,G.T=_}}ti=3}}function d4(){if(ti===4||ti===3){ti=0,U();var d=Kc,p=wh,_=Nl,S=Zj;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?ti=5:(ti=0,wh=Kc=null,f4(d,d.pendingLanes));var R=d.pendingLanes;if(R===0&&(Xc=null),xi(_),p=p.stateNode,ce&&typeof ce.onCommitFiberRoot=="function")try{ce.onCommitFiberRoot(Fe,p,void 0,(p.current.flags&128)===128)}catch{}if(S!==null){p=G.T,R=V.p,V.p=2,G.T=null;try{for(var O=d.onRecoverableError,q=0;q<S.length;q++){var oe=S[q];O(oe.value,{componentStack:oe.stack})}}finally{G.T=p,V.p=R}}(Nl&3)!==0&&bb(),Io(d),R=d.pendingLanes,(_&261930)!==0&&(R&42)!==0?d===iA?Ag++:(Ag=0,iA=d):Ag=0,Tg(0)}}function f4(d,p){(d.pooledCacheLanes&=p)===0&&(p=d.pooledCache,p!=null&&(d.pooledCache=null,og(p)))}function bb(){return c4(),u4(),d4(),h4()}function h4(){if(ti!==5)return!1;var d=Kc,p=nA;nA=0;var _=xi(Nl),S=G.T,R=V.p;try{V.p=32>_?32:_,G.T=null,_=rA,rA=null;var O=Kc,q=Nl;if(ti=0,wh=Kc=null,Nl=0,(Cn&6)!==0)throw Error(r(331));var oe=Cn;if(Cn|=4,Xj(O.current),Gj(O,O.current,q,_),Cn=oe,Tg(0,!1),ce&&typeof ce.onPostCommitFiberRoot=="function")try{ce.onPostCommitFiberRoot(Fe,O)}catch{}return!0}finally{V.p=R,G.T=S,f4(d,p)}}function p4(d,p,_){p=ba(_,p),p=IE(d.stateNode,p,2),d=Hc(d,p,2),d!==null&&(cn(d,2),Io(d))}function On(d,p,_){if(d.tag===3)p4(d,d,_);else for(;p!==null;){if(p.tag===3){p4(p,d,_);break}else if(p.tag===1){var S=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(Xc===null||!Xc.has(S))){d=ba(_,d),_=mj(2),S=Hc(p,_,2),S!==null&&(gj(_,S,p,d),cn(S,2),Io(S));break}}p=p.return}}function oA(d,p,_){var S=d.pingCache;if(S===null){S=d.pingCache=new Mte;var R=new Set;S.set(p,R)}else R=S.get(p),R===void 0&&(R=new Set,S.set(p,R));R.has(_)||(JE=!0,R.add(_),d=Nte.bind(null,d,p,_),p.then(d,d))}function Nte(d,p,_){var S=d.pingCache;S!==null&&S.delete(p),d.pingedLanes|=d.suspendedLanes&_,d.warmLanes&=~_,Xn===d&&(xn&_)===_&&(Sr===4||Sr===3&&(xn&62914560)===xn&&300>L()-hb?(Cn&2)===0&&Mh(d,0):eA|=_,Sh===xn&&(Sh=0)),Io(d)}function m4(d,p){p===0&&(p=yt()),d=vd(d,p),d!==null&&(cn(d,p),Io(d))}function Rte(d){var p=d.memoizedState,_=0;p!==null&&(_=p.retryLane),m4(d,_)}function Pte(d,p){var _=0;switch(d.tag){case 31:case 13:var S=d.stateNode,R=d.memoizedState;R!==null&&(_=R.retryLane);break;case 19:S=d.stateNode;break;case 22:S=d.stateNode._retryCache;break;default:throw Error(r(314))}S!==null&&S.delete(p),m4(d,_)}function kte(d,p){return Re(d,p)}var yb=null,Ah=null,lA=!1,_b=!1,cA=!1,Zc=0;function Io(d){d!==Ah&&d.next===null&&(Ah===null?yb=Ah=d:Ah=Ah.next=d),_b=!0,lA||(lA=!0,Ote())}function Tg(d,p){if(!cA&&_b){cA=!0;do for(var _=!1,S=yb;S!==null;){if(d!==0){var R=S.pendingLanes;if(R===0)var O=0;else{var q=S.suspendedLanes,oe=S.pingedLanes;O=(1<<31-Be(42|d)+1)-1,O&=R&~(q&~oe),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,b4(S,O))}else O=xn,O=be(S,S===Xn?O:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(O&3)===0||Ve(S,O)||(_=!0,b4(S,O));S=S.next}while(_);cA=!1}}function Dte(){g4()}function g4(){_b=lA=!1;var d=0;Zc!==0&&Vte()&&(d=Zc);for(var p=L(),_=null,S=yb;S!==null;){var R=S.next,O=x4(S,p);O===0?(S.next=null,_===null?yb=R:_.next=R,R===null&&(Ah=_)):(_=S,(d!==0||(O&3)!==0)&&(_b=!0)),S=R}ti!==0&&ti!==5||Tg(d),Zc!==0&&(Zc=0)}function x4(d,p){for(var _=d.suspendedLanes,S=d.pingedLanes,R=d.expirationTimes,O=d.pendingLanes&-62914561;0<O;){var q=31-Be(O),oe=1<<q,Se=R[q];Se===-1?((oe&_)===0||(oe&S)!==0)&&(R[q]=ft(oe,p)):Se<=p&&(d.expiredLanes|=oe),O&=~oe}if(p=Xn,_=xn,_=be(d,d===p?_:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S=d.callbackNode,_===0||d===p&&(Dn===2||Dn===9)||d.cancelPendingCommit!==null)return S!==null&&S!==null&&Ae(S),d.callbackNode=null,d.callbackPriority=0;if((_&3)===0||Ve(d,_)){if(p=_&-_,p===d.callbackPriority)return p;switch(S!==null&&Ae(S),xi(_)){case 2:case 8:_=ye;break;case 32:_=xe;break;case 268435456:_=je;break;default:_=xe}return S=v4.bind(null,d),_=Re(_,S),d.callbackPriority=p,d.callbackNode=_,p}return S!==null&&S!==null&&Ae(S),d.callbackPriority=2,d.callbackNode=null,2}function v4(d,p){if(ti!==0&&ti!==5)return d.callbackNode=null,d.callbackPriority=0,null;var _=d.callbackNode;if(bb()&&d.callbackNode!==_)return null;var S=xn;return S=be(d,d===Xn?S:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S===0?null:(Jj(d,S,p),x4(d,L()),d.callbackNode!=null&&d.callbackNode===_?v4.bind(null,d):null)}function b4(d,p){if(bb())return null;Jj(d,p,!0)}function Ote(){Wte(function(){(Cn&6)!==0?Re(ve,Dte):g4()})}function uA(){if(Zc===0){var d=dh;d===0&&(d=Je,Je<<=1,(Je&261888)===0&&(Je=256)),Zc=d}return Zc}function y4(d){return d==null||typeof d=="symbol"||typeof d=="boolean"?null:typeof d=="function"?d:Nv(""+d)}function _4(d,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,d.id&&_.setAttribute("form",d.id),p.parentNode.insertBefore(_,p),d=new FormData(d),_.parentNode.removeChild(_),d}function Lte(d,p,_,S,R){if(p==="submit"&&_&&_.stateNode===R){var O=y4((R[Cr]||null).action),q=S.submitter;q&&(p=(p=q[Cr]||null)?y4(p.formAction):q.getAttribute("formAction"),p!==null&&(O=p,q=null));var oe=new Dv("action","action",null,S,R);d.push({event:oe,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(Zc!==0){var Se=q?_4(R,q):new FormData(R);RE(_,{pending:!0,data:Se,method:R.method,action:O},null,Se)}}else typeof O=="function"&&(oe.preventDefault(),Se=q?_4(R,q):new FormData(R),RE(_,{pending:!0,data:Se,method:R.method,action:O},O,Se))},currentTarget:R}]})}}for(var dA=0;dA<qM.length;dA++){var fA=qM[dA],Ite=fA.toLowerCase(),jte=fA[0].toUpperCase()+fA.slice(1);ro(Ite,"on"+jte)}ro(QL,"onAnimationEnd"),ro(JL,"onAnimationIteration"),ro(eI,"onAnimationStart"),ro("dblclick","onDoubleClick"),ro("focusin","onFocus"),ro("focusout","onBlur"),ro(Jee,"onTransitionRun"),ro(ete,"onTransitionStart"),ro(tte,"onTransitionCancel"),ro(tI,"onTransitionEnd"),vt("onMouseEnter",["mouseout","mouseover"]),vt("onMouseLeave",["mouseout","mouseover"]),vt("onPointerEnter",["pointerout","pointerover"]),vt("onPointerLeave",["pointerout","pointerover"]),ht("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ht("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ht("onBeforeInput",["compositionend","keypress","textInput","paste"]),ht("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ht("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Cg="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(" "),Ute=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Cg));function S4(d,p){p=(p&4)!==0;for(var _=0;_<d.length;_++){var S=d[_],R=S.event;S=S.listeners;e:{var O=void 0;if(p)for(var q=S.length-1;0<=q;q--){var oe=S[q],Se=oe.instance,$e=oe.currentTarget;if(oe=oe.listener,Se!==O&&R.isPropagationStopped())break e;O=oe,R.currentTarget=$e;try{O(R)}catch(at){Iv(at)}R.currentTarget=null,O=Se}else for(q=0;q<S.length;q++){if(oe=S[q],Se=oe.instance,$e=oe.currentTarget,oe=oe.listener,Se!==O&&R.isPropagationStopped())break e;O=oe,R.currentTarget=$e;try{O(R)}catch(at){Iv(at)}R.currentTarget=null,O=Se}}}}function pn(d,p){var _=p[Oc];_===void 0&&(_=p[Oc]=new Set);var S=d+"__bubble";_.has(S)||(w4(p,d,2,!1),_.add(S))}function hA(d,p,_){var S=0;p&&(S|=4),w4(_,d,S,p)}var Sb="_reactListening"+Math.random().toString(36).slice(2);function pA(d){if(!d[Sb]){d[Sb]=!0,Me.forEach(function(_){_!=="selectionchange"&&(Ute.has(_)||hA(_,!1,d),hA(_,!0,d))});var p=d.nodeType===9?d:d.ownerDocument;p===null||p[Sb]||(p[Sb]=!0,hA("selectionchange",!1,p))}}function w4(d,p,_,S){switch(Q4(p)){case 2:var R=fne;break;case 8:R=hne;break;default:R=NA}_=R.bind(null,p,_,d),R=void 0,!OM||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(R=!0),S?R!==void 0?d.addEventListener(p,_,{capture:!0,passive:R}):d.addEventListener(p,_,!0):R!==void 0?d.addEventListener(p,_,{passive:R}):d.addEventListener(p,_,!1)}function mA(d,p,_,S,R){var O=S;if((p&1)===0&&(p&2)===0&&S!==null)e:for(;;){if(S===null)return;var q=S.tag;if(q===3||q===4){var oe=S.stateNode.containerInfo;if(oe===R)break;if(q===4)for(q=S.return;q!==null;){var Se=q.tag;if((Se===3||Se===4)&&q.stateNode.containerInfo===R)return;q=q.return}for(;oe!==null;){if(q=_t(oe),q===null)return;if(Se=q.tag,Se===5||Se===6||Se===26||Se===27){S=O=q;continue e}oe=oe.parentNode}}S=S.return}CL(function(){var $e=O,at=kM(_),ut=[];e:{var qe=nI.get(d);if(qe!==void 0){var rt=Dv,Rt=d;switch(d){case"keypress":if(Pv(_)===0)break e;case"keydown":case"keyup":rt=Pee;break;case"focusin":Rt="focus",rt=UM;break;case"focusout":Rt="blur",rt=UM;break;case"beforeblur":case"afterblur":rt=UM;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":rt=PL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":rt=bee;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":rt=Oee;break;case QL:case JL:case eI:rt=See;break;case tI:rt=Iee;break;case"scroll":case"scrollend":rt=xee;break;case"wheel":rt=Uee;break;case"copy":case"cut":case"paste":rt=Mee;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":rt=DL;break;case"toggle":case"beforetoggle":rt=zee}var Ht=(p&4)!==0,Fn=!Ht&&(d==="scroll"||d==="scrollend"),Oe=Ht?qe!==null?qe+"Capture":null:qe;Ht=[];for(var Ce=$e,He;Ce!==null;){var lt=Ce;if(He=lt.stateNode,lt=lt.tag,lt!==5&<!==26&<!==27||He===null||Oe===null||(lt=Ym(Ce,Oe),lt!=null&&Ht.push(Ng(Ce,lt,He))),Fn)break;Ce=Ce.return}0<Ht.length&&(qe=new rt(qe,Rt,null,_,at),ut.push({event:qe,listeners:Ht}))}}if((p&7)===0){e:{if(qe=d==="mouseover"||d==="pointerover",rt=d==="mouseout"||d==="pointerout",qe&&_!==PM&&(Rt=_.relatedTarget||_.fromElement)&&(_t(Rt)||Rt[to]))break e;if((rt||qe)&&(qe=at.window===at?at:(qe=at.ownerDocument)?qe.defaultView||qe.parentWindow:window,rt?(Rt=_.relatedTarget||_.toElement,rt=$e,Rt=Rt?_t(Rt):null,Rt!==null&&(Fn=s(Rt),Ht=Rt.tag,Rt!==Fn||Ht!==5&&Ht!==27&&Ht!==6)&&(Rt=null)):(rt=null,Rt=$e),rt!==Rt)){if(Ht=PL,lt="onMouseLeave",Oe="onMouseEnter",Ce="mouse",(d==="pointerout"||d==="pointerover")&&(Ht=DL,lt="onPointerLeave",Oe="onPointerEnter",Ce="pointer"),Fn=rt==null?qe:_e(rt),He=Rt==null?qe:_e(Rt),qe=new Ht(lt,Ce+"leave",rt,_,at),qe.target=Fn,qe.relatedTarget=He,lt=null,_t(at)===$e&&(Ht=new Ht(Oe,Ce+"enter",Rt,_,at),Ht.target=He,Ht.relatedTarget=Fn,lt=Ht),Fn=lt,rt&&Rt)t:{for(Ht=Fte,Oe=rt,Ce=Rt,He=0,lt=Oe;lt;lt=Ht(lt))He++;lt=0;for(var jt=Ce;jt;jt=Ht(jt))lt++;for(;0<He-lt;)Oe=Ht(Oe),He--;for(;0<lt-He;)Ce=Ht(Ce),lt--;for(;He--;){if(Oe===Ce||Ce!==null&&Oe===Ce.alternate){Ht=Oe;break t}Oe=Ht(Oe),Ce=Ht(Ce)}Ht=null}else Ht=null;rt!==null&&M4(ut,qe,rt,Ht,!1),Rt!==null&&Fn!==null&&M4(ut,Fn,Rt,Ht,!0)}}e:{if(qe=$e?_e($e):window,rt=qe.nodeName&&qe.nodeName.toLowerCase(),rt==="select"||rt==="input"&&qe.type==="file")var wn=BL;else if(FL(qe))if(HL)wn=Yee;else{wn=Xee;var Dt=qee}else rt=qe.nodeName,!rt||rt.toLowerCase()!=="input"||qe.type!=="checkbox"&&qe.type!=="radio"?$e&&RM($e.elementType)&&(wn=BL):wn=Kee;if(wn&&(wn=wn(d,$e))){zL(ut,wn,_,at);break e}Dt&&Dt(d,qe,$e),d==="focusout"&&$e&&qe.type==="number"&&$e.memoizedProps.value!=null&&vi(qe,"number",qe.value)}switch(Dt=$e?_e($e):window,d){case"focusin":(FL(Dt)||Dt.contentEditable==="true")&&(rh=Dt,VM=$e,ig=null);break;case"focusout":ig=VM=rh=null;break;case"mousedown":GM=!0;break;case"contextmenu":case"mouseup":case"dragend":GM=!1,YL(ut,_,at);break;case"selectionchange":if(Qee)break;case"keydown":case"keyup":YL(ut,_,at)}var en;if(zM)e:{switch(d){case"compositionstart":var vn="onCompositionStart";break e;case"compositionend":vn="onCompositionEnd";break e;case"compositionupdate":vn="onCompositionUpdate";break e}vn=void 0}else nh?jL(d,_)&&(vn="onCompositionEnd"):d==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(OL&&_.locale!=="ko"&&(nh||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&nh&&(en=NL()):(Lc=at,LM="value"in Lc?Lc.value:Lc.textContent,nh=!0)),Dt=wb($e,vn),0<Dt.length&&(vn=new kL(vn,d,null,_,at),ut.push({event:vn,listeners:Dt}),en?vn.data=en:(en=UL(_),en!==null&&(vn.data=en)))),(en=Hee?$ee(d,_):Vee(d,_))&&(vn=wb($e,"onBeforeInput"),0<vn.length&&(Dt=new kL("onBeforeInput","beforeinput",null,_,at),ut.push({event:Dt,listeners:vn}),Dt.data=en)),Lte(ut,d,$e,_,at)}S4(ut,p)})}function Ng(d,p,_){return{instance:d,listener:p,currentTarget:_}}function wb(d,p){for(var _=p+"Capture",S=[];d!==null;){var R=d,O=R.stateNode;if(R=R.tag,R!==5&&R!==26&&R!==27||O===null||(R=Ym(d,_),R!=null&&S.unshift(Ng(d,R,O)),R=Ym(d,p),R!=null&&S.push(Ng(d,R,O))),d.tag===3)return S;d=d.return}return[]}function Fte(d){if(d===null)return null;do d=d.return;while(d&&d.tag!==5&&d.tag!==27);return d||null}function M4(d,p,_,S,R){for(var O=p._reactName,q=[];_!==null&&_!==S;){var oe=_,Se=oe.alternate,$e=oe.stateNode;if(oe=oe.tag,Se!==null&&Se===S)break;oe!==5&&oe!==26&&oe!==27||$e===null||(Se=$e,R?($e=Ym(_,O),$e!=null&&q.unshift(Ng(_,$e,Se))):R||($e=Ym(_,O),$e!=null&&q.push(Ng(_,$e,Se)))),_=_.return}q.length!==0&&d.push({event:p,listeners:q})}var zte=/\r\n?/g,Bte=/\u0000|\uFFFD/g;function E4(d){return(typeof d=="string"?d:""+d).replace(zte,`
- `).replace(Bte,"")}function A4(d,p){return p=E4(p),E4(d)===p}function Un(d,p,_,S,R,O){switch(_){case"children":typeof S=="string"?p==="body"||p==="textarea"&&S===""||ko(d,S):(typeof S=="number"||typeof S=="bigint")&&p!=="body"&&ko(d,""+S);break;case"className":It(d,"class",S);break;case"tabIndex":It(d,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":It(d,_,S);break;case"style":AL(d,S,O);break;case"data":if(p!=="object"){It(d,"data",S);break}case"src":case"href":if(S===""&&(p!=="a"||_!=="href")){d.removeAttribute(_);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(_);break}S=Nv(""+S),d.setAttribute(_,S);break;case"action":case"formAction":if(typeof S=="function"){d.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(_==="formAction"?(p!=="input"&&Un(d,p,"name",R.name,R,null),Un(d,p,"formEncType",R.formEncType,R,null),Un(d,p,"formMethod",R.formMethod,R,null),Un(d,p,"formTarget",R.formTarget,R,null)):(Un(d,p,"encType",R.encType,R,null),Un(d,p,"method",R.method,R,null),Un(d,p,"target",R.target,R,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(_);break}S=Nv(""+S),d.setAttribute(_,S);break;case"onClick":S!=null&&(d.onclick=pl);break;case"onScroll":S!=null&&pn("scroll",d);break;case"onScrollEnd":S!=null&&pn("scrollend",d);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(R.children!=null)throw Error(r(60));d.innerHTML=_}}break;case"multiple":d.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":d.muted=S&&typeof S!="function"&&typeof S!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(S==null||typeof S=="function"||typeof S=="boolean"||typeof S=="symbol"){d.removeAttribute("xlink:href");break}_=Nv(""+S),d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":S!=null&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(_,""+S):d.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":S&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(_,""):d.removeAttribute(_);break;case"capture":case"download":S===!0?d.setAttribute(_,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(_,S):d.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?d.setAttribute(_,S):d.removeAttribute(_);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?d.removeAttribute(_):d.setAttribute(_,S);break;case"popover":pn("beforetoggle",d),pn("toggle",d),qt(d,"popover",S);break;case"xlinkActuate":nn(d,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":nn(d,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":nn(d,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":nn(d,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":nn(d,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":nn(d,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":nn(d,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":nn(d,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":nn(d,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":qt(d,"is",S);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=mee.get(_)||_,qt(d,_,S))}}function gA(d,p,_,S,R,O){switch(_){case"style":AL(d,S,O);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(r(61));if(_=S.__html,_!=null){if(R.children!=null)throw Error(r(60));d.innerHTML=_}}break;case"children":typeof S=="string"?ko(d,S):(typeof S=="number"||typeof S=="bigint")&&ko(d,""+S);break;case"onScroll":S!=null&&pn("scroll",d);break;case"onScrollEnd":S!=null&&pn("scrollend",d);break;case"onClick":S!=null&&(d.onclick=pl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!st.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(R=_.endsWith("Capture"),p=_.slice(2,R?_.length-7:void 0),O=d[Cr]||null,O=O!=null?O[_]:null,typeof O=="function"&&d.removeEventListener(p,O,R),typeof S=="function")){typeof O!="function"&&O!==null&&(_ in d?d[_]=null:d.hasAttribute(_)&&d.removeAttribute(_)),d.addEventListener(p,S,R);break e}_ in d?d[_]=S:S===!0?d.setAttribute(_,""):qt(d,_,S)}}}function Ui(d,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":pn("error",d),pn("load",d);var S=!1,R=!1,O;for(O in _)if(_.hasOwnProperty(O)){var q=_[O];if(q!=null)switch(O){case"src":S=!0;break;case"srcSet":R=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(d,p,O,q,_,null)}}R&&Un(d,p,"srcSet",_.srcSet,_,null),S&&Un(d,p,"src",_.src,_,null);return;case"input":pn("invalid",d);var oe=O=q=R=null,Se=null,$e=null;for(S in _)if(_.hasOwnProperty(S)){var at=_[S];if(at!=null)switch(S){case"name":R=at;break;case"type":q=at;break;case"checked":Se=at;break;case"defaultChecked":$e=at;break;case"value":O=at;break;case"defaultValue":oe=at;break;case"children":case"dangerouslySetInnerHTML":if(at!=null)throw Error(r(137,p));break;default:Un(d,p,S,at,_,null)}}kn(d,O,oe,Se,$e,q,R,!1);return;case"select":pn("invalid",d),S=q=O=null;for(R in _)if(_.hasOwnProperty(R)&&(oe=_[R],oe!=null))switch(R){case"value":O=oe;break;case"defaultValue":q=oe;break;case"multiple":S=oe;default:Un(d,p,R,oe,_,null)}p=O,_=q,d.multiple=!!S,p!=null?ei(d,!!S,p,!1):_!=null&&ei(d,!!S,_,!0);return;case"textarea":pn("invalid",d),O=R=S=null;for(q in _)if(_.hasOwnProperty(q)&&(oe=_[q],oe!=null))switch(q){case"value":S=oe;break;case"defaultValue":R=oe;break;case"children":O=oe;break;case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(91));break;default:Un(d,p,q,oe,_,null)}Oi(d,S,R,O);return;case"option":for(Se in _)if(_.hasOwnProperty(Se)&&(S=_[Se],S!=null))switch(Se){case"selected":d.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:Un(d,p,Se,S,_,null)}return;case"dialog":pn("beforetoggle",d),pn("toggle",d),pn("cancel",d),pn("close",d);break;case"iframe":case"object":pn("load",d);break;case"video":case"audio":for(S=0;S<Cg.length;S++)pn(Cg[S],d);break;case"image":pn("error",d),pn("load",d);break;case"details":pn("toggle",d);break;case"embed":case"source":case"link":pn("error",d),pn("load",d);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for($e in _)if(_.hasOwnProperty($e)&&(S=_[$e],S!=null))switch($e){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Un(d,p,$e,S,_,null)}return;default:if(RM(p)){for(at in _)_.hasOwnProperty(at)&&(S=_[at],S!==void 0&&gA(d,p,at,S,_,void 0));return}}for(oe in _)_.hasOwnProperty(oe)&&(S=_[oe],S!=null&&Un(d,p,oe,S,_,null))}function Hte(d,p,_,S){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var R=null,O=null,q=null,oe=null,Se=null,$e=null,at=null;for(rt in _){var ut=_[rt];if(_.hasOwnProperty(rt)&&ut!=null)switch(rt){case"checked":break;case"value":break;case"defaultValue":Se=ut;default:S.hasOwnProperty(rt)||Un(d,p,rt,null,S,ut)}}for(var qe in S){var rt=S[qe];if(ut=_[qe],S.hasOwnProperty(qe)&&(rt!=null||ut!=null))switch(qe){case"type":O=rt;break;case"name":R=rt;break;case"checked":$e=rt;break;case"defaultChecked":at=rt;break;case"value":q=rt;break;case"defaultValue":oe=rt;break;case"children":case"dangerouslySetInnerHTML":if(rt!=null)throw Error(r(137,p));break;default:rt!==ut&&Un(d,p,qe,rt,S,ut)}}no(d,q,oe,Se,$e,at,O,R);return;case"select":rt=q=oe=qe=null;for(O in _)if(Se=_[O],_.hasOwnProperty(O)&&Se!=null)switch(O){case"value":break;case"multiple":rt=Se;default:S.hasOwnProperty(O)||Un(d,p,O,null,S,Se)}for(R in S)if(O=S[R],Se=_[R],S.hasOwnProperty(R)&&(O!=null||Se!=null))switch(R){case"value":qe=O;break;case"defaultValue":oe=O;break;case"multiple":q=O;default:O!==Se&&Un(d,p,R,O,S,Se)}p=oe,_=q,S=rt,qe!=null?ei(d,!!_,qe,!1):!!S!=!!_&&(p!=null?ei(d,!!_,p,!0):ei(d,!!_,_?[]:"",!1));return;case"textarea":rt=qe=null;for(oe in _)if(R=_[oe],_.hasOwnProperty(oe)&&R!=null&&!S.hasOwnProperty(oe))switch(oe){case"value":break;case"children":break;default:Un(d,p,oe,null,S,R)}for(q in S)if(R=S[q],O=_[q],S.hasOwnProperty(q)&&(R!=null||O!=null))switch(q){case"value":qe=R;break;case"defaultValue":rt=R;break;case"children":break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(r(91));break;default:R!==O&&Un(d,p,q,R,S,O)}bi(d,qe,rt);return;case"option":for(var Rt in _)if(qe=_[Rt],_.hasOwnProperty(Rt)&&qe!=null&&!S.hasOwnProperty(Rt))switch(Rt){case"selected":d.selected=!1;break;default:Un(d,p,Rt,null,S,qe)}for(Se in S)if(qe=S[Se],rt=_[Se],S.hasOwnProperty(Se)&&qe!==rt&&(qe!=null||rt!=null))switch(Se){case"selected":d.selected=qe&&typeof qe!="function"&&typeof qe!="symbol";break;default:Un(d,p,Se,qe,S,rt)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ht in _)qe=_[Ht],_.hasOwnProperty(Ht)&&qe!=null&&!S.hasOwnProperty(Ht)&&Un(d,p,Ht,null,S,qe);for($e in S)if(qe=S[$e],rt=_[$e],S.hasOwnProperty($e)&&qe!==rt&&(qe!=null||rt!=null))switch($e){case"children":case"dangerouslySetInnerHTML":if(qe!=null)throw Error(r(137,p));break;default:Un(d,p,$e,qe,S,rt)}return;default:if(RM(p)){for(var Fn in _)qe=_[Fn],_.hasOwnProperty(Fn)&&qe!==void 0&&!S.hasOwnProperty(Fn)&&gA(d,p,Fn,void 0,S,qe);for(at in S)qe=S[at],rt=_[at],!S.hasOwnProperty(at)||qe===rt||qe===void 0&&rt===void 0||gA(d,p,at,qe,S,rt);return}}for(var Oe in _)qe=_[Oe],_.hasOwnProperty(Oe)&&qe!=null&&!S.hasOwnProperty(Oe)&&Un(d,p,Oe,null,S,qe);for(ut in S)qe=S[ut],rt=_[ut],!S.hasOwnProperty(ut)||qe===rt||qe==null&&rt==null||Un(d,p,ut,qe,S,rt)}function T4(d){switch(d){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function $te(){if(typeof performance.getEntriesByType=="function"){for(var d=0,p=0,_=performance.getEntriesByType("resource"),S=0;S<_.length;S++){var R=_[S],O=R.transferSize,q=R.initiatorType,oe=R.duration;if(O&&oe&&T4(q)){for(q=0,oe=R.responseEnd,S+=1;S<_.length;S++){var Se=_[S],$e=Se.startTime;if($e>oe)break;var at=Se.transferSize,ut=Se.initiatorType;at&&T4(ut)&&(Se=Se.responseEnd,q+=at*(Se<oe?1:(oe-$e)/(Se-$e)))}if(--S,p+=8*(O+q)/(R.duration/1e3),d++,10<d)break}}if(0<d)return p/d/1e6}return navigator.connection&&(d=navigator.connection.downlink,typeof d=="number")?d:5}var xA=null,vA=null;function Mb(d){return d.nodeType===9?d:d.ownerDocument}function C4(d){switch(d){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function N4(d,p){if(d===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return d===1&&p==="foreignObject"?0:d}function bA(d,p){return d==="textarea"||d==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.children=="bigint"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var yA=null;function Vte(){var d=window.event;return d&&d.type==="popstate"?d===yA?!1:(yA=d,!0):(yA=null,!1)}var R4=typeof setTimeout=="function"?setTimeout:void 0,Gte=typeof clearTimeout=="function"?clearTimeout:void 0,P4=typeof Promise=="function"?Promise:void 0,Wte=typeof queueMicrotask=="function"?queueMicrotask:typeof P4<"u"?function(d){return P4.resolve(null).then(d).catch(qte)}:R4;function qte(d){setTimeout(function(){throw d})}function Qc(d){return d==="head"}function k4(d,p){var _=p,S=0;do{var R=_.nextSibling;if(d.removeChild(_),R&&R.nodeType===8)if(_=R.data,_==="/$"||_==="/&"){if(S===0){d.removeChild(R),Rh(p);return}S--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")S++;else if(_==="html")Rg(d.ownerDocument.documentElement);else if(_==="head"){_=d.ownerDocument.head,Rg(_);for(var O=_.firstChild;O;){var q=O.nextSibling,oe=O.nodeName;O[nt]||oe==="SCRIPT"||oe==="STYLE"||oe==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=q}}else _==="body"&&Rg(d.ownerDocument.body);_=R}while(_);Rh(p)}function D4(d,p){var _=d;d=0;do{var S=_.nextSibling;if(_.nodeType===1?p?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(p?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),S&&S.nodeType===8)if(_=S.data,_==="/$"){if(d===0)break;d--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||d++;_=S}while(_)}function _A(d){var p=d.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":_A(_),Ze(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}d.removeChild(_)}}function Xte(d,p,_,S){for(;d.nodeType===1;){var R=_;if(d.nodeName.toLowerCase()!==p.toLowerCase()){if(!S&&(d.nodeName!=="INPUT"||d.type!=="hidden"))break}else if(S){if(!d[nt])switch(p){case"meta":if(!d.hasAttribute("itemprop"))break;return d;case"link":if(O=d.getAttribute("rel"),O==="stylesheet"&&d.hasAttribute("data-precedence"))break;if(O!==R.rel||d.getAttribute("href")!==(R.href==null||R.href===""?null:R.href)||d.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin)||d.getAttribute("title")!==(R.title==null?null:R.title))break;return d;case"style":if(d.hasAttribute("data-precedence"))break;return d;case"script":if(O=d.getAttribute("src"),(O!==(R.src==null?null:R.src)||d.getAttribute("type")!==(R.type==null?null:R.type)||d.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin))&&O&&d.hasAttribute("async")&&!d.hasAttribute("itemprop"))break;return d;default:return d}}else if(p==="input"&&d.type==="hidden"){var O=R.name==null?null:""+R.name;if(R.type==="hidden"&&d.getAttribute("name")===O)return d}else return d;if(d=Ma(d.nextSibling),d===null)break}return null}function Kte(d,p,_){if(p==="")return null;for(;d.nodeType!==3;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!_||(d=Ma(d.nextSibling),d===null))return null;return d}function O4(d,p){for(;d.nodeType!==8;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!p||(d=Ma(d.nextSibling),d===null))return null;return d}function SA(d){return d.data==="$?"||d.data==="$~"}function wA(d){return d.data==="$!"||d.data==="$?"&&d.ownerDocument.readyState!=="loading"}function Yte(d,p){var _=d.ownerDocument;if(d.data==="$~")d._reactRetry=p;else if(d.data!=="$?"||_.readyState!=="loading")p();else{var S=function(){p(),_.removeEventListener("DOMContentLoaded",S)};_.addEventListener("DOMContentLoaded",S),d._reactRetry=S}}function Ma(d){for(;d!=null;d=d.nextSibling){var p=d.nodeType;if(p===1||p===3)break;if(p===8){if(p=d.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return d}var MA=null;function L4(d){d=d.nextSibling;for(var p=0;d;){if(d.nodeType===8){var _=d.data;if(_==="/$"||_==="/&"){if(p===0)return Ma(d.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}d=d.nextSibling}return null}function I4(d){d=d.previousSibling;for(var p=0;d;){if(d.nodeType===8){var _=d.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return d;p--}else _!=="/$"&&_!=="/&"||p++}d=d.previousSibling}return null}function j4(d,p,_){switch(p=Mb(_),d){case"html":if(d=p.documentElement,!d)throw Error(r(452));return d;case"head":if(d=p.head,!d)throw Error(r(453));return d;case"body":if(d=p.body,!d)throw Error(r(454));return d;default:throw Error(r(451))}}function Rg(d){for(var p=d.attributes;p.length;)d.removeAttributeNode(p[0]);Ze(d)}var Ea=new Map,U4=new Set;function Eb(d){return typeof d.getRootNode=="function"?d.getRootNode():d.nodeType===9?d:d.ownerDocument}var Rl=V.d;V.d={f:Zte,r:Qte,D:Jte,C:ene,L:tne,m:nne,X:ine,S:rne,M:sne};function Zte(){var d=Rl.f(),p=gb();return d||p}function Qte(d){var p=re(d);p!==null&&p.tag===5&&p.type==="form"?tj(p):Rl.r(d)}var Th=typeof document>"u"?null:document;function F4(d,p,_){var S=Th;if(S&&typeof p=="string"&&p){var R=Nn(p);R='link[rel="'+d+'"][href="'+R+'"]',typeof _=="string"&&(R+='[crossorigin="'+_+'"]'),U4.has(R)||(U4.add(R),d={rel:d,crossOrigin:_,href:p},S.querySelector(R)===null&&(p=S.createElement("link"),Ui(p,"link",d),Pe(p),S.head.appendChild(p)))}}function Jte(d){Rl.D(d),F4("dns-prefetch",d,null)}function ene(d,p){Rl.C(d,p),F4("preconnect",d,p)}function tne(d,p,_){Rl.L(d,p,_);var S=Th;if(S&&d&&p){var R='link[rel="preload"][as="'+Nn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(R+='[imagesrcset="'+Nn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(R+='[imagesizes="'+Nn(_.imageSizes)+'"]')):R+='[href="'+Nn(d)+'"]';var O=R;switch(p){case"style":O=Ch(d);break;case"script":O=Nh(d)}Ea.has(O)||(d=h({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:d,as:p},_),Ea.set(O,d),S.querySelector(R)!==null||p==="style"&&S.querySelector(Pg(O))||p==="script"&&S.querySelector(kg(O))||(p=S.createElement("link"),Ui(p,"link",d),Pe(p),S.head.appendChild(p)))}}function nne(d,p){Rl.m(d,p);var _=Th;if(_&&d){var S=p&&typeof p.as=="string"?p.as:"script",R='link[rel="modulepreload"][as="'+Nn(S)+'"][href="'+Nn(d)+'"]',O=R;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=Nh(d)}if(!Ea.has(O)&&(d=h({rel:"modulepreload",href:d},p),Ea.set(O,d),_.querySelector(R)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(kg(O)))return}S=_.createElement("link"),Ui(S,"link",d),Pe(S),_.head.appendChild(S)}}}function rne(d,p,_){Rl.S(d,p,_);var S=Th;if(S&&d){var R=ke(S).hoistableStyles,O=Ch(d);p=p||"default";var q=R.get(O);if(!q){var oe={loading:0,preload:null};if(q=S.querySelector(Pg(O)))oe.loading=5;else{d=h({rel:"stylesheet",href:d,"data-precedence":p},_),(_=Ea.get(O))&&EA(d,_);var Se=q=S.createElement("link");Pe(Se),Ui(Se,"link",d),Se._p=new Promise(function($e,at){Se.onload=$e,Se.onerror=at}),Se.addEventListener("load",function(){oe.loading|=1}),Se.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,Ab(q,p,S)}q={type:"stylesheet",instance:q,count:1,state:oe},R.set(O,q)}}}function ine(d,p){Rl.X(d,p);var _=Th;if(_&&d){var S=ke(_).hoistableScripts,R=Nh(d),O=S.get(R);O||(O=_.querySelector(kg(R)),O||(d=h({src:d,async:!0},p),(p=Ea.get(R))&&AA(d,p),O=_.createElement("script"),Pe(O),Ui(O,"link",d),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(R,O))}}function sne(d,p){Rl.M(d,p);var _=Th;if(_&&d){var S=ke(_).hoistableScripts,R=Nh(d),O=S.get(R);O||(O=_.querySelector(kg(R)),O||(d=h({src:d,async:!0,type:"module"},p),(p=Ea.get(R))&&AA(d,p),O=_.createElement("script"),Pe(O),Ui(O,"link",d),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(R,O))}}function z4(d,p,_,S){var R=(R=Q.current)?Eb(R):null;if(!R)throw Error(r(446));switch(d){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Ch(_.href),_=ke(R).hoistableStyles,S=_.get(p),S||(S={type:"style",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){d=Ch(_.href);var O=ke(R).hoistableStyles,q=O.get(d);if(q||(R=R.ownerDocument||R,q={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(d,q),(O=R.querySelector(Pg(d)))&&!O._p&&(q.instance=O,q.state.loading=5),Ea.has(d)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Ea.set(d,_),O||ane(R,d,_,q.state))),p&&S===null)throw Error(r(528,""));return q}if(p&&S!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=Nh(_),_=ke(R).hoistableScripts,S=_.get(p),S||(S={type:"script",instance:null,count:0,state:null},_.set(p,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,d))}}function Ch(d){return'href="'+Nn(d)+'"'}function Pg(d){return'link[rel="stylesheet"]['+d+"]"}function B4(d){return h({},d,{"data-precedence":d.precedence,precedence:null})}function ane(d,p,_,S){d.querySelector('link[rel="preload"][as="style"]['+p+"]")?S.loading=1:(p=d.createElement("link"),S.preload=p,p.addEventListener("load",function(){return S.loading|=1}),p.addEventListener("error",function(){return S.loading|=2}),Ui(p,"link",_),Pe(p),d.head.appendChild(p))}function Nh(d){return'[src="'+Nn(d)+'"]'}function kg(d){return"script[async]"+d}function H4(d,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var S=d.querySelector('style[data-href~="'+Nn(_.href)+'"]');if(S)return p.instance=S,Pe(S),S;var R=h({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return S=(d.ownerDocument||d).createElement("style"),Pe(S),Ui(S,"style",R),Ab(S,_.precedence,d),p.instance=S;case"stylesheet":R=Ch(_.href);var O=d.querySelector(Pg(R));if(O)return p.state.loading|=4,p.instance=O,Pe(O),O;S=B4(_),(R=Ea.get(R))&&EA(S,R),O=(d.ownerDocument||d).createElement("link"),Pe(O);var q=O;return q._p=new Promise(function(oe,Se){q.onload=oe,q.onerror=Se}),Ui(O,"link",S),p.state.loading|=4,Ab(O,_.precedence,d),p.instance=O;case"script":return O=Nh(_.src),(R=d.querySelector(kg(O)))?(p.instance=R,Pe(R),R):(S=_,(R=Ea.get(O))&&(S=h({},_),AA(S,R)),d=d.ownerDocument||d,R=d.createElement("script"),Pe(R),Ui(R,"link",S),d.head.appendChild(R),p.instance=R);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(S=p.instance,p.state.loading|=4,Ab(S,_.precedence,d));return p.instance}function Ab(d,p,_){for(var S=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),R=S.length?S[S.length-1]:null,O=R,q=0;q<S.length;q++){var oe=S[q];if(oe.dataset.precedence===p)O=oe;else if(O!==R)break}O?O.parentNode.insertBefore(d,O.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(d,p.firstChild))}function EA(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.title==null&&(d.title=p.title)}function AA(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.integrity==null&&(d.integrity=p.integrity)}var Tb=null;function $4(d,p,_){if(Tb===null){var S=new Map,R=Tb=new Map;R.set(_,S)}else R=Tb,S=R.get(_),S||(S=new Map,R.set(_,S));if(S.has(d))return S;for(S.set(d,null),_=_.getElementsByTagName(d),R=0;R<_.length;R++){var O=_[R];if(!(O[nt]||O[pr]||d==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var q=O.getAttribute(p)||"";q=d+q;var oe=S.get(q);oe?oe.push(O):S.set(q,[O])}}return S}function V4(d,p,_){d=d.ownerDocument||d,d.head.insertBefore(_,p==="title"?d.querySelector("head > title"):null)}function one(d,p,_){if(_===1||p.itemProp!=null)return!1;switch(d){case"meta":case"title":return!0;case"style":if(typeof p.precedence!="string"||typeof p.href!="string"||p.href==="")break;return!0;case"link":if(typeof p.rel!="string"||typeof p.href!="string"||p.href===""||p.onLoad||p.onError)break;switch(p.rel){case"stylesheet":return d=p.disabled,typeof p.precedence=="string"&&d==null;default:return!0}case"script":if(p.async&&typeof p.async!="function"&&typeof p.async!="symbol"&&!p.onLoad&&!p.onError&&p.src&&typeof p.src=="string")return!0}return!1}function G4(d){return!(d.type==="stylesheet"&&(d.state.loading&3)===0)}function lne(d,p,_,S){if(_.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var R=Ch(S.href),O=p.querySelector(Pg(R));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(d.count++,d=Cb.bind(d),p.then(d,d)),_.state.loading|=4,_.instance=O,Pe(O);return}O=p.ownerDocument||p,S=B4(S),(R=Ea.get(R))&&EA(S,R),O=O.createElement("link"),Pe(O);var q=O;q._p=new Promise(function(oe,Se){q.onload=oe,q.onerror=Se}),Ui(O,"link",S),_.instance=O}d.stylesheets===null&&(d.stylesheets=new Map),d.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(d.count++,_=Cb.bind(d),p.addEventListener("load",_),p.addEventListener("error",_))}}var TA=0;function cne(d,p){return d.stylesheets&&d.count===0&&Rb(d,d.stylesheets),0<d.count||0<d.imgCount?function(_){var S=setTimeout(function(){if(d.stylesheets&&Rb(d,d.stylesheets),d.unsuspend){var O=d.unsuspend;d.unsuspend=null,O()}},6e4+p);0<d.imgBytes&&TA===0&&(TA=62500*$te());var R=setTimeout(function(){if(d.waitingForImages=!1,d.count===0&&(d.stylesheets&&Rb(d,d.stylesheets),d.unsuspend)){var O=d.unsuspend;d.unsuspend=null,O()}},(d.imgBytes>TA?50:800)+p);return d.unsuspend=_,function(){d.unsuspend=null,clearTimeout(S),clearTimeout(R)}}:null}function Cb(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Rb(this,this.stylesheets);else if(this.unsuspend){var d=this.unsuspend;this.unsuspend=null,d()}}}var Nb=null;function Rb(d,p){d.stylesheets=null,d.unsuspend!==null&&(d.count++,Nb=new Map,p.forEach(une,d),Nb=null,Cb.call(d))}function une(d,p){if(!(p.state.loading&4)){var _=Nb.get(d);if(_)var S=_.get(null);else{_=new Map,Nb.set(d,_);for(var R=d.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<R.length;O++){var q=R[O];(q.nodeName==="LINK"||q.getAttribute("media")!=="not all")&&(_.set(q.dataset.precedence,q),S=q)}S&&_.set(null,S)}R=p.instance,q=R.getAttribute("data-precedence"),O=_.get(q)||S,O===S&&_.set(null,R),_.set(q,R),this.count++,S=Cb.bind(this),R.addEventListener("load",S),R.addEventListener("error",S),O?O.parentNode.insertBefore(R,O.nextSibling):(d=d.nodeType===9?d.head:d,d.insertBefore(R,d.firstChild)),p.state.loading|=4}}var Dg={$$typeof:w,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function dne(d,p,_,S,R,O,q,oe,Se){this.tag=1,this.containerInfo=d,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pt(0),this.hiddenUpdates=Pt(null),this.identifierPrefix=S,this.onUncaughtError=R,this.onCaughtError=O,this.onRecoverableError=q,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Se,this.incompleteTransitions=new Map}function W4(d,p,_,S,R,O,q,oe,Se,$e,at,ut){return d=new dne(d,p,_,q,Se,$e,at,ut,oe),p=1,O===!0&&(p|=24),O=Zs(3,null,null,p),d.current=O,O.stateNode=d,p=aE(),p.refCount++,d.pooledCache=p,p.refCount++,O.memoizedState={element:S,isDehydrated:_,cache:p},uE(O),d}function q4(d){return d?(d=ah,d):ah}function X4(d,p,_,S,R,O){R=q4(R),S.context===null?S.context=R:S.pendingContext=R,S=Bc(p),S.payload={element:_},O=O===void 0?null:O,O!==null&&(S.callback=O),_=Hc(d,S,p),_!==null&&(Ds(_,d,p),dg(_,d,p))}function K4(d,p){if(d=d.memoizedState,d!==null&&d.dehydrated!==null){var _=d.retryLane;d.retryLane=_!==0&&_<p?_:p}}function CA(d,p){K4(d,p),(d=d.alternate)&&K4(d,p)}function Y4(d){if(d.tag===13||d.tag===31){var p=vd(d,67108864);p!==null&&Ds(p,d,67108864),CA(d,67108864)}}function Z4(d){if(d.tag===13||d.tag===31){var p=na();p=Jr(p);var _=vd(d,p);_!==null&&Ds(_,d,p),CA(d,p)}}var Pb=!0;function fne(d,p,_,S){var R=G.T;G.T=null;var O=V.p;try{V.p=2,NA(d,p,_,S)}finally{V.p=O,G.T=R}}function hne(d,p,_,S){var R=G.T;G.T=null;var O=V.p;try{V.p=8,NA(d,p,_,S)}finally{V.p=O,G.T=R}}function NA(d,p,_,S){if(Pb){var R=RA(S);if(R===null)mA(d,p,S,kb,_),J4(d,S);else if(mne(R,d,p,_,S))S.stopPropagation();else if(J4(d,S),p&4&&-1<pne.indexOf(d)){for(;R!==null;){var O=re(R);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var q=Te(O.pendingLanes);if(q!==0){var oe=O;for(oe.pendingLanes|=2,oe.entangledLanes|=2;q;){var Se=1<<31-Be(q);oe.entanglements[1]|=Se,q&=~Se}Io(O),(Cn&6)===0&&(pb=L()+500,Tg(0))}}break;case 31:case 13:oe=vd(O,2),oe!==null&&Ds(oe,O,2),gb(),CA(O,2)}if(O=RA(S),O===null&&mA(d,p,S,kb,_),O===R)break;R=O}R!==null&&S.stopPropagation()}else mA(d,p,S,null,_)}}function RA(d){return d=kM(d),PA(d)}var kb=null;function PA(d){if(kb=null,d=_t(d),d!==null){var p=s(d);if(p===null)d=null;else{var _=p.tag;if(_===13){if(d=a(p),d!==null)return d;d=null}else if(_===31){if(d=o(p),d!==null)return d;d=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;d=null}else p!==d&&(d=null)}}return kb=d,null}function Q4(d){switch(d){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ne()){case ve:return 2;case ye:return 8;case xe:case tt:return 32;case je:return 268435456;default:return 32}default:return 32}}var kA=!1,Jc=null,eu=null,tu=null,Og=new Map,Lg=new Map,nu=[],pne="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 J4(d,p){switch(d){case"focusin":case"focusout":Jc=null;break;case"dragenter":case"dragleave":eu=null;break;case"mouseover":case"mouseout":tu=null;break;case"pointerover":case"pointerout":Og.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Lg.delete(p.pointerId)}}function Ig(d,p,_,S,R,O){return d===null||d.nativeEvent!==O?(d={blockedOn:p,domEventName:_,eventSystemFlags:S,nativeEvent:O,targetContainers:[R]},p!==null&&(p=re(p),p!==null&&Y4(p)),d):(d.eventSystemFlags|=S,p=d.targetContainers,R!==null&&p.indexOf(R)===-1&&p.push(R),d)}function mne(d,p,_,S,R){switch(p){case"focusin":return Jc=Ig(Jc,d,p,_,S,R),!0;case"dragenter":return eu=Ig(eu,d,p,_,S,R),!0;case"mouseover":return tu=Ig(tu,d,p,_,S,R),!0;case"pointerover":var O=R.pointerId;return Og.set(O,Ig(Og.get(O)||null,d,p,_,S,R)),!0;case"gotpointercapture":return O=R.pointerId,Lg.set(O,Ig(Lg.get(O)||null,d,p,_,S,R)),!0}return!1}function eU(d){var p=_t(d.target);if(p!==null){var _=s(p);if(_!==null){if(p=_.tag,p===13){if(p=a(_),p!==null){d.blockedOn=p,Yi(d.priority,function(){Z4(_)});return}}else if(p===31){if(p=o(_),p!==null){d.blockedOn=p,Yi(d.priority,function(){Z4(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){d.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}d.blockedOn=null}function Db(d){if(d.blockedOn!==null)return!1;for(var p=d.targetContainers;0<p.length;){var _=RA(d.nativeEvent);if(_===null){_=d.nativeEvent;var S=new _.constructor(_.type,_);PM=S,_.target.dispatchEvent(S),PM=null}else return p=re(_),p!==null&&Y4(p),d.blockedOn=_,!1;p.shift()}return!0}function tU(d,p,_){Db(d)&&_.delete(p)}function gne(){kA=!1,Jc!==null&&Db(Jc)&&(Jc=null),eu!==null&&Db(eu)&&(eu=null),tu!==null&&Db(tu)&&(tu=null),Og.forEach(tU),Lg.forEach(tU)}function Ob(d,p){d.blockedOn===p&&(d.blockedOn=null,kA||(kA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,gne)))}var Lb=null;function nU(d){Lb!==d&&(Lb=d,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Lb===d&&(Lb=null);for(var p=0;p<d.length;p+=3){var _=d[p],S=d[p+1],R=d[p+2];if(typeof S!="function"){if(PA(S||_)===null)continue;break}var O=re(_);O!==null&&(d.splice(p,3),p-=3,RE(O,{pending:!0,data:R,method:_.method,action:S},S,R))}}))}function Rh(d){function p(Se){return Ob(Se,d)}Jc!==null&&Ob(Jc,d),eu!==null&&Ob(eu,d),tu!==null&&Ob(tu,d),Og.forEach(p),Lg.forEach(p);for(var _=0;_<nu.length;_++){var S=nu[_];S.blockedOn===d&&(S.blockedOn=null)}for(;0<nu.length&&(_=nu[0],_.blockedOn===null);)eU(_),_.blockedOn===null&&nu.shift();if(_=(d.ownerDocument||d).$$reactFormReplay,_!=null)for(S=0;S<_.length;S+=3){var R=_[S],O=_[S+1],q=R[Cr]||null;if(typeof O=="function")q||nU(_);else if(q){var oe=null;if(O&&O.hasAttribute("formAction")){if(R=O,q=O[Cr]||null)oe=q.formAction;else if(PA(R)!==null)continue}else oe=q.action;typeof oe=="function"?_[S+1]=oe:(_.splice(S,3),S-=3),nU(_)}}}function rU(){function d(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(q){return R=q})},focusReset:"manual",scroll:"manual"})}function p(){R!==null&&(R(),R=null),S||setTimeout(_,20)}function _(){if(!S&&!navigation.transition){var O=navigation.currentEntry;O&&O.url!=null&&navigation.navigate(O.url,{state:O.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,R=null;return navigation.addEventListener("navigate",d),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){S=!0,navigation.removeEventListener("navigate",d),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),R!==null&&(R(),R=null)}}}function DA(d){this._internalRoot=d}Ib.prototype.render=DA.prototype.render=function(d){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,S=na();X4(_,S,d,p,null,null)},Ib.prototype.unmount=DA.prototype.unmount=function(){var d=this._internalRoot;if(d!==null){this._internalRoot=null;var p=d.containerInfo;X4(d.current,2,null,d,null,null),gb(),p[to]=null}};function Ib(d){this._internalRoot=d}Ib.prototype.unstable_scheduleHydration=function(d){if(d){var p=Di();d={blockedOn:null,target:d,priority:p};for(var _=0;_<nu.length&&p!==0&&p<nu[_].priority;_++);nu.splice(_,0,d),_===0&&eU(d)}};var iU=e.version;if(iU!=="19.2.0")throw Error(r(527,iU,"19.2.0"));V.findDOMNode=function(d){var p=d._reactInternals;if(p===void 0)throw typeof d.render=="function"?Error(r(188)):(d=Object.keys(d).join(","),Error(r(268,d)));return d=c(p),d=d!==null?u(d):null,d=d===null?null:d.stateNode,d};var xne={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jb=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jb.isDisabled&&jb.supportsFiber)try{Fe=jb.inject(xne),ce=jb}catch{}}return Ug.createRoot=function(d,p){if(!i(d))throw Error(r(299));var _=!1,S="",R=dj,O=fj,q=hj;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onUncaughtError!==void 0&&(R=p.onUncaughtError),p.onCaughtError!==void 0&&(O=p.onCaughtError),p.onRecoverableError!==void 0&&(q=p.onRecoverableError)),p=W4(d,1,!1,null,null,_,S,null,R,O,q,rU),d[to]=p.current,pA(d),new DA(p)},Ug.hydrateRoot=function(d,p,_){if(!i(d))throw Error(r(299));var S=!1,R="",O=dj,q=fj,oe=hj,Se=null;return _!=null&&(_.unstable_strictMode===!0&&(S=!0),_.identifierPrefix!==void 0&&(R=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(q=_.onCaughtError),_.onRecoverableError!==void 0&&(oe=_.onRecoverableError),_.formState!==void 0&&(Se=_.formState)),p=W4(d,1,!0,p,_??null,S,R,Se,O,q,oe,rU),p.context=q4(null),_=p.current,S=na(),S=Jr(S),R=Bc(S),R.callback=null,Hc(_,R,S),_=S,p.current.lanes=_,cn(p,_),Io(p),d[to]=p.current,pA(d),new Ib(p)},Ug.version="19.2.0",Ug}var pU;function Cne(){if(pU)return IA.exports;pU=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(),IA.exports=Tne(),IA.exports}var Nne=Cne();const Gt=t=>typeof t=="string",Fg=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},mU=t=>t==null?"":""+t,Rne=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Pne=/###/g,gU=t=>t&&t.indexOf("###")>-1?t.replace(Pne,"."):t,xU=t=>!t||Gt(t),wx=(t,e,n)=>{const r=Gt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(xU(t))return{};const s=gU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return xU(t)?{}:{obj:t,k:gU(r[i])}},vU=(t,e,n)=>{const{obj:r,k:i}=wx(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],a=e.slice(0,e.length-1),o=wx(t,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=wx(t,a,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=n},kne=(t,e,n,r)=>{const{obj:i,k:s}=wx(t,e,Object);i[s]=i[s]||[],i[s].push(n)},G_=(t,e)=>{const{obj:n,k:r}=wx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Dne=(t,e,n)=>{const r=G_(t,n);return r!==void 0?r:G_(e,n)},wG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Gt(t[r])||t[r]instanceof String||Gt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):wG(t[r],e[r],n):t[r]=e[r]);return t},Ph=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var One={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Lne=t=>Gt(t)?t.replace(/[&<>"'\/]/g,e=>One[e]):t;class Ine{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 jne=[" ",",","?","!",";"],Une=new Ine(20),Fne=(t,e,n)=>{e=e||"",n=n||"";const r=jne.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=Une.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(t);if(!s){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(s=!0)}return s},NN=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let a,o="";for(let l=s;l<r.length;++l)if(l!==s&&(o+=n),o+=r[l],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=a}return i},qx=t=>t?.replace("_","-"),zne={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 W_{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||zne,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(Gt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new W_(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new W_(this.logger,e)}}var qo=new W_;let tw=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,s])=>{for(let a=0;a<s;a++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,s])=>{for(let a=0;a<s;a++)i.apply(i,[e,...n])})}};class bU extends tw{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],r&&(Array.isArray(r)?o.push(...r):Gt(r)&&s?o.push(...r.split(s)):o.push(r)));const l=G_(this.data,o);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),l||!a||!Gt(r)?l:NN(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),vU(this.data,o,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(Gt(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s,a={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),i=r,r=n,n=o[1]),this.addNamespaces(n);let l=G_(this.data,o)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?wG(l,r,s):l={...l,...r},vU(this.data,o,l),a.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var MG={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const EG=Symbol("i18next/PATH_KEY");function Bne(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===EG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function RN(t,e){const{[EG]:n}=t(Bne());return n.join(e?.keySeparator??".")}const yU={},zA=t=>!Gt(t)&&typeof t!="boolean"&&typeof t!="number";class q_ extends tw{constructor(e,n={}){super(),Rne(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=qo.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const s=zA(i.res);return!(r.returnObjects===!1&&s)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Fne(e,r,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:Gt(s)?[s]:s};const c=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(c[0])>-1)&&(s=c.shift()),e=c.join(i)}return{key:e,namespaces:Gt(s)?[s]:s}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=RN(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const s=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],i),c=l[l.length-1];let u=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const h=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return g?s?{res:`${c}${u}${o}`,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:`${c}${u}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:h,usedNS:c,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let b=m?.res;const y=m?.usedKey||o,v=m?.exactUsedKey||o,x=["[object Number]","[object Function]","[object RegExp]"],M=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!Gt(i.count),A=q_.hasDefaultValue(i),P=T?this.pluralResolver.getSuffix(h,i.count,i):"",C=i.ordinal&&T?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",j=T&&!i.ordinal&&i.count===0,N=j&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${P}`]||i[`defaultValue${C}`]||i.defaultValue;let k=b;w&&!b&&A&&(k=N);const F=zA(k),I=Object.prototype.toString.apply(k);if(w&&k&&F&&x.indexOf(I)<0&&!(Gt(M)&&Array.isArray(k))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const W=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,k,{...i,ns:l}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(m.res=W,m.usedParams=this.getUsedParamsDetails(i),m):W}if(a){const W=Array.isArray(k),D=W?[]:{},$=W?v:y;for(const G in k)if(Object.prototype.hasOwnProperty.call(k,G)){const V=`${$}${a}${G}`;A&&!b?D[G]=this.translate(V,{...i,defaultValue:zA(N)?N[G]:void 0,joinArrays:!1,ns:l}):D[G]=this.translate(V,{...i,joinArrays:!1,ns:l}),D[G]===V&&(D[G]=k[G])}b=D}}else if(w&&Gt(M)&&Array.isArray(b))b=b.join(M),b&&(b=this.extendTranslation(b,e,i,r));else{let W=!1,D=!1;!this.isValidLookup(b)&&A&&(W=!0,b=N),this.isValidLookup(b)||(D=!0,b=o);const G=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:b,V=A&&N!==b&&this.options.updateMissing;if(D||W||V){if(this.logger.log(V?"updateKey":"missingKey",h,c,o,V?N:b),a){const H=this.resolve(o,{...i,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const K=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&K&&K[0])for(let H=0;H<K.length;H++)Z.push(K[H]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(i.lng||this.language):Z.push(i.lng||this.language);const ee=(H,Y,te)=>{const ae=A&&te!==b?te:G;this.options.missingKeyHandler?this.options.missingKeyHandler(H,c,Y,ae,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,c,Y,ae,V,i),this.emit("missingKey",H,c,Y,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?Z.forEach(H=>{const Y=this.pluralResolver.getSuffixes(H,i);j&&i[`defaultValue${this.options.pluralSeparator}zero`]&&Y.indexOf(`${this.options.pluralSeparator}zero`)<0&&Y.push(`${this.options.pluralSeparator}zero`),Y.forEach(te=>{ee([H],o+te,i[`defaultValue${te}`]||N)})}):ee(Z,o,N))}b=this.extendTranslation(b,e,i,m,r),D&&b===o&&this.options.appendNamespaceToMissingKey&&(b=`${c}${u}${o}`),(D||W)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${u}${o}`:o,W?b:void 0,i))}return s?(m.res=b,m.usedParams=this.getUsedParamsDetails(i),m):b}extendTranslation(e,n,r,i,s){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const l=Gt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const h=e.match(this.interpolator.nestingRegexp);c=h&&h.length}let u=r.replace&&!Gt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,r.lng||this.language||i.usedLng,r),l){const h=e.match(this.interpolator.nestingRegexp),g=h&&h.length;c<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...h)=>s?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const a=r.postProcess||this.options.postProcess,o=Gt(a)?[a]:a;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=MG.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,a,o;return Gt(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const c=this.extractFromKey(l,n),u=c.key;i=u;let h=c.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const g=n.count!==void 0&&!Gt(n.count),m=g&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(Gt(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(v=>{this.isValidLookup(r)||(o=v,!yU[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(yU[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(x=>{if(this.isValidLookup(r))return;a=x;const M=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,u,x,v,n);else{let T;g&&(T=this.pluralResolver.getSuffix(x,n.count,n));const A=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&T.indexOf(P)===0&&M.push(u+T.replace(P,this.options.pluralSeparator)),M.push(u+T),m&&M.push(u+A)),b){const C=`${u}${this.options.contextSeparator||"_"}${n.context}`;M.push(C),g&&(n.ordinal&&T.indexOf(P)===0&&M.push(C+T.replace(P,this.options.pluralSeparator)),M.push(C+T),m&&M.push(C+A))}}let w;for(;w=M.pop();)this.isValidLookup(r)||(s=w,r=this.getResource(x,v,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Gt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class _U{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=qo.create("languageUtils")}getScriptPartFromCode(e){if(e=qx(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=qx(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Gt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(a=>{if(a===s)return a;if(!(a.indexOf("-")<0&&s.indexOf("-")<0)&&(a.indexOf("-")>0&&s.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===s||a.indexOf(s)===0&&s.length>1))return a})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Gt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return Gt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):Gt(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const SU={zero:0,one:1,two:2,few:3,many:4,other:5},wU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Hne{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=qo.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=qx(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),wU;if(!e.match(/-|_/))return wU;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[s]=a,a}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>SU[i]-SU[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const MU=(t,e,n,r=".",i=!0)=>{let s=Dne(t,e,n);return!s&&i&&Gt(n)&&(s=NN(t,n,r),s===void 0&&(s=NN(e,n,r))),s},BA=t=>t.replace(/\$/g,"$$$$");class $ne{constructor(e={}){this.logger=qo.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:s,prefixEscaped:a,suffix:o,suffixEscaped:l,formatSeparator:c,unescapeSuffix:u,unescapePrefix:h,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:b,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:Lne,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Ph(s):a||"{{",this.suffix=o?Ph(o):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=u?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=g?Ph(g):m||Ph("$t("),this.nestingSuffix=b?Ph(b):y||Ph(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||1e3,this.alwaysFormat=M!==void 0?M:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=m=>{if(m.indexOf(this.formatSeparator)<0){const x=MU(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,r,{...i,...n,interpolationkey:m}):x}const b=m.split(this.formatSeparator),y=b.shift().trim(),v=b.join(this.formatSeparator).trim();return this.format(MU(n,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const u=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>BA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?BA(this.escape(m)):BA(m)}].forEach(m=>{for(o=0;s=m.regex.exec(e);){const b=s[1].trim();if(a=c(b),a===void 0)if(typeof u=="function"){const v=u(e,s,i);a=Gt(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))a="";else if(h){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),a="";else!Gt(a)&&!this.useRawValueToEscape&&(a=mU(a));const y=m.safeValue(a);if(e=e.replace(s[0],y),h?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=s[0].length):m.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,s,a;const o=(l,c)=>{const u=this.nestingOptionsSeparator;if(l.indexOf(u)<0)return l;const h=l.split(new RegExp(`${u}[ ]*{`));let g=`{${h[1]}`;l=h[0],g=this.interpolate(g,a);const m=g.match(/'/g),b=g.match(/"/g);((m?.length??0)%2===0&&!b||b.length%2!==0)&&(g=g.replace(/'/g,'"'));try{a=JSON.parse(g),c&&(a={...c,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${u}${g}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!Gt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const c=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(c!==-1&&(l=i[1].slice(c).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),i[1]=i[1].slice(0,c)),s=n(o.call(this,i[1].trim(),a),a),s&&i[0]===e&&!Gt(s))return s;Gt(s)||(s=mU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),l.length&&(s=l.reduce((u,h)=>this.format(u,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const Vne=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[o,...l]=a.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),u=o.trim();n[u]||(n[u]=c),c==="false"&&(n[u]=!1),c==="true"&&(n[u]=!0),isNaN(c)||(n[u]=parseInt(c,10))}})}return{formatName:e,formatOptions:n}},EU=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=r+JSON.stringify(s);let o=e[a];return o||(o=t(qx(r),i),e[a]=o),o(n)}},Gne=t=>(e,n,r)=>t(qx(n),r)(e);class Wne{constructor(e={}){this.logger=qo.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?EU:Gne;this.formats={number:r((i,s)=>{const a=new Intl.NumberFormat(i,{...s});return o=>a.format(o)}),currency:r((i,s)=>{const a=new Intl.NumberFormat(i,{...s,style:"currency"});return o=>a.format(o)}),datetime:r((i,s)=>{const a=new Intl.DateTimeFormat(i,{...s});return o=>a.format(o)}),relativetime:r((i,s)=>{const a=new Intl.RelativeTimeFormat(i,{...s});return o=>a.format(o,s.range||"day")}),list:r((i,s)=>{const a=new Intl.ListFormat(i,{...s});return o=>a.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=EU(n)}format(e,n,r,i={}){const s=n.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(o=>o.indexOf(")")>-1)){const o=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,o)].join(this.formatSeparator)}return s.reduce((o,l)=>{const{formatName:c,formatOptions:u}=Vne(l);if(this.formats[c]){let h=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},m=g.locale||g.lng||i.locale||i.lng||r;h=this.formats[c](o,m,{...u,...i,...g})}catch(g){this.logger.warn(g)}return h}else this.logger.warn(`there was no format function for ${c}`);return o},e)}}const qne=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Xne extends tw{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=qo.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const s={},a={},o={},l={};return e.forEach(c=>{let u=!0;n.forEach(h=>{const g=`${c}|${h}`;!r.reload&&this.store.hasResourceBundle(c,h)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?a[g]===void 0&&(a[g]=!0):(this.state[g]=1,u=!1,a[g]===void 0&&(a[g]=!0),s[g]===void 0&&(s[g]=!0),l[h]===void 0&&(l[h]=!0)))}),u||(o[c]=!0)}),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],a=i[1];n&&this.emit("failedLoading",s,a,n),!n&&r&&this.store.addResourceBundle(s,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const o={};this.queue.forEach(l=>{kne(l.loaded,[s],a),qne(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{o[c]||(o[c]={});const u=l.loaded[c];u.length&&u.forEach(h=>{o[c][h]===void 0&&(o[c][h]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r,i=0,s=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:a});return}this.readingCalls++;const o=(c,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}if(c&&u&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(c,u)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const c=l(e,n);c&&typeof c.then=="function"?c.then(u=>o(null,u)).catch(o):o(null,c)}catch(c){o(c)}return}return l(e,n,o)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Gt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Gt(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(a,o)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&o&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,o),this.loaded(e,a,o)})}saveMissing(e,n,r,i,s,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const l={...a,isUpdate:s},c=this.backend.create.bind(this.backend);if(c.length<6)try{let u;c.length===5?u=c(e,n,r,i,l):u=c(e,n,r,i),u&&typeof u.then=="function"?u.then(h=>o(null,h)).catch(o):o(null,u)}catch(u){o(u)}else c(e,n,r,i,o,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const AU=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),Gt(t[1])&&(e.defaultValue=t[1]),Gt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),TU=t=>(Gt(t.ns)&&(t.ns=[t.ns]),Gt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Gt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),Fb=()=>{},Kne=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Mx extends tw{constructor(e={},n){if(super(),this.options=TU(e),this.services={},this.logger=qo,this.modules={external:[]},Kne(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(Gt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=AU();this.options={...r,...this.options,...TU(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?qo.init(i(this.modules.logger),this.options):qo.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=Wne;const u=new _U(this.options);this.store=new bU(this.options.resources,this.options);const h=this.services;h.logger=qo,h.resourceStore=this.store,h.languageUtils=u,h.pluralResolver=new Hne(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(h.formatter=i(c),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new $ne(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new Xne(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new q_(this.services,this.options),this.translator.on("*",(m,...b)=>{this.emit(m,...b)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Fb),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...u)=>this.store[c](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...u)=>(this.store[c](...u),this)});const o=Fg(),l=()=>{const c=(u,h)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(h),n(u,h)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,n=Fb){let r=n;const i=Gt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const s=[],a=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(c=>{c!=="cimode"&&s.indexOf(c)<0&&s.push(c)})};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>a(l)),this.options.preload?.forEach?.(o=>a(o)),this.services.backendConnector.load(s,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(o)})}else r(null)}reloadResources(e,n,r){const i=Fg();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=Fb),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&MG.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=Fg();this.emit("languageChanging",e);const i=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},s=(o,l)=>{l?this.isLanguageChangingTo===e&&(i(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,r.resolve((...c)=>this.t(...c)),n&&n(o,(...c)=>this.t(...c))},a=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const l=Gt(o)?o:o&&o[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(Gt(o)?[o]:o);c&&(this.language||i(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,u=>{s(u,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),r}getFixedT(e,n,r){const i=(s,a,...o)=>{let l;typeof a!="object"?l=this.options.overloadTranslationOptionHandler([s,a].concat(o)):l={...a},l.lng=l.lng||i.lng,l.lngs=l.lngs||i.lngs,l.ns=l.ns||i.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||r||i.keyPrefix);const c=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(s)?u=s.map(h=>(typeof h=="function"&&(h=RN(h,{...this.options,...a})),`${l.keyPrefix}${c}${h}`)):(typeof s=="function"&&(s=RN(s,{...this.options,...a})),u=l.keyPrefix?`${l.keyPrefix}${c}${s}`:s),this.t(u,l)};return Gt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(o,l)=>{const c=this.services.backendConnector.state[`${o}|${l}`];return c===-1||c===0||c===2};if(n.precheck){const o=n.precheck(this,a);if(o!==void 0)return o}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(s,e)))}loadNamespaces(e,n){const r=Fg();return this.options.ns?(Gt(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Fg();Gt(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const s=i.getTextInfo();if(s&&s.direction)return s.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new _U(AU());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 Mx(e,n);return r.createInstance=Mx.createInstance,r}cloneInstance(e={},n=Fb){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Mx(i);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(o=>{s[o]=this[o]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},r){const o=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((u,h)=>(u[h]={...l[c][h]},u),l[c]),l),{});s.store=new bU(o,i),s.services.resourceStore=s.store}return s.translator=new q_(s.services,i),s.translator.on("*",(o,...l)=>{s.emit(o,...l)}),s.init(i,n),s.translator.options=i,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ts=Mx.createInstance();Ts.createInstance;Ts.dir;Ts.init;Ts.loadResources;Ts.reloadResources;Ts.use;Ts.changeLanguage;Ts.getFixedT;Ts.t;Ts.exists;Ts.setDefaultNamespace;Ts.hasLoadedNamespace;Ts.loadNamespaces;Ts.loadLanguages;const Yne=(t,e,n,r)=>{const i=[n,{code:e,...r||{}}];if(t?.services?.logger?.forward)return t.services.logger.forward(i,"warn","react-i18next::",!0);wf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},CU={},AG=(t,e,n,r)=>{wf(n)&&CU[n]||(wf(n)&&(CU[n]=new Date),Yne(t,e,n,r))},TG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},PN=(t,e,n)=>{t.loadNamespaces(e,TG(t,n))},NU=(t,e,n,r)=>{if(wf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return PN(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,TG(t,r))},Zne=(t,e,n={})=>!e.languages||!e.languages.length?(AG(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(r,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!i(r.isLanguageChangingTo,t))return!1}}),wf=t=>typeof t=="string",Qne=t=>typeof t=="object"&&t!==null,Jne=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ere={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},tre=t=>ere[t],nre=t=>t.replace(Jne,tre);let kN={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:nre};const rre=(t={})=>{kN={...kN,...t}},ire=()=>kN;let CG;const sre=t=>{CG=t},are=()=>CG,ore={type:"3rdParty",init(t){rre(t.options.react),sre(t)}},lre=E.createContext();class cre{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var HA={exports:{}},$A={};var RU;function ure(){if(RU)return $A;RU=1;var t=Mm();function e(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,a=t.useDebugValue;function o(h,g){var m=g(),b=r({inst:{value:m,getSnapshot:g}}),y=b[0].inst,v=b[1];return s(function(){y.value=m,y.getSnapshot=g,l(y)&&v({inst:y})},[h,m,g]),i(function(){return l(y)&&v({inst:y}),h(function(){l(y)&&v({inst:y})})},[h]),a(m),m}function l(h){var g=h.getSnapshot;h=h.value;try{var m=g();return!n(h,m)}catch{return!0}}function c(h,g){return g()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:o;return $A.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,$A}var PU;function NG(){return PU||(PU=1,HA.exports=ure()),HA.exports}var LP=NG();const dre=(t,e)=>wf(e)?e:Qne(e)&&wf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,fre={t:dre,ready:!1},hre=()=>()=>{},IP=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=E.useContext(lre)||{},s=n||r||are();s&&!s.reportNamespaces&&(s.reportNamespaces=new cre),s||AG(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const a=E.useMemo(()=>({...ire(),...s?.options?.react,...e}),[s,e]),{useSuspense:o,keyPrefix:l}=a,c=i||s?.options?.defaultNS,u=wf(c)?[c]:c||["translation"],h=E.useMemo(()=>u,u);s?.reportNamespaces?.addUsedNamespaces?.(h);const g=E.useRef(0),m=E.useCallback(N=>{if(!s)return hre;const{bindI18n:k,bindI18nStore:F}=a,I=()=>{g.current+=1,N()};return k&&s.on(k,I),F&&s.store.on(F,I),()=>{k&&k.split(" ").forEach(W=>s.off(W,I)),F&&F.split(" ").forEach(W=>s.store.off(W,I))}},[s,a]),b=E.useRef(),y=E.useCallback(()=>{if(!s)return fre;const N=!!(s.isInitialized||s.initializedStoreOnce)&&h.every($=>Zne($,s,a)),k=e.lng||s.language,F=g.current,I=b.current;if(I&&I.ready===N&&I.lng===k&&I.keyPrefix===l&&I.revision===F)return I;const D={t:s.getFixedT(k,a.nsMode==="fallback"?h:h[0],l),ready:N,lng:k,keyPrefix:l,revision:F};return b.current=D,D},[s,h,l,a,e.lng]),[v,x]=E.useState(0),{t:M,ready:w}=LP.useSyncExternalStore(m,y,y);E.useEffect(()=>{if(s&&!w&&!o){const N=()=>x(k=>k+1);e.lng?NU(s,e.lng,h,N):PN(s,h,N)}},[s,e.lng,h,w,o,v]);const T=s||{},A=E.useRef(null),P=E.useRef(),C=N=>{const k=Object.getOwnPropertyDescriptors(N);k.__original&&delete k.__original;const F=Object.create(Object.getPrototypeOf(N),k);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:N,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},j=E.useMemo(()=>{const N=T,k=N?.language;let F=N;N&&(A.current&&A.current.__original===N?P.current!==k?(F=C(N),A.current=F,P.current=k):F=A.current:(F=C(N),A.current=F,P.current=k));const I=[M,F,w];return I.t=M,I.i18n=F,I.ready=w,I},[M,T,w,T.resolvedLanguage,T.language,T.languages]);if(s&&o&&!w)throw new Promise(N=>{const k=()=>N();e.lng?NU(s,e.lng,h,k):PN(s,h,k)});return j},{slice:pre,forEach:mre}=[];function gre(t){return mre.call(pre.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function xre(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 kU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,vre=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let s=`${t}=${i}`;if(r.maxAge>0){const a=r.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");s+=`; Max-Age=${Math.floor(a)}`}if(r.domain){if(!kU.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!kU.test(r.path))throw new TypeError("option path is invalid");s+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(s+="; HttpOnly"),r.secure&&(s+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(s+="; Partitioned"),s},DU={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=vre(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 bre={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return DU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&DU.create(n,t,r,i,s)}},yre={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const s=r.substring(1).split("&");for(let a=0;a<s.length;a++){const o=s[a].indexOf("=");o>0&&s[a].substring(0,o)===e&&(n=s[a].substring(o+1))}}return n}},_re={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const s=i.substring(1);if(e){const a=s.split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(r=a[o].substring(l+1))}}if(r)return r;if(!r&&n>-1){const a=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(a)?a[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let kh=null;const OU=()=>{if(kh!==null)return kh;try{if(kh=typeof window<"u"&&window.localStorage!==null,!kh)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{kh=!1}return kh};var Sre={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&OU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&OU()&&window.localStorage.setItem(n,t)}};let Dh=null;const LU=()=>{if(Dh!==null)return Dh;try{if(Dh=typeof window<"u"&&window.sessionStorage!==null,!Dh)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Dh=!1}return Dh};var wre={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&LU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&LU()&&window.sessionStorage.setItem(n,t)}},Mre={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let s=0;s<n.length;s++)e.push(n[s]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Ere={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}},Are={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}},Tre={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 RG=!1;try{document.cookie,RG=!0}catch{}const PG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];RG||PG.splice(1,1);const Cre=()=>({order:PG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class kG{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=gre(n,this.options||{},Cre()),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(bre),this.addDetector(yre),this.addDetector(Sre),this.addDetector(wre),this.addDetector(Mre),this.addDetector(Ere),this.addDetector(Are),this.addDetector(Tre),this.addDetector(_re)}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&&!xre(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)}))}}kG.type="languageDetector";const Nre={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",settings:"Settings",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Rre={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",settings:"Einstellungen",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},Pre={en:{translation:Nre},de:{translation:Rre}};Ts.use(kG).use(ore).init({resources:Pre,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const IU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var jU="popstate";function kre(t={}){function e(r,i){let{pathname:s,search:a,hash:o}=r.location;return DN("",{pathname:s,search:a,hash:o},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:Xx(i)}return Ore(e,n,null,t)}function gr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Mo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Dre(){return Math.random().toString(36).substring(2,10)}function UU(t,e){return{usr:t.state,key:t.key,idx:e}}function DN(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Em(e):e,state:n,key:e&&e.key||r||Dre()}}function Xx({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 Em(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 Ore(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,o="POP",l=null,c=u();c==null&&(c=0,a.replaceState({...a.state,idx:c},""));function u(){return(a.state||{idx:null}).idx}function h(){o="POP";let v=u(),x=v==null?null:v-c;c=v,l&&l({action:o,location:y.location,delta:x})}function g(v,x){o="PUSH";let M=DN(y.location,v,x);c=u()+1;let w=UU(M,c),T=y.createHref(M);try{a.pushState(w,"",T)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;i.location.assign(T)}s&&l&&l({action:o,location:y.location,delta:1})}function m(v,x){o="REPLACE";let M=DN(y.location,v,x);c=u();let w=UU(M,c),T=y.createHref(M);a.replaceState(w,"",T),s&&l&&l({action:o,location:y.location,delta:0})}function b(v){return Lre(v)}let y={get action(){return o},get location(){return t(i,a)},listen(v){if(l)throw new Error("A history only accepts one active listener");return i.addEventListener(jU,h),l=v,()=>{i.removeEventListener(jU,h),l=null}},createHref(v){return e(i,v)},createURL:b,encodeLocation(v){let x=b(v);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:g,replace:m,go(v){return a.go(v)}};return y}function Lre(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),gr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:Xx(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function DG(t,e,n="/"){return Ire(t,e,n,!1)}function Ire(t,e,n,r){let i=typeof e=="string"?Em(e):e,s=pc(i.pathname||"/",n);if(s==null)return null;let a=OG(t);jre(a);let o=null;for(let l=0;o==null&&l<a.length;++l){let c=Xre(s);o=Wre(a[l],c,r)}return o}function OG(t,e=[],n=[],r="",i=!1){let s=(a,o,l=i,c)=>{let u={relativePath:c===void 0?a.path||"":c,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(r)&&l)return;gr(u.relativePath.startsWith(r),`Absolute route path "${u.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(r.length)}let h=ac([r,u.relativePath]),g=n.concat(u);a.children&&a.children.length>0&&(gr(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),OG(a.children,e,g,h,l)),!(a.path==null&&!a.index)&&e.push({path:h,score:Vre(h,a.index),routesMeta:g})};return t.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))s(a,o);else for(let l of LG(a.path))s(a,o,!0,l)}),e}function LG(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let a=LG(r.join("/")),o=[];return o.push(...a.map(l=>l===""?s:[s,l].join("/"))),i&&o.push(...a),o.map(l=>t.startsWith("/")&&l===""?"/":l)}function jre(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Gre(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ure=/^:[\w-]+$/,Fre=3,zre=2,Bre=1,Hre=10,$re=-2,FU=t=>t==="*";function Vre(t,e){let n=t.split("/"),r=n.length;return n.some(FU)&&(r+=$re),e&&(r+=zre),n.filter(i=>!FU(i)).reduce((i,s)=>i+(Ure.test(s)?Fre:s===""?Bre:Hre),r)}function Gre(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 Wre(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",a=[];for(let o=0;o<r.length;++o){let l=r[o],c=o===r.length-1,u=s==="/"?e:e.slice(s.length)||"/",h=X_({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},u),g=l.route;if(!h&&c&&n&&!r[r.length-1].route.index&&(h=X_({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!h)return null;Object.assign(i,h.params),a.push({params:i,pathname:ac([s,h.pathname]),pathnameBase:Jre(ac([s,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(s=ac([s,h.pathnameBase]))}return a}function X_(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=qre(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),o=i.slice(1);return{params:r.reduce((c,{paramName:u,isOptional:h},g)=>{if(u==="*"){let b=o[g]||"";a=s.slice(0,s.length-b.length).replace(/(.)\/+$/,"$1")}const m=o[g];return h&&!m?c[u]=void 0:c[u]=(m||"").replace(/%2F/g,"/"),c},{}),pathname:s,pathnameBase:a,pattern:t}}function qre(t,e=!1,n=!0){Mo(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,l)=>(r.push({paramName:o,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function Xre(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Mo(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function pc(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}var Kre=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Yre=t=>Kre.test(t);function Zre(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Em(t):t,s;if(n)if(Yre(n))s=n;else{if(n.includes("//")){let a=n;n=n.replace(/\/\/+/g,"/"),Mo(!1,`Pathnames cannot have embedded double slashes - normalizing ${a} -> ${n}`)}n.startsWith("/")?s=zU(n.substring(1),"/"):s=zU(n,e)}else s=e;return{pathname:s,search:eie(r),hash:tie(i)}}function zU(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 VA(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 Qre(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function IG(t){let e=Qre(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function jG(t,e,n,r=!1){let i;typeof t=="string"?i=Em(t):(i={...t},gr(!i.pathname||!i.pathname.includes("?"),VA("?","pathname","search",i)),gr(!i.pathname||!i.pathname.includes("#"),VA("#","pathname","hash",i)),gr(!i.search||!i.search.includes("#"),VA("#","search","hash",i)));let s=t===""||i.pathname==="",a=s?"/":i.pathname,o;if(a==null)o=n;else{let h=e.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),h-=1;i.pathname=g.join("/")}o=h>=0?e[h]:"/"}let l=Zre(i,o),c=a&&a!=="/"&&a.endsWith("/"),u=(s||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}var ac=t=>t.join("/").replace(/\/\/+/g,"/"),Jre=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),eie=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,tie=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function nie(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 UG=["POST","PUT","PATCH","DELETE"];new Set(UG);var rie=["GET",...UG];new Set(rie);var Am=E.createContext(null);Am.displayName="DataRouter";var nw=E.createContext(null);nw.displayName="DataRouterState";E.createContext(!1);var FG=E.createContext({isTransitioning:!1});FG.displayName="ViewTransition";var iie=E.createContext(new Map);iie.displayName="Fetchers";var sie=E.createContext(null);sie.displayName="Await";var dl=E.createContext(null);dl.displayName="Navigation";var z0=E.createContext(null);z0.displayName="Location";var No=E.createContext({outlet:null,matches:[],isDataRoute:!1});No.displayName="Route";var jP=E.createContext(null);jP.displayName="RouteError";function aie(t,{relative:e}={}){gr(B0(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=E.useContext(dl),{hash:i,pathname:s,search:a}=H0(t,{relative:e}),o=s;return n!=="/"&&(o=s==="/"?n:ac([n,s])),r.createHref({pathname:o,search:a,hash:i})}function B0(){return E.useContext(z0)!=null}function ld(){return gr(B0(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(z0).location}var zG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function BG(t){E.useContext(dl).static||E.useLayoutEffect(t)}function UP(){let{isDataRoute:t}=E.useContext(No);return t?Sie():oie()}function oie(){gr(B0(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(Am),{basename:e,navigator:n}=E.useContext(dl),{matches:r}=E.useContext(No),{pathname:i}=ld(),s=JSON.stringify(IG(r)),a=E.useRef(!1);return BG(()=>{a.current=!0}),E.useCallback((l,c={})=>{if(Mo(a.current,zG),!a.current)return;if(typeof l=="number"){n.go(l);return}let u=jG(l,JSON.parse(s),i,c.relative==="path");t==null&&e!=="/"&&(u.pathname=u.pathname==="/"?e:ac([e,u.pathname])),(c.replace?n.replace:n.push)(u,c.state,c)},[e,n,s,i,t])}var lie=E.createContext(null);function cie(t){let e=E.useContext(No).outlet;return E.useMemo(()=>e&&E.createElement(lie.Provider,{value:t},e),[e,t])}function uie(){let{matches:t}=E.useContext(No),e=t[t.length-1];return e?e.params:{}}function H0(t,{relative:e}={}){let{matches:n}=E.useContext(No),{pathname:r}=ld(),i=JSON.stringify(IG(n));return E.useMemo(()=>jG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function die(t,e){return HG(t,e)}function HG(t,e,n,r,i){gr(B0(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=E.useContext(dl),{matches:a}=E.useContext(No),o=a[a.length-1],l=o?o.params:{},c=o?o.pathname:"/",u=o?o.pathnameBase:"/",h=o&&o.route;{let M=h&&h.path||"";$G(c,!h||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${M}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let g=ld(),m;if(e){let M=typeof e=="string"?Em(e):e;gr(u==="/"||M.pathname?.startsWith(u),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${M.pathname}" was given in the \`location\` prop.`),m=M}else m=g;let b=m.pathname||"/",y=b;if(u!=="/"){let M=u.replace(/^\//,"").split("/");y="/"+b.replace(/^\//,"").split("/").slice(M.length).join("/")}let v=DG(t,{pathname:y});Mo(h||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Mo(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=gie(v&&v.map(M=>Object.assign({},M,{params:Object.assign({},l,M.params),pathname:ac([u,s.encodeLocation?s.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?u:ac([u,s.encodeLocation?s.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),a,n,r,i);return e&&x?E.createElement(z0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function fie(){let t=_ie(),e=nie(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},a=null;return console.error("Error handled by React Router default ErrorBoundary:",t),a=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:s},"ErrorBoundary")," or"," ",E.createElement("code",{style:s},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:i},n):null,a)}var hie=E.createElement(fie,null),pie=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?E.createElement(No.Provider,{value:this.props.routeContext},E.createElement(jP.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function mie({routeContext:t,match:e,children:n}){let r=E.useContext(Am);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(No.Provider,{value:t},n)}function gie(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let s=t,a=n?.errors;if(a!=null){let u=s.findIndex(h=>h.route.id&&a?.[h.route.id]!==void 0);gr(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,u+1))}let o=!1,l=-1;if(n)for(let u=0;u<s.length;u++){let h=s[u];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=u),h.route.id){let{loaderData:g,errors:m}=n,b=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!m||m[h.route.id]===void 0);if(h.route.lazy||b){o=!0,l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}let c=n&&r?(u,h)=>{r(u,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:h})}:void 0;return s.reduceRight((u,h,g)=>{let m,b=!1,y=null,v=null;n&&(m=a&&h.route.id?a[h.route.id]:void 0,y=h.route.errorElement||hie,o&&(l<0&&g===0?($G("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):l===g&&(b=!0,v=h.route.hydrateFallbackElement||null)));let x=e.concat(s.slice(0,g+1)),M=()=>{let w;return m?w=y:b?w=v:h.route.Component?w=E.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=u,E.createElement(mie,{match:h,routeContext:{outlet:u,matches:x,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?E.createElement(pie,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:M(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:c}):M()},null)}function FP(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xie(t){let e=E.useContext(Am);return gr(e,FP(t)),e}function vie(t){let e=E.useContext(nw);return gr(e,FP(t)),e}function bie(t){let e=E.useContext(No);return gr(e,FP(t)),e}function zP(t){let e=bie(t),n=e.matches[e.matches.length-1];return gr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function yie(){return zP("useRouteId")}function _ie(){let t=E.useContext(jP),e=vie("useRouteError"),n=zP("useRouteError");return t!==void 0?t:e.errors?.[n]}function Sie(){let{router:t}=xie("useNavigate"),e=zP("useNavigate"),n=E.useRef(!1);return BG(()=>{n.current=!0}),E.useCallback(async(i,s={})=>{Mo(n.current,zG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var BU={};function $G(t,e,n){!e&&!BU[t]&&(BU[t]=!0,Mo(!1,n))}E.memo(wie);function wie({routes:t,future:e,state:n,unstable_onError:r}){return HG(t,void 0,n,r,e)}function Mie(t){return cie(t.context)}function zo(t){gr(!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 Eie({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1}){gr(!B0(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let a=t.replace(/^\/*/,"/"),o=E.useMemo(()=>({basename:a,navigator:i,static:s,future:{}}),[a,i,s]);typeof n=="string"&&(n=Em(n));let{pathname:l="/",search:c="",hash:u="",state:h=null,key:g="default"}=n,m=E.useMemo(()=>{let b=pc(l,a);return b==null?null:{location:{pathname:b,search:c,hash:u,state:h,key:g},navigationType:r}},[a,l,c,u,h,g,r]);return Mo(m!=null,`<Router basename="${a}"> is not able to match the URL "${l}${c}${u}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:E.createElement(dl.Provider,{value:o},E.createElement(z0.Provider,{children:e,value:m}))}function Aie({children:t,location:e}){return die(ON(t),e)}function ON(t,e=[]){let n=[];return E.Children.forEach(t,(r,i)=>{if(!E.isValidElement(r))return;let s=[...e,i];if(r.type===E.Fragment){n.push.apply(n,ON(r.props.children,s));return}gr(r.type===zo,`[${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>`),gr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let a={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(a.children=ON(r.props.children,s)),n.push(a)}),n}var y_="get",__="application/x-www-form-urlencoded";function rw(t){return t!=null&&typeof t.tagName=="string"}function Tie(t){return rw(t)&&t.tagName.toLowerCase()==="button"}function Cie(t){return rw(t)&&t.tagName.toLowerCase()==="form"}function Nie(t){return rw(t)&&t.tagName.toLowerCase()==="input"}function Rie(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Pie(t,e){return t.button===0&&(!e||e==="_self")&&!Rie(t)}var zb=null;function kie(){if(zb===null)try{new FormData(document.createElement("form"),0),zb=!1}catch{zb=!0}return zb}var Die=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function GA(t){return t!=null&&!Die.has(t)?(Mo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${__}"`),null):t}function Oie(t,e){let n,r,i,s,a;if(Cie(t)){let o=t.getAttribute("action");r=o?pc(o,e):null,n=t.getAttribute("method")||y_,i=GA(t.getAttribute("enctype"))||__,s=new FormData(t)}else if(Tie(t)||Nie(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=t.getAttribute("formaction")||o.getAttribute("action");if(r=l?pc(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||y_,i=GA(t.getAttribute("formenctype"))||GA(o.getAttribute("enctype"))||__,s=new FormData(o,t),!kie()){let{name:c,type:u,value:h}=t;if(u==="image"){let g=c?`${c}.`:"";s.append(`${g}x`,"0"),s.append(`${g}y`,"0")}else c&&s.append(c,h)}}else{if(rw(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=y_,r=null,i=__,a=t}return s&&i==="text/plain"&&(a=s,s=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:s,body:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function BP(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Lie(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&pc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Iie(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 jie(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 Uie(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let a=await Iie(s,n);return a.links?a.links():[]}return[]}));return Hie(r.flat(1).filter(jie).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function HU(t,e,n,r,i,s){let a=(l,c)=>n[c]?l.route.id!==n[c].route.id:!0,o=(l,c)=>n[c].pathname!==l.pathname||n[c].route.path?.endsWith("*")&&n[c].params["*"]!==l.params["*"];return s==="assets"?e.filter((l,c)=>a(l,c)||o(l,c)):s==="data"?e.filter((l,c)=>{let u=r.routes[l.route.id];if(!u||!u.hasLoader)return!1;if(a(l,c)||o(l,c))return!0;if(l.route.shouldRevalidate){let h=l.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Fie(t,e,{includeHydrateFallback:n}={}){return zie(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let s=[i.module];return i.clientActionModule&&(s=s.concat(i.clientActionModule)),i.clientLoaderModule&&(s=s.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(s=s.concat(i.hydrateFallbackModule)),i.imports&&(s=s.concat(i.imports)),s}).flat(1))}function zie(t){return[...new Set(t)]}function Bie(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Hie(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(Bie(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function VG(){let t=E.useContext(Am);return BP(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function $ie(){let t=E.useContext(nw);return BP(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var HP=E.createContext(void 0);HP.displayName="FrameworkContext";function GG(){let t=E.useContext(HP);return BP(t,"You must render this element inside a <HydratedRouter> element"),t}function Vie(t,e){let n=E.useContext(HP),[r,i]=E.useState(!1),[s,a]=E.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:u,onTouchStart:h}=e,g=E.useRef(null);E.useEffect(()=>{if(t==="render"&&a(!0),t==="viewport"){let y=x=>{x.forEach(M=>{a(M.isIntersecting)})},v=new IntersectionObserver(y,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.disconnect()}}},[t]),E.useEffect(()=>{if(r){let y=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},b=()=>{i(!1),a(!1)};return n?t!=="intent"?[s,g,{}]:[s,g,{onFocus:zg(o,m),onBlur:zg(l,b),onMouseEnter:zg(c,m),onMouseLeave:zg(u,b),onTouchStart:zg(h,m)}]:[!1,g,{}]}function zg(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Gie({page:t,...e}){let{router:n}=VG(),r=E.useMemo(()=>DG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?E.createElement(qie,{page:t,matches:r,...e}):null}function Wie(t){let{manifest:e,routeModules:n}=GG(),[r,i]=E.useState([]);return E.useEffect(()=>{let s=!1;return Uie(t,e,n).then(a=>{s||i(a)}),()=>{s=!0}},[t,e,n]),r}function qie({page:t,matches:e,...n}){let r=ld(),{manifest:i,routeModules:s}=GG(),{basename:a}=VG(),{loaderData:o,matches:l}=$ie(),c=E.useMemo(()=>HU(t,e,l,i,r,"data"),[t,e,l,i,r]),u=E.useMemo(()=>HU(t,e,l,i,r,"assets"),[t,e,l,i,r]),h=E.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,y=!1;if(e.forEach(x=>{let M=i.routes[x.route.id];!M||!M.hasLoader||(!c.some(w=>w.route.id===x.route.id)&&x.route.id in o&&s[x.route.id]?.shouldRevalidate||M.hasClientLoader?y=!0:b.add(x.route.id))}),b.size===0)return[];let v=Lie(t,a,"data");return y&&b.size>0&&v.searchParams.set("_routes",e.filter(x=>b.has(x.route.id)).map(x=>x.route.id).join(",")),[v.pathname+v.search]},[a,o,r,i,c,e,t,s]),g=E.useMemo(()=>Fie(u,i),[u,i]),m=Wie(u);return E.createElement(E.Fragment,null,h.map(b=>E.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),g.map(b=>E.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),m.map(({key:b,link:y})=>E.createElement("link",{key:b,nonce:n.nonce,...y})))}function Xie(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var WG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{WG&&(window.__reactRouterVersion="7.9.6")}catch{}function Kie({basename:t,children:e,window:n}){let r=E.useRef();r.current==null&&(r.current=kre({window:n,v5Compat:!0}));let i=r.current,[s,a]=E.useState({action:i.action,location:i.location}),o=E.useCallback(l=>{E.startTransition(()=>a(l))},[a]);return E.useLayoutEffect(()=>i.listen(o),[i,o]),E.createElement(Eie,{basename:t,children:e,location:s.location,navigationType:s.action,navigator:i})}var qG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,iw=E.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:a,state:o,target:l,to:c,preventScrollReset:u,viewTransition:h,...g},m){let{basename:b}=E.useContext(dl),y=typeof c=="string"&&qG.test(c),v,x=!1;if(typeof c=="string"&&y&&(v=c,WG))try{let N=new URL(window.location.href),k=c.startsWith("//")?new URL(N.protocol+c):new URL(c),F=pc(k.pathname,b);k.origin===N.origin&&F!=null?c=F+k.search+k.hash:x=!0}catch{Mo(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=aie(c,{relative:i}),[w,T,A]=Vie(r,g),P=Qie(c,{replace:a,state:o,target:l,preventScrollReset:u,relative:i,viewTransition:h});function C(N){e&&e(N),N.defaultPrevented||P(N)}let j=E.createElement("a",{...g,...A,href:v||M,onClick:x||s?e:C,ref:Xie(m,T),target:l,"data-discover":!y&&n==="render"?"true":void 0});return w&&!y?E.createElement(E.Fragment,null,j,E.createElement(Gie,{page:M})):j});iw.displayName="Link";var XG=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:a,viewTransition:o,children:l,...c},u){let h=H0(a,{relative:c.relative}),g=ld(),m=E.useContext(nw),{navigator:b,basename:y}=E.useContext(dl),v=m!=null&&rse(h)&&o===!0,x=b.encodeLocation?b.encodeLocation(h).pathname:h.pathname,M=g.pathname,w=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(M=M.toLowerCase(),w=w?w.toLowerCase():null,x=x.toLowerCase()),w&&y&&(w=pc(w,y)||w);const T=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let A=M===x||!i&&M.startsWith(x)&&M.charAt(T)==="/",P=w!=null&&(w===x||!i&&w.startsWith(x)&&w.charAt(x.length)==="/"),C={isActive:A,isPending:P,isTransitioning:v},j=A?e:void 0,N;typeof r=="function"?N=r(C):N=[r,A?"active":null,P?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let k=typeof s=="function"?s(C):s;return E.createElement(iw,{...c,"aria-current":j,className:N,ref:u,style:k,to:a,viewTransition:o},typeof l=="function"?l(C):l)});XG.displayName="NavLink";var Yie=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:a=y_,action:o,onSubmit:l,relative:c,preventScrollReset:u,viewTransition:h,...g},m)=>{let b=tse(),y=nse(o,{relative:c}),v=a.toLowerCase()==="get"?"get":"post",x=typeof o=="string"&&qG.test(o),M=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let T=w.nativeEvent.submitter,A=T?.getAttribute("formmethod")||a;b(T||w.currentTarget,{fetcherKey:e,method:A,navigate:n,replace:i,state:s,relative:c,preventScrollReset:u,viewTransition:h})};return E.createElement("form",{ref:m,method:v,action:y,onSubmit:r?l:M,...g,"data-discover":!x&&t==="render"?"true":void 0})});Yie.displayName="Form";function Zie(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function KG(t){let e=E.useContext(Am);return gr(e,Zie(t)),e}function Qie(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:a}={}){let o=UP(),l=ld(),c=H0(t,{relative:s});return E.useCallback(u=>{if(Pie(u,e)){u.preventDefault();let h=n!==void 0?n:Xx(l)===Xx(c);o(t,{replace:h,state:r,preventScrollReset:i,relative:s,viewTransition:a})}},[l,o,c,n,r,e,t,i,s,a])}var Jie=0,ese=()=>`__${String(++Jie)}__`;function tse(){let{router:t}=KG("useSubmit"),{basename:e}=E.useContext(dl),n=yie();return E.useCallback(async(r,i={})=>{let{action:s,method:a,encType:o,formData:l,body:c}=Oie(r,e);if(i.navigate===!1){let u=i.fetcherKey||ese();await t.fetch(u,n,i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||a,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:c,formMethod:i.method||a,formEncType:i.encType||o,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function nse(t,{relative:e}={}){let{basename:n}=E.useContext(dl),r=E.useContext(No);gr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...H0(t||".",{relative:e})},a=ld();if(t==null){s.search=a.search;let o=new URLSearchParams(s.search),l=o.getAll("index");if(l.some(u=>u==="")){o.delete("index"),l.filter(h=>h).forEach(h=>o.append("index",h));let u=o.toString();s.search=u?`?${u}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:ac([n,s.pathname])),Xx(s)}function rse(t,{relative:e}={}){let n=E.useContext(FG);gr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=KG("useViewTransitionState"),i=H0(t,{relative:e});if(!n.isTransitioning)return!1;let s=pc(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=pc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return X_(i.pathname,a)!=null||X_(i.pathname,s)!=null}var Jl=SG();const ise=Ja(Jl);var Tm=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(){}},sse={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},ase=class{#e=sse;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},ef=new ase;function ose(t){setTimeout(t,0)}var Mf=typeof window>"u"||"Deno"in globalThis;function xs(){}function lse(t,e){return typeof t=="function"?t(e):t}function LN(t){return typeof t=="number"&&t>=0&&t!==1/0}function YG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Fu(t,e){return typeof t=="function"?t(e):t}function Oa(t,e){return typeof t=="function"?t(e):t}function $U(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=t;if(a){if(r){if(e.queryHash!==$P(a,e.options))return!1}else if(!Kx(e.queryKey,a))return!1}if(n!=="all"){const l=e.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||s&&!s(e))}function VU(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(Ef(e.options.mutationKey)!==Ef(s))return!1}else if(!Kx(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function $P(t,e){return(e?.queryKeyHashFn||Ef)(t)}function Ef(t){return JSON.stringify(t,(e,n)=>IN(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Kx(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Kx(t[n],e[n])):!1}var cse=Object.prototype.hasOwnProperty;function ZG(t,e){if(t===e)return t;const n=GU(t)&&GU(e);if(!n&&!(IN(t)&&IN(e)))return e;const i=(n?t:Object.keys(t)).length,s=n?e:Object.keys(e),a=s.length,o=n?new Array(a):{};let l=0;for(let c=0;c<a;c++){const u=n?c:s[c],h=t[u],g=e[u];if(h===g){o[u]=h,(n?c<i:cse.call(t,u))&&l++;continue}if(h===null||g===null||typeof h!="object"||typeof g!="object"){o[u]=g;continue}const m=ZG(h,g);o[u]=m,m===h&&l++}return i===a&&l===i?t:o}function K_(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 GU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function IN(t){if(!WU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!WU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function WU(t){return Object.prototype.toString.call(t)==="[object Object]"}function use(t){return new Promise(e=>{ef.setTimeout(e,t)})}function jN(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?ZG(t,e):e}function dse(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function fse(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var VP=Symbol();function QG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===VP?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function JG(t,e){return typeof t=="function"?t(...e):!!t}var hse=class extends Tm{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Mf&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},GP=new hse;function UN(){let t,e;const n=new Promise((i,s)=>{t=i,e=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var pse=ose;function mse(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=pse;const s=o=>{e?t.push(o):i(()=>{n(o)})},a=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;e++;try{l=o()}finally{e--,e||a()}return l},batchCalls:o=>(...l)=>{s(()=>{o(...l)})},schedule:s,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var si=mse(),gse=class extends Tm{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Mf&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},Y_=new gse;function xse(t){return Math.min(1e3*2**t,3e4)}function e9(t){return(t??"online")==="online"?Y_.isOnline():!0}var FN=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function t9(t){let e=!1,n=0,r;const i=UN(),s=()=>i.status!=="pending",a=y=>{if(!s()){const v=new FN(y);g(v),t.onCancel?.(v)}},o=()=>{e=!0},l=()=>{e=!1},c=()=>GP.isFocused()&&(t.networkMode==="always"||Y_.isOnline())&&t.canRun(),u=()=>e9(t.networkMode)&&t.canRun(),h=y=>{s()||(r?.(),i.resolve(y))},g=y=>{s()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=v=>{(s()||c())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),b=()=>{if(s())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(x){y=Promise.reject(x)}Promise.resolve(y).then(h).catch(x=>{if(s())return;const M=t.retry??(Mf?0:3),w=t.retryDelay??xse,T=typeof w=="function"?w(n,x):w,A=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,x);if(e||!A){g(x);return}n++,t.onFail?.(n,x),use(T).then(()=>c()?void 0:m()).then(()=>{e?g(x):b()})})};return{promise:i,status:()=>i.status,cancel:a,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?b():m().then(b),i)}}var n9=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),LN(this.gcTime)&&(this.#e=ef.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Mf?1/0:300*1e3))}clearGcTimeout(){this.#e&&(ef.clearTimeout(this.#e),this.#e=void 0)}},vse=class extends n9{#e;#t;#n;#i;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=XU(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=XU(this.options);e.data!==void 0&&(this.setState(qU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=jN(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(xs).catch(xs):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Oa(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===VP||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Fu(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!YG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(l=>l.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=QG(this.options,e),c=(()=>{const u={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(u),u})();return this.#o=!1,this.options.persister?this.options.persister(o,c,this):o(c)},a=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(o),o})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:"fetch",meta:a.fetchOptions?.meta}),this.#r=t9({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof FN&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,l)=>{this.#s({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const o=await this.#r.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof FN){if(o.silent)return this.#r.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#s({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...r9(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...qU(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),si.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function r9(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:e9(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function qU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function XU(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 bse=class extends Tm{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#o=UN(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#m;#f;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),KU(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return zN(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return zN(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Oa(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),e._defaulted&&!K_(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&YU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Oa(this.options.enabled,this.#t)!==Oa(e.enabled,this.#t)||Fu(this.options.staleTime,this.#t)!==Fu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Oa(this.options.enabled,this.#t)!==Oa(e.enabled,this.#t)||i!==this.#l)&&this.#v(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return _se(this,n)&&(this.#i=n,this.#a=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#S();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(xs)),e}#g(){this.#y();const t=Fu(this.options.staleTime,this.#t);if(Mf||this.#i.isStale||!LN(t))return;const n=YG(this.#i.dataUpdatedAt,t)+1;this.#c=ef.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#_(),this.#l=t,!(Mf||Oa(this.options.enabled,this.#t)===!1||!LN(this.#l)||this.#l===0)&&(this.#u=ef.setInterval(()=>{(this.options.refetchIntervalInBackground||GP.isFocused())&&this.#d()},this.#l))}#b(){this.#g(),this.#v(this.#x())}#y(){this.#c&&(ef.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(ef.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,s=this.#r,a=this.#a,l=t!==n?t.state:this.#n,{state:c}=t;let u={...c},h=!1,g;if(e._optimisticResults){const j=this.hasListeners(),N=!j&&KU(t,e),k=j&&YU(t,n,e,r);(N||k)&&(u={...u,...r9(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:b,status:y}=u;g=u.data;let v=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let j;i?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(j=i.data,v=!0):j=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,j!==void 0&&(y="success",g=jN(i?.data,j,e),h=!0)}if(e.select&&g!==void 0&&!v)if(i&&g===s?.data&&e.select===this.#m)g=this.#f;else try{this.#m=e.select,g=e.select(g),g=jN(i?.data,g,e),this.#f=g,this.#s=null}catch(j){this.#s=j}this.#s&&(m=this.#s,g=this.#f,b=Date.now(),y="error");const x=u.fetchStatus==="fetching",M=y==="pending",w=y==="error",T=M&&x,A=g!==void 0,C={status:y,fetchStatus:u.fetchStatus,isPending:M,isSuccess:y==="success",isError:w,isInitialLoading:T,isLoading:T,data:g,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:b,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:x,isRefetching:x&&!M,isLoadingError:w&&!A,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&A,isStale:WP(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Oa(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const j=F=>{C.status==="error"?F.reject(C.error):C.data!==void 0&&F.resolve(C.data)},N=()=>{const F=this.#o=C.promise=UN();j(F)},k=this.#o;switch(k.status){case"pending":t.queryHash===n.queryHash&&j(k);break;case"fulfilled":(C.status==="error"||C.data!==k.value)&&N();break;case"rejected":(C.status!=="error"||C.error!==k.reason)&&N();break}}return C}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#h=this.#t),K_(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const s=new Set(i??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(a=>{const o=a;return this.#i[o]!==t[o]&&s.has(o)})};this.#w({listeners:n()})}#S(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#w(t){si.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function yse(t,e){return Oa(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function KU(t,e){return yse(t,e)||t.state.data!==void 0&&zN(t,e,e.refetchOnMount)}function zN(t,e,n){if(Oa(e.enabled,t)!==!1&&Fu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&WP(t,e)}return!1}function YU(t,e,n,r){return(t!==e||Oa(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&WP(t,n)}function WP(t,e){return Oa(e.enabled,t)!==!1&&t.isStaleByTime(Fu(e.staleTime,t))}function _se(t,e){return!K_(t.getCurrentResult(),e)}function ZU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const c=async()=>{let u=!1;const h=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?u=!0:e.signal.addEventListener("abort",()=>{u=!0}),e.signal)})},g=QG(e.options,e.fetchOptions),m=async(b,y,v)=>{if(u)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const M=(()=>{const P={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return h(P),P})(),w=await g(M),{maxPages:T}=e.options,A=v?fse:dse;return{pages:A(b.pages,w,T),pageParams:A(b.pageParams,y,T)}};if(i&&s.length){const b=i==="backward",y=b?Sse:QU,v={pages:s,pageParams:a},x=y(r,v);o=await m(v,x,b)}else{const b=t??s.length;do{const y=l===0?a[0]??r.initialPageParam:QU(r,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(l<b)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=c}}}function QU(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 Sse(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var wse=class extends n9{#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||i9(),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=t9({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,a)=>{this.#r({type:"failed",failureCount:s,error:a})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const a=await this.options.onMutate?.(t,n);a!==this.state.context&&this.#r({type:"pending",context:a,variables:t,isPaused:i})}const s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#r({type:"success",data:s}),s}catch(s){try{throw await this.#n.config.onError?.(s,t,this.state.context,this,n),await this.options.onError?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,s,t,this.state.context,n),s}finally{this.#r({type:"error",error:s})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),si.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function i9(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Mse=class extends Tm{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 wse({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=Bb(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=Bb(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=Bb(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=Bb(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){si.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=>VU(e,n))}findAll(t={}){return this.getAll().filter(e=>VU(t,e))}notify(t){si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return si.batch(()=>Promise.all(t.map(e=>e.continue().catch(xs))))}};function Bb(t){return t.options.scope?.id}var Ese=class extends Tm{#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),K_(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Ef(n.mutationKey)!==Ef(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??i9();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){si.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)})})}},Ase=class extends Tm{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??$P(r,e);let s=this.get(i);return s||(s=new vse({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(s)),s}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){si.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=>$U(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>$U(t,n)):e}notify(t){si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){si.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){si.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Tse=class{#e;#t;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#e=t.queryCache||new Ase,this.#t=t.mutationCache||new Mse,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=GP.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Y_.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Fu(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),s=this.#e.get(r.queryHash)?.state.data,a=lse(e,s);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(t,e,n){return si.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;si.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return si.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=si.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(xs).catch(xs)}invalidateQueries(t,e={}){return si.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=si.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(xs)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(xs)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Fu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(xs).catch(xs)}fetchInfiniteQuery(t){return t.behavior=ZU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(xs).catch(xs)}ensureInfiniteQueryData(t){return t.behavior=ZU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Y_.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Ef(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{Kx(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Ef(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{Kx(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=$P(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===VP&&(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()}},s9=E.createContext(void 0),Rn=t=>{const e=E.useContext(s9);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Cse=({client:t,children:e})=>(E.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),f.jsx(s9.Provider,{value:t,children:e})),a9=E.createContext(!1),Nse=()=>E.useContext(a9);a9.Provider;function Rse(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Pse=E.createContext(Rse()),kse=()=>E.useContext(Pse),Dse=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Ose=t=>{E.useEffect(()=>{t.clearReset()},[t])},Lse=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||JG(n,[t.error,r])),Ise=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))}},jse=(t,e)=>t.isLoading&&t.isFetching&&!e,Use=(t,e)=>t?.suspense&&e.isPending,JU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Fse(t,e,n){const r=Nse(),i=kse(),s=Rn(),a=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=r?"isRestoring":"optimistic",Ise(a),Dse(a,i),Ose(i);const o=!s.getQueryCache().get(a.queryHash),[l]=E.useState(()=>new e(s,a)),c=l.getOptimisticResult(a),u=!r&&t.subscribed!==!1;if(E.useSyncExternalStore(E.useCallback(h=>{const g=u?l.subscribe(si.batchCalls(h)):xs;return l.updateResult(),g},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),E.useEffect(()=>{l.setOptions(a)},[a,l]),Use(a,c))throw JU(a,l,i);if(Lse({result:c,errorResetBoundary:i,throwOnError:a.throwOnError,query:s.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw c.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(a,c),a.experimental_prefetchInRender&&!Mf&&jse(c,r)&&(o?JU(a,l,i):s.getQueryCache().get(a.queryHash)?.promise)?.catch(xs).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?c:l.trackResult(c)}function At(t,e){return Fse(t,bse)}function Tt(t,e){const n=Rn(),[r]=E.useState(()=>new Ese(n,t));E.useEffect(()=>{r.setOptions(t)},[r,t]);const i=E.useSyncExternalStore(E.useCallback(a=>r.subscribe(si.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=E.useCallback((a,o)=>{r.mutate(a,o).catch(xs)},[r]);if(i.error&&JG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const zse=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Bse=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),eF=t=>{const e=Bse(t);return e.charAt(0).toUpperCase()+e.slice(1)},o9=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Hse=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var $se={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 Vse=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:a,...o},l)=>E.createElement("svg",{ref:l,...$se,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:o9("lucide",i),...!s&&!Hse(o)&&{"aria-hidden":"true"},...o},[...a.map(([c,u])=>E.createElement(c,u)),...Array.isArray(s)?s:[s]]));const it=(t,e)=>{const n=E.forwardRef(({className:r,...i},s)=>E.createElement(Vse,{ref:s,iconNode:e,className:o9(`lucide-${zse(eF(t))}`,`lucide-${t}`,r),...i}));return n.displayName=eF(t),n};const Gse=[["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"}]],Wse=it("archive",Gse);const qse=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Yx=it("arrow-down",qse);const Xse=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],BN=it("arrow-right",Xse);const Kse=[["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"}]],Yse=it("arrow-up-down",Kse);const Zse=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Wp=it("arrow-up",Zse);const Qse=[["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"}]],S_=it("bell",Qse);const Jse=[["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"}]],eae=it("bold",Jse);const tae=[["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"}]],qp=it("box",tae);const nae=[["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"}]],rae=it("cable",nae);const iae=[["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"}]],sae=it("calendar-days",iae);const aae=[["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"}]],as=it("calendar",aae);const oae=[["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"}]],Z_=it("camera",oae);const lae=[["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"}]],cae=it("chart-column",lae);const uae=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Xp=it("check",uae);const dae=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],$0=it("chevron-down",dae);const fae=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Cm=it("chevron-right",fae);const hae=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Af=it("chevron-left",hae);const pae=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],l9=it("chevron-up",pae);const mae=[["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"}]],Eo=it("circle-alert",mae);const gae=[["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"}]],tF=it("circle-arrow-up",gae);const xae=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],mc=it("circle-check-big",xae);const vae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],bae=it("circle-dot",vae);const yae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],_ae=it("circle-stop",yae);const Sae=[["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"}]],V0=it("circle-x",Sae);const wae=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Pi=it("clock",wae);const Mae=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],qP=it("cloud",Mae);const Eae=[["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"}]],Aae=it("code-xml",Eae);const Tae=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Cae=it("code",Tae);const Nae=[["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"}]],Rae=it("cog",Nae);const Pae=[["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"}]],Kp=it("copy",Pae);const kae=[["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"}]],nF=it("database",kae);const Dae=[["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"}]],rF=it("dollar-sign",Dae);const Oae=[["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"}]],tl=it("download",Oae);const Lae=[["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"}]],XP=it("droplet",Lae);const Iae=[["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"}]],jae=it("droplets",Iae);const Uae=[["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"}]],Fae=it("ellipsis-vertical",Uae);const zae=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],WA=it("equal",zae);const Bae=[["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"}]],gc=it("external-link",Bae);const Hae=[["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"}]],KP=it("eye-off",Hae);const $ae=[["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"}]],Zx=it("eye",$ae);const Vae=[["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"}]],Gae=it("fan",Vae);const Wae=[["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"}]],qae=it("file-box",Wae);const Xae=[["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"}]],iF=it("file-code",Xae);const Kae=[["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"}]],Yae=it("file-exclamation-point",Kae);const Zae=[["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"}]],Pu=it("file-text",Zae);const Qae=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],c9=it("file",Qae);const Jae=[["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"}]],kp=it("film",Jae);const eoe=[["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"}]],toe=it("flame",eoe);const noe=[["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"}]],roe=it("folder-open",noe);const ioe=[["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"}]],soe=it("folder",ioe);const aoe=[["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"}]],YP=it("funnel",aoe);const ooe=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ZP=it("gauge",ooe);const loe=[["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"}]],Ex=it("git-compare",loe);const coe=[["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"}]],sF=it("github",coe);const uoe=[["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"}]],Q_=it("globe",uoe);const doe=[["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"}]],QP=it("grip-vertical",doe);const foe=[["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"}]],u9=it("hard-drive",foe);const hoe=[["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"}]],sw=it("image",hoe);const poe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],d9=it("info",poe);const moe=[["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"}]],goe=it("italic",moe);const xoe=[["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"}]],voe=it("key",xoe);const boe=[["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"}]],HN=it("keyboard",boe);const yoe=[["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"}]],Tf=it("layers",yoe);const _oe=[["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"}]],f9=it("layout-grid",_oe);const Soe=[["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"}]],woe=it("layout-list",Soe);const Moe=[["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"}]],Eoe=it("link-2-off",Moe);const Aoe=[["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"}]],Toe=it("link-2",Aoe);const Coe=[["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"}]],h9=it("link",Coe);const Noe=[["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"}]],p9=it("list-ordered",Noe);const Roe=[["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"}]],JP=it("list",Roe);const Poe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Vt=it("loader-circle",Poe);const koe=[["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"}]],aF=it("log-in",koe);const Doe=[["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"}]],Ooe=it("log-out",Doe);const Loe=[["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"}]],Ioe=it("maximize-2",Loe);const joe=[["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"}]],Uoe=it("maximize",joe);const Foe=[["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"}]],zoe=it("minimize-2",Foe);const Boe=[["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"}]],Hoe=it("minimize",Boe);const $oe=[["path",{d:"M5 12h14",key:"1ays0h"}]],oF=it("minus",$oe);const Voe=[["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"}]],J_=it("moon",Voe);const Goe=[["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"}]],e1=it("package",Goe);const Woe=[["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"}]],qoe=it("pause",Woe);const Xoe=[["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"}]],t1=it("pen-line",Xoe);const Koe=[["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"}]],ek=it("pen",Koe);const Yoe=[["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"}]],Cf=it("pencil",Yoe);const Zoe=[["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"}]],aw=it("play",Zoe);const Qoe=[["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"}]],w_=it("plug",Qoe);const Joe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ai=it("plus",Joe);const ele=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],m9=it("power-off",ele);const tle=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Xf=it("power",tle);const nle=[["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"}]],nl=it("printer",nle);const rle=[["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"}]],ile=it("qr-code",rle);const sle=[["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"}]],Ka=it("refresh-cw",sle);const ale=[["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"}]],G0=it("rotate-ccw",ale);const ole=[["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"}]],lle=it("ruler",ole);const cle=[["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"}]],Xo=it("save",cle);const ule=[["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"}]],dle=it("scan-search",ule);const fle=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ku=it("search",fle);const hle=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],g9=it("send",hle);const ple=[["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"}]],ow=it("settings-2",ple);const mle=[["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"}]],x9=it("settings",mle);const gle=[["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"}]],xle=it("signal",gle);const vle=[["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"}]],ble=it("skip-back",vle);const yle=[["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"}]],v9=it("skip-forward",yle);const _le=[["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"}]],lF=it("sliders-vertical",_le);const Sle=[["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"}]],Qx=it("sparkles",Sle);const wle=[["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"}]],Nf=it("square-check-big",wle);const Mle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Yp=it("square",Mle);const Ele=[["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"}]],Jx=it("star",Ele);const Ale=[["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"}]],b9=it("sticky-note",Ale);const Tle=[["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"}]],cF=it("sun",Tle);const Cle=[["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"}]],e0=it("tag",Cle);const Nle=[["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"}]],y9=it("target",Nle);const Rle=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ple=it("terminal",Rle);const kle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Dle=it("text-align-center",kle);const Ole=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Lle=it("text-align-end",Ole);const Ile=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],jle=it("text-align-start",Ile);const Ule=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Dp=it("thermometer",Ule);const Fle=[["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"}]],ku=it("timer",Fle);const zle=[["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"}]],fr=it("trash-2",zle);const Ble=[["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"}]],Ao=it("triangle-alert",Ble);const Hle=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],$le=it("underline",Hle);const Vle=[["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"}]],_9=it("unlink",Vle);const Gle=[["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"}]],Yu=it("upload",Gle);const Wle=[["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"}]],uF=it("user",Wle);const qle=[["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"}]],Xle=it("video",qle);const Kle=[["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"}]],tk=it("wifi-off",Kle);const Yle=[["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"}]],S9=it("wifi",Yle);const Zle=[["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"}]],Qle=it("wind",Zle);const Jle=[["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"}]],Zp=it("wrench",Jle);const ece=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tn=it("x",ece);const tce=[["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"}]],nce=it("zoom-in",tce);const rce=[["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"}]],nk=it("zap",rce);const ice=[["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"}]],sce=it("zoom-out",ice),w9=E.createContext(void 0);function ace({children:t}){const[e,n]=E.useState(()=>{const s=localStorage.getItem("theme");return s||(window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark")});E.useEffect(()=>{const s=document.documentElement;e==="dark"?s.classList.add("dark"):s.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const r=()=>{n(s=>s==="dark"?"light":"dark")},i=s=>{n(s)};return f.jsx(w9.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function M9(){const t=E.useContext(w9);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Ft({children:t,className:e="",onClick:n,onContextMenu:r}){return f.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function qd({children:t,className:e=""}){return f.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function $t({children:t,className:e=""}){return f.jsx("div",{className:`p-6 ${e}`,children:t})}function oce(t,e){return[{category:"Navigation",items:t?t.map((r,i)=>({keys:[String(i+1)],description:`Go to ${e(r.labelKey)}`})):[{keys:["1"],description:"Go to Printers"},{keys:["2"],description:"Go to Archives"},{keys:["3"],description:"Go to Queue"},{keys:["4"],description:"Go to Statistics"},{keys:["5"],description:"Go to Cloud Profiles"},{keys:["6"],description:"Go to Settings"}]},{category:"Archives",items:[{keys:["/"],description:"Focus search"},{keys:["U"],description:"Open upload modal"},{keys:["Esc"],description:"Clear selection / blur input"},{keys:["Right-click"],description:"Context menu on cards"}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles"},{keys:["N"],description:"New profile"},{keys:["Esc"],description:"Exit selection mode"}]},{category:"General",items:[{keys:["?"],description:"Show this help"}]}]}function dF({children:t}){return f.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 lce({onClose:t,navItems:e}){const{t:n}=IP(),r=oce(e,n);return E.useEffect(()=>{const i=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:f.jsx(Ft,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:f.jsxs($t,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(HN,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:r.map(i=>f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:i.category}),f.jsx("div",{className:"space-y-2",children:i.items.map(s=>f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-white text-sm",children:s.description}),f.jsx("div",{className:"flex gap-1",children:s.keys.map(a=>f.jsx(dF,{children:a},a))})]},s.description))})]},i.category))}),f.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:f.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",f.jsx(dF,{children:"Esc"})," or click outside to close"]})})]})})})}const kr="/api/v1";async function dt(t,e={}){const n=await fetch(`${kr}${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 Ue={getPrinters:()=>dt("/printers/"),getPrinter:t=>dt(`/printers/${t}`),createPrinter:t=>dt("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>dt(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>dt(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>dt(`/printers/${t}/status`),connectPrinter:t=>dt(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>dt(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>dt(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>dt(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>dt(`/printers/${t}/logging`),clearMQTTLogs:t=>dt(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>dt(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${kr}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>dt(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>dt(`/printers/${t}/storage`),getArchives:(t,e=50,n=0)=>{const r=new URLSearchParams;return t&&r.set("printer_id",String(t)),r.set("limit",String(e)),r.set("offset",String(n)),dt(`/archives/?${r}`)},getArchive:t=>dt(`/archives/${t}`),updateArchive:(t,e)=>dt(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>dt(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>dt(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>dt("/archives/stats"),getArchiveDuplicates:t=>dt(`/archives/${t}/duplicates`),backfillContentHashes:()=>dt("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${kr}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${kr}/archives/${t}/download`,getArchiveGcode:t=>`${kr}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${kr}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>dt(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>dt(`/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(`${kr}/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)=>`${kr}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${kr}/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)=>dt(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${kr}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${kr}/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(`${kr}/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=>dt(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${kr}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>dt(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>dt(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>dt(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${kr}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${kr}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>dt(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${kr}/archives/upload?printer_id=${e}`:`${kr}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(s=>n.append("files",s));const r=e?`${kr}/archives/upload-bulk?printer_id=${e}`:`${kr}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>dt("/settings/"),updateSettings:t=>dt("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>dt("/settings/reset",{method:"POST"}),checkFfmpeg:()=>dt("/settings/check-ffmpeg"),getCloudStatus:()=>dt("/cloud/status"),cloudLogin:(t,e,n="global")=>dt("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>dt("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>dt("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>dt("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>dt(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>dt(`/cloud/settings/${t}`),createCloudSetting:t=>dt("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>dt(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>dt(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>dt("/cloud/devices"),getCloudFields:t=>dt(`/cloud/fields/${t}`),getAllCloudFields:()=>dt("/cloud/fields"),getSmartPlugs:()=>dt("/smart-plugs/"),getSmartPlug:t=>dt(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>dt(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>dt("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>dt(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>dt(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>dt(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>dt(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>dt("/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),dt(`/queue/?${n}`)},getQueueItem:t=>dt(`/queue/${t}`),addToQueue:t=>dt("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>dt(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>dt(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>dt("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>dt(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>dt(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>dt(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>dt(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>dt(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>dt(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>dt(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>dt(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>dt(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>dt(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>dt(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>dt(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>dt(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>dt("/filaments/"),getFilament:t=>dt(`/filaments/${t}`),getFilamentsByType:t=>dt(`/filaments/by-type/${t}`),getNotificationProviders:()=>dt("/notifications/"),getNotificationProvider:t=>dt(`/notifications/${t}`),createNotificationProvider:t=>dt("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>dt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>dt(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>dt(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>dt("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),getNotificationTemplates:()=>dt("/notification-templates"),getNotificationTemplate:t=>dt(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>dt(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>dt(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>dt("/notification-templates/variables"),previewTemplate:t=>dt("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getSpoolmanStatus:()=>dt("/spoolman/status"),connectSpoolman:()=>dt("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>dt("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>dt(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>dt("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>dt("/spoolman/spools"),getSpoolmanFilaments:()=>dt("/spoolman/filaments"),getVersion:()=>dt("/updates/version"),checkForUpdates:()=>dt("/updates/check"),applyUpdate:()=>dt("/updates/apply",{method:"POST"}),getUpdateStatus:()=>dt("/updates/status"),getMaintenanceTypes:()=>dt("/maintenance/types"),createMaintenanceType:t=>dt("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>dt(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>dt(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>dt("/maintenance/overview"),getPrinterMaintenance:t=>dt(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>dt(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>dt(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>dt(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>dt("/maintenance/summary"),setPrinterHours:(t,e)=>dt(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),getCameraStreamUrl:(t,e=10)=>`${kr}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${kr}/printers/${t}/camera/snapshot`,testCameraConnection:t=>dt(`/printers/${t}/camera/test`)},M_=[{id:"printers",to:"/",icon:nl,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Wse,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:as,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:cae,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:qP,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Zp,labelKey:"nav.maintenance"},{id:"settings",to:"/settings",icon:x9,labelKey:"nav.settings"}];function cce(){const t=localStorage.getItem("sidebarOrder");if(t)try{const e=JSON.parse(t),n=new Map(M_.map(i=>[i.id,i])),r=[];for(const i of e){const s=n.get(i);s&&(r.push(s),n.delete(i))}for(const i of n.values())r.push(i);return r}catch{return M_}return M_}function uce(t){localStorage.setItem("sidebarOrder",JSON.stringify(t.map(e=>e.id)))}function E9(){return localStorage.getItem("defaultView")||"/"}function dce(t){localStorage.setItem("defaultView",t)}function fce(){const t=UP(),e=ld(),{theme:n,toggleTheme:r}=M9(),{t:i}=IP(),[s,a]=E.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[o,l]=E.useState(!1),[c,u]=E.useState(cce),[h,g]=E.useState(null),[m,b]=E.useState(null),y=E.useRef(!1),{data:v}=At({queryKey:["version"],queryFn:Ue.getVersion,staleTime:1/0}),{data:x}=At({queryKey:["settings"],queryFn:Ue.getSettings,staleTime:300*1e3}),{data:M}=At({queryKey:["updateCheck"],queryFn:Ue.checkForUpdates,enabled:x?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3});E.useEffect(()=>{if(!y.current&&e.pathname==="/"){const N=E9();N!=="/"&&(y.current=!0,t(N,{replace:!0}))}},[e.pathname,t]),E.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]);const w=(N,k)=>{g(k),N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",String(k))},T=(N,k)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",b(k)},A=()=>{b(null)},P=(N,k)=>{if(N.preventDefault(),h===null||h===k){g(null),b(null);return}const F=[...c],[I]=F.splice(h,1);F.splice(k,0,I),u(F),uce(F),g(null),b(null)},C=()=>{g(null),b(null)},j=E.useCallback(N=>{const k=N.target;if(!(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){const F=parseInt(N.key);if(F>=1&&F<=c.length){N.preventDefault(),t(c[F-1].to);return}switch(N.key){case"?":N.preventDefault(),l(!0);break;case"Escape":l(!1);break}}},[t,c]);return E.useEffect(()=>(document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)),[j]),f.jsxs("div",{className:"flex min-h-screen",children:[f.jsxs("aside",{className:`${s?"w-64":"w-16"} bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col fixed inset-y-0 left-0 z-30 transition-all duration-300`,children:[f.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s?"p-4":"p-2"}`,children:f.jsx("img",{src:n==="dark"?"/img/bambusy_logo_dark.png":"/img/bambusy_logo_light.png",alt:"Bambusy",className:s?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),f.jsx("nav",{className:"flex-1 p-2",children:f.jsx("ul",{className:"space-y-2",children:c.map(({id:N,to:k,icon:F,labelKey:I},W)=>f.jsx("li",{draggable:!0,onDragStart:D=>w(D,W),onDragOver:D=>T(D,W),onDragLeave:A,onDrop:D=>P(D,W),onDragEnd:C,className:`relative ${h===W?"opacity-50":""} ${m===W&&h!==W?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:f.jsxs(XG,{to:k,className:({isActive:D})=>`flex items-center ${s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${D?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:s?void 0:i(I),children:[s&&f.jsx(QP,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),f.jsx(F,{className:"w-5 h-5 flex-shrink-0"}),s&&f.jsx("span",{children:i(I)})]})},N))})}),f.jsx("button",{onClick:()=>a(!s),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(s?"nav.collapseSidebar":"nav.expandSidebar"),children:s?f.jsx(Af,{className:"w-5 h-5"}):f.jsx(Cm,{className:"w-5 h-5"})}),f.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s?f.jsxs("div",{className:"flex items-center justify-between px-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",v?.version||"..."]}),M?.update_available&&f.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:M.latest_version}),children:[f.jsx(tF,{className:"w-4 h-4"}),f.jsx("span",{children:i("nav.update")})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("a",{href:"https://github.com/maziggy/bambusy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:f.jsx(sF,{className:"w-5 h-5"})}),f.jsx("button",{onClick:()=>l(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:f.jsx(HN,{className:"w-5 h-5"})}),f.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"?f.jsx(cF,{className:"w-5 h-5"}):f.jsx(J_,{className:"w-5 h-5"})})]})]}):f.jsxs("div",{className:"flex flex-col items-center gap-1",children:[M?.update_available&&f.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:M.latest_version}),children:f.jsx(tF,{className:"w-5 h-5"})}),f.jsx("a",{href:"https://github.com/maziggy/bambusy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:f.jsx(sF,{className:"w-5 h-5"})}),f.jsx("button",{onClick:()=>l(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:f.jsx(HN,{className:"w-5 h-5"})}),f.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"?f.jsx(cF,{className:"w-5 h-5"}):f.jsx(J_,{className:"w-5 h-5"})})]})})]}),f.jsx("main",{className:`flex-1 bg-bambu-dark overflow-auto ${s?"ml-64":"ml-16"} transition-all duration-300`,children:f.jsx(Mie,{})}),o&&f.jsx(lce,{onClose:()=>l(!1),navItems:c})]})}function We({variant:t="primary",size:e="md",className:n="",children:r,...i}){const s="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",a={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-6 py-3 text-base gap-2"};return f.jsx("button",{className:`${s} ${a[t]} ${o[e]} ${n}`,...i,children:r})}function zs({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:s,onCancel:a}){E.useEffect(()=>{const c=u=>{u.key==="Escape"&&a()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]);const l={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a,children:f.jsx(Ft,{className:"w-full max-w-md",onClick:c=>c.stopPropagation(),children:f.jsxs($t,{className:"p-6",children:[f.jsxs("div",{className:"flex items-start gap-4",children:[f.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:f.jsx(Ao,{className:"w-6 h-6"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),f.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),f.jsxs("div",{className:"flex gap-3 mt-6",children:[f.jsx(We,{variant:"secondary",onClick:a,className:"flex-1",children:r}),f.jsx(We,{onClick:s,className:`flex-1 ${l.button}`,children:n})]})]})})})}const A9=E.createContext(void 0);function Ki(){const t=E.useContext(A9);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const hce={success:f.jsx(mc,{className:"w-5 h-5 text-green-400"}),error:f.jsx(V0,{className:"w-5 h-5 text-red-400"}),warning:f.jsx(Eo,{className:"w-5 h-5 text-yellow-400"}),info:f.jsx(d9,{className:"w-5 h-5 text-blue-400"})},pce={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30"};function mce({children:t}){const[e,n]=E.useState([]),r=E.useCallback((s,a="success")=>{const o=Math.random().toString(36).substr(2,9);n(l=>[...l,{id:o,message:s,type:a}]),setTimeout(()=>{n(l=>l.filter(c=>c.id!==o))},3e3)},[]),i=E.useCallback(s=>{n(a=>a.filter(o=>o.id!==s))},[]);return f.jsxs(A9.Provider,{value:{showToast:r},children:[t,f.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>f.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${pce[s.type]}`,children:[hce[s.type],f.jsx("span",{className:"text-white text-sm",children:s.message}),f.jsx("button",{onClick:()=>i(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-4 h-4"})})]},s.id))})]})}function gce(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 fF(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 xce(t,e){if(e)return soe;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return qae;case"gcode":return Pu;case"mp4":case"avi":return kp;case"png":case"jpg":case"jpeg":return sw;default:return c9}}function vce({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Ki(),i=Rn(),[s,a]=E.useState("/"),[o,l]=E.useState(null),[c,u]=E.useState(""),[h,g]=E.useState(null);E.useEffect(()=>{const C=j=>{j.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]);const{data:m,isLoading:b,refetch:y}=At({queryKey:["printerFiles",t,s],queryFn:()=>Ue.getPrinterFiles(t,s)}),{data:v}=At({queryKey:["printerStorage",t],queryFn:()=>Ue.getPrinterStorage(t),staleTime:3e4}),x=Tt({mutationFn:C=>Ue.deletePrinterFile(t,C),onSuccess:(C,j)=>{r(`Deleted: ${j.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:C=>{r(`Delete failed: ${C.message}`,"error")}}),M=C=>{a(C),l(null)},w=()=>{if(s==="/")return;const C=s.split("/").filter(Boolean);C.pop(),a(C.length?"/"+C.join("/"):"/"),l(null)},T=C=>{window.open(Ue.getPrinterFileDownloadUrl(t,C),"_blank")},A=C=>{g(C)},P=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[f.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:C=>C.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(u9,{className:"w-5 h-5 text-bambu-green"}),f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),f.jsxs("div",{className:"flex items-center gap-4",children:[v&&(v.used_bytes!=null||v.free_bytes!=null)&&f.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[v.used_bytes!=null&&f.jsxs("span",{children:["Used: ",fF(v.used_bytes)]}),v.used_bytes!=null&&v.free_bytes!=null&&f.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),v.free_bytes!=null&&f.jsxs("span",{children:["Free: ",fF(v.free_bytes)]})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[P.map(C=>f.jsx("button",{onClick:()=>{M(C.path),u("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${s===C.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:C.label},C.path)),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"relative",children:[f.jsx(Ku,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",placeholder:"Filter files...",value:c,onChange:C=>u(C.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),f.jsx(We,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:b,children:f.jsx(Ka,{className:`w-4 h-4 ${b?"animate-spin":""}`})})]}),f.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[f.jsx("button",{onClick:w,disabled:s==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:f.jsx(Af,{className:"w-4 h-4"})}),f.jsx("span",{className:"text-bambu-gray font-mono",children:s})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:b?f.jsx("div",{className:"flex items-center justify-center py-12",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?f.jsx("div",{className:"space-y-1",children:[...m.files].filter(C=>!c||C.name.toLowerCase().includes(c.toLowerCase())).sort((C,j)=>C.is_directory&&!j.is_directory?-1:!C.is_directory&&j.is_directory?1:C.name.localeCompare(j.name)).map(C=>{const j=xce(C.name,C.is_directory),N=o===C.path;return f.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${N?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{C.is_directory?M(C.path):l(N?null:C.path)},children:[f.jsx(j,{className:`w-5 h-5 flex-shrink-0 ${C.is_directory?"text-bambu-green":"text-bambu-gray"}`}),f.jsx("span",{className:"flex-1 text-white truncate",children:C.name}),!C.is_directory&&f.jsx("span",{className:"text-sm text-bambu-gray",children:gce(C.size)}),C.is_directory&&f.jsx(Af,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},C.path)})}):f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),f.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[f.jsx("div",{className:"text-sm text-bambu-gray",children:c?`${m?.files?.filter(C=>C.name.toLowerCase().includes(c.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(We,{variant:"secondary",disabled:!o,onClick:()=>o&&T(o),children:[f.jsx(tl,{className:"w-4 h-4"}),"Download"]}),f.jsxs(We,{variant:"secondary",disabled:!o||x.isPending,onClick:()=>o&&A(o),className:"text-red-400 hover:text-red-300",children:[x.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})]}),h&&f.jsx(zs,{title:"Delete File",message:`Delete "${h.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{x.mutate(h),g(null)},onCancel:()=>g(null)})]})}function bce({printerId:t,printerName:e,onClose:n}){const r=Rn(),[i,s]=E.useState(!0),[a,o]=E.useState(new Set),[l,c]=E.useState(""),[u,h]=E.useState("all"),g=E.useRef(null),{data:m,isLoading:b,refetch:y}=At({queryKey:["mqtt-logs",t],queryFn:()=>Ue.getMQTTLogs(t),refetchInterval:1e3}),v=Tt({mutationFn:()=>Ue.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),x=Tt({mutationFn:()=>Ue.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=Tt({mutationFn:()=>Ue.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});E.useEffect(()=>{const N=k=>{k.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]),E.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[m?.logs,i]);const w=N=>{o(k=>{const F=new Set(k);return F.has(N)?F.delete(N):F.add(N),F})},T=N=>new Date(N).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(N,k)=>{if(N==null)return"<empty>";const F=typeof N=="string"?JSON.parse(N):N,I=JSON.stringify(F,null,k?2:0);return!k&&I.length>100?I.substring(0,100)+"...":I},P=m?.logging_enabled??!1,C=m?.logs??[],j=E.useMemo(()=>C.filter(N=>{if(u!=="all"&&N.direction!==u)return!1;if(l.trim()){const k=l.toLowerCase(),F=N.topic.toLowerCase().includes(k),W=JSON.stringify(N.payload).toLowerCase().includes(k);return F||W}return!0}),[C,l,u]);return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[P?f.jsxs(We,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,children:[f.jsx(Yp,{className:"w-4 h-4"}),"Stop"]}):f.jsxs(We,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[f.jsx(aw,{className:"w-4 h-4"}),"Start Logging"]}),f.jsxs(We,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||C.length===0,children:[f.jsx(fr,{className:"w-4 h-4"}),"Clear"]}),f.jsx(We,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:b,children:f.jsx(Ka,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),f.jsx("div",{className:"flex-1"}),f.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:i,onChange:N=>s(N.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),f.jsxs("span",{className:"text-sm text-bambu-gray",children:[j.length,"/",C.length]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsx(Ku,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:l,onChange:N=>c(N.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),l&&f.jsx("button",{onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:f.jsx(tn,{className:"w-4 h-4"})})]}),f.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[f.jsx("button",{onClick:()=>h("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${u==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),f.jsxs("button",{onClick:()=>h("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${u==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[f.jsx(Yx,{className:"w-3 h-3"}),"In"]}),f.jsxs("button",{onClick:()=>h("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${u==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[f.jsx(Wp,{className:"w-3 h-3"}),"Out"]})]})]})]}),f.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:C.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[f.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!P&&f.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):j.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[f.jsx("p",{className:"mb-2",children:"No messages match your filter"}),f.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):f.jsx("div",{className:"space-y-1",children:j.map((N,k)=>{const F=a.has(k),I=N.direction==="in";return f.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>w(k),children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx("span",{className:"text-bambu-gray shrink-0",children:T(N.timestamp)}),f.jsx("span",{className:`shrink-0 ${I?"text-blue-400":"text-green-400"}`,title:I?"Incoming":"Outgoing",children:I?f.jsx(Yx,{className:"w-3 h-3"}):f.jsx(Wp,{className:"w-3 h-3"})}),f.jsx("span",{className:"text-purple-400 shrink-0",children:N.topic})]}),F?f.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:A(N.payload,!0)}):f.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(N.payload,!1)})]},k)})})}),f.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[f.jsx("div",{className:"text-sm text-bambu-gray",children:P?f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):f.jsx("span",{children:"Logging stopped"})}),f.jsx(We,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const yce={"0700_5500_0002_0001":"A binding error occurred between AMS and the extruder. Please perform AMS initialization again.","0500_0300_0002_000E":"Some modules are incompatible with the printer firmware version. Please update firmware.","0300_0100_0002_0054":"The heatbed temperature is abnormal. The sensor may be disconnected or damaged.","0500_0100_0005_0005":"Motor driver overheated. Let the printer cool down.","0500_0100_0005_0006":"Motor driver communication error.","0700_0100_0007_0001":"AMS communication error.","0700_0100_0007_0002":"AMS filament runout.","0700_0100_0007_0003":"AMS filament not detected.","0C00_0100_000C_0003":"First layer inspection failed.","0C00_0100_000C_0004":"Nozzle clog detected.","0C00_0100_000C_8000":"Foreign object detected on print bed.","0500_0100_0005_0000":"Motor X axis lost steps.","0500_0100_0005_0001":"Motor Y axis lost steps.","0500_0100_0005_0002":"Motor Z axis lost steps."};function _ce(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Ao};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Ao};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Eo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:d9}}}function T9(t,e){const n=(t>>24&255).toString(16).padStart(2,"0").toUpperCase(),r=(t>>16&255).toString(16).padStart(2,"0").toUpperCase(),i=(t>>8&255).toString(16).padStart(2,"0").toUpperCase(),s=(t&255).toString(16).padStart(2,"0").toUpperCase(),a=(e>>24&255).toString(16).padStart(2,"0").toUpperCase(),o=(e>>16&255).toString(16).padStart(2,"0").toUpperCase(),l=(e>>8&255).toString(16).padStart(2,"0").toUpperCase(),c=(e&255).toString(16).padStart(2,"0").toUpperCase();return`${n}${r}_${i}${s}_${a}${o}_${l}${c}`}function Sce(t,e,n){const r=T9(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function wce({printerName:t,errors:e,onClose:n}){return console.log("HMSErrorModal errors:",JSON.stringify(e,null,2)),E.useEffect(()=>{const r=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Ao,{className:"w-5 h-5 text-orange-400"}),f.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),f.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(tn,{className:"w-5 h-5 text-bambu-gray"})})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?f.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[f.jsx(Eo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),f.jsx("p",{children:"No HMS errors"})]}):f.jsx("div",{className:"space-y-3",children:e.map((r,i)=>{const{label:s,color:a,bgColor:o,Icon:l}=_ce(r.severity),c=parseInt(r.code.replace("0x",""),16)||0,u=T9(r.attr,c),h=yce[u]||"Unknown error. Click the link below for details.",g=Sce(r.attr,c,t),m=`HMS_${u.replace(/_/g,"-")}`;return f.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx(l,{className:`w-5 h-5 ${a} flex-shrink-0 mt-0.5`}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("span",{className:`font-mono text-sm ${a}`,children:m}),f.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${a}`,children:s})]}),f.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:h}),f.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[f.jsx(gc,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${r.code}-${i}`)})})}),f.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:f.jsx("p",{className:"text-xs text-bambu-gray",children:"HMS (Health Management System) monitors printer health. Clear errors on the printer to dismiss them here."})})]})})}function Mce(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 Ece({printerId:t}){const{data:e}=At({queryKey:["queue",t,"pending"],queryFn:()=>Ue.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:f.jsx(iw,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:f.jsxs("div",{className:"flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[f.jsx(as,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),f.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[f.jsx(Pi,{className:"w-3 h-3"}),Mce(n?.scheduled_time||null)]}),r>1&&f.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),f.jsx(Cm,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function Ace({side:t}){const{theme:e}=M9(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return f.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 hF({className:t}){return f.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:f.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 Tce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.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"}),f.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 Cce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.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"}),f.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 Nce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.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"}),f.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function Rce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),f.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),f.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 Pce({className:t}){return f.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),f.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),f.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 kce({humidity:t,goodThreshold:e=40,fairThreshold:n=60}){const r=typeof t=="string"?parseInt(t,10):t,i=typeof e=="number"?e:40,s=typeof n=="number"?n:60;let a,o;isNaN(r)?(a="#C3C2C1",o="Unknown"):r<=i?(a="#22a352",o="Good"):r<=s?(a="#d4a017",o="Fair"):(a="#c62828",o="Bad");let l;return isNaN(r)||r<=i?l=hF:r<=s?l=Tce:l=Cce,f.jsxs("div",{className:"flex items-center justify-end gap-1",title:`Humidity: ${r}% - ${o}`,children:[f.jsx(l,{className:"w-3 h-4"}),f.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:a},children:[r,"%"]})]})}function Dce({temp:t,goodThreshold:e=28,fairThreshold:n=35}){const r=typeof e=="number"?e:28,i=typeof n=="number"?n:35;let s,a;return t<=r?(s="#22a352",a=Nce):t<=i?(s="#d4a017",a=Rce):(s="#c62828",a=Pce),f.jsxs("span",{className:"flex items-center gap-1",title:"Temperature",children:[f.jsx(a,{className:"w-3 h-4"}),f.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:s},children:[t,"°C"]})]})}function Oce(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,s=r>=128?r-128:r,a=String.fromCharCode(65+s);return i?`HT-${a}`:`AMS-${a}`}function Lce(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Ice(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),r=new Date;r.setHours(0,0,0,0);const i=new Date(n);i.setHours(0,0,0,0);const s=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),a=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return a===0?s:a===1?`Tomorrow ${s}`:n.toLocaleDateString([],{weekday:"short"})+" "+s}function jce(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 Uce(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 Fce({url:t,printName:e}){const[n,r]=E.useState(!1),[i,s]=E.useState(!1),[a,o]=E.useState(!1);return f.jsxs(f.Fragment,{children:[f.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?f.jsxs(f.Fragment,{children:[f.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>s(!0)}),!n&&f.jsx(qp,{className:"w-8 h-8 text-bambu-gray"})]}):f.jsx(qp,{className:"w-8 h-8 text-bambu-gray"})}),a&&t&&f.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:f.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[f.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&f.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function zce({printers:t}){const e=Rn(),n=E.useMemo(()=>{let i=0,s=0,a=0,o=0;return t?.forEach(l=>{const c=e.getQueryData(["printerStatus",l.id]);c===void 0?o++:c.connected?c.state==="RUNNING"?i++:s++:a++}),{printing:i,idle:s,offline:a,loading:o,total:t?.length||0}},[t,e]),[,r]=E.useState(0);return E.useEffect(()=>{const i=e.getQueryCache().subscribe(()=>{r(s=>s+1)});return()=>i()},[e]),t?.length?f.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),f.jsxs("span",{className:"text-bambu-gray",children:[f.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),f.jsxs("span",{className:"text-bambu-gray",children:[f.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),f.jsxs("span",{className:"text-bambu-gray",children:[f.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function pF({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const s=Rn(),a=UP(),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[h,g]=E.useState(!1),[m,b]=E.useState(!1),[y,v]=E.useState(!1),[x,M]=E.useState(!1),[w,T]=E.useState(!1),[A,P]=E.useState(!1),{data:C}=At({queryKey:["printerStatus",t.id],queryFn:()=>Ue.getPrinterStatus(t.id),refetchInterval:3e4}),[j,N]=E.useState(null);E.useEffect(()=>{C?.wifi_signal!=null&&N(C.wifi_signal)},[C?.wifi_signal]);const k=C?.wifi_signal??j,F=E.useRef({});E.useEffect(()=>{C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0&&(F.current=C.ams_extruder_map)},[C?.ams_extruder_map]);const I=C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0?C.ams_extruder_map:F.current,W=E.useRef([]);E.useEffect(()=>{C?.ams&&C.ams.length>0&&(W.current=C.ams)},[C?.ams]);const D=C?.ams&&C.ams.length>0?C.ams:W.current,{data:$}=At({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Ue.getSmartPlugByPrinter(t.id)}),{data:G}=At({queryKey:["smartPlugStatus",$?.id],queryFn:()=>$?Ue.getSmartPlugStatus($.id):null,enabled:!!$,refetchInterval:1e4}),{data:V}=At({queryKey:["queue",t.id,"pending"],queryFn:()=>Ue.getQueue(t.id,"pending")}),Z=V?.length||0,{data:K}=At({queryKey:["archives",t.id,"last"],queryFn:()=>Ue.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),ee=K?.[0],H=e&&C&&!C.connected,Y=Tt({mutationFn:()=>Ue.deletePrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printers"]})}}),te=Tt({mutationFn:()=>Ue.connectPrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printerStatus",t.id]})}}),ae=Tt({mutationFn:Q=>$?Ue.controlSmartPlug($.id,Q):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugStatus",$?.id]})}}),fe=Tt({mutationFn:Q=>$?Ue.updateSmartPlug($.id,{auto_off:Q}):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),s.invalidateQueries({queryKey:["smart-plugs"]})}});return H?null:f.jsxs(Ft,{className:"relative",children:[f.jsxs($t,{children:[f.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[f.jsxs("div",{className:"flex items-start justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[f.jsx("img",{src:jce(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"}`}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&f.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${C?.connected?"bg-bambu-green":"bg-red-500"}`,title:C?.connected?"Connected":"Offline"})]}),f.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&C?.nozzles&&C.nozzles[0]?.nozzle_diameter&&f.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:C.nozzles[0].nozzle_type||"Nozzle",children:["• ",C.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&f.jsxs("span",{className:"ml-2 text-bambu-gray",children:[f.jsx(Pi,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),f.jsxs("div",{className:"relative flex-shrink-0",children:[f.jsx(We,{variant:"ghost",size:"sm",onClick:()=>l(!o),children:f.jsx(Fae,{className:"w-4 h-4"})}),o&&f.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:[f.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{g(!0),l(!1)},children:[f.jsx(Cf,{className:"w-4 h-4"}),"Edit"]}),f.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{te.mutate(),l(!1)},children:[f.jsx(Ka,{className:"w-4 h-4"}),"Reconnect"]}),f.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{v(!0),l(!1)},children:[f.jsx(Ple,{className:"w-4 h-4"}),"MQTT Debug"]}),f.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:()=>{u(!0),l(!1)},children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&f.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[f.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${C?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[C?.connected?f.jsx(h9,{className:"w-3 h-3"}):f.jsx(_9,{className:"w-3 h-3"}),C?.connected?"Connected":"Offline"]}),C?.connected&&k!=null&&f.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${k>=-50||k>=-60?"bg-bambu-green/20 text-bambu-green":k>=-70?"bg-amber-500/20 text-amber-600":k>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${k} dBm - ${Uce(k).label}`,children:[f.jsx(xle,{className:"w-3 h-3"}),k,"dBm"]}),C?.connected&&f.jsxs("button",{onClick:()=>P(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${C.hms_errors&&C.hms_errors.length>0?C.hms_errors.some(Q=>Q.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:[f.jsx(Ao,{className:"w-3 h-3"}),C.hms_errors&&C.hms_errors.length>0?C.hms_errors.length:"OK"]}),n&&f.jsxs("button",{onClick:()=>a("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[f.jsx(Zp,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Z>0&&f.jsxs("button",{onClick:()=>a("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${Z} print${Z>1?"s":""} in queue`,children:[f.jsx(Tf,{className:"w-3 h-3"}),Z]})]})]}),c&&f.jsx(zs,{title:"Delete Printer",message:`Are you sure you want to delete "${t.name}"? This will also remove all connection settings.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{Y.mutate(),u(!1)},onCancel:()=>u(!1)}),C?.connected&&f.jsxs(f.Fragment,{children:[r==="compact"?f.jsx("div",{className:"mt-2",children:C.state==="RUNNING"?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:f.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),f.jsxs("span",{className:"text-xs text-white",children:[Math.round(C.progress||0),"%"]})]}):f.jsx("p",{className:"text-xs text-bambu-gray capitalize",children:C.state?.toLowerCase()||"Idle"})}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:f.jsxs("div",{className:"flex gap-3",children:[f.jsx(Fce,{url:C.state==="RUNNING"?C.cover_url:null,printName:C.state==="RUNNING"&&(C.subtask_name||C.current_print)||void 0}),f.jsx("div",{className:"flex-1 min-w-0",children:C.current_print&&C.state==="RUNNING"?f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),f.jsx("p",{className:"text-white text-sm mb-2 truncate",children:C.subtask_name||C.current_print}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:f.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),f.jsxs("span",{className:"text-white",children:[Math.round(C.progress||0),"%"]})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[C.remaining_time!=null&&C.remaining_time>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(Pi,{className:"w-3 h-3"}),Lce(C.remaining_time*60)]}),f.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",Ice(C.remaining_time)]})]}),C.layer_num!=null&&C.total_layers!=null&&C.total_layers>0&&f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(Tf,{className:"w-3 h-3"}),C.layer_num,"/",C.total_layers]})]})]}):f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),f.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:C.state?.toLowerCase()||"Idle"}),f.jsxs("div",{className:"flex items-center justify-between text-sm",children:[f.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:f.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),f.jsx("span",{className:"text-bambu-gray",children:"—"})]}),ee?f.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:ee.print_name||ee.filename,children:["Last: ",ee.print_name||ee.filename,ee.completed_at&&f.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(ee.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):f.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),C.state!=="RUNNING"&&f.jsx(Ece,{printerId:t.id})]}),C.temperatures&&r==="expanded"&&f.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[f.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[f.jsx(Dp,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),C.temperatures.nozzle_2!==void 0?f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C / ",Math.round(C.temperatures.nozzle_2||0),"°C"]})]}):f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C"]})]})]}),f.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[f.jsx(Dp,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.bed||0),"°C"]})]}),C.temperatures.chamber!==void 0&&f.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[f.jsx(Dp,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),f.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.chamber||0),"°C"]})]})]}),D&&D.length>0&&r==="expanded"&&f.jsxs("div",{className:"mt-3 p-2 bg-bambu-dark rounded-lg",children:[f.jsx("div",{className:"space-y-2",children:D.map(Q=>{const me=Q.id>=128?Q.id-128:Q.id,Ee=I[String(me)],he=Ee!==void 0?Ee:me,we=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,De=he===1,de=he===0;return f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[we&&(De||de)&&f.jsx(Ace,{side:De?"L":"R"}),f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Oce(Q.id,Q.tray.length)}),f.jsx("div",{className:"flex gap-1",children:Q.tray.map((Le,B)=>f.jsx("div",{className:`w-5 h-5 rounded-full border border-white/20 ${Le.tray_type?"":"ams-empty-slot"}`,style:{backgroundColor:Le.tray_color?`#${Le.tray_color}`:Le.tray_type?"#333":void 0},title:Le.tray_type?`${Le.tray_sub_brands||Le.tray_type}${Le.remain?` (${Le.remain}%)`:""}`:"Empty slot"},`${Q.id}-${B}`))})]}),(Q.humidity!=null||Q.temp!=null)&&f.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[Q.humidity!=null&&f.jsx("div",{className:"w-14 text-right",children:f.jsx(kce,{humidity:Q.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair})}),Q.temp!=null&&f.jsx(Dce,{temp:Q.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair})]})]},Q.id)})}),C.vt_tray&&C.vt_tray.tray_type&&f.jsxs("div",{className:"flex items-center gap-2 pt-2 mt-2 border-t border-bambu-dark-tertiary",children:[f.jsx("span",{className:"text-xs text-bambu-gray w-10",children:"Ext"}),f.jsx("div",{className:"w-5 h-5 rounded-full border border-white/20",style:{backgroundColor:C.vt_tray.tray_color?`#${C.vt_tray.tray_color}`:"#333"},title:C.vt_tray.tray_sub_brands||C.vt_tray.tray_type||"External"})]})]})]}),$&&r==="expanded"&&f.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(nk,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),f.jsx("span",{className:"text-sm text-white truncate",children:$.name}),G&&f.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${G.state==="ON"?"bg-bambu-green/20 text-bambu-green":G.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:G.state||"?"}),G?.energy?.power!=null&&G.state==="ON"&&f.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[G.energy.power,"W"]})]}),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs("button",{onClick:()=>M(!0),disabled:ae.isPending||G?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${G?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[f.jsx(Xf,{className:"w-3 h-3"}),"On"]}),f.jsxs("button",{onClick:()=>T(!0),disabled:ae.isPending||G?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${G?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[f.jsx(m9,{className:"w-3 h-3"}),"Off"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx("span",{className:`text-xs hidden sm:inline ${$.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:$.auto_off_executed?"Auto-off done":"Auto-off"}),f.jsx("button",{onClick:()=>fe.mutate(!$.auto_off),disabled:fe.isPending||$.auto_off_executed,title:$.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${$.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":$.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:f.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${$.auto_off||$.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&f.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[f.jsxs("div",{className:"text-xs text-bambu-gray",children:[f.jsx("p",{children:t.ip_address}),f.jsx("p",{className:"truncate",children:t.serial_number})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(We,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!C?.connected,title:"Open camera in new window",children:f.jsx(Xle,{className:"w-4 h-4"})}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>b(!0),title:"Browse printer files",children:[f.jsx(u9,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&f.jsx(vce,{printerId:t.id,printerName:t.name,onClose:()=>b(!1)}),y&&f.jsx(bce,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),x&&$&&f.jsx(zs,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{ae.mutate("on"),M(!1)},onCancel:()=>M(!1)}),w&&$&&f.jsx(zs,{title:"Power Off Printer",message:C?.state==="RUNNING"?`WARNING: "${t.name}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`:`Are you sure you want to turn OFF the power for "${t.name}"?`,confirmText:"Power Off",variant:"danger",onConfirm:()=>{ae.mutate("off"),T(!1)},onCancel:()=>T(!1)}),A&&f.jsx(wce,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>P(!1)}),h&&f.jsx(Hce,{printer:t,onClose:()=>g(!1)})]})}function Bce({onClose:t,onAdd:e}){const[n,r]=E.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return E.useEffect(()=>{const i=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:f.jsx(Ft,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:f.jsxs($t,{children:[f.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),f.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),f.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.name,onChange:i=>r({...n,name:i.target.value}),placeholder:"My Printer"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),f.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.ip_address,onChange:i=>r({...n,ip_address:i.target.value}),placeholder:"192.168.1.100"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),f.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.serial_number,onChange:i=>r({...n,serial_number:i.target.value}),placeholder:"01P00A000000000"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),f.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.access_code,onChange:i=>r({...n,access_code:i.target.value}),placeholder:"From printer settings"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),f.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.model||"",onChange:i=>r({...n,model:i.target.value}),children:[f.jsx("option",{value:"",children:"Select model..."}),f.jsxs("optgroup",{label:"H2 Series",children:[f.jsx("option",{value:"H2C",children:"H2C"}),f.jsx("option",{value:"H2D",children:"H2D"}),f.jsx("option",{value:"H2S",children:"H2S"})]}),f.jsxs("optgroup",{label:"X1 Series",children:[f.jsx("option",{value:"X1E",children:"X1E"}),f.jsx("option",{value:"X1C",children:"X1 Carbon"}),f.jsx("option",{value:"X1",children:"X1"})]}),f.jsxs("optgroup",{label:"P Series",children:[f.jsx("option",{value:"P2S",children:"P2S"}),f.jsx("option",{value:"P1S",children:"P1S"}),f.jsx("option",{value:"P1P",children:"P1P"})]}),f.jsxs("optgroup",{label:"A1 Series",children:[f.jsx("option",{value:"A1",children:"A1"}),f.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"auto_archive",checked:n.auto_archive,onChange:i=>r({...n,auto_archive:i.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),f.jsxs("div",{className:"flex gap-3 pt-4",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),f.jsx(We,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function Hce({printer:t,onClose:e}){const n=Rn(),[r,i]=E.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),s=Tt({mutationFn:o=>Ue.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});E.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const a=o=>{o.preventDefault();const l={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(l.access_code=r.access_code),s.mutate(l)};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:f.jsx(Ft,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:f.jsxs($t,{children:[f.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),f.jsxs("form",{onSubmit:a,className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),f.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),f.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),f.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}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),f.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),f.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:[f.jsx("option",{value:"",children:"Select model..."}),f.jsxs("optgroup",{label:"H2 Series",children:[f.jsx("option",{value:"H2C",children:"H2C"}),f.jsx("option",{value:"H2D",children:"H2D"}),f.jsx("option",{value:"H2S",children:"H2S"})]}),f.jsxs("optgroup",{label:"X1 Series",children:[f.jsx("option",{value:"X1E",children:"X1E"}),f.jsx("option",{value:"X1C",children:"X1 Carbon"}),f.jsx("option",{value:"X1",children:"X1"})]}),f.jsxs("optgroup",{label:"P Series",children:[f.jsx("option",{value:"P2S",children:"P2S"}),f.jsx("option",{value:"P1S",children:"P1S"}),f.jsx("option",{value:"P1P",children:"P1P"})]}),f.jsxs("optgroup",{label:"A1 Series",children:[f.jsx("option",{value:"A1",children:"A1"}),f.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),f.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"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.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"}),f.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),f.jsxs("div",{className:"flex gap-3 pt-4",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsx(We,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Saving...":"Save Changes"})]})]})]})})})}function $ce(t){const{data:e}=At({queryKey:["printerStatus",t],queryFn:()=>Ue.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function Vce({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=$ce(t.id),{data:s}=At({queryKey:["smartPlugStatus",e.id],queryFn:()=>Ue.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?f.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&f.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${s.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:s.state||"?"})]}),f.jsxs("button",{onClick:()=>n(e.id),disabled:r||s?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${s?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[f.jsx(Xf,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function Gce(){const[t,e]=E.useState(!1),[n,r]=E.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,s]=E.useState(!1),[a,o]=E.useState(null),[l,c]=E.useState(()=>localStorage.getItem("printerSortBy")||"name"),[u,h]=E.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=E.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),b=Rn(),{data:y,isLoading:v}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),{data:x}=At({queryKey:["settings"],queryFn:Ue.getSettings}),{data:M}=At({queryKey:["smart-plugs"],queryFn:Ue.getSmartPlugs}),{data:w}=At({queryKey:["maintenanceOverview"],queryFn:Ue.getMaintenanceOverview,staleTime:60*1e3}),T=w?.reduce((D,$)=>(D[$.printer_id]={due_count:$.due_count,warning_count:$.warning_count,total_print_hours:$.total_print_hours},D),{})||{},A=M?.reduce((D,$)=>($.printer_id&&(D[$.printer_id]=$),D),{})||{},P=Tt({mutationFn:Ue.createPrinter,onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),e(!1)}}),C=Tt({mutationFn:D=>Ue.controlSmartPlug(D,"on"),onSuccess:()=>{b.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),j=()=>{const D=!n;r(D),localStorage.setItem("hideDisconnectedPrinters",String(D))},N=D=>{c(D),localStorage.setItem("printerSortBy",D)},k=()=>{const D=!u;h(D),localStorage.setItem("printerSortAsc",String(D))},F=()=>{const D=g==="expanded"?"compact":"expanded";m(D),localStorage.setItem("printerViewMode",D)},I=E.useMemo(()=>{if(!y)return[];const D=[...y];switch(l){case"name":D.sort(($,G)=>$.name.localeCompare(G.name));break;case"model":D.sort(($,G)=>($.model||"").localeCompare(G.model||""));break;case"location":D.sort(($,G)=>{const V=$.location||"",Z=G.location||"";return!V&&Z?1:V&&!Z?-1:V.localeCompare(Z)||$.name.localeCompare(G.name)});break;case"status":D.sort(($,G)=>{const V=b.getQueryData(["printerStatus",$.id]),Z=b.getQueryData(["printerStatus",G.id]),K=ee=>ee?.connected?ee.state==="RUNNING"?0:1:2;return K(V)-K(Z)});break}return u||D.reverse(),D},[y,l,u,b]),W=E.useMemo(()=>{if(l!=="location")return null;const D={};return I.forEach($=>{const G=$.location||"Ungrouped";D[G]||(D[G]=[]),D[G].push($)}),D},[l,I]);return f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"flex items-center justify-between mb-6",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),f.jsx(zce,{printers:y})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs("select",{value:l,onChange:D=>N(D.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:[f.jsx("option",{value:"name",children:"Name"}),f.jsx("option",{value:"status",children:"Status"}),f.jsx("option",{value:"model",children:"Model"}),f.jsx("option",{value:"location",children:"Location"})]}),f.jsx("button",{onClick:k,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:u?"Sort descending":"Sort ascending",children:u?f.jsx(Wp,{className:"w-4 h-4 text-bambu-gray"}):f.jsx(Yx,{className:"w-4 h-4 text-bambu-gray"})})]}),f.jsx("button",{onClick:F,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"?f.jsx(woe,{className:"w-5 h-5 text-bambu-gray"}):f.jsx(f9,{className:"w-5 h-5 text-bambu-gray"})}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:n,onChange:j,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(A).length>0&&f.jsxs("div",{className:"relative",children:[f.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[f.jsx(Xf,{className:"w-4 h-4"}),"Power On",f.jsx($0,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),f.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:[f.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),y?.filter(D=>A[D.id]).map(D=>f.jsx(Vce,{printer:D,plug:A[D.id],onPowerOn:$=>{o($),C.mutate($)},isPowering:a===A[D.id]?.id},D.id)),y?.filter(D=>A[D.id]).length===0&&f.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),f.jsxs(We,{onClick:()=>e(!0),children:[f.jsx(ai,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):y?.length===0?f.jsx(Ft,{children:f.jsxs($t,{className:"text-center py-12",children:[f.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),f.jsxs(We,{onClick:()=>e(!0),children:[f.jsx(ai,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):W?f.jsx("div",{className:"space-y-6",children:Object.entries(W).map(([D,$])=>f.jsxs("div",{children:[f.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[f.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),D,f.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",$.length,")"]})]}),f.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:$.map(G=>f.jsx(pF,{printer:G,hideIfDisconnected:n,maintenanceInfo:T[G.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},G.id))})]},D))}):f.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:I.map(D=>f.jsx(pF,{printer:D,hideIfDisconnected:n,maintenanceInfo:T[D.id],viewMode:g,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},D.id))}),t&&f.jsx(Bce,{onClose:()=>e(!1),onAdd:D=>P.mutate(D)})]})}const rk="181",Op={ROTATE:0,DOLLY:1,PAN:2},Ap={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Wce=0,mF=1,qce=2,C9=1,Xce=2,Gl=3,Zu=0,Bs=1,Go=2,oc=0,Lp=1,gF=2,xF=3,vF=4,Kce=5,Xd=100,Yce=101,Zce=102,Qce=103,Jce=104,eue=200,tue=201,nue=202,rue=203,$N=204,VN=205,iue=206,sue=207,aue=208,oue=209,lue=210,cue=211,uue=212,due=213,fue=214,GN=0,WN=1,qN=2,Qp=3,XN=4,KN=5,YN=6,ZN=7,ik=0,hue=1,pue=2,zu=0,mue=1,gue=2,xue=3,vue=4,bue=5,yue=6,_ue=7,N9=300,Jp=301,em=302,QN=303,JN=304,lw=306,e3=1e3,ec=1001,t3=1002,fa=1003,Sue=1004,Hb=1005,$a=1006,qA=1007,tf=1008,rl=1009,R9=1010,P9=1011,t0=1012,sk=1013,Rf=1014,tc=1015,Nm=1016,ak=1017,ok=1018,n0=1020,k9=35902,D9=35899,O9=1021,L9=1022,bo=1023,r0=1026,i0=1027,I9=1028,lk=1029,ck=1030,uk=1031,dk=1033,E_=33776,A_=33777,T_=33778,C_=33779,n3=35840,r3=35841,i3=35842,s3=35843,a3=36196,o3=37492,l3=37496,c3=37808,u3=37809,d3=37810,f3=37811,h3=37812,p3=37813,m3=37814,g3=37815,x3=37816,v3=37817,b3=37818,y3=37819,_3=37820,S3=37821,w3=36492,M3=36494,E3=36495,A3=36283,T3=36284,C3=36285,N3=36286,wue=3200,Mue=3201,j9=0,Eue=1,Tu="",La="srgb",tm="srgb-linear",n1="linear",Bn="srgb",Oh=7680,bF=519,Aue=512,Tue=513,Cue=514,U9=515,Nue=516,Rue=517,Pue=518,kue=519,yF=35044,_F="300 es",Ko=2e3,r1=2001;function F9(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function i1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Due(){const t=i1("canvas");return t.style.display="block",t}const SF={};function wF(...t){const e="THREE."+t.shift();console.log(e,...t)}function Xt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Or(...t){const e="THREE."+t.shift();console.error(e,...t)}function s0(...t){const e=t.join(" ");e in SF||(SF[e]=!0,Xt(...t))}function Oue(t,e,n){return new Promise(function(r,i){function s(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(s,n);break;default:r()}}setTimeout(s,n)})}let Kf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}};const Qi=["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"],N_=Math.PI/180,R3=180/Math.PI;function W0(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Qi[t&255]+Qi[t>>8&255]+Qi[t>>16&255]+Qi[t>>24&255]+"-"+Qi[e&255]+Qi[e>>8&255]+"-"+Qi[e>>16&15|64]+Qi[e>>24&255]+"-"+Qi[n&63|128]+Qi[n>>8&255]+"-"+Qi[n>>16&255]+Qi[n>>24&255]+Qi[r&255]+Qi[r>>8&255]+Qi[r>>16&255]+Qi[r>>24&255]).toLowerCase()}function mn(t,e,n){return Math.max(e,Math.min(n,t))}function Lue(t,e){return(t%e+e)%e}function XA(t,e,n){return(1-n)*t+n*e}function Bg(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 Os(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 Iue={DEG2RAD:N_};let on=class z9{constructor(e=0,n=0){z9.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Pf=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,s,a,o){let l=r[i+0],c=r[i+1],u=r[i+2],h=r[i+3],g=s[a+0],m=s[a+1],b=s[a+2],y=s[a+3];if(o<=0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(h!==y||l!==g||c!==m||u!==b){let v=l*g+c*m+u*b+h*y;v<0&&(g=-g,m=-m,b=-b,y=-y,v=-v);let x=1-o;if(v<.9995){const M=Math.acos(v),w=Math.sin(M);x=Math.sin(x*M)/w,o=Math.sin(o*M)/w,l=l*x+g*o,c=c*x+m*o,u=u*x+b*o,h=h*x+y*o}else{l=l*x+g*o,c=c*x+m*o,u=u*x+b*o,h=h*x+y*o;const M=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=M,c*=M,u*=M,h*=M}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],c=r[i+2],u=r[i+3],h=s[a],g=s[a+1],m=s[a+2],b=s[a+3];return e[n]=o*b+u*h+l*m-c*g,e[n+1]=l*b+u*g+c*h-o*m,e[n+2]=c*b+u*m+o*g-l*h,e[n+3]=u*b-o*h-l*g-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(r/2),u=o(i/2),h=o(s/2),g=l(r/2),m=l(i/2),b=l(s/2);switch(a){case"XYZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"YXZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"ZXY":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"ZYX":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"YZX":this._x=g*u*h+c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h-g*m*b;break;case"XZY":this._x=g*u*h-c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h+g*m*b;break;default:Xt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],a=n[1],o=n[5],l=n[9],c=n[2],u=n[6],h=n[10],g=r+o+h;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(u-l)*m,this._y=(s-c)*m,this._z=(a-i)*m}else if(r>o&&r>h){const m=2*Math.sqrt(1+r-o-h);this._w=(u-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+c)/m}else if(o>h){const m=2*Math.sqrt(1+o-r-h);this._w=(s-c)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+h-r-o);this._w=(a-i)/m,this._x=(s+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(mn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,l=n._y,c=n._z,u=n._w;return this._x=r*u+a*o+i*c-s*l,this._y=i*u+a*l+s*o-r*c,this._z=s*u+a*c+r*l-i*o,this._w=a*u-r*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let l=1-n;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,n=Math.sin(n*c)/u,this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*n,this._onChangeCallback()}else this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Xe=class B9{constructor(e=0,n=0,r=0){B9.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(MF.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(MF.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*r),u=2*(o*n-s*i),h=2*(s*r-a*n);return this.x=n+l*c+a*h-o*u,this.y=r+l*u+o*c-s*h,this.z=i+l*h+s*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,l=n.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return KA.copy(this).projectOnVector(e),this.sub(KA)}reflect(e){return this.sub(KA.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(mn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const KA=new Xe,MF=new Pf;let un=class H9{constructor(e,n,r,i,s,a,o,l,c){H9.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,c)}set(e,n,r,i,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=n,u[4]=s,u[5]=l,u[6]=r,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],l=r[6],c=r[1],u=r[4],h=r[7],g=r[2],m=r[5],b=r[8],y=i[0],v=i[3],x=i[6],M=i[1],w=i[4],T=i[7],A=i[2],P=i[5],C=i[8];return s[0]=a*y+o*M+l*A,s[3]=a*v+o*w+l*P,s[6]=a*x+o*T+l*C,s[1]=c*y+u*M+h*A,s[4]=c*v+u*w+h*P,s[7]=c*x+u*T+h*C,s[2]=g*y+m*M+b*A,s[5]=g*v+m*w+b*P,s[8]=g*x+m*T+b*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return n*a*u-n*o*c-r*s*u+r*o*l+i*s*c-i*a*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,g=o*l-u*s,m=c*s-a*l,b=n*h+r*g+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=h*y,e[1]=(i*c-u*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(u*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-c*n)*y,e[8]=(a*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(YA.makeScale(e,n)),this}rotate(e){return this.premultiply(YA.makeRotation(-e)),this}translate(e,n){return this.premultiply(YA.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 YA=new un,EF=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),AF=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function jue(){const t={enabled:!0,workingColorSpace:tm,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Bn&&(i.r=lc(i.r),i.g=lc(i.g),i.b=lc(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Bn&&(i.r=Ip(i.r),i.g=Ip(i.g),i.b=Ip(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Tu?n1:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return s0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return s0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[tm]:{primaries:e,whitePoint:r,transfer:n1,toXYZ:EF,fromXYZ:AF,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:La},outputColorSpaceConfig:{drawingBufferColorSpace:La}},[La]:{primaries:e,whitePoint:r,transfer:Bn,toXYZ:EF,fromXYZ:AF,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:La}}}),t}const En=jue();function lc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ip(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Lh,Uue=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{Lh===void 0&&(Lh=i1("canvas")),Lh.width=e.width,Lh.height=e.height;const i=Lh.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Lh}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=i1("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=lc(s[a]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(lc(n[r]/255)*255):n[r]=lc(n[r]);return{data:n,width:e.width,height:e.height}}else return Xt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Fue=0,fk=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Fue++}),this.uuid=W0(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(ZA(i[a].image)):s.push(ZA(i[a]))}else s=ZA(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function ZA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Uue.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Xt("Texture: Unable to serialize Texture."),{})}let zue=0;const QA=new Xe;let Ro=class R_ extends Kf{constructor(e=R_.DEFAULT_IMAGE,n=R_.DEFAULT_MAPPING,r=ec,i=ec,s=$a,a=tf,o=bo,l=rl,c=R_.DEFAULT_ANISOTROPY,u=Tu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:zue++}),this.uuid=W0(),this.name="",this.source=new fk(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new on(0,0),this.repeat=new on(1,1),this.center=new on(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(QA).x}get height(){return this.source.getSize(QA).y}get depth(){return this.source.getSize(QA).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){Xt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==N9)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case e3:e.x=e.x-Math.floor(e.x);break;case ec:e.x=e.x<0?0:1;break;case t3: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 e3:e.y=e.y-Math.floor(e.y);break;case ec:e.y=e.y<0?0:1;break;case t3: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++}};Ro.DEFAULT_IMAGE=null;Ro.DEFAULT_MAPPING=N9;Ro.DEFAULT_ANISOTROPY=1;let Gr=class $9{constructor(e=0,n=0,r=0,i=1){$9.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*n+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*n+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const l=e.elements,c=l[0],u=l[4],h=l[8],g=l[1],m=l[5],b=l[9],y=l[2],v=l[6],x=l[10];if(Math.abs(u-g)<.01&&Math.abs(h-y)<.01&&Math.abs(b-v)<.01){if(Math.abs(u+g)<.1&&Math.abs(h+y)<.1&&Math.abs(b+v)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,T=(m+1)/2,A=(x+1)/2,P=(u+g)/4,C=(h+y)/4,j=(b+v)/4;return w>T&&w>A?w<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(w),i=P/r,s=C/r):T>A?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=P/i,s=j/i):A<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(A),r=C/s,i=j/s),this.set(r,i,s,n),this}let M=Math.sqrt((v-b)*(v-b)+(h-y)*(h-y)+(g-u)*(g-u));return Math.abs(M)<.001&&(M=1),this.x=(v-b)/M,this.y=(h-y)/M,this.z=(g-u)/M,this.w=Math.acos((c+m+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=mn(this.x,e.x,n.x),this.y=mn(this.y,e.y,n.y),this.z=mn(this.z,e.z,n.z),this.w=mn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=mn(this.x,e,n),this.y=mn(this.y,e,n),this.z=mn(this.z,e,n),this.w=mn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(mn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Bue=class extends Kf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:$a,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new Gr(0,0,e,n),this.scissorTest=!1,this.viewport=new Gr(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new Ro(i);this.textures=[];const a=r.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:$a,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new fk(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"})}},kf=class extends Bue{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},V9=class extends Ro{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=fa,this.minFilter=fa,this.wrapR=ec,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Hue=class extends Ro{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=fa,this.minFilter=fa,this.wrapR=ec,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Df=class{constructor(e=new Xe(1/0,1/0,1/0),n=new Xe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(ao.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(ao.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=ao.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,ao):ao.fromBufferAttribute(s,a),ao.applyMatrix4(e.matrixWorld),this.expandByPoint(ao);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),$b.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),$b.copy(r.boundingBox)),$b.applyMatrix4(e.matrixWorld),this.union($b)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ao),ao.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(Hg),Vb.subVectors(this.max,Hg),Ih.subVectors(e.a,Hg),jh.subVectors(e.b,Hg),Uh.subVectors(e.c,Hg),iu.subVectors(jh,Ih),su.subVectors(Uh,jh),Pd.subVectors(Ih,Uh);let n=[0,-iu.z,iu.y,0,-su.z,su.y,0,-Pd.z,Pd.y,iu.z,0,-iu.x,su.z,0,-su.x,Pd.z,0,-Pd.x,-iu.y,iu.x,0,-su.y,su.x,0,-Pd.y,Pd.x,0];return!JA(n,Ih,jh,Uh,Vb)||(n=[1,0,0,0,1,0,0,0,1],!JA(n,Ih,jh,Uh,Vb))?!1:(Gb.crossVectors(iu,su),n=[Gb.x,Gb.y,Gb.z],JA(n,Ih,jh,Uh,Vb))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ao).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ao).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:(Pl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Pl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Pl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Pl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Pl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Pl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Pl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Pl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Pl),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 Pl=[new Xe,new Xe,new Xe,new Xe,new Xe,new Xe,new Xe,new Xe],ao=new Xe,$b=new Df,Ih=new Xe,jh=new Xe,Uh=new Xe,iu=new Xe,su=new Xe,Pd=new Xe,Hg=new Xe,Vb=new Xe,Gb=new Xe,kd=new Xe;function JA(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){kd.fromArray(t,s);const o=i.x*Math.abs(kd.x)+i.y*Math.abs(kd.y)+i.z*Math.abs(kd.z),l=e.dot(kd),c=n.dot(kd),u=r.dot(kd);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const $ue=new Df,$g=new Xe,eT=new Xe;let cw=class{constructor(e=new Xe,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):$ue.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;$g.subVectors(e,this.center);const n=$g.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector($g,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):(eT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint($g.copy(e.center).add(eT)),this.expandByPoint($g.copy(e.center).sub(eT))),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 kl=new Xe,tT=new Xe,Wb=new Xe,au=new Xe,nT=new Xe,qb=new Xe,rT=new Xe;let hk=class{constructor(e=new Xe,n=new Xe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,kl)),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=kl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(kl.copy(this.origin).addScaledVector(this.direction,n),kl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){tT.copy(e).add(n).multiplyScalar(.5),Wb.copy(n).sub(e).normalize(),au.copy(this.origin).sub(tT);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Wb),o=au.dot(this.direction),l=-au.dot(Wb),c=au.lengthSq(),u=Math.abs(1-a*a);let h,g,m,b;if(u>0)if(h=a*l-o,g=a*o-l,b=s*u,h>=0)if(g>=-b)if(g<=b){const y=1/u;h*=y,g*=y,m=h*(h+a*g+2*o)+g*(a*h+g+2*l)+c}else g=s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g=-s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g<=-b?(h=Math.max(0,-(-a*s+o)),g=h>0?-s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c):g<=b?(h=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+c):(h=Math.max(0,-(a*s+o)),g=h>0?s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c);else g=a>0?-s:s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(tT).addScaledVector(Wb,g),m}intersectSphere(e,n){kl.subVectors(e.center,this.origin);const r=kl.dot(this.direction),i=kl.dot(kl)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,g=this.origin;return c>=0?(r=(e.min.x-g.x)*c,i=(e.max.x-g.x)*c):(r=(e.max.x-g.x)*c,i=(e.min.x-g.x)*c),u>=0?(s=(e.min.y-g.y)*u,a=(e.max.y-g.y)*u):(s=(e.max.y-g.y)*u,a=(e.min.y-g.y)*u),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-g.z)*h,l=(e.max.z-g.z)*h):(o=(e.max.z-g.z)*h,l=(e.min.z-g.z)*h),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,kl)!==null}intersectTriangle(e,n,r,i,s){nT.subVectors(n,e),qb.subVectors(r,e),rT.crossVectors(nT,qb);let a=this.direction.dot(rT),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;au.subVectors(this.origin,e);const l=o*this.direction.dot(qb.crossVectors(au,qb));if(l<0)return null;const c=o*this.direction.dot(nT.cross(au));if(c<0||l+c>a)return null;const u=-o*au.dot(rT);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Kr=class P3{constructor(e,n,r,i,s,a,o,l,c,u,h,g,m,b,y,v){P3.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,c,u,h,g,m,b,y,v)}set(e,n,r,i,s,a,o,l,c,u,h,g,m,b,y,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=s,x[5]=a,x[9]=o,x[13]=l,x[2]=c,x[6]=u,x[10]=h,x[14]=g,x[3]=m,x[7]=b,x[11]=y,x[15]=v,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 P3().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/Fh.setFromMatrixColumn(e,0).length(),s=1/Fh.setFromMatrixColumn(e,1).length(),a=1/Fh.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const g=a*u,m=a*h,b=o*u,y=o*h;n[0]=l*u,n[4]=-l*h,n[8]=c,n[1]=m+b*c,n[5]=g-y*c,n[9]=-o*l,n[2]=y-g*c,n[6]=b+m*c,n[10]=a*l}else if(e.order==="YXZ"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g+y*o,n[4]=b*o-m,n[8]=a*c,n[1]=a*h,n[5]=a*u,n[9]=-o,n[2]=m*o-b,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g-y*o,n[4]=-a*h,n[8]=b+m*o,n[1]=m+b*o,n[5]=a*u,n[9]=y-g*o,n[2]=-a*c,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*u,m=a*h,b=o*u,y=o*h;n[0]=l*u,n[4]=b*c-m,n[8]=g*c+y,n[1]=l*h,n[5]=y*c+g,n[9]=m*c-b,n[2]=-c,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*c,b=o*l,y=o*c;n[0]=l*u,n[4]=y-g*h,n[8]=b*h+m,n[1]=h,n[5]=a*u,n[9]=-o*u,n[2]=-c*u,n[6]=m*h+b,n[10]=g-y*h}else if(e.order==="XZY"){const g=a*l,m=a*c,b=o*l,y=o*c;n[0]=l*u,n[4]=-h,n[8]=c*u,n[1]=g*h+y,n[5]=a*u,n[9]=m*h-b,n[2]=b*h-m,n[6]=o*u,n[10]=y*h+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Vue,e,Gue)}lookAt(e,n,r){const i=this.elements;return ra.subVectors(e,n),ra.lengthSq()===0&&(ra.z=1),ra.normalize(),ou.crossVectors(r,ra),ou.lengthSq()===0&&(Math.abs(r.z)===1?ra.x+=1e-4:ra.z+=1e-4,ra.normalize(),ou.crossVectors(r,ra)),ou.normalize(),Xb.crossVectors(ra,ou),i[0]=ou.x,i[4]=Xb.x,i[8]=ra.x,i[1]=ou.y,i[5]=Xb.y,i[9]=ra.y,i[2]=ou.z,i[6]=Xb.z,i[10]=ra.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[4],l=r[8],c=r[12],u=r[1],h=r[5],g=r[9],m=r[13],b=r[2],y=r[6],v=r[10],x=r[14],M=r[3],w=r[7],T=r[11],A=r[15],P=i[0],C=i[4],j=i[8],N=i[12],k=i[1],F=i[5],I=i[9],W=i[13],D=i[2],$=i[6],G=i[10],V=i[14],Z=i[3],K=i[7],ee=i[11],H=i[15];return s[0]=a*P+o*k+l*D+c*Z,s[4]=a*C+o*F+l*$+c*K,s[8]=a*j+o*I+l*G+c*ee,s[12]=a*N+o*W+l*V+c*H,s[1]=u*P+h*k+g*D+m*Z,s[5]=u*C+h*F+g*$+m*K,s[9]=u*j+h*I+g*G+m*ee,s[13]=u*N+h*W+g*V+m*H,s[2]=b*P+y*k+v*D+x*Z,s[6]=b*C+y*F+v*$+x*K,s[10]=b*j+y*I+v*G+x*ee,s[14]=b*N+y*W+v*V+x*H,s[3]=M*P+w*k+T*D+A*Z,s[7]=M*C+w*F+T*$+A*K,s[11]=M*j+w*I+T*G+A*ee,s[15]=M*N+w*W+T*V+A*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],g=e[10],m=e[14],b=e[3],y=e[7],v=e[11],x=e[15];return b*(+s*l*h-i*c*h-s*o*g+r*c*g+i*o*m-r*l*m)+y*(+n*l*m-n*c*g+s*a*g-i*a*m+i*c*u-s*l*u)+v*(+n*c*h-n*o*m-s*a*h+r*a*m+s*o*u-r*c*u)+x*(-i*o*u-n*l*h+n*o*g+i*a*h-r*a*g+r*l*u)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],g=e[10],m=e[11],b=e[12],y=e[13],v=e[14],x=e[15],M=h*v*c-y*g*c+y*l*m-o*v*m-h*l*x+o*g*x,w=b*g*c-u*v*c-b*l*m+a*v*m+u*l*x-a*g*x,T=u*y*c-b*h*c+b*o*m-a*y*m-u*o*x+a*h*x,A=b*h*l-u*y*l-b*o*g+a*y*g+u*o*v-a*h*v,P=n*M+r*w+i*T+s*A;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/P;return e[0]=M*C,e[1]=(y*g*s-h*v*s-y*i*m+r*v*m+h*i*x-r*g*x)*C,e[2]=(o*v*s-y*l*s+y*i*c-r*v*c-o*i*x+r*l*x)*C,e[3]=(h*l*s-o*g*s-h*i*c+r*g*c+o*i*m-r*l*m)*C,e[4]=w*C,e[5]=(u*v*s-b*g*s+b*i*m-n*v*m-u*i*x+n*g*x)*C,e[6]=(b*l*s-a*v*s-b*i*c+n*v*c+a*i*x-n*l*x)*C,e[7]=(a*g*s-u*l*s+u*i*c-n*g*c-a*i*m+n*l*m)*C,e[8]=T*C,e[9]=(b*h*s-u*y*s-b*r*m+n*y*m+u*r*x-n*h*x)*C,e[10]=(a*y*s-b*o*s+b*r*c-n*y*c-a*r*x+n*o*x)*C,e[11]=(u*o*s-a*h*s-u*r*c+n*h*c+a*r*m-n*o*m)*C,e[12]=A*C,e[13]=(u*y*i-b*h*i+b*r*g-n*y*g-u*r*v+n*h*v)*C,e[14]=(b*o*i-a*y*i-b*r*l+n*y*l+a*r*v-n*o*v)*C,e[15]=(a*h*i-u*o*i+u*r*l-n*h*l-a*r*g+n*o*g)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+r,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+r,u*l-i*a,0,c*l-i*o,u*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,c=s+s,u=a+a,h=o+o,g=s*c,m=s*u,b=s*h,y=a*u,v=a*h,x=o*h,M=l*c,w=l*u,T=l*h,A=r.x,P=r.y,C=r.z;return i[0]=(1-(y+x))*A,i[1]=(m+T)*A,i[2]=(b-w)*A,i[3]=0,i[4]=(m-T)*P,i[5]=(1-(g+x))*P,i[6]=(v+M)*P,i[7]=0,i[8]=(b+w)*C,i[9]=(v-M)*C,i[10]=(1-(g+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=Fh.set(i[0],i[1],i[2]).length();const a=Fh.set(i[4],i[5],i[6]).length(),o=Fh.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],oo.copy(this);const c=1/s,u=1/a,h=1/o;return oo.elements[0]*=c,oo.elements[1]*=c,oo.elements[2]*=c,oo.elements[4]*=u,oo.elements[5]*=u,oo.elements[6]*=u,oo.elements[8]*=h,oo.elements[9]*=h,oo.elements[10]*=h,n.setFromRotationMatrix(oo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=Ko,l=!1){const c=this.elements,u=2*s/(n-e),h=2*s/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let b,y;if(l)b=s/(a-s),y=a*s/(a-s);else if(o===Ko)b=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===r1)b=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=h,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=b,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=Ko,l=!1){const c=this.elements,u=2/(n-e),h=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let b,y;if(l)b=1/(a-s),y=a/(a-s);else if(o===Ko)b=-2/(a-s),y=-(a+s)/(a-s);else if(o===r1)b=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=h,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=b,c[14]=y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const Fh=new Xe,oo=new Kr,Vue=new Xe(0,0,0),Gue=new Xe(1,1,1),ou=new Xe,Xb=new Xe,ra=new Xe,TF=new Kr,CF=new Pf;let Qu=class G9{constructor(e=0,n=0,r=0,i=G9.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(mn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-mn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(mn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-mn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(mn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-mn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:Xt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return TF.makeRotationFromQuaternion(e),this.setFromRotationMatrix(TF,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return CF.setFromEuler(this),this.setFromQuaternion(CF,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}};Qu.DEFAULT_ORDER="XYZ";let W9=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}},Wue=0;const NF=new Xe,zh=new Pf,Dl=new Kr,Kb=new Xe,Vg=new Xe,que=new Xe,Xue=new Pf,RF=new Xe(1,0,0),PF=new Xe(0,1,0),kF=new Xe(0,0,1),DF={type:"added"},Kue={type:"removed"},Bh={type:"childadded",child:null},iT={type:"childremoved",child:null};let ga=class P_ extends Kf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Wue++}),this.uuid=W0(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=P_.DEFAULT_UP.clone();const e=new Xe,n=new Qu,r=new Pf,i=new Xe(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Kr},normalMatrix:{value:new un}}),this.matrix=new Kr,this.matrixWorld=new Kr,this.matrixAutoUpdate=P_.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=P_.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new W9,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 zh.setFromAxisAngle(e,n),this.quaternion.multiply(zh),this}rotateOnWorldAxis(e,n){return zh.setFromAxisAngle(e,n),this.quaternion.premultiply(zh),this}rotateX(e){return this.rotateOnAxis(RF,e)}rotateY(e){return this.rotateOnAxis(PF,e)}rotateZ(e){return this.rotateOnAxis(kF,e)}translateOnAxis(e,n){return NF.copy(e).applyQuaternion(this.quaternion),this.position.add(NF.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(RF,e)}translateY(e){return this.translateOnAxis(PF,e)}translateZ(e){return this.translateOnAxis(kF,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Dl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Kb.copy(e):Kb.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Vg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Dl.lookAt(Vg,Kb,this.up):Dl.lookAt(Kb,Vg,this.up),this.quaternion.setFromRotationMatrix(Dl),i&&(Dl.extractRotation(i.matrixWorld),zh.setFromRotationMatrix(Dl),this.quaternion.premultiply(zh.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Or("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(DF),Bh.child=e,this.dispatchEvent(Bh),Bh.child=null):Or("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(Kue),iT.child=e,this.dispatchEvent(iT),iT.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),Dl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Dl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Dl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(DF),Bh.child=e,this.dispatchEvent(Bh),Bh.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vg,e,que),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vg,Xue,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(n){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),g=a(e.skeletons),m=a(e.animations),b=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),h.length>0&&(r.shapes=h),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}return r.object=i,r;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};ga.DEFAULT_UP=new Xe(0,1,0);ga.DEFAULT_MATRIX_AUTO_UPDATE=!0;ga.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const lo=new Xe,Ol=new Xe,sT=new Xe,Ll=new Xe,Hh=new Xe,$h=new Xe,OF=new Xe,aT=new Xe,oT=new Xe,lT=new Xe,cT=new Gr,uT=new Gr,dT=new Gr;let Gg=class yp{constructor(e=new Xe,n=new Xe,r=new Xe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),lo.subVectors(e,n),i.cross(lo);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){lo.subVectors(i,n),Ol.subVectors(r,n),sT.subVectors(e,n);const a=lo.dot(lo),o=lo.dot(Ol),l=lo.dot(sT),c=Ol.dot(Ol),u=Ol.dot(sT),h=a*c-o*o;if(h===0)return s.set(0,0,0),null;const g=1/h,m=(c*l-o*u)*g,b=(a*u-o*l)*g;return s.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Ll)===null?!1:Ll.x>=0&&Ll.y>=0&&Ll.x+Ll.y<=1}static getInterpolation(e,n,r,i,s,a,o,l){return this.getBarycoord(e,n,r,i,Ll)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Ll.x),l.addScaledVector(a,Ll.y),l.addScaledVector(o,Ll.z),l)}static getInterpolatedAttribute(e,n,r,i,s,a){return cT.setScalar(0),uT.setScalar(0),dT.setScalar(0),cT.fromBufferAttribute(e,n),uT.fromBufferAttribute(e,r),dT.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(cT,s.x),a.addScaledVector(uT,s.y),a.addScaledVector(dT,s.z),a}static isFrontFacing(e,n,r,i){return lo.subVectors(r,n),Ol.subVectors(e,n),lo.cross(Ol).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 lo.subVectors(this.c,this.b),Ol.subVectors(this.a,this.b),lo.cross(Ol).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return yp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return yp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return yp.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return yp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return yp.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;Hh.subVectors(i,r),$h.subVectors(s,r),aT.subVectors(e,r);const l=Hh.dot(aT),c=$h.dot(aT);if(l<=0&&c<=0)return n.copy(r);oT.subVectors(e,i);const u=Hh.dot(oT),h=$h.dot(oT);if(u>=0&&h<=u)return n.copy(i);const g=l*h-u*c;if(g<=0&&l>=0&&u<=0)return a=l/(l-u),n.copy(r).addScaledVector(Hh,a);lT.subVectors(e,s);const m=Hh.dot(lT),b=$h.dot(lT);if(b>=0&&m<=b)return n.copy(s);const y=m*c-l*b;if(y<=0&&c>=0&&b<=0)return o=c/(c-b),n.copy(r).addScaledVector($h,o);const v=u*b-m*h;if(v<=0&&h-u>=0&&m-b>=0)return OF.subVectors(s,i),o=(h-u)/(h-u+(m-b)),n.copy(i).addScaledVector(OF,o);const x=1/(v+y+g);return a=y*x,o=g*x,n.copy(r).addScaledVector(Hh,a).addScaledVector($h,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const q9={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},lu={h:0,s:0,l:0},Yb={h:0,s:0,l:0};function fT(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let bn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=La){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,En.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=En.workingColorSpace){return this.r=e,this.g=n,this.b=r,En.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=En.workingColorSpace){if(e=Lue(e,1),n=mn(n,0,1),r=mn(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=fT(a,s,e+1/3),this.g=fT(a,s,e),this.b=fT(a,s,e-1/3)}return En.colorSpaceToWorking(this,i),this}setStyle(e,n=La){function r(s){s!==void 0&&parseFloat(s)<1&&Xt("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:Xt("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);Xt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=La){const r=q9[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Xt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=lc(e.r),this.g=lc(e.g),this.b=lc(e.b),this}copyLinearToSRGB(e){return this.r=Ip(e.r),this.g=Ip(e.g),this.b=Ip(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=La){return En.workingToColorSpace(Ji.copy(this),e),Math.round(mn(Ji.r*255,0,255))*65536+Math.round(mn(Ji.g*255,0,255))*256+Math.round(mn(Ji.b*255,0,255))}getHexString(e=La){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=En.workingColorSpace){En.workingToColorSpace(Ji.copy(this),n);const r=Ji.r,i=Ji.g,s=Ji.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case r:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-r)/h+2;break;case s:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,n=En.workingColorSpace){return En.workingToColorSpace(Ji.copy(this),n),e.r=Ji.r,e.g=Ji.g,e.b=Ji.b,e}getStyle(e=La){En.workingToColorSpace(Ji.copy(this),e);const n=Ji.r,r=Ji.g,i=Ji.b;return e!==La?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(lu),this.setHSL(lu.h+e,lu.s+n,lu.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(lu),e.getHSL(Yb);const r=XA(lu.h,Yb.h,n),i=XA(lu.s,Yb.s,n),s=XA(lu.l,Yb.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Ji=new bn;bn.NAMES=q9;let Yue=0,Rm=class extends Kf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Yue++}),this.uuid=W0(),this.name="",this.type="Material",this.blending=Lp,this.side=Zu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=$N,this.blendDst=VN,this.blendEquation=Xd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new bn(0,0,0),this.blendAlpha=0,this.depthFunc=Qp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=bF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Oh,this.stencilZFail=Oh,this.stencilZPass=Oh,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){Xt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Xt(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Lp&&(r.blending=this.blending),this.side!==Zu&&(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!==$N&&(r.blendSrc=this.blendSrc),this.blendDst!==VN&&(r.blendDst=this.blendDst),this.blendEquation!==Xd&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Qp&&(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!==bF&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Oh&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Oh&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Oh&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},pk=class extends Rm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new bn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qu,this.combine=ik,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const Hr=new Xe,Zb=new on;let Zue=0,Ga=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:Zue++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=yF,this.updateRanges=[],this.gpuType=tc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)Zb.fromBufferAttribute(this,n),Zb.applyMatrix3(e),this.setXY(n,Zb.x,Zb.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyMatrix3(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyMatrix4(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.applyNormalMatrix(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Hr.fromBufferAttribute(this,n),Hr.transformDirection(e),this.setXYZ(n,Hr.x,Hr.y,Hr.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Bg(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Os(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Bg(n,this.array)),n}setX(e,n){return this.normalized&&(n=Os(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Bg(n,this.array)),n}setY(e,n){return this.normalized&&(n=Os(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=Bg(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Os(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=Bg(n,this.array)),n}setW(e,n){return this.normalized&&(n=Os(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Os(n,this.array),r=Os(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=Os(n,this.array),r=Os(r,this.array),i=Os(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Os(n,this.array),r=Os(r,this.array),i=Os(i,this.array),s=Os(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==yF&&(e.usage=this.usage),e}},X9=class extends Ga{constructor(e,n,r){super(new Uint16Array(e),n,r)}},K9=class extends Ga{constructor(e,n,r){super(new Uint32Array(e),n,r)}},So=class extends Ga{constructor(e,n,r){super(new Float32Array(e),n,r)}},Que=0;const Aa=new Kr,hT=new ga,Vh=new Xe,ia=new Df,Wg=new Df,_i=new Xe;let fl=class Y9 extends Kf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Que++}),this.uuid=W0(),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(F9(e)?K9:X9)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new un().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Aa.makeRotationFromQuaternion(e),this.applyMatrix4(Aa),this}rotateX(e){return Aa.makeRotationX(e),this.applyMatrix4(Aa),this}rotateY(e){return Aa.makeRotationY(e),this.applyMatrix4(Aa),this}rotateZ(e){return Aa.makeRotationZ(e),this.applyMatrix4(Aa),this}translate(e,n,r){return Aa.makeTranslation(e,n,r),this.applyMatrix4(Aa),this}scale(e,n,r){return Aa.makeScale(e,n,r),this.applyMatrix4(Aa),this}lookAt(e){return hT.lookAt(e),hT.updateMatrix(),this.applyMatrix4(hT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vh).negate(),this.translate(Vh.x,Vh.y,Vh.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,s=e.length;i<s;i++){const a=e[i];r.push(a.x,a.y,a.z||0)}this.setAttribute("position",new So(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const s=e[i];n.setXYZ(i,s.x,s.y,s.z||0)}e.length>n.count&&Xt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Df);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Or("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Xe(-1/0,-1/0,-1/0),new Xe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];ia.setFromBufferAttribute(s),this.morphTargetsRelative?(_i.addVectors(this.boundingBox.min,ia.min),this.boundingBox.expandByPoint(_i),_i.addVectors(this.boundingBox.max,ia.max),this.boundingBox.expandByPoint(_i)):(this.boundingBox.expandByPoint(ia.min),this.boundingBox.expandByPoint(ia.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Or('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new cw);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Or("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Xe,1/0);return}if(e){const r=this.boundingSphere.center;if(ia.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];Wg.setFromBufferAttribute(o),this.morphTargetsRelative?(_i.addVectors(ia.min,Wg.min),ia.expandByPoint(_i),_i.addVectors(ia.max,Wg.max),ia.expandByPoint(_i)):(ia.expandByPoint(Wg.min),ia.expandByPoint(Wg.max))}ia.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)_i.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(_i));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)_i.fromBufferAttribute(o,c),l&&(Vh.fromBufferAttribute(e,c),_i.add(Vh)),i=Math.max(i,r.distanceToSquared(_i))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Or('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Or("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,s=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ga(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let j=0;j<r.count;j++)o[j]=new Xe,l[j]=new Xe;const c=new Xe,u=new Xe,h=new Xe,g=new on,m=new on,b=new on,y=new Xe,v=new Xe;function x(j,N,k){c.fromBufferAttribute(r,j),u.fromBufferAttribute(r,N),h.fromBufferAttribute(r,k),g.fromBufferAttribute(s,j),m.fromBufferAttribute(s,N),b.fromBufferAttribute(s,k),u.sub(c),h.sub(c),m.sub(g),b.sub(g);const F=1/(m.x*b.y-b.x*m.y);isFinite(F)&&(y.copy(u).multiplyScalar(b.y).addScaledVector(h,-m.y).multiplyScalar(F),v.copy(h).multiplyScalar(m.x).addScaledVector(u,-b.x).multiplyScalar(F),o[j].add(y),o[N].add(y),o[k].add(y),l[j].add(v),l[N].add(v),l[k].add(v))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let j=0,N=M.length;j<N;++j){const k=M[j],F=k.start,I=k.count;for(let W=F,D=F+I;W<D;W+=3)x(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const w=new Xe,T=new Xe,A=new Xe,P=new Xe;function C(j){A.fromBufferAttribute(i,j),P.copy(A);const N=o[j];w.copy(N),w.sub(A.multiplyScalar(A.dot(N))).normalize(),T.crossVectors(P,N);const F=T.dot(l[j])<0?-1:1;a.setXYZW(j,w.x,w.y,w.z,F)}for(let j=0,N=M.length;j<N;++j){const k=M[j],F=k.start,I=k.count;for(let W=F,D=F+I;W<D;W+=3)C(e.getX(W+0)),C(e.getX(W+1)),C(e.getX(W+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Ga(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Xe,s=new Xe,a=new Xe,o=new Xe,l=new Xe,c=new Xe,u=new Xe,h=new Xe;if(e)for(let g=0,m=e.count;g<m;g+=3){const b=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,b),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),u.subVectors(a,s),h.subVectors(i,s),u.cross(h),o.fromBufferAttribute(r,b),l.fromBufferAttribute(r,y),c.fromBufferAttribute(r,v),o.add(u),l.add(u),c.add(u),r.setXYZ(b,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),u.subVectors(a,s),h.subVectors(i,s),u.cross(h),r.setXYZ(g+0,u.x,u.y,u.z),r.setXYZ(g+1,u.x,u.y,u.z),r.setXYZ(g+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)_i.fromBufferAttribute(e,n),_i.normalize(),e.setXYZ(n,_i.x,_i.y,_i.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,g=new c.constructor(l.length*u);let m=0,b=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*u;for(let x=0;x<u;x++)g[b++]=c[m++]}return new Ga(g,u,h)}if(this.index===null)return Xt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Y9,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);n.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,h=c.length;u<h;u++){const g=c[u],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,g=c.length;h<g;h++){const m=c[h];u.push(m.toJSON(e.data))}u.length>0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(n))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let g=0,m=h.length;g<m;g++)u.push(h[g].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const LF=new Kr,Dd=new hk,Qb=new cw,IF=new Xe,Jb=new Xe,ey=new Xe,ty=new Xe,pT=new Xe,ny=new Xe,jF=new Xe,ry=new Xe;let il=class extends ga{constructor(e=new fl,n=new pk){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){ny.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(pT.fromBufferAttribute(h,e),a?ny.addScaledVector(pT,u):ny.addScaledVector(pT.sub(n),u))}n.add(ny)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Qb.copy(r.boundingSphere),Qb.applyMatrix4(s),Dd.copy(e.ray).recast(e.near),!(Qb.containsPoint(Dd.origin)===!1&&(Dd.intersectSphere(Qb,IF)===null||Dd.origin.distanceToSquared(IF)>(e.far-e.near)**2))&&(LF.copy(s).invert(),Dd.copy(e.ray).applyMatrix4(LF),!(r.boundingBox!==null&&Dd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Dd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=a[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let T=M,A=w;T<A;T+=3){const P=o.getX(T),C=o.getX(T+1),j=o.getX(T+2);i=iy(this,x,e,r,c,u,h,P,C,j),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),T=o.getX(v+2);i=iy(this,a,e,r,c,u,h,M,w,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=a[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let T=M,A=w;T<A;T+=3){const P=T,C=T+1,j=T+2;i=iy(this,x,e,r,c,u,h,P,C,j),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=v,w=v+1,T=v+2;i=iy(this,a,e,r,c,u,h,M,w,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function Jue(t,e,n,r,i,s,a,o){let l;if(e.side===Bs?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===Zu,o),l===null)return null;ry.copy(o),ry.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(ry);return c<n.near||c>n.far?null:{distance:c,point:ry.clone(),object:t}}function iy(t,e,n,r,i,s,a,o,l,c){t.getVertexPosition(o,Jb),t.getVertexPosition(l,ey),t.getVertexPosition(c,ty);const u=Jue(t,e,n,r,Jb,ey,ty,jF);if(u){const h=new Xe;Gg.getBarycoord(jF,Jb,ey,ty,h),i&&(u.uv=Gg.getInterpolatedAttribute(i,o,l,c,h,new on)),s&&(u.uv1=Gg.getInterpolatedAttribute(s,o,l,c,h,new on)),a&&(u.normal=Gg.getInterpolatedAttribute(a,o,l,c,h,new Xe),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const g={a:o,b:l,c,normal:new Xe,materialIndex:0};Gg.getNormal(Jb,ey,ty,g.normal),u.face=g,u.barycoord=h}return u}let mk=class Z9 extends fl{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],h=[];let g=0,m=0;b("z","y","x",-1,-1,r,n,e,a,s,0),b("z","y","x",1,-1,r,n,-e,a,s,1),b("x","z","y",1,1,e,r,n,i,a,2),b("x","z","y",1,-1,e,r,-n,i,a,3),b("x","y","z",1,-1,e,n,r,i,s,4),b("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new So(c,3)),this.setAttribute("normal",new So(u,3)),this.setAttribute("uv",new So(h,2));function b(y,v,x,M,w,T,A,P,C,j,N){const k=T/C,F=A/j,I=T/2,W=A/2,D=P/2,$=C+1,G=j+1;let V=0,Z=0;const K=new Xe;for(let ee=0;ee<G;ee++){const H=ee*F-W;for(let Y=0;Y<$;Y++){const te=Y*k-I;K[y]=te*M,K[v]=H*w,K[x]=D,c.push(K.x,K.y,K.z),K[y]=0,K[v]=0,K[x]=P>0?1:-1,u.push(K.x,K.y,K.z),h.push(Y/C),h.push(1-ee/j),V+=1}}for(let ee=0;ee<j;ee++)for(let H=0;H<C;H++){const Y=g+H+$*ee,te=g+H+$*(ee+1),ae=g+(H+1)+$*(ee+1),fe=g+(H+1)+$*ee;l.push(Y,te,fe),l.push(te,ae,fe),Z+=6}o.addGroup(m,Z,N),m+=Z,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Z9(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function nm(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Xt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function ms(t){const e={};for(let n=0;n<t.length;n++){const r=nm(t[n]);for(const i in r)e[i]=r[i]}return e}function ede(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function Q9(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:En.workingColorSpace}const tde={clone:nm,merge:ms};var nde=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,rde=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let xc=class extends Rm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=nde,this.fragmentShader=rde,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=nm(e.uniforms),this.uniformsGroups=ede(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?n.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?n.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?n.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?n.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?n.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?n.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?n.uniforms[i]={type:"m4",value:a.toArray()}:n.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},J9=class extends ga{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Kr,this.projectionMatrix=new Kr,this.projectionMatrixInverse=new Kr,this.coordinateSystem=Ko,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const cu=new Xe,UF=new on,FF=new on;let Ua=class extends J9{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=R3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(N_*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return R3*2*Math.atan(Math.tan(N_*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,r){cu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(cu.x,cu.y).multiplyScalar(-e/cu.z),cu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(cu.x,cu.y).multiplyScalar(-e/cu.z)}getViewSize(e,n){return this.getViewBounds(e,UF,FF),n.subVectors(FF,UF)}setViewOffset(e,n,r,i,s,a){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(N_*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/c,i*=a.width/l,r*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const Gh=-90,Wh=1;let ide=class extends ga{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ua(Gh,Wh,e,n);i.layers=this.layers,this.add(i);const s=new Ua(Gh,Wh,e,n);s.layers=this.layers,this.add(s);const a=new Ua(Gh,Wh,e,n);a.layers=this.layers,this.add(a);const o=new Ua(Gh,Wh,e,n);o.layers=this.layers,this.add(o);const l=new Ua(Gh,Wh,e,n);l.layers=this.layers,this.add(l);const c=new Ua(Gh,Wh,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const c of n)this.remove(c);if(e===Ko)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===r1)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,u]=this.children,h=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,a),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,c),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(h,g,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},e7=class extends Ro{constructor(e=[],n=Jp,r,i,s,a,o,l,c,u){super(e,n,r,i,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},sde=class extends kf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new e7(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new mk(5,5,5),s=new xc({name:"CubemapFromEquirect",uniforms:nm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Bs,blending:oc});s.uniforms.tEquirect.value=n;const a=new il(i,s),o=n.minFilter;return n.minFilter===tf&&(n.minFilter=$a),new ide(1,10,this).update(e,a),n.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,r,i);e.setRenderTarget(s)}},fx=class extends ga{constructor(){super(),this.isGroup=!0,this.type="Group"}};const ade={type:"move"};let mT=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new fx,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 fx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Xe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Xe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new fx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Xe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Xe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),x=this._getHandJoint(c,y);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],g=u.position.distanceTo(h.position),m=.02,b=.005;c.inputState.pinching&&g>m+b?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-b&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(ade)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new fx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},ode=class extends ga{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 Qu,this.environmentIntensity=1,this.environmentRotation=new Qu,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}},lde=class extends Ro{constructor(e=null,n=1,r=1,i,s,a,o,l,c=fa,u=fa,h,g){super(null,a,o,l,c,u,i,s,h,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const gT=new Xe,cde=new Xe,ude=new un;let bu=class{constructor(e=new Xe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=gT.subVectors(r,n).cross(cde.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(gT),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||ude.getNormalMatrix(e),i=this.coplanarPoint(gT).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Od=new cw,dde=new on(.5,.5),sy=new Xe;let gk=class{constructor(e=new bu,n=new bu,r=new bu,i=new bu,s=new bu,a=new bu){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Ko,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],u=s[4],h=s[5],g=s[6],m=s[7],b=s[8],y=s[9],v=s[10],x=s[11],M=s[12],w=s[13],T=s[14],A=s[15];if(i[0].setComponents(c-a,m-u,x-b,A-M).normalize(),i[1].setComponents(c+a,m+u,x+b,A+M).normalize(),i[2].setComponents(c+o,m+h,x+y,A+w).normalize(),i[3].setComponents(c-o,m-h,x-y,A-w).normalize(),r)i[4].setComponents(l,g,v,T).normalize(),i[5].setComponents(c-l,m-g,x-v,A-T).normalize();else if(i[4].setComponents(c-l,m-g,x-v,A-T).normalize(),n===Ko)i[5].setComponents(c+l,m+g,x+v,A+T).normalize();else if(n===r1)i[5].setComponents(l,g,v,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Od.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Od.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Od)}intersectsSprite(e){Od.center.set(0,0,0);const n=dde.distanceTo(e.center);return Od.radius=.7071067811865476+n,Od.applyMatrix4(e.matrixWorld),this.intersectsSphere(Od)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(sy.x=i.normal.x>0?e.max.x:e.min.x,sy.y=i.normal.y>0?e.max.y:e.min.y,sy.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(sy)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},t7=class extends Rm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new bn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const s1=new Xe,a1=new Xe,zF=new Kr,qg=new hk,ay=new cw,xT=new Xe,BF=new Xe;let fde=class extends ga{constructor(e=new fl,n=new t7){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)s1.fromBufferAttribute(n,i-1),a1.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=s1.distanceTo(a1);e.setAttribute("lineDistance",new So(r,1))}else Xt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),ay.copy(r.boundingSphere),ay.applyMatrix4(i),ay.radius+=s,e.ray.intersectsSphere(ay)===!1)return;zF.copy(i).invert(),qg.copy(e.ray).applyMatrix4(zF);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=r.index,g=r.attributes.position;if(u!==null){const m=Math.max(0,a.start),b=Math.min(u.count,a.start+a.count);for(let y=m,v=b-1;y<v;y+=c){const x=u.getX(y),M=u.getX(y+1),w=oy(this,e,qg,l,x,M,y);w&&n.push(w)}if(this.isLineLoop){const y=u.getX(b-1),v=u.getX(m),x=oy(this,e,qg,l,y,v,b-1);x&&n.push(x)}}else{const m=Math.max(0,a.start),b=Math.min(g.count,a.start+a.count);for(let y=m,v=b-1;y<v;y+=c){const x=oy(this,e,qg,l,y,y+1,y);x&&n.push(x)}if(this.isLineLoop){const y=oy(this,e,qg,l,b-1,m,b-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}};function oy(t,e,n,r,i,s,a){const o=t.geometry.attributes.position;if(s1.fromBufferAttribute(o,i),a1.fromBufferAttribute(o,s),n.distanceSqToSegment(s1,a1,xT,BF)>r)return;xT.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(xT);if(!(c<e.near||c>e.far))return{distance:c,point:BF.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const HF=new Xe,$F=new Xe;let hde=class extends fde{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)HF.fromBufferAttribute(n,i),$F.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+HF.distanceTo($F);e.setAttribute("lineDistance",new So(r,1))}else Xt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},n7=class extends Ro{constructor(e,n,r=Rf,i,s,a,o=fa,l=fa,c,u=r0,h=1){if(u!==r0&&u!==i0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:h};super(g,i,s,a,o,l,u,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new fk(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 r7 extends Ro{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let xk=class i7 extends fl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,u=l+1,h=e/o,g=n/l,m=[],b=[],y=[],v=[];for(let x=0;x<u;x++){const M=x*g-a;for(let w=0;w<c;w++){const T=w*h-s;b.push(T,-M,0),y.push(0,0,1),v.push(w/o),v.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,T=M+c*(x+1),A=M+1+c*(x+1),P=M+1+c*x;m.push(w,T,P),m.push(T,A,P)}this.setIndex(m),this.setAttribute("position",new So(b,3)),this.setAttribute("normal",new So(y,3)),this.setAttribute("uv",new So(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i7(e.width,e.height,e.widthSegments,e.heightSegments)}};class pde extends Rm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new bn(16777215),this.specular=new bn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new bn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=j9,this.normalScale=new on(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Qu,this.combine=ik,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 mde=class extends Rm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=wue,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}},gde=class extends Rm{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}},s7=class extends ga{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new bn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const vT=new Kr,VF=new Xe,GF=new Xe;let xde=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new on(512,512),this.mapType=rl,this.map=null,this.mapPass=null,this.matrix=new Kr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new gk,this._frameExtents=new on(1,1),this._viewportCount=1,this._viewports=[new Gr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;VF.setFromMatrixPosition(e.matrixWorld),n.position.copy(VF),GF.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(GF),n.updateMatrixWorld(),vT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vT,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(vT)}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}},a7=class extends J9{constructor(e=-1,n=1,r=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,a=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class vde extends xde{constructor(){super(new a7(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class WF extends s7{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ga.DEFAULT_UP),this.updateMatrix(),this.target=new ga,this.shadow=new vde}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let bde=class extends s7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},yde=class extends Ua{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},qF=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=mn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(mn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class _de extends hde{constructor(e=10,n=10,r=4473924,i=8947848){r=new bn(r),i=new bn(i);const s=n/2,a=e/n,o=e/2,l=[],c=[];for(let g=0,m=0,b=-o;g<=n;g++,b+=a){l.push(-o,0,b,o,0,b),l.push(b,0,-o,b,0,o);const y=g===s?r:i;y.toArray(c,m),m+=3,y.toArray(c,m),m+=3,y.toArray(c,m),m+=3,y.toArray(c,m),m+=3}const u=new fl;u.setAttribute("position",new So(l,3)),u.setAttribute("color",new So(c,3));const h=new t7({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Sde extends Kf{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Xt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function XF(t,e,n,r){const i=wde(r);switch(n){case O9:return t*e;case I9:return t*e/i.components*i.byteLength;case lk:return t*e/i.components*i.byteLength;case ck:return t*e*2/i.components*i.byteLength;case uk:return t*e*2/i.components*i.byteLength;case L9:return t*e*3/i.components*i.byteLength;case bo:return t*e*4/i.components*i.byteLength;case dk:return t*e*4/i.components*i.byteLength;case E_:case A_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case T_:case C_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case r3:case s3:return Math.max(t,16)*Math.max(e,8)/4;case n3:case i3:return Math.max(t,8)*Math.max(e,8)/2;case a3:case o3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case l3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case c3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case u3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case d3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case f3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case h3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case p3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case m3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case g3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case x3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case v3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case b3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case y3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case _3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case S3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case w3:case M3:case E3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case A3:case T3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case C3:case N3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function wde(t){switch(t){case rl:case R9:return{byteLength:1,components:1};case t0:case P9:case Nm:return{byteLength:2,components:1};case ak:case ok:return{byteLength:2,components:4};case Rf:case sk:case tc:return{byteLength:4,components:1};case k9:case D9:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:rk}}));typeof window<"u"&&(window.__THREE__?Xt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=rk);function o7(){let t=null,e=!1,n=null,r=null;function i(s,a){n(s,a),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function Mde(t){const e=new WeakMap;function n(o,l){const c=o.array,u=o.usage,h=c.byteLength,g=t.createBuffer();t.bindBuffer(l,g),t.bufferData(l,c,u),o.onUploadCallback();let m;if(c instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=t.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=t.SHORT;else if(c instanceof Uint32Array)m=t.UNSIGNED_INT;else if(c instanceof Int32Array)m=t.INT;else if(c instanceof Int8Array)m=t.BYTE;else if(c instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:g,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function r(o,l,c){const u=l.array,h=l.updateRanges;if(t.bindBuffer(c,o),h.length===0)t.bufferSubData(c,0,u);else{h.sort((m,b)=>m.start-b.start);let g=0;for(let m=1;m<h.length;m++){const b=h[g],y=h[m];y.start<=b.start+b.count+1?b.count=Math.max(b.count,y.start+y.count-b.start):(++g,h[g]=y)}h.length=g+1;for(let m=0,b=h.length;m<b;m++){const y=h[m];t.bufferSubData(c,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(t.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(c.buffer,o,l),c.version=o.version}}return{get:i,remove:s,update:a}}var Ede=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Ade=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,Tde=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Cde=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Nde=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,Rde=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Pde=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,kde=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Dde=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,Ode=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,Lde=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Ide=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,jde=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,Ude=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,Fde=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,zde=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,Bde=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,Hde=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,$de=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,Vde=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,Gde=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,Wde=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,qde=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,Xde=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,Kde=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,Yde=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,Zde=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Qde=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,Jde=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,efe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,tfe="gl_FragColor = linearToOutputTexel( gl_FragColor );",nfe=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,rfe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,ife=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,sfe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,afe=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,ofe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,lfe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,cfe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,ufe=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,dfe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,ffe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,hfe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,pfe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,mfe=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,gfe=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,xfe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,vfe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,bfe=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,yfe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,_fe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Sfe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,wfe=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,Mfe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,Efe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,Afe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,Tfe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,Cfe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Nfe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Rfe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,Pfe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,kfe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,Dfe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,Ofe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Lfe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,Ife=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,jfe=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,Ufe=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,Ffe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,zfe=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,Bfe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,Hfe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,$fe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,Vfe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Gfe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Wfe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,qfe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,Xfe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Kfe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Yfe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,Zfe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Qfe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Jfe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,ehe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,the=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,nhe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,rhe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,ihe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,she=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,ahe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,ohe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,lhe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,che=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,uhe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,dhe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,fhe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,hhe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,phe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,mhe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,ghe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,xhe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,vhe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,bhe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,yhe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,_he=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,She=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,whe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const Mhe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Ehe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Ahe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,The=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Che=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Nhe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Rhe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,Phe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,khe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,Dhe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,Ohe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,Lhe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Ihe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,jhe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,Uhe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,Fhe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,zhe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Bhe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Hhe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,$he=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Vhe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,Ghe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,Whe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,qhe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Xhe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,Khe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Yhe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Zhe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Qhe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,Jhe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,epe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,tpe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,npe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,rpe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,sn={alphahash_fragment:Ede,alphahash_pars_fragment:Ade,alphamap_fragment:Tde,alphamap_pars_fragment:Cde,alphatest_fragment:Nde,alphatest_pars_fragment:Rde,aomap_fragment:Pde,aomap_pars_fragment:kde,batching_pars_vertex:Dde,batching_vertex:Ode,begin_vertex:Lde,beginnormal_vertex:Ide,bsdfs:jde,iridescence_fragment:Ude,bumpmap_pars_fragment:Fde,clipping_planes_fragment:zde,clipping_planes_pars_fragment:Bde,clipping_planes_pars_vertex:Hde,clipping_planes_vertex:$de,color_fragment:Vde,color_pars_fragment:Gde,color_pars_vertex:Wde,color_vertex:qde,common:Xde,cube_uv_reflection_fragment:Kde,defaultnormal_vertex:Yde,displacementmap_pars_vertex:Zde,displacementmap_vertex:Qde,emissivemap_fragment:Jde,emissivemap_pars_fragment:efe,colorspace_fragment:tfe,colorspace_pars_fragment:nfe,envmap_fragment:rfe,envmap_common_pars_fragment:ife,envmap_pars_fragment:sfe,envmap_pars_vertex:afe,envmap_physical_pars_fragment:xfe,envmap_vertex:ofe,fog_vertex:lfe,fog_pars_vertex:cfe,fog_fragment:ufe,fog_pars_fragment:dfe,gradientmap_pars_fragment:ffe,lightmap_pars_fragment:hfe,lights_lambert_fragment:pfe,lights_lambert_pars_fragment:mfe,lights_pars_begin:gfe,lights_toon_fragment:vfe,lights_toon_pars_fragment:bfe,lights_phong_fragment:yfe,lights_phong_pars_fragment:_fe,lights_physical_fragment:Sfe,lights_physical_pars_fragment:wfe,lights_fragment_begin:Mfe,lights_fragment_maps:Efe,lights_fragment_end:Afe,logdepthbuf_fragment:Tfe,logdepthbuf_pars_fragment:Cfe,logdepthbuf_pars_vertex:Nfe,logdepthbuf_vertex:Rfe,map_fragment:Pfe,map_pars_fragment:kfe,map_particle_fragment:Dfe,map_particle_pars_fragment:Ofe,metalnessmap_fragment:Lfe,metalnessmap_pars_fragment:Ife,morphinstance_vertex:jfe,morphcolor_vertex:Ufe,morphnormal_vertex:Ffe,morphtarget_pars_vertex:zfe,morphtarget_vertex:Bfe,normal_fragment_begin:Hfe,normal_fragment_maps:$fe,normal_pars_fragment:Vfe,normal_pars_vertex:Gfe,normal_vertex:Wfe,normalmap_pars_fragment:qfe,clearcoat_normal_fragment_begin:Xfe,clearcoat_normal_fragment_maps:Kfe,clearcoat_pars_fragment:Yfe,iridescence_pars_fragment:Zfe,opaque_fragment:Qfe,packing:Jfe,premultiplied_alpha_fragment:ehe,project_vertex:the,dithering_fragment:nhe,dithering_pars_fragment:rhe,roughnessmap_fragment:ihe,roughnessmap_pars_fragment:she,shadowmap_pars_fragment:ahe,shadowmap_pars_vertex:ohe,shadowmap_vertex:lhe,shadowmask_pars_fragment:che,skinbase_vertex:uhe,skinning_pars_vertex:dhe,skinning_vertex:fhe,skinnormal_vertex:hhe,specularmap_fragment:phe,specularmap_pars_fragment:mhe,tonemapping_fragment:ghe,tonemapping_pars_fragment:xhe,transmission_fragment:vhe,transmission_pars_fragment:bhe,uv_pars_fragment:yhe,uv_pars_vertex:_he,uv_vertex:She,worldpos_vertex:whe,background_vert:Mhe,background_frag:Ehe,backgroundCube_vert:Ahe,backgroundCube_frag:The,cube_vert:Che,cube_frag:Nhe,depth_vert:Rhe,depth_frag:Phe,distanceRGBA_vert:khe,distanceRGBA_frag:Dhe,equirect_vert:Ohe,equirect_frag:Lhe,linedashed_vert:Ihe,linedashed_frag:jhe,meshbasic_vert:Uhe,meshbasic_frag:Fhe,meshlambert_vert:zhe,meshlambert_frag:Bhe,meshmatcap_vert:Hhe,meshmatcap_frag:$he,meshnormal_vert:Vhe,meshnormal_frag:Ghe,meshphong_vert:Whe,meshphong_frag:qhe,meshphysical_vert:Xhe,meshphysical_frag:Khe,meshtoon_vert:Yhe,meshtoon_frag:Zhe,points_vert:Qhe,points_frag:Jhe,shadow_vert:epe,shadow_frag:tpe,sprite_vert:npe,sprite_frag:rpe},St={common:{diffuse:{value:new bn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new un}},envmap:{envMap:{value:null},envMapRotation:{value:new un},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new un}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new un}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new un},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new un},normalScale:{value:new on(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new un},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new un}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new un}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new un}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new bn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new bn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0},uvTransform:{value:new un}},sprite:{diffuse:{value:new bn(16777215)},opacity:{value:1},center:{value:new on(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new un},alphaMap:{value:null},alphaMapTransform:{value:new un},alphaTest:{value:0}}},Vo={basic:{uniforms:ms([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:sn.meshbasic_vert,fragmentShader:sn.meshbasic_frag},lambert:{uniforms:ms([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 bn(0)}}]),vertexShader:sn.meshlambert_vert,fragmentShader:sn.meshlambert_frag},phong:{uniforms:ms([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 bn(0)},specular:{value:new bn(1118481)},shininess:{value:30}}]),vertexShader:sn.meshphong_vert,fragmentShader:sn.meshphong_frag},standard:{uniforms:ms([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 bn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag},toon:{uniforms:ms([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new bn(0)}}]),vertexShader:sn.meshtoon_vert,fragmentShader:sn.meshtoon_frag},matcap:{uniforms:ms([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:sn.meshmatcap_vert,fragmentShader:sn.meshmatcap_frag},points:{uniforms:ms([St.points,St.fog]),vertexShader:sn.points_vert,fragmentShader:sn.points_frag},dashed:{uniforms:ms([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:sn.linedashed_vert,fragmentShader:sn.linedashed_frag},depth:{uniforms:ms([St.common,St.displacementmap]),vertexShader:sn.depth_vert,fragmentShader:sn.depth_frag},normal:{uniforms:ms([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:sn.meshnormal_vert,fragmentShader:sn.meshnormal_frag},sprite:{uniforms:ms([St.sprite,St.fog]),vertexShader:sn.sprite_vert,fragmentShader:sn.sprite_frag},background:{uniforms:{uvTransform:{value:new un},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:sn.background_vert,fragmentShader:sn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new un}},vertexShader:sn.backgroundCube_vert,fragmentShader:sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:sn.cube_vert,fragmentShader:sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:sn.equirect_vert,fragmentShader:sn.equirect_frag},distanceRGBA:{uniforms:ms([St.common,St.displacementmap,{referencePosition:{value:new Xe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:sn.distanceRGBA_vert,fragmentShader:sn.distanceRGBA_frag},shadow:{uniforms:ms([St.lights,St.fog,{color:{value:new bn(0)},opacity:{value:1}}]),vertexShader:sn.shadow_vert,fragmentShader:sn.shadow_frag}};Vo.physical={uniforms:ms([Vo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new un},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new un},clearcoatNormalScale:{value:new on(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new un},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new un},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new un},sheen:{value:0},sheenColor:{value:new bn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new un},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new un},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new un},transmissionSamplerSize:{value:new on},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new un},attenuationDistance:{value:0},attenuationColor:{value:new bn(0)},specularColor:{value:new bn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new un},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new un},anisotropyVector:{value:new on},anisotropyMap:{value:null},anisotropyMapTransform:{value:new un}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag};const ly={r:0,b:0,g:0},Ld=new Qu,ipe=new Kr;function spe(t,e,n,r,i,s,a){const o=new bn(0);let l=s===!0?0:1,c,u,h=null,g=0,m=null;function b(w){let T=w.isScene===!0?w.background:null;return T&&T.isTexture&&(T=(w.backgroundBlurriness>0?n:e).get(T)),T}function y(w){let T=!1;const A=b(w);A===null?x(o,l):A&&A.isColor&&(x(A,1),T=!0);const P=t.xr.getEnvironmentBlendMode();P==="additive"?r.buffers.color.setClear(0,0,0,1,a):P==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(t.autoClear||T)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function v(w,T){const A=b(T);A&&(A.isCubeTexture||A.mapping===lw)?(u===void 0&&(u=new il(new mk(1,1,1),new xc({name:"BackgroundCubeMaterial",uniforms:nm(Vo.backgroundCube.uniforms),vertexShader:Vo.backgroundCube.vertexShader,fragmentShader:Vo.backgroundCube.fragmentShader,side:Bs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(P,C,j){this.matrixWorld.copyPosition(j.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Ld.copy(T.backgroundRotation),Ld.x*=-1,Ld.y*=-1,Ld.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(Ld.y*=-1,Ld.z*=-1),u.material.uniforms.envMap.value=A,u.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(ipe.makeRotationFromEuler(Ld)),u.material.toneMapped=En.getTransfer(A.colorSpace)!==Bn,(h!==A||g!==A.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=A,g=A.version,m=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null)):A&&A.isTexture&&(c===void 0&&(c=new il(new xk(2,2),new xc({name:"BackgroundMaterial",uniforms:nm(Vo.background.uniforms),vertexShader:Vo.background.vertexShader,fragmentShader:Vo.background.fragmentShader,side:Zu,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=A,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=En.getTransfer(A.colorSpace)!==Bn,A.matrixAutoUpdate===!0&&A.updateMatrix(),c.material.uniforms.uvTransform.value.copy(A.matrix),(h!==A||g!==A.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,h=A,g=A.version,m=t.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function x(w,T){w.getRGB(ly,Q9(t)),r.buffers.color.setClear(ly.r,ly.g,ly.b,T,a)}function M(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,T=1){o.set(w),l=T,x(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,x(o,l)},render:y,addToRenderList:v,dispose:M}}function ape(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let s=i,a=!1;function o(k,F,I,W,D){let $=!1;const G=h(W,I,F);s!==G&&(s=G,c(s.object)),$=m(k,W,I,D),$&&b(k,W,I,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),($||a)&&(a=!1,T(k,F,I,W),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function l(){return t.createVertexArray()}function c(k){return t.bindVertexArray(k)}function u(k){return t.deleteVertexArray(k)}function h(k,F,I){const W=I.wireframe===!0;let D=r[k.id];D===void 0&&(D={},r[k.id]=D);let $=D[F.id];$===void 0&&($={},D[F.id]=$);let G=$[W];return G===void 0&&(G=g(l()),$[W]=G),G}function g(k){const F=[],I=[],W=[];for(let D=0;D<n;D++)F[D]=0,I[D]=0,W[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:I,attributeDivisors:W,object:k,attributes:{},index:null}}function m(k,F,I,W){const D=s.attributes,$=F.attributes;let G=0;const V=I.getAttributes();for(const Z in V)if(V[Z].location>=0){const ee=D[Z];let H=$[Z];if(H===void 0&&(Z==="instanceMatrix"&&k.instanceMatrix&&(H=k.instanceMatrix),Z==="instanceColor"&&k.instanceColor&&(H=k.instanceColor)),ee===void 0||ee.attribute!==H||H&&ee.data!==H.data)return!0;G++}return s.attributesNum!==G||s.index!==W}function b(k,F,I,W){const D={},$=F.attributes;let G=0;const V=I.getAttributes();for(const Z in V)if(V[Z].location>=0){let ee=$[Z];ee===void 0&&(Z==="instanceMatrix"&&k.instanceMatrix&&(ee=k.instanceMatrix),Z==="instanceColor"&&k.instanceColor&&(ee=k.instanceColor));const H={};H.attribute=ee,ee&&ee.data&&(H.data=ee.data),D[Z]=H,G++}s.attributes=D,s.attributesNum=G,s.index=W}function y(){const k=s.newAttributes;for(let F=0,I=k.length;F<I;F++)k[F]=0}function v(k){x(k,0)}function x(k,F){const I=s.newAttributes,W=s.enabledAttributes,D=s.attributeDivisors;I[k]=1,W[k]===0&&(t.enableVertexAttribArray(k),W[k]=1),D[k]!==F&&(t.vertexAttribDivisor(k,F),D[k]=F)}function M(){const k=s.newAttributes,F=s.enabledAttributes;for(let I=0,W=F.length;I<W;I++)F[I]!==k[I]&&(t.disableVertexAttribArray(I),F[I]=0)}function w(k,F,I,W,D,$,G){G===!0?t.vertexAttribIPointer(k,F,I,D,$):t.vertexAttribPointer(k,F,I,W,D,$)}function T(k,F,I,W){y();const D=W.attributes,$=I.getAttributes(),G=F.defaultAttributeValues;for(const V in $){const Z=$[V];if(Z.location>=0){let K=D[V];if(K===void 0&&(V==="instanceMatrix"&&k.instanceMatrix&&(K=k.instanceMatrix),V==="instanceColor"&&k.instanceColor&&(K=k.instanceColor)),K!==void 0){const ee=K.normalized,H=K.itemSize,Y=e.get(K);if(Y===void 0)continue;const te=Y.buffer,ae=Y.type,fe=Y.bytesPerElement,Q=ae===t.INT||ae===t.UNSIGNED_INT||K.gpuType===sk;if(K.isInterleavedBufferAttribute){const me=K.data,Ee=me.stride,he=K.offset;if(me.isInstancedInterleavedBuffer){for(let we=0;we<Z.locationSize;we++)x(Z.location+we,me.meshPerAttribute);k.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=me.meshPerAttribute*me.count)}else for(let we=0;we<Z.locationSize;we++)v(Z.location+we);t.bindBuffer(t.ARRAY_BUFFER,te);for(let we=0;we<Z.locationSize;we++)w(Z.location+we,H/Z.locationSize,ae,ee,Ee*fe,(he+H/Z.locationSize*we)*fe,Q)}else{if(K.isInstancedBufferAttribute){for(let me=0;me<Z.locationSize;me++)x(Z.location+me,K.meshPerAttribute);k.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=K.meshPerAttribute*K.count)}else for(let me=0;me<Z.locationSize;me++)v(Z.location+me);t.bindBuffer(t.ARRAY_BUFFER,te);for(let me=0;me<Z.locationSize;me++)w(Z.location+me,H/Z.locationSize,ae,ee,H*fe,H/Z.locationSize*me*fe,Q)}}else if(G!==void 0){const ee=G[V];if(ee!==void 0)switch(ee.length){case 2:t.vertexAttrib2fv(Z.location,ee);break;case 3:t.vertexAttrib3fv(Z.location,ee);break;case 4:t.vertexAttrib4fv(Z.location,ee);break;default:t.vertexAttrib1fv(Z.location,ee)}}}}M()}function A(){j();for(const k in r){const F=r[k];for(const I in F){const W=F[I];for(const D in W)u(W[D].object),delete W[D];delete F[I]}delete r[k]}}function P(k){if(r[k.id]===void 0)return;const F=r[k.id];for(const I in F){const W=F[I];for(const D in W)u(W[D].object),delete W[D];delete F[I]}delete r[k.id]}function C(k){for(const F in r){const I=r[F];if(I[k.id]===void 0)continue;const W=I[k.id];for(const D in W)u(W[D].object),delete W[D];delete I[k.id]}}function j(){N(),a=!0,s!==i&&(s=i,c(s.object))}function N(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:j,resetDefaultState:N,dispose:A,releaseStatesOfGeometry:P,releaseStatesOfProgram:C,initAttributes:y,enableAttribute:v,disableUnusedAttributes:M}}function ope(t,e,n){let r;function i(c){r=c}function s(c,u){t.drawArrays(r,c,u),n.update(u,r,1)}function a(c,u,h){h!==0&&(t.drawArraysInstanced(r,c,u,h),n.update(u,r,h))}function o(c,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,c,0,u,0,h);let m=0;for(let b=0;b<h;b++)m+=u[b];n.update(m,r,1)}function l(c,u,h,g){if(h===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<c.length;b++)a(c[b],u[b],g[b]);else{m.multiDrawArraysInstancedWEBGL(r,c,0,u,0,g,0,h);let b=0;for(let y=0;y<h;y++)b+=u[y]*g[y];n.update(b,r,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function lpe(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(C){return!(C!==bo&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){const j=C===Nm&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==rl&&r.convert(C)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==tc&&!j)}function l(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=n.precision!==void 0?n.precision:"highp";const u=l(c);u!==c&&(Xt("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),x=t.getParameter(t.MAX_VERTEX_ATTRIBS),M=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),A=b>0,P=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:b,maxTextureSize:y,maxCubemapSize:v,maxAttributes:x,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:T,vertexTextures:A,maxSamples:P}}function cpe(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new bu,o=new un,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,g){const m=h.length!==0||g||r!==0||i;return i=g,r=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,g){n=u(h,g,0)},this.setState=function(h,g,m){const b=h.clippingPlanes,y=h.clipIntersection,v=h.clipShadows,x=t.get(h);if(!i||b===null||b.length===0||s&&!v)s?u(null):c();else{const M=s?0:r,w=M*4;let T=x.clippingState||null;l.value=T,T=u(b,g,w,m);for(let A=0;A!==w;++A)T[A]=n[A];x.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(h,g,m,b){const y=h!==null?h.length:0;let v=null;if(y!==0){if(v=l.value,b!==!0||v===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,T=m;w!==y;++w,T+=4)a.copy(h[w]).applyMatrix4(M,o),a.normal.toArray(v,T),v[T+3]=a.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function upe(t){let e=new WeakMap;function n(a,o){return o===QN?a.mapping=Jp:o===JN&&(a.mapping=em),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===QN||o===JN)if(e.has(a)){const l=e.get(a).texture;return n(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new sde(l.height);return c.fromEquirectangularTexture(t,a),e.set(a,c),a.addEventListener("dispose",i),n(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const Du=4,KF=[.125,.215,.35,.446,.526,.582],Kd=20,dpe=256,Xg=new a7,YF=new bn;let bT=null,yT=0,_T=0,ST=!1;const fpe=new Xe;let ZF=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,s={}){const{size:a=256,position:o=fpe}=s;bT=this._renderer.getRenderTarget(),yT=this._renderer.getActiveCubeFace(),_T=this._renderer.getActiveMipmapLevel(),ST=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,r,i,l,o),n>0&&this._blur(l,0,0,n),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ez(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=JF(),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(bT,yT,_T),this._renderer.xr.enabled=ST,e.scissorTest=!1,qh(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Jp||e.mapping===em?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),bT=this._renderer.getRenderTarget(),yT=this._renderer.getActiveCubeFace(),_T=this._renderer.getActiveMipmapLevel(),ST=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:$a,minFilter:$a,generateMipmaps:!1,type:Nm,format:bo,colorSpace:tm,depthBuffer:!1},i=QF(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=QF(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=hpe(s)),this._blurMaterial=mpe(s,e,n),this._ggxMaterial=ppe(s,e,n)}return i}_compileMaterial(e){const n=new il(new fl,e);this._renderer.compile(n,Xg)}_sceneToCubeUV(e,n,r,i,s){const l=new Ua(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,g=h.autoClear,m=h.toneMapping;h.getClearColor(YF),h.toneMapping=zu,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new il(new mk,new pk({name:"PMREM.Background",side:Bs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,v=y.material;let x=!1;const M=e.background;M?M.isColor&&(v.color.copy(M),e.background=null,x=!0):(v.color.copy(YF),x=!0);for(let w=0;w<6;w++){const T=w%3;T===0?(l.up.set(0,c[w],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+u[w],s.y,s.z)):T===1?(l.up.set(0,0,c[w]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+u[w],s.z)):(l.up.set(0,c[w],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+u[w]));const A=this._cubeSize;qh(i,T*A,w>2?A:0,A,A),h.setRenderTarget(i),x&&h.render(y,l),h.render(e,l)}h.toneMapping=m,h.autoClear=g,e.background=M}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Jp||e.mapping===em;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ez()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=JF());const s=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;qh(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,Xg)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;s<i;s++)this._applyGGXFilter(e,s-1,s);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[r];o.material=a;const l=a.uniforms,c=r/(this._lodMeshes.length-1),u=n/(this._lodMeshes.length-1),h=Math.sqrt(c*c-u*u),g=.05+c*.95,m=h*g,{_lodMax:b}=this,y=this._sizeLods[r],v=3*y*(r>b-Du?r-b+Du:0),x=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=b-n,qh(s,v,x,3*y,2*y),i.setRenderTarget(s),i.render(o,Xg),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=b-r,qh(e,v,x,3*y,2*y),i.setRenderTarget(e),i.render(o,Xg)}_blur(e,n,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,n,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Or("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[i];h.material=c;const g=c.uniforms,m=this._sizeLods[r]-1,b=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Kd-1),y=s/b,v=isFinite(s)?1+Math.floor(u*y):Kd;v>Kd&&Xt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Kd}`);const x=[];let M=0;for(let C=0;C<Kd;++C){const j=C/y,N=Math.exp(-j*j/2);x.push(N),C===0?M+=N:C<v&&(M+=2*N)}for(let C=0;C<x.length;C++)x[C]=x[C]/M;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=x,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=b,g.mipInt.value=w-r;const T=this._sizeLods[i],A=3*T*(i>w-Du?i-w+Du:0),P=4*(this._cubeSize-T);qh(n,A,P,3*T,2*T),l.setRenderTarget(n),l.render(h,Xg)}};function hpe(t){const e=[],n=[],r=[];let i=t;const s=t-Du+1+KF.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>t-Du?l=KF[a-t+Du-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),u=-c,h=1+c,g=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,b=6,y=3,v=2,x=1,M=new Float32Array(y*b*m),w=new Float32Array(v*b*m),T=new Float32Array(x*b*m);for(let P=0;P<m;P++){const C=P%3*2/3-1,j=P>2?0:-1,N=[C,j,0,C+2/3,j,0,C+2/3,j+1,0,C,j,0,C+2/3,j+1,0,C,j+1,0];M.set(N,y*b*P),w.set(g,v*b*P);const k=[P,P,P,P,P,P];T.set(k,x*b*P)}const A=new fl;A.setAttribute("position",new Ga(M,y)),A.setAttribute("uv",new Ga(w,v)),A.setAttribute("faceIndex",new Ga(T,x)),r.push(new il(A,null)),i>Du&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function QF(t,e,n){const r=new kf(t,e,n);return r.texture.mapping=lw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function qh(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function ppe(t,e,n){return new xc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:dpe,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:uw(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:oc,depthTest:!1,depthWrite:!1})}function mpe(t,e,n){const r=new Float32Array(Kd),i=new Xe(0,1,0);return new xc({name:"SphericalGaussianBlur",defines:{n:Kd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:uw(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:oc,depthTest:!1,depthWrite:!1})}function JF(){return new xc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uw(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:oc,depthTest:!1,depthWrite:!1})}function ez(){return new xc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uw(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:oc,depthTest:!1,depthWrite:!1})}function uw(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function gpe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===QN||l===JN,u=l===Jp||l===em;if(c||u){let h=e.get(o);const g=h!==void 0?h.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new ZF(t)),h=c?n.fromEquirectangular(o,h):n.fromCubemap(o,h),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),h.texture;if(h!==void 0)return h.texture;{const m=o.image;return c&&m&&m.height>0||u&&m&&i(m)?(n===null&&(n=new ZF(t)),h=c?n.fromEquirectangular(o):n.fromCubemap(o),h.texture.pmremVersion=o.pmremVersion,e.set(o,h),o.addEventListener("dispose",s),h.texture):null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function xpe(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&&s0("WebGLRenderer: "+r+" extension not supported."),i}}}function vpe(t,e,n,r){const i={},s=new WeakMap;function a(h){const g=h.target;g.index!==null&&e.remove(g.index);for(const b in g.attributes)e.remove(g.attributes[b]);g.removeEventListener("dispose",a),delete i[g.id];const m=s.get(g);m&&(e.remove(m),s.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(h,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(h){const g=h.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function c(h){const g=[],m=h.index,b=h.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let w=0,T=M.length;w<T;w+=3){const A=M[w+0],P=M[w+1],C=M[w+2];g.push(A,P,P,C,C,A)}}else if(b!==void 0){const M=b.array;y=b.version;for(let w=0,T=M.length/3-1;w<T;w+=3){const A=w+0,P=w+1,C=w+2;g.push(A,P,P,C,C,A)}}else return;const v=new(F9(g)?K9:X9)(g,1);v.version=y;const x=s.get(h);x&&e.remove(x),s.set(h,v)}function u(h){const g=s.get(h);if(g){const m=h.index;m!==null&&g.version<m.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function bpe(t,e,n){let r;function i(g){r=g}let s,a;function o(g){s=g.type,a=g.bytesPerElement}function l(g,m){t.drawElements(r,m,s,g*a),n.update(m,r,1)}function c(g,m,b){b!==0&&(t.drawElementsInstanced(r,m,s,g*a,b),n.update(m,r,b))}function u(g,m,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,s,g,0,b);let v=0;for(let x=0;x<b;x++)v+=m[x];n.update(v,r,1)}function h(g,m,b,y){if(b===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<g.length;x++)c(g[x]/a,m[x],y[x]);else{v.multiDrawElementsInstancedWEBGL(r,m,0,s,g,0,y,0,b);let x=0;for(let M=0;M<b;M++)x+=m[M]*y[M];n.update(x,r,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function ype(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default:Or("WebGLInfo: Unknown draw mode:",a);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function _pe(t,e,n){const r=new WeakMap,i=new Gr;function s(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let g=r.get(o);if(g===void 0||g.count!==h){let k=function(){j.dispose(),r.delete(o),o.removeEventListener("dispose",k)};var m=k;g!==void 0&&g.texture.dispose();const b=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],M=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let T=0;b===!0&&(T=1),y===!0&&(T=2),v===!0&&(T=3);let A=o.attributes.position.count*T,P=1;A>e.maxTextureSize&&(P=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const C=new Float32Array(A*P*4*h),j=new V9(C,A,P,h);j.type=tc,j.needsUpdate=!0;const N=T*4;for(let F=0;F<h;F++){const I=x[F],W=M[F],D=w[F],$=A*P*4*F;for(let G=0;G<I.count;G++){const V=G*N;b===!0&&(i.fromBufferAttribute(I,G),C[$+V+0]=i.x,C[$+V+1]=i.y,C[$+V+2]=i.z,C[$+V+3]=0),y===!0&&(i.fromBufferAttribute(W,G),C[$+V+4]=i.x,C[$+V+5]=i.y,C[$+V+6]=i.z,C[$+V+7]=0),v===!0&&(i.fromBufferAttribute(D,G),C[$+V+8]=i.x,C[$+V+9]=i.y,C[$+V+10]=i.z,C[$+V+11]=D.itemSize===4?i.w:1)}}g={count:h,texture:j,size:new on(A,P)},r.set(o,g),o.addEventListener("dispose",k)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let b=0;for(let v=0;v<c.length;v++)b+=c[v];const y=o.morphTargetsRelative?1:1-b;l.getUniforms().setValue(t,"morphTargetBaseInfluence",y),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:s}}function Spe(t,e,n,r){let i=new WeakMap;function s(l){const c=r.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==c&&(g.update(),i.set(g,c))}return h}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:s,dispose:a}}const l7=new Ro,tz=new n7(1,1),c7=new V9,u7=new Hue,d7=new e7,nz=[],rz=[],iz=new Float32Array(16),sz=new Float32Array(9),az=new Float32Array(4);function Pm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=nz[i];if(s===void 0&&(s=new Float32Array(i),nz[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(s,o)}return s}function oi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function li(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function dw(t,e){let n=rz[e];n===void 0&&(n=new Int32Array(e),rz[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function wpe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Mpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(oi(n,e))return;t.uniform2fv(this.addr,e),li(n,e)}}function Epe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(oi(n,e))return;t.uniform3fv(this.addr,e),li(n,e)}}function Ape(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(oi(n,e))return;t.uniform4fv(this.addr,e),li(n,e)}}function Tpe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;az.set(r),t.uniformMatrix2fv(this.addr,!1,az),li(n,r)}}function Cpe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;sz.set(r),t.uniformMatrix3fv(this.addr,!1,sz),li(n,r)}}function Npe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(oi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),li(n,e)}else{if(oi(n,r))return;iz.set(r),t.uniformMatrix4fv(this.addr,!1,iz),li(n,r)}}function Rpe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Ppe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(oi(n,e))return;t.uniform2iv(this.addr,e),li(n,e)}}function kpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(oi(n,e))return;t.uniform3iv(this.addr,e),li(n,e)}}function Dpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(oi(n,e))return;t.uniform4iv(this.addr,e),li(n,e)}}function Ope(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function Lpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(oi(n,e))return;t.uniform2uiv(this.addr,e),li(n,e)}}function Ipe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(oi(n,e))return;t.uniform3uiv(this.addr,e),li(n,e)}}function jpe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(oi(n,e))return;t.uniform4uiv(this.addr,e),li(n,e)}}function Upe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let s;this.type===t.SAMPLER_2D_SHADOW?(tz.compareFunction=U9,s=tz):s=l7,n.setTexture2D(e||s,i)}function Fpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||u7,i)}function zpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||d7,i)}function Bpe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||c7,i)}function Hpe(t){switch(t){case 5126:return wpe;case 35664:return Mpe;case 35665:return Epe;case 35666:return Ape;case 35674:return Tpe;case 35675:return Cpe;case 35676:return Npe;case 5124:case 35670:return Rpe;case 35667:case 35671:return Ppe;case 35668:case 35672:return kpe;case 35669:case 35673:return Dpe;case 5125:return Ope;case 36294:return Lpe;case 36295:return Ipe;case 36296:return jpe;case 35678:case 36198:case 36298:case 36306:case 35682:return Upe;case 35679:case 36299:case 36307:return Fpe;case 35680:case 36300:case 36308:case 36293:return zpe;case 36289:case 36303:case 36311:case 36292:return Bpe}}function $pe(t,e){t.uniform1fv(this.addr,e)}function Vpe(t,e){const n=Pm(e,this.size,2);t.uniform2fv(this.addr,n)}function Gpe(t,e){const n=Pm(e,this.size,3);t.uniform3fv(this.addr,n)}function Wpe(t,e){const n=Pm(e,this.size,4);t.uniform4fv(this.addr,n)}function qpe(t,e){const n=Pm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Xpe(t,e){const n=Pm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Kpe(t,e){const n=Pm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Ype(t,e){t.uniform1iv(this.addr,e)}function Zpe(t,e){t.uniform2iv(this.addr,e)}function Qpe(t,e){t.uniform3iv(this.addr,e)}function Jpe(t,e){t.uniform4iv(this.addr,e)}function eme(t,e){t.uniform1uiv(this.addr,e)}function tme(t,e){t.uniform2uiv(this.addr,e)}function nme(t,e){t.uniform3uiv(this.addr,e)}function rme(t,e){t.uniform4uiv(this.addr,e)}function ime(t,e,n){const r=this.cache,i=e.length,s=dw(n,i);oi(r,s)||(t.uniform1iv(this.addr,s),li(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||l7,s[a])}function sme(t,e,n){const r=this.cache,i=e.length,s=dw(n,i);oi(r,s)||(t.uniform1iv(this.addr,s),li(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||u7,s[a])}function ame(t,e,n){const r=this.cache,i=e.length,s=dw(n,i);oi(r,s)||(t.uniform1iv(this.addr,s),li(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||d7,s[a])}function ome(t,e,n){const r=this.cache,i=e.length,s=dw(n,i);oi(r,s)||(t.uniform1iv(this.addr,s),li(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||c7,s[a])}function lme(t){switch(t){case 5126:return $pe;case 35664:return Vpe;case 35665:return Gpe;case 35666:return Wpe;case 35674:return qpe;case 35675:return Xpe;case 35676:return Kpe;case 5124:case 35670:return Ype;case 35667:case 35671:return Zpe;case 35668:case 35672:return Qpe;case 35669:case 35673:return Jpe;case 5125:return eme;case 36294:return tme;case 36295:return nme;case 36296:return rme;case 35678:case 36198:case 36298:case 36306:case 35682:return ime;case 35679:case 36299:case 36307:return sme;case 35680:case 36300:case 36308:case 36293:return ame;case 36289:case 36303:case 36311:case 36292:return ome}}let cme=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Hpe(n.type)}},ume=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=lme(n.type)}},dme=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,n[o.id],r)}}};const wT=/(\w+)(\])?(\[|\.)?/g;function oz(t,e){t.seq.push(e),t.map[e.id]=e}function fme(t,e,n){const r=t.name,i=r.length;for(wT.lastIndex=0;;){const s=wT.exec(r),a=wT.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){oz(n,c===void 0?new cme(o,t,e):new ume(o,t,e));break}else{let h=n.map[o];h===void 0&&(h=new dme(o),oz(n,h)),n=h}}}let k_=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),a=e.getUniformLocation(n,s.name);fme(s,a,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,a=n.length;s!==a;++s){const o=n[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in n&&r.push(a)}return r}};function lz(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const hme=37297;let pme=0;function mme(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let a=i;a<s;a++){const o=a+1;r.push(`${o===e?">":" "} ${o}: ${n[a]}`)}return r.join(`
- `)}const cz=new un;function gme(t){En._getMatrix(cz,En.workingColorSpace,t);const e=`mat3( ${cz.elements.map(n=>n.toFixed(4))} )`;switch(En.getTransfer(t)){case n1:return[e,"LinearTransferOETF"];case Bn:return[e,"sRGBTransferOETF"];default:return Xt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function uz(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),s=(t.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+s+`
- `+mme(t.getShaderSource(e),o)}else return s}function xme(t,e){const n=gme(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function vme(t,e){let n;switch(e){case mue:n="Linear";break;case gue:n="Reinhard";break;case xue:n="Cineon";break;case vue:n="ACESFilmic";break;case yue:n="AgX";break;case _ue:n="Neutral";break;case bue:n="Custom";break;default:Xt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const cy=new Xe;function bme(){En.getLuminanceCoefficients(cy);const t=cy.x.toFixed(4),e=cy.y.toFixed(4),n=cy.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function yme(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(hx).join(`
- `)}function _me(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function Sme(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),a=s.name;let o=1;s.type===t.FLOAT_MAT2&&(o=2),s.type===t.FLOAT_MAT3&&(o=3),s.type===t.FLOAT_MAT4&&(o=4),n[a]={type:s.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function hx(t){return t!==""}function dz(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 fz(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const wme=/^[ \t]*#include +<([\w\d./]+)>/gm;function k3(t){return t.replace(wme,Eme)}const Mme=new Map;function Eme(t,e){let n=sn[e];if(n===void 0){const r=Mme.get(e);if(r!==void 0)n=sn[r],Xt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return k3(n)}const Ame=/#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 hz(t){return t.replace(Ame,Tme)}function Tme(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function pz(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function Cme(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===C9?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Xce?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Gl&&(e="SHADOWMAP_TYPE_VSM"),e}function Nme(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Jp:case em:e="ENVMAP_TYPE_CUBE";break;case lw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Rme(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case em:e="ENVMAP_MODE_REFRACTION";break}return e}function Pme(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case ik:e="ENVMAP_BLENDING_MULTIPLY";break;case hue:e="ENVMAP_BLENDING_MIX";break;case pue:e="ENVMAP_BLENDING_ADD";break}return e}function kme(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 Dme(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=Cme(n),c=Nme(n),u=Rme(n),h=Pme(n),g=kme(n),m=yme(n),b=_me(s),y=i.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(hx).join(`
- `),v.length>0&&(v+=`
- `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(hx).join(`
- `),x.length>0&&(x+=`
- `)):(v=[pz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(hx).join(`
- `),x=[pz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==zu?"#define TONE_MAPPING":"",n.toneMapping!==zu?sn.tonemapping_pars_fragment:"",n.toneMapping!==zu?vme("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",sn.colorspace_pars_fragment,xme("linearToOutputTexel",n.outputColorSpace),bme(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(hx).join(`
- `)),a=k3(a),a=dz(a,n),a=fz(a,n),o=k3(o),o=dz(o,n),o=fz(o,n),a=hz(a),o=hz(o),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,x=["#define varying in",n.glslVersion===_F?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===_F?"":"#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(`
- `)+`
- `+x);const w=M+v+a,T=M+x+o,A=lz(i,i.VERTEX_SHADER,w),P=lz(i,i.FRAGMENT_SHADER,T);i.attachShader(y,A),i.attachShader(y,P),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(y)||"",W=i.getShaderInfoLog(A)||"",D=i.getShaderInfoLog(P)||"",$=I.trim(),G=W.trim(),V=D.trim();let Z=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Z=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,P);else{const ee=uz(i,A,"vertex"),H=uz(i,P,"fragment");Or("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+F.name+`
- Material Type: `+F.type+`
- Program Info Log: `+$+`
- `+ee+`
- `+H)}else $!==""?Xt("WebGLProgram: Program Info Log:",$):(G===""||V==="")&&(K=!1);K&&(F.diagnostics={runnable:Z,programLog:$,vertexShader:{log:G,prefix:v},fragmentShader:{log:V,prefix:x}})}i.deleteShader(A),i.deleteShader(P),j=new k_(i,y),N=Sme(i,y)}let j;this.getUniforms=function(){return j===void 0&&C(this),j};let N;this.getAttributes=function(){return N===void 0&&C(this),N};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(y,hme)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=pme++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=P,this}let Ome=0,Lme=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new Ime(e),n.set(e,r)),r}},Ime=class{constructor(e){this.id=Ome++,this.code=e,this.usedTimes=0}};function jme(t,e,n,r,i,s,a){const o=new W9,l=new Lme,c=new Set,u=[],h=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return c.add(N),N===0?"uv":`uv${N}`}function v(N,k,F,I,W){const D=I.fog,$=W.geometry,G=N.isMeshStandardMaterial?I.environment:null,V=(N.isMeshStandardMaterial?n:e).get(N.envMap||G),Z=V&&V.mapping===lw?V.image.height:null,K=b[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&Xt("WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const ee=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=ee!==void 0?ee.length:0;let Y=0;$.morphAttributes.position!==void 0&&(Y=1),$.morphAttributes.normal!==void 0&&(Y=2),$.morphAttributes.color!==void 0&&(Y=3);let te,ae,fe,Q;if(K){const Pt=Vo[K];te=Pt.vertexShader,ae=Pt.fragmentShader}else te=N.vertexShader,ae=N.fragmentShader,l.update(N),fe=l.getVertexShaderID(N),Q=l.getFragmentShaderID(N);const me=t.getRenderTarget(),Ee=t.state.buffers.depth.getReversed(),he=W.isInstancedMesh===!0,we=W.isBatchedMesh===!0,De=!!N.map,de=!!N.matcap,Le=!!V,B=!!N.aoMap,z=!!N.lightMap,ie=!!N.bumpMap,X=!!N.normalMap,J=!!N.displacementMap,le=!!N.emissiveMap,Re=!!N.metalnessMap,Ae=!!N.roughnessMap,se=N.anisotropy>0,U=N.clearcoat>0,L=N.dispersion>0,ne=N.iridescence>0,ve=N.sheen>0,ye=N.transmission>0,xe=se&&!!N.anisotropyMap,tt=U&&!!N.clearcoatMap,je=U&&!!N.clearcoatNormalMap,Ye=U&&!!N.clearcoatRoughnessMap,ot=ne&&!!N.iridescenceMap,Fe=ne&&!!N.iridescenceThicknessMap,ce=ve&&!!N.sheenColorMap,Qe=ve&&!!N.sheenRoughnessMap,Be=!!N.specularMap,Ke=!!N.specularColorMap,ct=!!N.specularIntensityMap,ue=ye&&!!N.transmissionMap,Je=ye&&!!N.thicknessMap,ge=!!N.gradientMap,Ie=!!N.alphaMap,Te=N.alphaTest>0,be=!!N.alphaHash,Ve=!!N.extensions;let ft=zu;N.toneMapped&&(me===null||me.isXRRenderTarget===!0)&&(ft=t.toneMapping);const yt={shaderID:K,shaderType:N.type,shaderName:N.name,vertexShader:te,fragmentShader:ae,defines:N.defines,customVertexShaderID:fe,customFragmentShaderID:Q,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:we,batchingColor:we&&W._colorsTexture!==null,instancing:he,instancingColor:he&&W.instanceColor!==null,instancingMorph:he&&W.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:me===null?t.outputColorSpace:me.isXRRenderTarget===!0?me.texture.colorSpace:tm,alphaToCoverage:!!N.alphaToCoverage,map:De,matcap:de,envMap:Le,envMapMode:Le&&V.mapping,envMapCubeUVHeight:Z,aoMap:B,lightMap:z,bumpMap:ie,normalMap:X,displacementMap:g&&J,emissiveMap:le,normalMapObjectSpace:X&&N.normalMapType===Eue,normalMapTangentSpace:X&&N.normalMapType===j9,metalnessMap:Re,roughnessMap:Ae,anisotropy:se,anisotropyMap:xe,clearcoat:U,clearcoatMap:tt,clearcoatNormalMap:je,clearcoatRoughnessMap:Ye,dispersion:L,iridescence:ne,iridescenceMap:ot,iridescenceThicknessMap:Fe,sheen:ve,sheenColorMap:ce,sheenRoughnessMap:Qe,specularMap:Be,specularColorMap:Ke,specularIntensityMap:ct,transmission:ye,transmissionMap:ue,thicknessMap:Je,gradientMap:ge,opaque:N.transparent===!1&&N.blending===Lp&&N.alphaToCoverage===!1,alphaMap:Ie,alphaTest:Te,alphaHash:be,combine:N.combine,mapUv:De&&y(N.map.channel),aoMapUv:B&&y(N.aoMap.channel),lightMapUv:z&&y(N.lightMap.channel),bumpMapUv:ie&&y(N.bumpMap.channel),normalMapUv:X&&y(N.normalMap.channel),displacementMapUv:J&&y(N.displacementMap.channel),emissiveMapUv:le&&y(N.emissiveMap.channel),metalnessMapUv:Re&&y(N.metalnessMap.channel),roughnessMapUv:Ae&&y(N.roughnessMap.channel),anisotropyMapUv:xe&&y(N.anisotropyMap.channel),clearcoatMapUv:tt&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:je&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ye&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:ot&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:Fe&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:Qe&&y(N.sheenRoughnessMap.channel),specularMapUv:Be&&y(N.specularMap.channel),specularColorMapUv:Ke&&y(N.specularColorMap.channel),specularIntensityMapUv:ct&&y(N.specularIntensityMap.channel),transmissionMapUv:ue&&y(N.transmissionMap.channel),thicknessMapUv:Je&&y(N.thicknessMap.channel),alphaMapUv:Ie&&y(N.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(X||se),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!$.attributes.uv&&(De||Ie),fog:!!D,useFog:N.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:N.flatShading===!0&&N.wireframe===!1,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Ee,skinning:W.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:Y,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:ft,decodeVideoTexture:De&&N.map.isVideoTexture===!0&&En.getTransfer(N.map.colorSpace)===Bn,decodeVideoTextureEmissive:le&&N.emissiveMap.isVideoTexture===!0&&En.getTransfer(N.emissiveMap.colorSpace)===Bn,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Go,flipSided:N.side===Bs,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionClipCullDistance:Ve&&N.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ve&&N.extensions.multiDraw===!0||we)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()};return yt.vertexUv1s=c.has(1),yt.vertexUv2s=c.has(2),yt.vertexUv3s=c.has(3),c.clear(),yt}function x(N){const k=[];if(N.shaderID?k.push(N.shaderID):(k.push(N.customVertexShaderID),k.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)k.push(F),k.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(M(k,N),w(k,N),k.push(t.outputColorSpace)),k.push(N.customProgramCacheKey),k.join()}function M(N,k){N.push(k.precision),N.push(k.outputColorSpace),N.push(k.envMapMode),N.push(k.envMapCubeUVHeight),N.push(k.mapUv),N.push(k.alphaMapUv),N.push(k.lightMapUv),N.push(k.aoMapUv),N.push(k.bumpMapUv),N.push(k.normalMapUv),N.push(k.displacementMapUv),N.push(k.emissiveMapUv),N.push(k.metalnessMapUv),N.push(k.roughnessMapUv),N.push(k.anisotropyMapUv),N.push(k.clearcoatMapUv),N.push(k.clearcoatNormalMapUv),N.push(k.clearcoatRoughnessMapUv),N.push(k.iridescenceMapUv),N.push(k.iridescenceThicknessMapUv),N.push(k.sheenColorMapUv),N.push(k.sheenRoughnessMapUv),N.push(k.specularMapUv),N.push(k.specularColorMapUv),N.push(k.specularIntensityMapUv),N.push(k.transmissionMapUv),N.push(k.thicknessMapUv),N.push(k.combine),N.push(k.fogExp2),N.push(k.sizeAttenuation),N.push(k.morphTargetsCount),N.push(k.morphAttributeCount),N.push(k.numDirLights),N.push(k.numPointLights),N.push(k.numSpotLights),N.push(k.numSpotLightMaps),N.push(k.numHemiLights),N.push(k.numRectAreaLights),N.push(k.numDirLightShadows),N.push(k.numPointLightShadows),N.push(k.numSpotLightShadows),N.push(k.numSpotLightShadowsWithMaps),N.push(k.numLightProbes),N.push(k.shadowMapType),N.push(k.toneMapping),N.push(k.numClippingPlanes),N.push(k.numClipIntersection),N.push(k.depthPacking)}function w(N,k){o.disableAll(),k.supportsVertexTextures&&o.enable(0),k.instancing&&o.enable(1),k.instancingColor&&o.enable(2),k.instancingMorph&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),k.dispersion&&o.enable(20),k.batchingColor&&o.enable(21),k.gradientMap&&o.enable(22),N.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.reversedDepthBuffer&&o.enable(4),k.skinning&&o.enable(5),k.morphTargets&&o.enable(6),k.morphNormals&&o.enable(7),k.morphColors&&o.enable(8),k.premultipliedAlpha&&o.enable(9),k.shadowMapEnabled&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),k.decodeVideoTextureEmissive&&o.enable(20),k.alphaToCoverage&&o.enable(21),N.push(o.mask)}function T(N){const k=b[N.type];let F;if(k){const I=Vo[k];F=tde.clone(I.uniforms)}else F=N.uniforms;return F}function A(N,k){let F;for(let I=0,W=u.length;I<W;I++){const D=u[I];if(D.cacheKey===k){F=D,++F.usedTimes;break}}return F===void 0&&(F=new Dme(t,k,N,s),u.push(F)),F}function P(N){if(--N.usedTimes===0){const k=u.indexOf(N);u[k]=u[u.length-1],u.pop(),N.destroy()}}function C(N){l.remove(N)}function j(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:T,acquireProgram:A,releaseProgram:P,releaseShaderCache:C,programs:u,dispose:j}}function Ume(){let t=new WeakMap;function e(a){return t.has(a)}function n(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function r(a){t.delete(a)}function i(a,o,l){t.get(a)[o]=l}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function Fme(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 mz(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 gz(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(h,g,m,b,y,v){let x=t[e];return x===void 0?(x={id:h.id,object:h,geometry:g,material:m,groupOrder:b,renderOrder:h.renderOrder,z:y,group:v},t[e]=x):(x.id=h.id,x.object=h,x.geometry=g,x.material=m,x.groupOrder=b,x.renderOrder=h.renderOrder,x.z=y,x.group=v),e++,x}function o(h,g,m,b,y,v){const x=a(h,g,m,b,y,v);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(h,g,m,b,y,v){const x=a(h,g,m,b,y,v);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(h,g){n.length>1&&n.sort(h||Fme),r.length>1&&r.sort(g||mz),i.length>1&&i.sort(g||mz)}function u(){for(let h=e,g=t.length;h<g;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:u,sort:c}}function zme(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new gz,t.set(r,[a])):i>=s.length?(a=new gz,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function Bme(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Xe,color:new bn};break;case"SpotLight":n={position:new Xe,direction:new Xe,color:new bn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Xe,color:new bn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Xe,skyColor:new bn,groundColor:new bn};break;case"RectAreaLight":n={color:new bn,position:new Xe,halfWidth:new Xe,halfHeight:new Xe};break}return t[e.id]=n,n}}}function Hme(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new on,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let $me=0;function Vme(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Gme(t){const e=new Bme,n=Hme(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)r.probe.push(new Xe);const i=new Xe,s=new Kr,a=new Kr;function o(c){let u=0,h=0,g=0;for(let N=0;N<9;N++)r.probe[N].set(0,0,0);let m=0,b=0,y=0,v=0,x=0,M=0,w=0,T=0,A=0,P=0,C=0;c.sort(Vme);for(let N=0,k=c.length;N<k;N++){const F=c[N],I=F.color,W=F.intensity,D=F.distance,$=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)u+=I.r*W,h+=I.g*W,g+=I.b*W;else if(F.isLightProbe){for(let G=0;G<9;G++)r.probe[G].addScaledVector(F.sh.coefficients[G],W);C++}else if(F.isDirectionalLight){const G=e.get(F);if(G.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const V=F.shadow,Z=n.get(F);Z.shadowIntensity=V.intensity,Z.shadowBias=V.bias,Z.shadowNormalBias=V.normalBias,Z.shadowRadius=V.radius,Z.shadowMapSize=V.mapSize,r.directionalShadow[m]=Z,r.directionalShadowMap[m]=$,r.directionalShadowMatrix[m]=F.shadow.matrix,M++}r.directional[m]=G,m++}else if(F.isSpotLight){const G=e.get(F);G.position.setFromMatrixPosition(F.matrixWorld),G.color.copy(I).multiplyScalar(W),G.distance=D,G.coneCos=Math.cos(F.angle),G.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),G.decay=F.decay,r.spot[y]=G;const V=F.shadow;if(F.map&&(r.spotLightMap[A]=F.map,A++,V.updateMatrices(F),F.castShadow&&P++),r.spotLightMatrix[y]=V.matrix,F.castShadow){const Z=n.get(F);Z.shadowIntensity=V.intensity,Z.shadowBias=V.bias,Z.shadowNormalBias=V.normalBias,Z.shadowRadius=V.radius,Z.shadowMapSize=V.mapSize,r.spotShadow[y]=Z,r.spotShadowMap[y]=$,T++}y++}else if(F.isRectAreaLight){const G=e.get(F);G.color.copy(I).multiplyScalar(W),G.halfWidth.set(F.width*.5,0,0),G.halfHeight.set(0,F.height*.5,0),r.rectArea[v]=G,v++}else if(F.isPointLight){const G=e.get(F);if(G.color.copy(F.color).multiplyScalar(F.intensity),G.distance=F.distance,G.decay=F.decay,F.castShadow){const V=F.shadow,Z=n.get(F);Z.shadowIntensity=V.intensity,Z.shadowBias=V.bias,Z.shadowNormalBias=V.normalBias,Z.shadowRadius=V.radius,Z.shadowMapSize=V.mapSize,Z.shadowCameraNear=V.camera.near,Z.shadowCameraFar=V.camera.far,r.pointShadow[b]=Z,r.pointShadowMap[b]=$,r.pointShadowMatrix[b]=F.shadow.matrix,w++}r.point[b]=G,b++}else if(F.isHemisphereLight){const G=e.get(F);G.skyColor.copy(F.color).multiplyScalar(W),G.groundColor.copy(F.groundColor).multiplyScalar(W),r.hemi[x]=G,x++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=St.LTC_FLOAT_1,r.rectAreaLTC2=St.LTC_FLOAT_2):(r.rectAreaLTC1=St.LTC_HALF_1,r.rectAreaLTC2=St.LTC_HALF_2)),r.ambient[0]=u,r.ambient[1]=h,r.ambient[2]=g;const j=r.hash;(j.directionalLength!==m||j.pointLength!==b||j.spotLength!==y||j.rectAreaLength!==v||j.hemiLength!==x||j.numDirectionalShadows!==M||j.numPointShadows!==w||j.numSpotShadows!==T||j.numSpotMaps!==A||j.numLightProbes!==C)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=v,r.point.length=b,r.hemi.length=x,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=T+A-P,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=P,r.numLightProbes=C,j.directionalLength=m,j.pointLength=b,j.spotLength=y,j.rectAreaLength=v,j.hemiLength=x,j.numDirectionalShadows=M,j.numPointShadows=w,j.numSpotShadows=T,j.numSpotMaps=A,j.numLightProbes=C,r.version=$me++)}function l(c,u){let h=0,g=0,m=0,b=0,y=0;const v=u.matrixWorldInverse;for(let x=0,M=c.length;x<M;x++){const w=c[x];if(w.isDirectionalLight){const T=r.directional[h];T.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(v),h++}else if(w.isSpotLight){const T=r.spot[m];T.position.setFromMatrixPosition(w.matrixWorld),T.position.applyMatrix4(v),T.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(v),m++}else if(w.isRectAreaLight){const T=r.rectArea[b];T.position.setFromMatrixPosition(w.matrixWorld),T.position.applyMatrix4(v),a.identity(),s.copy(w.matrixWorld),s.premultiply(v),a.extractRotation(s),T.halfWidth.set(w.width*.5,0,0),T.halfHeight.set(0,w.height*.5,0),T.halfWidth.applyMatrix4(a),T.halfHeight.applyMatrix4(a),b++}else if(w.isPointLight){const T=r.point[g];T.position.setFromMatrixPosition(w.matrixWorld),T.position.applyMatrix4(v),g++}else if(w.isHemisphereLight){const T=r.hemi[y];T.direction.setFromMatrixPosition(w.matrixWorld),T.direction.transformDirection(v),y++}}}return{setup:o,setupView:l,state:r}}function xz(t){const e=new Gme(t),n=[],r=[];function i(u){c.camera=u,n.length=0,r.length=0}function s(u){n.push(u)}function a(u){r.push(u)}function o(){e.setup(n)}function l(u){e.setupView(n,u)}const c={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function Wme(t){let e=new WeakMap;function n(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new xz(t),e.set(i,[o])):s>=a.length?(o=new xz(t),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const qme=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,Xme=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function Kme(t,e,n){let r=new gk;const i=new on,s=new on,a=new Gr,o=new mde({depthPacking:Mue}),l=new gde,c={},u=n.maxTextureSize,h={[Zu]:Bs,[Bs]:Zu,[Go]:Go},g=new xc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new on},radius:{value:4}},vertexShader:qme,fragmentShader:Xme}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const b=new fl;b.setAttribute("position",new Ga(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new il(b,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=C9;let x=this.type;this.render=function(P,C,j){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||P.length===0)return;const N=t.getRenderTarget(),k=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),I=t.state;I.setBlending(oc),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const W=x!==Gl&&this.type===Gl,D=x===Gl&&this.type!==Gl;for(let $=0,G=P.length;$<G;$++){const V=P[$],Z=V.shadow;if(Z===void 0){Xt("WebGLShadowMap:",V,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;i.copy(Z.mapSize);const K=Z.getFrameExtents();if(i.multiply(K),s.copy(Z.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/K.x),i.x=s.x*K.x,Z.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/K.y),i.y=s.y*K.y,Z.mapSize.y=s.y)),Z.map===null||W===!0||D===!0){const H=this.type!==Gl?{minFilter:fa,magFilter:fa}:{};Z.map!==null&&Z.map.dispose(),Z.map=new kf(i.x,i.y,H),Z.map.texture.name=V.name+".shadowMap",Z.camera.updateProjectionMatrix()}t.setRenderTarget(Z.map),t.clear();const ee=Z.getViewportCount();for(let H=0;H<ee;H++){const Y=Z.getViewport(H);a.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),I.viewport(a),Z.updateMatrices(V,H),r=Z.getFrustum(),T(C,j,Z.camera,V,this.type)}Z.isPointLightShadow!==!0&&this.type===Gl&&M(Z,j),Z.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(N,k,F)};function M(P,C){const j=e.update(y);g.defines.VSM_SAMPLES!==P.blurSamples&&(g.defines.VSM_SAMPLES=P.blurSamples,m.defines.VSM_SAMPLES=P.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new kf(i.x,i.y)),g.uniforms.shadow_pass.value=P.map.texture,g.uniforms.resolution.value=P.mapSize,g.uniforms.radius.value=P.radius,t.setRenderTarget(P.mapPass),t.clear(),t.renderBufferDirect(C,null,j,g,y,null),m.uniforms.shadow_pass.value=P.mapPass.texture,m.uniforms.resolution.value=P.mapSize,m.uniforms.radius.value=P.radius,t.setRenderTarget(P.map),t.clear(),t.renderBufferDirect(C,null,j,m,y,null)}function w(P,C,j,N){let k=null;const F=j.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(F!==void 0)k=F;else if(k=j.isPointLight===!0?l:o,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){const I=k.uuid,W=C.uuid;let D=c[I];D===void 0&&(D={},c[I]=D);let $=D[W];$===void 0&&($=k.clone(),D[W]=$,C.addEventListener("dispose",A)),k=$}if(k.visible=C.visible,k.wireframe=C.wireframe,N===Gl?k.side=C.shadowSide!==null?C.shadowSide:C.side:k.side=C.shadowSide!==null?C.shadowSide:h[C.side],k.alphaMap=C.alphaMap,k.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,k.map=C.map,k.clipShadows=C.clipShadows,k.clippingPlanes=C.clippingPlanes,k.clipIntersection=C.clipIntersection,k.displacementMap=C.displacementMap,k.displacementScale=C.displacementScale,k.displacementBias=C.displacementBias,k.wireframeLinewidth=C.wireframeLinewidth,k.linewidth=C.linewidth,j.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const I=t.properties.get(k);I.light=j}return k}function T(P,C,j,N,k){if(P.visible===!1)return;if(P.layers.test(C.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&k===Gl)&&(!P.frustumCulled||r.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,P.matrixWorld);const W=e.update(P),D=P.material;if(Array.isArray(D)){const $=W.groups;for(let G=0,V=$.length;G<V;G++){const Z=$[G],K=D[Z.materialIndex];if(K&&K.visible){const ee=w(P,K,N,k);P.onBeforeShadow(t,P,C,j,W,ee,Z),t.renderBufferDirect(j,null,W,ee,P,Z),P.onAfterShadow(t,P,C,j,W,ee,Z)}}}else if(D.visible){const $=w(P,D,N,k);P.onBeforeShadow(t,P,C,j,W,$,null),t.renderBufferDirect(j,null,W,$,P,null),P.onAfterShadow(t,P,C,j,W,$,null)}}const I=P.children;for(let W=0,D=I.length;W<D;W++)T(I[W],C,j,N,k)}function A(P){P.target.removeEventListener("dispose",A);for(const j in c){const N=c[j],k=P.target.uuid;k in N&&(N[k].dispose(),delete N[k])}}}const Yme={[GN]:WN,[qN]:YN,[XN]:ZN,[Qp]:KN,[WN]:GN,[YN]:qN,[ZN]:XN,[KN]:Qp};function Zme(t,e){function n(){let ue=!1;const Je=new Gr;let ge=null;const Ie=new Gr(0,0,0,0);return{setMask:function(Te){ge!==Te&&!ue&&(t.colorMask(Te,Te,Te,Te),ge=Te)},setLocked:function(Te){ue=Te},setClear:function(Te,be,Ve,ft,yt){yt===!0&&(Te*=ft,be*=ft,Ve*=ft),Je.set(Te,be,Ve,ft),Ie.equals(Je)===!1&&(t.clearColor(Te,be,Ve,ft),Ie.copy(Je))},reset:function(){ue=!1,ge=null,Ie.set(-1,0,0,0)}}}function r(){let ue=!1,Je=!1,ge=null,Ie=null,Te=null;return{setReversed:function(be){if(Je!==be){const Ve=e.get("EXT_clip_control");be?Ve.clipControlEXT(Ve.LOWER_LEFT_EXT,Ve.ZERO_TO_ONE_EXT):Ve.clipControlEXT(Ve.LOWER_LEFT_EXT,Ve.NEGATIVE_ONE_TO_ONE_EXT),Je=be;const ft=Te;Te=null,this.setClear(ft)}},getReversed:function(){return Je},setTest:function(be){be?me(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(be){ge!==be&&!ue&&(t.depthMask(be),ge=be)},setFunc:function(be){if(Je&&(be=Yme[be]),Ie!==be){switch(be){case GN:t.depthFunc(t.NEVER);break;case WN:t.depthFunc(t.ALWAYS);break;case qN:t.depthFunc(t.LESS);break;case Qp:t.depthFunc(t.LEQUAL);break;case XN:t.depthFunc(t.EQUAL);break;case KN:t.depthFunc(t.GEQUAL);break;case YN:t.depthFunc(t.GREATER);break;case ZN:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ie=be}},setLocked:function(be){ue=be},setClear:function(be){Te!==be&&(Je&&(be=1-be),t.clearDepth(be),Te=be)},reset:function(){ue=!1,ge=null,Ie=null,Te=null,Je=!1}}}function i(){let ue=!1,Je=null,ge=null,Ie=null,Te=null,be=null,Ve=null,ft=null,yt=null;return{setTest:function(Pt){ue||(Pt?me(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(Pt){Je!==Pt&&!ue&&(t.stencilMask(Pt),Je=Pt)},setFunc:function(Pt,cn,Ot){(ge!==Pt||Ie!==cn||Te!==Ot)&&(t.stencilFunc(Pt,cn,Ot),ge=Pt,Ie=cn,Te=Ot)},setOp:function(Pt,cn,Ot){(be!==Pt||Ve!==cn||ft!==Ot)&&(t.stencilOp(Pt,cn,Ot),be=Pt,Ve=cn,ft=Ot)},setLocked:function(Pt){ue=Pt},setClear:function(Pt){yt!==Pt&&(t.clearStencil(Pt),yt=Pt)},reset:function(){ue=!1,Je=null,ge=null,Ie=null,Te=null,be=null,Ve=null,ft=null,yt=null}}}const s=new n,a=new r,o=new i,l=new WeakMap,c=new WeakMap;let u={},h={},g=new WeakMap,m=[],b=null,y=!1,v=null,x=null,M=null,w=null,T=null,A=null,P=null,C=new bn(0,0,0),j=0,N=!1,k=null,F=null,I=null,W=null,D=null;const $=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,V=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(Z)[1]),G=V>=1):Z.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),G=V>=2);let K=null,ee={};const H=t.getParameter(t.SCISSOR_BOX),Y=t.getParameter(t.VIEWPORT),te=new Gr().fromArray(H),ae=new Gr().fromArray(Y);function fe(ue,Je,ge,Ie){const Te=new Uint8Array(4),be=t.createTexture();t.bindTexture(ue,be),t.texParameteri(ue,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ue,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ve=0;Ve<ge;Ve++)ue===t.TEXTURE_3D||ue===t.TEXTURE_2D_ARRAY?t.texImage3D(Je,0,t.RGBA,1,1,Ie,0,t.RGBA,t.UNSIGNED_BYTE,Te):t.texImage2D(Je+Ve,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Te);return be}const Q={};Q[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),Q[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),Q[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Q[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),me(t.DEPTH_TEST),a.setFunc(Qp),ie(!1),X(mF),me(t.CULL_FACE),B(oc);function me(ue){u[ue]!==!0&&(t.enable(ue),u[ue]=!0)}function Ee(ue){u[ue]!==!1&&(t.disable(ue),u[ue]=!1)}function he(ue,Je){return h[ue]!==Je?(t.bindFramebuffer(ue,Je),h[ue]=Je,ue===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=Je),ue===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=Je),!0):!1}function we(ue,Je){let ge=m,Ie=!1;if(ue){ge=g.get(Je),ge===void 0&&(ge=[],g.set(Je,ge));const Te=ue.textures;if(ge.length!==Te.length||ge[0]!==t.COLOR_ATTACHMENT0){for(let be=0,Ve=Te.length;be<Ve;be++)ge[be]=t.COLOR_ATTACHMENT0+be;ge.length=Te.length,Ie=!0}}else ge[0]!==t.BACK&&(ge[0]=t.BACK,Ie=!0);Ie&&t.drawBuffers(ge)}function De(ue){return b!==ue?(t.useProgram(ue),b=ue,!0):!1}const de={[Xd]:t.FUNC_ADD,[Yce]:t.FUNC_SUBTRACT,[Zce]:t.FUNC_REVERSE_SUBTRACT};de[Qce]=t.MIN,de[Jce]=t.MAX;const Le={[eue]:t.ZERO,[tue]:t.ONE,[nue]:t.SRC_COLOR,[$N]:t.SRC_ALPHA,[lue]:t.SRC_ALPHA_SATURATE,[aue]:t.DST_COLOR,[iue]:t.DST_ALPHA,[rue]:t.ONE_MINUS_SRC_COLOR,[VN]:t.ONE_MINUS_SRC_ALPHA,[oue]:t.ONE_MINUS_DST_COLOR,[sue]:t.ONE_MINUS_DST_ALPHA,[cue]:t.CONSTANT_COLOR,[uue]:t.ONE_MINUS_CONSTANT_COLOR,[due]:t.CONSTANT_ALPHA,[fue]:t.ONE_MINUS_CONSTANT_ALPHA};function B(ue,Je,ge,Ie,Te,be,Ve,ft,yt,Pt){if(ue===oc){y===!0&&(Ee(t.BLEND),y=!1);return}if(y===!1&&(me(t.BLEND),y=!0),ue!==Kce){if(ue!==v||Pt!==N){if((x!==Xd||T!==Xd)&&(t.blendEquation(t.FUNC_ADD),x=Xd,T=Xd),Pt)switch(ue){case Lp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case gF:t.blendFunc(t.ONE,t.ONE);break;case xF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case vF:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Or("WebGLState: Invalid blending: ",ue);break}else switch(ue){case Lp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case gF:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case xF:Or("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case vF:Or("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Or("WebGLState: Invalid blending: ",ue);break}M=null,w=null,A=null,P=null,C.set(0,0,0),j=0,v=ue,N=Pt}return}Te=Te||Je,be=be||ge,Ve=Ve||Ie,(Je!==x||Te!==T)&&(t.blendEquationSeparate(de[Je],de[Te]),x=Je,T=Te),(ge!==M||Ie!==w||be!==A||Ve!==P)&&(t.blendFuncSeparate(Le[ge],Le[Ie],Le[be],Le[Ve]),M=ge,w=Ie,A=be,P=Ve),(ft.equals(C)===!1||yt!==j)&&(t.blendColor(ft.r,ft.g,ft.b,yt),C.copy(ft),j=yt),v=ue,N=!1}function z(ue,Je){ue.side===Go?Ee(t.CULL_FACE):me(t.CULL_FACE);let ge=ue.side===Bs;Je&&(ge=!ge),ie(ge),ue.blending===Lp&&ue.transparent===!1?B(oc):B(ue.blending,ue.blendEquation,ue.blendSrc,ue.blendDst,ue.blendEquationAlpha,ue.blendSrcAlpha,ue.blendDstAlpha,ue.blendColor,ue.blendAlpha,ue.premultipliedAlpha),a.setFunc(ue.depthFunc),a.setTest(ue.depthTest),a.setMask(ue.depthWrite),s.setMask(ue.colorWrite);const Ie=ue.stencilWrite;o.setTest(Ie),Ie&&(o.setMask(ue.stencilWriteMask),o.setFunc(ue.stencilFunc,ue.stencilRef,ue.stencilFuncMask),o.setOp(ue.stencilFail,ue.stencilZFail,ue.stencilZPass)),le(ue.polygonOffset,ue.polygonOffsetFactor,ue.polygonOffsetUnits),ue.alphaToCoverage===!0?me(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function ie(ue){k!==ue&&(ue?t.frontFace(t.CW):t.frontFace(t.CCW),k=ue)}function X(ue){ue!==Wce?(me(t.CULL_FACE),ue!==F&&(ue===mF?t.cullFace(t.BACK):ue===qce?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),F=ue}function J(ue){ue!==I&&(G&&t.lineWidth(ue),I=ue)}function le(ue,Je,ge){ue?(me(t.POLYGON_OFFSET_FILL),(W!==Je||D!==ge)&&(t.polygonOffset(Je,ge),W=Je,D=ge)):Ee(t.POLYGON_OFFSET_FILL)}function Re(ue){ue?me(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function Ae(ue){ue===void 0&&(ue=t.TEXTURE0+$-1),K!==ue&&(t.activeTexture(ue),K=ue)}function se(ue,Je,ge){ge===void 0&&(K===null?ge=t.TEXTURE0+$-1:ge=K);let Ie=ee[ge];Ie===void 0&&(Ie={type:void 0,texture:void 0},ee[ge]=Ie),(Ie.type!==ue||Ie.texture!==Je)&&(K!==ge&&(t.activeTexture(ge),K=ge),t.bindTexture(ue,Je||Q[ue]),Ie.type=ue,Ie.texture=Je)}function U(){const ue=ee[K];ue!==void 0&&ue.type!==void 0&&(t.bindTexture(ue.type,null),ue.type=void 0,ue.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function ve(){try{t.texSubImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function ye(){try{t.texSubImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function xe(){try{t.compressedTexSubImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function tt(){try{t.compressedTexSubImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function je(){try{t.texStorage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function Ye(){try{t.texStorage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function ot(){try{t.texImage2D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function Fe(){try{t.texImage3D(...arguments)}catch(ue){ue("WebGLState:",ue)}}function ce(ue){te.equals(ue)===!1&&(t.scissor(ue.x,ue.y,ue.z,ue.w),te.copy(ue))}function Qe(ue){ae.equals(ue)===!1&&(t.viewport(ue.x,ue.y,ue.z,ue.w),ae.copy(ue))}function Be(ue,Je){let ge=c.get(Je);ge===void 0&&(ge=new WeakMap,c.set(Je,ge));let Ie=ge.get(ue);Ie===void 0&&(Ie=t.getUniformBlockIndex(Je,ue.name),ge.set(ue,Ie))}function Ke(ue,Je){const Ie=c.get(Je).get(ue);l.get(Je)!==Ie&&(t.uniformBlockBinding(Je,Ie,ue.__bindingPointIndex),l.set(Je,Ie))}function ct(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),u={},K=null,ee={},h={},g=new WeakMap,m=[],b=null,y=!1,v=null,x=null,M=null,w=null,T=null,A=null,P=null,C=new bn(0,0,0),j=0,N=!1,k=null,F=null,I=null,W=null,D=null,te.set(0,0,t.canvas.width,t.canvas.height),ae.set(0,0,t.canvas.width,t.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:me,disable:Ee,bindFramebuffer:he,drawBuffers:we,useProgram:De,setBlending:B,setMaterial:z,setFlipSided:ie,setCullFace:X,setLineWidth:J,setPolygonOffset:le,setScissorTest:Re,activeTexture:Ae,bindTexture:se,unbindTexture:U,compressedTexImage2D:L,compressedTexImage3D:ne,texImage2D:ot,texImage3D:Fe,updateUBOMapping:Be,uniformBlockBinding:Ke,texStorage2D:je,texStorage3D:Ye,texSubImage2D:ve,texSubImage3D:ye,compressedTexSubImage2D:xe,compressedTexSubImage3D:tt,scissor:ce,viewport:Qe,reset:ct}}function Qme(t,e,n,r,i,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new on,u=new WeakMap;let h;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(U,L){return m?new OffscreenCanvas(U,L):i1("canvas")}function y(U,L,ne){let ve=1;const ye=se(U);if((ye.width>ne||ye.height>ne)&&(ve=ne/Math.max(ye.width,ye.height)),ve<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const xe=Math.floor(ve*ye.width),tt=Math.floor(ve*ye.height);h===void 0&&(h=b(xe,tt));const je=L?b(xe,tt):h;return je.width=xe,je.height=tt,je.getContext("2d").drawImage(U,0,0,xe,tt),Xt("WebGLRenderer: Texture has been resized from ("+ye.width+"x"+ye.height+") to ("+xe+"x"+tt+")."),je}else return"data"in U&&Xt("WebGLRenderer: Image in DataTexture is too big ("+ye.width+"x"+ye.height+")."),U;return U}function v(U){return U.generateMipmaps}function x(U){t.generateMipmap(U)}function M(U){return U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?t.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(U,L,ne,ve,ye=!1){if(U!==null){if(t[U]!==void 0)return t[U];Xt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let xe=L;if(L===t.RED&&(ne===t.FLOAT&&(xe=t.R32F),ne===t.HALF_FLOAT&&(xe=t.R16F),ne===t.UNSIGNED_BYTE&&(xe=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(xe=t.R8UI),ne===t.UNSIGNED_SHORT&&(xe=t.R16UI),ne===t.UNSIGNED_INT&&(xe=t.R32UI),ne===t.BYTE&&(xe=t.R8I),ne===t.SHORT&&(xe=t.R16I),ne===t.INT&&(xe=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(xe=t.RG32F),ne===t.HALF_FLOAT&&(xe=t.RG16F),ne===t.UNSIGNED_BYTE&&(xe=t.RG8)),L===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(xe=t.RG8UI),ne===t.UNSIGNED_SHORT&&(xe=t.RG16UI),ne===t.UNSIGNED_INT&&(xe=t.RG32UI),ne===t.BYTE&&(xe=t.RG8I),ne===t.SHORT&&(xe=t.RG16I),ne===t.INT&&(xe=t.RG32I)),L===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(xe=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(xe=t.RGB16UI),ne===t.UNSIGNED_INT&&(xe=t.RGB32UI),ne===t.BYTE&&(xe=t.RGB8I),ne===t.SHORT&&(xe=t.RGB16I),ne===t.INT&&(xe=t.RGB32I)),L===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(xe=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(xe=t.RGBA16UI),ne===t.UNSIGNED_INT&&(xe=t.RGBA32UI),ne===t.BYTE&&(xe=t.RGBA8I),ne===t.SHORT&&(xe=t.RGBA16I),ne===t.INT&&(xe=t.RGBA32I)),L===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(xe=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(xe=t.R11F_G11F_B10F)),L===t.RGBA){const tt=ye?n1:En.getTransfer(ve);ne===t.FLOAT&&(xe=t.RGBA32F),ne===t.HALF_FLOAT&&(xe=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(xe=tt===Bn?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(xe=t.RGBA4),ne===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 T(U,L){let ne;return U?L===null||L===Rf||L===n0?ne=t.DEPTH24_STENCIL8:L===tc?ne=t.DEPTH32F_STENCIL8:L===t0&&(ne=t.DEPTH24_STENCIL8,Xt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Rf||L===n0?ne=t.DEPTH_COMPONENT24:L===tc?ne=t.DEPTH_COMPONENT32F:L===t0&&(ne=t.DEPTH_COMPONENT16),ne}function A(U,L){return v(U)===!0||U.isFramebufferTexture&&U.minFilter!==fa&&U.minFilter!==$a?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function P(U){const L=U.target;L.removeEventListener("dispose",P),j(L),L.isVideoTexture&&u.delete(L)}function C(U){const L=U.target;L.removeEventListener("dispose",C),k(L)}function j(U){const L=r.get(U);if(L.__webglInit===void 0)return;const ne=U.source,ve=g.get(ne);if(ve){const ye=ve[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&N(U),Object.keys(ve).length===0&&g.delete(ne)}r.remove(U)}function N(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const ne=U.source,ve=g.get(ne);delete ve[L.__cacheKey],a.memory.textures--}function k(U){const L=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++){if(Array.isArray(L.__webglFramebuffer[ve]))for(let ye=0;ye<L.__webglFramebuffer[ve].length;ye++)t.deleteFramebuffer(L.__webglFramebuffer[ve][ye]);else t.deleteFramebuffer(L.__webglFramebuffer[ve]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ve])}else{if(Array.isArray(L.__webglFramebuffer))for(let ve=0;ve<L.__webglFramebuffer.length;ve++)t.deleteFramebuffer(L.__webglFramebuffer[ve]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ve=0;ve<L.__webglColorRenderbuffer.length;ve++)L.__webglColorRenderbuffer[ve]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ve]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const ne=U.textures;for(let ve=0,ye=ne.length;ve<ye;ve++){const xe=r.get(ne[ve]);xe.__webglTexture&&(t.deleteTexture(xe.__webglTexture),a.memory.textures--),r.remove(ne[ve])}r.remove(U)}let F=0;function I(){F=0}function W(){const U=F;return U>=i.maxTextures&&Xt("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),F+=1,U}function D(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function $(U,L){const ne=r.get(U);if(U.isVideoTexture&&Re(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&ne.__version!==U.version){const ve=U.image;if(ve===null)Xt("WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)Xt("WebGLRenderer: Texture marked for update but image is incomplete");else{Q(ne,U,L);return}}else U.isExternalTexture&&(ne.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function G(U,L){const ne=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&ne.__version!==U.version){Q(ne,U,L);return}else U.isExternalTexture&&(ne.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function V(U,L){const ne=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&ne.__version!==U.version){Q(ne,U,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function Z(U,L){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){me(ne,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const K={[e3]:t.REPEAT,[ec]:t.CLAMP_TO_EDGE,[t3]:t.MIRRORED_REPEAT},ee={[fa]:t.NEAREST,[Sue]:t.NEAREST_MIPMAP_NEAREST,[Hb]:t.NEAREST_MIPMAP_LINEAR,[$a]:t.LINEAR,[qA]:t.LINEAR_MIPMAP_NEAREST,[tf]:t.LINEAR_MIPMAP_LINEAR},H={[Aue]:t.NEVER,[kue]:t.ALWAYS,[Tue]:t.LESS,[U9]:t.LEQUAL,[Cue]:t.EQUAL,[Pue]:t.GEQUAL,[Nue]:t.GREATER,[Rue]:t.NOTEQUAL};function Y(U,L){if(L.type===tc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===$a||L.magFilter===qA||L.magFilter===Hb||L.magFilter===tf||L.minFilter===$a||L.minFilter===qA||L.minFilter===Hb||L.minFilter===tf)&&Xt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(U,t.TEXTURE_WRAP_S,K[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,K[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,K[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,ee[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,ee[L.minFilter]),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,H[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===fa||L.minFilter!==Hb&&L.minFilter!==tf||L.type===tc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function te(U,L){let ne=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",P));const ve=L.source;let ye=g.get(ve);ye===void 0&&(ye={},g.set(ve,ye));const xe=D(L);if(xe!==U.__cacheKey){ye[xe]===void 0&&(ye[xe]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,ne=!0),ye[xe].usedTimes++;const tt=ye[U.__cacheKey];tt!==void 0&&(ye[U.__cacheKey].usedTimes--,tt.usedTimes===0&&N(L)),U.__cacheKey=xe,U.__webglTexture=ye[xe].texture}return ne}function ae(U,L,ne){return Math.floor(Math.floor(U/ne)/L)}function fe(U,L,ne,ve){const xe=U.updateRanges;if(xe.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,ne,ve,L.data);else{xe.sort((Fe,ce)=>Fe.start-ce.start);let tt=0;for(let Fe=1;Fe<xe.length;Fe++){const ce=xe[tt],Qe=xe[Fe],Be=ce.start+ce.count,Ke=ae(Qe.start,L.width,4),ct=ae(ce.start,L.width,4);Qe.start<=Be+1&&Ke===ct&&ae(Qe.start+Qe.count-1,L.width,4)===Ke?ce.count=Math.max(ce.count,Qe.start+Qe.count-ce.start):(++tt,xe[tt]=Qe)}xe.length=tt+1;const je=t.getParameter(t.UNPACK_ROW_LENGTH),Ye=t.getParameter(t.UNPACK_SKIP_PIXELS),ot=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Fe=0,ce=xe.length;Fe<ce;Fe++){const Qe=xe[Fe],Be=Math.floor(Qe.start/4),Ke=Math.ceil(Qe.count/4),ct=Be%L.width,ue=Math.floor(Be/L.width),Je=Ke,ge=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ct),t.pixelStorei(t.UNPACK_SKIP_ROWS,ue),n.texSubImage2D(t.TEXTURE_2D,0,ct,ue,Je,ge,ne,ve,L.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,je),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ye),t.pixelStorei(t.UNPACK_SKIP_ROWS,ot)}}function Q(U,L,ne){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const ye=te(U,L),xe=L.source;n.bindTexture(ve,U.__webglTexture,t.TEXTURE0+ne);const tt=r.get(xe);if(xe.version!==tt.__version||ye===!0){n.activeTexture(t.TEXTURE0+ne);const je=En.getPrimaries(En.workingColorSpace),Ye=L.colorSpace===Tu?null:En.getPrimaries(L.colorSpace),ot=L.colorSpace===Tu||je===Ye?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ot);let Fe=y(L.image,!1,i.maxTextureSize);Fe=Ae(L,Fe);const ce=s.convert(L.format,L.colorSpace),Qe=s.convert(L.type);let Be=w(L.internalFormat,ce,Qe,L.colorSpace,L.isVideoTexture);Y(ve,L);let Ke;const ct=L.mipmaps,ue=L.isVideoTexture!==!0,Je=tt.__version===void 0||ye===!0,ge=xe.dataReady,Ie=A(L,Fe);if(L.isDepthTexture)Be=T(L.format===i0,L.type),Je&&(ue?n.texStorage2D(t.TEXTURE_2D,1,Be,Fe.width,Fe.height):n.texImage2D(t.TEXTURE_2D,0,Be,Fe.width,Fe.height,0,ce,Qe,null));else if(L.isDataTexture)if(ct.length>0){ue&&Je&&n.texStorage2D(t.TEXTURE_2D,Ie,Be,ct[0].width,ct[0].height);for(let Te=0,be=ct.length;Te<be;Te++)Ke=ct[Te],ue?ge&&n.texSubImage2D(t.TEXTURE_2D,Te,0,0,Ke.width,Ke.height,ce,Qe,Ke.data):n.texImage2D(t.TEXTURE_2D,Te,Be,Ke.width,Ke.height,0,ce,Qe,Ke.data);L.generateMipmaps=!1}else ue?(Je&&n.texStorage2D(t.TEXTURE_2D,Ie,Be,Fe.width,Fe.height),ge&&fe(L,Fe,ce,Qe)):n.texImage2D(t.TEXTURE_2D,0,Be,Fe.width,Fe.height,0,ce,Qe,Fe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ue&&Je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ie,Be,ct[0].width,ct[0].height,Fe.depth);for(let Te=0,be=ct.length;Te<be;Te++)if(Ke=ct[Te],L.format!==bo)if(ce!==null)if(ue){if(ge)if(L.layerUpdates.size>0){const Ve=XF(Ke.width,Ke.height,L.format,L.type);for(const ft of L.layerUpdates){const yt=Ke.data.subarray(ft*Ve/Ke.data.BYTES_PER_ELEMENT,(ft+1)*Ve/Ke.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,ft,Ke.width,Ke.height,1,ce,yt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,0,Ke.width,Ke.height,Fe.depth,ce,Ke.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Te,Be,Ke.width,Ke.height,Fe.depth,0,Ke.data,0,0);else Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ue?ge&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,0,Ke.width,Ke.height,Fe.depth,ce,Qe,Ke.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Te,Be,Ke.width,Ke.height,Fe.depth,0,ce,Qe,Ke.data)}else{ue&&Je&&n.texStorage2D(t.TEXTURE_2D,Ie,Be,ct[0].width,ct[0].height);for(let Te=0,be=ct.length;Te<be;Te++)Ke=ct[Te],L.format!==bo?ce!==null?ue?ge&&n.compressedTexSubImage2D(t.TEXTURE_2D,Te,0,0,Ke.width,Ke.height,ce,Ke.data):n.compressedTexImage2D(t.TEXTURE_2D,Te,Be,Ke.width,Ke.height,0,Ke.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ue?ge&&n.texSubImage2D(t.TEXTURE_2D,Te,0,0,Ke.width,Ke.height,ce,Qe,Ke.data):n.texImage2D(t.TEXTURE_2D,Te,Be,Ke.width,Ke.height,0,ce,Qe,Ke.data)}else if(L.isDataArrayTexture)if(ue){if(Je&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ie,Be,Fe.width,Fe.height,Fe.depth),ge)if(L.layerUpdates.size>0){const Te=XF(Fe.width,Fe.height,L.format,L.type);for(const be of L.layerUpdates){const Ve=Fe.data.subarray(be*Te/Fe.data.BYTES_PER_ELEMENT,(be+1)*Te/Fe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,be,Fe.width,Fe.height,1,ce,Qe,Ve)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Fe.width,Fe.height,Fe.depth,ce,Qe,Fe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Be,Fe.width,Fe.height,Fe.depth,0,ce,Qe,Fe.data);else if(L.isData3DTexture)ue?(Je&&n.texStorage3D(t.TEXTURE_3D,Ie,Be,Fe.width,Fe.height,Fe.depth),ge&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Fe.width,Fe.height,Fe.depth,ce,Qe,Fe.data)):n.texImage3D(t.TEXTURE_3D,0,Be,Fe.width,Fe.height,Fe.depth,0,ce,Qe,Fe.data);else if(L.isFramebufferTexture){if(Je)if(ue)n.texStorage2D(t.TEXTURE_2D,Ie,Be,Fe.width,Fe.height);else{let Te=Fe.width,be=Fe.height;for(let Ve=0;Ve<Ie;Ve++)n.texImage2D(t.TEXTURE_2D,Ve,Be,Te,be,0,ce,Qe,null),Te>>=1,be>>=1}}else if(ct.length>0){if(ue&&Je){const Te=se(ct[0]);n.texStorage2D(t.TEXTURE_2D,Ie,Be,Te.width,Te.height)}for(let Te=0,be=ct.length;Te<be;Te++)Ke=ct[Te],ue?ge&&n.texSubImage2D(t.TEXTURE_2D,Te,0,0,ce,Qe,Ke):n.texImage2D(t.TEXTURE_2D,Te,Be,ce,Qe,Ke);L.generateMipmaps=!1}else if(ue){if(Je){const Te=se(Fe);n.texStorage2D(t.TEXTURE_2D,Ie,Be,Te.width,Te.height)}ge&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce,Qe,Fe)}else n.texImage2D(t.TEXTURE_2D,0,Be,ce,Qe,Fe);v(L)&&x(ve),tt.__version=xe.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function me(U,L,ne){if(L.image.length!==6)return;const ve=te(U,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+ne);const xe=r.get(ye);if(ye.version!==xe.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const tt=En.getPrimaries(En.workingColorSpace),je=L.colorSpace===Tu?null:En.getPrimaries(L.colorSpace),Ye=L.colorSpace===Tu||tt===je?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,Ye);const ot=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let be=0;be<6;be++)!ot&&!Fe?ce[be]=y(L.image[be],!0,i.maxCubemapSize):ce[be]=Fe?L.image[be].image:L.image[be],ce[be]=Ae(L,ce[be]);const Qe=ce[0],Be=s.convert(L.format,L.colorSpace),Ke=s.convert(L.type),ct=w(L.internalFormat,Be,Ke,L.colorSpace),ue=L.isVideoTexture!==!0,Je=xe.__version===void 0||ve===!0,ge=ye.dataReady;let Ie=A(L,Qe);Y(t.TEXTURE_CUBE_MAP,L);let Te;if(ot){ue&&Je&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ie,ct,Qe.width,Qe.height);for(let be=0;be<6;be++){Te=ce[be].mipmaps;for(let Ve=0;Ve<Te.length;Ve++){const ft=Te[Ve];L.format!==bo?Be!==null?ue?ge&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,0,0,ft.width,ft.height,Be,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,ct,ft.width,ft.height,0,ft.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ue?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,0,0,ft.width,ft.height,Be,Ke,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,ct,ft.width,ft.height,0,Be,Ke,ft.data)}}}else{if(Te=L.mipmaps,ue&&Je){Te.length>0&&Ie++;const be=se(ce[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ie,ct,be.width,be.height)}for(let be=0;be<6;be++)if(Fe){ue?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,ce[be].width,ce[be].height,Be,Ke,ce[be].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ct,ce[be].width,ce[be].height,0,Be,Ke,ce[be].data);for(let Ve=0;Ve<Te.length;Ve++){const yt=Te[Ve].image[be].image;ue?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,0,0,yt.width,yt.height,Be,Ke,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,ct,yt.width,yt.height,0,Be,Ke,yt.data)}}else{ue?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,Be,Ke,ce[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ct,Be,Ke,ce[be]);for(let Ve=0;Ve<Te.length;Ve++){const ft=Te[Ve];ue?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,0,0,Be,Ke,ft.image[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,ct,Be,Ke,ft.image[be])}}}v(L)&&x(t.TEXTURE_CUBE_MAP),xe.__version=ye.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Ee(U,L,ne,ve,ye,xe){const tt=s.convert(ne.format,ne.colorSpace),je=s.convert(ne.type),Ye=w(ne.internalFormat,tt,je,ne.colorSpace),ot=r.get(L),Fe=r.get(ne);if(Fe.__renderTarget=L,!ot.__hasExternalTextures){const ce=Math.max(1,L.width>>xe),Qe=Math.max(1,L.height>>xe);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,xe,Ye,ce,Qe,L.depth,0,tt,je,null):n.texImage2D(ye,xe,Ye,ce,Qe,0,tt,je,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,ye,Fe.__webglTexture,0,J(L)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,ye,Fe.__webglTexture,xe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(U,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer){const ve=L.depthTexture,ye=ve&&ve.isDepthTexture?ve.type:null,xe=T(L.stencilBuffer,ye),tt=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,je=J(L);le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,je,xe,L.width,L.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,je,xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,xe,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,tt,t.RENDERBUFFER,U)}else{const ve=L.textures;for(let ye=0;ye<ve.length;ye++){const xe=ve[ye],tt=s.convert(xe.format,xe.colorSpace),je=s.convert(xe.type),Ye=w(xe.internalFormat,tt,je,xe.colorSpace),ot=J(L);ne&&le(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ot,Ye,L.width,L.height):le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ot,Ye,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Ye,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function we(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ve=r.get(L.depthTexture);ve.__renderTarget=L,(!ve.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),$(L.depthTexture,0);const ye=ve.__webglTexture,xe=J(L);if(L.depthTexture.format===r0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,xe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(L.depthTexture.format===i0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,xe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function De(U){const L=r.get(U),ne=U.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==U.depthTexture){const ve=U.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ve){const ye=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ve.removeEventListener("dispose",ye)};ve.addEventListener("dispose",ye),L.__depthDisposeCallback=ye}L.__boundDepthTexture=ve}if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const ve=U.texture.mipmaps;ve&&ve.length>0?we(L.__webglFramebuffer[0],U):we(L.__webglFramebuffer,U)}else if(ne){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]===void 0)L.__webglDepthbuffer[ve]=t.createRenderbuffer(),he(L.__webglDepthbuffer[ve],U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,xe=L.__webglDepthbuffer[ve];t.bindRenderbuffer(t.RENDERBUFFER,xe),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,xe)}}else{const ve=U.texture.mipmaps;if(ve&&ve.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,xe=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,xe),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,xe)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(U,L,ne){const ve=r.get(U);L!==void 0&&Ee(ve.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&De(U)}function Le(U){const L=U.texture,ne=r.get(U),ve=r.get(L);U.addEventListener("dispose",C);const ye=U.textures,xe=U.isWebGLCubeRenderTarget===!0,tt=ye.length>1;if(tt||(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,a.memory.textures++),xe){ne.__webglFramebuffer=[];for(let je=0;je<6;je++)if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[je]=[];for(let Ye=0;Ye<L.mipmaps.length;Ye++)ne.__webglFramebuffer[je][Ye]=t.createFramebuffer()}else ne.__webglFramebuffer[je]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let je=0;je<L.mipmaps.length;je++)ne.__webglFramebuffer[je]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(tt)for(let je=0,Ye=ye.length;je<Ye;je++){const ot=r.get(ye[je]);ot.__webglTexture===void 0&&(ot.__webglTexture=t.createTexture(),a.memory.textures++)}if(U.samples>0&&le(U)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let je=0;je<ye.length;je++){const Ye=ye[je];ne.__webglColorRenderbuffer[je]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[je]);const ot=s.convert(Ye.format,Ye.colorSpace),Fe=s.convert(Ye.type),ce=w(Ye.internalFormat,ot,Fe,Ye.colorSpace,U.isXRRenderTarget===!0),Qe=J(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Qe,ce,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+je,t.RENDERBUFFER,ne.__webglColorRenderbuffer[je])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),he(ne.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(xe){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),Y(t.TEXTURE_CUBE_MAP,L);for(let je=0;je<6;je++)if(L.mipmaps&&L.mipmaps.length>0)for(let Ye=0;Ye<L.mipmaps.length;Ye++)Ee(ne.__webglFramebuffer[je][Ye],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ye);else Ee(ne.__webglFramebuffer[je],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0);v(L)&&x(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(tt){for(let je=0,Ye=ye.length;je<Ye;je++){const ot=ye[je],Fe=r.get(ot);let ce=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ce=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ce,Fe.__webglTexture),Y(ce,ot),Ee(ne.__webglFramebuffer,U,ot,t.COLOR_ATTACHMENT0+je,ce,0),v(ot)&&x(ce)}n.unbindTexture()}else{let je=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(je=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(je,ve.__webglTexture),Y(je,L),L.mipmaps&&L.mipmaps.length>0)for(let Ye=0;Ye<L.mipmaps.length;Ye++)Ee(ne.__webglFramebuffer[Ye],U,L,t.COLOR_ATTACHMENT0,je,Ye);else Ee(ne.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,je,0);v(L)&&x(je),n.unbindTexture()}U.depthBuffer&&De(U)}function B(U){const L=U.textures;for(let ne=0,ve=L.length;ne<ve;ne++){const ye=L[ne];if(v(ye)){const xe=M(U),tt=r.get(ye).__webglTexture;n.bindTexture(xe,tt),x(xe),n.unbindTexture()}}}const z=[],ie=[];function X(U){if(U.samples>0){if(le(U)===!1){const L=U.textures,ne=U.width,ve=U.height;let ye=t.COLOR_BUFFER_BIT;const xe=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,tt=r.get(U),je=L.length>1;if(je)for(let ot=0;ot<L.length;ot++)n.bindFramebuffer(t.FRAMEBUFFER,tt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,tt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,tt.__webglMultisampledFramebuffer);const Ye=U.texture.mipmaps;Ye&&Ye.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,tt.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,tt.__webglFramebuffer);for(let ot=0;ot<L.length;ot++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),je){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,tt.__webglColorRenderbuffer[ot]);const Fe=r.get(L[ot]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Fe,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,ye,t.NEAREST),l===!0&&(z.length=0,ie.length=0,z.push(t.COLOR_ATTACHMENT0+ot),U.depthBuffer&&U.resolveDepthBuffer===!1&&(z.push(xe),ie.push(xe),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ie)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,z))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),je)for(let ot=0;ot<L.length;ot++){n.bindFramebuffer(t.FRAMEBUFFER,tt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,tt.__webglColorRenderbuffer[ot]);const Fe=r.get(L[ot]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,tt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,tt.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&l){const L=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function J(U){return Math.min(i.maxSamples,U.samples)}function le(U){const L=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Re(U){const L=a.render.frame;u.get(U)!==L&&(u.set(U,L),U.update())}function Ae(U,L){const ne=U.colorSpace,ve=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||ne!==tm&&ne!==Tu&&(En.getTransfer(ne)===Bn?(ve!==bo||ye!==rl)&&Xt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Or("WebGLTextures: Unsupported texture color space:",ne)),L}function se(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(c.width=U.naturalWidth||U.width,c.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(c.width=U.displayWidth,c.height=U.displayHeight):(c.width=U.width,c.height=U.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=I,this.setTexture2D=$,this.setTexture2DArray=G,this.setTexture3D=V,this.setTextureCube=Z,this.rebindTextures=de,this.setupRenderTarget=Le,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=X,this.setupDepthRenderbuffer=De,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=le}function Jme(t,e){function n(r,i=Tu){let s;const a=En.getTransfer(i);if(r===rl)return t.UNSIGNED_BYTE;if(r===ak)return t.UNSIGNED_SHORT_4_4_4_4;if(r===ok)return t.UNSIGNED_SHORT_5_5_5_1;if(r===k9)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===D9)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===R9)return t.BYTE;if(r===P9)return t.SHORT;if(r===t0)return t.UNSIGNED_SHORT;if(r===sk)return t.INT;if(r===Rf)return t.UNSIGNED_INT;if(r===tc)return t.FLOAT;if(r===Nm)return t.HALF_FLOAT;if(r===O9)return t.ALPHA;if(r===L9)return t.RGB;if(r===bo)return t.RGBA;if(r===r0)return t.DEPTH_COMPONENT;if(r===i0)return t.DEPTH_STENCIL;if(r===I9)return t.RED;if(r===lk)return t.RED_INTEGER;if(r===ck)return t.RG;if(r===uk)return t.RG_INTEGER;if(r===dk)return t.RGBA_INTEGER;if(r===E_||r===A_||r===T_||r===C_)if(a===Bn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===E_)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===A_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===T_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===C_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===E_)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===A_)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===T_)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===C_)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===n3||r===r3||r===i3||r===s3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===n3)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===r3)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===i3)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===s3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===a3||r===o3||r===l3)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===a3||r===o3)return a===Bn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===l3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===c3||r===u3||r===d3||r===f3||r===h3||r===p3||r===m3||r===g3||r===x3||r===v3||r===b3||r===y3||r===_3||r===S3)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===c3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===u3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===d3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===f3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===h3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===p3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===m3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===g3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===x3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===v3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===b3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===y3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===_3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===S3)return a===Bn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===w3||r===M3||r===E3)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===w3)return a===Bn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===M3)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===E3)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===A3||r===T3||r===C3||r===N3)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===A3)return s.COMPRESSED_RED_RGTC1_EXT;if(r===T3)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===C3)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===N3)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===n0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const ege=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,tge=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class nge{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new r7(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 xc({vertexShader:ege,fragmentShader:tge,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new il(new xk(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let rge=class extends Kf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,g=null,m=null,b=null;const y=typeof XRWebGLBinding<"u",v=new nge,x={},M=n.getContextAttributes();let w=null,T=null;const A=[],P=[],C=new on;let j=null;const N=new Ua;N.viewport=new Gr;const k=new Ua;k.viewport=new Gr;const F=[N,k],I=new yde;let W=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let me=A[Q];return me===void 0&&(me=new mT,A[Q]=me),me.getTargetRaySpace()},this.getControllerGrip=function(Q){let me=A[Q];return me===void 0&&(me=new mT,A[Q]=me),me.getGripSpace()},this.getHand=function(Q){let me=A[Q];return me===void 0&&(me=new mT,A[Q]=me),me.getHandSpace()};function $(Q){const me=P.indexOf(Q.inputSource);if(me===-1)return;const Ee=A[me];Ee!==void 0&&(Ee.update(Q.inputSource,Q.frame,c||a),Ee.dispatchEvent({type:Q.type,data:Q.inputSource}))}function G(){i.removeEventListener("select",$),i.removeEventListener("selectstart",$),i.removeEventListener("selectend",$),i.removeEventListener("squeeze",$),i.removeEventListener("squeezestart",$),i.removeEventListener("squeezeend",$),i.removeEventListener("end",G),i.removeEventListener("inputsourceschange",V);for(let Q=0;Q<A.length;Q++){const me=P[Q];me!==null&&(P[Q]=null,A[Q].disconnect(me))}W=null,D=null,v.reset();for(const Q in x)delete x[Q];e.setRenderTarget(w),m=null,g=null,h=null,i=null,T=null,fe.stop(),r.isPresenting=!1,e.setPixelRatio(j),e.setSize(C.width,C.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Q){s=Q,r.isPresenting===!0&&Xt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Q){o=Q,r.isPresenting===!0&&Xt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Q){c=Q},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,n)),h},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(Q){if(i=Q,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",$),i.addEventListener("selectstart",$),i.addEventListener("selectend",$),i.addEventListener("squeeze",$),i.addEventListener("squeezestart",$),i.addEventListener("squeezeend",$),i.addEventListener("end",G),i.addEventListener("inputsourceschange",V),M.xrCompatible!==!0&&await n.makeXRCompatible(),j=e.getPixelRatio(),e.getSize(C),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,he=null,we=null;M.depth&&(we=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ee=M.stencil?i0:r0,he=M.stencil?n0:Rf);const De={colorFormat:n.RGBA8,depthFormat:we,scaleFactor:s};h=this.getBinding(),g=h.createProjectionLayer(De),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),T=new kf(g.textureWidth,g.textureHeight,{format:bo,type:rl,depthTexture:new n7(g.textureWidth,g.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Ee={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,Ee),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),T=new kf(m.framebufferWidth,m.framebufferHeight,{format:bo,type:rl,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),fe.setContext(i),fe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function V(Q){for(let me=0;me<Q.removed.length;me++){const Ee=Q.removed[me],he=P.indexOf(Ee);he>=0&&(P[he]=null,A[he].disconnect(Ee))}for(let me=0;me<Q.added.length;me++){const Ee=Q.added[me];let he=P.indexOf(Ee);if(he===-1){for(let De=0;De<A.length;De++)if(De>=P.length){P.push(Ee),he=De;break}else if(P[De]===null){P[De]=Ee,he=De;break}if(he===-1)break}const we=A[he];we&&we.connect(Ee)}}const Z=new Xe,K=new Xe;function ee(Q,me,Ee){Z.setFromMatrixPosition(me.matrixWorld),K.setFromMatrixPosition(Ee.matrixWorld);const he=Z.distanceTo(K),we=me.projectionMatrix.elements,De=Ee.projectionMatrix.elements,de=we[14]/(we[10]-1),Le=we[14]/(we[10]+1),B=(we[9]+1)/we[5],z=(we[9]-1)/we[5],ie=(we[8]-1)/we[0],X=(De[8]+1)/De[0],J=de*ie,le=de*X,Re=he/(-ie+X),Ae=Re*-ie;if(me.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(Ae),Q.translateZ(Re),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert(),we[10]===-1)Q.projectionMatrix.copy(me.projectionMatrix),Q.projectionMatrixInverse.copy(me.projectionMatrixInverse);else{const se=de+Re,U=Le+Re,L=J-Ae,ne=le+(he-Ae),ve=B*Le/U*se,ye=z*Le/U*se;Q.projectionMatrix.makePerspective(L,ne,ve,ye,se,U),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}}function H(Q,me){me===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(me.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(i===null)return;let me=Q.near,Ee=Q.far;v.texture!==null&&(v.depthNear>0&&(me=v.depthNear),v.depthFar>0&&(Ee=v.depthFar)),I.near=k.near=N.near=me,I.far=k.far=N.far=Ee,(W!==I.near||D!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),W=I.near,D=I.far),I.layers.mask=Q.layers.mask|6,N.layers.mask=I.layers.mask&3,k.layers.mask=I.layers.mask&5;const he=Q.parent,we=I.cameras;H(I,he);for(let De=0;De<we.length;De++)H(we[De],he);we.length===2?ee(I,N,k):I.projectionMatrix.copy(N.projectionMatrix),Y(Q,I,he)};function Y(Q,me,Ee){Ee===null?Q.matrix.copy(me.matrixWorld):(Q.matrix.copy(Ee.matrixWorld),Q.matrix.invert(),Q.matrix.multiply(me.matrixWorld)),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale),Q.updateMatrixWorld(!0),Q.projectionMatrix.copy(me.projectionMatrix),Q.projectionMatrixInverse.copy(me.projectionMatrixInverse),Q.isPerspectiveCamera&&(Q.fov=R3*2*Math.atan(1/Q.projectionMatrix.elements[5]),Q.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(Q){l=Q,g!==null&&(g.fixedFoveation=Q),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=Q)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(I)},this.getCameraTexture=function(Q){return x[Q]};let te=null;function ae(Q,me){if(u=me.getViewerPose(c||a),b=me,u!==null){const Ee=u.views;m!==null&&(e.setRenderTargetFramebuffer(T,m.framebuffer),e.setRenderTarget(T));let he=!1;Ee.length!==I.cameras.length&&(I.cameras.length=0,he=!0);for(let Le=0;Le<Ee.length;Le++){const B=Ee[Le];let z=null;if(m!==null)z=m.getViewport(B);else{const X=h.getViewSubImage(g,B);z=X.viewport,Le===0&&(e.setRenderTargetTextures(T,X.colorTexture,X.depthStencilTexture),e.setRenderTarget(T))}let ie=F[Le];ie===void 0&&(ie=new Ua,ie.layers.enable(Le),ie.viewport=new Gr,F[Le]=ie),ie.matrix.fromArray(B.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(B.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(z.x,z.y,z.width,z.height),Le===0&&(I.matrix.copy(ie.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),he===!0&&I.cameras.push(ie)}const we=i.enabledFeatures;if(we&&we.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=r.getBinding();const Le=h.getDepthInformation(Ee[0]);Le&&Le.isValid&&Le.texture&&v.init(Le,i.renderState)}if(we&&we.includes("camera-access")&&y){e.state.unbindTexture(),h=r.getBinding();for(let Le=0;Le<Ee.length;Le++){const B=Ee[Le].camera;if(B){let z=x[B];z||(z=new r7,x[B]=z);const ie=h.getCameraImage(B);z.sourceTexture=ie}}}}for(let Ee=0;Ee<A.length;Ee++){const he=P[Ee],we=A[Ee];he!==null&&we!==void 0&&we.update(he,me,c||a)}te&&te(Q,me),me.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:me}),b=null}const fe=new o7;fe.setAnimationLoop(ae),this.setAnimationLoop=function(Q){te=Q},this.dispose=function(){}}};const Id=new Qu,ige=new Kr;function sge(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function r(v,x){x.color.getRGB(v.fogColor.value,Q9(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function i(v,x,M,w,T){x.isMeshBasicMaterial||x.isMeshLambertMaterial?s(v,x):x.isMeshToonMaterial?(s(v,x),h(v,x)):x.isMeshPhongMaterial?(s(v,x),u(v,x)):x.isMeshStandardMaterial?(s(v,x),g(v,x),x.isMeshPhysicalMaterial&&m(v,x,T)):x.isMeshMatcapMaterial?(s(v,x),b(v,x)):x.isMeshDepthMaterial?s(v,x):x.isMeshDistanceMaterial?(s(v,x),y(v,x)):x.isMeshNormalMaterial?s(v,x):x.isLineBasicMaterial?(a(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?l(v,x,M,w):x.isSpriteMaterial?c(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function s(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===Bs&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===Bs&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x),w=M.envMap,T=M.envMapRotation;w&&(v.envMap.value=w,Id.copy(T),Id.x*=-1,Id.y*=-1,Id.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Id.y*=-1,Id.z*=-1),v.envMapRotation.value.setFromMatrix4(ige.makeRotationFromEuler(Id)),v.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap&&(v.lightMap.value=x.lightMap,v.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,v.lightMapTransform)),x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function a(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function l(v,x,M,w){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=w*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function c(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function u(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function h(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function g(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),x.envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Bs&&v.clearcoatNormalScale.value.negate())),x.dispersion>0&&(v.dispersion.value=x.dispersion),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function b(v,x){x.matcap&&(v.matcap.value=x.matcap)}function y(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function age(t,e,n,r){let i={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,w){const T=w.program;r.uniformBlockBinding(M,T)}function c(M,w){let T=i[M.id];T===void 0&&(b(M),T=u(M),i[M.id]=T,M.addEventListener("dispose",v));const A=w.program;r.updateUBOMapping(M,A);const P=e.render.frame;s[M.id]!==P&&(g(M),s[M.id]=P)}function u(M){const w=h();M.__bindingPointIndex=w;const T=t.createBuffer(),A=M.__size,P=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,A,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,T),T}function h(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Or("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const w=i[M.id],T=M.uniforms,A=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let P=0,C=T.length;P<C;P++){const j=Array.isArray(T[P])?T[P]:[T[P]];for(let N=0,k=j.length;N<k;N++){const F=j[N];if(m(F,P,N,A)===!0){const I=F.__offset,W=Array.isArray(F.value)?F.value:[F.value];let D=0;for(let $=0;$<W.length;$++){const G=W[$],V=y(G);typeof G=="number"||typeof G=="boolean"?(F.__data[0]=G,t.bufferSubData(t.UNIFORM_BUFFER,I+D,F.__data)):G.isMatrix3?(F.__data[0]=G.elements[0],F.__data[1]=G.elements[1],F.__data[2]=G.elements[2],F.__data[3]=0,F.__data[4]=G.elements[3],F.__data[5]=G.elements[4],F.__data[6]=G.elements[5],F.__data[7]=0,F.__data[8]=G.elements[6],F.__data[9]=G.elements[7],F.__data[10]=G.elements[8],F.__data[11]=0):(G.toArray(F.__data,D),D+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,I,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,T,A){const P=M.value,C=w+"_"+T;if(A[C]===void 0)return typeof P=="number"||typeof P=="boolean"?A[C]=P:A[C]=P.clone(),!0;{const j=A[C];if(typeof P=="number"||typeof P=="boolean"){if(j!==P)return A[C]=P,!0}else if(j.equals(P)===!1)return j.copy(P),!0}return!1}function b(M){const w=M.uniforms;let T=0;const A=16;for(let C=0,j=w.length;C<j;C++){const N=Array.isArray(w[C])?w[C]:[w[C]];for(let k=0,F=N.length;k<F;k++){const I=N[k],W=Array.isArray(I.value)?I.value:[I.value];for(let D=0,$=W.length;D<$;D++){const G=W[D],V=y(G),Z=T%A,K=Z%V.boundary,ee=Z+K;T+=K,ee!==0&&A-ee<V.storage&&(T+=A-ee),I.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=T,T+=V.storage}}}const P=T%A;return P>0&&(T+=A-P),M.__size=T,M.__cache={},this}function y(M){const w={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?Xt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Xt("WebGLRenderer: Unsupported uniform value type.",M),w}function v(M){const w=M.target;w.removeEventListener("dispose",v);const T=a.indexOf(w.__bindingPointIndex);a.splice(T,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);a=[],i={},s={}}return{bind:l,update:c,dispose:x}}const oge=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 Il=null;function lge(){return Il===null&&(Il=new lde(oge,32,32,ck,Nm),Il.minFilter=$a,Il.magFilter=$a,Il.wrapS=ec,Il.wrapT=ec,Il.generateMipmaps=!1,Il.needsUpdate=!0),Il}let cge=class{constructor(e={}){const{canvas:n=Due(),context:r=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=a;const b=new Set([dk,uk,lk]),y=new Set([rl,Rf,t0,n0,ak,ok]),v=new Uint32Array(4),x=new Int32Array(4);let M=null,w=null;const T=[],A=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=zu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let C=!1;this._outputColorSpace=La;let j=0,N=0,k=null,F=-1,I=null;const W=new Gr,D=new Gr;let $=null;const G=new bn(0);let V=0,Z=n.width,K=n.height,ee=1,H=null,Y=null;const te=new Gr(0,0,Z,K),ae=new Gr(0,0,Z,K);let fe=!1;const Q=new gk;let me=!1,Ee=!1;const he=new Kr,we=new Xe,De=new Gr,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Le=!1;function B(){return k===null?ee:1}let z=r;function ie(re,_e){return n.getContext(re,_e)}try{const re={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${rk}`),n.addEventListener("webglcontextlost",Te,!1),n.addEventListener("webglcontextrestored",be,!1),n.addEventListener("webglcontextcreationerror",Ve,!1),z===null){const _e="webgl2";if(z=ie(_e,re),z===null)throw ie(_e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(re){throw re("WebGLRenderer: "+re.message),re}let X,J,le,Re,Ae,se,U,L,ne,ve,ye,xe,tt,je,Ye,ot,Fe,ce,Qe,Be,Ke,ct,ue,Je;function ge(){X=new xpe(z),X.init(),ct=new Jme(z,X),J=new lpe(z,X,e,ct),le=new Zme(z,X),J.reversedDepthBuffer&&g&&le.buffers.depth.setReversed(!0),Re=new ype(z),Ae=new Ume,se=new Qme(z,X,le,Ae,J,ct,Re),U=new upe(P),L=new gpe(P),ne=new Mde(z),ue=new ape(z,ne),ve=new vpe(z,ne,Re,ue),ye=new Spe(z,ve,ne,Re),Qe=new _pe(z,J,se),ot=new cpe(Ae),xe=new jme(P,U,L,X,J,ue,ot),tt=new sge(P,Ae),je=new zme,Ye=new Wme(X),ce=new spe(P,U,L,le,ye,m,l),Fe=new Kme(P,ye,J),Je=new age(z,Re,J,le),Be=new ope(z,X,Re),Ke=new bpe(z,X,Re),Re.programs=xe.programs,P.capabilities=J,P.extensions=X,P.properties=Ae,P.renderLists=je,P.shadowMap=Fe,P.state=le,P.info=Re}ge();const Ie=new rge(P,z);this.xr=Ie,this.getContext=function(){return z},this.getContextAttributes=function(){return z.getContextAttributes()},this.forceContextLoss=function(){const re=X.get("WEBGL_lose_context");re&&re.loseContext()},this.forceContextRestore=function(){const re=X.get("WEBGL_lose_context");re&&re.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(re){re!==void 0&&(ee=re,this.setSize(Z,K,!1))},this.getSize=function(re){return re.set(Z,K)},this.setSize=function(re,_e,ke=!0){if(Ie.isPresenting){Xt("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=re,K=_e,n.width=Math.floor(re*ee),n.height=Math.floor(_e*ee),ke===!0&&(n.style.width=re+"px",n.style.height=_e+"px"),this.setViewport(0,0,re,_e)},this.getDrawingBufferSize=function(re){return re.set(Z*ee,K*ee).floor()},this.setDrawingBufferSize=function(re,_e,ke){Z=re,K=_e,ee=ke,n.width=Math.floor(re*ke),n.height=Math.floor(_e*ke),this.setViewport(0,0,re,_e)},this.getCurrentViewport=function(re){return re.copy(W)},this.getViewport=function(re){return re.copy(te)},this.setViewport=function(re,_e,ke,Pe){re.isVector4?te.set(re.x,re.y,re.z,re.w):te.set(re,_e,ke,Pe),le.viewport(W.copy(te).multiplyScalar(ee).round())},this.getScissor=function(re){return re.copy(ae)},this.setScissor=function(re,_e,ke,Pe){re.isVector4?ae.set(re.x,re.y,re.z,re.w):ae.set(re,_e,ke,Pe),le.scissor(D.copy(ae).multiplyScalar(ee).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(re){le.setScissorTest(fe=re)},this.setOpaqueSort=function(re){H=re},this.setTransparentSort=function(re){Y=re},this.getClearColor=function(re){return re.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor(...arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha(...arguments)},this.clear=function(re=!0,_e=!0,ke=!0){let Pe=0;if(re){let Me=!1;if(k!==null){const st=k.texture.format;Me=b.has(st)}if(Me){const st=k.texture.type,ht=y.has(st),vt=ce.getClearColor(),xt=ce.getClearAlpha(),kt=vt.r,wt=vt.g,mt=vt.b;ht?(v[0]=kt,v[1]=wt,v[2]=mt,v[3]=xt,z.clearBufferuiv(z.COLOR,0,v)):(x[0]=kt,x[1]=wt,x[2]=mt,x[3]=xt,z.clearBufferiv(z.COLOR,0,x))}else Pe|=z.COLOR_BUFFER_BIT}_e&&(Pe|=z.DEPTH_BUFFER_BIT),ke&&(Pe|=z.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z.clear(Pe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Te,!1),n.removeEventListener("webglcontextrestored",be,!1),n.removeEventListener("webglcontextcreationerror",Ve,!1),ce.dispose(),je.dispose(),Ye.dispose(),Ae.dispose(),U.dispose(),L.dispose(),ye.dispose(),ue.dispose(),Je.dispose(),xe.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",qn),Ie.removeEventListener("sessionend",gi),Jr.stop()};function Te(re){re.preventDefault(),wF("WebGLRenderer: Context Lost."),C=!0}function be(){wF("WebGLRenderer: Context Restored."),C=!1;const re=Re.autoReset,_e=Fe.enabled,ke=Fe.autoUpdate,Pe=Fe.needsUpdate,Me=Fe.type;ge(),Re.autoReset=re,Fe.enabled=_e,Fe.autoUpdate=ke,Fe.needsUpdate=Pe,Fe.type=Me}function Ve(re){Or("WebGLRenderer: A WebGL context could not be created. Reason: ",re.statusMessage)}function ft(re){const _e=re.target;_e.removeEventListener("dispose",ft),yt(_e)}function yt(re){Pt(re),Ae.remove(re)}function Pt(re){const _e=Ae.get(re).programs;_e!==void 0&&(_e.forEach(function(ke){xe.releaseProgram(ke)}),re.isShaderMaterial&&xe.releaseShaderCache(re))}this.renderBufferDirect=function(re,_e,ke,Pe,Me,st){_e===null&&(_e=de);const ht=Me.isMesh&&Me.matrixWorld.determinant()<0,vt=pe(re,_e,ke,Pe,Me);le.setMaterial(Pe,ht);let xt=ke.index,kt=1;if(Pe.wireframe===!0){if(xt=ve.getWireframeAttribute(ke),xt===void 0)return;kt=2}const wt=ke.drawRange,mt=ke.attributes.position;let qt=wt.start*kt,It=(wt.start+wt.count)*kt;st!==null&&(qt=Math.max(qt,st.start*kt),It=Math.min(It,(st.start+st.count)*kt)),xt!==null?(qt=Math.max(qt,0),It=Math.min(It,xt.count)):mt!=null&&(qt=Math.max(qt,0),It=Math.min(It,mt.count));const nn=It-qt;if(nn<0||nn===1/0)return;ue.setup(Me,Pe,vt,ke,xt);let dn,gn=Be;if(xt!==null&&(dn=ne.get(xt),gn=Ke,gn.setIndex(dn)),Me.isMesh)Pe.wireframe===!0?(le.setLineWidth(Pe.wireframeLinewidth*B()),gn.setMode(z.LINES)):gn.setMode(z.TRIANGLES);else if(Me.isLine){let Lt=Pe.linewidth;Lt===void 0&&(Lt=1),le.setLineWidth(Lt*B()),Me.isLineSegments?gn.setMode(z.LINES):Me.isLineLoop?gn.setMode(z.LINE_LOOP):gn.setMode(z.LINE_STRIP)}else Me.isPoints?gn.setMode(z.POINTS):Me.isSprite&&gn.setMode(z.TRIANGLES);if(Me.isBatchedMesh)if(Me._multiDrawInstances!==null)s0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),gn.renderMultiDrawInstances(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount,Me._multiDrawInstances);else if(X.get("WEBGL_multi_draw"))gn.renderMultiDraw(Me._multiDrawStarts,Me._multiDrawCounts,Me._multiDrawCount);else{const Lt=Me._multiDrawStarts,Yt=Me._multiDrawCounts,Qt=Me._multiDrawCount,yr=xt?ne.get(xt).bytesPerElement:1,Nr=Ae.get(Pe).currentProgram.getUniforms();for(let Nn=0;Nn<Qt;Nn++)Nr.setValue(z,"_gl_DrawID",Nn),gn.render(Lt[Nn]/yr,Yt[Nn])}else if(Me.isInstancedMesh)gn.renderInstances(qt,nn,Me.count);else if(ke.isInstancedBufferGeometry){const Lt=ke._maxInstanceCount!==void 0?ke._maxInstanceCount:1/0,Yt=Math.min(ke.instanceCount,Lt);gn.renderInstances(qt,nn,Yt)}else gn.render(qt,nn)};function cn(re,_e,ke){re.transparent===!0&&re.side===Go&&re.forceSinglePass===!1?(re.side=Bs,re.needsUpdate=!0,Cr(re,_e,ke),re.side=Zu,re.needsUpdate=!0,Cr(re,_e,ke),re.side=Go):Cr(re,_e,ke)}this.compile=function(re,_e,ke=null){ke===null&&(ke=re),w=Ye.get(ke),w.init(_e),A.push(w),ke.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),re!==ke&&re.traverseVisible(function(Me){Me.isLight&&Me.layers.test(_e.layers)&&(w.pushLight(Me),Me.castShadow&&w.pushShadow(Me))}),w.setupLights();const Pe=new Set;return re.traverse(function(Me){if(!(Me.isMesh||Me.isPoints||Me.isLine||Me.isSprite))return;const st=Me.material;if(st)if(Array.isArray(st))for(let ht=0;ht<st.length;ht++){const vt=st[ht];cn(vt,ke,Me),Pe.add(vt)}else cn(st,ke,Me),Pe.add(st)}),w=A.pop(),Pe},this.compileAsync=function(re,_e,ke=null){const Pe=this.compile(re,_e,ke);return new Promise(Me=>{function st(){if(Pe.forEach(function(ht){Ae.get(ht).currentProgram.isReady()&&Pe.delete(ht)}),Pe.size===0){Me(re);return}setTimeout(st,10)}X.get("KHR_parallel_shader_compile")!==null?st():setTimeout(st,10)})};let Ot=null;function Pn(re){Ot&&Ot(re)}function qn(){Jr.stop()}function gi(){Jr.start()}const Jr=new o7;Jr.setAnimationLoop(Pn),typeof self<"u"&&Jr.setContext(self),this.setAnimationLoop=function(re){Ot=re,Ie.setAnimationLoop(re),re===null?Jr.stop():Jr.start()},Ie.addEventListener("sessionstart",qn),Ie.addEventListener("sessionend",gi),this.render=function(re,_e){if(_e!==void 0&&_e.isCamera!==!0){Or("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;if(re.matrixWorldAutoUpdate===!0&&re.updateMatrixWorld(),_e.parent===null&&_e.matrixWorldAutoUpdate===!0&&_e.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(_e),_e=Ie.getCamera()),re.isScene===!0&&re.onBeforeRender(P,re,_e,k),w=Ye.get(re,A.length),w.init(_e),A.push(w),he.multiplyMatrices(_e.projectionMatrix,_e.matrixWorldInverse),Q.setFromProjectionMatrix(he,Ko,_e.reversedDepth),Ee=this.localClippingEnabled,me=ot.init(this.clippingPlanes,Ee),M=je.get(re,T.length),M.init(),T.push(M),Ie.enabled===!0&&Ie.isPresenting===!0){const st=P.xr.getDepthSensingMesh();st!==null&&xi(st,_e,-1/0,P.sortObjects)}xi(re,_e,0,P.sortObjects),M.finish(),P.sortObjects===!0&&M.sort(H,Y),Le=Ie.enabled===!1||Ie.isPresenting===!1||Ie.hasDepthSensing()===!1,Le&&ce.addToRenderList(M,re),this.info.render.frame++,me===!0&&ot.beginShadows();const ke=w.state.shadowsArray;Fe.render(ke,re,_e),me===!0&&ot.endShadows(),this.info.autoReset===!0&&this.info.reset();const Pe=M.opaque,Me=M.transmissive;if(w.setupLights(),_e.isArrayCamera){const st=_e.cameras;if(Me.length>0)for(let ht=0,vt=st.length;ht<vt;ht++){const xt=st[ht];Yi(Pe,Me,re,xt)}Le&&ce.render(re);for(let ht=0,vt=st.length;ht<vt;ht++){const xt=st[ht];Di(M,re,xt,xt.viewport)}}else Me.length>0&&Yi(Pe,Me,re,_e),Le&&ce.render(re),Di(M,re,_e);k!==null&&N===0&&(se.updateMultisampleRenderTarget(k),se.updateRenderTargetMipmap(k)),re.isScene===!0&&re.onAfterRender(P,re,_e),ue.resetDefaultState(),F=-1,I=null,A.pop(),A.length>0?(w=A[A.length-1],me===!0&&ot.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,T.pop(),T.length>0?M=T[T.length-1]:M=null};function xi(re,_e,ke,Pe){if(re.visible===!1)return;if(re.layers.test(_e.layers)){if(re.isGroup)ke=re.renderOrder;else if(re.isLOD)re.autoUpdate===!0&&re.update(_e);else if(re.isLight)w.pushLight(re),re.castShadow&&w.pushShadow(re);else if(re.isSprite){if(!re.frustumCulled||Q.intersectsSprite(re)){Pe&&De.setFromMatrixPosition(re.matrixWorld).applyMatrix4(he);const ht=ye.update(re),vt=re.material;vt.visible&&M.push(re,ht,vt,ke,De.z,null)}}else if((re.isMesh||re.isLine||re.isPoints)&&(!re.frustumCulled||Q.intersectsObject(re))){const ht=ye.update(re),vt=re.material;if(Pe&&(re.boundingSphere!==void 0?(re.boundingSphere===null&&re.computeBoundingSphere(),De.copy(re.boundingSphere.center)):(ht.boundingSphere===null&&ht.computeBoundingSphere(),De.copy(ht.boundingSphere.center)),De.applyMatrix4(re.matrixWorld).applyMatrix4(he)),Array.isArray(vt)){const xt=ht.groups;for(let kt=0,wt=xt.length;kt<wt;kt++){const mt=xt[kt],qt=vt[mt.materialIndex];qt&&qt.visible&&M.push(re,ht,qt,ke,De.z,mt)}}else vt.visible&&M.push(re,ht,vt,ke,De.z,null)}}const st=re.children;for(let ht=0,vt=st.length;ht<vt;ht++)xi(st[ht],_e,ke,Pe)}function Di(re,_e,ke,Pe){const{opaque:Me,transmissive:st,transparent:ht}=re;w.setupLightsView(ke),me===!0&&ot.setGlobalState(P.clippingPlanes,ke),Pe&&le.viewport(W.copy(Pe)),Me.length>0&&jr(Me,_e,ke),st.length>0&&jr(st,_e,ke),ht.length>0&&jr(ht,_e,ke),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function Yi(re,_e,ke,Pe){if((ke.isScene===!0?ke.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Pe.id]===void 0&&(w.state.transmissionRenderTarget[Pe.id]=new kf(1,1,{generateMipmaps:!0,type:X.has("EXT_color_buffer_half_float")||X.has("EXT_color_buffer_float")?Nm:rl,minFilter:tf,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:En.workingColorSpace}));const st=w.state.transmissionRenderTarget[Pe.id],ht=Pe.viewport||W;st.setSize(ht.z*P.transmissionResolutionScale,ht.w*P.transmissionResolutionScale);const vt=P.getRenderTarget(),xt=P.getActiveCubeFace(),kt=P.getActiveMipmapLevel();P.setRenderTarget(st),P.getClearColor(G),V=P.getClearAlpha(),V<1&&P.setClearColor(16777215,.5),P.clear(),Le&&ce.render(ke);const wt=P.toneMapping;P.toneMapping=zu;const mt=Pe.viewport;if(Pe.viewport!==void 0&&(Pe.viewport=void 0),w.setupLightsView(Pe),me===!0&&ot.setGlobalState(P.clippingPlanes,Pe),jr(re,ke,Pe),se.updateMultisampleRenderTarget(st),se.updateRenderTargetMipmap(st),X.has("WEBGL_multisampled_render_to_texture")===!1){let qt=!1;for(let It=0,nn=_e.length;It<nn;It++){const dn=_e[It],{object:gn,geometry:Lt,material:Yt,group:Qt}=dn;if(Yt.side===Go&&gn.layers.test(Pe.layers)){const yr=Yt.side;Yt.side=Bs,Yt.needsUpdate=!0,pr(gn,ke,Pe,Lt,Yt,Qt),Yt.side=yr,Yt.needsUpdate=!0,qt=!0}}qt===!0&&(se.updateMultisampleRenderTarget(st),se.updateRenderTargetMipmap(st))}P.setRenderTarget(vt,xt,kt),P.setClearColor(G,V),mt!==void 0&&(Pe.viewport=mt),P.toneMapping=wt}function jr(re,_e,ke){const Pe=_e.isScene===!0?_e.overrideMaterial:null;for(let Me=0,st=re.length;Me<st;Me++){const ht=re[Me],{object:vt,geometry:xt,group:kt}=ht;let wt=ht.material;wt.allowOverride===!0&&Pe!==null&&(wt=Pe),vt.layers.test(ke.layers)&&pr(vt,_e,ke,xt,wt,kt)}}function pr(re,_e,ke,Pe,Me,st){re.onBeforeRender(P,_e,ke,Pe,Me,st),re.modelViewMatrix.multiplyMatrices(ke.matrixWorldInverse,re.matrixWorld),re.normalMatrix.getNormalMatrix(re.modelViewMatrix),Me.onBeforeRender(P,_e,ke,Pe,re,st),Me.transparent===!0&&Me.side===Go&&Me.forceSinglePass===!1?(Me.side=Bs,Me.needsUpdate=!0,P.renderBufferDirect(ke,_e,Pe,Me,re,st),Me.side=Zu,Me.needsUpdate=!0,P.renderBufferDirect(ke,_e,Pe,Me,re,st),Me.side=Go):P.renderBufferDirect(ke,_e,Pe,Me,re,st),re.onAfterRender(P,_e,ke,Pe,Me,st)}function Cr(re,_e,ke){_e.isScene!==!0&&(_e=de);const Pe=Ae.get(re),Me=w.state.lights,st=w.state.shadowsArray,ht=Me.state.version,vt=xe.getParameters(re,Me.state,st,_e,ke),xt=xe.getProgramCacheKey(vt);let kt=Pe.programs;Pe.environment=re.isMeshStandardMaterial?_e.environment:null,Pe.fog=_e.fog,Pe.envMap=(re.isMeshStandardMaterial?L:U).get(re.envMap||Pe.environment),Pe.envMapRotation=Pe.environment!==null&&re.envMap===null?_e.environmentRotation:re.envMapRotation,kt===void 0&&(re.addEventListener("dispose",ft),kt=new Map,Pe.programs=kt);let wt=kt.get(xt);if(wt!==void 0){if(Pe.currentProgram===wt&&Pe.lightsStateVersion===ht)return Oc(re,vt),wt}else vt.uniforms=xe.getUniforms(re),re.onBeforeCompile(vt,P),wt=xe.acquireProgram(vt,xt),kt.set(xt,wt),Pe.uniforms=vt.uniforms;const mt=Pe.uniforms;return(!re.isShaderMaterial&&!re.isRawShaderMaterial||re.clipping===!0)&&(mt.clippingPlanes=ot.uniform),Oc(re,vt),Pe.needsLights=et(re),Pe.lightsStateVersion=ht,Pe.needsLights&&(mt.ambientLightColor.value=Me.state.ambient,mt.lightProbe.value=Me.state.probe,mt.directionalLights.value=Me.state.directional,mt.directionalLightShadows.value=Me.state.directionalShadow,mt.spotLights.value=Me.state.spot,mt.spotLightShadows.value=Me.state.spotShadow,mt.rectAreaLights.value=Me.state.rectArea,mt.ltc_1.value=Me.state.rectAreaLTC1,mt.ltc_2.value=Me.state.rectAreaLTC2,mt.pointLights.value=Me.state.point,mt.pointLightShadows.value=Me.state.pointShadow,mt.hemisphereLights.value=Me.state.hemi,mt.directionalShadowMap.value=Me.state.directionalShadowMap,mt.directionalShadowMatrix.value=Me.state.directionalShadowMatrix,mt.spotShadowMap.value=Me.state.spotShadowMap,mt.spotLightMatrix.value=Me.state.spotLightMatrix,mt.spotLightMap.value=Me.state.spotLightMap,mt.pointShadowMap.value=Me.state.pointShadowMap,mt.pointShadowMatrix.value=Me.state.pointShadowMatrix),Pe.currentProgram=wt,Pe.uniformsList=null,wt}function to(re){if(re.uniformsList===null){const _e=re.currentProgram.getUniforms();re.uniformsList=k_.seqWithValue(_e.seq,re.uniforms)}return re.uniformsList}function Oc(re,_e){const ke=Ae.get(re);ke.outputColorSpace=_e.outputColorSpace,ke.batching=_e.batching,ke.batchingColor=_e.batchingColor,ke.instancing=_e.instancing,ke.instancingColor=_e.instancingColor,ke.instancingMorph=_e.instancingMorph,ke.skinning=_e.skinning,ke.morphTargets=_e.morphTargets,ke.morphNormals=_e.morphNormals,ke.morphColors=_e.morphColors,ke.morphTargetsCount=_e.morphTargetsCount,ke.numClippingPlanes=_e.numClippingPlanes,ke.numIntersection=_e.numClipIntersection,ke.vertexAlphas=_e.vertexAlphas,ke.vertexTangents=_e.vertexTangents,ke.toneMapping=_e.toneMapping}function pe(re,_e,ke,Pe,Me){_e.isScene!==!0&&(_e=de),se.resetTextureUnits();const st=_e.fog,ht=Pe.isMeshStandardMaterial?_e.environment:null,vt=k===null?P.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:tm,xt=(Pe.isMeshStandardMaterial?L:U).get(Pe.envMap||ht),kt=Pe.vertexColors===!0&&!!ke.attributes.color&&ke.attributes.color.itemSize===4,wt=!!ke.attributes.tangent&&(!!Pe.normalMap||Pe.anisotropy>0),mt=!!ke.morphAttributes.position,qt=!!ke.morphAttributes.normal,It=!!ke.morphAttributes.color;let nn=zu;Pe.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(nn=P.toneMapping);const dn=ke.morphAttributes.position||ke.morphAttributes.normal||ke.morphAttributes.color,gn=dn!==void 0?dn.length:0,Lt=Ae.get(Pe),Yt=w.state.lights;if(me===!0&&(Ee===!0||re!==I)){const bi=re===I&&Pe.id===F;ot.setState(Pe,re,bi)}let Qt=!1;Pe.version===Lt.__version?(Lt.needsLights&&Lt.lightsStateVersion!==Yt.state.version||Lt.outputColorSpace!==vt||Me.isBatchedMesh&&Lt.batching===!1||!Me.isBatchedMesh&&Lt.batching===!0||Me.isBatchedMesh&&Lt.batchingColor===!0&&Me.colorTexture===null||Me.isBatchedMesh&&Lt.batchingColor===!1&&Me.colorTexture!==null||Me.isInstancedMesh&&Lt.instancing===!1||!Me.isInstancedMesh&&Lt.instancing===!0||Me.isSkinnedMesh&&Lt.skinning===!1||!Me.isSkinnedMesh&&Lt.skinning===!0||Me.isInstancedMesh&&Lt.instancingColor===!0&&Me.instanceColor===null||Me.isInstancedMesh&&Lt.instancingColor===!1&&Me.instanceColor!==null||Me.isInstancedMesh&&Lt.instancingMorph===!0&&Me.morphTexture===null||Me.isInstancedMesh&&Lt.instancingMorph===!1&&Me.morphTexture!==null||Lt.envMap!==xt||Pe.fog===!0&&Lt.fog!==st||Lt.numClippingPlanes!==void 0&&(Lt.numClippingPlanes!==ot.numPlanes||Lt.numIntersection!==ot.numIntersection)||Lt.vertexAlphas!==kt||Lt.vertexTangents!==wt||Lt.morphTargets!==mt||Lt.morphNormals!==qt||Lt.morphColors!==It||Lt.toneMapping!==nn||Lt.morphTargetsCount!==gn)&&(Qt=!0):(Qt=!0,Lt.__version=Pe.version);let yr=Lt.currentProgram;Qt===!0&&(yr=Cr(Pe,_e,Me));let Nr=!1,Nn=!1,no=!1;const kn=yr.getUniforms(),vi=Lt.uniforms;if(le.useProgram(yr.program)&&(Nr=!0,Nn=!0,no=!0),Pe.id!==F&&(F=Pe.id,Nn=!0),Nr||I!==re){le.buffers.depth.getReversed()&&re.reversedDepth!==!0&&(re._reversedDepth=!0,re.updateProjectionMatrix()),kn.setValue(z,"projectionMatrix",re.projectionMatrix),kn.setValue(z,"viewMatrix",re.matrixWorldInverse);const Oi=kn.map.cameraPosition;Oi!==void 0&&Oi.setValue(z,we.setFromMatrixPosition(re.matrixWorld)),J.logarithmicDepthBuffer&&kn.setValue(z,"logDepthBufFC",2/(Math.log(re.far+1)/Math.LN2)),(Pe.isMeshPhongMaterial||Pe.isMeshToonMaterial||Pe.isMeshLambertMaterial||Pe.isMeshBasicMaterial||Pe.isMeshStandardMaterial||Pe.isShaderMaterial)&&kn.setValue(z,"isOrthographic",re.isOrthographicCamera===!0),I!==re&&(I=re,Nn=!0,no=!0)}if(Me.isSkinnedMesh){kn.setOptional(z,Me,"bindMatrix"),kn.setOptional(z,Me,"bindMatrixInverse");const bi=Me.skeleton;bi&&(bi.boneTexture===null&&bi.computeBoneTexture(),kn.setValue(z,"boneTexture",bi.boneTexture,se))}Me.isBatchedMesh&&(kn.setOptional(z,Me,"batchingTexture"),kn.setValue(z,"batchingTexture",Me._matricesTexture,se),kn.setOptional(z,Me,"batchingIdTexture"),kn.setValue(z,"batchingIdTexture",Me._indirectTexture,se),kn.setOptional(z,Me,"batchingColorTexture"),Me._colorsTexture!==null&&kn.setValue(z,"batchingColorTexture",Me._colorsTexture,se));const ei=ke.morphAttributes;if((ei.position!==void 0||ei.normal!==void 0||ei.color!==void 0)&&Qe.update(Me,ke,yr),(Nn||Lt.receiveShadow!==Me.receiveShadow)&&(Lt.receiveShadow=Me.receiveShadow,kn.setValue(z,"receiveShadow",Me.receiveShadow)),Pe.isMeshGouraudMaterial&&Pe.envMap!==null&&(vi.envMap.value=xt,vi.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Pe.isMeshStandardMaterial&&Pe.envMap===null&&_e.environment!==null&&(vi.envMapIntensity.value=_e.environmentIntensity),vi.dfgLUT!==void 0&&(vi.dfgLUT.value=lge()),Nn&&(kn.setValue(z,"toneMappingExposure",P.toneMappingExposure),Lt.needsLights&&ze(vi,no),st&&Pe.fog===!0&&tt.refreshFogUniforms(vi,st),tt.refreshMaterialUniforms(vi,Pe,ee,K,w.state.transmissionRenderTarget[re.id]),k_.upload(z,to(Lt),vi,se)),Pe.isShaderMaterial&&Pe.uniformsNeedUpdate===!0&&(k_.upload(z,to(Lt),vi,se),Pe.uniformsNeedUpdate=!1),Pe.isSpriteMaterial&&kn.setValue(z,"center",Me.center),kn.setValue(z,"modelViewMatrix",Me.modelViewMatrix),kn.setValue(z,"normalMatrix",Me.normalMatrix),kn.setValue(z,"modelMatrix",Me.matrixWorld),Pe.isShaderMaterial||Pe.isRawShaderMaterial){const bi=Pe.uniformsGroups;for(let Oi=0,ko=bi.length;Oi<ko;Oi++){const hl=bi[Oi];Je.update(hl,yr),Je.bind(hl,yr)}}return yr}function ze(re,_e){re.ambientLightColor.needsUpdate=_e,re.lightProbe.needsUpdate=_e,re.directionalLights.needsUpdate=_e,re.directionalLightShadows.needsUpdate=_e,re.pointLights.needsUpdate=_e,re.pointLightShadows.needsUpdate=_e,re.spotLights.needsUpdate=_e,re.spotLightShadows.needsUpdate=_e,re.rectAreaLights.needsUpdate=_e,re.hemisphereLights.needsUpdate=_e}function et(re){return re.isMeshLambertMaterial||re.isMeshToonMaterial||re.isMeshPhongMaterial||re.isMeshStandardMaterial||re.isShadowMaterial||re.isShaderMaterial&&re.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(re,_e,ke){const Pe=Ae.get(re);Pe.__autoAllocateDepthBuffer=re.resolveDepthBuffer===!1,Pe.__autoAllocateDepthBuffer===!1&&(Pe.__useRenderToTexture=!1),Ae.get(re.texture).__webglTexture=_e,Ae.get(re.depthTexture).__webglTexture=Pe.__autoAllocateDepthBuffer?void 0:ke,Pe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(re,_e){const ke=Ae.get(re);ke.__webglFramebuffer=_e,ke.__useDefaultFramebuffer=_e===void 0};const nt=z.createFramebuffer();this.setRenderTarget=function(re,_e=0,ke=0){k=re,j=_e,N=ke;let Pe=!0,Me=null,st=!1,ht=!1;if(re){const xt=Ae.get(re);if(xt.__useDefaultFramebuffer!==void 0)le.bindFramebuffer(z.FRAMEBUFFER,null),Pe=!1;else if(xt.__webglFramebuffer===void 0)se.setupRenderTarget(re);else if(xt.__hasExternalTextures)se.rebindTextures(re,Ae.get(re.texture).__webglTexture,Ae.get(re.depthTexture).__webglTexture);else if(re.depthBuffer){const mt=re.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Ae.has(mt)&&(re.width!==mt.image.width||re.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");se.setupDepthRenderbuffer(re)}}const kt=re.texture;(kt.isData3DTexture||kt.isDataArrayTexture||kt.isCompressedArrayTexture)&&(ht=!0);const wt=Ae.get(re).__webglFramebuffer;re.isWebGLCubeRenderTarget?(Array.isArray(wt[_e])?Me=wt[_e][ke]:Me=wt[_e],st=!0):re.samples>0&&se.useMultisampledRTT(re)===!1?Me=Ae.get(re).__webglMultisampledFramebuffer:Array.isArray(wt)?Me=wt[ke]:Me=wt,W.copy(re.viewport),D.copy(re.scissor),$=re.scissorTest}else W.copy(te).multiplyScalar(ee).floor(),D.copy(ae).multiplyScalar(ee).floor(),$=fe;if(ke!==0&&(Me=nt),le.bindFramebuffer(z.FRAMEBUFFER,Me)&&Pe&&le.drawBuffers(re,Me),le.viewport(W),le.scissor(D),le.setScissorTest($),st){const xt=Ae.get(re.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+_e,xt.__webglTexture,ke)}else if(ht){const xt=_e;for(let kt=0;kt<re.textures.length;kt++){const wt=Ae.get(re.textures[kt]);z.framebufferTextureLayer(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0+kt,wt.__webglTexture,ke,xt)}}else if(re!==null&&ke!==0){const xt=Ae.get(re.texture);z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,xt.__webglTexture,ke)}F=-1},this.readRenderTargetPixels=function(re,_e,ke,Pe,Me,st,ht,vt=0){if(!(re&&re.isWebGLRenderTarget)){Or("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ae.get(re).__webglFramebuffer;if(re.isWebGLCubeRenderTarget&&ht!==void 0&&(xt=xt[ht]),xt){le.bindFramebuffer(z.FRAMEBUFFER,xt);try{const kt=re.textures[vt],wt=kt.format,mt=kt.type;if(!J.textureFormatReadable(wt)){Or("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!J.textureTypeReadable(mt)){Or("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}_e>=0&&_e<=re.width-Pe&&ke>=0&&ke<=re.height-Me&&(re.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+vt),z.readPixels(_e,ke,Pe,Me,ct.convert(wt),ct.convert(mt),st))}finally{const kt=k!==null?Ae.get(k).__webglFramebuffer:null;le.bindFramebuffer(z.FRAMEBUFFER,kt)}}},this.readRenderTargetPixelsAsync=async function(re,_e,ke,Pe,Me,st,ht,vt=0){if(!(re&&re.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ae.get(re).__webglFramebuffer;if(re.isWebGLCubeRenderTarget&&ht!==void 0&&(xt=xt[ht]),xt)if(_e>=0&&_e<=re.width-Pe&&ke>=0&&ke<=re.height-Me){le.bindFramebuffer(z.FRAMEBUFFER,xt);const kt=re.textures[vt],wt=kt.format,mt=kt.type;if(!J.textureFormatReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!J.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qt=z.createBuffer();z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.bufferData(z.PIXEL_PACK_BUFFER,st.byteLength,z.STREAM_READ),re.textures.length>1&&z.readBuffer(z.COLOR_ATTACHMENT0+vt),z.readPixels(_e,ke,Pe,Me,ct.convert(wt),ct.convert(mt),0);const It=k!==null?Ae.get(k).__webglFramebuffer:null;le.bindFramebuffer(z.FRAMEBUFFER,It);const nn=z.fenceSync(z.SYNC_GPU_COMMANDS_COMPLETE,0);return z.flush(),await Oue(z,nn,4),z.bindBuffer(z.PIXEL_PACK_BUFFER,qt),z.getBufferSubData(z.PIXEL_PACK_BUFFER,0,st),z.deleteBuffer(qt),z.deleteSync(nn),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(re,_e=null,ke=0){const Pe=Math.pow(2,-ke),Me=Math.floor(re.image.width*Pe),st=Math.floor(re.image.height*Pe),ht=_e!==null?_e.x:0,vt=_e!==null?_e.y:0;se.setTexture2D(re,0),z.copyTexSubImage2D(z.TEXTURE_2D,ke,0,0,ht,vt,Me,st),le.unbindTexture()};const Ze=z.createFramebuffer(),_t=z.createFramebuffer();this.copyTextureToTexture=function(re,_e,ke=null,Pe=null,Me=0,st=null){st===null&&(Me!==0?(s0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),st=Me,Me=0):st=0);let ht,vt,xt,kt,wt,mt,qt,It,nn;const dn=re.isCompressedTexture?re.mipmaps[st]:re.image;if(ke!==null)ht=ke.max.x-ke.min.x,vt=ke.max.y-ke.min.y,xt=ke.isBox3?ke.max.z-ke.min.z:1,kt=ke.min.x,wt=ke.min.y,mt=ke.isBox3?ke.min.z:0;else{const ei=Math.pow(2,-Me);ht=Math.floor(dn.width*ei),vt=Math.floor(dn.height*ei),re.isDataArrayTexture?xt=dn.depth:re.isData3DTexture?xt=Math.floor(dn.depth*ei):xt=1,kt=0,wt=0,mt=0}Pe!==null?(qt=Pe.x,It=Pe.y,nn=Pe.z):(qt=0,It=0,nn=0);const gn=ct.convert(_e.format),Lt=ct.convert(_e.type);let Yt;_e.isData3DTexture?(se.setTexture3D(_e,0),Yt=z.TEXTURE_3D):_e.isDataArrayTexture||_e.isCompressedArrayTexture?(se.setTexture2DArray(_e,0),Yt=z.TEXTURE_2D_ARRAY):(se.setTexture2D(_e,0),Yt=z.TEXTURE_2D),z.pixelStorei(z.UNPACK_FLIP_Y_WEBGL,_e.flipY),z.pixelStorei(z.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_e.premultiplyAlpha),z.pixelStorei(z.UNPACK_ALIGNMENT,_e.unpackAlignment);const Qt=z.getParameter(z.UNPACK_ROW_LENGTH),yr=z.getParameter(z.UNPACK_IMAGE_HEIGHT),Nr=z.getParameter(z.UNPACK_SKIP_PIXELS),Nn=z.getParameter(z.UNPACK_SKIP_ROWS),no=z.getParameter(z.UNPACK_SKIP_IMAGES);z.pixelStorei(z.UNPACK_ROW_LENGTH,dn.width),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,dn.height),z.pixelStorei(z.UNPACK_SKIP_PIXELS,kt),z.pixelStorei(z.UNPACK_SKIP_ROWS,wt),z.pixelStorei(z.UNPACK_SKIP_IMAGES,mt);const kn=re.isDataArrayTexture||re.isData3DTexture,vi=_e.isDataArrayTexture||_e.isData3DTexture;if(re.isDepthTexture){const ei=Ae.get(re),bi=Ae.get(_e),Oi=Ae.get(ei.__renderTarget),ko=Ae.get(bi.__renderTarget);le.bindFramebuffer(z.READ_FRAMEBUFFER,Oi.__webglFramebuffer),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,ko.__webglFramebuffer);for(let hl=0;hl<xt;hl++)kn&&(z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ae.get(re).__webglTexture,Me,mt+hl),z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,Ae.get(_e).__webglTexture,st,nn+hl)),z.blitFramebuffer(kt,wt,ht,vt,qt,It,ht,vt,z.DEPTH_BUFFER_BIT,z.NEAREST);le.bindFramebuffer(z.READ_FRAMEBUFFER,null),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else if(Me!==0||re.isRenderTargetTexture||Ae.has(re)){const ei=Ae.get(re),bi=Ae.get(_e);le.bindFramebuffer(z.READ_FRAMEBUFFER,Ze),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,_t);for(let Oi=0;Oi<xt;Oi++)kn?z.framebufferTextureLayer(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,ei.__webglTexture,Me,mt+Oi):z.framebufferTexture2D(z.READ_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,ei.__webglTexture,Me),vi?z.framebufferTextureLayer(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,bi.__webglTexture,st,nn+Oi):z.framebufferTexture2D(z.DRAW_FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_2D,bi.__webglTexture,st),Me!==0?z.blitFramebuffer(kt,wt,ht,vt,qt,It,ht,vt,z.COLOR_BUFFER_BIT,z.NEAREST):vi?z.copyTexSubImage3D(Yt,st,qt,It,nn+Oi,kt,wt,ht,vt):z.copyTexSubImage2D(Yt,st,qt,It,kt,wt,ht,vt);le.bindFramebuffer(z.READ_FRAMEBUFFER,null),le.bindFramebuffer(z.DRAW_FRAMEBUFFER,null)}else vi?re.isDataTexture||re.isData3DTexture?z.texSubImage3D(Yt,st,qt,It,nn,ht,vt,xt,gn,Lt,dn.data):_e.isCompressedArrayTexture?z.compressedTexSubImage3D(Yt,st,qt,It,nn,ht,vt,xt,gn,dn.data):z.texSubImage3D(Yt,st,qt,It,nn,ht,vt,xt,gn,Lt,dn):re.isDataTexture?z.texSubImage2D(z.TEXTURE_2D,st,qt,It,ht,vt,gn,Lt,dn.data):re.isCompressedTexture?z.compressedTexSubImage2D(z.TEXTURE_2D,st,qt,It,dn.width,dn.height,gn,dn.data):z.texSubImage2D(z.TEXTURE_2D,st,qt,It,ht,vt,gn,Lt,dn);z.pixelStorei(z.UNPACK_ROW_LENGTH,Qt),z.pixelStorei(z.UNPACK_IMAGE_HEIGHT,yr),z.pixelStorei(z.UNPACK_SKIP_PIXELS,Nr),z.pixelStorei(z.UNPACK_SKIP_ROWS,Nn),z.pixelStorei(z.UNPACK_SKIP_IMAGES,no),st===0&&_e.generateMipmaps&&z.generateMipmap(Yt),le.unbindTexture()},this.initRenderTarget=function(re){Ae.get(re).__webglFramebuffer===void 0&&se.setupRenderTarget(re)},this.initTexture=function(re){re.isCubeTexture?se.setTextureCube(re,0):re.isData3DTexture?se.setTexture3D(re,0):re.isDataArrayTexture||re.isCompressedArrayTexture?se.setTexture2DArray(re,0):se.setTexture2D(re,0),le.unbindTexture()},this.resetState=function(){j=0,N=0,k=null,le.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ko}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=En._getDrawingBufferColorSpace(e),n.unpackColorSpace=En._getUnpackColorSpace()}};const vz={type:"change"},vk={type:"start"},f7={type:"end"},uy=new hk,bz=new bu,uge=Math.cos(70*Iue.DEG2RAD),ni=new Xe,Ls=2*Math.PI,Vn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},MT=1e-6;class dge extends Sde{constructor(e,n=null){super(e,n),this.state=Vn.NONE,this.target=new Xe,this.cursor=new Xe,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Op.ROTATE,MIDDLE:Op.DOLLY,RIGHT:Op.PAN},this.touches={ONE:Ap.ROTATE,TWO:Ap.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Xe,this._lastQuaternion=new Pf,this._lastTargetPosition=new Xe,this._quat=new Pf().setFromUnitVectors(e.up,new Xe(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new qF,this._sphericalDelta=new qF,this._scale=1,this._panOffset=new Xe,this._rotateStart=new on,this._rotateEnd=new on,this._rotateDelta=new on,this._panStart=new on,this._panEnd=new on,this._panDelta=new on,this._dollyStart=new on,this._dollyEnd=new on,this._dollyDelta=new on,this._dollyDirection=new Xe,this._mouse=new on,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=hge.bind(this),this._onPointerDown=fge.bind(this),this._onPointerUp=pge.bind(this),this._onContextMenu=_ge.bind(this),this._onMouseWheel=xge.bind(this),this._onKeyDown=vge.bind(this),this._onTouchStart=bge.bind(this),this._onTouchMove=yge.bind(this),this._onMouseDown=mge.bind(this),this._onMouseMove=gge.bind(this),this._interceptControlDown=Sge.bind(this),this._interceptControlUp=wge.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(vz),this.update(),this.state=Vn.NONE}update(e=null){const n=this.object.position;ni.copy(n).sub(this.target),ni.applyQuaternion(this._quat),this._spherical.setFromVector3(ni),this.autoRotate&&this.state===Vn.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Ls:r>Math.PI&&(r-=Ls),i<-Math.PI?i+=Ls:i>Math.PI&&(i-=Ls),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(ni.setFromSpherical(this._spherical),ni.applyQuaternion(this._quatInverse),n.copy(this.target).add(ni),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=ni.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new Xe(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new Xe(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=ni.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(uy.origin.copy(this.object.position),uy.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(uy.direction))<uge?this.object.lookAt(this.target):(bz.setFromNormalAndCoplanarPoint(this.object.up,this.target),uy.intersectPlane(bz,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>MT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>MT||this._lastTargetPosition.distanceToSquared(this.target)>MT?(this.dispatchEvent(vz),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ls/60*this.autoRotateSpeed*e:Ls/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){ni.setFromMatrixColumn(n,0),ni.multiplyScalar(-e),this._panOffset.add(ni)}_panUp(e,n){this.screenSpacePanning===!0?ni.setFromMatrixColumn(n,1):(ni.setFromMatrixColumn(n,0),ni.crossVectors(this.object.up,ni)),ni.multiplyScalar(e),this._panOffset.add(ni)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ni.copy(i).sub(this.target);let s=ni.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*n*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,s=n-r.top,a=r.width,o=r.height;this._mouse.x=i/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ls*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ls*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(Ls*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(-Ls*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(Ls*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(-Ls*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ls*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ls*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new on,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function fge(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 hge(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function pge(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(f7),this.state=Vn.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function mge(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 Op.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Vn.DOLLY;break;case Op.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}break;case Op.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(vk)}function gge(t){switch(this.state){case Vn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Vn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Vn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function xge(t){this.enabled===!1||this.enableZoom===!1||this.state!==Vn.NONE||(t.preventDefault(),this.dispatchEvent(vk),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(f7))}function vge(t){this.enabled!==!1&&this._handleKeyDown(t)}function bge(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Ap.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Vn.TOUCH_ROTATE;break;case Ap.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Vn.TOUCH_PAN;break;default:this.state=Vn.NONE}break;case 2:switch(this.touches.TWO){case Ap.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Vn.TOUCH_DOLLY_PAN;break;case Ap.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Vn.TOUCH_DOLLY_ROTATE;break;default:this.state=Vn.NONE}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(vk)}function yge(t){switch(this._trackPointer(t),this.state){case Vn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Vn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Vn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Vn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Vn.NONE}}function _ge(t){this.enabled!==!1&&t.preventDefault()}function Sge(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function wge(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Mge(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),s={},a={},o=t[0].morphTargetsRelative,l=new fl;let c=0;for(let u=0;u<t.length;++u){const h=t[u];let g=0;if(n!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in h.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(h.attributes[m]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in h.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[m]===void 0&&(a[m]=[]),a[m].push(h.morphAttributes[m])}if(e){let m;if(n)m=h.index.count;else if(h.attributes.position!==void 0)m=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,u),c+=m}}if(n){let u=0;const h=[];for(let g=0;g<t.length;++g){const m=t[g].index;for(let b=0;b<m.count;++b)h.push(m.getX(b)+u);u+=t[g].attributes.position.count}l.setIndex(h)}for(const u in s){const h=yz(s[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,h)}for(const u in a){const h=a[u][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let g=0;g<h;++g){const m=[];for(let y=0;y<a[u].length;++y)m.push(a[u][y][g]);const b=yz(m);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(b)}}return l}function yz(t){let e,n,r,i=-1,s=0;for(let c=0;c<t.length;++c){const u=t[c];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=u.itemSize),n!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=u.normalized),r!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=u.gpuType),i!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=u.count*n}const a=new e(s),o=new Ga(a,n,r);let l=0;for(let c=0;c<t.length;++c){const u=t[c];if(u.isInterleavedBufferAttribute){const h=l/n;for(let g=0,m=u.count;g<m;g++)for(let b=0;b<n;b++){const y=u.getComponent(g,b);o.setComponent(g+h,b,y)}}else a.set(u.array,l);l+=u.count*n}return i!==void 0&&(o.gpuType=i),o}function dy(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 ET={exports:{}};var _z;function Ege(){return _z||(_z=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function a(c,u){if(!i[c]){if(!r[c]){var h=typeof dy=="function"&&dy;if(!u&&h)return h(c,!0);if(o)return o(c,!0);var g=new Error("Cannot find module '"+c+"'");throw g.code="MODULE_NOT_FOUND",g}var m=i[c]={exports:{}};r[c][0].call(m.exports,function(b){var y=r[c][1][b];return a(y||b)},m,m.exports,n,r,i,s)}return i[c].exports}for(var o=typeof dy=="function"&&dy,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(n,r,i){var s=n("./utils"),a=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,u,h,g,m,b,y,v=[],x=0,M=l.length,w=M,T=s.getTypeOf(l)!=="string";x<l.length;)w=M-x,h=T?(c=l[x++],u=x<M?l[x++]:0,x<M?l[x++]:0):(c=l.charCodeAt(x++),u=x<M?l.charCodeAt(x++):0,x<M?l.charCodeAt(x++):0),g=c>>2,m=(3&c)<<4|u>>4,b=1<w?(15&u)<<2|h>>6:64,y=2<w?63&h:64,v.push(o.charAt(g)+o.charAt(m)+o.charAt(b)+o.charAt(y));return v.join("")},i.decode=function(l){var c,u,h,g,m,b,y=0,v=0,x="data:";if(l.substr(0,x.length)===x)throw new Error("Invalid base64 input, it looks like a data url.");var M,w=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&w--,l.charAt(l.length-2)===o.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(M=a.uint8array?new Uint8Array(0|w):new Array(0|w);y<l.length;)c=o.indexOf(l.charAt(y++))<<2|(g=o.indexOf(l.charAt(y++)))>>4,u=(15&g)<<4|(m=o.indexOf(l.charAt(y++)))>>2,h=(3&m)<<6|(b=o.indexOf(l.charAt(y++))),M[v++]=c,m!==64&&(M[v++]=u),b!==64&&(M[v++]=h);return M}},{"./support":30,"./utils":32}],2:[function(n,r,i){var s=n("./external"),a=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(u,h,g,m,b){this.compressedSize=u,this.uncompressedSize=h,this.crc32=g,this.compression=m,this.compressedContent=b}c.prototype={getContentWorker:function(){var u=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return u.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,h,g){return u.pipe(new o).pipe(new l("uncompressedSize")).pipe(h.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},r.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var s=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var s=n("./utils"),a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l){return o!==void 0&&o.length?s.getTypeOf(o)!=="string"?(function(c,u,h,g){var m=a,b=g+h;c^=-1;for(var y=g;y<b;y++)c=c>>>8^m[255&(c^u[y])];return-1^c})(0|l,o,o.length,0):(function(c,u,h,g){var m=a,b=g+h;c^=-1;for(var y=g;y<b;y++)c=c>>>8^m[255&(c^u.charCodeAt(y))];return-1^c})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var s=null;s=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:s}},{lie:37}],7:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=n("pako"),o=n("./utils"),l=n("./stream/GenericWorker"),c=s?"uint8array":"array";function u(h,g){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(u,l),u.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,h.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(g){h.push({data:g,meta:h.meta})}},i.compressWorker=function(h){return new u("Deflate",h)},i.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,b){var y,v="";for(y=0;y<b;y++)v+=String.fromCharCode(255&m),m>>>=8;return v}function a(m,b,y,v,x,M){var w,T,A=m.file,P=m.compression,C=M!==c.utf8encode,j=o.transformTo("string",M(A.name)),N=o.transformTo("string",c.utf8encode(A.name)),k=A.comment,F=o.transformTo("string",M(k)),I=o.transformTo("string",c.utf8encode(k)),W=N.length!==A.name.length,D=I.length!==k.length,$="",G="",V="",Z=A.dir,K=A.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};b&&!y||(ee.crc32=m.crc32,ee.compressedSize=m.compressedSize,ee.uncompressedSize=m.uncompressedSize);var H=0;b&&(H|=8),C||!W&&!D||(H|=2048);var Y=0,te=0;Z&&(Y|=16),x==="UNIX"?(te=798,Y|=(function(fe,Q){var me=fe;return fe||(me=Q?16893:33204),(65535&me)<<16})(A.unixPermissions,Z)):(te=20,Y|=(function(fe){return 63&(fe||0)})(A.dosPermissions)),w=K.getUTCHours(),w<<=6,w|=K.getUTCMinutes(),w<<=5,w|=K.getUTCSeconds()/2,T=K.getUTCFullYear()-1980,T<<=4,T|=K.getUTCMonth()+1,T<<=5,T|=K.getUTCDate(),W&&(G=s(1,1)+s(u(j),4)+N,$+="up"+s(G.length,2)+G),D&&(V=s(1,1)+s(u(F),4)+I,$+="uc"+s(V.length,2)+V);var ae="";return ae+=`
- \0`,ae+=s(H,2),ae+=P.magic,ae+=s(w,2),ae+=s(T,2),ae+=s(ee.crc32,4),ae+=s(ee.compressedSize,4),ae+=s(ee.uncompressedSize,4),ae+=s(j.length,2),ae+=s($.length,2),{fileRecord:h.LOCAL_FILE_HEADER+ae+j+$,dirRecord:h.CENTRAL_FILE_HEADER+s(te,2)+ae+s(F.length,2)+"\0\0\0\0"+s(Y,4)+s(v,4)+j+$+F}}var o=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),h=n("../signature");function g(m,b,y,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=y,this.encodeFileName=v,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(g,l),g.prototype.push=function(m){var b=m.meta.percent||0,y=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,l.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(b+100*(y-v-1))/y:100}}))},g.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var b=this.streamFiles&&!m.file.dir;if(b){var y=a(m,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(m){this.accumulate=!1;var b=this.streamFiles&&!m.file.dir,y=a(m,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),b)this.push({data:(function(v){return h.DATA_DESCRIPTOR+s(v.crc32,4)+s(v.compressedSize,4)+s(v.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var m=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var y=this.bytesWritten-m,v=(function(x,M,w,T,A){var P=o.transformTo("string",A(T));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(x,2)+s(x,2)+s(M,4)+s(w,4)+s(P.length,2)+P})(this.dirRecords.length,y,m,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(m){this._sources.push(m);var b=this;return m.on("data",function(y){b.processChunk(y)}),m.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),m.on("error",function(y){b.error(y)}),this},g.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(m){var b=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var y=0;y<b.length;y++)try{b[y].error(m)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,b=0;b<m.length;b++)m[b].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var s=n("../compressions"),a=n("./ZipFileWorker");i.generateWorker=function(o,l,c){var u=new a(l.streamFiles,c,l.platform,l.encodeFileName),h=0;try{o.forEach(function(g,m){h++;var b=(function(M,w){var T=M||w,A=s[T];if(!A)throw new Error(T+" is not a valid compression method !");return A})(m.options.compression,l.compression),y=m.options.compressionOptions||l.compressionOptions||{},v=m.dir,x=m.date;m._compressWorker(b,y).withStreamInfo("file",{name:g,dir:v,date:x,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(u)}),u.entriesCount=h}catch(g){u.error(g)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(a,o){return new s().loadAsync(a,o)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),a=n("./external"),o=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),u=n("./nodejsUtils");function h(g){return new a.Promise(function(m,b){var y=g.decompressed.getContentWorker().pipe(new c);y.on("error",function(v){b(v)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var b=this;return m=s.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),u.isNode&&u.isStream(g)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(y){var v=new l(m);return v.load(y),v}).then(function(y){var v=[a.Promise.resolve(y)],x=y.files;if(m.checkCRC32)for(var M=0;M<x.length;M++)v.push(h(x[M]));return a.Promise.all(v)}).then(function(y){for(var v=y.shift(),x=v.files,M=0;M<x.length;M++){var w=x[M],T=w.fileNameStr,A=s.resolve(w.fileNameStr);b.file(A,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:m.createFolders}),w.dir||(b.file(A).unsafeOriginalName=T)}return v.zipComment.length&&(b.comment=v.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var s=n("../utils"),a=n("../stream/GenericWorker");function o(l,c){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(o,a),o.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var s=n("readable-stream").Readable;function a(o,l,c){s.call(this,l),this._helper=o;var u=this;o.on("data",function(h,g){u.push(h)||u._helper.pause(),c&&c(g)}).on("error",function(h){u.emit("error",h)}).on("end",function(){u.push(null)})}n("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(A,P,C){var j,N=o.getTypeOf(P),k=o.extend(C||{},u);k.date=k.date||new Date,k.compression!==null&&(k.compression=k.compression.toUpperCase()),typeof k.unixPermissions=="string"&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(A=x(A)),k.createFolders&&(j=v(A))&&M.call(this,j,!0);var F=N==="string"&&k.binary===!1&&k.base64===!1;C&&C.binary!==void 0||(k.binary=!F),(P instanceof h&&P.uncompressedSize===0||k.dir||!P||P.length===0)&&(k.base64=!1,k.binary=!0,P="",k.compression="STORE",N="string");var I=null;I=P instanceof h||P instanceof l?P:b.isNode&&b.isStream(P)?new y(A,P):o.prepareContent(A,P,k.binary,k.optimizedBinaryString,k.base64);var W=new g(A,I,k);this.files[A]=W}var a=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),h=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),b=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),v=function(A){A.slice(-1)==="/"&&(A=A.substring(0,A.length-1));var P=A.lastIndexOf("/");return 0<P?A.substring(0,P):""},x=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},M=function(A,P){return P=P!==void 0?P:u.createFolders,A=x(A),this.files[A]||s.call(this,A,null,{dir:!0,createFolders:P}),this.files[A]};function w(A){return Object.prototype.toString.call(A)==="[object RegExp]"}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var P,C,j;for(P in this.files)j=this.files[P],(C=P.slice(this.root.length,P.length))&&P.slice(0,this.root.length)===this.root&&A(C,j)},filter:function(A){var P=[];return this.forEach(function(C,j){A(C,j)&&P.push(j)}),P},file:function(A,P,C){if(arguments.length!==1)return A=this.root+A,s.call(this,A,P,C),this;if(w(A)){var j=A;return this.filter(function(k,F){return!F.dir&&j.test(k)})}var N=this.files[this.root+A];return N&&!N.dir?N:null},folder:function(A){if(!A)return this;if(w(A))return this.filter(function(N,k){return k.dir&&A.test(N)});var P=this.root+A,C=M.call(this,P),j=this.clone();return j.root=C.name,j},remove:function(A){A=this.root+A;var P=this.files[A];if(P||(A.slice(-1)!=="/"&&(A+="/"),P=this.files[A]),P&&!P.dir)delete this.files[A];else for(var C=this.filter(function(N,k){return k.name.slice(0,A.length)===A}),j=0;j<C.length;j++)delete this.files[C[j].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(A){var P,C={};try{if((C=o.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");o.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var j=C.comment||this.comment||"";P=m.generateWorker(this,C,j)}catch(N){(P=new l("error")).error(N)}return new c(P,C.type||"string",C.mimeType)},generateAsync:function(A,P){return this.generateInternalStream(A).accumulate(P)},generateNodeStream:function(A,P){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(P)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function a(o){s.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),u=o.charCodeAt(2),h=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===c&&this.data[g+2]===u&&this.data[g+3]===h)return g-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),u=o.charCodeAt(2),h=o.charCodeAt(3),g=this.readData(4);return l===g[0]&&c===g[1]&&u===g[2]&&h===g[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var s=n("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,c=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return s.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},r.exports=a},{"../utils":32}],19:[function(n,r,i){var s=n("./Uint8ArrayReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var s=n("./DataReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var s=n("./ArrayReader");function a(o){s.call(this,o)}n("../utils").inherits(a,s),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),a=n("../support"),o=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),u=n("./Uint8ArrayReader");r.exports=function(h){var g=s.getTypeOf(h);return s.checkSupport(g),g!=="string"||a.uint8array?g==="nodebuffer"?new c(h):a.uint8array?new u(s.transformTo("uint8array",h)):new o(s.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var s=n("./GenericWorker"),a=n("../utils");function o(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,s),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},r.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var s=n("./GenericWorker"),a=n("../crc32");function o(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,s),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=s.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},r.exports=s},{}],29:[function(n,r,i){var s=n("../utils"),a=n("./ConvertWorker"),o=n("./GenericWorker"),l=n("../base64"),c=n("../support"),u=n("../external"),h=null;if(c.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(b,y){return new u.Promise(function(v,x){var M=[],w=b._internalType,T=b._outputType,A=b._mimeType;b.on("data",function(P,C){M.push(P),y&&y(C)}).on("error",function(P){M=[],x(P)}).on("end",function(){try{var P=(function(C,j,N){switch(C){case"blob":return s.newBlob(s.transformTo("arraybuffer",j),N);case"base64":return l.encode(j);default:return s.transformTo(C,j)}})(T,(function(C,j){var N,k=0,F=null,I=0;for(N=0;N<j.length;N++)I+=j[N].length;switch(C){case"string":return j.join("");case"array":return Array.prototype.concat.apply([],j);case"uint8array":for(F=new Uint8Array(I),N=0;N<j.length;N++)F.set(j[N],k),k+=j[N].length;return F;case"nodebuffer":return Buffer.concat(j);default:throw new Error("concat : unsupported type '"+C+"'")}})(w,M),A);v(P)}catch(C){x(C)}M=[]}).resume()})}function m(b,y,v){var x=y;switch(y){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=y,this._mimeType=v,s.checkSupport(x),this._worker=b.pipe(new a(x)),b.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}m.prototype={accumulate:function(b){return g(this,b)},on:function(b,y){var v=this;return b==="data"?this._worker.on(b,function(x){y.call(v,x.data,x.meta)}):this._worker.on(b,function(){s.delay(y,arguments,v)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},b)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var s=n("./utils"),a=n("./support"),o=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function g(){l.call(this,"utf-8 encode")}i.utf8encode=function(m){return a.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(b){var y,v,x,M,w,T=b.length,A=0;for(M=0;M<T;M++)(64512&(v=b.charCodeAt(M)))==55296&&M+1<T&&(64512&(x=b.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),A+=v<128?1:v<2048?2:v<65536?3:4;for(y=a.uint8array?new Uint8Array(A):new Array(A),M=w=0;w<A;M++)(64512&(v=b.charCodeAt(M)))==55296&&M+1<T&&(64512&(x=b.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),v<128?y[w++]=v:(v<2048?y[w++]=192|v>>>6:(v<65536?y[w++]=224|v>>>12:(y[w++]=240|v>>>18,y[w++]=128|v>>>12&63),y[w++]=128|v>>>6&63),y[w++]=128|63&v);return y})(m)},i.utf8decode=function(m){return a.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(b){var y,v,x,M,w=b.length,T=new Array(2*w);for(y=v=0;y<w;)if((x=b[y++])<128)T[v++]=x;else if(4<(M=c[x]))T[v++]=65533,y+=M-1;else{for(x&=M===2?31:M===3?15:7;1<M&&y<w;)x=x<<6|63&b[y++],M--;1<M?T[v++]=65533:x<65536?T[v++]=x:(x-=65536,T[v++]=55296|x>>10&1023,T[v++]=56320|1023&x)}return T.length!==v&&(T.subarray?T=T.subarray(0,v):T.length=v),s.applyFromCharCode(T)})(m=s.transformTo(a.uint8array?"uint8array":"array",m))},s.inherits(h,l),h.prototype.processChunk=function(m){var b=s.transformTo(a.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var y=b;(b=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),b.set(y,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var v=(function(M,w){var T;for((w=w||M.length)>M.length&&(w=M.length),T=w-1;0<=T&&(192&M[T])==128;)T--;return T<0||T===0?w:T+c[M[T]]>w?T:w})(b),x=b;v!==b.length&&(a.uint8array?(x=b.subarray(0,v),this.leftOver=b.subarray(v,b.length)):(x=b.slice(0,v),this.leftOver=b.slice(v,b.length))),this.push({data:i.utf8decode(x),meta:m.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.inherits(g,l),g.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var s=n("./support"),a=n("./base64"),o=n("./nodejsUtils"),l=n("./external");function c(y){return y}function u(y,v){for(var x=0;x<y.length;++x)v[x]=255&y.charCodeAt(x);return v}n("setimmediate"),i.newBlob=function(y,v){i.checkSupport("blob");try{return new Blob([y],{type:v})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(y),x.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(y,v,x){var M=[],w=0,T=y.length;if(T<=x)return String.fromCharCode.apply(null,y);for(;w<T;)v==="array"||v==="nodebuffer"?M.push(String.fromCharCode.apply(null,y.slice(w,Math.min(w+x,T)))):M.push(String.fromCharCode.apply(null,y.subarray(w,Math.min(w+x,T)))),w+=x;return M.join("")},stringifyByChar:function(y){for(var v="",x=0;x<y.length;x++)v+=String.fromCharCode(y[x]);return v},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function g(y){var v=65536,x=i.getTypeOf(y),M=!0;if(x==="uint8array"?M=h.applyCanBeUsed.uint8array:x==="nodebuffer"&&(M=h.applyCanBeUsed.nodebuffer),M)for(;1<v;)try{return h.stringifyByChunk(y,x,v)}catch{v=Math.floor(v/2)}return h.stringifyByChar(y)}function m(y,v){for(var x=0;x<y.length;x++)v[x]=y[x];return v}i.applyFromCharCode=g;var b={};b.string={string:c,array:function(y){return u(y,new Array(y.length))},arraybuffer:function(y){return b.string.uint8array(y).buffer},uint8array:function(y){return u(y,new Uint8Array(y.length))},nodebuffer:function(y){return u(y,o.allocBuffer(y.length))}},b.array={string:g,array:c,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(y)}},b.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:c,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(new Uint8Array(y))}},b.uint8array={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:c,nodebuffer:function(y){return o.newBufferFrom(y)}},b.nodebuffer={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return b.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:c},i.transformTo=function(y,v){if(v=v||"",!y)return v;i.checkSupport(y);var x=i.getTypeOf(v);return b[x][y](v)},i.resolve=function(y){for(var v=y.split("/"),x=[],M=0;M<v.length;M++){var w=v[M];w==="."||w===""&&M!==0&&M!==v.length-1||(w===".."?x.pop():x.push(w))}return x.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":s.nodebuffer&&o.isBuffer(y)?"nodebuffer":s.uint8array&&y instanceof Uint8Array?"uint8array":s.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!s[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var v,x,M="";for(x=0;x<(y||"").length;x++)M+="\\x"+((v=y.charCodeAt(x))<16?"0":"")+v.toString(16).toUpperCase();return M},i.delay=function(y,v,x){setImmediate(function(){y.apply(x||null,v||[])})},i.inherits=function(y,v){function x(){}x.prototype=v.prototype,y.prototype=new x},i.extend=function(){var y,v,x={};for(y=0;y<arguments.length;y++)for(v in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],v)&&x[v]===void 0&&(x[v]=arguments[y][v]);return x},i.prepareContent=function(y,v,x,M,w){return l.Promise.resolve(v).then(function(T){return s.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new l.Promise(function(A,P){var C=new FileReader;C.onload=function(j){A(j.target.result)},C.onerror=function(j){P(j.target.error)},C.readAsArrayBuffer(T)}):T}).then(function(T){var A=i.getTypeOf(T);return A?(A==="arraybuffer"?T=i.transformTo("uint8array",T):A==="string"&&(w?T=a.decode(T):x&&M!==!0&&(T=(function(P){return u(P,s.uint8array?new Uint8Array(P.length):new Array(P.length))})(T))),T):l.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./signature"),l=n("./zipEntry"),c=n("./support");function u(h){this.files=[],this.loadOptions=h}u.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(g)+", expected "+a.pretty(h)+")")}},isSignature:function(h,g){var m=this.reader.index;this.reader.setIndex(h);var b=this.reader.readString(4)===g;return this.reader.setIndex(m),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),g=c.uint8array?"uint8array":"array",m=a.transformTo(g,h);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,g,m,b=this.zip64EndOfCentralSize-44;0<b;)h=this.reader.readInt(2),g=this.reader.readInt(4),m=this.reader.readData(g),this.zip64ExtensibleData[h]={id:h,length:g,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,g;for(h=0;h<this.files.length;h++)g=this.files[h],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(h=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(h);var g=h;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var b=g-m;if(0<b)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),u=n("./compressions"),h=n("./support");function g(m,b){this.options=m,this.loadOptions=b}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var b,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(v){for(var x in u)if(Object.prototype.hasOwnProperty.call(u,x)&&u[x].magic===v)return u[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,b,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var b=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(b),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var b,y,v,x=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<x;)b=m.readInt(2),y=m.readInt(2),v=m.readData(y),this.extraFields[b]={id:b,length:y,value:v};m.setIndex(x)},handleUTF8:function(){var m=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var y=a.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var x=a.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var b=s(m.value);return b.readInt(1)!==1||l(this.fileName)!==b.readInt(4)?null:c.utf8decode(b.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var b=s(m.value);return b.readInt(1)!==1||l(this.fileComment)!==b.readInt(4)?null:c.utf8decode(b.readData(m.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(b,y,v){this.name=b,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=y,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var a=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),u=n("./stream/GenericWorker");s.prototype={internalStream:function(b){var y=null,v="string";try{if(!b)throw new Error("No output type specified.");var x=(v=b.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),y=this._decompressWorker();var M=!this._dataBinary;M&&!x&&(y=y.pipe(new l.Utf8EncodeWorker)),!M&&x&&(y=y.pipe(new l.Utf8DecodeWorker))}catch(w){(y=new u("error")).error(w)}return new a(y,v,"")},async:function(b,y){return this.internalStream(b).accumulate(y)},nodeStream:function(b,y){return this.internalStream(b||"nodebuffer").toNodejsStream(y)},_compressWorker:function(b,y){if(this._data instanceof c&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(v,b,y)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new o(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<h.length;m++)s.prototype[h[m]]=g;r.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(s){var a,o,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,u=new l(b),h=s.document.createTextNode("");u.observe(h,{characterData:!0}),a=function(){h.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var y=s.document.createElement("script");y.onreadystatechange=function(){b(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},s.document.documentElement.appendChild(y)}:function(){setTimeout(b,0)};else{var g=new s.MessageChannel;g.port1.onmessage=b,a=function(){g.port2.postMessage(0)}}var m=[];function b(){var y,v;o=!0;for(var x=m.length;x;){for(v=m,m=[],y=-1;++y<x;)v[y]();x=m.length}o=!1}r.exports=function(y){m.push(y)!==1||o||a()}}).call(this,typeof Ub<"u"?Ub:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function a(){}var o={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function h(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,x!==a&&y(this,x)}function g(x,M,w){this.promise=x,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function m(x,M,w){s(function(){var T;try{T=M(w)}catch(A){return o.reject(x,A)}T===x?o.reject(x,new TypeError("Cannot resolve promise with itself")):o.resolve(x,T)})}function b(x){var M=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof M=="function")return function(){M.apply(x,arguments)}}function y(x,M){var w=!1;function T(C){w||(w=!0,o.reject(x,C))}function A(C){w||(w=!0,o.resolve(x,C))}var P=v(function(){M(A,T)});P.status==="error"&&T(P.value)}function v(x,M){var w={};try{w.value=x(M),w.status="success"}catch(T){w.status="error",w.value=T}return w}(r.exports=h).prototype.finally=function(x){if(typeof x!="function")return this;var M=this.constructor;return this.then(function(w){return M.resolve(x()).then(function(){return w})},function(w){return M.resolve(x()).then(function(){throw w})})},h.prototype.catch=function(x){return this.then(null,x)},h.prototype.then=function(x,M){if(typeof x!="function"&&this.state===c||typeof M!="function"&&this.state===l)return this;var w=new this.constructor(a);return this.state!==u?m(w,this.state===c?x:M,this.outcome):this.queue.push(new g(w,x,M)),w},g.prototype.callFulfilled=function(x){o.resolve(this.promise,x)},g.prototype.otherCallFulfilled=function(x){m(this.promise,this.onFulfilled,x)},g.prototype.callRejected=function(x){o.reject(this.promise,x)},g.prototype.otherCallRejected=function(x){m(this.promise,this.onRejected,x)},o.resolve=function(x,M){var w=v(b,M);if(w.status==="error")return o.reject(x,w.value);var T=w.value;if(T)y(x,T);else{x.state=c,x.outcome=M;for(var A=-1,P=x.queue.length;++A<P;)x.queue[A].callFulfilled(M)}return x},o.reject=function(x,M){x.state=l,x.outcome=M;for(var w=-1,T=x.queue.length;++w<T;)x.queue[w].callRejected(M);return x},h.resolve=function(x){return x instanceof this?x:o.resolve(new this(a),x)},h.reject=function(x){var M=new this(a);return o.reject(M,x)},h.all=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,T=!1;if(!w)return this.resolve([]);for(var A=new Array(w),P=0,C=-1,j=new this(a);++C<w;)N(x[C],C);return j;function N(k,F){M.resolve(k).then(function(I){A[F]=I,++P!==w||T||(T=!0,o.resolve(j,A))},function(I){T||(T=!0,o.reject(j,I))})}},h.race=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,T=!1;if(!w)return this.resolve([]);for(var A=-1,P=new this(a);++A<w;)C=x[A],M.resolve(C).then(function(j){T||(T=!0,o.resolve(P,j))},function(j){T||(T=!0,o.reject(P,j))});var C;return P}},{immediate:36}],38:[function(n,r,i){var s={};(0,n("./lib/utils/common").assign)(s,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var s=n("./zlib/deflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),u=Object.prototype.toString,h=0,g=-1,m=0,b=8;function y(x){if(!(this instanceof y))return new y(x);this.options=a.assign({level:g,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},x||{});var M=this.options;M.raw&&0<M.windowBits?M.windowBits=-M.windowBits:M.gzip&&0<M.windowBits&&M.windowBits<16&&(M.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var w=s.deflateInit2(this.strm,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(w!==h)throw new Error(l[w]);if(M.header&&s.deflateSetHeader(this.strm,M.header),M.dictionary){var T;if(T=typeof M.dictionary=="string"?o.string2buf(M.dictionary):u.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(w=s.deflateSetDictionary(this.strm,T))!==h)throw new Error(l[w]);this._dict_set=!0}}function v(x,M){var w=new y(M);if(w.push(x,!0),w.err)throw w.msg||l[w.err];return w.result}y.prototype.push=function(x,M){var w,T,A=this.strm,P=this.options.chunkSize;if(this.ended)return!1;T=M===~~M?M:M===!0?4:0,typeof x=="string"?A.input=o.string2buf(x):u.call(x)==="[object ArrayBuffer]"?A.input=new Uint8Array(x):A.input=x,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new a.Buf8(P),A.next_out=0,A.avail_out=P),(w=s.deflate(A,T))!==1&&w!==h)return this.onEnd(w),!(this.ended=!0);A.avail_out!==0&&(A.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(A.output,A.next_out))):this.onData(a.shrinkBuf(A.output,A.next_out)))}while((0<A.avail_in||A.avail_out===0)&&w!==1);return T===4?(w=s.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===h):T!==2||(this.onEnd(h),!(A.avail_out=0))},y.prototype.onData=function(x){this.chunks.push(x)},y.prototype.onEnd=function(x){x===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},i.Deflate=y,i.deflate=v,i.deflateRaw=function(x,M){return(M=M||{}).raw=!0,v(x,M)},i.gzip=function(x,M){return(M=M||{}).gzip=!0,v(x,M)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var s=n("./zlib/inflate"),a=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),u=n("./zlib/zstream"),h=n("./zlib/gzheader"),g=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(y);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},y||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||y&&y.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var x=s.inflateInit2(this.strm,v.windowBits);if(x!==l.Z_OK)throw new Error(c[x]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function b(y,v){var x=new m(v);if(x.push(y,!0),x.err)throw x.msg||c[x.err];return x.result}m.prototype.push=function(y,v){var x,M,w,T,A,P,C=this.strm,j=this.options.chunkSize,N=this.options.dictionary,k=!1;if(this.ended)return!1;M=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof y=="string"?C.input=o.binstring2buf(y):g.call(y)==="[object ArrayBuffer]"?C.input=new Uint8Array(y):C.input=y,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(j),C.next_out=0,C.avail_out=j),(x=s.inflate(C,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&N&&(P=typeof N=="string"?o.string2buf(N):g.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,x=s.inflateSetDictionary(this.strm,P)),x===l.Z_BUF_ERROR&&k===!0&&(x=l.Z_OK,k=!1),x!==l.Z_STREAM_END&&x!==l.Z_OK)return this.onEnd(x),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&x!==l.Z_STREAM_END&&(C.avail_in!==0||M!==l.Z_FINISH&&M!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=o.utf8border(C.output,C.next_out),T=C.next_out-w,A=o.buf2string(C.output,w),C.next_out=T,C.avail_out=j-T,T&&a.arraySet(C.output,C.output,w,T,0),this.onData(A)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(k=!0)}while((0<C.avail_in||C.avail_out===0)&&x!==l.Z_STREAM_END);return x===l.Z_STREAM_END&&(M=l.Z_FINISH),M===l.Z_FINISH?(x=s.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===l.Z_OK):M!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(C.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=m,i.inflate=b,i.inflateRaw=function(y,v){return(v=v||{}).raw=!0,b(y,v)},i.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var h in u)u.hasOwnProperty(h)&&(l[h]=u[h])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var a={arraySet:function(l,c,u,h,g){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+h),g);else for(var m=0;m<h;m++)l[g+m]=c[u+m]},flattenChunks:function(l){var c,u,h,g,m,b;for(c=h=0,u=l.length;c<u;c++)h+=l[c].length;for(b=new Uint8Array(h),c=g=0,u=l.length;c<u;c++)m=l[c],b.set(m,g),g+=m.length;return b}},o={arraySet:function(l,c,u,h,g){for(var m=0;m<h;m++)l[g+m]=c[u+m]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new s.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(h,g){if(g<65537&&(h.subarray&&o||!h.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(h,g));for(var m="",b=0;b<g;b++)m+=String.fromCharCode(h[b]);return m}l[254]=l[254]=1,i.string2buf=function(h){var g,m,b,y,v,x=h.length,M=0;for(y=0;y<x;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<x&&(64512&(b=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),M+=m<128?1:m<2048?2:m<65536?3:4;for(g=new s.Buf8(M),y=v=0;v<M;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<x&&(64512&(b=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(b-56320),y++),m<128?g[v++]=m:(m<2048?g[v++]=192|m>>>6:(m<65536?g[v++]=224|m>>>12:(g[v++]=240|m>>>18,g[v++]=128|m>>>12&63),g[v++]=128|m>>>6&63),g[v++]=128|63&m);return g},i.buf2binstring=function(h){return u(h,h.length)},i.binstring2buf=function(h){for(var g=new s.Buf8(h.length),m=0,b=g.length;m<b;m++)g[m]=h.charCodeAt(m);return g},i.buf2string=function(h,g){var m,b,y,v,x=g||h.length,M=new Array(2*x);for(m=b=0;m<x;)if((y=h[m++])<128)M[b++]=y;else if(4<(v=l[y]))M[b++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<x;)y=y<<6|63&h[m++],v--;1<v?M[b++]=65533:y<65536?M[b++]=y:(y-=65536,M[b++]=55296|y>>10&1023,M[b++]=56320|1023&y)}return u(M,b)},i.utf8border=function(h,g){var m;for((g=g||h.length)>h.length&&(g=h.length),m=g-1;0<=m&&(192&h[m])==128;)m--;return m<0||m===0?g:m+l[h[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,a,o,l){for(var c=65535&s|0,u=s>>>16&65535|0,h=0;o!==0;){for(o-=h=2e3<o?2e3:o;u=u+(c=c+a[l++]|0)|0,--h;);c%=65521,u%=65521}return c|u<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();r.exports=function(a,o,l,c){var u=s,h=c+l;a^=-1;for(var g=c;g<h;g++)a=a>>>8^u[255&(a^o[g])];return-1^a}},{}],46:[function(n,r,i){var s,a=n("../utils/common"),o=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),h=0,g=4,m=0,b=-2,y=-1,v=4,x=2,M=8,w=9,T=286,A=30,P=19,C=2*T+1,j=15,N=3,k=258,F=k+N+1,I=42,W=113,D=1,$=2,G=3,V=4;function Z(B,z){return B.msg=u[z],z}function K(B){return(B<<1)-(4<B?9:0)}function ee(B){for(var z=B.length;0<=--z;)B[z]=0}function H(B){var z=B.state,ie=z.pending;ie>B.avail_out&&(ie=B.avail_out),ie!==0&&(a.arraySet(B.output,z.pending_buf,z.pending_out,ie,B.next_out),B.next_out+=ie,z.pending_out+=ie,B.total_out+=ie,B.avail_out-=ie,z.pending-=ie,z.pending===0&&(z.pending_out=0))}function Y(B,z){o._tr_flush_block(B,0<=B.block_start?B.block_start:-1,B.strstart-B.block_start,z),B.block_start=B.strstart,H(B.strm)}function te(B,z){B.pending_buf[B.pending++]=z}function ae(B,z){B.pending_buf[B.pending++]=z>>>8&255,B.pending_buf[B.pending++]=255&z}function fe(B,z){var ie,X,J=B.max_chain_length,le=B.strstart,Re=B.prev_length,Ae=B.nice_match,se=B.strstart>B.w_size-F?B.strstart-(B.w_size-F):0,U=B.window,L=B.w_mask,ne=B.prev,ve=B.strstart+k,ye=U[le+Re-1],xe=U[le+Re];B.prev_length>=B.good_match&&(J>>=2),Ae>B.lookahead&&(Ae=B.lookahead);do if(U[(ie=z)+Re]===xe&&U[ie+Re-1]===ye&&U[ie]===U[le]&&U[++ie]===U[le+1]){le+=2,ie++;do;while(U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&U[++le]===U[++ie]&&le<ve);if(X=k-(ve-le),le=ve-k,Re<X){if(B.match_start=z,Ae<=(Re=X))break;ye=U[le+Re-1],xe=U[le+Re]}}while((z=ne[z&L])>se&&--J!=0);return Re<=B.lookahead?Re:B.lookahead}function Q(B){var z,ie,X,J,le,Re,Ae,se,U,L,ne=B.w_size;do{if(J=B.window_size-B.lookahead-B.strstart,B.strstart>=ne+(ne-F)){for(a.arraySet(B.window,B.window,ne,ne,0),B.match_start-=ne,B.strstart-=ne,B.block_start-=ne,z=ie=B.hash_size;X=B.head[--z],B.head[z]=ne<=X?X-ne:0,--ie;);for(z=ie=ne;X=B.prev[--z],B.prev[z]=ne<=X?X-ne:0,--ie;);J+=ne}if(B.strm.avail_in===0)break;if(Re=B.strm,Ae=B.window,se=B.strstart+B.lookahead,U=J,L=void 0,L=Re.avail_in,U<L&&(L=U),ie=L===0?0:(Re.avail_in-=L,a.arraySet(Ae,Re.input,Re.next_in,L,se),Re.state.wrap===1?Re.adler=l(Re.adler,Ae,L,se):Re.state.wrap===2&&(Re.adler=c(Re.adler,Ae,L,se)),Re.next_in+=L,Re.total_in+=L,L),B.lookahead+=ie,B.lookahead+B.insert>=N)for(le=B.strstart-B.insert,B.ins_h=B.window[le],B.ins_h=(B.ins_h<<B.hash_shift^B.window[le+1])&B.hash_mask;B.insert&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[le+N-1])&B.hash_mask,B.prev[le&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=le,le++,B.insert--,!(B.lookahead+B.insert<N)););}while(B.lookahead<F&&B.strm.avail_in!==0)}function me(B,z){for(var ie,X;;){if(B.lookahead<F){if(Q(B),B.lookahead<F&&z===h)return D;if(B.lookahead===0)break}if(ie=0,B.lookahead>=N&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),ie!==0&&B.strstart-ie<=B.w_size-F&&(B.match_length=fe(B,ie)),B.match_length>=N)if(X=o._tr_tally(B,B.strstart-B.match_start,B.match_length-N),B.lookahead-=B.match_length,B.match_length<=B.max_lazy_match&&B.lookahead>=N){for(B.match_length--;B.strstart++,B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart,--B.match_length!=0;);B.strstart++}else B.strstart+=B.match_length,B.match_length=0,B.ins_h=B.window[B.strstart],B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+1])&B.hash_mask;else X=o._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++;if(X&&(Y(B,!1),B.strm.avail_out===0))return D}return B.insert=B.strstart<N-1?B.strstart:N-1,z===g?(Y(B,!0),B.strm.avail_out===0?G:V):B.last_lit&&(Y(B,!1),B.strm.avail_out===0)?D:$}function Ee(B,z){for(var ie,X,J;;){if(B.lookahead<F){if(Q(B),B.lookahead<F&&z===h)return D;if(B.lookahead===0)break}if(ie=0,B.lookahead>=N&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),B.prev_length=B.match_length,B.prev_match=B.match_start,B.match_length=N-1,ie!==0&&B.prev_length<B.max_lazy_match&&B.strstart-ie<=B.w_size-F&&(B.match_length=fe(B,ie),B.match_length<=5&&(B.strategy===1||B.match_length===N&&4096<B.strstart-B.match_start)&&(B.match_length=N-1)),B.prev_length>=N&&B.match_length<=B.prev_length){for(J=B.strstart+B.lookahead-N,X=o._tr_tally(B,B.strstart-1-B.prev_match,B.prev_length-N),B.lookahead-=B.prev_length-1,B.prev_length-=2;++B.strstart<=J&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+N-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),--B.prev_length!=0;);if(B.match_available=0,B.match_length=N-1,B.strstart++,X&&(Y(B,!1),B.strm.avail_out===0))return D}else if(B.match_available){if((X=o._tr_tally(B,0,B.window[B.strstart-1]))&&Y(B,!1),B.strstart++,B.lookahead--,B.strm.avail_out===0)return D}else B.match_available=1,B.strstart++,B.lookahead--}return B.match_available&&(X=o._tr_tally(B,0,B.window[B.strstart-1]),B.match_available=0),B.insert=B.strstart<N-1?B.strstart:N-1,z===g?(Y(B,!0),B.strm.avail_out===0?G:V):B.last_lit&&(Y(B,!1),B.strm.avail_out===0)?D:$}function he(B,z,ie,X,J){this.good_length=B,this.max_lazy=z,this.nice_length=ie,this.max_chain=X,this.func=J}function we(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=M,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*C),this.dyn_dtree=new a.Buf16(2*(2*A+1)),this.bl_tree=new a.Buf16(2*(2*P+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(j+1),this.heap=new a.Buf16(2*T+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*T+1),ee(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function De(B){var z;return B&&B.state?(B.total_in=B.total_out=0,B.data_type=x,(z=B.state).pending=0,z.pending_out=0,z.wrap<0&&(z.wrap=-z.wrap),z.status=z.wrap?I:W,B.adler=z.wrap===2?0:1,z.last_flush=h,o._tr_init(z),m):Z(B,b)}function de(B){var z=De(B);return z===m&&(function(ie){ie.window_size=2*ie.w_size,ee(ie.head),ie.max_lazy_match=s[ie.level].max_lazy,ie.good_match=s[ie.level].good_length,ie.nice_match=s[ie.level].nice_length,ie.max_chain_length=s[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=N-1,ie.match_available=0,ie.ins_h=0})(B.state),z}function Le(B,z,ie,X,J,le){if(!B)return b;var Re=1;if(z===y&&(z=6),X<0?(Re=0,X=-X):15<X&&(Re=2,X-=16),J<1||w<J||ie!==M||X<8||15<X||z<0||9<z||le<0||v<le)return Z(B,b);X===8&&(X=9);var Ae=new we;return(B.state=Ae).strm=B,Ae.wrap=Re,Ae.gzhead=null,Ae.w_bits=X,Ae.w_size=1<<Ae.w_bits,Ae.w_mask=Ae.w_size-1,Ae.hash_bits=J+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 a.Buf8(2*Ae.w_size),Ae.head=new a.Buf16(Ae.hash_size),Ae.prev=new a.Buf16(Ae.w_size),Ae.lit_bufsize=1<<J+6,Ae.pending_buf_size=4*Ae.lit_bufsize,Ae.pending_buf=new a.Buf8(Ae.pending_buf_size),Ae.d_buf=1*Ae.lit_bufsize,Ae.l_buf=3*Ae.lit_bufsize,Ae.level=z,Ae.strategy=le,Ae.method=ie,de(B)}s=[new he(0,0,0,0,function(B,z){var ie=65535;for(ie>B.pending_buf_size-5&&(ie=B.pending_buf_size-5);;){if(B.lookahead<=1){if(Q(B),B.lookahead===0&&z===h)return D;if(B.lookahead===0)break}B.strstart+=B.lookahead,B.lookahead=0;var X=B.block_start+ie;if((B.strstart===0||B.strstart>=X)&&(B.lookahead=B.strstart-X,B.strstart=X,Y(B,!1),B.strm.avail_out===0)||B.strstart-B.block_start>=B.w_size-F&&(Y(B,!1),B.strm.avail_out===0))return D}return B.insert=0,z===g?(Y(B,!0),B.strm.avail_out===0?G:V):(B.strstart>B.block_start&&(Y(B,!1),B.strm.avail_out),D)}),new he(4,4,8,4,me),new he(4,5,16,8,me),new he(4,6,32,32,me),new he(4,4,16,16,Ee),new he(8,16,32,32,Ee),new he(8,16,128,128,Ee),new he(8,32,128,256,Ee),new he(32,128,258,1024,Ee),new he(32,258,258,4096,Ee)],i.deflateInit=function(B,z){return Le(B,z,M,15,8,0)},i.deflateInit2=Le,i.deflateReset=de,i.deflateResetKeep=De,i.deflateSetHeader=function(B,z){return B&&B.state?B.state.wrap!==2?b:(B.state.gzhead=z,m):b},i.deflate=function(B,z){var ie,X,J,le;if(!B||!B.state||5<z||z<0)return B?Z(B,b):b;if(X=B.state,!B.output||!B.input&&B.avail_in!==0||X.status===666&&z!==g)return Z(B,B.avail_out===0?-5:b);if(X.strm=B,ie=X.last_flush,X.last_flush=z,X.status===I)if(X.wrap===2)B.adler=0,te(X,31),te(X,139),te(X,8),X.gzhead?(te(X,(X.gzhead.text?1:0)+(X.gzhead.hcrc?2:0)+(X.gzhead.extra?4:0)+(X.gzhead.name?8:0)+(X.gzhead.comment?16:0)),te(X,255&X.gzhead.time),te(X,X.gzhead.time>>8&255),te(X,X.gzhead.time>>16&255),te(X,X.gzhead.time>>24&255),te(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),te(X,255&X.gzhead.os),X.gzhead.extra&&X.gzhead.extra.length&&(te(X,255&X.gzhead.extra.length),te(X,X.gzhead.extra.length>>8&255)),X.gzhead.hcrc&&(B.adler=c(B.adler,X.pending_buf,X.pending,0)),X.gzindex=0,X.status=69):(te(X,0),te(X,0),te(X,0),te(X,0),te(X,0),te(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),te(X,3),X.status=W);else{var Re=M+(X.w_bits-8<<4)<<8;Re|=(2<=X.strategy||X.level<2?0:X.level<6?1:X.level===6?2:3)<<6,X.strstart!==0&&(Re|=32),Re+=31-Re%31,X.status=W,ae(X,Re),X.strstart!==0&&(ae(X,B.adler>>>16),ae(X,65535&B.adler)),B.adler=1}if(X.status===69)if(X.gzhead.extra){for(J=X.pending;X.gzindex<(65535&X.gzhead.extra.length)&&(X.pending!==X.pending_buf_size||(X.gzhead.hcrc&&X.pending>J&&(B.adler=c(B.adler,X.pending_buf,X.pending-J,J)),H(B),J=X.pending,X.pending!==X.pending_buf_size));)te(X,255&X.gzhead.extra[X.gzindex]),X.gzindex++;X.gzhead.hcrc&&X.pending>J&&(B.adler=c(B.adler,X.pending_buf,X.pending-J,J)),X.gzindex===X.gzhead.extra.length&&(X.gzindex=0,X.status=73)}else X.status=73;if(X.status===73)if(X.gzhead.name){J=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>J&&(B.adler=c(B.adler,X.pending_buf,X.pending-J,J)),H(B),J=X.pending,X.pending===X.pending_buf_size)){le=1;break}le=X.gzindex<X.gzhead.name.length?255&X.gzhead.name.charCodeAt(X.gzindex++):0,te(X,le)}while(le!==0);X.gzhead.hcrc&&X.pending>J&&(B.adler=c(B.adler,X.pending_buf,X.pending-J,J)),le===0&&(X.gzindex=0,X.status=91)}else X.status=91;if(X.status===91)if(X.gzhead.comment){J=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>J&&(B.adler=c(B.adler,X.pending_buf,X.pending-J,J)),H(B),J=X.pending,X.pending===X.pending_buf_size)){le=1;break}le=X.gzindex<X.gzhead.comment.length?255&X.gzhead.comment.charCodeAt(X.gzindex++):0,te(X,le)}while(le!==0);X.gzhead.hcrc&&X.pending>J&&(B.adler=c(B.adler,X.pending_buf,X.pending-J,J)),le===0&&(X.status=103)}else X.status=103;if(X.status===103&&(X.gzhead.hcrc?(X.pending+2>X.pending_buf_size&&H(B),X.pending+2<=X.pending_buf_size&&(te(X,255&B.adler),te(X,B.adler>>8&255),B.adler=0,X.status=W)):X.status=W),X.pending!==0){if(H(B),B.avail_out===0)return X.last_flush=-1,m}else if(B.avail_in===0&&K(z)<=K(ie)&&z!==g)return Z(B,-5);if(X.status===666&&B.avail_in!==0)return Z(B,-5);if(B.avail_in!==0||X.lookahead!==0||z!==h&&X.status!==666){var Ae=X.strategy===2?(function(se,U){for(var L;;){if(se.lookahead===0&&(Q(se),se.lookahead===0)){if(U===h)return D;break}if(se.match_length=0,L=o._tr_tally(se,0,se.window[se.strstart]),se.lookahead--,se.strstart++,L&&(Y(se,!1),se.strm.avail_out===0))return D}return se.insert=0,U===g?(Y(se,!0),se.strm.avail_out===0?G:V):se.last_lit&&(Y(se,!1),se.strm.avail_out===0)?D:$})(X,z):X.strategy===3?(function(se,U){for(var L,ne,ve,ye,xe=se.window;;){if(se.lookahead<=k){if(Q(se),se.lookahead<=k&&U===h)return D;if(se.lookahead===0)break}if(se.match_length=0,se.lookahead>=N&&0<se.strstart&&(ne=xe[ve=se.strstart-1])===xe[++ve]&&ne===xe[++ve]&&ne===xe[++ve]){ye=se.strstart+k;do;while(ne===xe[++ve]&&ne===xe[++ve]&&ne===xe[++ve]&&ne===xe[++ve]&&ne===xe[++ve]&&ne===xe[++ve]&&ne===xe[++ve]&&ne===xe[++ve]&&ve<ye);se.match_length=k-(ye-ve),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&&(Y(se,!1),se.strm.avail_out===0))return D}return se.insert=0,U===g?(Y(se,!0),se.strm.avail_out===0?G:V):se.last_lit&&(Y(se,!1),se.strm.avail_out===0)?D:$})(X,z):s[X.level].func(X,z);if(Ae!==G&&Ae!==V||(X.status=666),Ae===D||Ae===G)return B.avail_out===0&&(X.last_flush=-1),m;if(Ae===$&&(z===1?o._tr_align(X):z!==5&&(o._tr_stored_block(X,0,0,!1),z===3&&(ee(X.head),X.lookahead===0&&(X.strstart=0,X.block_start=0,X.insert=0))),H(B),B.avail_out===0))return X.last_flush=-1,m}return z!==g?m:X.wrap<=0?1:(X.wrap===2?(te(X,255&B.adler),te(X,B.adler>>8&255),te(X,B.adler>>16&255),te(X,B.adler>>24&255),te(X,255&B.total_in),te(X,B.total_in>>8&255),te(X,B.total_in>>16&255),te(X,B.total_in>>24&255)):(ae(X,B.adler>>>16),ae(X,65535&B.adler)),H(B),0<X.wrap&&(X.wrap=-X.wrap),X.pending!==0?m:1)},i.deflateEnd=function(B){var z;return B&&B.state?(z=B.state.status)!==I&&z!==69&&z!==73&&z!==91&&z!==103&&z!==W&&z!==666?Z(B,b):(B.state=null,z===W?Z(B,-3):m):b},i.deflateSetDictionary=function(B,z){var ie,X,J,le,Re,Ae,se,U,L=z.length;if(!B||!B.state||(le=(ie=B.state).wrap)===2||le===1&&ie.status!==I||ie.lookahead)return b;for(le===1&&(B.adler=l(B.adler,z,L,0)),ie.wrap=0,L>=ie.w_size&&(le===0&&(ee(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),U=new a.Buf8(ie.w_size),a.arraySet(U,z,L-ie.w_size,ie.w_size,0),z=U,L=ie.w_size),Re=B.avail_in,Ae=B.next_in,se=B.input,B.avail_in=L,B.next_in=0,B.input=z,Q(ie);ie.lookahead>=N;){for(X=ie.strstart,J=ie.lookahead-(N-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[X+N-1])&ie.hash_mask,ie.prev[X&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=X,X++,--J;);ie.strstart=X,ie.lookahead=N-1,Q(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=N-1,ie.match_available=0,B.next_in=Ae,B.input=se,B.avail_in=Re,ie.wrap=le,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,a){var o,l,c,u,h,g,m,b,y,v,x,M,w,T,A,P,C,j,N,k,F,I,W,D,$;o=s.state,l=s.next_in,D=s.input,c=l+(s.avail_in-5),u=s.next_out,$=s.output,h=u-(a-s.avail_out),g=u+(s.avail_out-257),m=o.dmax,b=o.wsize,y=o.whave,v=o.wnext,x=o.window,M=o.hold,w=o.bits,T=o.lencode,A=o.distcode,P=(1<<o.lenbits)-1,C=(1<<o.distbits)-1;e:do{w<15&&(M+=D[l++]<<w,w+=8,M+=D[l++]<<w,w+=8),j=T[M&P];t:for(;;){if(M>>>=N=j>>>24,w-=N,(N=j>>>16&255)===0)$[u++]=65535&j;else{if(!(16&N)){if((64&N)==0){j=T[(65535&j)+(M&(1<<N)-1)];continue t}if(32&N){o.mode=12;break e}s.msg="invalid literal/length code",o.mode=30;break e}k=65535&j,(N&=15)&&(w<N&&(M+=D[l++]<<w,w+=8),k+=M&(1<<N)-1,M>>>=N,w-=N),w<15&&(M+=D[l++]<<w,w+=8,M+=D[l++]<<w,w+=8),j=A[M&C];n:for(;;){if(M>>>=N=j>>>24,w-=N,!(16&(N=j>>>16&255))){if((64&N)==0){j=A[(65535&j)+(M&(1<<N)-1)];continue n}s.msg="invalid distance code",o.mode=30;break e}if(F=65535&j,w<(N&=15)&&(M+=D[l++]<<w,(w+=8)<N&&(M+=D[l++]<<w,w+=8)),m<(F+=M&(1<<N)-1)){s.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=N,w-=N,(N=u-h)<F){if(y<(N=F-N)&&o.sane){s.msg="invalid distance too far back",o.mode=30;break e}if(W=x,(I=0)===v){if(I+=b-N,N<k){for(k-=N;$[u++]=x[I++],--N;);I=u-F,W=$}}else if(v<N){if(I+=b+v-N,(N-=v)<k){for(k-=N;$[u++]=x[I++],--N;);if(I=0,v<k){for(k-=N=v;$[u++]=x[I++],--N;);I=u-F,W=$}}}else if(I+=v-N,N<k){for(k-=N;$[u++]=x[I++],--N;);I=u-F,W=$}for(;2<k;)$[u++]=W[I++],$[u++]=W[I++],$[u++]=W[I++],k-=3;k&&($[u++]=W[I++],1<k&&($[u++]=W[I++]))}else{for(I=u-F;$[u++]=$[I++],$[u++]=$[I++],$[u++]=$[I++],2<(k-=3););k&&($[u++]=$[I++],1<k&&($[u++]=$[I++]))}break}}break}}while(l<c&&u<g);l-=k=w>>3,M&=(1<<(w-=k<<3))-1,s.next_in=l,s.next_out=u,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=u<g?g-u+257:257-(u-g),o.hold=M,o.bits=w}},{}],49:[function(n,r,i){var s=n("../utils/common"),a=n("./adler32"),o=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),u=1,h=2,g=0,m=-2,b=1,y=852,v=592;function x(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function M(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(I){var W;return I&&I.state?(W=I.state,I.total_in=I.total_out=W.total=0,I.msg="",W.wrap&&(I.adler=1&W.wrap),W.mode=b,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new s.Buf32(y),W.distcode=W.distdyn=new s.Buf32(v),W.sane=1,W.back=-1,g):m}function T(I){var W;return I&&I.state?((W=I.state).wsize=0,W.whave=0,W.wnext=0,w(I)):m}function A(I,W){var D,$;return I&&I.state?($=I.state,W<0?(D=0,W=-W):(D=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?m:($.window!==null&&$.wbits!==W&&($.window=null),$.wrap=D,$.wbits=W,T(I))):m}function P(I,W){var D,$;return I?($=new M,(I.state=$).window=null,(D=A(I,W))!==g&&(I.state=null),D):m}var C,j,N=!0;function k(I){if(N){var W;for(C=new s.Buf32(512),j=new s.Buf32(32),W=0;W<144;)I.lens[W++]=8;for(;W<256;)I.lens[W++]=9;for(;W<280;)I.lens[W++]=7;for(;W<288;)I.lens[W++]=8;for(c(u,I.lens,0,288,C,0,I.work,{bits:9}),W=0;W<32;)I.lens[W++]=5;c(h,I.lens,0,32,j,0,I.work,{bits:5}),N=!1}I.lencode=C,I.lenbits=9,I.distcode=j,I.distbits=5}function F(I,W,D,$){var G,V=I.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new s.Buf8(V.wsize)),$>=V.wsize?(s.arraySet(V.window,W,D-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):($<(G=V.wsize-V.wnext)&&(G=$),s.arraySet(V.window,W,D-$,G,V.wnext),($-=G)?(s.arraySet(V.window,W,D-$,$,0),V.wnext=$,V.whave=V.wsize):(V.wnext+=G,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=G))),0}i.inflateReset=T,i.inflateReset2=A,i.inflateResetKeep=w,i.inflateInit=function(I){return P(I,15)},i.inflateInit2=P,i.inflate=function(I,W){var D,$,G,V,Z,K,ee,H,Y,te,ae,fe,Q,me,Ee,he,we,De,de,Le,B,z,ie,X,J=0,le=new s.Buf8(4),Re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return m;(D=I.state).mode===12&&(D.mode=13),Z=I.next_out,G=I.output,ee=I.avail_out,V=I.next_in,$=I.input,K=I.avail_in,H=D.hold,Y=D.bits,te=K,ae=ee,z=g;e:for(;;)switch(D.mode){case b:if(D.wrap===0){D.mode=13;break}for(;Y<16;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(2&D.wrap&&H===35615){le[D.check=0]=255&H,le[1]=H>>>8&255,D.check=o(D.check,le,2,0),Y=H=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&H)<<8)+(H>>8))%31){I.msg="incorrect header check",D.mode=30;break}if((15&H)!=8){I.msg="unknown compression method",D.mode=30;break}if(Y-=4,B=8+(15&(H>>>=4)),D.wbits===0)D.wbits=B;else if(B>D.wbits){I.msg="invalid window size",D.mode=30;break}D.dmax=1<<B,I.adler=D.check=1,D.mode=512&H?10:12,Y=H=0;break;case 2:for(;Y<16;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(D.flags=H,(255&D.flags)!=8){I.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){I.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=H>>8&1),512&D.flags&&(le[0]=255&H,le[1]=H>>>8&255,D.check=o(D.check,le,2,0)),Y=H=0,D.mode=3;case 3:for(;Y<32;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}D.head&&(D.head.time=H),512&D.flags&&(le[0]=255&H,le[1]=H>>>8&255,le[2]=H>>>16&255,le[3]=H>>>24&255,D.check=o(D.check,le,4,0)),Y=H=0,D.mode=4;case 4:for(;Y<16;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}D.head&&(D.head.xflags=255&H,D.head.os=H>>8),512&D.flags&&(le[0]=255&H,le[1]=H>>>8&255,D.check=o(D.check,le,2,0)),Y=H=0,D.mode=5;case 5:if(1024&D.flags){for(;Y<16;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}D.length=H,D.head&&(D.head.extra_len=H),512&D.flags&&(le[0]=255&H,le[1]=H>>>8&255,D.check=o(D.check,le,2,0)),Y=H=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(K<(fe=D.length)&&(fe=K),fe&&(D.head&&(B=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),s.arraySet(D.head.extra,$,V,fe,B)),512&D.flags&&(D.check=o(D.check,$,fe,V)),K-=fe,V+=fe,D.length-=fe),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(K===0)break e;for(fe=0;B=$[V+fe++],D.head&&B&&D.length<65536&&(D.head.name+=String.fromCharCode(B)),B&&fe<K;);if(512&D.flags&&(D.check=o(D.check,$,fe,V)),K-=fe,V+=fe,B)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(K===0)break e;for(fe=0;B=$[V+fe++],D.head&&B&&D.length<65536&&(D.head.comment+=String.fromCharCode(B)),B&&fe<K;);if(512&D.flags&&(D.check=o(D.check,$,fe,V)),K-=fe,V+=fe,B)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;Y<16;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(H!==(65535&D.check)){I.msg="header crc mismatch",D.mode=30;break}Y=H=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),I.adler=D.check=0,D.mode=12;break;case 10:for(;Y<32;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}I.adler=D.check=x(H),Y=H=0,D.mode=11;case 11:if(D.havedict===0)return I.next_out=Z,I.avail_out=ee,I.next_in=V,I.avail_in=K,D.hold=H,D.bits=Y,2;I.adler=D.check=1,D.mode=12;case 12:if(W===5||W===6)break e;case 13:if(D.last){H>>>=7&Y,Y-=7&Y,D.mode=27;break}for(;Y<3;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}switch(D.last=1&H,Y-=1,3&(H>>>=1)){case 0:D.mode=14;break;case 1:if(k(D),D.mode=20,W!==6)break;H>>>=2,Y-=2;break e;case 2:D.mode=17;break;case 3:I.msg="invalid block type",D.mode=30}H>>>=2,Y-=2;break;case 14:for(H>>>=7&Y,Y-=7&Y;Y<32;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if((65535&H)!=(H>>>16^65535)){I.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&H,Y=H=0,D.mode=15,W===6)break e;case 15:D.mode=16;case 16:if(fe=D.length){if(K<fe&&(fe=K),ee<fe&&(fe=ee),fe===0)break e;s.arraySet(G,$,V,fe,Z),K-=fe,V+=fe,ee-=fe,Z+=fe,D.length-=fe;break}D.mode=12;break;case 17:for(;Y<14;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(D.nlen=257+(31&H),H>>>=5,Y-=5,D.ndist=1+(31&H),H>>>=5,Y-=5,D.ncode=4+(15&H),H>>>=4,Y-=4,286<D.nlen||30<D.ndist){I.msg="too many length or distance symbols",D.mode=30;break}D.have=0,D.mode=18;case 18:for(;D.have<D.ncode;){for(;Y<3;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}D.lens[Re[D.have++]]=7&H,H>>>=3,Y-=3}for(;D.have<19;)D.lens[Re[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,ie={bits:D.lenbits},z=c(0,D.lens,0,19,D.lencode,0,D.work,ie),D.lenbits=ie.bits,z){I.msg="invalid code lengths set",D.mode=30;break}D.have=0,D.mode=19;case 19:for(;D.have<D.nlen+D.ndist;){for(;he=(J=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,we=65535&J,!((Ee=J>>>24)<=Y);){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(we<16)H>>>=Ee,Y-=Ee,D.lens[D.have++]=we;else{if(we===16){for(X=Ee+2;Y<X;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(H>>>=Ee,Y-=Ee,D.have===0){I.msg="invalid bit length repeat",D.mode=30;break}B=D.lens[D.have-1],fe=3+(3&H),H>>>=2,Y-=2}else if(we===17){for(X=Ee+3;Y<X;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}Y-=Ee,B=0,fe=3+(7&(H>>>=Ee)),H>>>=3,Y-=3}else{for(X=Ee+7;Y<X;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}Y-=Ee,B=0,fe=11+(127&(H>>>=Ee)),H>>>=7,Y-=7}if(D.have+fe>D.nlen+D.ndist){I.msg="invalid bit length repeat",D.mode=30;break}for(;fe--;)D.lens[D.have++]=B}}if(D.mode===30)break;if(D.lens[256]===0){I.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,ie={bits:D.lenbits},z=c(u,D.lens,0,D.nlen,D.lencode,0,D.work,ie),D.lenbits=ie.bits,z){I.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,ie={bits:D.distbits},z=c(h,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,ie),D.distbits=ie.bits,z){I.msg="invalid distances set",D.mode=30;break}if(D.mode=20,W===6)break e;case 20:D.mode=21;case 21:if(6<=K&&258<=ee){I.next_out=Z,I.avail_out=ee,I.next_in=V,I.avail_in=K,D.hold=H,D.bits=Y,l(I,ae),Z=I.next_out,G=I.output,ee=I.avail_out,V=I.next_in,$=I.input,K=I.avail_in,H=D.hold,Y=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;he=(J=D.lencode[H&(1<<D.lenbits)-1])>>>16&255,we=65535&J,!((Ee=J>>>24)<=Y);){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(he&&(240&he)==0){for(De=Ee,de=he,Le=we;he=(J=D.lencode[Le+((H&(1<<De+de)-1)>>De)])>>>16&255,we=65535&J,!(De+(Ee=J>>>24)<=Y);){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}H>>>=De,Y-=De,D.back+=De}if(H>>>=Ee,Y-=Ee,D.back+=Ee,D.length=we,he===0){D.mode=26;break}if(32&he){D.back=-1,D.mode=12;break}if(64&he){I.msg="invalid literal/length code",D.mode=30;break}D.extra=15&he,D.mode=22;case 22:if(D.extra){for(X=D.extra;Y<X;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}D.length+=H&(1<<D.extra)-1,H>>>=D.extra,Y-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;he=(J=D.distcode[H&(1<<D.distbits)-1])>>>16&255,we=65535&J,!((Ee=J>>>24)<=Y);){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if((240&he)==0){for(De=Ee,de=he,Le=we;he=(J=D.distcode[Le+((H&(1<<De+de)-1)>>De)])>>>16&255,we=65535&J,!(De+(Ee=J>>>24)<=Y);){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}H>>>=De,Y-=De,D.back+=De}if(H>>>=Ee,Y-=Ee,D.back+=Ee,64&he){I.msg="invalid distance code",D.mode=30;break}D.offset=we,D.extra=15&he,D.mode=24;case 24:if(D.extra){for(X=D.extra;Y<X;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}D.offset+=H&(1<<D.extra)-1,H>>>=D.extra,Y-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){I.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(ee===0)break e;if(fe=ae-ee,D.offset>fe){if((fe=D.offset-fe)>D.whave&&D.sane){I.msg="invalid distance too far back",D.mode=30;break}Q=fe>D.wnext?(fe-=D.wnext,D.wsize-fe):D.wnext-fe,fe>D.length&&(fe=D.length),me=D.window}else me=G,Q=Z-D.offset,fe=D.length;for(ee<fe&&(fe=ee),ee-=fe,D.length-=fe;G[Z++]=me[Q++],--fe;);D.length===0&&(D.mode=21);break;case 26:if(ee===0)break e;G[Z++]=D.length,ee--,D.mode=21;break;case 27:if(D.wrap){for(;Y<32;){if(K===0)break e;K--,H|=$[V++]<<Y,Y+=8}if(ae-=ee,I.total_out+=ae,D.total+=ae,ae&&(I.adler=D.check=D.flags?o(D.check,G,ae,Z-ae):a(D.check,G,ae,Z-ae)),ae=ee,(D.flags?H:x(H))!==D.check){I.msg="incorrect data check",D.mode=30;break}Y=H=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;Y<32;){if(K===0)break e;K--,H+=$[V++]<<Y,Y+=8}if(H!==(4294967295&D.total)){I.msg="incorrect length check",D.mode=30;break}Y=H=0}D.mode=29;case 29:z=1;break e;case 30:z=-3;break e;case 31:return-4;case 32:default:return m}return I.next_out=Z,I.avail_out=ee,I.next_in=V,I.avail_in=K,D.hold=H,D.bits=Y,(D.wsize||ae!==I.avail_out&&D.mode<30&&(D.mode<27||W!==4))&&F(I,I.output,I.next_out,ae-I.avail_out)?(D.mode=31,-4):(te-=I.avail_in,ae-=I.avail_out,I.total_in+=te,I.total_out+=ae,D.total+=ae,D.wrap&&ae&&(I.adler=D.check=D.flags?o(D.check,G,ae,I.next_out-ae):a(D.check,G,ae,I.next_out-ae)),I.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(te==0&&ae===0||W===4)&&z===g&&(z=-5),z)},i.inflateEnd=function(I){if(!I||!I.state)return m;var W=I.state;return W.window&&(W.window=null),I.state=null,g},i.inflateGetHeader=function(I,W){var D;return I&&I.state?(2&(D=I.state).wrap)==0?m:((D.head=W).done=!1,g):m},i.inflateSetDictionary=function(I,W){var D,$=W.length;return I&&I.state?(D=I.state).wrap!==0&&D.mode!==11?m:D.mode===11&&a(1,W,$,0)!==D.check?-3:F(I,W,$,$)?(D.mode=31,-4):(D.havedict=1,g):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var s=n("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(u,h,g,m,b,y,v,x){var M,w,T,A,P,C,j,N,k,F=x.bits,I=0,W=0,D=0,$=0,G=0,V=0,Z=0,K=0,ee=0,H=0,Y=null,te=0,ae=new s.Buf16(16),fe=new s.Buf16(16),Q=null,me=0;for(I=0;I<=15;I++)ae[I]=0;for(W=0;W<m;W++)ae[h[g+W]]++;for(G=F,$=15;1<=$&&ae[$]===0;$--);if($<G&&(G=$),$===0)return b[y++]=20971520,b[y++]=20971520,x.bits=1,0;for(D=1;D<$&&ae[D]===0;D++);for(G<D&&(G=D),I=K=1;I<=15;I++)if(K<<=1,(K-=ae[I])<0)return-1;if(0<K&&(u===0||$!==1))return-1;for(fe[1]=0,I=1;I<15;I++)fe[I+1]=fe[I]+ae[I];for(W=0;W<m;W++)h[g+W]!==0&&(v[fe[h[g+W]]++]=W);if(C=u===0?(Y=Q=v,19):u===1?(Y=a,te-=257,Q=o,me-=257,256):(Y=l,Q=c,-1),I=D,P=y,Z=W=H=0,T=-1,A=(ee=1<<(V=G))-1,u===1&&852<ee||u===2&&592<ee)return 1;for(;;){for(j=I-Z,k=v[W]<C?(N=0,v[W]):v[W]>C?(N=Q[me+v[W]],Y[te+v[W]]):(N=96,0),M=1<<I-Z,D=w=1<<V;b[P+(H>>Z)+(w-=M)]=j<<24|N<<16|k|0,w!==0;);for(M=1<<I-1;H&M;)M>>=1;if(M!==0?(H&=M-1,H+=M):H=0,W++,--ae[I]==0){if(I===$)break;I=h[g+v[W]]}if(G<I&&(H&A)!==T){for(Z===0&&(Z=G),P+=D,K=1<<(V=I-Z);V+Z<$&&!((K-=ae[V+Z])<=0);)V++,K<<=1;if(ee+=1<<V,u===1&&852<ee||u===2&&592<ee)return 1;b[T=H&A]=G<<24|V<<16|P-y|0}}return H!==0&&(b[P+H]=I-Z<<24|64<<16|0),x.bits=G,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),a=0,o=1;function l(J){for(var le=J.length;0<=--le;)J[le]=0}var c=0,u=29,h=256,g=h+1+u,m=30,b=19,y=2*g+1,v=15,x=16,M=7,w=256,T=16,A=17,P=18,C=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],j=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(g+2));l(F);var I=new Array(2*m);l(I);var W=new Array(512);l(W);var D=new Array(256);l(D);var $=new Array(u);l($);var G,V,Z,K=new Array(m);function ee(J,le,Re,Ae,se){this.static_tree=J,this.extra_bits=le,this.extra_base=Re,this.elems=Ae,this.max_length=se,this.has_stree=J&&J.length}function H(J,le){this.dyn_tree=J,this.max_code=0,this.stat_desc=le}function Y(J){return J<256?W[J]:W[256+(J>>>7)]}function te(J,le){J.pending_buf[J.pending++]=255&le,J.pending_buf[J.pending++]=le>>>8&255}function ae(J,le,Re){J.bi_valid>x-Re?(J.bi_buf|=le<<J.bi_valid&65535,te(J,J.bi_buf),J.bi_buf=le>>x-J.bi_valid,J.bi_valid+=Re-x):(J.bi_buf|=le<<J.bi_valid&65535,J.bi_valid+=Re)}function fe(J,le,Re){ae(J,Re[2*le],Re[2*le+1])}function Q(J,le){for(var Re=0;Re|=1&J,J>>>=1,Re<<=1,0<--le;);return Re>>>1}function me(J,le,Re){var Ae,se,U=new Array(v+1),L=0;for(Ae=1;Ae<=v;Ae++)U[Ae]=L=L+Re[Ae-1]<<1;for(se=0;se<=le;se++){var ne=J[2*se+1];ne!==0&&(J[2*se]=Q(U[ne]++,ne))}}function Ee(J){var le;for(le=0;le<g;le++)J.dyn_ltree[2*le]=0;for(le=0;le<m;le++)J.dyn_dtree[2*le]=0;for(le=0;le<b;le++)J.bl_tree[2*le]=0;J.dyn_ltree[2*w]=1,J.opt_len=J.static_len=0,J.last_lit=J.matches=0}function he(J){8<J.bi_valid?te(J,J.bi_buf):0<J.bi_valid&&(J.pending_buf[J.pending++]=J.bi_buf),J.bi_buf=0,J.bi_valid=0}function we(J,le,Re,Ae){var se=2*le,U=2*Re;return J[se]<J[U]||J[se]===J[U]&&Ae[le]<=Ae[Re]}function De(J,le,Re){for(var Ae=J.heap[Re],se=Re<<1;se<=J.heap_len&&(se<J.heap_len&&we(le,J.heap[se+1],J.heap[se],J.depth)&&se++,!we(le,Ae,J.heap[se],J.depth));)J.heap[Re]=J.heap[se],Re=se,se<<=1;J.heap[Re]=Ae}function de(J,le,Re){var Ae,se,U,L,ne=0;if(J.last_lit!==0)for(;Ae=J.pending_buf[J.d_buf+2*ne]<<8|J.pending_buf[J.d_buf+2*ne+1],se=J.pending_buf[J.l_buf+ne],ne++,Ae===0?fe(J,se,le):(fe(J,(U=D[se])+h+1,le),(L=C[U])!==0&&ae(J,se-=$[U],L),fe(J,U=Y(--Ae),Re),(L=j[U])!==0&&ae(J,Ae-=K[U],L)),ne<J.last_lit;);fe(J,w,le)}function Le(J,le){var Re,Ae,se,U=le.dyn_tree,L=le.stat_desc.static_tree,ne=le.stat_desc.has_stree,ve=le.stat_desc.elems,ye=-1;for(J.heap_len=0,J.heap_max=y,Re=0;Re<ve;Re++)U[2*Re]!==0?(J.heap[++J.heap_len]=ye=Re,J.depth[Re]=0):U[2*Re+1]=0;for(;J.heap_len<2;)U[2*(se=J.heap[++J.heap_len]=ye<2?++ye:0)]=1,J.depth[se]=0,J.opt_len--,ne&&(J.static_len-=L[2*se+1]);for(le.max_code=ye,Re=J.heap_len>>1;1<=Re;Re--)De(J,U,Re);for(se=ve;Re=J.heap[1],J.heap[1]=J.heap[J.heap_len--],De(J,U,1),Ae=J.heap[1],J.heap[--J.heap_max]=Re,J.heap[--J.heap_max]=Ae,U[2*se]=U[2*Re]+U[2*Ae],J.depth[se]=(J.depth[Re]>=J.depth[Ae]?J.depth[Re]:J.depth[Ae])+1,U[2*Re+1]=U[2*Ae+1]=se,J.heap[1]=se++,De(J,U,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],(function(xe,tt){var je,Ye,ot,Fe,ce,Qe,Be=tt.dyn_tree,Ke=tt.max_code,ct=tt.stat_desc.static_tree,ue=tt.stat_desc.has_stree,Je=tt.stat_desc.extra_bits,ge=tt.stat_desc.extra_base,Ie=tt.stat_desc.max_length,Te=0;for(Fe=0;Fe<=v;Fe++)xe.bl_count[Fe]=0;for(Be[2*xe.heap[xe.heap_max]+1]=0,je=xe.heap_max+1;je<y;je++)Ie<(Fe=Be[2*Be[2*(Ye=xe.heap[je])+1]+1]+1)&&(Fe=Ie,Te++),Be[2*Ye+1]=Fe,Ke<Ye||(xe.bl_count[Fe]++,ce=0,ge<=Ye&&(ce=Je[Ye-ge]),Qe=Be[2*Ye],xe.opt_len+=Qe*(Fe+ce),ue&&(xe.static_len+=Qe*(ct[2*Ye+1]+ce)));if(Te!==0){do{for(Fe=Ie-1;xe.bl_count[Fe]===0;)Fe--;xe.bl_count[Fe]--,xe.bl_count[Fe+1]+=2,xe.bl_count[Ie]--,Te-=2}while(0<Te);for(Fe=Ie;Fe!==0;Fe--)for(Ye=xe.bl_count[Fe];Ye!==0;)Ke<(ot=xe.heap[--je])||(Be[2*ot+1]!==Fe&&(xe.opt_len+=(Fe-Be[2*ot+1])*Be[2*ot],Be[2*ot+1]=Fe),Ye--)}})(J,le),me(U,ye,J.bl_count)}function B(J,le,Re){var Ae,se,U=-1,L=le[1],ne=0,ve=7,ye=4;for(L===0&&(ve=138,ye=3),le[2*(Re+1)+1]=65535,Ae=0;Ae<=Re;Ae++)se=L,L=le[2*(Ae+1)+1],++ne<ve&&se===L||(ne<ye?J.bl_tree[2*se]+=ne:se!==0?(se!==U&&J.bl_tree[2*se]++,J.bl_tree[2*T]++):ne<=10?J.bl_tree[2*A]++:J.bl_tree[2*P]++,U=se,ye=(ne=0)===L?(ve=138,3):se===L?(ve=6,3):(ve=7,4))}function z(J,le,Re){var Ae,se,U=-1,L=le[1],ne=0,ve=7,ye=4;for(L===0&&(ve=138,ye=3),Ae=0;Ae<=Re;Ae++)if(se=L,L=le[2*(Ae+1)+1],!(++ne<ve&&se===L)){if(ne<ye)for(;fe(J,se,J.bl_tree),--ne!=0;);else se!==0?(se!==U&&(fe(J,se,J.bl_tree),ne--),fe(J,T,J.bl_tree),ae(J,ne-3,2)):ne<=10?(fe(J,A,J.bl_tree),ae(J,ne-3,3)):(fe(J,P,J.bl_tree),ae(J,ne-11,7));U=se,ye=(ne=0)===L?(ve=138,3):se===L?(ve=6,3):(ve=7,4)}}l(K);var ie=!1;function X(J,le,Re,Ae){ae(J,(c<<1)+(Ae?1:0),3),(function(se,U,L,ne){he(se),te(se,L),te(se,~L),s.arraySet(se.pending_buf,se.window,U,L,se.pending),se.pending+=L})(J,le,Re)}i._tr_init=function(J){ie||((function(){var le,Re,Ae,se,U,L=new Array(v+1);for(se=Ae=0;se<u-1;se++)for($[se]=Ae,le=0;le<1<<C[se];le++)D[Ae++]=se;for(D[Ae-1]=se,se=U=0;se<16;se++)for(K[se]=U,le=0;le<1<<j[se];le++)W[U++]=se;for(U>>=7;se<m;se++)for(K[se]=U<<7,le=0;le<1<<j[se]-7;le++)W[256+U++]=se;for(Re=0;Re<=v;Re++)L[Re]=0;for(le=0;le<=143;)F[2*le+1]=8,le++,L[8]++;for(;le<=255;)F[2*le+1]=9,le++,L[9]++;for(;le<=279;)F[2*le+1]=7,le++,L[7]++;for(;le<=287;)F[2*le+1]=8,le++,L[8]++;for(me(F,g+1,L),le=0;le<m;le++)I[2*le+1]=5,I[2*le]=Q(le,5);G=new ee(F,C,h+1,g,v),V=new ee(I,j,0,m,v),Z=new ee(new Array(0),N,0,b,M)})(),ie=!0),J.l_desc=new H(J.dyn_ltree,G),J.d_desc=new H(J.dyn_dtree,V),J.bl_desc=new H(J.bl_tree,Z),J.bi_buf=0,J.bi_valid=0,Ee(J)},i._tr_stored_block=X,i._tr_flush_block=function(J,le,Re,Ae){var se,U,L=0;0<J.level?(J.strm.data_type===2&&(J.strm.data_type=(function(ne){var ve,ye=4093624447;for(ve=0;ve<=31;ve++,ye>>>=1)if(1&ye&&ne.dyn_ltree[2*ve]!==0)return a;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return o;for(ve=32;ve<h;ve++)if(ne.dyn_ltree[2*ve]!==0)return o;return a})(J)),Le(J,J.l_desc),Le(J,J.d_desc),L=(function(ne){var ve;for(B(ne,ne.dyn_ltree,ne.l_desc.max_code),B(ne,ne.dyn_dtree,ne.d_desc.max_code),Le(ne,ne.bl_desc),ve=b-1;3<=ve&&ne.bl_tree[2*k[ve]+1]===0;ve--);return ne.opt_len+=3*(ve+1)+5+5+4,ve})(J),se=J.opt_len+3+7>>>3,(U=J.static_len+3+7>>>3)<=se&&(se=U)):se=U=Re+5,Re+4<=se&&le!==-1?X(J,le,Re,Ae):J.strategy===4||U===se?(ae(J,2+(Ae?1:0),3),de(J,F,I)):(ae(J,4+(Ae?1:0),3),(function(ne,ve,ye,xe){var tt;for(ae(ne,ve-257,5),ae(ne,ye-1,5),ae(ne,xe-4,4),tt=0;tt<xe;tt++)ae(ne,ne.bl_tree[2*k[tt]+1],3);z(ne,ne.dyn_ltree,ve-1),z(ne,ne.dyn_dtree,ye-1)})(J,J.l_desc.max_code+1,J.d_desc.max_code+1,L+1),de(J,J.dyn_ltree,J.dyn_dtree)),Ee(J),Ae&&he(J)},i._tr_tally=function(J,le,Re){return J.pending_buf[J.d_buf+2*J.last_lit]=le>>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&le,J.pending_buf[J.l_buf+J.last_lit]=255&Re,J.last_lit++,le===0?J.dyn_ltree[2*Re]++:(J.matches++,le--,J.dyn_ltree[2*(D[Re]+h+1)]++,J.dyn_dtree[2*Y(le)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){ae(J,2,3),fe(J,w,F),(function(le){le.bi_valid===16?(te(le,le.bi_buf),le.bi_buf=0,le.bi_valid=0):8<=le.bi_valid&&(le.pending_buf[le.pending++]=255&le.bi_buf,le.bi_buf>>=8,le.bi_valid-=8)})(J)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(s){(function(a,o){if(!a.setImmediate){var l,c,u,h,g=1,m={},b=!1,y=a.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(a);v=v&&v.setTimeout?v:a,l={}.toString.call(a.process)==="[object process]"?function(T){process.nextTick(function(){M(T)})}:(function(){if(a.postMessage&&!a.importScripts){var T=!0,A=a.onmessage;return a.onmessage=function(){T=!1},a.postMessage("","*"),a.onmessage=A,T}})()?(h="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",w,!1):a.attachEvent("onmessage",w),function(T){a.postMessage(h+T,"*")}):a.MessageChannel?((u=new MessageChannel).port1.onmessage=function(T){M(T.data)},function(T){u.port2.postMessage(T)}):y&&"onreadystatechange"in y.createElement("script")?(c=y.documentElement,function(T){var A=y.createElement("script");A.onreadystatechange=function(){M(T),A.onreadystatechange=null,c.removeChild(A),A=null},c.appendChild(A)}):function(T){setTimeout(M,0,T)},v.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var A=new Array(arguments.length-1),P=0;P<A.length;P++)A[P]=arguments[P+1];var C={callback:T,args:A};return m[g]=C,l(g),g++},v.clearImmediate=x}function x(T){delete m[T]}function M(T){if(b)setTimeout(M,0,T);else{var A=m[T];if(A){b=!0;try{(function(P){var C=P.callback,j=P.args;switch(j.length){case 0:C();break;case 1:C(j[0]);break;case 2:C(j[0],j[1]);break;case 3:C(j[0],j[1],j[2]);break;default:C.apply(o,j)}})(A)}finally{x(T),b=!1}}}}function w(T){T.source===a&&typeof T.data=="string"&&T.data.indexOf(h)===0&&M(+T.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Ub<"u"?Ub:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(ET)),ET.exports}var Age=Ege();const Tge=Ja(Age);function Cge(t){const e=new Kr;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 Sz=Cge;async function wz(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],s=[],a=[],o=i.getElementsByTagName("vertex");for(let c=0;c<o.length;c++){const u=o[c];s.push(parseFloat(u.getAttribute("x")||"0"),parseFloat(u.getAttribute("y")||"0"),parseFloat(u.getAttribute("z")||"0"))}const l=i.getElementsByTagName("triangle");for(let c=0;c<l.length;c++){const u=l[c];a.push(parseInt(u.getAttribute("v1")||"0"),parseInt(u.getAttribute("v2")||"0"),parseInt(u.getAttribute("v3")||"0"))}s.length>0&&a.length>0&&e.push({vertices:s,triangles:a})}return e}async function Nge(t){const e=await Tge.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function s(u){const h=u.startsWith("/")?u.slice(1):u,g=e.files[h];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const a=Object.keys(e.files).find(u=>u==="3D/3dmodel.model"||u.endsWith("/3dmodel.model"));if(!a){const u=Object.keys(e.files).find(h=>h.endsWith(".model"));if(u){const h=await s(u);if(h){const g=await wz(h);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await s(a);if(!o)return{objects:n,buildItems:r};const l=o.getElementsByTagName("object");for(let u=0;u<l.length;u++){const h=l[u],g=h.getAttribute("id");if(!g)continue;const m=[],b=h.getElementsByTagName("mesh");for(let v=0;v<b.length;v++){const x=b[v],M=[],w=[],T=x.getElementsByTagName("vertex");for(let P=0;P<T.length;P++){const C=T[P];M.push(parseFloat(C.getAttribute("x")||"0"),parseFloat(C.getAttribute("y")||"0"),parseFloat(C.getAttribute("z")||"0"))}const A=x.getElementsByTagName("triangle");for(let P=0;P<A.length;P++){const C=A[P];w.push(parseInt(C.getAttribute("v1")||"0"),parseInt(C.getAttribute("v2")||"0"),parseInt(C.getAttribute("v3")||"0"))}M.length>0&&w.length>0&&m.push({vertices:M,triangles:w})}const y=h.getElementsByTagName("component");for(let v=0;v<y.length;v++){const x=y[v],M=x.getAttribute("p:path")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(M){const w=await s(M);if(w){const T=await wz(w),A=x.getAttribute("transform"),P=Sz(A);for(const C of T)if(A){const j=[];for(let N=0;N<C.vertices.length;N+=3){const k=new Xe(C.vertices[N],C.vertices[N+1],C.vertices[N+2]);k.applyMatrix4(P),j.push(k.x,k.y,k.z)}m.push({vertices:j,triangles:C.triangles})}else m.push(C)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const c=o.getElementsByTagName("build");if(c.length>0){const u=c[0].getElementsByTagName("item");for(let h=0;h<u.length;h++){const g=u[h],m=g.getAttribute("objectid");if(!m)continue;const b=Sz(g.getAttribute("transform"));r.push({objectId:m,transform:b})}}return{objects:n,buildItems:r}}function Mz(t){const e=new fl,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 Ga(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function Rge({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),s=E.useRef(null),a=E.useRef(null),o=E.useRef(null),[l,c]=E.useState(!0),[u,h]=E.useState(null);E.useEffect(()=>{if(!r.current)return;const b=r.current,y=b.clientWidth,v=b.clientHeight,x=new ode;x.background=new bn(1710618),s.current=x;const M=new Ua(45,y/v,.1,1e4);M.position.set(150,150,150),a.current=M;const w=new cge({antialias:!0});w.setSize(y,v),w.setPixelRatio(window.devicePixelRatio),b.appendChild(w.domElement),i.current=w;const T=new dge(M,w.domElement);T.enableDamping=!0,T.dampingFactor=.05,o.current=T;const A=new bde(16777215,.6);x.add(A);const P=new WF(16777215,.8);P.position.set(100,100,100),x.add(P);const C=new WF(16777215,.4);C.position.set(-100,50,-100),x.add(C);const j=Math.max(e.x,e.y),N=Math.ceil(j/16),k=new _de(j,N,4473924,3355443);x.add(k);const F=new xk(e.x,e.y),I=new pk({color:44610,transparent:!0,opacity:.15,side:Go}),W=new il(F,I);W.rotation.x=-Math.PI/2,W.position.y=-.5,x.add(W);let D;const $=()=>{D=requestAnimationFrame($),T.update(),w.render(x,M)};$(),fetch(t).then(V=>{if(!V.ok)throw new Error("Failed to load file");return V.arrayBuffer()}).then(Nge).then(({objects:V,buildItems:Z})=>{if(V.size===0)throw new Error("No meshes found in 3MF file");const K=new pde({color:44610,shininess:30,flatShading:!1}),ee=new fx,H=[];if(Z.length>0)for(const he of Z){const we=V.get(he.objectId);if(we)for(const De of we.meshes){const de=[];for(let B=0;B<De.vertices.length;B+=3){const z=new Xe(De.vertices[B],De.vertices[B+1],De.vertices[B+2]);z.applyMatrix4(he.transform),de.push(z.x,z.y,z.z)}const Le=Mz({vertices:de,triangles:De.triangles});H.push(Le)}}else for(const he of V.values())for(const we of he.meshes){const De=Mz(we);H.push(De)}if(H.length>0){const he=H.length===1?H[0]:Mge(H,!1);if(he){const we=new il(he,K);ee.add(we)}if(H.length>1)for(const we of H)we.dispose()}const Y=new Df().setFromObject(ee),te=Y.getCenter(new Xe);ee.position.y=-Y.min.y,Z.length===0&&(ee.position.x=-te.x,ee.position.z=-te.z),x.add(ee);const ae=new Df().setFromObject(ee),fe=ae.getCenter(new Xe),Q=ae.getSize(new Xe),Ee=Math.max(Q.x,Q.y,Q.z)*1.8;M.position.set(fe.x+Ee*.7,fe.y+Ee*.5,fe.z+Ee*.7),T.target.copy(fe),T.update(),c(!1)}).catch(V=>{h(V.message),c(!1)});const G=()=>{if(!b)return;const V=b.clientWidth,Z=b.clientHeight;M.aspect=V/Z,M.updateProjectionMatrix(),w.setSize(V,Z)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),cancelAnimationFrame(D),T.dispose(),w.dispose(),b.removeChild(w.domElement)}},[t,e]);const g=()=>{a.current&&o.current&&(a.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=b=>{a.current&&a.current.position.multiplyScalar(b)};return f.jsxs("div",{className:`relative ${n}`,children:[f.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),l&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),u&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsx("p",{className:"text-red-400",children:u})}),!l&&!u&&f.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[f.jsx(We,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:f.jsx(nce,{className:"w-4 h-4"})}),f.jsx(We,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:f.jsx(sce,{className:"w-4 h-4"})}),f.jsx(We,{variant:"secondary",size:"sm",onClick:g,children:f.jsx(G0,{className:"w-4 h-4"})})]})]})}const fw="159",Xh={ROTATE:0,DOLLY:1,PAN:2},Kh={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Pge=0,Ez=1,kge=2,h7=1,Dge=2,Wl=3,Ju=0,Hs=1,Yl=2,Bu=0,jp=1,Az=2,Tz=3,Cz=4,Oge=5,Yd=100,Lge=101,Ige=102,Nz=103,Rz=104,jge=200,Uge=201,Fge=202,zge=203,D3=204,O3=205,Bge=206,Hge=207,$ge=208,Vge=209,Gge=210,Wge=211,qge=212,Xge=213,Kge=214,Yge=0,Zge=1,Qge=2,o1=3,Jge=4,exe=5,txe=6,nxe=7,bk=0,rxe=1,ixe=2,Hu=0,sxe=1,axe=2,oxe=3,lxe=4,cxe=5,p7=300,rm=301,im=302,L3=303,I3=304,hw=306,j3=1e3,po=1001,U3=1002,Vi=1003,Pz=1004,AT=1005,Fa=1006,uxe=1007,a0=1008,$u=1009,dxe=1010,fxe=1011,yk=1012,m7=1013,Ou=1014,nc=1015,o0=1016,g7=1017,x7=1018,uf=1020,hxe=1021,za=1023,pxe=1024,mxe=1025,df=1026,sm=1027,gxe=1028,v7=1029,xxe=1030,b7=1031,y7=1033,TT=33776,CT=33777,NT=33778,RT=33779,kz=35840,Dz=35841,Oz=35842,Lz=35843,_7=36196,Iz=37492,jz=37496,Uz=37808,Fz=37809,zz=37810,Bz=37811,Hz=37812,$z=37813,Vz=37814,Gz=37815,Wz=37816,qz=37817,Xz=37818,Kz=37819,Yz=37820,Zz=37821,PT=36492,Qz=36494,Jz=36495,vxe=36283,e5=36284,t5=36285,n5=36286,S7=3e3,ff=3001,bxe=3200,yxe=3201,w7=0,_xe=1,Ba="",Gi="srgb",vc="srgb-linear",_k="display-p3",pw="display-p3-linear",l1="linear",rr="srgb",c1="rec709",u1="p3",Yh=7680,r5=519,Sxe=512,wxe=513,Mxe=514,M7=515,Exe=516,Axe=517,Txe=518,Cxe=519,F3=35044,i5="300 es",z3=1035,Yo=2e3,l0=2001;class Yf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(n);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s<a;s++)i[s].call(this,e);e.target=null}}}const es=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let s5=1234567;const Ax=Math.PI/180,c0=180/Math.PI;function cc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(es[t&255]+es[t>>8&255]+es[t>>16&255]+es[t>>24&255]+"-"+es[e&255]+es[e>>8&255]+"-"+es[e>>16&15|64]+es[e>>24&255]+"-"+es[n&63|128]+es[n>>8&255]+"-"+es[n>>16&255]+es[n>>24&255]+es[r&255]+es[r>>8&255]+es[r>>16&255]+es[r>>24&255]).toLowerCase()}function Wi(t,e,n){return Math.max(e,Math.min(n,t))}function Sk(t,e){return(t%e+e)%e}function Nxe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function Rxe(t,e,n){return t!==e?(n-t)/(e-t):0}function Tx(t,e,n){return(1-n)*t+n*e}function Pxe(t,e,n,r){return Tx(t,e,1-Math.exp(-n*r))}function kxe(t,e=1){return e-Math.abs(Sk(t,e*2)-e)}function Dxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function Oxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function Lxe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function Ixe(t,e){return t+Math.random()*(e-t)}function jxe(t){return t*(.5-Math.random())}function Uxe(t){t!==void 0&&(s5=t);let e=s5+=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 Fxe(t){return t*Ax}function zxe(t){return t*c0}function B3(t){return(t&t-1)===0&&t!==0}function Bxe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function d1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Hxe(t,e,n,r,i){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((e+r)/2),u=a((e+r)/2),h=s((e-r)/2),g=a((e-r)/2),m=s((r-e)/2),b=a((r-e)/2);switch(i){case"XYX":t.set(o*u,l*h,l*g,o*c);break;case"YZY":t.set(l*g,o*u,l*h,o*c);break;case"ZXZ":t.set(l*h,l*g,o*u,o*c);break;case"XZX":t.set(o*u,l*b,l*m,o*c);break;case"YXY":t.set(l*m,o*u,l*b,o*c);break;case"ZYZ":t.set(l*b,l*m,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Wo(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Hn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const E7={DEG2RAD:Ax,RAD2DEG:c0,generateUUID:cc,clamp:Wi,euclideanModulo:Sk,mapLinear:Nxe,inverseLerp:Rxe,lerp:Tx,damp:Pxe,pingpong:kxe,smoothstep:Dxe,smootherstep:Oxe,randInt:Lxe,randFloat:Ixe,randFloatSpread:jxe,seededRandom:Uxe,degToRad:Fxe,radToDeg:zxe,isPowerOfTwo:B3,ceilPowerOfTwo:Bxe,floorPowerOfTwo:d1,setQuaternionFromProperEuler:Hxe,normalize:Hn,denormalize:Wo};class Kt{constructor(e=0,n=0){Kt.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Wi(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,n,r,i,s,a,o,l,c){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,c)}set(e,n,r,i,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=n,u[4]=s,u[5]=l,u[6]=r,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],l=r[6],c=r[1],u=r[4],h=r[7],g=r[2],m=r[5],b=r[8],y=i[0],v=i[3],x=i[6],M=i[1],w=i[4],T=i[7],A=i[2],P=i[5],C=i[8];return s[0]=a*y+o*M+l*A,s[3]=a*v+o*w+l*P,s[6]=a*x+o*T+l*C,s[1]=c*y+u*M+h*A,s[4]=c*v+u*w+h*P,s[7]=c*x+u*T+h*C,s[2]=g*y+m*M+b*A,s[5]=g*v+m*w+b*P,s[8]=g*x+m*T+b*C,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return n*a*u-n*o*c-r*s*u+r*o*l+i*s*c-i*a*l}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,g=o*l-u*s,m=c*s-a*l,b=n*h+r*g+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/b;return e[0]=h*y,e[1]=(i*c-u*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(u*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-c*n)*y,e[8]=(a*n-r*s)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(kT.makeScale(e,n)),this}rotate(e){return this.premultiply(kT.makeRotation(-e)),this}translate(e,n){return this.premultiply(kT.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 kT=new fn;function A7(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function f1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function $xe(){const t=f1("canvas");return t.style.display="block",t}const a5={};function Cx(t){t in a5||(a5[t]=!0,console.warn(t))}const o5=new fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),l5=new fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),fy={[vc]:{transfer:l1,primaries:c1,toReference:t=>t,fromReference:t=>t},[Gi]:{transfer:rr,primaries:c1,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[pw]:{transfer:l1,primaries:u1,toReference:t=>t.applyMatrix3(l5),fromReference:t=>t.applyMatrix3(o5)},[_k]:{transfer:rr,primaries:u1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(l5),fromReference:t=>t.applyMatrix3(o5).convertLinearToSRGB()}},Vxe=new Set([vc,pw]),$n={enabled:!0,_workingColorSpace:vc,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(!Vxe.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=fy[e].toReference,i=fy[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 fy[t].primaries},getTransfer:function(t){return t===Ba?l1:fy[t].transfer}};function Up(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function DT(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Zh;class T7{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Zh===void 0&&(Zh=f1("canvas")),Zh.width=e.width,Zh.height=e.height;const r=Zh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Zh}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=f1("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a<s.length;a++)s[a]=Up(s[a]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Up(n[r]/255)*255):n[r]=Up(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 Gxe=0;class C7{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Gxe++}),this.uuid=cc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?s.push(OT(i[a].image)):s.push(OT(i[a]))}else s=OT(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function OT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?T7.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 Wxe=0;class $s extends Yf{constructor(e=$s.DEFAULT_IMAGE,n=$s.DEFAULT_MAPPING,r=po,i=po,s=Fa,a=a0,o=za,l=$u,c=$s.DEFAULT_ANISOTROPY,u=Ba){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Wxe++}),this.uuid=cc(),this.name="",this.source=new C7(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Kt(0,0),this.repeat=new Kt(1,1),this.center=new Kt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(Cx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===ff?Gi:Ba),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!==p7)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case j3:e.x=e.x-Math.floor(e.x);break;case po:e.x=e.x<0?0:1;break;case U3: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 j3:e.y=e.y-Math.floor(e.y);break;case po:e.y=e.y<0?0:1;break;case U3: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 Cx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Gi?ff:S7}set encoding(e){Cx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===ff?Gi:Ba}}$s.DEFAULT_IMAGE=null;$s.DEFAULT_MAPPING=p7;$s.DEFAULT_ANISOTROPY=1;class Gn{constructor(e=0,n=0,r=0,i=1){Gn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*n+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*n+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*n+a[7]*r+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,s;const l=e.elements,c=l[0],u=l[4],h=l[8],g=l[1],m=l[5],b=l[9],y=l[2],v=l[6],x=l[10];if(Math.abs(u-g)<.01&&Math.abs(h-y)<.01&&Math.abs(b-v)<.01){if(Math.abs(u+g)<.1&&Math.abs(h+y)<.1&&Math.abs(b+v)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,T=(m+1)/2,A=(x+1)/2,P=(u+g)/4,C=(h+y)/4,j=(b+v)/4;return w>T&&w>A?w<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(w),i=P/r,s=C/r):T>A?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=P/i,s=j/i):A<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(A),r=C/s,i=j/s),this.set(r,i,s,n),this}let M=Math.sqrt((v-b)*(v-b)+(h-y)*(h-y)+(g-u)*(g-u));return Math.abs(M)<.001&&(M=1),this.x=(v-b)/M,this.y=(h-y)/M,this.z=(g-u)/M,this.w=Math.acos((c+m+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class qxe extends Yf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Gn(0,0,e,n),this.scissorTest=!1,this.viewport=new Gn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Cx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===ff?Gi:Ba),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fa,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new $s(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 C7(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 qxe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class N7 extends $s{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=Vi,this.minFilter=Vi,this.wrapR=po,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Xxe extends $s{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=Vi,this.minFilter=Vi,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,s,a,o){let l=r[i+0],c=r[i+1],u=r[i+2],h=r[i+3];const g=s[a+0],m=s[a+1],b=s[a+2],y=s[a+3];if(o===0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=b,e[n+3]=y;return}if(h!==y||l!==g||c!==m||u!==b){let v=1-o;const x=l*g+c*m+u*b+h*y,M=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){const A=Math.sqrt(w),P=Math.atan2(A,x*M);v=Math.sin(v*P)/A,o=Math.sin(o*P)/A}const T=o*M;if(l=l*v+g*T,c=c*v+m*T,u=u*v+b*T,h=h*v+y*T,v===1-o){const A=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=A,c*=A,u*=A,h*=A}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],c=r[i+2],u=r[i+3],h=s[a],g=s[a+1],m=s[a+2],b=s[a+3];return e[n]=o*b+u*h+l*m-c*g,e[n+1]=l*b+u*g+c*h-o*m,e[n+2]=c*b+u*m+o*g-l*h,e[n+3]=u*b-o*h-l*g-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(r/2),u=o(i/2),h=o(s/2),g=l(r/2),m=l(i/2),b=l(s/2);switch(a){case"XYZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"YXZ":this._x=g*u*h+c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"ZXY":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h-g*m*b;break;case"ZYX":this._x=g*u*h-c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h+g*m*b;break;case"YZX":this._x=g*u*h+c*m*b,this._y=c*m*h+g*u*b,this._z=c*u*b-g*m*h,this._w=c*u*h-g*m*b;break;case"XZY":this._x=g*u*h-c*m*b,this._y=c*m*h-g*u*b,this._z=c*u*b+g*m*h,this._w=c*u*h+g*m*b;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],s=n[8],a=n[1],o=n[5],l=n[9],c=n[2],u=n[6],h=n[10],g=r+o+h;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(u-l)*m,this._y=(s-c)*m,this._z=(a-i)*m}else if(r>o&&r>h){const m=2*Math.sqrt(1+r-o-h);this._w=(u-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+c)/m}else if(o>h){const m=2*Math.sqrt(1+o-r-h);this._w=(s-c)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+h-r-o);this._w=(a-i)/m,this._x=(s+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Wi(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,l=n._y,c=n._z,u=n._w;return this._x=r*u+a*o+i*c-s*l,this._y=i*u+a*l+s*o-r*c,this._z=s*u+a*c+r*l-i*o,this._w=a*u-r*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+r*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=r,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-n;return this._w=m*a+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),h=Math.sin((1-n)*u)/c,g=Math.sin(n*u)/c;return this._w=a*h+this._w*g,this._x=r*h+this._x*g,this._y=i*h+this._y*g,this._z=s*h+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(s),r*Math.cos(s),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ne{constructor(e=0,n=0,r=0){Ne.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(c5.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(c5.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[3]*r+s[6]*i,this.y=s[1]*n+s[4]*r+s[7]*i,this.z=s[2]*n+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*n+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*n+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*n+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*n+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*r),u=2*(o*n-s*i),h=2*(s*r-a*n);return this.x=n+l*c+a*h-o*u,this.y=r+l*u+o*c-s*h,this.z=i+l*h+s*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i,this.y=s[1]*n+s[5]*r+s[9]*i,this.z=s[2]*n+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,l=n.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return LT.copy(this).projectOnVector(e),this.sub(LT)}reflect(e){return this.sub(LT.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(Wi(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 LT=new Ne,c5=new Lf;class Wa{constructor(e=new Ne(1/0,1/0,1/0),n=new Ne(-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(co.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(co.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=co.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const s=r.getAttribute("position");if(n===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,co):co.fromBufferAttribute(s,a),co.applyMatrix4(e.matrixWorld),this.expandByPoint(co);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),hy.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),hy.copy(r.boundingBox)),hy.applyMatrix4(e.matrixWorld),this.union(hy)}const i=e.children;for(let s=0,a=i.length;s<a;s++)this.expandByObject(i[s],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,co),co.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(Kg),py.subVectors(this.max,Kg),Qh.subVectors(e.a,Kg),Jh.subVectors(e.b,Kg),ep.subVectors(e.c,Kg),uu.subVectors(Jh,Qh),du.subVectors(ep,Jh),jd.subVectors(Qh,ep);let n=[0,-uu.z,uu.y,0,-du.z,du.y,0,-jd.z,jd.y,uu.z,0,-uu.x,du.z,0,-du.x,jd.z,0,-jd.x,-uu.y,uu.x,0,-du.y,du.x,0,-jd.y,jd.x,0];return!IT(n,Qh,Jh,ep,py)||(n=[1,0,0,0,1,0,0,0,1],!IT(n,Qh,Jh,ep,py))?!1:(my.crossVectors(uu,du),n=[my.x,my.y,my.z],IT(n,Qh,Jh,ep,py))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,co).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(co).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:(jl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),jl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),jl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),jl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),jl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),jl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),jl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),jl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(jl),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 jl=[new Ne,new Ne,new Ne,new Ne,new Ne,new Ne,new Ne,new Ne],co=new Ne,hy=new Wa,Qh=new Ne,Jh=new Ne,ep=new Ne,uu=new Ne,du=new Ne,jd=new Ne,Kg=new Ne,py=new Ne,my=new Ne,Ud=new Ne;function IT(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){Ud.fromArray(t,s);const o=i.x*Math.abs(Ud.x)+i.y*Math.abs(Ud.y)+i.z*Math.abs(Ud.z),l=e.dot(Ud),c=n.dot(Ud),u=r.dot(Ud);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Kxe=new Wa,Yg=new Ne,jT=new Ne;class Qo{constructor(e=new Ne,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):Kxe.setFromPoints(e).getCenter(r);let i=0;for(let s=0,a=e.length;s<a;s++)i=Math.max(i,r.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Yg.subVectors(e,this.center);const n=Yg.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Yg,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):(jT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Yg.copy(e.center).add(jT)),this.expandByPoint(Yg.copy(e.center).sub(jT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ul=new Ne,UT=new Ne,gy=new Ne,fu=new Ne,FT=new Ne,xy=new Ne,zT=new Ne;class wk{constructor(e=new Ne,n=new Ne(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,Ul)),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=Ul.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ul.copy(this.origin).addScaledVector(this.direction,n),Ul.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){UT.copy(e).add(n).multiplyScalar(.5),gy.copy(n).sub(e).normalize(),fu.copy(this.origin).sub(UT);const s=e.distanceTo(n)*.5,a=-this.direction.dot(gy),o=fu.dot(this.direction),l=-fu.dot(gy),c=fu.lengthSq(),u=Math.abs(1-a*a);let h,g,m,b;if(u>0)if(h=a*l-o,g=a*o-l,b=s*u,h>=0)if(g>=-b)if(g<=b){const y=1/u;h*=y,g*=y,m=h*(h+a*g+2*o)+g*(a*h+g+2*l)+c}else g=s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g=-s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;else g<=-b?(h=Math.max(0,-(-a*s+o)),g=h>0?-s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c):g<=b?(h=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+c):(h=Math.max(0,-(a*s+o)),g=h>0?s:Math.min(Math.max(-s,-l),s),m=-h*h+g*(g+2*l)+c);else g=a>0?-s:s,h=Math.max(0,-(a*g+o)),m=-h*h+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(UT).addScaledVector(gy,g),m}intersectSphere(e,n){Ul.subVectors(e.center,this.origin);const r=Ul.dot(this.direction),i=Ul.dot(Ul)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,g=this.origin;return c>=0?(r=(e.min.x-g.x)*c,i=(e.max.x-g.x)*c):(r=(e.max.x-g.x)*c,i=(e.min.x-g.x)*c),u>=0?(s=(e.min.y-g.y)*u,a=(e.max.y-g.y)*u):(s=(e.max.y-g.y)*u,a=(e.min.y-g.y)*u),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-g.z)*h,l=(e.max.z-g.z)*h):(o=(e.max.z-g.z)*h,l=(e.min.z-g.z)*h),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Ul)!==null}intersectTriangle(e,n,r,i,s){FT.subVectors(n,e),xy.subVectors(r,e),zT.crossVectors(FT,xy);let a=this.direction.dot(zT),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;fu.subVectors(this.origin,e);const l=o*this.direction.dot(xy.crossVectors(fu,xy));if(l<0)return null;const c=o*this.direction.dot(FT.cross(fu));if(c<0||l+c>a)return null;const u=-o*fu.dot(zT);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Jn{constructor(e,n,r,i,s,a,o,l,c,u,h,g,m,b,y,v){Jn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,l,c,u,h,g,m,b,y,v)}set(e,n,r,i,s,a,o,l,c,u,h,g,m,b,y,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=r,x[12]=i,x[1]=s,x[5]=a,x[9]=o,x[13]=l,x[2]=c,x[6]=u,x[10]=h,x[14]=g,x[3]=m,x[7]=b,x[11]=y,x[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Jn().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/tp.setFromMatrixColumn(e,0).length(),s=1/tp.setFromMatrixColumn(e,1).length(),a=1/tp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*s,n[5]=r[5]*s,n[6]=r[6]*s,n[7]=0,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),o=Math.sin(r),l=Math.cos(i),c=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){const g=a*u,m=a*h,b=o*u,y=o*h;n[0]=l*u,n[4]=-l*h,n[8]=c,n[1]=m+b*c,n[5]=g-y*c,n[9]=-o*l,n[2]=y-g*c,n[6]=b+m*c,n[10]=a*l}else if(e.order==="YXZ"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g+y*o,n[4]=b*o-m,n[8]=a*c,n[1]=a*h,n[5]=a*u,n[9]=-o,n[2]=m*o-b,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*u,m=l*h,b=c*u,y=c*h;n[0]=g-y*o,n[4]=-a*h,n[8]=b+m*o,n[1]=m+b*o,n[5]=a*u,n[9]=y-g*o,n[2]=-a*c,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*u,m=a*h,b=o*u,y=o*h;n[0]=l*u,n[4]=b*c-m,n[8]=g*c+y,n[1]=l*h,n[5]=y*c+g,n[9]=m*c-b,n[2]=-c,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*c,b=o*l,y=o*c;n[0]=l*u,n[4]=y-g*h,n[8]=b*h+m,n[1]=h,n[5]=a*u,n[9]=-o*u,n[2]=-c*u,n[6]=m*h+b,n[10]=g-y*h}else if(e.order==="XZY"){const g=a*l,m=a*c,b=o*l,y=o*c;n[0]=l*u,n[4]=-h,n[8]=c*u,n[1]=g*h+y,n[5]=a*u,n[9]=m*h-b,n[2]=b*h-m,n[6]=o*u,n[10]=y*h+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Yxe,e,Zxe)}lookAt(e,n,r){const i=this.elements;return sa.subVectors(e,n),sa.lengthSq()===0&&(sa.z=1),sa.normalize(),hu.crossVectors(r,sa),hu.lengthSq()===0&&(Math.abs(r.z)===1?sa.x+=1e-4:sa.z+=1e-4,sa.normalize(),hu.crossVectors(r,sa)),hu.normalize(),vy.crossVectors(sa,hu),i[0]=hu.x,i[4]=vy.x,i[8]=sa.x,i[1]=hu.y,i[5]=vy.y,i[9]=sa.y,i[2]=hu.z,i[6]=vy.z,i[10]=sa.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[4],l=r[8],c=r[12],u=r[1],h=r[5],g=r[9],m=r[13],b=r[2],y=r[6],v=r[10],x=r[14],M=r[3],w=r[7],T=r[11],A=r[15],P=i[0],C=i[4],j=i[8],N=i[12],k=i[1],F=i[5],I=i[9],W=i[13],D=i[2],$=i[6],G=i[10],V=i[14],Z=i[3],K=i[7],ee=i[11],H=i[15];return s[0]=a*P+o*k+l*D+c*Z,s[4]=a*C+o*F+l*$+c*K,s[8]=a*j+o*I+l*G+c*ee,s[12]=a*N+o*W+l*V+c*H,s[1]=u*P+h*k+g*D+m*Z,s[5]=u*C+h*F+g*$+m*K,s[9]=u*j+h*I+g*G+m*ee,s[13]=u*N+h*W+g*V+m*H,s[2]=b*P+y*k+v*D+x*Z,s[6]=b*C+y*F+v*$+x*K,s[10]=b*j+y*I+v*G+x*ee,s[14]=b*N+y*W+v*V+x*H,s[3]=M*P+w*k+T*D+A*Z,s[7]=M*C+w*F+T*$+A*K,s[11]=M*j+w*I+T*G+A*ee,s[15]=M*N+w*W+T*V+A*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],g=e[10],m=e[14],b=e[3],y=e[7],v=e[11],x=e[15];return b*(+s*l*h-i*c*h-s*o*g+r*c*g+i*o*m-r*l*m)+y*(+n*l*m-n*c*g+s*a*g-i*a*m+i*c*u-s*l*u)+v*(+n*c*h-n*o*m-s*a*h+r*a*m+s*o*u-r*c*u)+x*(-i*o*u-n*l*h+n*o*g+i*a*h-r*a*g+r*l*u)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],g=e[10],m=e[11],b=e[12],y=e[13],v=e[14],x=e[15],M=h*v*c-y*g*c+y*l*m-o*v*m-h*l*x+o*g*x,w=b*g*c-u*v*c-b*l*m+a*v*m+u*l*x-a*g*x,T=u*y*c-b*h*c+b*o*m-a*y*m-u*o*x+a*h*x,A=b*h*l-u*y*l-b*o*g+a*y*g+u*o*v-a*h*v,P=n*M+r*w+i*T+s*A;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/P;return e[0]=M*C,e[1]=(y*g*s-h*v*s-y*i*m+r*v*m+h*i*x-r*g*x)*C,e[2]=(o*v*s-y*l*s+y*i*c-r*v*c-o*i*x+r*l*x)*C,e[3]=(h*l*s-o*g*s-h*i*c+r*g*c+o*i*m-r*l*m)*C,e[4]=w*C,e[5]=(u*v*s-b*g*s+b*i*m-n*v*m-u*i*x+n*g*x)*C,e[6]=(b*l*s-a*v*s-b*i*c+n*v*c+a*i*x-n*l*x)*C,e[7]=(a*g*s-u*l*s+u*i*c-n*g*c-a*i*m+n*l*m)*C,e[8]=T*C,e[9]=(b*h*s-u*y*s-b*r*m+n*y*m+u*r*x-n*h*x)*C,e[10]=(a*y*s-b*o*s+b*r*c-n*y*c-a*r*x+n*o*x)*C,e[11]=(u*o*s-a*h*s-u*r*c+n*h*c+a*r*m-n*o*m)*C,e[12]=A*C,e[13]=(u*y*i-b*h*i+b*r*g-n*y*g-u*r*v+n*h*v)*C,e[14]=(b*o*i-a*y*i-b*r*l+n*y*l+a*r*v-n*o*v)*C,e[15]=(a*h*i-u*o*i+u*r*l-n*h*l-a*r*g+n*o*g)*C,this}scale(e){const n=this.elements,r=e.x,i=e.y,s=e.z;return n[0]*=r,n[4]*=i,n[8]*=s,n[1]*=r,n[5]*=i,n[9]*=s,n[2]*=r,n[6]*=i,n[10]*=s,n[3]*=r,n[7]*=i,n[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),s=1-r,a=e.x,o=e.y,l=e.z,c=s*a,u=s*o;return this.set(c*a+r,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+r,u*l-i*a,0,c*l-i*o,u*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,c=s+s,u=a+a,h=o+o,g=s*c,m=s*u,b=s*h,y=a*u,v=a*h,x=o*h,M=l*c,w=l*u,T=l*h,A=r.x,P=r.y,C=r.z;return i[0]=(1-(y+x))*A,i[1]=(m+T)*A,i[2]=(b-w)*A,i[3]=0,i[4]=(m-T)*P,i[5]=(1-(g+x))*P,i[6]=(v+M)*P,i[7]=0,i[8]=(b+w)*C,i[9]=(v-M)*C,i[10]=(1-(g+y))*C,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=tp.set(i[0],i[1],i[2]).length();const a=tp.set(i[4],i[5],i[6]).length(),o=tp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],uo.copy(this);const c=1/s,u=1/a,h=1/o;return uo.elements[0]*=c,uo.elements[1]*=c,uo.elements[2]*=c,uo.elements[4]*=u,uo.elements[5]*=u,uo.elements[6]*=u,uo.elements[8]*=h,uo.elements[9]*=h,uo.elements[10]*=h,n.setFromRotationMatrix(uo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=Yo){const l=this.elements,c=2*s/(n-e),u=2*s/(r-i),h=(n+e)/(n-e),g=(r+i)/(r-i);let m,b;if(o===Yo)m=-(a+s)/(a-s),b=-2*a*s/(a-s);else if(o===l0)m=-a/(a-s),b=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=u,l[9]=g,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=b,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=Yo){const l=this.elements,c=1/(n-e),u=1/(r-i),h=1/(a-s),g=(n+e)*c,m=(r+i)*u;let b,y;if(o===Yo)b=(a+s)*h,y=-2*h;else if(o===l0)b=s*h,y=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-g,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=y,l[14]=-b,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const tp=new Ne,uo=new Jn,Yxe=new Ne(0,0,0),Zxe=new Ne(1,1,1),hu=new Ne,vy=new Ne,sa=new Ne,u5=new Jn,d5=new Lf;class q0{constructor(e=0,n=0,r=0,i=q0.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Wi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Wi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Wi(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Wi(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Wi(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Wi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return u5.makeRotationFromQuaternion(e),this.setFromRotationMatrix(u5,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return d5.setFromEuler(this),this.setFromQuaternion(d5,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}}q0.DEFAULT_ORDER="XYZ";class R7{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 Qxe=0;const f5=new Ne,np=new Lf,Fl=new Jn,by=new Ne,Zg=new Ne,Jxe=new Ne,e0e=new Lf,h5=new Ne(1,0,0),p5=new Ne(0,1,0),m5=new Ne(0,0,1),t0e={type:"added"},n0e={type:"removed"};class _s extends Yf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Qxe++}),this.uuid=cc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_s.DEFAULT_UP.clone();const e=new Ne,n=new q0,r=new Lf,i=new Ne(1,1,1);function s(){r.setFromEuler(n,!1)}function a(){n.setFromQuaternion(r,void 0,!1)}n._onChange(s),r._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Jn},normalMatrix:{value:new fn}}),this.matrix=new Jn,this.matrixWorld=new Jn,this.matrixAutoUpdate=_s.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new R7,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 np.setFromAxisAngle(e,n),this.quaternion.multiply(np),this}rotateOnWorldAxis(e,n){return np.setFromAxisAngle(e,n),this.quaternion.premultiply(np),this}rotateX(e){return this.rotateOnAxis(h5,e)}rotateY(e){return this.rotateOnAxis(p5,e)}rotateZ(e){return this.rotateOnAxis(m5,e)}translateOnAxis(e,n){return f5.copy(e).applyQuaternion(this.quaternion),this.position.add(f5.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(h5,e)}translateY(e){return this.translateOnAxis(p5,e)}translateZ(e){return this.translateOnAxis(m5,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Fl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?by.copy(e):by.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Zg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Fl.lookAt(Zg,by,this.up):Fl.lookAt(by,Zg,this.up),this.quaternion.setFromRotationMatrix(Fl),i&&(Fl.extractRotation(i.matrixWorld),np.setFromRotationMatrix(Fl),this.quaternion.premultiply(np.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(t0e)):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(n0e)),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),Fl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Fl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Fl),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const a=this.children[r].getObjectByProperty(e,n);if(a!==void 0)return a}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zg,e,Jxe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zg,e0e,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const s=n[r];(s.matrixWorldAutoUpdate===!0||e===!0)&&s.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let s=0,a=i.length;s<a;s++){const o=i[s];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(e.materials,this.material[l]));i.material=o}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(s(e.animations,l))}}if(n){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),g=a(e.skeletons),m=a(e.animations),b=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),h.length>0&&(r.shapes=h),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),b.length>0&&(r.nodes=b)}return r.object=i,r;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}_s.DEFAULT_UP=new Ne(0,1,0);_s.DEFAULT_MATRIX_AUTO_UPDATE=!0;_s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const fo=new Ne,zl=new Ne,BT=new Ne,Bl=new Ne,rp=new Ne,ip=new Ne,g5=new Ne,HT=new Ne,$T=new Ne,VT=new Ne;let yy=!1;class ho{constructor(e=new Ne,n=new Ne,r=new Ne){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),fo.subVectors(e,n),i.cross(fo);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,n,r,i,s){fo.subVectors(i,n),zl.subVectors(r,n),BT.subVectors(e,n);const a=fo.dot(fo),o=fo.dot(zl),l=fo.dot(BT),c=zl.dot(zl),u=zl.dot(BT),h=a*c-o*o;if(h===0)return s.set(-2,-1,-1);const g=1/h,m=(c*l-o*u)*g,b=(a*u-o*l)*g;return s.set(1-m-b,b,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Bl),Bl.x>=0&&Bl.y>=0&&Bl.x+Bl.y<=1}static getUV(e,n,r,i,s,a,o,l){return yy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yy=!0),this.getInterpolation(e,n,r,i,s,a,o,l)}static getInterpolation(e,n,r,i,s,a,o,l){return this.getBarycoord(e,n,r,i,Bl),l.setScalar(0),l.addScaledVector(s,Bl.x),l.addScaledVector(a,Bl.y),l.addScaledVector(o,Bl.z),l}static isFrontFacing(e,n,r,i){return fo.subVectors(r,n),zl.subVectors(e,n),fo.cross(zl).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 fo.subVectors(this.c,this.b),zl.subVectors(this.a,this.b),fo.cross(zl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ho.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return ho.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return yy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),yy=!0),ho.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return ho.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return ho.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ho.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,s=this.c;let a,o;rp.subVectors(i,r),ip.subVectors(s,r),HT.subVectors(e,r);const l=rp.dot(HT),c=ip.dot(HT);if(l<=0&&c<=0)return n.copy(r);$T.subVectors(e,i);const u=rp.dot($T),h=ip.dot($T);if(u>=0&&h<=u)return n.copy(i);const g=l*h-u*c;if(g<=0&&l>=0&&u<=0)return a=l/(l-u),n.copy(r).addScaledVector(rp,a);VT.subVectors(e,s);const m=rp.dot(VT),b=ip.dot(VT);if(b>=0&&m<=b)return n.copy(s);const y=m*c-l*b;if(y<=0&&c>=0&&b<=0)return o=c/(c-b),n.copy(r).addScaledVector(ip,o);const v=u*b-m*h;if(v<=0&&h-u>=0&&m-b>=0)return g5.subVectors(s,i),o=(h-u)/(h-u+(m-b)),n.copy(i).addScaledVector(g5,o);const x=1/(v+y+g);return a=y*x,o=g*x,n.copy(r).addScaledVector(rp,a).addScaledVector(ip,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const P7={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},pu={h:0,s:0,l:0},_y={h:0,s:0,l:0};function GT(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Bt=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Gi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$n.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=$n.workingColorSpace){return this.r=e,this.g=n,this.b=r,$n.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=$n.workingColorSpace){if(e=Sk(e,1),n=Wi(n,0,1),r=Wi(r,0,1),n===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+n):r+n-r*n,a=2*r-s;this.r=GT(a,s,e+1/3),this.g=GT(a,s,e),this.b=GT(a,s,e-1/3)}return $n.toWorkingColorSpace(this,i),this}setStyle(e,n=Gi){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Gi){const r=P7[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=Up(e.r),this.g=Up(e.g),this.b=Up(e.b),this}copyLinearToSRGB(e){return this.r=DT(e.r),this.g=DT(e.g),this.b=DT(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Gi){return $n.fromWorkingColorSpace(ts.copy(this),e),Math.round(Wi(ts.r*255,0,255))*65536+Math.round(Wi(ts.g*255,0,255))*256+Math.round(Wi(ts.b*255,0,255))}getHexString(e=Gi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=$n.workingColorSpace){$n.fromWorkingColorSpace(ts.copy(this),n);const r=ts.r,i=ts.g,s=ts.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case r:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-r)/h+2;break;case s:l=(r-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,n=$n.workingColorSpace){return $n.fromWorkingColorSpace(ts.copy(this),n),e.r=ts.r,e.g=ts.g,e.b=ts.b,e}getStyle(e=Gi){$n.fromWorkingColorSpace(ts.copy(this),e);const n=ts.r,r=ts.g,i=ts.b;return e!==Gi?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(pu),this.setHSL(pu.h+e,pu.s+n,pu.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(pu),e.getHSL(_y);const r=Tx(pu.h,_y.h,n),i=Tx(pu.s,_y.s,n),s=Tx(pu.l,_y.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const ts=new Bt;Bt.NAMES=P7;let r0e=0;class km extends Yf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:r0e++}),this.uuid=cc(),this.name="",this.type="Material",this.blending=jp,this.side=Ju,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=D3,this.blendDst=O3,this.blendEquation=Yd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Bt(0,0,0),this.blendAlpha=0,this.depthFunc=o1,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=r5,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yh,this.stencilZFail=Yh,this.stencilZPass=Yh,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!==jp&&(r.blending=this.blending),this.side!==Ju&&(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!==D3&&(r.blendSrc=this.blendSrc),this.blendDst!==O3&&(r.blendDst=this.blendDst),this.blendEquation!==Yd&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==o1&&(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!==r5&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Yh&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Yh&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Yh&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(n){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=n[s].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class k7 extends km{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Bt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=bk,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const $r=new Ne,Sy=new Kt;class ha{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=F3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=nc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)Sy.fromBufferAttribute(this,n),Sy.applyMatrix3(e),this.setXY(n,Sy.x,Sy.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyMatrix3(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyMatrix4(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.applyNormalMatrix(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)$r.fromBufferAttribute(this,n),$r.transformDirection(e),this.setXYZ(n,$r.x,$r.y,$r.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Wo(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Hn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Wo(n,this.array)),n}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Wo(n,this.array)),n}setY(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=Wo(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=Wo(n,this.array)),n}setW(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Hn(n,this.array),r=Hn(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e*=this.itemSize,this.normalized&&(n=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array),s=Hn(s,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==F3&&(e.usage=this.usage),e}}class D7 extends ha{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class O7 extends ha{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Lr extends ha{constructor(e,n,r){super(new Float32Array(e),n,r)}}let i0e=0;const Ta=new Jn,WT=new _s,sp=new Ne,aa=new Wa,Qg=new Wa,Si=new Ne;class us extends Yf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:i0e++}),this.uuid=cc(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(A7(e)?O7:D7)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new fn().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ta.makeRotationFromQuaternion(e),this.applyMatrix4(Ta),this}rotateX(e){return Ta.makeRotationX(e),this.applyMatrix4(Ta),this}rotateY(e){return Ta.makeRotationY(e),this.applyMatrix4(Ta),this}rotateZ(e){return Ta.makeRotationZ(e),this.applyMatrix4(Ta),this}translate(e,n,r){return Ta.makeTranslation(e,n,r),this.applyMatrix4(Ta),this}scale(e,n,r){return Ta.makeScale(e,n,r),this.applyMatrix4(Ta),this}lookAt(e){return WT.lookAt(e),WT.updateMatrix(),this.applyMatrix4(WT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(sp).negate(),this.translate(sp.x,sp.y,sp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const s=e[r];n.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Lr(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wa);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 Ne(-1/0,-1/0,-1/0),new Ne(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];aa.setFromBufferAttribute(s),this.morphTargetsRelative?(Si.addVectors(this.boundingBox.min,aa.min),this.boundingBox.expandByPoint(Si),Si.addVectors(this.boundingBox.max,aa.max),this.boundingBox.expandByPoint(Si)):(this.boundingBox.expandByPoint(aa.min),this.boundingBox.expandByPoint(aa.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 Qo);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 Ne,1/0);return}if(e){const r=this.boundingSphere.center;if(aa.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];Qg.setFromBufferAttribute(o),this.morphTargetsRelative?(Si.addVectors(aa.min,Qg.min),aa.expandByPoint(Si),Si.addVectors(aa.max,Qg.max),aa.expandByPoint(Si)):(aa.expandByPoint(Qg.min),aa.expandByPoint(Qg.max))}aa.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Si.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Si));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)Si.fromBufferAttribute(o,c),l&&(sp.fromBufferAttribute(e,c),Si.add(sp)),i=Math.max(i,r.distanceToSquared(Si))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,s=n.normal.array,a=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ha(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],u=[];for(let k=0;k<o;k++)c[k]=new Ne,u[k]=new Ne;const h=new Ne,g=new Ne,m=new Ne,b=new Kt,y=new Kt,v=new Kt,x=new Ne,M=new Ne;function w(k,F,I){h.fromArray(i,k*3),g.fromArray(i,F*3),m.fromArray(i,I*3),b.fromArray(a,k*2),y.fromArray(a,F*2),v.fromArray(a,I*2),g.sub(h),m.sub(h),y.sub(b),v.sub(b);const W=1/(y.x*v.y-v.x*y.y);isFinite(W)&&(x.copy(g).multiplyScalar(v.y).addScaledVector(m,-y.y).multiplyScalar(W),M.copy(m).multiplyScalar(y.x).addScaledVector(g,-v.x).multiplyScalar(W),c[k].add(x),c[F].add(x),c[I].add(x),u[k].add(M),u[F].add(M),u[I].add(M))}let T=this.groups;T.length===0&&(T=[{start:0,count:r.length}]);for(let k=0,F=T.length;k<F;++k){const I=T[k],W=I.start,D=I.count;for(let $=W,G=W+D;$<G;$+=3)w(r[$+0],r[$+1],r[$+2])}const A=new Ne,P=new Ne,C=new Ne,j=new Ne;function N(k){C.fromArray(s,k*3),j.copy(C);const F=c[k];A.copy(F),A.sub(C.multiplyScalar(C.dot(F))).normalize(),P.crossVectors(j,F);const W=P.dot(u[k])<0?-1:1;l[k*4]=A.x,l[k*4+1]=A.y,l[k*4+2]=A.z,l[k*4+3]=W}for(let k=0,F=T.length;k<F;++k){const I=T[k],W=I.start,D=I.count;for(let $=W,G=W+D;$<G;$+=3)N(r[$+0]),N(r[$+1]),N(r[$+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new ha(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,m=r.count;g<m;g++)r.setXYZ(g,0,0,0);const i=new Ne,s=new Ne,a=new Ne,o=new Ne,l=new Ne,c=new Ne,u=new Ne,h=new Ne;if(e)for(let g=0,m=e.count;g<m;g+=3){const b=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,b),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),u.subVectors(a,s),h.subVectors(i,s),u.cross(h),o.fromBufferAttribute(r,b),l.fromBufferAttribute(r,y),c.fromBufferAttribute(r,v),o.add(u),l.add(u),c.add(u),r.setXYZ(b,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),u.subVectors(a,s),h.subVectors(i,s),u.cross(h),r.setXYZ(g+0,u.x,u.y,u.z),r.setXYZ(g+1,u.x,u.y,u.z),r.setXYZ(g+2,u.x,u.y,u.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Si.fromBufferAttribute(e,n),Si.normalize(),e.setXYZ(n,Si.x,Si.y,Si.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,g=new c.constructor(l.length*u);let m=0,b=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*u;for(let x=0;x<u;x++)g[b++]=c[m++]}return new ha(g,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new us,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,r);n.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let u=0,h=c.length;u<h;u++){const g=c[u],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,g=c.length;h<g;h++){const m=c[h];u.push(m.toJSON(e.data))}u.length>0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(n))}const s=e.morphAttributes;for(const c in s){const u=[],h=s[c];for(let g=0,m=h.length;g<m;g++)u.push(h[g].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const x5=new Jn,Fd=new wk,wy=new Qo,v5=new Ne,ap=new Ne,op=new Ne,lp=new Ne,qT=new Ne,My=new Ne,Ey=new Kt,Ay=new Kt,Ty=new Kt,b5=new Ne,y5=new Ne,_5=new Ne,Cy=new Ne,Ny=new Ne;class yo extends _s{constructor(e=new us,n=new k7){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(s&&o){My.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=o[l],h=s[l];u!==0&&(qT.fromBufferAttribute(h,e),a?My.addScaledVector(qT,u):My.addScaledVector(qT.sub(n),u))}n.add(My)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),wy.copy(r.boundingSphere),wy.applyMatrix4(s),Fd.copy(e.ray).recast(e.near),!(wy.containsPoint(Fd.origin)===!1&&(Fd.intersectSphere(wy,v5)===null||Fd.origin.distanceToSquared(v5)>(e.far-e.near)**2))&&(x5.copy(s).invert(),Fd.copy(e.ray).applyMatrix4(x5),!(r.boundingBox!==null&&Fd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Fd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=a[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let T=M,A=w;T<A;T+=3){const P=o.getX(T),C=o.getX(T+1),j=o.getX(T+2);i=Ry(this,x,e,r,c,u,h,P,C,j),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),T=o.getX(v+2);i=Ry(this,a,e,r,c,u,h,M,w,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let b=0,y=g.length;b<y;b++){const v=g[b],x=a[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let T=M,A=w;T<A;T+=3){const P=T,C=T+1,j=T+2;i=Ry(this,x,e,r,c,u,h,P,C,j),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const b=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=b,x=y;v<x;v+=3){const M=v,w=v+1,T=v+2;i=Ry(this,a,e,r,c,u,h,M,w,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function s0e(t,e,n,r,i,s,a,o){let l;if(e.side===Hs?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===Ju,o),l===null)return null;Ny.copy(o),Ny.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Ny);return c<n.near||c>n.far?null:{distance:c,point:Ny.clone(),object:t}}function Ry(t,e,n,r,i,s,a,o,l,c){t.getVertexPosition(o,ap),t.getVertexPosition(l,op),t.getVertexPosition(c,lp);const u=s0e(t,e,n,r,ap,op,lp,Cy);if(u){i&&(Ey.fromBufferAttribute(i,o),Ay.fromBufferAttribute(i,l),Ty.fromBufferAttribute(i,c),u.uv=ho.getInterpolation(Cy,ap,op,lp,Ey,Ay,Ty,new Kt)),s&&(Ey.fromBufferAttribute(s,o),Ay.fromBufferAttribute(s,l),Ty.fromBufferAttribute(s,c),u.uv1=ho.getInterpolation(Cy,ap,op,lp,Ey,Ay,Ty,new Kt),u.uv2=u.uv1),a&&(b5.fromBufferAttribute(a,o),y5.fromBufferAttribute(a,l),_5.fromBufferAttribute(a,c),u.normal=ho.getInterpolation(Cy,ap,op,lp,b5,y5,_5,new Ne),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new Ne,materialIndex:0};ho.getNormal(ap,op,lp,h.normal),u.face=h}return u}class X0 extends us{constructor(e=1,n=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],h=[];let g=0,m=0;b("z","y","x",-1,-1,r,n,e,a,s,0),b("z","y","x",1,-1,r,n,-e,a,s,1),b("x","z","y",1,1,e,r,n,i,a,2),b("x","z","y",1,-1,e,r,-n,i,a,3),b("x","y","z",1,-1,e,n,r,i,s,4),b("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Lr(c,3)),this.setAttribute("normal",new Lr(u,3)),this.setAttribute("uv",new Lr(h,2));function b(y,v,x,M,w,T,A,P,C,j,N){const k=T/C,F=A/j,I=T/2,W=A/2,D=P/2,$=C+1,G=j+1;let V=0,Z=0;const K=new Ne;for(let ee=0;ee<G;ee++){const H=ee*F-W;for(let Y=0;Y<$;Y++){const te=Y*k-I;K[y]=te*M,K[v]=H*w,K[x]=D,c.push(K.x,K.y,K.z),K[y]=0,K[v]=0,K[x]=P>0?1:-1,u.push(K.x,K.y,K.z),h.push(Y/C),h.push(1-ee/j),V+=1}}for(let ee=0;ee<j;ee++)for(let H=0;H<C;H++){const Y=g+H+$*ee,te=g+H+$*(ee+1),ae=g+(H+1)+$*(ee+1),fe=g+(H+1)+$*ee;l.push(Y,te,fe),l.push(te,ae,fe),Z+=6}o.addGroup(m,Z,N),m+=Z,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new X0(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function am(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 gs(t){const e={};for(let n=0;n<t.length;n++){const r=am(t[n]);for(const i in r)e[i]=r[i]}return e}function a0e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function L7(t){return t.getRenderTarget()===null?t.outputColorSpace:$n.workingColorSpace}const Mk={clone:am,merge:gs};var o0e=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,l0e=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class ed extends km{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=o0e,this.fragmentShader=l0e,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=am(e.uniforms),this.uniformsGroups=a0e(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?n.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?n.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?n.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?n.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?n.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?n.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?n.uniforms[i]={type:"m4",value:a.toArray()}:n.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class I7 extends _s{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jn,this.projectionMatrix=new Jn,this.projectionMatrixInverse=new Jn,this.coordinateSystem=Yo}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 la extends I7{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=c0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ax*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return c0*2*Math.atan(Math.tan(Ax*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,s,a){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Ax*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/c,i*=a.width/l,r*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const cp=-90,up=1;class c0e extends _s{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new la(cp,up,e,n);i.layers=this.layers,this.add(i);const s=new la(cp,up,e,n);s.layers=this.layers,this.add(s);const a=new la(cp,up,e,n);a.layers=this.layers,this.add(a);const o=new la(cp,up,e,n);o.layers=this.layers,this.add(o);const l=new la(cp,up,e,n);l.layers=this.layers,this.add(l);const c=new la(cp,up,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const c of n)this.remove(c);if(e===Yo)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===l0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,u]=this.children,h=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,s),e.setRenderTarget(r,1,i),e.render(n,a),e.setRenderTarget(r,2,i),e.render(n,o),e.setRenderTarget(r,3,i),e.render(n,l),e.setRenderTarget(r,4,i),e.render(n,c),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,u),e.setRenderTarget(h,g,m),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class j7 extends $s{constructor(e,n,r,i,s,a,o,l,c,u){e=e!==void 0?e:[],n=n!==void 0?n:rm,super(e,n,r,i,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class u0e 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&&(Cx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===ff?Gi:Ba),this.texture=new j7(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:Fa}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new X0(5,5,5),s=new ed({name:"CubemapFromEquirect",uniforms:am(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Hs,blending:Bu});s.uniforms.tEquirect.value=n;const a=new yo(i,s),o=n.minFilter;return n.minFilter===a0&&(n.minFilter=Fa),new c0e(1,10,this).update(e,a),n.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,n,r,i){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(n,r,i);e.setRenderTarget(s)}}const XT=new Ne,d0e=new Ne,f0e=new fn;class yu{constructor(e=new Ne(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=XT.subVectors(r,n).cross(d0e.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(XT),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:n.copy(e.start).addScaledVector(r,s)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||f0e.getNormalMatrix(e),i=this.coplanarPoint(XT).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const zd=new Qo,Py=new Ne;class mw{constructor(e=new yu,n=new yu,r=new yu,i=new yu,s=new yu,a=new yu){this.planes=[e,n,r,i,s,a]}set(e,n,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Yo){const r=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],u=i[5],h=i[6],g=i[7],m=i[8],b=i[9],y=i[10],v=i[11],x=i[12],M=i[13],w=i[14],T=i[15];if(r[0].setComponents(l-s,g-c,v-m,T-x).normalize(),r[1].setComponents(l+s,g+c,v+m,T+x).normalize(),r[2].setComponents(l+a,g+u,v+b,T+M).normalize(),r[3].setComponents(l-a,g-u,v-b,T-M).normalize(),r[4].setComponents(l-o,g-h,v-y,T-w).normalize(),n===Yo)r[5].setComponents(l+o,g+h,v+y,T+w).normalize();else if(n===l0)r[5].setComponents(o,h,y,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),zd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),zd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(zd)}intersectsSprite(e){return zd.center.set(0,0,0),zd.radius=.7071067811865476,zd.applyMatrix4(e.matrixWorld),this.intersectsSphere(zd)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Py.x=i.normal.x>0?e.max.x:e.min.x,Py.y=i.normal.y>0?e.max.y:e.min.y,Py.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Py)<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 U7(){let t=null,e=!1,n=null,r=null;function i(s,a){n(s,a),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){n=s},setContext:function(s){t=s}}}function h0e(t,e){const n=e.isWebGL2,r=new WeakMap;function i(c,u){const h=c.array,g=c.usage,m=h.byteLength,b=t.createBuffer();t.bindBuffer(u,b),t.bufferData(u,h,g),c.onUploadCallback();let y;if(h instanceof Float32Array)y=t.FLOAT;else if(h instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(h instanceof Int16Array)y=t.SHORT;else if(h instanceof Uint32Array)y=t.UNSIGNED_INT;else if(h instanceof Int32Array)y=t.INT;else if(h instanceof Int8Array)y=t.BYTE;else if(h instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:b,type:y,bytesPerElement:h.BYTES_PER_ELEMENT,version:c.version,size:m}}function s(c,u,h){const g=u.array,m=u._updateRange,b=u.updateRanges;if(t.bindBuffer(h,c),m.count===-1&&b.length===0&&t.bufferSubData(h,0,g),b.length!==0){for(let y=0,v=b.length;y<v;y++){const x=b[y];n?t.bufferSubData(h,x.start*g.BYTES_PER_ELEMENT,g,x.start,x.count):t.bufferSubData(h,x.start*g.BYTES_PER_ELEMENT,g.subarray(x.start,x.start+x.count))}u.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(h,m.offset*g.BYTES_PER_ELEMENT,g,m.offset,m.count):t.bufferSubData(h,m.offset*g.BYTES_PER_ELEMENT,g.subarray(m.offset,m.offset+m.count)),m.count=-1),u.onUploadCallback()}function a(c){return c.isInterleavedBufferAttribute&&(c=c.data),r.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=r.get(c);u&&(t.deleteBuffer(u.buffer),r.delete(c))}function l(c,u){if(c.isGLBufferAttribute){const g=r.get(c);(!g||g.version<c.version)&&r.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const h=r.get(c);if(h===void 0)r.set(c,i(c,u));else if(h.version<c.version){if(h.size!==c.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(h.buffer,c,u),h.version=c.version}}return{get:a,remove:o,update:l}}class Ek extends us{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const s=e/2,a=n/2,o=Math.floor(r),l=Math.floor(i),c=o+1,u=l+1,h=e/o,g=n/l,m=[],b=[],y=[],v=[];for(let x=0;x<u;x++){const M=x*g-a;for(let w=0;w<c;w++){const T=w*h-s;b.push(T,-M,0),y.push(0,0,1),v.push(w/o),v.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,T=M+c*(x+1),A=M+1+c*(x+1),P=M+1+c*x;m.push(w,T,P),m.push(T,A,P)}this.setIndex(m),this.setAttribute("position",new Lr(b,3)),this.setAttribute("normal",new Lr(y,3)),this.setAttribute("uv",new Lr(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ek(e.width,e.height,e.widthSegments,e.heightSegments)}}var p0e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,m0e=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,g0e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,x0e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,v0e=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,b0e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,y0e=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,_0e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,S0e=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,w0e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,M0e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,E0e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,A0e=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,T0e=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,C0e=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,N0e=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,R0e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,P0e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,k0e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,D0e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,O0e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,L0e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,I0e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,j0e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,U0e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,F0e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,z0e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,B0e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,H0e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,$0e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,V0e="gl_FragColor = linearToOutputTexel( gl_FragColor );",G0e=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,W0e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,q0e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,X0e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,K0e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,Y0e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,Z0e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,Q0e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,J0e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,eve=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,tve=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,nve=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,rve=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,ive=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,sve=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ave=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,ove=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,lve=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,cve=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,uve=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,dve=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,fve=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,hve=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,pve=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,mve=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,gve=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,xve=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,vve=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,bve=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,yve=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,_ve=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Sve=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,wve=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,Mve=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Eve=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,Ave=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,Tve=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,Cve=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,Nve=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,Rve=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,Pve=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,kve=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,Dve=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Ove=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Lve=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Ive=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,jve=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Uve=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Fve=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,zve=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Bve=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Hve=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,$ve=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,Vve=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,Gve=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,Wve=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,qve=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Xve=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Kve=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,Yve=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,Zve=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,Qve=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,Jve=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,ebe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,tbe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,nbe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,rbe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,ibe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,sbe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,abe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,obe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,lbe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,cbe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,ube=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,dbe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,fbe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const hbe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,pbe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,mbe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,gbe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,xbe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,vbe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,bbe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,ybe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,_be=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,Sbe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,wbe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,Mbe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Ebe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,Abe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,Tbe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,Cbe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Nbe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Rbe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Pbe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,kbe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Dbe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,Obe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,Lbe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Ibe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,jbe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,Ube=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Fbe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,zbe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Bbe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,Hbe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,$be=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Vbe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Gbe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,Wbe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,an={alphahash_fragment:p0e,alphahash_pars_fragment:m0e,alphamap_fragment:g0e,alphamap_pars_fragment:x0e,alphatest_fragment:v0e,alphatest_pars_fragment:b0e,aomap_fragment:y0e,aomap_pars_fragment:_0e,batching_pars_vertex:S0e,batching_vertex:w0e,begin_vertex:M0e,beginnormal_vertex:E0e,bsdfs:A0e,iridescence_fragment:T0e,bumpmap_pars_fragment:C0e,clipping_planes_fragment:N0e,clipping_planes_pars_fragment:R0e,clipping_planes_pars_vertex:P0e,clipping_planes_vertex:k0e,color_fragment:D0e,color_pars_fragment:O0e,color_pars_vertex:L0e,color_vertex:I0e,common:j0e,cube_uv_reflection_fragment:U0e,defaultnormal_vertex:F0e,displacementmap_pars_vertex:z0e,displacementmap_vertex:B0e,emissivemap_fragment:H0e,emissivemap_pars_fragment:$0e,colorspace_fragment:V0e,colorspace_pars_fragment:G0e,envmap_fragment:W0e,envmap_common_pars_fragment:q0e,envmap_pars_fragment:X0e,envmap_pars_vertex:K0e,envmap_physical_pars_fragment:ove,envmap_vertex:Y0e,fog_vertex:Z0e,fog_pars_vertex:Q0e,fog_fragment:J0e,fog_pars_fragment:eve,gradientmap_pars_fragment:tve,lightmap_fragment:nve,lightmap_pars_fragment:rve,lights_lambert_fragment:ive,lights_lambert_pars_fragment:sve,lights_pars_begin:ave,lights_toon_fragment:lve,lights_toon_pars_fragment:cve,lights_phong_fragment:uve,lights_phong_pars_fragment:dve,lights_physical_fragment:fve,lights_physical_pars_fragment:hve,lights_fragment_begin:pve,lights_fragment_maps:mve,lights_fragment_end:gve,logdepthbuf_fragment:xve,logdepthbuf_pars_fragment:vve,logdepthbuf_pars_vertex:bve,logdepthbuf_vertex:yve,map_fragment:_ve,map_pars_fragment:Sve,map_particle_fragment:wve,map_particle_pars_fragment:Mve,metalnessmap_fragment:Eve,metalnessmap_pars_fragment:Ave,morphcolor_vertex:Tve,morphnormal_vertex:Cve,morphtarget_pars_vertex:Nve,morphtarget_vertex:Rve,normal_fragment_begin:Pve,normal_fragment_maps:kve,normal_pars_fragment:Dve,normal_pars_vertex:Ove,normal_vertex:Lve,normalmap_pars_fragment:Ive,clearcoat_normal_fragment_begin:jve,clearcoat_normal_fragment_maps:Uve,clearcoat_pars_fragment:Fve,iridescence_pars_fragment:zve,opaque_fragment:Bve,packing:Hve,premultiplied_alpha_fragment:$ve,project_vertex:Vve,dithering_fragment:Gve,dithering_pars_fragment:Wve,roughnessmap_fragment:qve,roughnessmap_pars_fragment:Xve,shadowmap_pars_fragment:Kve,shadowmap_pars_vertex:Yve,shadowmap_vertex:Zve,shadowmask_pars_fragment:Qve,skinbase_vertex:Jve,skinning_pars_vertex:ebe,skinning_vertex:tbe,skinnormal_vertex:nbe,specularmap_fragment:rbe,specularmap_pars_fragment:ibe,tonemapping_fragment:sbe,tonemapping_pars_fragment:abe,transmission_fragment:obe,transmission_pars_fragment:lbe,uv_pars_fragment:cbe,uv_pars_vertex:ube,uv_vertex:dbe,worldpos_vertex:fbe,background_vert:hbe,background_frag:pbe,backgroundCube_vert:mbe,backgroundCube_frag:gbe,cube_vert:xbe,cube_frag:vbe,depth_vert:bbe,depth_frag:ybe,distanceRGBA_vert:_be,distanceRGBA_frag:Sbe,equirect_vert:wbe,equirect_frag:Mbe,linedashed_vert:Ebe,linedashed_frag:Abe,meshbasic_vert:Tbe,meshbasic_frag:Cbe,meshlambert_vert:Nbe,meshlambert_frag:Rbe,meshmatcap_vert:Pbe,meshmatcap_frag:kbe,meshnormal_vert:Dbe,meshnormal_frag:Obe,meshphong_vert:Lbe,meshphong_frag:Ibe,meshphysical_vert:jbe,meshphysical_frag:Ube,meshtoon_vert:Fbe,meshtoon_frag:zbe,points_vert:Bbe,points_frag:Hbe,shadow_vert:$be,shadow_frag:Vbe,sprite_vert:Gbe,sprite_frag:Wbe},bt={common:{diffuse:{value:new Bt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new Kt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Bt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Bt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0},uvTransform:{value:new fn}},sprite:{diffuse:{value:new Bt(16777215)},opacity:{value:1},center:{value:new Kt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},js={basic:{uniforms:gs([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:gs([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:gs([bt.common,bt.specularmap,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)},specular:{value:new Bt(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:gs([bt.common,bt.envmap,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.roughnessmap,bt.metalnessmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:gs([bt.common,bt.aomap,bt.lightmap,bt.emissivemap,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.gradientmap,bt.fog,bt.lights,{emissive:{value:new Bt(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:gs([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,bt.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:gs([bt.points,bt.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:gs([bt.common,bt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:gs([bt.common,bt.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:gs([bt.common,bt.bumpmap,bt.normalmap,bt.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:gs([bt.sprite,bt.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:an.background_vert,fragmentShader:an.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:an.backgroundCube_vert,fragmentShader:an.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:an.cube_vert,fragmentShader:an.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:an.equirect_vert,fragmentShader:an.equirect_frag},distanceRGBA:{uniforms:gs([bt.common,bt.displacementmap,{referencePosition:{value:new Ne},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distanceRGBA_vert,fragmentShader:an.distanceRGBA_frag},shadow:{uniforms:gs([bt.lights,bt.fog,{color:{value:new Bt(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};js.physical={uniforms:gs([js.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new Kt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new Bt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fn},transmissionSamplerSize:{value:new Kt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new Bt(0)},specularColor:{value:new Bt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new Kt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const ky={r:0,b:0,g:0};function qbe(t,e,n,r,i,s,a){const o=new Bt(0);let l=s===!0?0:1,c,u,h=null,g=0,m=null;function b(v,x){let M=!1,w=x.isScene===!0?x.background:null;w&&w.isTexture&&(w=(x.backgroundBlurriness>0?n:e).get(w)),w===null?y(o,l):w&&w.isColor&&(y(w,1),M=!0);const T=t.xr.getEnvironmentBlendMode();T==="additive"?r.buffers.color.setClear(0,0,0,1,a):T==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(t.autoClear||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===hw)?(u===void 0&&(u=new yo(new X0(1,1,1),new ed({name:"BackgroundCubeMaterial",uniforms:am(js.backgroundCube.uniforms),vertexShader:js.backgroundCube.vertexShader,fragmentShader:js.backgroundCube.fragmentShader,side:Hs,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(A,P,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.toneMapped=$n.getTransfer(w.colorSpace)!==rr,(h!==w||g!==w.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=w,g=w.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new yo(new Ek(2,2),new ed({name:"BackgroundMaterial",uniforms:am(js.background.uniforms),vertexShader:js.background.vertexShader,fragmentShader:js.background.fragmentShader,side:Ju,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=$n.getTransfer(w.colorSpace)!==rr,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(h!==w||g!==w.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,h=w,g=w.version,m=t.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function y(v,x){v.getRGB(ky,L7(t)),r.buffers.color.setClear(ky.r,ky.g,ky.b,x,a)}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),l=x,y(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,y(o,l)},render:b}}function Xbe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=r.isWebGL2?null:e.get("OES_vertex_array_object"),a=r.isWebGL2||s!==null,o={},l=v(null);let c=l,u=!1;function h(D,$,G,V,Z){let K=!1;if(a){const ee=y(V,G,$);c!==ee&&(c=ee,m(c.object)),K=x(D,V,G,Z),K&&M(D,V,G,Z)}else{const ee=$.wireframe===!0;(c.geometry!==V.id||c.program!==G.id||c.wireframe!==ee)&&(c.geometry=V.id,c.program=G.id,c.wireframe=ee,K=!0)}Z!==null&&n.update(Z,t.ELEMENT_ARRAY_BUFFER),(K||u)&&(u=!1,j(D,$,G,V),Z!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Z).buffer))}function g(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(D){return r.isWebGL2?t.bindVertexArray(D):s.bindVertexArrayOES(D)}function b(D){return r.isWebGL2?t.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function y(D,$,G){const V=G.wireframe===!0;let Z=o[D.id];Z===void 0&&(Z={},o[D.id]=Z);let K=Z[$.id];K===void 0&&(K={},Z[$.id]=K);let ee=K[V];return ee===void 0&&(ee=v(g()),K[V]=ee),ee}function v(D){const $=[],G=[],V=[];for(let Z=0;Z<i;Z++)$[Z]=0,G[Z]=0,V[Z]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:G,attributeDivisors:V,object:D,attributes:{},index:null}}function x(D,$,G,V){const Z=c.attributes,K=$.attributes;let ee=0;const H=G.getAttributes();for(const Y in H)if(H[Y].location>=0){const ae=Z[Y];let fe=K[Y];if(fe===void 0&&(Y==="instanceMatrix"&&D.instanceMatrix&&(fe=D.instanceMatrix),Y==="instanceColor"&&D.instanceColor&&(fe=D.instanceColor)),ae===void 0||ae.attribute!==fe||fe&&ae.data!==fe.data)return!0;ee++}return c.attributesNum!==ee||c.index!==V}function M(D,$,G,V){const Z={},K=$.attributes;let ee=0;const H=G.getAttributes();for(const Y in H)if(H[Y].location>=0){let ae=K[Y];ae===void 0&&(Y==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),Y==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor));const fe={};fe.attribute=ae,ae&&ae.data&&(fe.data=ae.data),Z[Y]=fe,ee++}c.attributes=Z,c.attributesNum=ee,c.index=V}function w(){const D=c.newAttributes;for(let $=0,G=D.length;$<G;$++)D[$]=0}function T(D){A(D,0)}function A(D,$){const G=c.newAttributes,V=c.enabledAttributes,Z=c.attributeDivisors;G[D]=1,V[D]===0&&(t.enableVertexAttribArray(D),V[D]=1),Z[D]!==$&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,$),Z[D]=$)}function P(){const D=c.newAttributes,$=c.enabledAttributes;for(let G=0,V=$.length;G<V;G++)$[G]!==D[G]&&(t.disableVertexAttribArray(G),$[G]=0)}function C(D,$,G,V,Z,K,ee){ee===!0?t.vertexAttribIPointer(D,$,G,Z,K):t.vertexAttribPointer(D,$,G,V,Z,K)}function j(D,$,G,V){if(r.isWebGL2===!1&&(D.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const Z=V.attributes,K=G.getAttributes(),ee=$.defaultAttributeValues;for(const H in K){const Y=K[H];if(Y.location>=0){let te=Z[H];if(te===void 0&&(H==="instanceMatrix"&&D.instanceMatrix&&(te=D.instanceMatrix),H==="instanceColor"&&D.instanceColor&&(te=D.instanceColor)),te!==void 0){const ae=te.normalized,fe=te.itemSize,Q=n.get(te);if(Q===void 0)continue;const me=Q.buffer,Ee=Q.type,he=Q.bytesPerElement,we=r.isWebGL2===!0&&(Ee===t.INT||Ee===t.UNSIGNED_INT||te.gpuType===m7);if(te.isInterleavedBufferAttribute){const De=te.data,de=De.stride,Le=te.offset;if(De.isInstancedInterleavedBuffer){for(let B=0;B<Y.locationSize;B++)A(Y.location+B,De.meshPerAttribute);D.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=De.meshPerAttribute*De.count)}else for(let B=0;B<Y.locationSize;B++)T(Y.location+B);t.bindBuffer(t.ARRAY_BUFFER,me);for(let B=0;B<Y.locationSize;B++)C(Y.location+B,fe/Y.locationSize,Ee,ae,de*he,(Le+fe/Y.locationSize*B)*he,we)}else{if(te.isInstancedBufferAttribute){for(let De=0;De<Y.locationSize;De++)A(Y.location+De,te.meshPerAttribute);D.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let De=0;De<Y.locationSize;De++)T(Y.location+De);t.bindBuffer(t.ARRAY_BUFFER,me);for(let De=0;De<Y.locationSize;De++)C(Y.location+De,fe/Y.locationSize,Ee,ae,fe*he,fe/Y.locationSize*De*he,we)}}else if(ee!==void 0){const ae=ee[H];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(Y.location,ae);break;case 3:t.vertexAttrib3fv(Y.location,ae);break;case 4:t.vertexAttrib4fv(Y.location,ae);break;default:t.vertexAttrib1fv(Y.location,ae)}}}}P()}function N(){I();for(const D in o){const $=o[D];for(const G in $){const V=$[G];for(const Z in V)b(V[Z].object),delete V[Z];delete $[G]}delete o[D]}}function k(D){if(o[D.id]===void 0)return;const $=o[D.id];for(const G in $){const V=$[G];for(const Z in V)b(V[Z].object),delete V[Z];delete $[G]}delete o[D.id]}function F(D){for(const $ in o){const G=o[$];if(G[D.id]===void 0)continue;const V=G[D.id];for(const Z in V)b(V[Z].object),delete V[Z];delete G[D.id]}}function I(){W(),u=!0,c!==l&&(c=l,m(c.object))}function W(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:I,resetDefaultState:W,dispose:N,releaseStatesOfGeometry:k,releaseStatesOfProgram:F,initAttributes:w,enableAttribute:T,disableUnusedAttributes:P}}function Kbe(t,e,n,r){const i=r.isWebGL2;let s;function a(u){s=u}function o(u,h){t.drawArrays(s,u,h),n.update(h,s,1)}function l(u,h,g){if(g===0)return;let m,b;if(i)m=t,b="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[b](s,u,h,g),n.update(h,s,g)}function c(u,h,g){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let b=0;b<g;b++)this.render(u[b],h[b]);else{m.multiDrawArraysWEBGL(s,u,0,h,0,g);let b=0;for(let y=0;y<g;y++)b+=h[y];n.update(b,s,1)}}this.setMode=a,this.render=o,this.renderInstances=l,this.renderMultiDraw=c}function Ybe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const C=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(C){if(C==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const a=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const l=s(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=a||e.has("WEBGL_draw_buffers"),u=n.logarithmicDepthBuffer===!0,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),x=t.getParameter(t.MAX_VARYING_VECTORS),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,T=a||e.has("OES_texture_float"),A=w&&T,P=a?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:c,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:u,maxTextures:h,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:b,maxAttributes:y,maxVertexUniforms:v,maxVaryings:x,maxFragmentUniforms:M,vertexTextures:w,floatFragmentTextures:T,floatVertexTextures:A,maxSamples:P}}function Zbe(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new yu,o=new fn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,g){const m=h.length!==0||g||r!==0||i;return i=g,r=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,g){n=u(h,g,0)},this.setState=function(h,g,m){const b=h.clippingPlanes,y=h.clipIntersection,v=h.clipShadows,x=t.get(h);if(!i||b===null||b.length===0||s&&!v)s?u(null):c();else{const M=s?0:r,w=M*4;let T=x.clippingState||null;l.value=T,T=u(b,g,w,m);for(let A=0;A!==w;++A)T[A]=n[A];x.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(h,g,m,b){const y=h!==null?h.length:0;let v=null;if(y!==0){if(v=l.value,b!==!0||v===null){const x=m+y*4,M=g.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,T=m;w!==y;++w,T+=4)a.copy(h[w]).applyMatrix4(M,o),a.normal.toArray(v,T),v[T+3]=a.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function Qbe(t){let e=new WeakMap;function n(a,o){return o===L3?a.mapping=rm:o===I3&&(a.mapping=im),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===L3||o===I3)if(e.has(a)){const l=e.get(a).texture;return n(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new u0e(l.height/2);return c.fromEquirectangularTexture(t,a),e.set(a,c),a.addEventListener("dispose",i),n(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class Jbe extends I7{constructor(e=-1,n=1,r=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=r-e,a=r+e,o=i+n,l=i-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Tp=4,S5=[.125,.215,.35,.446,.526,.582],Zd=20,KT=new Jbe,w5=new Bt;let YT=null,ZT=0,QT=0;const $d=(1+Math.sqrt(5))/2,dp=1/$d,M5=[new Ne(1,1,1),new Ne(-1,1,1),new Ne(1,1,-1),new Ne(-1,1,-1),new Ne(0,$d,dp),new Ne(0,$d,-dp),new Ne(dp,0,$d),new Ne(-dp,0,$d),new Ne($d,dp,0),new Ne(-$d,dp,0)];class E5{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){YT=this._renderer.getRenderTarget(),ZT=this._renderer.getActiveCubeFace(),QT=this._renderer.getActiveMipmapLevel(),this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,r,i,s),n>0&&this._blur(s,0,0,n),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=C5(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=T5(),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(YT,ZT,QT),e.scissorTest=!1,Dy(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===rm||e.mapping===im?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),YT=this._renderer.getRenderTarget(),ZT=this._renderer.getActiveCubeFace(),QT=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:Fa,minFilter:Fa,generateMipmaps:!1,type:o0,format:za,colorSpace:vc,depthBuffer:!1},i=A5(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=A5(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=eye(s)),this._blurMaterial=tye(s,e,n)}return i}_compileMaterial(e){const n=new yo(this._lodPlanes[0],e);this._renderer.compile(n,KT)}_sceneToCubeUV(e,n,r,i){const o=new la(90,1,n,r),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,g=u.toneMapping;u.getClearColor(w5),u.toneMapping=Hu,u.autoClear=!1;const m=new k7({name:"PMREM.Background",side:Hs,depthWrite:!1,depthTest:!1}),b=new yo(new X0,m);let y=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,y=!0):(m.color.copy(w5),y=!0);for(let x=0;x<6;x++){const M=x%3;M===0?(o.up.set(0,l[x],0),o.lookAt(c[x],0,0)):M===1?(o.up.set(0,0,l[x]),o.lookAt(0,c[x],0)):(o.up.set(0,l[x],0),o.lookAt(0,0,c[x]));const w=this._cubeSize;Dy(i,M*w,x>2?w:0,w,w),u.setRenderTarget(i),y&&u.render(b,o),u.render(e,o)}b.geometry.dispose(),b.material.dispose(),u.toneMapping=g,u.autoClear=h,e.background=v}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===rm||e.mapping===im;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=C5()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=T5());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new yo(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Dy(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,KT)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),a=M5[(i-1)%M5.length];this._blur(e,i-1,i,s,a)}n.autoClear=r}_blur(e,n,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,n,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,n,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new yo(this._lodPlanes[i],c),g=c.uniforms,m=this._sizeLods[r]-1,b=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Zd-1),y=s/b,v=isFinite(s)?1+Math.floor(u*y):Zd;v>Zd&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Zd}`);const x=[];let M=0;for(let C=0;C<Zd;++C){const j=C/y,N=Math.exp(-j*j/2);x.push(N),C===0?M+=N:C<v&&(M+=2*N)}for(let C=0;C<x.length;C++)x[C]=x[C]/M;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=x,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:w}=this;g.dTheta.value=b,g.mipInt.value=w-r;const T=this._sizeLods[i],A=3*T*(i>w-Tp?i-w+Tp:0),P=4*(this._cubeSize-T);Dy(n,A,P,3*T,2*T),l.setRenderTarget(n),l.render(h,KT)}}function eye(t){const e=[],n=[],r=[];let i=t;const s=t-Tp+1+S5.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);n.push(o);let l=1/o;a>t-Tp?l=S5[a-t+Tp-1]:a===0&&(l=0),r.push(l);const c=1/(o-2),u=-c,h=1+c,g=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,b=6,y=3,v=2,x=1,M=new Float32Array(y*b*m),w=new Float32Array(v*b*m),T=new Float32Array(x*b*m);for(let P=0;P<m;P++){const C=P%3*2/3-1,j=P>2?0:-1,N=[C,j,0,C+2/3,j,0,C+2/3,j+1,0,C,j,0,C+2/3,j+1,0,C,j+1,0];M.set(N,y*b*P),w.set(g,v*b*P);const k=[P,P,P,P,P,P];T.set(k,x*b*P)}const A=new us;A.setAttribute("position",new ha(M,y)),A.setAttribute("uv",new ha(w,v)),A.setAttribute("faceIndex",new ha(T,x)),e.push(A),i>Tp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function A5(t,e,n){const r=new Of(t,e,n);return r.texture.mapping=hw,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Dy(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function tye(t,e,n){const r=new Float32Array(Zd),i=new Ne(0,1,0);return new ed({name:"SphericalGaussianBlur",defines:{n:Zd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ak(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Bu,depthTest:!1,depthWrite:!1})}function T5(){return new ed({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ak(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Bu,depthTest:!1,depthWrite:!1})}function C5(){return new ed({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ak(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Bu,depthTest:!1,depthWrite:!1})}function Ak(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function nye(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,c=l===L3||l===I3,u=l===rm||l===im;if(c||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let h=e.get(o);return n===null&&(n=new E5(t)),h=c?n.fromEquirectangular(o,h):n.fromCubemap(o,h),e.set(o,h),h.texture}else{if(e.has(o))return e.get(o).texture;{const h=o.image;if(c&&h&&h.height>0||u&&h&&i(h)){n===null&&(n=new E5(t));const g=c?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,g),o.addEventListener("dispose",s),g.texture}else return null}}}return o}function i(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function rye(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 iye(t,e,n,r){const i={},s=new WeakMap;function a(h){const g=h.target;g.index!==null&&e.remove(g.index);for(const b in g.attributes)e.remove(g.attributes[b]);for(const b in g.morphAttributes){const y=g.morphAttributes[b];for(let v=0,x=y.length;v<x;v++)e.remove(y[v])}g.removeEventListener("dispose",a),delete i[g.id];const m=s.get(g);m&&(e.remove(m),s.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function o(h,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(h){const g=h.attributes;for(const b in g)e.update(g[b],t.ARRAY_BUFFER);const m=h.morphAttributes;for(const b in m){const y=m[b];for(let v=0,x=y.length;v<x;v++)e.update(y[v],t.ARRAY_BUFFER)}}function c(h){const g=[],m=h.index,b=h.attributes.position;let y=0;if(m!==null){const M=m.array;y=m.version;for(let w=0,T=M.length;w<T;w+=3){const A=M[w+0],P=M[w+1],C=M[w+2];g.push(A,P,P,C,C,A)}}else if(b!==void 0){const M=b.array;y=b.version;for(let w=0,T=M.length/3-1;w<T;w+=3){const A=w+0,P=w+1,C=w+2;g.push(A,P,P,C,C,A)}}else return;const v=new(A7(g)?O7:D7)(g,1);v.version=y;const x=s.get(h);x&&e.remove(x),s.set(h,v)}function u(h){const g=s.get(h);if(g){const m=h.index;m!==null&&g.version<m.version&&c(h)}else c(h);return s.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function sye(t,e,n,r){const i=r.isWebGL2;let s;function a(m){s=m}let o,l;function c(m){o=m.type,l=m.bytesPerElement}function u(m,b){t.drawElements(s,b,o,m*l),n.update(b,s,1)}function h(m,b,y){if(y===0)return;let v,x;if(i)v=t,x="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[x](s,b,o,m*l,y),n.update(b,s,y)}function g(m,b,y){if(y===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<y;x++)this.render(m[x]/l,b[x]);else{v.multiDrawElementsWEBGL(s,b,0,o,m,0,y);let x=0;for(let M=0;M<y;M++)x+=b[M];n.update(x,s,1)}}this.setMode=a,this.setIndex=c,this.render=u,this.renderInstances=h,this.renderMultiDraw=g}function aye(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function oye(t,e){return t[0]-e[0]}function lye(t,e){return Math.abs(e[1])-Math.abs(t[1])}function cye(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,a=new Gn,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,u,h){const g=c.morphTargetInfluences;if(e.isWebGL2===!0){const b=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,y=b!==void 0?b.length:0;let v=s.get(u);if(v===void 0||v.count!==y){let $=function(){W.dispose(),s.delete(u),u.removeEventListener("dispose",$)};var m=$;v!==void 0&&v.texture.dispose();const w=u.morphAttributes.position!==void 0,T=u.morphAttributes.normal!==void 0,A=u.morphAttributes.color!==void 0,P=u.morphAttributes.position||[],C=u.morphAttributes.normal||[],j=u.morphAttributes.color||[];let N=0;w===!0&&(N=1),T===!0&&(N=2),A===!0&&(N=3);let k=u.attributes.position.count*N,F=1;k>e.maxTextureSize&&(F=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const I=new Float32Array(k*F*4*y),W=new N7(I,k,F,y);W.type=nc,W.needsUpdate=!0;const D=N*4;for(let G=0;G<y;G++){const V=P[G],Z=C[G],K=j[G],ee=k*F*4*G;for(let H=0;H<V.count;H++){const Y=H*D;w===!0&&(a.fromBufferAttribute(V,H),I[ee+Y+0]=a.x,I[ee+Y+1]=a.y,I[ee+Y+2]=a.z,I[ee+Y+3]=0),T===!0&&(a.fromBufferAttribute(Z,H),I[ee+Y+4]=a.x,I[ee+Y+5]=a.y,I[ee+Y+6]=a.z,I[ee+Y+7]=0),A===!0&&(a.fromBufferAttribute(K,H),I[ee+Y+8]=a.x,I[ee+Y+9]=a.y,I[ee+Y+10]=a.z,I[ee+Y+11]=K.itemSize===4?a.w:1)}}v={count:y,texture:W,size:new Kt(k,F)},s.set(u,v),u.addEventListener("dispose",$)}let x=0;for(let w=0;w<g.length;w++)x+=g[w];const M=u.morphTargetsRelative?1:1-x;h.getUniforms().setValue(t,"morphTargetBaseInfluence",M),h.getUniforms().setValue(t,"morphTargetInfluences",g),h.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const b=g===void 0?0:g.length;let y=r[u.id];if(y===void 0||y.length!==b){y=[];for(let T=0;T<b;T++)y[T]=[T,0];r[u.id]=y}for(let T=0;T<b;T++){const A=y[T];A[0]=T,A[1]=g[T]}y.sort(lye);for(let T=0;T<8;T++)T<b&&y[T][1]?(o[T][0]=y[T][0],o[T][1]=y[T][1]):(o[T][0]=Number.MAX_SAFE_INTEGER,o[T][1]=0);o.sort(oye);const v=u.morphAttributes.position,x=u.morphAttributes.normal;let M=0;for(let T=0;T<8;T++){const A=o[T],P=A[0],C=A[1];P!==Number.MAX_SAFE_INTEGER&&C?(v&&u.getAttribute("morphTarget"+T)!==v[P]&&u.setAttribute("morphTarget"+T,v[P]),x&&u.getAttribute("morphNormal"+T)!==x[P]&&u.setAttribute("morphNormal"+T,x[P]),i[T]=C,M+=C):(v&&u.hasAttribute("morphTarget"+T)===!0&&u.deleteAttribute("morphTarget"+T),x&&u.hasAttribute("morphNormal"+T)===!0&&u.deleteAttribute("morphNormal"+T),i[T]=0)}const w=u.morphTargetsRelative?1:1-M;h.getUniforms().setValue(t,"morphTargetBaseInfluence",w),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:l}}function uye(t,e,n,r){let i=new WeakMap;function s(l){const c=r.render.frame,u=l.geometry,h=e.get(l,u);if(i.get(h)!==c&&(e.update(h),i.set(h,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,c))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==c&&(g.update(),i.set(g,c))}return h}function a(){i=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:s,dispose:a}}class F7 extends $s{constructor(e,n,r,i,s,a,o,l,c,u){if(u=u!==void 0?u:df,u!==df&&u!==sm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&u===df&&(r=Ou),r===void 0&&u===sm&&(r=uf),super(null,i,s,a,o,l,u,r,c),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Vi,this.minFilter=l!==void 0?l:Vi,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 z7=new $s,B7=new F7(1,1);B7.compareFunction=M7;const H7=new N7,$7=new Xxe,V7=new j7,N5=[],R5=[],P5=new Float32Array(16),k5=new Float32Array(9),D5=new Float32Array(4);function Dm(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=N5[i];if(s===void 0&&(s=new Float32Array(i),N5[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=n,t[a].toArray(s,o)}return s}function ci(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function ui(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function gw(t,e){let n=R5[e];n===void 0&&(n=new Int32Array(e),R5[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function dye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function fye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ci(n,e))return;t.uniform2fv(this.addr,e),ui(n,e)}}function hye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ci(n,e))return;t.uniform3fv(this.addr,e),ui(n,e)}}function pye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ci(n,e))return;t.uniform4fv(this.addr,e),ui(n,e)}}function mye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ci(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ui(n,e)}else{if(ci(n,r))return;D5.set(r),t.uniformMatrix2fv(this.addr,!1,D5),ui(n,r)}}function gye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ci(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ui(n,e)}else{if(ci(n,r))return;k5.set(r),t.uniformMatrix3fv(this.addr,!1,k5),ui(n,r)}}function xye(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ci(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ui(n,e)}else{if(ci(n,r))return;P5.set(r),t.uniformMatrix4fv(this.addr,!1,P5),ui(n,r)}}function vye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function bye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ci(n,e))return;t.uniform2iv(this.addr,e),ui(n,e)}}function yye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ci(n,e))return;t.uniform3iv(this.addr,e),ui(n,e)}}function _ye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ci(n,e))return;t.uniform4iv(this.addr,e),ui(n,e)}}function Sye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function wye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ci(n,e))return;t.uniform2uiv(this.addr,e),ui(n,e)}}function Mye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ci(n,e))return;t.uniform3uiv(this.addr,e),ui(n,e)}}function Eye(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ci(n,e))return;t.uniform4uiv(this.addr,e),ui(n,e)}}function Aye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const s=this.type===t.SAMPLER_2D_SHADOW?B7:z7;n.setTexture2D(e||s,i)}function Tye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||$7,i)}function Cye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||V7,i)}function Nye(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||H7,i)}function Rye(t){switch(t){case 5126:return dye;case 35664:return fye;case 35665:return hye;case 35666:return pye;case 35674:return mye;case 35675:return gye;case 35676:return xye;case 5124:case 35670:return vye;case 35667:case 35671:return bye;case 35668:case 35672:return yye;case 35669:case 35673:return _ye;case 5125:return Sye;case 36294:return wye;case 36295:return Mye;case 36296:return Eye;case 35678:case 36198:case 36298:case 36306:case 35682:return Aye;case 35679:case 36299:case 36307:return Tye;case 35680:case 36300:case 36308:case 36293:return Cye;case 36289:case 36303:case 36311:case 36292:return Nye}}function Pye(t,e){t.uniform1fv(this.addr,e)}function kye(t,e){const n=Dm(e,this.size,2);t.uniform2fv(this.addr,n)}function Dye(t,e){const n=Dm(e,this.size,3);t.uniform3fv(this.addr,n)}function Oye(t,e){const n=Dm(e,this.size,4);t.uniform4fv(this.addr,n)}function Lye(t,e){const n=Dm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Iye(t,e){const n=Dm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function jye(t,e){const n=Dm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Uye(t,e){t.uniform1iv(this.addr,e)}function Fye(t,e){t.uniform2iv(this.addr,e)}function zye(t,e){t.uniform3iv(this.addr,e)}function Bye(t,e){t.uniform4iv(this.addr,e)}function Hye(t,e){t.uniform1uiv(this.addr,e)}function $ye(t,e){t.uniform2uiv(this.addr,e)}function Vye(t,e){t.uniform3uiv(this.addr,e)}function Gye(t,e){t.uniform4uiv(this.addr,e)}function Wye(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||z7,s[a])}function qye(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||$7,s[a])}function Xye(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||V7,s[a])}function Kye(t,e,n){const r=this.cache,i=e.length,s=gw(n,i);ci(r,s)||(t.uniform1iv(this.addr,s),ui(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||H7,s[a])}function Yye(t){switch(t){case 5126:return Pye;case 35664:return kye;case 35665:return Dye;case 35666:return Oye;case 35674:return Lye;case 35675:return Iye;case 35676:return jye;case 5124:case 35670:return Uye;case 35667:case 35671:return Fye;case 35668:case 35672:return zye;case 35669:case 35673:return Bye;case 5125:return Hye;case 36294:return $ye;case 36295:return Vye;case 36296:return Gye;case 35678:case 36198:case 36298:case 36306:case 35682:return Wye;case 35679:case 36299:case 36307:return qye;case 35680:case 36300:case 36308:case 36293:return Xye;case 36289:case 36303:case 36311:case 36292:return Kye}}class Zye{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Rye(n.type)}}class Qye{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Yye(n.type)}}class Jye{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let s=0,a=i.length;s!==a;++s){const o=i[s];o.setValue(e,n[o.id],r)}}}const JT=/(\w+)(\])?(\[|\.)?/g;function O5(t,e){t.seq.push(e),t.map[e.id]=e}function e_e(t,e,n){const r=t.name,i=r.length;for(JT.lastIndex=0;;){const s=JT.exec(r),a=JT.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){O5(n,c===void 0?new Zye(o,t,e):new Qye(o,t,e));break}else{let h=n.map[o];h===void 0&&(h=new Jye(o),O5(n,h)),n=h}}}class D_{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),a=e.getUniformLocation(n,s.name);e_e(s,a,this)}}setValue(e,n,r,i){const s=this.map[n];s!==void 0&&s.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let s=0,a=n.length;s!==a;++s){const o=n[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in n&&r.push(a)}return r}}function L5(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const t_e=37297;let n_e=0;function r_e(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,n.length);for(let a=i;a<s;a++){const o=a+1;r.push(`${o===e?">":" "} ${o}: ${n[a]}`)}return r.join(`
- `)}function i_e(t){const e=$n.getPrimaries($n.workingColorSpace),n=$n.getPrimaries(t);let r;switch(e===n?r="":e===u1&&n===c1?r="LinearDisplayP3ToLinearSRGB":e===c1&&n===u1&&(r="LinearSRGBToLinearDisplayP3"),t){case vc:case pw:return[r,"LinearTransferOETF"];case Gi:case _k:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function I5(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return n.toUpperCase()+`
- `+i+`
- `+r_e(t.getShaderSource(e),a)}else return i}function s_e(t,e){const n=i_e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function a_e(t,e){let n;switch(e){case sxe:n="Linear";break;case axe:n="Reinhard";break;case oxe:n="OptimizedCineon";break;case lxe:n="ACESFilmic";break;case cxe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function o_e(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||t.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(px).join(`
- `)}function l_e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function c_e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const s=t.getActiveAttrib(e,i),a=s.name;let o=1;s.type===t.FLOAT_MAT2&&(o=2),s.type===t.FLOAT_MAT3&&(o=3),s.type===t.FLOAT_MAT4&&(o=4),n[a]={type:s.type,location:t.getAttribLocation(e,a),locationSize:o}}return n}function px(t){return t!==""}function j5(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 U5(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const u_e=/^[ \t]*#include +<([\w\d./]+)>/gm;function H3(t){return t.replace(u_e,f_e)}const d_e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function f_e(t,e){let n=an[e];if(n===void 0){const r=d_e.get(e);if(r!==void 0)n=an[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return H3(n)}const h_e=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function F5(t){return t.replace(h_e,p_e)}function p_e(t,e,n,r){let i="";for(let s=parseInt(e);s<parseInt(n);s++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return i}function z5(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function m_e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===h7?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Dge?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Wl&&(e="SHADOWMAP_TYPE_VSM"),e}function g_e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case rm:case im:e="ENVMAP_TYPE_CUBE";break;case hw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function x_e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case im:e="ENVMAP_MODE_REFRACTION";break}return e}function v_e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case bk:e="ENVMAP_BLENDING_MULTIPLY";break;case rxe:e="ENVMAP_BLENDING_MIX";break;case ixe:e="ENVMAP_BLENDING_ADD";break}return e}function b_e(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}function y_e(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=m_e(n),c=g_e(n),u=x_e(n),h=v_e(n),g=b_e(n),m=n.isWebGL2?"":o_e(n),b=l_e(s),y=i.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(px).join(`
- `),v.length>0&&(v+=`
- `),x=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(px).join(`
- `),x.length>0&&(x+=`
- `)):(v=[z5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(px).join(`
- `),x=[m,z5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",n.envMap?"#define "+h:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Hu?"#define TONE_MAPPING":"",n.toneMapping!==Hu?an.tonemapping_pars_fragment:"",n.toneMapping!==Hu?a_e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,s_e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(px).join(`
- `)),a=H3(a),a=j5(a,n),a=U5(a,n),o=H3(o),o=j5(o,n),o=U5(o,n),a=F5(a),o=F5(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,x=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===i5?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===i5?"":"#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(`
- `)+`
- `+x);const w=M+v+a,T=M+x+o,A=L5(i,i.VERTEX_SHADER,w),P=L5(i,i.FRAGMENT_SHADER,T);i.attachShader(y,A),i.attachShader(y,P),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function C(F){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(y).trim(),W=i.getShaderInfoLog(A).trim(),D=i.getShaderInfoLog(P).trim();let $=!0,G=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if($=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,P);else{const V=I5(i,A,"vertex"),Z=I5(i,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+I+`
- `+V+`
- `+Z)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(W===""||D==="")&&(G=!1);G&&(F.diagnostics={runnable:$,programLog:I,vertexShader:{log:W,prefix:v},fragmentShader:{log:D,prefix:x}})}i.deleteShader(A),i.deleteShader(P),j=new D_(i,y),N=c_e(i,y)}let j;this.getUniforms=function(){return j===void 0&&C(this),j};let N;this.getAttributes=function(){return N===void 0&&C(this),N};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=i.getProgramParameter(y,t_e)),k},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=n_e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=P,this}let __e=0;class S_e{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),s=this._getShaderStage(r),a=this._getShaderCacheForMaterial(e);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new w_e(e),n.set(e,r)),r}}class w_e{constructor(e){this.id=__e++,this.code=e,this.usedTimes=0}}function M_e(t,e,n,r,i,s,a){const o=new R7,l=new S_e,c=[],u=i.isWebGL2,h=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const b={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(N){return N===0?"uv":`uv${N}`}function v(N,k,F,I,W){const D=I.fog,$=W.geometry,G=N.isMeshStandardMaterial?I.environment:null,V=(N.isMeshStandardMaterial?n:e).get(N.envMap||G),Z=V&&V.mapping===hw?V.image.height:null,K=b[N.type];N.precision!==null&&(m=i.getMaxPrecision(N.precision),m!==N.precision&&console.warn("THREE.WebGLProgram.getParameters:",N.precision,"not supported, using",m,"instead."));const ee=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=ee!==void 0?ee.length:0;let Y=0;$.morphAttributes.position!==void 0&&(Y=1),$.morphAttributes.normal!==void 0&&(Y=2),$.morphAttributes.color!==void 0&&(Y=3);let te,ae,fe,Q;if(K){const cn=js[K];te=cn.vertexShader,ae=cn.fragmentShader}else te=N.vertexShader,ae=N.fragmentShader,l.update(N),fe=l.getVertexShaderID(N),Q=l.getFragmentShaderID(N);const me=t.getRenderTarget(),Ee=W.isInstancedMesh===!0,he=W.isBatchedMesh===!0,we=!!N.map,De=!!N.matcap,de=!!V,Le=!!N.aoMap,B=!!N.lightMap,z=!!N.bumpMap,ie=!!N.normalMap,X=!!N.displacementMap,J=!!N.emissiveMap,le=!!N.metalnessMap,Re=!!N.roughnessMap,Ae=N.anisotropy>0,se=N.clearcoat>0,U=N.iridescence>0,L=N.sheen>0,ne=N.transmission>0,ve=Ae&&!!N.anisotropyMap,ye=se&&!!N.clearcoatMap,xe=se&&!!N.clearcoatNormalMap,tt=se&&!!N.clearcoatRoughnessMap,je=U&&!!N.iridescenceMap,Ye=U&&!!N.iridescenceThicknessMap,ot=L&&!!N.sheenColorMap,Fe=L&&!!N.sheenRoughnessMap,ce=!!N.specularMap,Qe=!!N.specularColorMap,Be=!!N.specularIntensityMap,Ke=ne&&!!N.transmissionMap,ct=ne&&!!N.thicknessMap,ue=!!N.gradientMap,Je=!!N.alphaMap,ge=N.alphaTest>0,Ie=!!N.alphaHash,Te=!!N.extensions,be=!!$.attributes.uv1,Ve=!!$.attributes.uv2,ft=!!$.attributes.uv3;let yt=Hu;return N.toneMapped&&(me===null||me.isXRRenderTarget===!0)&&(yt=t.toneMapping),{isWebGL2:u,shaderID:K,shaderType:N.type,shaderName:N.name,vertexShader:te,fragmentShader:ae,defines:N.defines,customVertexShaderID:fe,customFragmentShaderID:Q,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:m,batching:he,instancing:Ee,instancingColor:Ee&&W.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:me===null?t.outputColorSpace:me.isXRRenderTarget===!0?me.texture.colorSpace:vc,map:we,matcap:De,envMap:de,envMapMode:de&&V.mapping,envMapCubeUVHeight:Z,aoMap:Le,lightMap:B,bumpMap:z,normalMap:ie,displacementMap:g&&X,emissiveMap:J,normalMapObjectSpace:ie&&N.normalMapType===_xe,normalMapTangentSpace:ie&&N.normalMapType===w7,metalnessMap:le,roughnessMap:Re,anisotropy:Ae,anisotropyMap:ve,clearcoat:se,clearcoatMap:ye,clearcoatNormalMap:xe,clearcoatRoughnessMap:tt,iridescence:U,iridescenceMap:je,iridescenceThicknessMap:Ye,sheen:L,sheenColorMap:ot,sheenRoughnessMap:Fe,specularMap:ce,specularColorMap:Qe,specularIntensityMap:Be,transmission:ne,transmissionMap:Ke,thicknessMap:ct,gradientMap:ue,opaque:N.transparent===!1&&N.blending===jp,alphaMap:Je,alphaTest:ge,alphaHash:Ie,combine:N.combine,mapUv:we&&y(N.map.channel),aoMapUv:Le&&y(N.aoMap.channel),lightMapUv:B&&y(N.lightMap.channel),bumpMapUv:z&&y(N.bumpMap.channel),normalMapUv:ie&&y(N.normalMap.channel),displacementMapUv:X&&y(N.displacementMap.channel),emissiveMapUv:J&&y(N.emissiveMap.channel),metalnessMapUv:le&&y(N.metalnessMap.channel),roughnessMapUv:Re&&y(N.roughnessMap.channel),anisotropyMapUv:ve&&y(N.anisotropyMap.channel),clearcoatMapUv:ye&&y(N.clearcoatMap.channel),clearcoatNormalMapUv:xe&&y(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&y(N.clearcoatRoughnessMap.channel),iridescenceMapUv:je&&y(N.iridescenceMap.channel),iridescenceThicknessMapUv:Ye&&y(N.iridescenceThicknessMap.channel),sheenColorMapUv:ot&&y(N.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&y(N.sheenRoughnessMap.channel),specularMapUv:ce&&y(N.specularMap.channel),specularColorMapUv:Qe&&y(N.specularColorMap.channel),specularIntensityMapUv:Be&&y(N.specularIntensityMap.channel),transmissionMapUv:Ke&&y(N.transmissionMap.channel),thicknessMapUv:ct&&y(N.thicknessMap.channel),alphaMapUv:Je&&y(N.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(ie||Ae),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,vertexUv1s:be,vertexUv2s:Ve,vertexUv3s:ft,pointsUvs:W.isPoints===!0&&!!$.attributes.uv&&(we||Je),fog:!!D,useFog:N.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:N.flatShading===!0,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:W.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:Y,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:yt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:we&&N.map.isVideoTexture===!0&&$n.getTransfer(N.map.colorSpace)===rr,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Yl,flipSided:N.side===Hs,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionDerivatives:Te&&N.extensions.derivatives===!0,extensionFragDepth:Te&&N.extensions.fragDepth===!0,extensionDrawBuffers:Te&&N.extensions.drawBuffers===!0,extensionShaderTextureLOD:Te&&N.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()}}function x(N){const k=[];if(N.shaderID?k.push(N.shaderID):(k.push(N.customVertexShaderID),k.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)k.push(F),k.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(M(k,N),w(k,N),k.push(t.outputColorSpace)),k.push(N.customProgramCacheKey),k.join()}function M(N,k){N.push(k.precision),N.push(k.outputColorSpace),N.push(k.envMapMode),N.push(k.envMapCubeUVHeight),N.push(k.mapUv),N.push(k.alphaMapUv),N.push(k.lightMapUv),N.push(k.aoMapUv),N.push(k.bumpMapUv),N.push(k.normalMapUv),N.push(k.displacementMapUv),N.push(k.emissiveMapUv),N.push(k.metalnessMapUv),N.push(k.roughnessMapUv),N.push(k.anisotropyMapUv),N.push(k.clearcoatMapUv),N.push(k.clearcoatNormalMapUv),N.push(k.clearcoatRoughnessMapUv),N.push(k.iridescenceMapUv),N.push(k.iridescenceThicknessMapUv),N.push(k.sheenColorMapUv),N.push(k.sheenRoughnessMapUv),N.push(k.specularMapUv),N.push(k.specularColorMapUv),N.push(k.specularIntensityMapUv),N.push(k.transmissionMapUv),N.push(k.thicknessMapUv),N.push(k.combine),N.push(k.fogExp2),N.push(k.sizeAttenuation),N.push(k.morphTargetsCount),N.push(k.morphAttributeCount),N.push(k.numDirLights),N.push(k.numPointLights),N.push(k.numSpotLights),N.push(k.numSpotLightMaps),N.push(k.numHemiLights),N.push(k.numRectAreaLights),N.push(k.numDirLightShadows),N.push(k.numPointLightShadows),N.push(k.numSpotLightShadows),N.push(k.numSpotLightShadowsWithMaps),N.push(k.numLightProbes),N.push(k.shadowMapType),N.push(k.toneMapping),N.push(k.numClippingPlanes),N.push(k.numClipIntersection),N.push(k.depthPacking)}function w(N,k){o.disableAll(),k.isWebGL2&&o.enable(0),k.supportsVertexTextures&&o.enable(1),k.instancing&&o.enable(2),k.instancingColor&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),N.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.skinning&&o.enable(4),k.morphTargets&&o.enable(5),k.morphNormals&&o.enable(6),k.morphColors&&o.enable(7),k.premultipliedAlpha&&o.enable(8),k.shadowMapEnabled&&o.enable(9),k.useLegacyLights&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),N.push(o.mask)}function T(N){const k=b[N.type];let F;if(k){const I=js[k];F=Mk.clone(I.uniforms)}else F=N.uniforms;return F}function A(N,k){let F;for(let I=0,W=c.length;I<W;I++){const D=c[I];if(D.cacheKey===k){F=D,++F.usedTimes;break}}return F===void 0&&(F=new y_e(t,k,N,s),c.push(F)),F}function P(N){if(--N.usedTimes===0){const k=c.indexOf(N);c[k]=c[c.length-1],c.pop(),N.destroy()}}function C(N){l.remove(N)}function j(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:T,acquireProgram:A,releaseProgram:P,releaseShaderCache:C,programs:c,dispose:j}}function E_e(){let t=new WeakMap;function e(s){let a=t.get(s);return a===void 0&&(a={},t.set(s,a)),a}function n(s){t.delete(s)}function r(s,a,o){t.get(s)[a]=o}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function A_e(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function B5(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 H5(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(h,g,m,b,y,v){let x=t[e];return x===void 0?(x={id:h.id,object:h,geometry:g,material:m,groupOrder:b,renderOrder:h.renderOrder,z:y,group:v},t[e]=x):(x.id=h.id,x.object=h,x.geometry=g,x.material=m,x.groupOrder=b,x.renderOrder=h.renderOrder,x.z=y,x.group=v),e++,x}function o(h,g,m,b,y,v){const x=a(h,g,m,b,y,v);m.transmission>0?r.push(x):m.transparent===!0?i.push(x):n.push(x)}function l(h,g,m,b,y,v){const x=a(h,g,m,b,y,v);m.transmission>0?r.unshift(x):m.transparent===!0?i.unshift(x):n.unshift(x)}function c(h,g){n.length>1&&n.sort(h||A_e),r.length>1&&r.sort(g||B5),i.length>1&&i.sort(g||B5)}function u(){for(let h=e,g=t.length;h<g;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:u,sort:c}}function T_e(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new H5,t.set(r,[a])):i>=s.length?(a=new H5,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function C_e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Ne,color:new Bt};break;case"SpotLight":n={position:new Ne,direction:new Ne,color:new Bt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ne,color:new Bt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ne,skyColor:new Bt,groundColor:new Bt};break;case"RectAreaLight":n={color:new Bt,position:new Ne,halfWidth:new Ne,halfHeight:new Ne};break}return t[e.id]=n,n}}}function N_e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Kt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let R_e=0;function P_e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function k_e(t,e){const n=new C_e,r=N_e(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)i.probe.push(new Ne);const s=new Ne,a=new Jn,o=new Jn;function l(u,h){let g=0,m=0,b=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let y=0,v=0,x=0,M=0,w=0,T=0,A=0,P=0,C=0,j=0,N=0;u.sort(P_e);const k=h===!0?Math.PI:1;for(let I=0,W=u.length;I<W;I++){const D=u[I],$=D.color,G=D.intensity,V=D.distance,Z=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)g+=$.r*G*k,m+=$.g*G*k,b+=$.b*G*k;else if(D.isLightProbe){for(let K=0;K<9;K++)i.probe[K].addScaledVector(D.sh.coefficients[K],G);N++}else if(D.isDirectionalLight){const K=n.get(D);if(K.color.copy(D.color).multiplyScalar(D.intensity*k),D.castShadow){const ee=D.shadow,H=r.get(D);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,i.directionalShadow[y]=H,i.directionalShadowMap[y]=Z,i.directionalShadowMatrix[y]=D.shadow.matrix,T++}i.directional[y]=K,y++}else if(D.isSpotLight){const K=n.get(D);K.position.setFromMatrixPosition(D.matrixWorld),K.color.copy($).multiplyScalar(G*k),K.distance=V,K.coneCos=Math.cos(D.angle),K.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),K.decay=D.decay,i.spot[x]=K;const ee=D.shadow;if(D.map&&(i.spotLightMap[C]=D.map,C++,ee.updateMatrices(D),D.castShadow&&j++),i.spotLightMatrix[x]=ee.matrix,D.castShadow){const H=r.get(D);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,i.spotShadow[x]=H,i.spotShadowMap[x]=Z,P++}x++}else if(D.isRectAreaLight){const K=n.get(D);K.color.copy($).multiplyScalar(G),K.halfWidth.set(D.width*.5,0,0),K.halfHeight.set(0,D.height*.5,0),i.rectArea[M]=K,M++}else if(D.isPointLight){const K=n.get(D);if(K.color.copy(D.color).multiplyScalar(D.intensity*k),K.distance=D.distance,K.decay=D.decay,D.castShadow){const ee=D.shadow,H=r.get(D);H.shadowBias=ee.bias,H.shadowNormalBias=ee.normalBias,H.shadowRadius=ee.radius,H.shadowMapSize=ee.mapSize,H.shadowCameraNear=ee.camera.near,H.shadowCameraFar=ee.camera.far,i.pointShadow[v]=H,i.pointShadowMap[v]=Z,i.pointShadowMatrix[v]=D.shadow.matrix,A++}i.point[v]=K,v++}else if(D.isHemisphereLight){const K=n.get(D);K.skyColor.copy(D.color).multiplyScalar(G*k),K.groundColor.copy(D.groundColor).multiplyScalar(G*k),i.hemi[w]=K,w++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=bt.LTC_FLOAT_1,i.rectAreaLTC2=bt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=bt.LTC_HALF_1,i.rectAreaLTC2=bt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=m,i.ambient[2]=b;const F=i.hash;(F.directionalLength!==y||F.pointLength!==v||F.spotLength!==x||F.rectAreaLength!==M||F.hemiLength!==w||F.numDirectionalShadows!==T||F.numPointShadows!==A||F.numSpotShadows!==P||F.numSpotMaps!==C||F.numLightProbes!==N)&&(i.directional.length=y,i.spot.length=x,i.rectArea.length=M,i.point.length=v,i.hemi.length=w,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=P,i.spotShadowMap.length=P,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=P+C-j,i.spotLightMap.length=C,i.numSpotLightShadowsWithMaps=j,i.numLightProbes=N,F.directionalLength=y,F.pointLength=v,F.spotLength=x,F.rectAreaLength=M,F.hemiLength=w,F.numDirectionalShadows=T,F.numPointShadows=A,F.numSpotShadows=P,F.numSpotMaps=C,F.numLightProbes=N,i.version=R_e++)}function c(u,h){let g=0,m=0,b=0,y=0,v=0;const x=h.matrixWorldInverse;for(let M=0,w=u.length;M<w;M++){const T=u[M];if(T.isDirectionalLight){const A=i.directional[g];A.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),A.direction.sub(s),A.direction.transformDirection(x),g++}else if(T.isSpotLight){const A=i.spot[b];A.position.setFromMatrixPosition(T.matrixWorld),A.position.applyMatrix4(x),A.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),A.direction.sub(s),A.direction.transformDirection(x),b++}else if(T.isRectAreaLight){const A=i.rectArea[y];A.position.setFromMatrixPosition(T.matrixWorld),A.position.applyMatrix4(x),o.identity(),a.copy(T.matrixWorld),a.premultiply(x),o.extractRotation(a),A.halfWidth.set(T.width*.5,0,0),A.halfHeight.set(0,T.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),y++}else if(T.isPointLight){const A=i.point[m];A.position.setFromMatrixPosition(T.matrixWorld),A.position.applyMatrix4(x),m++}else if(T.isHemisphereLight){const A=i.hemi[v];A.direction.setFromMatrixPosition(T.matrixWorld),A.direction.transformDirection(x),v++}}}return{setup:l,setupView:c,state:i}}function $5(t,e){const n=new k_e(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function a(h){r.push(h)}function o(h){i.push(h)}function l(h){n.setup(r,h)}function c(h){n.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function D_e(t,e){let n=new WeakMap;function r(s,a=0){const o=n.get(s);let l;return o===void 0?(l=new $5(t,e),n.set(s,[l])):a>=o.length?(l=new $5(t,e),o.push(l)):l=o[a],l}function i(){n=new WeakMap}return{get:r,dispose:i}}class O_e extends km{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bxe,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 L_e extends km{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 I_e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,j_e=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function U_e(t,e,n){let r=new mw;const i=new Kt,s=new Kt,a=new Gn,o=new O_e({depthPacking:yxe}),l=new L_e,c={},u=n.maxTextureSize,h={[Ju]:Hs,[Hs]:Ju,[Yl]:Yl},g=new ed({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Kt},radius:{value:4}},vertexShader:I_e,fragmentShader:j_e}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const b=new us;b.setAttribute("position",new ha(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new yo(b,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=h7;let x=this.type;this.render=function(A,P,C){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||A.length===0)return;const j=t.getRenderTarget(),N=t.getActiveCubeFace(),k=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Bu),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const I=x!==Wl&&this.type===Wl,W=x===Wl&&this.type!==Wl;for(let D=0,$=A.length;D<$;D++){const G=A[D],V=G.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",G,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Z=V.getFrameExtents();if(i.multiply(Z),s.copy(V.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/Z.x),i.x=s.x*Z.x,V.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/Z.y),i.y=s.y*Z.y,V.mapSize.y=s.y)),V.map===null||I===!0||W===!0){const ee=this.type!==Wl?{minFilter:Vi,magFilter:Vi}:{};V.map!==null&&V.map.dispose(),V.map=new Of(i.x,i.y,ee),V.map.texture.name=G.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const K=V.getViewportCount();for(let ee=0;ee<K;ee++){const H=V.getViewport(ee);a.set(s.x*H.x,s.y*H.y,s.x*H.z,s.y*H.w),F.viewport(a),V.updateMatrices(G,ee),r=V.getFrustum(),T(P,C,V.camera,G,this.type)}V.isPointLightShadow!==!0&&this.type===Wl&&M(V,C),V.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(j,N,k)};function M(A,P){const C=e.update(y);g.defines.VSM_SAMPLES!==A.blurSamples&&(g.defines.VSM_SAMPLES=A.blurSamples,m.defines.VSM_SAMPLES=A.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new Of(i.x,i.y)),g.uniforms.shadow_pass.value=A.map.texture,g.uniforms.resolution.value=A.mapSize,g.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(P,null,C,g,y,null),m.uniforms.shadow_pass.value=A.mapPass.texture,m.uniforms.resolution.value=A.mapSize,m.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(P,null,C,m,y,null)}function w(A,P,C,j){let N=null;const k=C.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(k!==void 0)N=k;else if(N=C.isPointLight===!0?l:o,t.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0){const F=N.uuid,I=P.uuid;let W=c[F];W===void 0&&(W={},c[F]=W);let D=W[I];D===void 0&&(D=N.clone(),W[I]=D),N=D}if(N.visible=P.visible,N.wireframe=P.wireframe,j===Wl?N.side=P.shadowSide!==null?P.shadowSide:P.side:N.side=P.shadowSide!==null?P.shadowSide:h[P.side],N.alphaMap=P.alphaMap,N.alphaTest=P.alphaTest,N.map=P.map,N.clipShadows=P.clipShadows,N.clippingPlanes=P.clippingPlanes,N.clipIntersection=P.clipIntersection,N.displacementMap=P.displacementMap,N.displacementScale=P.displacementScale,N.displacementBias=P.displacementBias,N.wireframeLinewidth=P.wireframeLinewidth,N.linewidth=P.linewidth,C.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const F=t.properties.get(N);F.light=C}return N}function T(A,P,C,j,N){if(A.visible===!1)return;if(A.layers.test(P.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&N===Wl)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,A.matrixWorld);const I=e.update(A),W=A.material;if(Array.isArray(W)){const D=I.groups;for(let $=0,G=D.length;$<G;$++){const V=D[$],Z=W[V.materialIndex];if(Z&&Z.visible){const K=w(A,Z,j,N);A.onBeforeShadow(t,A,P,C,I,K,V),t.renderBufferDirect(C,null,I,K,A,V),A.onAfterShadow(t,A,P,C,I,K,V)}}}else if(W.visible){const D=w(A,W,j,N);A.onBeforeShadow(t,A,P,C,I,D,null),t.renderBufferDirect(C,null,I,D,A,null),A.onAfterShadow(t,A,P,C,I,D,null)}}const F=A.children;for(let I=0,W=F.length;I<W;I++)T(F[I],P,C,j,N)}}function F_e(t,e,n){const r=n.isWebGL2;function i(){let ge=!1;const Ie=new Gn;let Te=null;const be=new Gn(0,0,0,0);return{setMask:function(Ve){Te!==Ve&&!ge&&(t.colorMask(Ve,Ve,Ve,Ve),Te=Ve)},setLocked:function(Ve){ge=Ve},setClear:function(Ve,ft,yt,Pt,cn){cn===!0&&(Ve*=Pt,ft*=Pt,yt*=Pt),Ie.set(Ve,ft,yt,Pt),be.equals(Ie)===!1&&(t.clearColor(Ve,ft,yt,Pt),be.copy(Ie))},reset:function(){ge=!1,Te=null,be.set(-1,0,0,0)}}}function s(){let ge=!1,Ie=null,Te=null,be=null;return{setTest:function(Ve){Ve?he(t.DEPTH_TEST):we(t.DEPTH_TEST)},setMask:function(Ve){Ie!==Ve&&!ge&&(t.depthMask(Ve),Ie=Ve)},setFunc:function(Ve){if(Te!==Ve){switch(Ve){case Yge:t.depthFunc(t.NEVER);break;case Zge:t.depthFunc(t.ALWAYS);break;case Qge:t.depthFunc(t.LESS);break;case o1:t.depthFunc(t.LEQUAL);break;case Jge:t.depthFunc(t.EQUAL);break;case exe:t.depthFunc(t.GEQUAL);break;case txe:t.depthFunc(t.GREATER);break;case nxe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Te=Ve}},setLocked:function(Ve){ge=Ve},setClear:function(Ve){be!==Ve&&(t.clearDepth(Ve),be=Ve)},reset:function(){ge=!1,Ie=null,Te=null,be=null}}}function a(){let ge=!1,Ie=null,Te=null,be=null,Ve=null,ft=null,yt=null,Pt=null,cn=null;return{setTest:function(Ot){ge||(Ot?he(t.STENCIL_TEST):we(t.STENCIL_TEST))},setMask:function(Ot){Ie!==Ot&&!ge&&(t.stencilMask(Ot),Ie=Ot)},setFunc:function(Ot,Pn,qn){(Te!==Ot||be!==Pn||Ve!==qn)&&(t.stencilFunc(Ot,Pn,qn),Te=Ot,be=Pn,Ve=qn)},setOp:function(Ot,Pn,qn){(ft!==Ot||yt!==Pn||Pt!==qn)&&(t.stencilOp(Ot,Pn,qn),ft=Ot,yt=Pn,Pt=qn)},setLocked:function(Ot){ge=Ot},setClear:function(Ot){cn!==Ot&&(t.clearStencil(Ot),cn=Ot)},reset:function(){ge=!1,Ie=null,Te=null,be=null,Ve=null,ft=null,yt=null,Pt=null,cn=null}}}const o=new i,l=new s,c=new a,u=new WeakMap,h=new WeakMap;let g={},m={},b=new WeakMap,y=[],v=null,x=!1,M=null,w=null,T=null,A=null,P=null,C=null,j=null,N=new Bt(0,0,0),k=0,F=!1,I=null,W=null,D=null,$=null,G=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,K=0;const ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(ee)[1]),Z=K>=1):ee.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),Z=K>=2);let H=null,Y={};const te=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),fe=new Gn().fromArray(te),Q=new Gn().fromArray(ae);function me(ge,Ie,Te,be){const Ve=new Uint8Array(4),ft=t.createTexture();t.bindTexture(ge,ft),t.texParameteri(ge,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ge,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let yt=0;yt<Te;yt++)r&&(ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ie,0,t.RGBA,1,1,be,0,t.RGBA,t.UNSIGNED_BYTE,Ve):t.texImage2D(Ie+yt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ve);return ft}const Ee={};Ee[t.TEXTURE_2D]=me(t.TEXTURE_2D,t.TEXTURE_2D,1),Ee[t.TEXTURE_CUBE_MAP]=me(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ee[t.TEXTURE_2D_ARRAY]=me(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ee[t.TEXTURE_3D]=me(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),he(t.DEPTH_TEST),l.setFunc(o1),J(!1),le(Ez),he(t.CULL_FACE),ie(Bu);function he(ge){g[ge]!==!0&&(t.enable(ge),g[ge]=!0)}function we(ge){g[ge]!==!1&&(t.disable(ge),g[ge]=!1)}function De(ge,Ie){return m[ge]!==Ie?(t.bindFramebuffer(ge,Ie),m[ge]=Ie,r&&(ge===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ie),ge===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ie)),!0):!1}function de(ge,Ie){let Te=y,be=!1;if(ge)if(Te=b.get(Ie),Te===void 0&&(Te=[],b.set(Ie,Te)),ge.isWebGLMultipleRenderTargets){const Ve=ge.texture;if(Te.length!==Ve.length||Te[0]!==t.COLOR_ATTACHMENT0){for(let ft=0,yt=Ve.length;ft<yt;ft++)Te[ft]=t.COLOR_ATTACHMENT0+ft;Te.length=Ve.length,be=!0}}else Te[0]!==t.COLOR_ATTACHMENT0&&(Te[0]=t.COLOR_ATTACHMENT0,be=!0);else Te[0]!==t.BACK&&(Te[0]=t.BACK,be=!0);be&&(n.isWebGL2?t.drawBuffers(Te):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Te))}function Le(ge){return v!==ge?(t.useProgram(ge),v=ge,!0):!1}const B={[Yd]:t.FUNC_ADD,[Lge]:t.FUNC_SUBTRACT,[Ige]:t.FUNC_REVERSE_SUBTRACT};if(r)B[Nz]=t.MIN,B[Rz]=t.MAX;else{const ge=e.get("EXT_blend_minmax");ge!==null&&(B[Nz]=ge.MIN_EXT,B[Rz]=ge.MAX_EXT)}const z={[jge]:t.ZERO,[Uge]:t.ONE,[Fge]:t.SRC_COLOR,[D3]:t.SRC_ALPHA,[Gge]:t.SRC_ALPHA_SATURATE,[$ge]:t.DST_COLOR,[Bge]:t.DST_ALPHA,[zge]:t.ONE_MINUS_SRC_COLOR,[O3]:t.ONE_MINUS_SRC_ALPHA,[Vge]:t.ONE_MINUS_DST_COLOR,[Hge]:t.ONE_MINUS_DST_ALPHA,[Wge]:t.CONSTANT_COLOR,[qge]:t.ONE_MINUS_CONSTANT_COLOR,[Xge]:t.CONSTANT_ALPHA,[Kge]:t.ONE_MINUS_CONSTANT_ALPHA};function ie(ge,Ie,Te,be,Ve,ft,yt,Pt,cn,Ot){if(ge===Bu){x===!0&&(we(t.BLEND),x=!1);return}if(x===!1&&(he(t.BLEND),x=!0),ge!==Oge){if(ge!==M||Ot!==F){if((w!==Yd||P!==Yd)&&(t.blendEquation(t.FUNC_ADD),w=Yd,P=Yd),Ot)switch(ge){case jp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Az:t.blendFunc(t.ONE,t.ONE);break;case Tz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case Cz: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 jp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Az:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case Tz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case Cz:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}T=null,A=null,C=null,j=null,N.set(0,0,0),k=0,M=ge,F=Ot}return}Ve=Ve||Ie,ft=ft||Te,yt=yt||be,(Ie!==w||Ve!==P)&&(t.blendEquationSeparate(B[Ie],B[Ve]),w=Ie,P=Ve),(Te!==T||be!==A||ft!==C||yt!==j)&&(t.blendFuncSeparate(z[Te],z[be],z[ft],z[yt]),T=Te,A=be,C=ft,j=yt),(Pt.equals(N)===!1||cn!==k)&&(t.blendColor(Pt.r,Pt.g,Pt.b,cn),N.copy(Pt),k=cn),M=ge,F=!1}function X(ge,Ie){ge.side===Yl?we(t.CULL_FACE):he(t.CULL_FACE);let Te=ge.side===Hs;Ie&&(Te=!Te),J(Te),ge.blending===jp&&ge.transparent===!1?ie(Bu):ie(ge.blending,ge.blendEquation,ge.blendSrc,ge.blendDst,ge.blendEquationAlpha,ge.blendSrcAlpha,ge.blendDstAlpha,ge.blendColor,ge.blendAlpha,ge.premultipliedAlpha),l.setFunc(ge.depthFunc),l.setTest(ge.depthTest),l.setMask(ge.depthWrite),o.setMask(ge.colorWrite);const be=ge.stencilWrite;c.setTest(be),be&&(c.setMask(ge.stencilWriteMask),c.setFunc(ge.stencilFunc,ge.stencilRef,ge.stencilFuncMask),c.setOp(ge.stencilFail,ge.stencilZFail,ge.stencilZPass)),Ae(ge.polygonOffset,ge.polygonOffsetFactor,ge.polygonOffsetUnits),ge.alphaToCoverage===!0?he(t.SAMPLE_ALPHA_TO_COVERAGE):we(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(ge){I!==ge&&(ge?t.frontFace(t.CW):t.frontFace(t.CCW),I=ge)}function le(ge){ge!==Pge?(he(t.CULL_FACE),ge!==W&&(ge===Ez?t.cullFace(t.BACK):ge===kge?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):we(t.CULL_FACE),W=ge}function Re(ge){ge!==D&&(Z&&t.lineWidth(ge),D=ge)}function Ae(ge,Ie,Te){ge?(he(t.POLYGON_OFFSET_FILL),($!==Ie||G!==Te)&&(t.polygonOffset(Ie,Te),$=Ie,G=Te)):we(t.POLYGON_OFFSET_FILL)}function se(ge){ge?he(t.SCISSOR_TEST):we(t.SCISSOR_TEST)}function U(ge){ge===void 0&&(ge=t.TEXTURE0+V-1),H!==ge&&(t.activeTexture(ge),H=ge)}function L(ge,Ie,Te){Te===void 0&&(H===null?Te=t.TEXTURE0+V-1:Te=H);let be=Y[Te];be===void 0&&(be={type:void 0,texture:void 0},Y[Te]=be),(be.type!==ge||be.texture!==Ie)&&(H!==Te&&(t.activeTexture(Te),H=Te),t.bindTexture(ge,Ie||Ee[ge]),be.type=ge,be.texture=Ie)}function ne(){const ge=Y[H];ge!==void 0&&ge.type!==void 0&&(t.bindTexture(ge.type,null),ge.type=void 0,ge.texture=void 0)}function ve(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ye(){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 tt(){try{t.texSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function je(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ye(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ot(){try{t.texStorage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Fe(){try{t.texStorage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ce(){try{t.texImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Qe(){try{t.texImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Be(ge){fe.equals(ge)===!1&&(t.scissor(ge.x,ge.y,ge.z,ge.w),fe.copy(ge))}function Ke(ge){Q.equals(ge)===!1&&(t.viewport(ge.x,ge.y,ge.z,ge.w),Q.copy(ge))}function ct(ge,Ie){let Te=h.get(Ie);Te===void 0&&(Te=new WeakMap,h.set(Ie,Te));let be=Te.get(ge);be===void 0&&(be=t.getUniformBlockIndex(Ie,ge.name),Te.set(ge,be))}function ue(ge,Ie){const be=h.get(Ie).get(ge);u.get(Ie)!==be&&(t.uniformBlockBinding(Ie,be,ge.__bindingPointIndex),u.set(Ie,be))}function Je(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},H=null,Y={},m={},b=new WeakMap,y=[],v=null,x=!1,M=null,w=null,T=null,A=null,P=null,C=null,j=null,N=new Bt(0,0,0),k=0,F=!1,I=null,W=null,D=null,$=null,G=null,fe.set(0,0,t.canvas.width,t.canvas.height),Q.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:he,disable:we,bindFramebuffer:De,drawBuffers:de,useProgram:Le,setBlending:ie,setMaterial:X,setFlipSided:J,setCullFace:le,setLineWidth:Re,setPolygonOffset:Ae,setScissorTest:se,activeTexture:U,bindTexture:L,unbindTexture:ne,compressedTexImage2D:ve,compressedTexImage3D:ye,texImage2D:ce,texImage3D:Qe,updateUBOMapping:ct,uniformBlockBinding:ue,texStorage2D:ot,texStorage3D:Fe,texSubImage2D:xe,texSubImage3D:tt,compressedTexSubImage2D:je,compressedTexSubImage3D:Ye,scissor:Be,viewport:Ke,reset:Je}}function z_e(t,e,n,r,i,s,a){const o=i.isWebGL2,l=i.maxTextures,c=i.maxCubemapSize,u=i.maxTextureSize,h=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),b=new WeakMap;let y;const v=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(U,L){return x?new OffscreenCanvas(U,L):f1("canvas")}function w(U,L,ne,ve){let ye=1;if((U.width>ve||U.height>ve)&&(ye=ve/Math.max(U.width,U.height)),ye<1||L===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const xe=L?d1:Math.floor,tt=xe(ye*U.width),je=xe(ye*U.height);y===void 0&&(y=M(tt,je));const Ye=ne?M(tt,je):y;return Ye.width=tt,Ye.height=je,Ye.getContext("2d").drawImage(U,0,0,tt,je),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+tt+"x"+je+")."),Ye}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function T(U){return B3(U.width)&&B3(U.height)}function A(U){return o?!1:U.wrapS!==po||U.wrapT!==po||U.minFilter!==Vi&&U.minFilter!==Fa}function P(U,L){return U.generateMipmaps&&L&&U.minFilter!==Vi&&U.minFilter!==Fa}function C(U){t.generateMipmap(U)}function j(U,L,ne,ve,ye=!1){if(o===!1)return L;if(U!==null){if(t[U]!==void 0)return t[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let xe=L;if(L===t.RED&&(ne===t.FLOAT&&(xe=t.R32F),ne===t.HALF_FLOAT&&(xe=t.R16F),ne===t.UNSIGNED_BYTE&&(xe=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(xe=t.R8UI),ne===t.UNSIGNED_SHORT&&(xe=t.R16UI),ne===t.UNSIGNED_INT&&(xe=t.R32UI),ne===t.BYTE&&(xe=t.R8I),ne===t.SHORT&&(xe=t.R16I),ne===t.INT&&(xe=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(xe=t.RG32F),ne===t.HALF_FLOAT&&(xe=t.RG16F),ne===t.UNSIGNED_BYTE&&(xe=t.RG8)),L===t.RGBA){const tt=ye?l1:$n.getTransfer(ve);ne===t.FLOAT&&(xe=t.RGBA32F),ne===t.HALF_FLOAT&&(xe=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(xe=tt===rr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(xe=t.RGBA4),ne===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(U,L,ne){return P(U,ne)===!0||U.isFramebufferTexture&&U.minFilter!==Vi&&U.minFilter!==Fa?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function k(U){return U===Vi||U===Pz||U===AT?t.NEAREST:t.LINEAR}function F(U){const L=U.target;L.removeEventListener("dispose",F),W(L),L.isVideoTexture&&b.delete(L)}function I(U){const L=U.target;L.removeEventListener("dispose",I),$(L)}function W(U){const L=r.get(U);if(L.__webglInit===void 0)return;const ne=U.source,ve=v.get(ne);if(ve){const ye=ve[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&D(U),Object.keys(ve).length===0&&v.delete(ne)}r.remove(U)}function D(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const ne=U.source,ve=v.get(ne);delete ve[L.__cacheKey],a.memory.textures--}function $(U){const L=U.texture,ne=r.get(U),ve=r.get(L);if(ve.__webglTexture!==void 0&&(t.deleteTexture(ve.__webglTexture),a.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(ne.__webglFramebuffer[ye]))for(let xe=0;xe<ne.__webglFramebuffer[ye].length;xe++)t.deleteFramebuffer(ne.__webglFramebuffer[ye][xe]);else t.deleteFramebuffer(ne.__webglFramebuffer[ye]);ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer[ye])}else{if(Array.isArray(ne.__webglFramebuffer))for(let ye=0;ye<ne.__webglFramebuffer.length;ye++)t.deleteFramebuffer(ne.__webglFramebuffer[ye]);else t.deleteFramebuffer(ne.__webglFramebuffer);if(ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let ye=0;ye<ne.__webglColorRenderbuffer.length;ye++)ne.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(ne.__webglColorRenderbuffer[ye]);ne.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let ye=0,xe=L.length;ye<xe;ye++){const tt=r.get(L[ye]);tt.__webglTexture&&(t.deleteTexture(tt.__webglTexture),a.memory.textures--),r.remove(L[ye])}r.remove(L),r.remove(U)}let G=0;function V(){G=0}function Z(){const U=G;return U>=l&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+l),G+=1,U}function K(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function ee(U,L){const ne=r.get(U);if(U.isVideoTexture&&Ae(U),U.isRenderTargetTexture===!1&&U.version>0&&ne.__version!==U.version){const ve=U.image;if(ve===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{he(ne,U,L);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function H(U,L){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){he(ne,U,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function Y(U,L){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){he(ne,U,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function te(U,L){const ne=r.get(U);if(U.version>0&&ne.__version!==U.version){we(ne,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const ae={[j3]:t.REPEAT,[po]:t.CLAMP_TO_EDGE,[U3]:t.MIRRORED_REPEAT},fe={[Vi]:t.NEAREST,[Pz]:t.NEAREST_MIPMAP_NEAREST,[AT]:t.NEAREST_MIPMAP_LINEAR,[Fa]:t.LINEAR,[uxe]:t.LINEAR_MIPMAP_NEAREST,[a0]:t.LINEAR_MIPMAP_LINEAR},Q={[Sxe]:t.NEVER,[Cxe]:t.ALWAYS,[wxe]:t.LESS,[M7]:t.LEQUAL,[Mxe]:t.EQUAL,[Txe]:t.GEQUAL,[Exe]:t.GREATER,[Axe]:t.NOTEQUAL};function me(U,L,ne){if(ne?(t.texParameteri(U,t.TEXTURE_WRAP_S,ae[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,ae[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,ae[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,fe[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,fe[L.minFilter])):(t.texParameteri(U,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(U,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==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(U,t.TEXTURE_MAG_FILTER,k(L.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,k(L.minFilter)),L.minFilter!==Vi&&L.minFilter!==Fa&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,Q[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ve=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Vi||L.minFilter!==AT&&L.minFilter!==a0||L.type===nc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===o0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(U,ve.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ee(U,L){let ne=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",F));const ve=L.source;let ye=v.get(ve);ye===void 0&&(ye={},v.set(ve,ye));const xe=K(L);if(xe!==U.__cacheKey){ye[xe]===void 0&&(ye[xe]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,ne=!0),ye[xe].usedTimes++;const tt=ye[U.__cacheKey];tt!==void 0&&(ye[U.__cacheKey].usedTimes--,tt.usedTimes===0&&D(L)),U.__cacheKey=xe,U.__webglTexture=ye[xe].texture}return ne}function he(U,L,ne){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const ye=Ee(U,L),xe=L.source;n.bindTexture(ve,U.__webglTexture,t.TEXTURE0+ne);const tt=r.get(xe);if(xe.version!==tt.__version||ye===!0){n.activeTexture(t.TEXTURE0+ne);const je=$n.getPrimaries($n.workingColorSpace),Ye=L.colorSpace===Ba?null:$n.getPrimaries(L.colorSpace),ot=L.colorSpace===Ba||je===Ye?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ot);const Fe=A(L)&&T(L.image)===!1;let ce=w(L.image,Fe,!1,u);ce=se(L,ce);const Qe=T(ce)||o,Be=s.convert(L.format,L.colorSpace);let Ke=s.convert(L.type),ct=j(L.internalFormat,Be,Ke,L.colorSpace,L.isVideoTexture);me(ve,L,Qe);let ue;const Je=L.mipmaps,ge=o&&L.isVideoTexture!==!0&&ct!==_7,Ie=tt.__version===void 0||ye===!0,Te=N(L,ce,Qe);if(L.isDepthTexture)ct=t.DEPTH_COMPONENT,o?L.type===nc?ct=t.DEPTH_COMPONENT32F:L.type===Ou?ct=t.DEPTH_COMPONENT24:L.type===uf?ct=t.DEPTH24_STENCIL8:ct=t.DEPTH_COMPONENT16:L.type===nc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===df&&ct===t.DEPTH_COMPONENT&&L.type!==yk&&L.type!==Ou&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Ou,Ke=s.convert(L.type)),L.format===sm&&ct===t.DEPTH_COMPONENT&&(ct=t.DEPTH_STENCIL,L.type!==uf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=uf,Ke=s.convert(L.type))),Ie&&(ge?n.texStorage2D(t.TEXTURE_2D,1,ct,ce.width,ce.height):n.texImage2D(t.TEXTURE_2D,0,ct,ce.width,ce.height,0,Be,Ke,null));else if(L.isDataTexture)if(Je.length>0&&Qe){ge&&Ie&&n.texStorage2D(t.TEXTURE_2D,Te,ct,Je[0].width,Je[0].height);for(let be=0,Ve=Je.length;be<Ve;be++)ue=Je[be],ge?n.texSubImage2D(t.TEXTURE_2D,be,0,0,ue.width,ue.height,Be,Ke,ue.data):n.texImage2D(t.TEXTURE_2D,be,ct,ue.width,ue.height,0,Be,Ke,ue.data);L.generateMipmaps=!1}else ge?(Ie&&n.texStorage2D(t.TEXTURE_2D,Te,ct,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce.width,ce.height,Be,Ke,ce.data)):n.texImage2D(t.TEXTURE_2D,0,ct,ce.width,ce.height,0,Be,Ke,ce.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ge&&Ie&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Te,ct,Je[0].width,Je[0].height,ce.depth);for(let be=0,Ve=Je.length;be<Ve;be++)ue=Je[be],L.format!==za?Be!==null?ge?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,be,0,0,0,ue.width,ue.height,ce.depth,Be,ue.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,be,ct,ue.width,ue.height,ce.depth,0,ue.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage3D(t.TEXTURE_2D_ARRAY,be,0,0,0,ue.width,ue.height,ce.depth,Be,Ke,ue.data):n.texImage3D(t.TEXTURE_2D_ARRAY,be,ct,ue.width,ue.height,ce.depth,0,Be,Ke,ue.data)}else{ge&&Ie&&n.texStorage2D(t.TEXTURE_2D,Te,ct,Je[0].width,Je[0].height);for(let be=0,Ve=Je.length;be<Ve;be++)ue=Je[be],L.format!==za?Be!==null?ge?n.compressedTexSubImage2D(t.TEXTURE_2D,be,0,0,ue.width,ue.height,Be,ue.data):n.compressedTexImage2D(t.TEXTURE_2D,be,ct,ue.width,ue.height,0,ue.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage2D(t.TEXTURE_2D,be,0,0,ue.width,ue.height,Be,Ke,ue.data):n.texImage2D(t.TEXTURE_2D,be,ct,ue.width,ue.height,0,Be,Ke,ue.data)}else if(L.isDataArrayTexture)ge?(Ie&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Te,ct,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ce.width,ce.height,ce.depth,Be,Ke,ce.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ct,ce.width,ce.height,ce.depth,0,Be,Ke,ce.data);else if(L.isData3DTexture)ge?(Ie&&n.texStorage3D(t.TEXTURE_3D,Te,ct,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ce.width,ce.height,ce.depth,Be,Ke,ce.data)):n.texImage3D(t.TEXTURE_3D,0,ct,ce.width,ce.height,ce.depth,0,Be,Ke,ce.data);else if(L.isFramebufferTexture){if(Ie)if(ge)n.texStorage2D(t.TEXTURE_2D,Te,ct,ce.width,ce.height);else{let be=ce.width,Ve=ce.height;for(let ft=0;ft<Te;ft++)n.texImage2D(t.TEXTURE_2D,ft,ct,be,Ve,0,Be,Ke,null),be>>=1,Ve>>=1}}else if(Je.length>0&&Qe){ge&&Ie&&n.texStorage2D(t.TEXTURE_2D,Te,ct,Je[0].width,Je[0].height);for(let be=0,Ve=Je.length;be<Ve;be++)ue=Je[be],ge?n.texSubImage2D(t.TEXTURE_2D,be,0,0,Be,Ke,ue):n.texImage2D(t.TEXTURE_2D,be,ct,Be,Ke,ue);L.generateMipmaps=!1}else ge?(Ie&&n.texStorage2D(t.TEXTURE_2D,Te,ct,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Be,Ke,ce)):n.texImage2D(t.TEXTURE_2D,0,ct,Be,Ke,ce);P(L,Qe)&&C(ve),tt.__version=xe.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function we(U,L,ne){if(L.image.length!==6)return;const ve=Ee(U,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+ne);const xe=r.get(ye);if(ye.version!==xe.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const tt=$n.getPrimaries($n.workingColorSpace),je=L.colorSpace===Ba?null:$n.getPrimaries(L.colorSpace),Ye=L.colorSpace===Ba||tt===je?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,Ye);const ot=L.isCompressedTexture||L.image[0].isCompressedTexture,Fe=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let be=0;be<6;be++)!ot&&!Fe?ce[be]=w(L.image[be],!1,!0,c):ce[be]=Fe?L.image[be].image:L.image[be],ce[be]=se(L,ce[be]);const Qe=ce[0],Be=T(Qe)||o,Ke=s.convert(L.format,L.colorSpace),ct=s.convert(L.type),ue=j(L.internalFormat,Ke,ct,L.colorSpace),Je=o&&L.isVideoTexture!==!0,ge=xe.__version===void 0||ve===!0;let Ie=N(L,Qe,Be);me(t.TEXTURE_CUBE_MAP,L,Be);let Te;if(ot){Je&&ge&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ie,ue,Qe.width,Qe.height);for(let be=0;be<6;be++){Te=ce[be].mipmaps;for(let Ve=0;Ve<Te.length;Ve++){const ft=Te[Ve];L.format!==za?Ke!==null?Je?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,0,0,ft.width,ft.height,Ke,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,ue,ft.width,ft.height,0,ft.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,0,0,ft.width,ft.height,Ke,ct,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve,ue,ft.width,ft.height,0,Ke,ct,ft.data)}}}else{Te=L.mipmaps,Je&&ge&&(Te.length>0&&Ie++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ie,ue,ce[0].width,ce[0].height));for(let be=0;be<6;be++)if(Fe){Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,ce[be].width,ce[be].height,Ke,ct,ce[be].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ue,ce[be].width,ce[be].height,0,Ke,ct,ce[be].data);for(let Ve=0;Ve<Te.length;Ve++){const yt=Te[Ve].image[be].image;Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,0,0,yt.width,yt.height,Ke,ct,yt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,ue,yt.width,yt.height,0,Ke,ct,yt.data)}}else{Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,0,0,Ke,ct,ce[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,0,ue,Ke,ct,ce[be]);for(let Ve=0;Ve<Te.length;Ve++){const ft=Te[Ve];Je?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,0,0,Ke,ct,ft.image[be]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+be,Ve+1,ue,Ke,ct,ft.image[be])}}}P(L,Be)&&C(t.TEXTURE_CUBE_MAP),xe.__version=ye.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function De(U,L,ne,ve,ye,xe){const tt=s.convert(ne.format,ne.colorSpace),je=s.convert(ne.type),Ye=j(ne.internalFormat,tt,je,ne.colorSpace);if(!r.get(L).__hasExternalTextures){const Fe=Math.max(1,L.width>>xe),ce=Math.max(1,L.height>>xe);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,xe,Ye,Fe,ce,L.depth,0,tt,je,null):n.texImage2D(ye,xe,Ye,Fe,ce,0,tt,je,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),Re(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,ye,r.get(ne).__webglTexture,0,le(L)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,ye,r.get(ne).__webglTexture,xe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function de(U,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer&&!L.stencilBuffer){let ve=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||Re(L)){const ye=L.depthTexture;ye&&ye.isDepthTexture&&(ye.type===nc?ve=t.DEPTH_COMPONENT32F:ye.type===Ou&&(ve=t.DEPTH_COMPONENT24));const xe=le(L);Re(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,xe,ve,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,xe,ve,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ve,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(L.depthBuffer&&L.stencilBuffer){const ve=le(L);ne&&Re(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,L.width,L.height):Re(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const ve=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ye=0;ye<ve.length;ye++){const xe=ve[ye],tt=s.convert(xe.format,xe.colorSpace),je=s.convert(xe.type),Ye=j(xe.internalFormat,tt,je,xe.colorSpace),ot=le(L);ne&&Re(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ot,Ye,L.width,L.height):Re(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ot,Ye,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Ye,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Le(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),ee(L.depthTexture,0);const ve=r.get(L.depthTexture).__webglTexture,ye=le(L);if(L.depthTexture.format===df)Re(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0);else if(L.depthTexture.format===sm)Re(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function B(U){const L=r.get(U),ne=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");Le(L.__webglFramebuffer,U)}else if(ne){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]=t.createRenderbuffer(),de(L.__webglDepthbuffer[ve],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),de(L.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function z(U,L,ne){const ve=r.get(U);L!==void 0&&De(ve.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&B(U)}function ie(U){const L=U.texture,ne=r.get(U),ve=r.get(L);U.addEventListener("dispose",I),U.isWebGLMultipleRenderTargets!==!0&&(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,a.memory.textures++);const ye=U.isWebGLCubeRenderTarget===!0,xe=U.isWebGLMultipleRenderTargets===!0,tt=T(U)||o;if(ye){ne.__webglFramebuffer=[];for(let je=0;je<6;je++)if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[je]=[];for(let Ye=0;Ye<L.mipmaps.length;Ye++)ne.__webglFramebuffer[je][Ye]=t.createFramebuffer()}else ne.__webglFramebuffer[je]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let je=0;je<L.mipmaps.length;je++)ne.__webglFramebuffer[je]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(xe)if(i.drawBuffers){const je=U.texture;for(let Ye=0,ot=je.length;Ye<ot;Ye++){const Fe=r.get(je[Ye]);Fe.__webglTexture===void 0&&(Fe.__webglTexture=t.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&U.samples>0&&Re(U)===!1){const je=xe?L:[L];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Ye=0;Ye<je.length;Ye++){const ot=je[Ye];ne.__webglColorRenderbuffer[Ye]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ye]);const Fe=s.convert(ot.format,ot.colorSpace),ce=s.convert(ot.type),Qe=j(ot.internalFormat,Fe,ce,ot.colorSpace,U.isXRRenderTarget===!0),Be=le(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,Qe,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ye,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ye])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),de(ne.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),me(t.TEXTURE_CUBE_MAP,L,tt);for(let je=0;je<6;je++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let Ye=0;Ye<L.mipmaps.length;Ye++)De(ne.__webglFramebuffer[je][Ye],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+je,Ye);else De(ne.__webglFramebuffer[je],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+je,0);P(L,tt)&&C(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(xe){const je=U.texture;for(let Ye=0,ot=je.length;Ye<ot;Ye++){const Fe=je[Ye],ce=r.get(Fe);n.bindTexture(t.TEXTURE_2D,ce.__webglTexture),me(t.TEXTURE_2D,Fe,tt),De(ne.__webglFramebuffer,U,Fe,t.COLOR_ATTACHMENT0+Ye,t.TEXTURE_2D,0),P(Fe,tt)&&C(t.TEXTURE_2D)}n.unbindTexture()}else{let je=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(o?je=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(je,ve.__webglTexture),me(je,L,tt),o&&L.mipmaps&&L.mipmaps.length>0)for(let Ye=0;Ye<L.mipmaps.length;Ye++)De(ne.__webglFramebuffer[Ye],U,L,t.COLOR_ATTACHMENT0,je,Ye);else De(ne.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,je,0);P(L,tt)&&C(je),n.unbindTexture()}U.depthBuffer&&B(U)}function X(U){const L=T(U)||o,ne=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let ve=0,ye=ne.length;ve<ye;ve++){const xe=ne[ve];if(P(xe,L)){const tt=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,je=r.get(xe).__webglTexture;n.bindTexture(tt,je),C(tt),n.unbindTexture()}}}function J(U){if(o&&U.samples>0&&Re(U)===!1){const L=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],ne=U.width,ve=U.height;let ye=t.COLOR_BUFFER_BIT;const xe=[],tt=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,je=r.get(U),Ye=U.isWebGLMultipleRenderTargets===!0;if(Ye)for(let ot=0;ot<L.length;ot++)n.bindFramebuffer(t.FRAMEBUFFER,je.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,je.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,je.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,je.__webglFramebuffer);for(let ot=0;ot<L.length;ot++){xe.push(t.COLOR_ATTACHMENT0+ot),U.depthBuffer&&xe.push(tt);const Fe=je.__ignoreDepthValues!==void 0?je.__ignoreDepthValues:!1;if(Fe===!1&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Ye&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,je.__webglColorRenderbuffer[ot]),Fe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[tt]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[tt])),Ye){const ce=r.get(L[ot]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ce,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,ye,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,xe)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ye)for(let ot=0;ot<L.length;ot++){n.bindFramebuffer(t.FRAMEBUFFER,je.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.RENDERBUFFER,je.__webglColorRenderbuffer[ot]);const Fe=r.get(L[ot]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,je.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ot,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,je.__webglMultisampledFramebuffer)}}function le(U){return Math.min(h,U.samples)}function Re(U){const L=r.get(U);return o&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ae(U){const L=a.render.frame;b.get(U)!==L&&(b.set(U,L),U.update())}function se(U,L){const ne=U.colorSpace,ve=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===z3||ne!==vc&&ne!==Ba&&($n.getTransfer(ne)===rr?o===!1?e.has("EXT_sRGB")===!0&&ve===za?(U.format=z3,U.minFilter=Fa,U.generateMipmaps=!1):L=T7.sRGBToLinear(L):(ve!==za||ye!==$u)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),L}this.allocateTextureUnit=Z,this.resetTextureUnits=V,this.setTexture2D=ee,this.setTexture2DArray=H,this.setTexture3D=Y,this.setTextureCube=te,this.rebindTextures=z,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=X,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=De,this.useMultisampledRTT=Re}function B_e(t,e,n){const r=n.isWebGL2;function i(s,a=Ba){let o;const l=$n.getTransfer(a);if(s===$u)return t.UNSIGNED_BYTE;if(s===g7)return t.UNSIGNED_SHORT_4_4_4_4;if(s===x7)return t.UNSIGNED_SHORT_5_5_5_1;if(s===dxe)return t.BYTE;if(s===fxe)return t.SHORT;if(s===yk)return t.UNSIGNED_SHORT;if(s===m7)return t.INT;if(s===Ou)return t.UNSIGNED_INT;if(s===nc)return t.FLOAT;if(s===o0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===hxe)return t.ALPHA;if(s===za)return t.RGBA;if(s===pxe)return t.LUMINANCE;if(s===mxe)return t.LUMINANCE_ALPHA;if(s===df)return t.DEPTH_COMPONENT;if(s===sm)return t.DEPTH_STENCIL;if(s===z3)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===gxe)return t.RED;if(s===v7)return t.RED_INTEGER;if(s===xxe)return t.RG;if(s===b7)return t.RG_INTEGER;if(s===y7)return t.RGBA_INTEGER;if(s===TT||s===CT||s===NT||s===RT)if(l===rr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===TT)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===CT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===NT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===RT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===TT)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===CT)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===NT)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===RT)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===kz||s===Dz||s===Oz||s===Lz)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===kz)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Dz)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Oz)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Lz)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===_7)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Iz||s===jz)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===Iz)return l===rr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===jz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Uz||s===Fz||s===zz||s===Bz||s===Hz||s===$z||s===Vz||s===Gz||s===Wz||s===qz||s===Xz||s===Kz||s===Yz||s===Zz)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===Uz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Fz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===zz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Bz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Hz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===$z)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Vz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Gz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===Wz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===qz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Xz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===Kz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Yz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===Zz)return l===rr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===PT||s===Qz||s===Jz)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===PT)return l===rr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Qz)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Jz)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===vxe||s===e5||s===t5||s===n5)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===PT)return o.COMPRESSED_RED_RGTC1_EXT;if(s===e5)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===t5)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===n5)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===uf?r?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[s]!==void 0?t[s]:null}return{convert:i}}class H_e extends la{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class mx extends _s{constructor(){super(),this.isGroup=!0,this.type="Group"}}const $_e={type:"move"};class e2{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new mx,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new mx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ne,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ne),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new mx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ne,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ne),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),x=this._getHandJoint(c,y);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],g=u.position.distanceTo(h.position),m=.02,b=.005;c.inputState.pinching&&g>m+b?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&g<=m-b&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($_e)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new mx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class V_e extends Yf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,g=null,m=null,b=null;const y=n.getContextAttributes();let v=null,x=null;const M=[],w=[],T=new Kt;let A=null;const P=new la;P.layers.enable(1),P.viewport=new Gn;const C=new la;C.layers.enable(2),C.viewport=new Gn;const j=[P,C],N=new H_e;N.layers.enable(1),N.layers.enable(2);let k=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let ae=M[te];return ae===void 0&&(ae=new e2,M[te]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(te){let ae=M[te];return ae===void 0&&(ae=new e2,M[te]=ae),ae.getGripSpace()},this.getHand=function(te){let ae=M[te];return ae===void 0&&(ae=new e2,M[te]=ae),ae.getHandSpace()};function I(te){const ae=w.indexOf(te.inputSource);if(ae===-1)return;const fe=M[ae];fe!==void 0&&(fe.update(te.inputSource,te.frame,c||a),fe.dispatchEvent({type:te.type,data:te.inputSource}))}function W(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",D);for(let te=0;te<M.length;te++){const ae=w[te];ae!==null&&(w[te]=null,M[te].disconnect(ae))}k=null,F=null,e.setRenderTarget(v),m=null,g=null,h=null,i=null,x=null,Y.stop(),r.isPresenting=!1,e.setPixelRatio(A),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){s=te,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){o=te,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(te){c=te},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return h},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(te){if(i=te,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",W),i.addEventListener("inputsourceschange",D),y.xrCompatible!==!0&&await n.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ae={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ae),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new Of(m.framebufferWidth,m.framebufferHeight,{format:za,type:$u,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,fe=null,Q=null;y.depth&&(Q=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?sm:df,fe=y.stencil?uf:Ou);const me={colorFormat:n.RGBA8,depthFormat:Q,scaleFactor:s};h=new XRWebGLBinding(i,n),g=h.createProjectionLayer(me),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),x=new Of(g.textureWidth,g.textureHeight,{format:za,type:$u,depthTexture:new F7(g.textureWidth,g.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Ee=e.properties.get(x);Ee.__ignoreDepthValues=g.ignoreDepthValues}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),Y.setContext(i),Y.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function D(te){for(let ae=0;ae<te.removed.length;ae++){const fe=te.removed[ae],Q=w.indexOf(fe);Q>=0&&(w[Q]=null,M[Q].disconnect(fe))}for(let ae=0;ae<te.added.length;ae++){const fe=te.added[ae];let Q=w.indexOf(fe);if(Q===-1){for(let Ee=0;Ee<M.length;Ee++)if(Ee>=w.length){w.push(fe),Q=Ee;break}else if(w[Ee]===null){w[Ee]=fe,Q=Ee;break}if(Q===-1)break}const me=M[Q];me&&me.connect(fe)}}const $=new Ne,G=new Ne;function V(te,ae,fe){$.setFromMatrixPosition(ae.matrixWorld),G.setFromMatrixPosition(fe.matrixWorld);const Q=$.distanceTo(G),me=ae.projectionMatrix.elements,Ee=fe.projectionMatrix.elements,he=me[14]/(me[10]-1),we=me[14]/(me[10]+1),De=(me[9]+1)/me[5],de=(me[9]-1)/me[5],Le=(me[8]-1)/me[0],B=(Ee[8]+1)/Ee[0],z=he*Le,ie=he*B,X=Q/(-Le+B),J=X*-Le;ae.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(J),te.translateZ(X),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();const le=he+X,Re=we+X,Ae=z-J,se=ie+(Q-J),U=De*we/Re*le,L=de*we/Re*le;te.projectionMatrix.makePerspective(Ae,se,U,L,le,Re),te.projectionMatrixInverse.copy(te.projectionMatrix).invert()}function Z(te,ae){ae===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(ae.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(i===null)return;N.near=C.near=P.near=te.near,N.far=C.far=P.far=te.far,(k!==N.near||F!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),k=N.near,F=N.far);const ae=te.parent,fe=N.cameras;Z(N,ae);for(let Q=0;Q<fe.length;Q++)Z(fe[Q],ae);fe.length===2?V(N,P,C):N.projectionMatrix.copy(P.projectionMatrix),K(te,N,ae)};function K(te,ae,fe){fe===null?te.matrix.copy(ae.matrixWorld):(te.matrix.copy(fe.matrixWorld),te.matrix.invert(),te.matrix.multiply(ae.matrixWorld)),te.matrix.decompose(te.position,te.quaternion,te.scale),te.updateMatrixWorld(!0),te.projectionMatrix.copy(ae.projectionMatrix),te.projectionMatrixInverse.copy(ae.projectionMatrixInverse),te.isPerspectiveCamera&&(te.fov=c0*2*Math.atan(1/te.projectionMatrix.elements[5]),te.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(te){l=te,g!==null&&(g.fixedFoveation=te),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=te)};let ee=null;function H(te,ae){if(u=ae.getViewerPose(c||a),b=ae,u!==null){const fe=u.views;m!==null&&(e.setRenderTargetFramebuffer(x,m.framebuffer),e.setRenderTarget(x));let Q=!1;fe.length!==N.cameras.length&&(N.cameras.length=0,Q=!0);for(let me=0;me<fe.length;me++){const Ee=fe[me];let he=null;if(m!==null)he=m.getViewport(Ee);else{const De=h.getViewSubImage(g,Ee);he=De.viewport,me===0&&(e.setRenderTargetTextures(x,De.colorTexture,g.ignoreDepthValues?void 0:De.depthStencilTexture),e.setRenderTarget(x))}let we=j[me];we===void 0&&(we=new la,we.layers.enable(me),we.viewport=new Gn,j[me]=we),we.matrix.fromArray(Ee.transform.matrix),we.matrix.decompose(we.position,we.quaternion,we.scale),we.projectionMatrix.fromArray(Ee.projectionMatrix),we.projectionMatrixInverse.copy(we.projectionMatrix).invert(),we.viewport.set(he.x,he.y,he.width,he.height),me===0&&(N.matrix.copy(we.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),Q===!0&&N.cameras.push(we)}}for(let fe=0;fe<M.length;fe++){const Q=w[fe],me=M[fe];Q!==null&&me!==void 0&&me.update(Q,ae,c||a)}ee&&ee(te,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),b=null}const Y=new U7;Y.setAnimationLoop(H),this.setAnimationLoop=function(te){ee=te},this.dispose=function(){}}}function G_e(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function r(v,x){x.color.getRGB(v.fogColor.value,L7(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function i(v,x,M,w,T){x.isMeshBasicMaterial||x.isMeshLambertMaterial?s(v,x):x.isMeshToonMaterial?(s(v,x),h(v,x)):x.isMeshPhongMaterial?(s(v,x),u(v,x)):x.isMeshStandardMaterial?(s(v,x),g(v,x),x.isMeshPhysicalMaterial&&m(v,x,T)):x.isMeshMatcapMaterial?(s(v,x),b(v,x)):x.isMeshDepthMaterial?s(v,x):x.isMeshDistanceMaterial?(s(v,x),y(v,x)):x.isMeshNormalMaterial?s(v,x):x.isLineBasicMaterial?(a(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?l(v,x,M,w):x.isSpriteMaterial?c(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function s(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===Hs&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===Hs&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x).envMap;if(M&&(v.envMap.value=M,v.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap){v.lightMap.value=x.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=x.lightMapIntensity*w,n(x.lightMap,v.lightMapTransform)}x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function a(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function l(v,x,M,w){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=w*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function c(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function u(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function h(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function g(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),e.get(x).envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Hs&&v.clearcoatNormalScale.value.negate())),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function b(v,x){x.matcap&&(v.matcap.value=x.matcap)}function y(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function W_e(t,e,n,r){let i={},s={},a=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(M,w){const T=w.program;r.uniformBlockBinding(M,T)}function c(M,w){let T=i[M.id];T===void 0&&(b(M),T=u(M),i[M.id]=T,M.addEventListener("dispose",v));const A=w.program;r.updateUBOMapping(M,A);const P=e.render.frame;s[M.id]!==P&&(g(M),s[M.id]=P)}function u(M){const w=h();M.__bindingPointIndex=w;const T=t.createBuffer(),A=M.__size,P=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,A,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,T),T}function h(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(M){const w=i[M.id],T=M.uniforms,A=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let P=0,C=T.length;P<C;P++){const j=T[P];if(m(j,P,A)===!0){const N=j.__offset,k=Array.isArray(j.value)?j.value:[j.value];let F=0;for(let I=0;I<k.length;I++){const W=k[I],D=y(W);typeof W=="number"?(j.__data[0]=W,t.bufferSubData(t.UNIFORM_BUFFER,N+F,j.__data)):W.isMatrix3?(j.__data[0]=W.elements[0],j.__data[1]=W.elements[1],j.__data[2]=W.elements[2],j.__data[3]=W.elements[0],j.__data[4]=W.elements[3],j.__data[5]=W.elements[4],j.__data[6]=W.elements[5],j.__data[7]=W.elements[0],j.__data[8]=W.elements[6],j.__data[9]=W.elements[7],j.__data[10]=W.elements[8],j.__data[11]=W.elements[0]):(W.toArray(j.__data,F),F+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,N,j.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,T){const A=M.value;if(T[w]===void 0){if(typeof A=="number")T[w]=A;else{const P=Array.isArray(A)?A:[A],C=[];for(let j=0;j<P.length;j++)C.push(P[j].clone());T[w]=C}return!0}else if(typeof A=="number"){if(T[w]!==A)return T[w]=A,!0}else{const P=Array.isArray(T[w])?T[w]:[T[w]],C=Array.isArray(A)?A:[A];for(let j=0;j<P.length;j++){const N=P[j];if(N.equals(C[j])===!1)return N.copy(C[j]),!0}}return!1}function b(M){const w=M.uniforms;let T=0;const A=16;let P=0;for(let C=0,j=w.length;C<j;C++){const N=w[C],k={boundary:0,storage:0},F=Array.isArray(N.value)?N.value:[N.value];for(let I=0,W=F.length;I<W;I++){const D=F[I],$=y(D);k.boundary+=$.boundary,k.storage+=$.storage}if(N.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=T,C>0){P=T%A;const I=A-P;P!==0&&I-k.boundary<0&&(T+=A-P,N.__offset=T)}T+=k.storage}return P=T%A,P>0&&(T+=A-P),M.__size=T,M.__cache={},this}function y(M){const w={boundary:0,storage:0};return typeof M=="number"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),w}function v(M){const w=M.target;w.removeEventListener("dispose",v);const T=a.indexOf(w.__bindingPointIndex);a.splice(T,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete s[w.id]}function x(){for(const M in i)t.deleteBuffer(i[M]);a=[],i={},s={}}return{bind:l,update:c,dispose:x}}class $3{constructor(e={}){const{canvas:n=$xe(),context:r=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=a;const m=new Uint32Array(4),b=new Int32Array(4);let y=null,v=null;const x=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Gi,this._useLegacyLights=!1,this.toneMapping=Hu,this.toneMappingExposure=1;const w=this;let T=!1,A=0,P=0,C=null,j=-1,N=null;const k=new Gn,F=new Gn;let I=null;const W=new Bt(0);let D=0,$=n.width,G=n.height,V=1,Z=null,K=null;const ee=new Gn(0,0,$,G),H=new Gn(0,0,$,G);let Y=!1;const te=new mw;let ae=!1,fe=!1,Q=null;const me=new Jn,Ee=new Kt,he=new Ne,we={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function De(){return C===null?V:1}let de=r;function Le(pe,ze){for(let et=0;et<pe.length;et++){const nt=pe[et],Ze=n.getContext(nt,ze);if(Ze!==null)return Ze}return null}try{const pe={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${fw}`),n.addEventListener("webglcontextlost",Je,!1),n.addEventListener("webglcontextrestored",ge,!1),n.addEventListener("webglcontextcreationerror",Ie,!1),de===null){const ze=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&ze.shift(),de=Le(ze,pe),de===null)throw Le(ze)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&de instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),de.getShaderPrecisionFormat===void 0&&(de.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(pe){throw console.error("THREE.WebGLRenderer: "+pe.message),pe}let B,z,ie,X,J,le,Re,Ae,se,U,L,ne,ve,ye,xe,tt,je,Ye,ot,Fe,ce,Qe,Be,Ke;function ct(){B=new rye(de),z=new Ybe(de,B,e),B.init(z),Qe=new B_e(de,B,z),ie=new F_e(de,B,z),X=new aye(de),J=new E_e,le=new z_e(de,B,ie,J,z,Qe,X),Re=new Qbe(w),Ae=new nye(w),se=new h0e(de,z),Be=new Xbe(de,B,se,z),U=new iye(de,se,X,Be),L=new uye(de,U,se,X),ot=new cye(de,z,le),tt=new Zbe(J),ne=new M_e(w,Re,Ae,B,z,Be,tt),ve=new G_e(w,J),ye=new T_e,xe=new D_e(B,z),Ye=new qbe(w,Re,Ae,ie,L,g,l),je=new U_e(w,L,z),Ke=new W_e(de,X,z,ie),Fe=new Kbe(de,B,X,z),ce=new sye(de,B,X,z),X.programs=ne.programs,w.capabilities=z,w.extensions=B,w.properties=J,w.renderLists=ye,w.shadowMap=je,w.state=ie,w.info=X}ct();const ue=new V_e(w,de);this.xr=ue,this.getContext=function(){return de},this.getContextAttributes=function(){return de.getContextAttributes()},this.forceContextLoss=function(){const pe=B.get("WEBGL_lose_context");pe&&pe.loseContext()},this.forceContextRestore=function(){const pe=B.get("WEBGL_lose_context");pe&&pe.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(pe){pe!==void 0&&(V=pe,this.setSize($,G,!1))},this.getSize=function(pe){return pe.set($,G)},this.setSize=function(pe,ze,et=!0){if(ue.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=pe,G=ze,n.width=Math.floor(pe*V),n.height=Math.floor(ze*V),et===!0&&(n.style.width=pe+"px",n.style.height=ze+"px"),this.setViewport(0,0,pe,ze)},this.getDrawingBufferSize=function(pe){return pe.set($*V,G*V).floor()},this.setDrawingBufferSize=function(pe,ze,et){$=pe,G=ze,V=et,n.width=Math.floor(pe*et),n.height=Math.floor(ze*et),this.setViewport(0,0,pe,ze)},this.getCurrentViewport=function(pe){return pe.copy(k)},this.getViewport=function(pe){return pe.copy(ee)},this.setViewport=function(pe,ze,et,nt){pe.isVector4?ee.set(pe.x,pe.y,pe.z,pe.w):ee.set(pe,ze,et,nt),ie.viewport(k.copy(ee).multiplyScalar(V).floor())},this.getScissor=function(pe){return pe.copy(H)},this.setScissor=function(pe,ze,et,nt){pe.isVector4?H.set(pe.x,pe.y,pe.z,pe.w):H.set(pe,ze,et,nt),ie.scissor(F.copy(H).multiplyScalar(V).floor())},this.getScissorTest=function(){return Y},this.setScissorTest=function(pe){ie.setScissorTest(Y=pe)},this.setOpaqueSort=function(pe){Z=pe},this.setTransparentSort=function(pe){K=pe},this.getClearColor=function(pe){return pe.copy(Ye.getClearColor())},this.setClearColor=function(){Ye.setClearColor.apply(Ye,arguments)},this.getClearAlpha=function(){return Ye.getClearAlpha()},this.setClearAlpha=function(){Ye.setClearAlpha.apply(Ye,arguments)},this.clear=function(pe=!0,ze=!0,et=!0){let nt=0;if(pe){let Ze=!1;if(C!==null){const _t=C.texture.format;Ze=_t===y7||_t===b7||_t===v7}if(Ze){const _t=C.texture.type,re=_t===$u||_t===Ou||_t===yk||_t===uf||_t===g7||_t===x7,_e=Ye.getClearColor(),ke=Ye.getClearAlpha(),Pe=_e.r,Me=_e.g,st=_e.b;re?(m[0]=Pe,m[1]=Me,m[2]=st,m[3]=ke,de.clearBufferuiv(de.COLOR,0,m)):(b[0]=Pe,b[1]=Me,b[2]=st,b[3]=ke,de.clearBufferiv(de.COLOR,0,b))}else nt|=de.COLOR_BUFFER_BIT}ze&&(nt|=de.DEPTH_BUFFER_BIT),et&&(nt|=de.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),de.clear(nt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Je,!1),n.removeEventListener("webglcontextrestored",ge,!1),n.removeEventListener("webglcontextcreationerror",Ie,!1),ye.dispose(),xe.dispose(),J.dispose(),Re.dispose(),Ae.dispose(),L.dispose(),Be.dispose(),Ke.dispose(),ne.dispose(),ue.dispose(),ue.removeEventListener("sessionstart",cn),ue.removeEventListener("sessionend",Ot),Q&&(Q.dispose(),Q=null),Pn.stop()};function Je(pe){pe.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function ge(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const pe=X.autoReset,ze=je.enabled,et=je.autoUpdate,nt=je.needsUpdate,Ze=je.type;ct(),X.autoReset=pe,je.enabled=ze,je.autoUpdate=et,je.needsUpdate=nt,je.type=Ze}function Ie(pe){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",pe.statusMessage)}function Te(pe){const ze=pe.target;ze.removeEventListener("dispose",Te),be(ze)}function be(pe){Ve(pe),J.remove(pe)}function Ve(pe){const ze=J.get(pe).programs;ze!==void 0&&(ze.forEach(function(et){ne.releaseProgram(et)}),pe.isShaderMaterial&&ne.releaseShaderCache(pe))}this.renderBufferDirect=function(pe,ze,et,nt,Ze,_t){ze===null&&(ze=we);const re=Ze.isMesh&&Ze.matrixWorld.determinant()<0,_e=Cr(pe,ze,et,nt,Ze);ie.setMaterial(nt,re);let ke=et.index,Pe=1;if(nt.wireframe===!0){if(ke=U.getWireframeAttribute(et),ke===void 0)return;Pe=2}const Me=et.drawRange,st=et.attributes.position;let ht=Me.start*Pe,vt=(Me.start+Me.count)*Pe;_t!==null&&(ht=Math.max(ht,_t.start*Pe),vt=Math.min(vt,(_t.start+_t.count)*Pe)),ke!==null?(ht=Math.max(ht,0),vt=Math.min(vt,ke.count)):st!=null&&(ht=Math.max(ht,0),vt=Math.min(vt,st.count));const xt=vt-ht;if(xt<0||xt===1/0)return;Be.setup(Ze,nt,_e,et,ke);let kt,wt=Fe;if(ke!==null&&(kt=se.get(ke),wt=ce,wt.setIndex(kt)),Ze.isMesh)nt.wireframe===!0?(ie.setLineWidth(nt.wireframeLinewidth*De()),wt.setMode(de.LINES)):wt.setMode(de.TRIANGLES);else if(Ze.isLine){let mt=nt.linewidth;mt===void 0&&(mt=1),ie.setLineWidth(mt*De()),Ze.isLineSegments?wt.setMode(de.LINES):Ze.isLineLoop?wt.setMode(de.LINE_LOOP):wt.setMode(de.LINE_STRIP)}else Ze.isPoints?wt.setMode(de.POINTS):Ze.isSprite&&wt.setMode(de.TRIANGLES);if(Ze.isBatchedMesh)wt.renderMultiDraw(Ze._multiDrawStarts,Ze._multiDrawCounts,Ze._multiDrawCount);else if(Ze.isInstancedMesh)wt.renderInstances(ht,xt,Ze.count);else if(et.isInstancedBufferGeometry){const mt=et._maxInstanceCount!==void 0?et._maxInstanceCount:1/0,qt=Math.min(et.instanceCount,mt);wt.renderInstances(ht,xt,qt)}else wt.render(ht,xt)};function ft(pe,ze,et){pe.transparent===!0&&pe.side===Yl&&pe.forceSinglePass===!1?(pe.side=Hs,pe.needsUpdate=!0,Yi(pe,ze,et),pe.side=Ju,pe.needsUpdate=!0,Yi(pe,ze,et),pe.side=Yl):Yi(pe,ze,et)}this.compile=function(pe,ze,et=null){et===null&&(et=pe),v=xe.get(et),v.init(),M.push(v),et.traverseVisible(function(Ze){Ze.isLight&&Ze.layers.test(ze.layers)&&(v.pushLight(Ze),Ze.castShadow&&v.pushShadow(Ze))}),pe!==et&&pe.traverseVisible(function(Ze){Ze.isLight&&Ze.layers.test(ze.layers)&&(v.pushLight(Ze),Ze.castShadow&&v.pushShadow(Ze))}),v.setupLights(w._useLegacyLights);const nt=new Set;return pe.traverse(function(Ze){const _t=Ze.material;if(_t)if(Array.isArray(_t))for(let re=0;re<_t.length;re++){const _e=_t[re];ft(_e,et,Ze),nt.add(_e)}else ft(_t,et,Ze),nt.add(_t)}),M.pop(),v=null,nt},this.compileAsync=function(pe,ze,et=null){const nt=this.compile(pe,ze,et);return new Promise(Ze=>{function _t(){if(nt.forEach(function(re){J.get(re).currentProgram.isReady()&&nt.delete(re)}),nt.size===0){Ze(pe);return}setTimeout(_t,10)}B.get("KHR_parallel_shader_compile")!==null?_t():setTimeout(_t,10)})};let yt=null;function Pt(pe){yt&&yt(pe)}function cn(){Pn.stop()}function Ot(){Pn.start()}const Pn=new U7;Pn.setAnimationLoop(Pt),typeof self<"u"&&Pn.setContext(self),this.setAnimationLoop=function(pe){yt=pe,ue.setAnimationLoop(pe),pe===null?Pn.stop():Pn.start()},ue.addEventListener("sessionstart",cn),ue.addEventListener("sessionend",Ot),this.render=function(pe,ze){if(ze!==void 0&&ze.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;pe.matrixWorldAutoUpdate===!0&&pe.updateMatrixWorld(),ze.parent===null&&ze.matrixWorldAutoUpdate===!0&&ze.updateMatrixWorld(),ue.enabled===!0&&ue.isPresenting===!0&&(ue.cameraAutoUpdate===!0&&ue.updateCamera(ze),ze=ue.getCamera()),pe.isScene===!0&&pe.onBeforeRender(w,pe,ze,C),v=xe.get(pe,M.length),v.init(),M.push(v),me.multiplyMatrices(ze.projectionMatrix,ze.matrixWorldInverse),te.setFromProjectionMatrix(me),fe=this.localClippingEnabled,ae=tt.init(this.clippingPlanes,fe),y=ye.get(pe,x.length),y.init(),x.push(y),qn(pe,ze,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(Z,K),this.info.render.frame++,ae===!0&&tt.beginShadows();const et=v.state.shadowsArray;if(je.render(et,pe,ze),ae===!0&&tt.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ye.render(y,pe),v.setupLights(w._useLegacyLights),ze.isArrayCamera){const nt=ze.cameras;for(let Ze=0,_t=nt.length;Ze<_t;Ze++){const re=nt[Ze];gi(y,pe,re,re.viewport)}}else gi(y,pe,ze);C!==null&&(le.updateMultisampleRenderTarget(C),le.updateRenderTargetMipmap(C)),pe.isScene===!0&&pe.onAfterRender(w,pe,ze),Be.resetDefaultState(),j=-1,N=null,M.pop(),M.length>0?v=M[M.length-1]:v=null,x.pop(),x.length>0?y=x[x.length-1]:y=null};function qn(pe,ze,et,nt){if(pe.visible===!1)return;if(pe.layers.test(ze.layers)){if(pe.isGroup)et=pe.renderOrder;else if(pe.isLOD)pe.autoUpdate===!0&&pe.update(ze);else if(pe.isLight)v.pushLight(pe),pe.castShadow&&v.pushShadow(pe);else if(pe.isSprite){if(!pe.frustumCulled||te.intersectsSprite(pe)){nt&&he.setFromMatrixPosition(pe.matrixWorld).applyMatrix4(me);const re=L.update(pe),_e=pe.material;_e.visible&&y.push(pe,re,_e,et,he.z,null)}}else if((pe.isMesh||pe.isLine||pe.isPoints)&&(!pe.frustumCulled||te.intersectsObject(pe))){const re=L.update(pe),_e=pe.material;if(nt&&(pe.boundingSphere!==void 0?(pe.boundingSphere===null&&pe.computeBoundingSphere(),he.copy(pe.boundingSphere.center)):(re.boundingSphere===null&&re.computeBoundingSphere(),he.copy(re.boundingSphere.center)),he.applyMatrix4(pe.matrixWorld).applyMatrix4(me)),Array.isArray(_e)){const ke=re.groups;for(let Pe=0,Me=ke.length;Pe<Me;Pe++){const st=ke[Pe],ht=_e[st.materialIndex];ht&&ht.visible&&y.push(pe,re,ht,et,he.z,st)}}else _e.visible&&y.push(pe,re,_e,et,he.z,null)}}const _t=pe.children;for(let re=0,_e=_t.length;re<_e;re++)qn(_t[re],ze,et,nt)}function gi(pe,ze,et,nt){const Ze=pe.opaque,_t=pe.transmissive,re=pe.transparent;v.setupLightsView(et),ae===!0&&tt.setGlobalState(w.clippingPlanes,et),_t.length>0&&Jr(Ze,_t,ze,et),nt&&ie.viewport(k.copy(nt)),Ze.length>0&&xi(Ze,ze,et),_t.length>0&&xi(_t,ze,et),re.length>0&&xi(re,ze,et),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function Jr(pe,ze,et,nt){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;const _t=z.isWebGL2;Q===null&&(Q=new Of(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")?o0:$u,minFilter:a0,samples:_t?4:0})),w.getDrawingBufferSize(Ee),_t?Q.setSize(Ee.x,Ee.y):Q.setSize(d1(Ee.x),d1(Ee.y));const re=w.getRenderTarget();w.setRenderTarget(Q),w.getClearColor(W),D=w.getClearAlpha(),D<1&&w.setClearColor(16777215,.5),w.clear();const _e=w.toneMapping;w.toneMapping=Hu,xi(pe,et,nt),le.updateMultisampleRenderTarget(Q),le.updateRenderTargetMipmap(Q);let ke=!1;for(let Pe=0,Me=ze.length;Pe<Me;Pe++){const st=ze[Pe],ht=st.object,vt=st.geometry,xt=st.material,kt=st.group;if(xt.side===Yl&&ht.layers.test(nt.layers)){const wt=xt.side;xt.side=Hs,xt.needsUpdate=!0,Di(ht,et,nt,vt,xt,kt),xt.side=wt,xt.needsUpdate=!0,ke=!0}}ke===!0&&(le.updateMultisampleRenderTarget(Q),le.updateRenderTargetMipmap(Q)),w.setRenderTarget(re),w.setClearColor(W,D),w.toneMapping=_e}function xi(pe,ze,et){const nt=ze.isScene===!0?ze.overrideMaterial:null;for(let Ze=0,_t=pe.length;Ze<_t;Ze++){const re=pe[Ze],_e=re.object,ke=re.geometry,Pe=nt===null?re.material:nt,Me=re.group;_e.layers.test(et.layers)&&Di(_e,ze,et,ke,Pe,Me)}}function Di(pe,ze,et,nt,Ze,_t){pe.onBeforeRender(w,ze,et,nt,Ze,_t),pe.modelViewMatrix.multiplyMatrices(et.matrixWorldInverse,pe.matrixWorld),pe.normalMatrix.getNormalMatrix(pe.modelViewMatrix),Ze.onBeforeRender(w,ze,et,nt,pe,_t),Ze.transparent===!0&&Ze.side===Yl&&Ze.forceSinglePass===!1?(Ze.side=Hs,Ze.needsUpdate=!0,w.renderBufferDirect(et,ze,nt,Ze,pe,_t),Ze.side=Ju,Ze.needsUpdate=!0,w.renderBufferDirect(et,ze,nt,Ze,pe,_t),Ze.side=Yl):w.renderBufferDirect(et,ze,nt,Ze,pe,_t),pe.onAfterRender(w,ze,et,nt,Ze,_t)}function Yi(pe,ze,et){ze.isScene!==!0&&(ze=we);const nt=J.get(pe),Ze=v.state.lights,_t=v.state.shadowsArray,re=Ze.state.version,_e=ne.getParameters(pe,Ze.state,_t,ze,et),ke=ne.getProgramCacheKey(_e);let Pe=nt.programs;nt.environment=pe.isMeshStandardMaterial?ze.environment:null,nt.fog=ze.fog,nt.envMap=(pe.isMeshStandardMaterial?Ae:Re).get(pe.envMap||nt.environment),Pe===void 0&&(pe.addEventListener("dispose",Te),Pe=new Map,nt.programs=Pe);let Me=Pe.get(ke);if(Me!==void 0){if(nt.currentProgram===Me&&nt.lightsStateVersion===re)return pr(pe,_e),Me}else _e.uniforms=ne.getUniforms(pe),pe.onBuild(et,_e,w),pe.onBeforeCompile(_e,w),Me=ne.acquireProgram(_e,ke),Pe.set(ke,Me),nt.uniforms=_e.uniforms;const st=nt.uniforms;return(!pe.isShaderMaterial&&!pe.isRawShaderMaterial||pe.clipping===!0)&&(st.clippingPlanes=tt.uniform),pr(pe,_e),nt.needsLights=Oc(pe),nt.lightsStateVersion=re,nt.needsLights&&(st.ambientLightColor.value=Ze.state.ambient,st.lightProbe.value=Ze.state.probe,st.directionalLights.value=Ze.state.directional,st.directionalLightShadows.value=Ze.state.directionalShadow,st.spotLights.value=Ze.state.spot,st.spotLightShadows.value=Ze.state.spotShadow,st.rectAreaLights.value=Ze.state.rectArea,st.ltc_1.value=Ze.state.rectAreaLTC1,st.ltc_2.value=Ze.state.rectAreaLTC2,st.pointLights.value=Ze.state.point,st.pointLightShadows.value=Ze.state.pointShadow,st.hemisphereLights.value=Ze.state.hemi,st.directionalShadowMap.value=Ze.state.directionalShadowMap,st.directionalShadowMatrix.value=Ze.state.directionalShadowMatrix,st.spotShadowMap.value=Ze.state.spotShadowMap,st.spotLightMatrix.value=Ze.state.spotLightMatrix,st.spotLightMap.value=Ze.state.spotLightMap,st.pointShadowMap.value=Ze.state.pointShadowMap,st.pointShadowMatrix.value=Ze.state.pointShadowMatrix),nt.currentProgram=Me,nt.uniformsList=null,Me}function jr(pe){if(pe.uniformsList===null){const ze=pe.currentProgram.getUniforms();pe.uniformsList=D_.seqWithValue(ze.seq,pe.uniforms)}return pe.uniformsList}function pr(pe,ze){const et=J.get(pe);et.outputColorSpace=ze.outputColorSpace,et.batching=ze.batching,et.instancing=ze.instancing,et.instancingColor=ze.instancingColor,et.skinning=ze.skinning,et.morphTargets=ze.morphTargets,et.morphNormals=ze.morphNormals,et.morphColors=ze.morphColors,et.morphTargetsCount=ze.morphTargetsCount,et.numClippingPlanes=ze.numClippingPlanes,et.numIntersection=ze.numClipIntersection,et.vertexAlphas=ze.vertexAlphas,et.vertexTangents=ze.vertexTangents,et.toneMapping=ze.toneMapping}function Cr(pe,ze,et,nt,Ze){ze.isScene!==!0&&(ze=we),le.resetTextureUnits();const _t=ze.fog,re=nt.isMeshStandardMaterial?ze.environment:null,_e=C===null?w.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:vc,ke=(nt.isMeshStandardMaterial?Ae:Re).get(nt.envMap||re),Pe=nt.vertexColors===!0&&!!et.attributes.color&&et.attributes.color.itemSize===4,Me=!!et.attributes.tangent&&(!!nt.normalMap||nt.anisotropy>0),st=!!et.morphAttributes.position,ht=!!et.morphAttributes.normal,vt=!!et.morphAttributes.color;let xt=Hu;nt.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(xt=w.toneMapping);const kt=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,wt=kt!==void 0?kt.length:0,mt=J.get(nt),qt=v.state.lights;if(ae===!0&&(fe===!0||pe!==N)){const Nr=pe===N&&nt.id===j;tt.setState(nt,pe,Nr)}let It=!1;nt.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==qt.state.version||mt.outputColorSpace!==_e||Ze.isBatchedMesh&&mt.batching===!1||!Ze.isBatchedMesh&&mt.batching===!0||Ze.isInstancedMesh&&mt.instancing===!1||!Ze.isInstancedMesh&&mt.instancing===!0||Ze.isSkinnedMesh&&mt.skinning===!1||!Ze.isSkinnedMesh&&mt.skinning===!0||Ze.isInstancedMesh&&mt.instancingColor===!0&&Ze.instanceColor===null||Ze.isInstancedMesh&&mt.instancingColor===!1&&Ze.instanceColor!==null||mt.envMap!==ke||nt.fog===!0&&mt.fog!==_t||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==tt.numPlanes||mt.numIntersection!==tt.numIntersection)||mt.vertexAlphas!==Pe||mt.vertexTangents!==Me||mt.morphTargets!==st||mt.morphNormals!==ht||mt.morphColors!==vt||mt.toneMapping!==xt||z.isWebGL2===!0&&mt.morphTargetsCount!==wt)&&(It=!0):(It=!0,mt.__version=nt.version);let nn=mt.currentProgram;It===!0&&(nn=Yi(nt,ze,Ze));let dn=!1,gn=!1,Lt=!1;const Yt=nn.getUniforms(),Qt=mt.uniforms;if(ie.useProgram(nn.program)&&(dn=!0,gn=!0,Lt=!0),nt.id!==j&&(j=nt.id,gn=!0),dn||N!==pe){Yt.setValue(de,"projectionMatrix",pe.projectionMatrix),Yt.setValue(de,"viewMatrix",pe.matrixWorldInverse);const Nr=Yt.map.cameraPosition;Nr!==void 0&&Nr.setValue(de,he.setFromMatrixPosition(pe.matrixWorld)),z.logarithmicDepthBuffer&&Yt.setValue(de,"logDepthBufFC",2/(Math.log(pe.far+1)/Math.LN2)),(nt.isMeshPhongMaterial||nt.isMeshToonMaterial||nt.isMeshLambertMaterial||nt.isMeshBasicMaterial||nt.isMeshStandardMaterial||nt.isShaderMaterial)&&Yt.setValue(de,"isOrthographic",pe.isOrthographicCamera===!0),N!==pe&&(N=pe,gn=!0,Lt=!0)}if(Ze.isSkinnedMesh){Yt.setOptional(de,Ze,"bindMatrix"),Yt.setOptional(de,Ze,"bindMatrixInverse");const Nr=Ze.skeleton;Nr&&(z.floatVertexTextures?(Nr.boneTexture===null&&Nr.computeBoneTexture(),Yt.setValue(de,"boneTexture",Nr.boneTexture,le)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ze.isBatchedMesh&&(Yt.setOptional(de,Ze,"batchingTexture"),Yt.setValue(de,"batchingTexture",Ze._matricesTexture,le));const yr=et.morphAttributes;if((yr.position!==void 0||yr.normal!==void 0||yr.color!==void 0&&z.isWebGL2===!0)&&ot.update(Ze,et,nn),(gn||mt.receiveShadow!==Ze.receiveShadow)&&(mt.receiveShadow=Ze.receiveShadow,Yt.setValue(de,"receiveShadow",Ze.receiveShadow)),nt.isMeshGouraudMaterial&&nt.envMap!==null&&(Qt.envMap.value=ke,Qt.flipEnvMap.value=ke.isCubeTexture&&ke.isRenderTargetTexture===!1?-1:1),gn&&(Yt.setValue(de,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&to(Qt,Lt),_t&&nt.fog===!0&&ve.refreshFogUniforms(Qt,_t),ve.refreshMaterialUniforms(Qt,nt,V,G,Q),D_.upload(de,jr(mt),Qt,le)),nt.isShaderMaterial&&nt.uniformsNeedUpdate===!0&&(D_.upload(de,jr(mt),Qt,le),nt.uniformsNeedUpdate=!1),nt.isSpriteMaterial&&Yt.setValue(de,"center",Ze.center),Yt.setValue(de,"modelViewMatrix",Ze.modelViewMatrix),Yt.setValue(de,"normalMatrix",Ze.normalMatrix),Yt.setValue(de,"modelMatrix",Ze.matrixWorld),nt.isShaderMaterial||nt.isRawShaderMaterial){const Nr=nt.uniformsGroups;for(let Nn=0,no=Nr.length;Nn<no;Nn++)if(z.isWebGL2){const kn=Nr[Nn];Ke.update(kn,nn),Ke.bind(kn,nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return nn}function to(pe,ze){pe.ambientLightColor.needsUpdate=ze,pe.lightProbe.needsUpdate=ze,pe.directionalLights.needsUpdate=ze,pe.directionalLightShadows.needsUpdate=ze,pe.pointLights.needsUpdate=ze,pe.pointLightShadows.needsUpdate=ze,pe.spotLights.needsUpdate=ze,pe.spotLightShadows.needsUpdate=ze,pe.rectAreaLights.needsUpdate=ze,pe.hemisphereLights.needsUpdate=ze}function Oc(pe){return pe.isMeshLambertMaterial||pe.isMeshToonMaterial||pe.isMeshPhongMaterial||pe.isMeshStandardMaterial||pe.isShadowMaterial||pe.isShaderMaterial&&pe.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return P},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(pe,ze,et){J.get(pe.texture).__webglTexture=ze,J.get(pe.depthTexture).__webglTexture=et;const nt=J.get(pe);nt.__hasExternalTextures=!0,nt.__hasExternalTextures&&(nt.__autoAllocateDepthBuffer=et===void 0,nt.__autoAllocateDepthBuffer||B.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),nt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(pe,ze){const et=J.get(pe);et.__webglFramebuffer=ze,et.__useDefaultFramebuffer=ze===void 0},this.setRenderTarget=function(pe,ze=0,et=0){C=pe,A=ze,P=et;let nt=!0,Ze=null,_t=!1,re=!1;if(pe){const ke=J.get(pe);ke.__useDefaultFramebuffer!==void 0?(ie.bindFramebuffer(de.FRAMEBUFFER,null),nt=!1):ke.__webglFramebuffer===void 0?le.setupRenderTarget(pe):ke.__hasExternalTextures&&le.rebindTextures(pe,J.get(pe.texture).__webglTexture,J.get(pe.depthTexture).__webglTexture);const Pe=pe.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(re=!0);const Me=J.get(pe).__webglFramebuffer;pe.isWebGLCubeRenderTarget?(Array.isArray(Me[ze])?Ze=Me[ze][et]:Ze=Me[ze],_t=!0):z.isWebGL2&&pe.samples>0&&le.useMultisampledRTT(pe)===!1?Ze=J.get(pe).__webglMultisampledFramebuffer:Array.isArray(Me)?Ze=Me[et]:Ze=Me,k.copy(pe.viewport),F.copy(pe.scissor),I=pe.scissorTest}else k.copy(ee).multiplyScalar(V).floor(),F.copy(H).multiplyScalar(V).floor(),I=Y;if(ie.bindFramebuffer(de.FRAMEBUFFER,Ze)&&z.drawBuffers&&nt&&ie.drawBuffers(pe,Ze),ie.viewport(k),ie.scissor(F),ie.setScissorTest(I),_t){const ke=J.get(pe.texture);de.framebufferTexture2D(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,de.TEXTURE_CUBE_MAP_POSITIVE_X+ze,ke.__webglTexture,et)}else if(re){const ke=J.get(pe.texture),Pe=ze||0;de.framebufferTextureLayer(de.FRAMEBUFFER,de.COLOR_ATTACHMENT0,ke.__webglTexture,et||0,Pe)}j=-1},this.readRenderTargetPixels=function(pe,ze,et,nt,Ze,_t,re){if(!(pe&&pe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=J.get(pe).__webglFramebuffer;if(pe.isWebGLCubeRenderTarget&&re!==void 0&&(_e=_e[re]),_e){ie.bindFramebuffer(de.FRAMEBUFFER,_e);try{const ke=pe.texture,Pe=ke.format,Me=ke.type;if(Pe!==za&&Qe.convert(Pe)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const st=Me===o0&&(B.has("EXT_color_buffer_half_float")||z.isWebGL2&&B.has("EXT_color_buffer_float"));if(Me!==$u&&Qe.convert(Me)!==de.getParameter(de.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Me===nc&&(z.isWebGL2||B.has("OES_texture_float")||B.has("WEBGL_color_buffer_float")))&&!st){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ze>=0&&ze<=pe.width-nt&&et>=0&&et<=pe.height-Ze&&de.readPixels(ze,et,nt,Ze,Qe.convert(Pe),Qe.convert(Me),_t)}finally{const ke=C!==null?J.get(C).__webglFramebuffer:null;ie.bindFramebuffer(de.FRAMEBUFFER,ke)}}},this.copyFramebufferToTexture=function(pe,ze,et=0){const nt=Math.pow(2,-et),Ze=Math.floor(ze.image.width*nt),_t=Math.floor(ze.image.height*nt);le.setTexture2D(ze,0),de.copyTexSubImage2D(de.TEXTURE_2D,et,0,0,pe.x,pe.y,Ze,_t),ie.unbindTexture()},this.copyTextureToTexture=function(pe,ze,et,nt=0){const Ze=ze.image.width,_t=ze.image.height,re=Qe.convert(et.format),_e=Qe.convert(et.type);le.setTexture2D(et,0),de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,et.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,et.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,et.unpackAlignment),ze.isDataTexture?de.texSubImage2D(de.TEXTURE_2D,nt,pe.x,pe.y,Ze,_t,re,_e,ze.image.data):ze.isCompressedTexture?de.compressedTexSubImage2D(de.TEXTURE_2D,nt,pe.x,pe.y,ze.mipmaps[0].width,ze.mipmaps[0].height,re,ze.mipmaps[0].data):de.texSubImage2D(de.TEXTURE_2D,nt,pe.x,pe.y,re,_e,ze.image),nt===0&&et.generateMipmaps&&de.generateMipmap(de.TEXTURE_2D),ie.unbindTexture()},this.copyTextureToTexture3D=function(pe,ze,et,nt,Ze=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const _t=pe.max.x-pe.min.x+1,re=pe.max.y-pe.min.y+1,_e=pe.max.z-pe.min.z+1,ke=Qe.convert(nt.format),Pe=Qe.convert(nt.type);let Me;if(nt.isData3DTexture)le.setTexture3D(nt,0),Me=de.TEXTURE_3D;else if(nt.isDataArrayTexture)le.setTexture2DArray(nt,0),Me=de.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}de.pixelStorei(de.UNPACK_FLIP_Y_WEBGL,nt.flipY),de.pixelStorei(de.UNPACK_PREMULTIPLY_ALPHA_WEBGL,nt.premultiplyAlpha),de.pixelStorei(de.UNPACK_ALIGNMENT,nt.unpackAlignment);const st=de.getParameter(de.UNPACK_ROW_LENGTH),ht=de.getParameter(de.UNPACK_IMAGE_HEIGHT),vt=de.getParameter(de.UNPACK_SKIP_PIXELS),xt=de.getParameter(de.UNPACK_SKIP_ROWS),kt=de.getParameter(de.UNPACK_SKIP_IMAGES),wt=et.isCompressedTexture?et.mipmaps[0]:et.image;de.pixelStorei(de.UNPACK_ROW_LENGTH,wt.width),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,wt.height),de.pixelStorei(de.UNPACK_SKIP_PIXELS,pe.min.x),de.pixelStorei(de.UNPACK_SKIP_ROWS,pe.min.y),de.pixelStorei(de.UNPACK_SKIP_IMAGES,pe.min.z),et.isDataTexture||et.isData3DTexture?de.texSubImage3D(Me,Ze,ze.x,ze.y,ze.z,_t,re,_e,ke,Pe,wt.data):et.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),de.compressedTexSubImage3D(Me,Ze,ze.x,ze.y,ze.z,_t,re,_e,ke,wt.data)):de.texSubImage3D(Me,Ze,ze.x,ze.y,ze.z,_t,re,_e,ke,Pe,wt),de.pixelStorei(de.UNPACK_ROW_LENGTH,st),de.pixelStorei(de.UNPACK_IMAGE_HEIGHT,ht),de.pixelStorei(de.UNPACK_SKIP_PIXELS,vt),de.pixelStorei(de.UNPACK_SKIP_ROWS,xt),de.pixelStorei(de.UNPACK_SKIP_IMAGES,kt),Ze===0&&nt.generateMipmaps&&de.generateMipmap(Me),ie.unbindTexture()},this.initTexture=function(pe){pe.isCubeTexture?le.setTextureCube(pe,0):pe.isData3DTexture?le.setTexture3D(pe,0):pe.isDataArrayTexture||pe.isCompressedArrayTexture?le.setTexture2DArray(pe,0):le.setTexture2D(pe,0),ie.unbindTexture()},this.resetState=function(){A=0,P=0,C=null,ie.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Yo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===_k?"display-p3":"srgb",n.unpackColorSpace=$n.workingColorSpace===pw?"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===Gi?ff:S7}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===ff?Gi:vc}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 q_e extends $3{}q_e.prototype.isWebGL1Renderer=!0;class Tk{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Bt(e),this.near=n,this.far=r}clone(){return new Tk(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class X_e extends _s{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 K_e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=F3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=cc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=cc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=cc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ps=new Ne;class Lu{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,r=this.data.count;n<r;n++)ps.fromBufferAttribute(this,n),ps.applyMatrix4(e),this.setXYZ(n,ps.x,ps.y,ps.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ps.fromBufferAttribute(this,n),ps.applyNormalMatrix(e),this.setXYZ(n,ps.x,ps.y,ps.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ps.fromBufferAttribute(this,n),ps.transformDirection(e),this.setXYZ(n,ps.x,ps.y,ps.z);return this}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=Wo(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Wo(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Wo(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Wo(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Hn(n,this.array),r=Hn(r,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this}setXYZ(e,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(n=Hn(n,this.array),r=Hn(r,this.array),i=Hn(i,this.array),s=Hn(s,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return new ha(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Lu(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)n.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Y_e extends $s{constructor(e=null,n=1,r=1,i,s,a,o,l,c=Vi,u=Vi,h,g){super(null,a,o,l,c,u,i,s,h,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function Z_e(t,e){return t.z-e.z}function Q_e(t,e){return e.z-t.z}class J_e{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const s=r[this.index];i.push(s),this.index++,s.start=e.start,s.count=e.count,s.z=n}reset(){this.list.length=0,this.index=0}}const fp="batchId",mu=new Jn,V5=new Jn,e1e=new Jn,G5=new Jn,t2=new mw,Oy=new Wa,Bd=new Qo,Jg=new Ne,n2=new J_e,ns=new yo,Ly=[];function t1e(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let s=0;s<i;s++)for(let a=0;a<r;a++)e.setComponent(s+n,a,t.getComponent(s,a))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class n1e extends yo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new us,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 Y_e(n,e,e,za,nc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:c,itemSize:u,normalized:h}=l,g=new c.constructor(r*u),m=new l.constructor(g,u,h);m.setUsage(l.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new ha(o,1))}const a=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(fp,new ha(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(fp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${fp}"`);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===fp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=n.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wa);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,mu),this.getBoundingBoxAt(i,Oy).applyMatrix4(mu),n.union(Oy))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Qo);const e=this._geometryCount,n=this.boundingSphere,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,mu),this.getBoundingSphereAt(i,Bd).applyMatrix4(mu),n.union(Bd))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const c=e.getIndex(),u=c!==null;if(u&&(r===-1?i.indexCount=c.count:i.indexCount=r,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._visibility,g=this._active,m=this._matricesTexture,b=this._matricesTexture.image.data;h.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,e1e.toArray(b,y*16),m.needsUpdate=!0,a.push(i),o.push({start:u?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Wa,sphereInitialized:!1,sphere:new Qo});const v=this.geometry.getAttribute(fp);for(let x=0;x<i.vertexCount;x++)v.setX(i.vertexStart+x,y);return v.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),a=n.getIndex(),o=this._reservedRanges[e];if(i&&a.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const m in r.attributes){if(m===fp)continue;const b=n.getAttribute(m),y=r.getAttribute(m);t1e(b,y,l);const v=b.itemSize;for(let x=b.count,M=c;x<M;x++){const w=l+x;for(let T=0;T<v;T++)y.setComponent(w,T,0)}y.needsUpdate=!0}if(i){const m=o.indexStart;for(let b=0;b<a.count;b++)s.setX(m+b,l+a.getX(b));for(let b=a.count,y=o.indexCount;b<y;b++)s.setX(m+b,l);s.needsUpdate=!0}const u=this._bounds[e];n.boundingBox!==null?(u.box.copy(n.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,n.boundingSphere!==null?(u.sphere.copy(n.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],g=n.getAttribute("position");return h.count=i?a.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.box,a=this.geometry;if(i.boxInitialized===!1){s.makeEmpty();const o=a.index,l=a.attributes.position,c=this._drawRanges[e];for(let u=c.start,h=c.start+c.count;u<h;u++){let g=u;o&&(g=o.getX(g)),s.expandByPoint(Jg.fromBufferAttribute(l,g))}i.boxInitialized=!0}return n.copy(s),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],s=i.sphere,a=this.geometry;if(i.sphereInitialized===!1){s.makeEmpty(),this.getBoundingBoxAt(e,Oy),Oy.getCenter(s.center);const o=a.index,l=a.attributes.position,c=this._drawRanges[e];let u=0;for(let h=c.start,g=c.start+c.count;h<g;h++){let m=h;o&&(m=o.getX(m)),Jg.fromBufferAttribute(l,m),u=Math.max(u,s.center.distanceToSquared(Jg))}s.radius=Math.sqrt(u),i.sphereInitialized=!0}return n.copy(s),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?this:(n.toArray(s,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,s=this._geometryCount;return e>=s||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;ns.material=this.material,ns.geometry.index=l.index,ns.geometry.attributes=l.attributes,ns.geometry.boundingBox===null&&(ns.geometry.boundingBox=new Wa),ns.geometry.boundingSphere===null&&(ns.geometry.boundingSphere=new Qo);for(let c=0;c<a;c++){if(!r[c]||!i[c])continue;const u=s[c];ns.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,ns.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,ns.geometry.boundingBox),this.getBoundingSphereAt(c,ns.geometry.boundingSphere),ns.raycast(e,Ly);for(let h=0,g=Ly.length;h<g;h++){const m=Ly[h];m.object=this,m.batchId=c,n.push(m)}Ly.length=0}ns.material=null,ns.geometry.index=null,ns.geometry.attributes={},ns.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._visibility,c=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,g=this.perObjectFrustumCulled;g&&(G5.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),t2.setFromProjectionMatrix(G5,e.isWebGPURenderer?l0:Yo));let m=0;if(this.sortObjects){V5.copy(this.matrixWorld).invert(),Jg.setFromMatrixPosition(r.matrixWorld).applyMatrix4(V5);for(let v=0,x=l.length;v<x;v++)if(l[v]){this.getMatrixAt(v,mu),this.getBoundingSphereAt(v,Bd).applyMatrix4(mu);let M=!1;if(g&&(M=!t2.intersectsSphere(Bd)),!M){const w=Jg.distanceTo(Bd.center);n2.push(h[v],w)}}const b=n2.list,y=this.customSort;y===null?b.sort(s.transparent?Q_e:Z_e):y.call(this,b,r);for(let v=0,x=b.length;v<x;v++){const M=b[v];c[m]=M.start*o,u[m]=M.count,m++}n2.reset()}else for(let b=0,y=l.length;b<y;b++)if(l[b]){let v=!1;if(g&&(this.getMatrixAt(b,mu),this.getBoundingSphereAt(b,Bd).applyMatrix4(mu),v=!t2.intersectsSphere(Bd)),!v){const x=h[b];c[m]=x.start*o,u[m]=x.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,a){this.onBeforeRender(e,null,i,s,a)}}class K0 extends km{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Bt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const W5=new Ne,q5=new Ne,X5=new Jn,r2=new wk,Iy=new Qo;class r1e extends _s{constructor(e=new us,n=new K0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,s=n.count;i<s;i++)W5.fromBufferAttribute(n,i-1),q5.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=W5.distanceTo(q5);e.setAttribute("lineDistance",new Lr(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Iy.copy(r.boundingSphere),Iy.applyMatrix4(i),Iy.radius+=s,e.ray.intersectsSphere(Iy)===!1)return;X5.copy(i).invert(),r2.copy(e.ray).applyMatrix4(X5);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new Ne,u=new Ne,h=new Ne,g=new Ne,m=this.isLineSegments?2:1,b=r.index,v=r.attributes.position;if(b!==null){const x=Math.max(0,a.start),M=Math.min(b.count,a.start+a.count);for(let w=x,T=M-1;w<T;w+=m){const A=b.getX(w),P=b.getX(w+1);if(c.fromBufferAttribute(v,A),u.fromBufferAttribute(v,P),r2.distanceSqToSegment(c,u,g,h)>l)continue;g.applyMatrix4(this.matrixWorld);const j=e.ray.origin.distanceTo(g);j<e.near||j>e.far||n.push({distance:j,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,a.start),M=Math.min(v.count,a.start+a.count);for(let w=x,T=M-1;w<T;w+=m){if(c.fromBufferAttribute(v,w),u.fromBufferAttribute(v,w+1),r2.distanceSqToSegment(c,u,g,h)>l)continue;g.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(g);P<e.near||P>e.far||n.push({distance:P,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s<a;s++){const o=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}const K5=new Ne,Y5=new Ne;class xw extends r1e{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,s=n.count;i<s;i+=2)K5.fromBufferAttribute(n,i),Y5.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+K5.distanceTo(Y5);e.setAttribute("lineDistance",new Lr(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class i1e extends us{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Ne,s=new Ne;if(e.index!==null){const a=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const h=l[c],g=h.start,m=h.count;for(let b=g,y=g+m;b<y;b+=3)for(let v=0;v<3;v++){const x=o.getX(b+v),M=o.getX(b+(v+1)%3);i.fromBufferAttribute(a,x),s.fromBufferAttribute(a,M),Z5(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}}else{const a=e.attributes.position;for(let o=0,l=a.count/3;o<l;o++)for(let c=0;c<3;c++){const u=3*o+c,h=3*o+(c+1)%3;i.fromBufferAttribute(a,u),s.fromBufferAttribute(a,h),Z5(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Lr(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Z5(t,e,n){const r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}class s1e extends km{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Bt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=w7,this.normalScale=new Kt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=bk,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 a1e extends K0{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 G7 extends _s{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Bt(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}const i2=new Jn,Q5=new Ne,J5=new Ne;class o1e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Kt(512,512),this.map=null,this.mapPass=null,this.matrix=new Jn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new mw,this._frameExtents=new Kt(1,1),this._viewportCount=1,this._viewports=[new Gn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;Q5.setFromMatrixPosition(e.matrixWorld),n.position.copy(Q5),J5.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(J5),n.updateMatrixWorld(),i2.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(i2),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(i2)}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 eB=new Jn,ex=new Ne,s2=new Ne;class l1e extends o1e{constructor(){super(new la(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Kt(4,2),this._viewportCount=6,this._viewports=[new Gn(2,1,1,1),new Gn(0,1,1,1),new Gn(3,1,1,1),new Gn(1,1,1,1),new Gn(3,0,1,1),new Gn(1,0,1,1)],this._cubeDirections=[new Ne(1,0,0),new Ne(-1,0,0),new Ne(0,0,1),new Ne(0,0,-1),new Ne(0,1,0),new Ne(0,-1,0)],this._cubeUps=[new Ne(0,1,0),new Ne(0,1,0),new Ne(0,1,0),new Ne(0,1,0),new Ne(0,0,1),new Ne(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),ex.setFromMatrixPosition(e.matrixWorld),r.position.copy(ex),s2.copy(r.position),s2.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(s2),r.updateMatrixWorld(),i.makeTranslation(-ex.x,-ex.y,-ex.z),eB.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(eB)}}class c1e extends G7{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 l1e}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 u1e extends G7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class d1e extends us{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 V3 extends K_e{constructor(e,n,r=1){super(e,n),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const n=super.clone(e);return n.meshPerAttribute=this.meshPerAttribute,n}toJSON(e){const n=super.toJSON(e);return n.isInstancedInterleavedBuffer=!0,n.meshPerAttribute=this.meshPerAttribute,n}}class tB{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(Wi(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const nB=new Ne,jy=new Ne;class f1e{constructor(e=new Ne,n=new Ne){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){nB.subVectors(e,this.start),jy.subVectors(this.end,this.start);const r=jy.dot(jy);let s=jy.dot(nB)/r;return n&&(s=Wi(s,0,1)),s}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class h1e extends xw{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 us;i.setAttribute("position",new Lr(n,3)),i.setAttribute("color",new Lr(r,3));const s=new K0({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new Bt,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:fw}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=fw);class Jo{constructor(e,n,r,i,s="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(s),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Jo.nextNameID=Jo.nextNameID||0,this.$name.id=`lil-gui-name-${++Jo.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",a=>a.stopPropagation()),this.domElement.addEventListener("keyup",a=>a.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class p1e extends Jo{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 G3(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 m1e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:G3,toHexString:G3},u0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},g1e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=u0.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 u0.toHexString(i)}},x1e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=u0.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 u0.toHexString(i)}},v1e=[m1e,u0,g1e,x1e];function b1e(t){return v1e.find(e=>e.match(t))}class y1e extends Jo{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=b1e(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const s=G3(this.$text.value);s&&this._setValueFromHexString(s)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class a2 extends Jo{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 _1e extends Jo{constructor(e,n,r,i,s,a){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(s);const o=a!==void 0;this.step(o?a:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let M=parseFloat(this.$input.value);isNaN(M)||(this._stepExplicit&&(M=this._snap(M)),this.setValue(this._clamp(M)))},r=M=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+M),this.$input.value=this.getValue())},i=M=>{M.key==="Enter"&&this.$input.blur(),M.code==="ArrowUp"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M))),M.code==="ArrowDown"&&(M.preventDefault(),r(this._step*this._arrowKeyMultiplier(M)*-1))},s=M=>{this._inputFocused&&(M.preventDefault(),r(this._step*this._normalizeMouseWheel(M)))};let a=!1,o,l,c,u,h;const g=5,m=M=>{o=M.clientX,l=c=M.clientY,a=!0,u=this.getValue(),h=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",y)},b=M=>{if(a){const w=M.clientX-o,T=M.clientY-l;Math.abs(T)>g?(M.preventDefault(),this.$input.blur(),a=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&y()}if(!a){const w=M.clientY-c;h-=w*this._step*this._arrowKeyMultiplier(M),u+h>this._max?h=this._max-u:u+h<this._min&&(h=this._min-u),this._snapClampSetValue(u+h)}c=M.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)},v=()=>{this._inputFocused=!0},x=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",x)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(x,M,w,T,A)=>(x-M)/(w-M)*(A-T)+T,n=x=>{const M=this.$slider.getBoundingClientRect();let w=e(x,M.left,M.right,this._min,this._max);this._snapClampSetValue(w)},r=x=>{this._setDraggingStyle(!0),n(x.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=x=>{n(x.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let a=!1,o,l;const c=x=>{x.preventDefault(),this._setDraggingStyle(!0),n(x.touches[0].clientX),a=!1},u=x=>{x.touches.length>1||(this._hasScrollBar?(o=x.touches[0].clientX,l=x.touches[0].clientY,a=!0):c(x),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",g))},h=x=>{if(a){const M=x.touches[0].clientX-o,w=x.touches[0].clientY-l;Math.abs(M)>Math.abs(w)?c(x):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",g))}else x.preventDefault(),n(x.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),b=400;let y;const v=x=>{if(Math.abs(x.deltaX)<Math.abs(x.deltaY)&&this._hasScrollBar)return;x.preventDefault();const w=this._normalizeMouseWheel(x)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,b)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",u,{passive:!1}),this.$slider.addEventListener("wheel",v,{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 S1e extends Jo{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 w1e extends Jo{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 M1e=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function E1e(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 rB=!1;class h1{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="Controls",closeFolders:a=!1,injectStyles:o=!0,touchStyles:l=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",c=>{(c.code==="Enter"||c.code==="Space")&&(c.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(s),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),l&&this.domElement.classList.add("allow-touch-styles"),!rB&&o&&(E1e(M1e),rB=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=a}add(e,n,r,i,s){if(Object(r)===r)return new S1e(this,e,n,r);const a=e[n];switch(typeof a){case"number":return new _1e(this,e,n,r,i,s);case"boolean":return new p1e(this,e,n);case"string":return new w1e(this,e,n);case"function":return new a2(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,a)}addColor(e,n,r=1){return new y1e(this,e,n,r)}addFolder(e){const n=new h1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof a2||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 a2)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=s=>{s.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function o2(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(c){try{l(r.next(c))}catch(u){s(u)}}function o(c){try{l(r.throw(c))}catch(u){s(u)}}function l(c){var u;c.done?i(c.value):(u=c.value,u instanceof n?u:new n((function(h){h(u)}))).then(a,o)}l((r=r.apply(t,[])).next())}))}class Ck{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 Ck(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 Nk{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class iB extends Nk{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class gu extends Nk{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class sB{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class p1{constructor(e){this.lines=[],this.preamble=new sB(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((s=>s.comment))).thumbnails;for(const[s,a]of Object.entries(i))this.metadata.thumbnails[s]=a;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),s=i[0],a=n&&i[1]||void 0,o=s.split(/([a-zA-Z])/g).slice(1).map((u=>u.trim())),l=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",c=this.parseParams(o.slice(2));switch(l){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new iB(e,l,c,a);case"t0":return new gu(e,l,a,0);case"t1":return new gu(e,l,a,1);case"t2":return new gu(e,l,a,2);case"t3":return new gu(e,l,a,3);case"t4":return new gu(e,l,a,4);case"t5":return new gu(e,l,a,5);case"t6":return new gu(e,l,a,6);case"t7":return new gu(e,l,a,7);default:return new Nk(e,l,c,a)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,s)=>{if(i%2==0)return n;let a=s[i-1];return a=a.toLowerCase(),this.isAlpha(a)&&(n[a]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof iB){const s=i.params;if(s.z&&(this.curZ=s.z),((n=s.e)!==null&&n!==void 0?n:0)>0&&(s.x!=null||s.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const a=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new sB(this.layers.length,[],r,a))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const s=i.comment;if(!s)continue;const a=s.indexOf("thumbnail begin"),o=s.indexOf("thumbnail end");a>-1?r=Ck.parse(s.slice(a+15).trim()):r&&(o==-1?r.chars+=s.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}p1.prototype.parseGcode=p1.prototype.parseGCode;const aB={type:"change"},l2={type:"start"},oB={type:"end"},Uy=new wk,lB=new yu,A1e=Math.cos(70*E7.DEG2RAD);class T1e extends Yf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ne,this.cursor=new Ne,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:Xh.ROTATE,MIDDLE:Xh.DOLLY,RIGHT:Xh.PAN},this.touches={ONE:Kh.ROTATE,TWO:Kh.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(z){z.addEventListener("keydown",De),this._domElementKeyEvents=z},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",De),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(aB),r.update(),s=i.NONE},this.update=(function(){const z=new Ne,ie=new Lf().setFromUnitVectors(e.up,new Ne(0,1,0)),X=ie.clone().invert(),J=new Ne,le=new Lf,Re=new Ne,Ae=2*Math.PI;return function(se=null){const U=r.object.position;z.copy(U).sub(r.target),z.applyQuaternion(ie),o.setFromVector3(z),r.autoRotate&&s===i.NONE&&k((function(ye){return ye!==null?2*Math.PI/60*r.autoRotateSpeed*ye:2*Math.PI/60/60*r.autoRotateSpeed})(se)),r.enableDamping?(o.theta+=l.theta*r.dampingFactor,o.phi+=l.phi*r.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let L=r.minAzimuthAngle,ne=r.maxAzimuthAngle;isFinite(L)&&isFinite(ne)&&(L<-Math.PI?L+=Ae:L>Math.PI&&(L-=Ae),ne<-Math.PI?ne+=Ae:ne>Math.PI&&(ne-=Ae),o.theta=L<=ne?Math.max(L,Math.min(ne,o.theta)):o.theta>(L+ne)/2?Math.max(L,o.theta):Math.min(ne,o.theta)),o.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,o.phi)),o.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(u,r.dampingFactor):r.target.add(u),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&P||r.object.isOrthographicCamera?o.radius=Z(o.radius):o.radius=Z(o.radius*c),z.setFromSpherical(o),z.applyQuaternion(X),U.copy(r.target).add(z),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,u.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let ve=!1;if(r.zoomToCursor&&P){let ye=null;if(r.object.isPerspectiveCamera){const xe=z.length();ye=Z(xe*c);const tt=xe-ye;r.object.position.addScaledVector(T,tt),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const xe=new Ne(A.x,A.y,0);xe.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),ve=!0;const tt=new Ne(A.x,A.y,0);tt.unproject(r.object),r.object.position.sub(tt).add(xe),r.object.updateMatrixWorld(),ye=z.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;ye!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(ye).add(r.object.position):(Uy.origin.copy(r.object.position),Uy.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(Uy.direction))<A1e?e.lookAt(r.target):(lB.setFromNormalAndCoplanarPoint(r.object.up,r.target),Uy.intersectPlane(lB,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/c)),r.object.updateProjectionMatrix(),ve=!0);return c=1,P=!1,!!(ve||J.distanceToSquared(r.object.position)>a||8*(1-le.dot(r.object.quaternion))>a||Re.distanceToSquared(r.target)>0)&&(r.dispatchEvent(aB),J.copy(r.object.position),le.copy(r.object.quaternion),Re.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",de),r.domElement.removeEventListener("pointerdown",me),r.domElement.removeEventListener("pointercancel",he),r.domElement.removeEventListener("wheel",we),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",he),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",De),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=i.NONE;const a=1e-6,o=new tB,l=new tB;let c=1;const u=new Ne,h=new Kt,g=new Kt,m=new Kt,b=new Kt,y=new Kt,v=new Kt,x=new Kt,M=new Kt,w=new Kt,T=new Ne,A=new Kt;let P=!1;const C=[],j={};function N(){return Math.pow(.95,r.zoomSpeed)}function k(z){l.theta-=z}function F(z){l.phi-=z}const I=(function(){const z=new Ne;return function(ie,X){z.setFromMatrixColumn(X,0),z.multiplyScalar(-ie),u.add(z)}})(),W=(function(){const z=new Ne;return function(ie,X){r.screenSpacePanning===!0?z.setFromMatrixColumn(X,1):(z.setFromMatrixColumn(X,0),z.crossVectors(r.object.up,z)),z.multiplyScalar(ie),u.add(z)}})(),D=(function(){const z=new Ne;return function(ie,X){const J=r.domElement;if(r.object.isPerspectiveCamera){const le=r.object.position;z.copy(le).sub(r.target);let Re=z.length();Re*=Math.tan(r.object.fov/2*Math.PI/180),I(2*ie*Re/J.clientHeight,r.object.matrix),W(2*X*Re/J.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(I(ie*(r.object.right-r.object.left)/r.object.zoom/J.clientWidth,r.object.matrix),W(X*(r.object.top-r.object.bottom)/r.object.zoom/J.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function $(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c/=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(z){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?c*=z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(z){if(!r.zoomToCursor)return;P=!0;const ie=r.domElement.getBoundingClientRect(),X=z.clientX-ie.left,J=z.clientY-ie.top,le=ie.width,Re=ie.height;A.x=X/le*2-1,A.y=-J/Re*2+1,T.set(A.x,A.y,1).unproject(r.object).sub(r.object.position).normalize()}function Z(z){return Math.max(r.minDistance,Math.min(r.maxDistance,z))}function K(z){h.set(z.clientX,z.clientY)}function ee(z){b.set(z.clientX,z.clientY)}function H(){if(C.length===1)h.set(C[0].pageX,C[0].pageY);else{const z=.5*(C[0].pageX+C[1].pageX),ie=.5*(C[0].pageY+C[1].pageY);h.set(z,ie)}}function Y(){if(C.length===1)b.set(C[0].pageX,C[0].pageY);else{const z=.5*(C[0].pageX+C[1].pageX),ie=.5*(C[0].pageY+C[1].pageY);b.set(z,ie)}}function te(){const z=C[0].pageX-C[1].pageX,ie=C[0].pageY-C[1].pageY,X=Math.sqrt(z*z+ie*ie);x.set(0,X)}function ae(z){if(C.length==1)g.set(z.pageX,z.pageY);else{const X=B(z),J=.5*(z.pageX+X.x),le=.5*(z.pageY+X.y);g.set(J,le)}m.subVectors(g,h).multiplyScalar(r.rotateSpeed);const ie=r.domElement;k(2*Math.PI*m.x/ie.clientHeight),F(2*Math.PI*m.y/ie.clientHeight),h.copy(g)}function fe(z){if(C.length===1)y.set(z.pageX,z.pageY);else{const ie=B(z),X=.5*(z.pageX+ie.x),J=.5*(z.pageY+ie.y);y.set(X,J)}v.subVectors(y,b).multiplyScalar(r.panSpeed),D(v.x,v.y),b.copy(y)}function Q(z){const ie=B(z),X=z.pageX-ie.x,J=z.pageY-ie.y,le=Math.sqrt(X*X+J*J);M.set(0,le),w.set(0,Math.pow(M.y/x.y,r.zoomSpeed)),$(w.y),x.copy(M)}function me(z){r.enabled!==!1&&(C.length===0&&(r.domElement.setPointerCapture(z.pointerId),r.domElement.addEventListener("pointermove",Ee),r.domElement.addEventListener("pointerup",he)),(function(ie){C.push(ie)})(z),z.pointerType==="touch"?(function(ie){switch(Le(ie),C.length){case 1:switch(r.touches.ONE){case Kh.ROTATE:if(r.enableRotate===!1)return;H(),s=i.TOUCH_ROTATE;break;case Kh.PAN:if(r.enablePan===!1)return;Y(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case Kh.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&te(),r.enablePan&&Y(),s=i.TOUCH_DOLLY_PAN;break;case Kh.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&te(),r.enableRotate&&H(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(l2)})(z):(function(ie){let X;switch(ie.button){case 0:X=r.mouseButtons.LEFT;break;case 1:X=r.mouseButtons.MIDDLE;break;case 2:X=r.mouseButtons.RIGHT;break;default:X=-1}switch(X){case Xh.DOLLY:if(r.enableZoom===!1)return;(function(J){V(J),x.set(J.clientX,J.clientY)})(ie),s=i.DOLLY;break;case Xh.ROTATE:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enablePan===!1)return;ee(ie),s=i.PAN}else{if(r.enableRotate===!1)return;K(ie),s=i.ROTATE}break;case Xh.PAN:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enableRotate===!1)return;K(ie),s=i.ROTATE}else{if(r.enablePan===!1)return;ee(ie),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(l2)})(z))}function Ee(z){r.enabled!==!1&&(z.pointerType==="touch"?(function(ie){switch(Le(ie),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ae(ie),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;fe(ie),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(X){r.enableZoom&&Q(X),r.enablePan&&fe(X)})(ie),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(X){r.enableZoom&&Q(X),r.enableRotate&&ae(X)})(ie),r.update();break;default:s=i.NONE}})(z):(function(ie){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(X){g.set(X.clientX,X.clientY),m.subVectors(g,h).multiplyScalar(r.rotateSpeed);const J=r.domElement;k(2*Math.PI*m.x/J.clientHeight),F(2*Math.PI*m.y/J.clientHeight),h.copy(g),r.update()})(ie);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(X){M.set(X.clientX,X.clientY),w.subVectors(M,x),w.y>0?$(N()):w.y<0&&G(N()),x.copy(M),r.update()})(ie);break;case i.PAN:if(r.enablePan===!1)return;(function(X){y.set(X.clientX,X.clientY),v.subVectors(y,b).multiplyScalar(r.panSpeed),D(v.x,v.y),b.copy(y),r.update()})(ie)}})(z))}function he(z){(function(ie){delete j[ie.pointerId];for(let X=0;X<C.length;X++)if(C[X].pointerId==ie.pointerId)return void C.splice(X,1)})(z),C.length===0&&(r.domElement.releasePointerCapture(z.pointerId),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",he)),r.dispatchEvent(oB),s=i.NONE}function we(z){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(z.preventDefault(),r.dispatchEvent(l2),(function(ie){V(ie),ie.deltaY<0?G(N()):ie.deltaY>0&&$(N()),r.update()})(z),r.dispatchEvent(oB))}function De(z){r.enabled!==!1&&r.enablePan!==!1&&(function(ie){let X=!1;switch(ie.code){case r.keys.UP:ie.ctrlKey||ie.metaKey||ie.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,r.keyPanSpeed),X=!0;break;case r.keys.BOTTOM:ie.ctrlKey||ie.metaKey||ie.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(0,-r.keyPanSpeed),X=!0;break;case r.keys.LEFT:ie.ctrlKey||ie.metaKey||ie.shiftKey?k(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(r.keyPanSpeed,0),X=!0;break;case r.keys.RIGHT:ie.ctrlKey||ie.metaKey||ie.shiftKey?k(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):D(-r.keyPanSpeed,0),X=!0}X&&(ie.preventDefault(),r.update())})(z)}function de(z){r.enabled!==!1&&z.preventDefault()}function Le(z){let ie=j[z.pointerId];ie===void 0&&(ie=new Kt,j[z.pointerId]=ie),ie.set(z.pageX,z.pageY)}function B(z){const ie=z.pointerId===C[0].pointerId?C[1]:C[0];return j[ie.pointerId]}r.domElement.addEventListener("contextmenu",de),r.domElement.addEventListener("pointerdown",me),r.domElement.addEventListener("pointercancel",he),r.domElement.addEventListener("wheel",we,{passive:!1}),this.update()}}bt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Kt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},js.line={uniforms:Mk.merge([bt.common,bt.fog,bt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class W7 extends ed{constructor(e){super({type:"LineMaterial",uniforms:Mk.clone(js.line.uniforms),vertexShader:js.line.vertexShader,fragmentShader:js.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 cB=new Wa,Fy=new Ne;class q7 extends d1e{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new Lr([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new Lr([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const n=this.attributes.instanceStart,r=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),r.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new V3(n,6,1);return this.setAttribute("instanceStart",new Lu(r,3,0)),this.setAttribute("instanceEnd",new Lu(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new V3(n,6,1);return this.setAttribute("instanceColorStart",new Lu(r,3,0)),this.setAttribute("instanceColorEnd",new Lu(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new i1e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wa);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),cB.setFromBufferAttribute(n),this.boundingBox.union(cB))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Qo),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Fy.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Fy)),Fy.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(Fy));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 uB=new Ne,dB=new Ne,Fi=new Gn,zi=new Gn,jo=new Gn,c2=new Ne,u2=new Jn,Bi=new f1e,fB=new Ne,zy=new Wa,By=new Qo,Uo=new Gn;let Fo,Qd;function hB(t,e,n){return Uo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Uo.multiplyScalar(1/Uo.w),Uo.x=Qd/n.width,Uo.y=Qd/n.height,Uo.applyMatrix4(t.projectionMatrixInverse),Uo.multiplyScalar(1/Uo.w),Math.abs(Math.max(Uo.x,Uo.y))}class C1e extends yo{constructor(e=new q7,n=new W7({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let a=0,o=0,l=n.count;a<l;a++,o+=2)uB.fromBufferAttribute(n,a),dB.fromBufferAttribute(r,a),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+uB.distanceTo(dB);const s=new V3(i,2,1);return e.setAttribute("instanceDistanceStart",new Lu(s,1,0)),e.setAttribute("instanceDistanceEnd",new Lu(s,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Fo=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;let c,u;Qd=l.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),By.copy(o.boundingSphere).applyMatrix4(a),r?c=.5*Qd:c=hB(i,Math.max(i.near,By.distanceToPoint(Fo.origin)),l.resolution),By.radius+=c,Fo.intersectsSphere(By)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),zy.copy(o.boundingBox).applyMatrix4(a),r?u=.5*Qd:u=hB(i,Math.max(i.near,zy.distanceToPoint(Fo.origin)),l.resolution),zy.expandByScalar(u),Fo.intersectsBox(zy)!==!1&&(r?(function(h,g){const m=h.matrixWorld,b=h.geometry,y=b.attributes.instanceStart,v=b.attributes.instanceEnd;for(let x=0,M=Math.min(b.instanceCount,y.count);x<M;x++){Bi.start.fromBufferAttribute(y,x),Bi.end.fromBufferAttribute(v,x),Bi.applyMatrix4(m);const w=new Ne,T=new Ne;Fo.distanceSqToSegment(Bi.start,Bi.end,T,w),T.distanceTo(w)<.5*Qd&&g.push({point:T,pointOnLine:w,distance:Fo.origin.distanceTo(T),object:h,face:null,faceIndex:x,uv:null,uv1:null})}})(this,n):(function(h,g,m){const b=g.projectionMatrix,y=h.material.resolution,v=h.matrixWorld,x=h.geometry,M=x.attributes.instanceStart,w=x.attributes.instanceEnd,T=Math.min(x.instanceCount,M.count),A=-g.near;Fo.at(1,jo),jo.w=1,jo.applyMatrix4(g.matrixWorldInverse),jo.applyMatrix4(b),jo.multiplyScalar(1/jo.w),jo.x*=y.x/2,jo.y*=y.y/2,jo.z=0,c2.copy(jo),u2.multiplyMatrices(g.matrixWorldInverse,v);for(let P=0,C=T;P<C;P++){if(Fi.fromBufferAttribute(M,P),zi.fromBufferAttribute(w,P),Fi.w=1,zi.w=1,Fi.applyMatrix4(u2),zi.applyMatrix4(u2),Fi.z>A&&zi.z>A)continue;if(Fi.z>A){const I=Fi.z-zi.z,W=(Fi.z-A)/I;Fi.lerp(zi,W)}else if(zi.z>A){const I=zi.z-Fi.z,W=(zi.z-A)/I;zi.lerp(Fi,W)}Fi.applyMatrix4(b),zi.applyMatrix4(b),Fi.multiplyScalar(1/Fi.w),zi.multiplyScalar(1/zi.w),Fi.x*=y.x/2,Fi.y*=y.y/2,zi.x*=y.x/2,zi.y*=y.y/2,Bi.start.copy(Fi),Bi.start.z=0,Bi.end.copy(zi),Bi.end.z=0;const j=Bi.closestPointToPointParameter(c2,!0);Bi.at(j,fB);const N=E7.lerp(Fi.z,zi.z,j),k=N>=-1&&N<=1,F=c2.distanceTo(fB)<.5*Qd;if(k&&F){Bi.start.fromBufferAttribute(M,P),Bi.end.fromBufferAttribute(w,P),Bi.start.applyMatrix4(v),Bi.end.applyMatrix4(v);const I=new Ne,W=new Ne;Fo.distanceSqToSegment(Bi.start,Bi.end,W,I),m.push({point:W,pointOnLine:I,distance:Fo.origin.distanceTo(W),object:h,face:null,faceIndex:P,uv:null,uv1:null})}}})(this,i,n)))}}class N1e extends xw{constructor(e,n,r,i,s=4473924,a=8947848){s=new Bt(s),a=new Bt(a);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const l=[],c=[];let u=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){l.push(g,0,-1*r,g,0,r);const m=g===0?s:a;m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3}for(let g=-1*r;g<=r;g+=i){l.push(-1*e,0,g,e,0,g);const m=g===0?s:a;m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3,m.toArray(c,u),u+=3}const h=new us;h.setAttribute("position",new Lr(l,3)),h.setAttribute("color",new Lr(c,3)),super(h,new K0({vertexColors:!0,toneMapped:!1}))}}function R1e(t,e,n,r){const i=(function(a,o,l){a*=.5,o*=.5,l*=.5;const c=new us,u=[];return u.push(-a,-o,-l,-a,o,-l,-a,o,-l,a,o,-l,a,o,-l,a,-o,-l,a,-o,-l,-a,-o,-l,-a,-o,l,-a,o,l,-a,o,l,a,o,l,a,o,l,a,-o,l,a,-o,l,-a,-o,l,-a,-o,-l,-a,-o,l,-a,o,-l,-a,o,l,a,o,-l,a,o,l,a,-o,-l,a,-o,l),c.setAttribute("position",new Lr(u,3)),c})(t,e,n),s=new xw(i,new a1e({color:new Bt(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var Nx=function(){var t=0,e=document.createElement("div");function n(u){return e.appendChild(u.dom),u}function r(u){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===u?"block":"none";t=u}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(u){u.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),s=i,a=0,o=n(new Nx.Panel("FPS","#0ff","#002")),l=n(new Nx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Nx.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){a++;var u=(performance||Date).now();if(l.update(u-i,200),u>=s+1e3&&(o.update(1e3*a/(u-s),100),s=u,a=0,c)){var h=performance.memory;c.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return u},update:function(){i=this.end()},domElement:e,setMode:r}};Nx.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),o=80*a,l=48*a,c=3*a,u=2*a,h=3*a,g=15*a,m=74*a,b=30*a,y=document.createElement("canvas");y.width=o,y.height=l,y.style.cssText="width:80px;height:48px";var v=y.getContext("2d");return v.font="bold "+9*a+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=n,v.fillRect(0,0,o,l),v.fillStyle=e,v.fillText(t,c,u),v.fillRect(h,g,m,b),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(h,g,m,b),{dom:y,update:function(x,M){r=Math.min(r,x),i=Math.max(i,x),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,o,g),v.fillStyle=e,v.fillText(s(x)+" "+t+" ("+s(r)+"-"+s(i)+")",c,u),v.drawImage(y,h+a,g,m-a,b,h,g,m-a,b),v.fillRect(h+m-a,g,a,b),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(h+m-a,g,a,s((1-x/M)*b))}}};var P1e=Nx;class pB{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new h1,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 h1,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 k1e extends us{constructor(e=[new Ne],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const s=new Ne,a=new Ne,o=new Kt,l=[],c=[],u=[],h=[];function g(m){const[b,y,v]=(function(x){const M=e[x],w=new Ne,T=new Ne,A=new Ne,P=new Ne;w.copy(M).sub(e[x-1]||M).normalize().add((e[x+1]||M).clone().sub(M).normalize()).normalize();let C=Number.MAX_VALUE;const j=Math.abs(w.x),N=Math.abs(w.y),k=Math.abs(w.z);return j<=C&&(C=j,T.set(1,0,0)),N<=C&&(C=N,T.set(0,1,0)),k<=C&&T.set(0,0,1),P.crossVectors(w,T).normalize(),T.crossVectors(w,P),A.crossVectors(w,T),[M,T,A]})(m);for(let x=0;x<=i;x++){const M=x/i*Math.PI*2,w=Math.sin(M),T=-Math.cos(M);a.x=T*y.x+w*v.x,a.y=T*y.y+w*v.y,a.z=T*y.z+w*v.z,a.normalize(),c.push(a.x,a.y,a.z),s.x=b.x+n*a.x*.5,s.y=b.y+n*a.y*.5,s.z=b.z+r*a.z*.5,l.push(s.x,s.y,s.z)}}(function(){for(let m=0;m<e.length;m++)g(m);g(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let b=0;b<=i;b++)o.x=m/e.length,o.y=b/i,u.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let b=1;b<=i;b++){const y=(i+1)*(m-1)+(b-1),v=(i+1)*m+(b-1),x=(i+1)*m+b,M=(i+1)*(m-1)+b;h.push(y,v,M),h.push(v,x,M)}})()})(),this.setIndex(h),this.setAttribute("position",new Lr(l,3)),this.setAttribute("normal",new Lr(c,3)),this.setAttribute("uv",new Lr(u,2))}}class Rx{static get initial(){const e=new Rx;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const d2={h:0,s:0,l:0};class Fp{constructor(e){var n,r,i,s,a,o,l,c,u;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Rx.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Fp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Bt(14737632),this._travelColor=new Bt(10027008),this._toolColors={},this.devMode=!1,this._lastRenderTime=0,this._wireframe=!1,this.minLayerThreshold=(n=e.minLayerThreshold)!==null&&n!==void 0?n:this.minLayerThreshold,this.parser=new p1(this.minLayerThreshold),this.scene=new X_e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Bt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(s=e.renderExtrusion)!==null&&s!==void 0?s:this.renderExtrusion,this.renderTravel=(a=e.renderTravel)!==null&&a!==void 0?a:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(l=e.renderTubes)!==null&&l!==void 0?l:this.renderTubes,this.extrusionWidth=(c=e.extrusionWidth)!==null&&c!==void 0?c:this.extrusionWidth,this.devMode=(u=e.devMode)!==null&&u!==void 0?u:this.devMode,this.stats=this.devMode?new P1e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Bt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Bt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Bt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,b]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new Bt(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+fw),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 $3({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new $3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new la(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const h=this.camera.far,g=.8*h;this.scene.fog=new Tk(this._backgroundColor,g,h),this.resize(),this.controls=new T1e(this.camera,this.renderer.domElement),this.initScene(),this.animate(),e.allowDragNDrop&&this._enableDropHandler(),this.initStats()}get extrusionColor(){return this._extrusionColor}set extrusionColor(e){if(Array.isArray(e)){this._extrusionColor=[];for(const[n,r]of e.entries())this._extrusionColor[n]=new Bt(r)}else this._extrusionColor=new Bt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Fp.defaultExtrusionColor:this._extrusionColor instanceof Bt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Fp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Bt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Bt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Bt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Bt(e):void 0}get layers(){return[this.parser.preamble].concat(this.parser.layers.concat())}get maxLayerIndex(){var e;return((e=this.endLayer)!==null&&e!==void 0?e:this.layers.length)-1}get minLayerIndex(){var e;return this.singleLayerMode?this.maxLayerIndex:((e=this.startLayer)!==null&&e!==void 0?e:0)-1}animate(){var e;this.animationFrameId=requestAnimationFrame((()=>this.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)===null||e===void 0||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){const e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){const e=new h1e(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 u1e(13421772,.3*Math.PI),n=new c1e(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 mx;return n.name=e,n.quaternion.setFromEuler(new q0(-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=Rx.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 o2(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,s,a,o,l,c;if(e>this.maxLayerIndex)return;const u=this.layers[e],h={extrusion:[],travel:[],z:this.state.z,height:u.height};for(const g of u.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(h,e),h.extrusion=[];const m=g;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const m=g,b={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=m.params.r)!==null&&s!==void 0?s:this.state.r,e:(a=m.params.e)!==null&&a!==void 0?a:this.state.e,i:(o=m.params.i)!==null&&o!==void 0?o:this.state.i,j:(l=m.params.j)!==null&&l!==void 0?l:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((c=m.params.e)!==null&&c!==void 0?c:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(h,this.state,b,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(h,this.state,b,y))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(h,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let s=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const a=.1+.7*n/this.layers.length;s.getHSL(d2),s=new Bt().setHSL(d2.h,d2.s,a)}if(n==this.layers.length-1){const a=(r=this._topLayerColor)!==null&&r!==void 0?r:s,o=(i=this._lastSegmentColor)!==null&&i!==void 0?i:a,l=e.extrusion.splice(-3),c=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,a.getHex(),e.height),this.addTubeLine([...c,...l],o.getHex(),e.height)):(this.addLine(e.extrusion,a.getHex()),this.addLine([...c,...l],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,s.getHex(),e.height):this.addLine(e.extrusion,s.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new N1e(this.buildVolume.x,10,this.buildVolume.y,10));const e=R1e(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 p1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Rx.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,s){const a=i?e.extrusion:e.travel,o=n.x,l=n.y,c=n.z,u=r.x,h=r.y,g=r.z;let m=r.r,b=r.i,y=r.j;if(m){const $=u-o,G=h-l,V=Math.sqrt(Math.pow($/2,2)+Math.pow(G/2,2));m=Math.max(m,V);const Z=Math.pow($,2)+Math.pow(G,2),K=Math.pow(m,2)-Z/4;let ee=Math.sqrt(K/Z);(s&&m<0||!s&&m>0)&&(ee=-ee),b=$/2+G*ee,y=G/2-$*ee}const v=o==u&&l==h,x=o+b,M=l+y,w=Math.sqrt(b*b+y*y),T=Math.atan2(-y,-b),A=Math.atan2(h-M,u-x);let P;v?P=2*Math.PI:(P=s?T-A:A-T,P<0&&(P+=2*Math.PI));let C=w*P/1.8;this.inches&&(C*=25),C<1&&(C=1);let j=P/C;j*=s?-1:1;const N=[];N.push({x:o,y:l,z:c});const k=(c-g)/C;let F=o,I=l,W=c,D=T;for(let $=0;$<C-1;$++)D+=j,F=x+w*Math.cos(D),I=M+w*Math.sin(D),W+=k,N.push({x:F,y:I,z:W});N.push({x:r.x,y:r.y,z:r.z});for(let $=0;$<N.length-1;$++)a.push(N[$].x,N[$].y,N[$].z,N[$+1].x,N[$+1].y,N[$+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new us;i.setAttribute("position",new Lr(e,3)),this.disposables.push(i);const s=new K0({color:n});this.disposables.push(s);const a=new xw(i,s);(r=this.group)===null||r===void 0||r.add(a)}addTubeLine(e,n,r=.2){let i=[];const s=[];for(let a=0;a<e.length;a+=6){const o=e.slice(a,a+9),l=new Ne(o[0],o[1],o[2]),c=new Ne(o[3],o[4],o[5]),u=new Ne(o[6],o[7],o[8]);i.push(l),c.equals(u)||(i.push(c),s.push(i),i=[])}s.forEach((a=>{var o;const l=new k1e(a,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(l)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new q7;this.disposables.push(i);const s=new W7({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const a=new C1e(i,s);(r=this.group)===null||r===void 0||r.add(a)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>o2(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 s1e({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((o,l)=>3*l.attributes.position.count+o),0),a=new n1e(r.length,s,void 0,i);return this.disposables.push(a),(n=this.group)===null||n===void 0||n.add(a),a}_readFromStream(e){var n,r;return o2(this,void 0,void 0,(function*(){const i=e.getReader();let s,a="",o=0;do{console.debug("reading from stream"),s=yield i.read(),o+=(r=(n=s.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const c=(l=s.value,new TextDecoder("utf-8").decode(l)),u=c.lastIndexOf(`
- `),h=c.slice(0,u);this.parser.parseGCode(a+h),a=c.slice(u)}while(!s.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new pB(this):typeof this.devMode=="object"&&(this.devGui=new pB(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())}}Fp.defaultExtrusionColor=new Bt("hotpink");const D1e=function(t){return new Fp(t)};function O1e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=E.useRef(null),i=E.useRef(null),[s,a]=E.useState(!0),[o,l]=E.useState(null),[c,u]=E.useState(!1),[h,g]=E.useState(0),[m,b]=E.useState(0);E.useEffect(()=>{if(!r.current)return;const x=r.current,M=D1e({canvas:x,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});i.current=M,a(!0),l(null),u(!1),fetch(t).then(async T=>{if(!T.ok)throw T.status===404&&(await T.json().catch(()=>({}))).detail?.includes("sliced")?(u(!0),new Error("not_sliced")):new Error("Failed to load G-code");return T.text()}).then(T=>{M.processGCode(T);const A=M.layers?.length||0;b(A),g(A),M.render(),a(!1)}).catch(T=>{l(T.message),a(!1)});const w=()=>{if(x.parentElement){const T=x.parentElement.getBoundingClientRect();x.width=T.width,x.height=T.height,M.resize()}};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),M.dispose()}},[t,e]);const y=x=>{if(!i.current)return;const M=Math.max(1,Math.min(x,m));g(M),i.current.render()},v=x=>{y(parseInt(x.target.value,10))};return f.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[f.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[f.jsx("canvas",{ref:r,className:"w-full h-full"}),s&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsxs("div",{className:"text-center",children:[f.jsx(Vt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),f.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),c&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsxs("div",{className:"text-center max-w-sm px-4",children:[f.jsx(Yae,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),f.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),f.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing the model in Bambu Studio or Orca Slicer."})]})}),o&&!c&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:f.jsx("div",{className:"text-center text-red-400",children:f.jsx("p",{className:"text-sm",children:o})})})]}),!s&&!o&&!c&&m>0&&f.jsx("div",{className:"mt-4 px-2",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Tf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),f.jsx("button",{onClick:()=>y(h-1),disabled:h<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:f.jsx(Af,{className:"w-4 h-4"})}),f.jsx("input",{type:"range",min:1,max:m,value:h,onChange:v,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),f.jsx("button",{onClick:()=>y(h+1),disabled:h>=m,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:f.jsx(Cm,{className:"w-4 h-4"})}),f.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[h," / ",m]})]})})]})}function L1e({archiveId:t,title:e,onClose:n}){const[r,i]=E.useState(null),[s,a]=E.useState(null),[o,l]=E.useState(!0);E.useEffect(()=>{const u=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]),E.useEffect(()=>{Ue.getArchiveCapabilities(t).then(u=>{a(u),u.has_model?i("3d"):u.has_gcode&&i("gcode"),l(!1)}).catch(()=>{a({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),l(!1)})},[t]);const c=()=>{const u=e||"model",h=`${window.location.origin}${Ue.getArchiveForSlicer(t,u)}`;window.location.href=`bambustudioopen://${encodeURIComponent(h)}`};return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:u=>u.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(We,{variant:"secondary",size:"sm",onClick:c,children:[f.jsx(gc,{className:"w-4 h-4"}),"Open in Slicer"]}),f.jsx(We,{variant:"ghost",size:"sm",onClick:n,children:f.jsx(tn,{className:"w-5 h-5"})})]})]}),s&&f.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[f.jsxs("button",{onClick:()=>s.has_model&&i("3d"),disabled:!s.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":s.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[f.jsx(qp,{className:"w-4 h-4"}),"3D Model",!s.has_model&&f.jsx("span",{className:"text-xs",children:"(not available)"})]}),f.jsxs("button",{onClick:()=>s.has_gcode&&i("gcode"),disabled:!s.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":s.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[f.jsx(Aae,{className:"w-4 h-4"}),"G-code Preview",!s.has_gcode&&f.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),f.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?f.jsx("div",{className:"w-full h-full flex items-center justify-center",children:f.jsx(Vt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&s?f.jsx(Rge,{url:Ue.getArchiveDownload(t),buildVolume:s.build_volume,className:"w-full h-full"}):r==="gcode"&&s?f.jsx(O1e,{gcodeUrl:Ue.getArchiveGcode(t),buildVolume:s.build_volume,className:"w-full h-full"}):f.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function I1e({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,s]=E.useState(null);E.useEffect(()=>{const u=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]);const{data:a,isLoading:o}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),l=Tt({mutationFn:()=>{if(!i)throw new Error("No printer selected");return Ue.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),c=a?.filter(u=>u.is_active)||[];return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:f.jsx(Ft,{className:"w-full max-w-md",children:f.jsxs($t,{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),f.jsx(We,{variant:"ghost",size:"sm",onClick:n,children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",f.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?f.jsx("div",{className:"flex justify-center py-8",children:f.jsx(Vt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c.length===0?f.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):f.jsx("div",{className:"space-y-2 mb-6",children:c.map(u=>f.jsxs("button",{onClick:()=>s(u.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===u.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[f.jsx("div",{className:`p-2 rounded-lg ${i===u.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:f.jsx(nl,{className:`w-5 h-5 ${i===u.id?"text-bambu-green":"text-bambu-gray"}`})}),f.jsxs("div",{className:"text-left",children:[f.jsx("p",{className:"text-white font-medium",children:u.name}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.model||"Unknown model"," • ",u.ip_address]})]})]},u.id))}),l.isError&&f.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:l.error.message||"Failed to start print"}),f.jsxs("div",{className:"flex gap-3",children:[f.jsx(We,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),f.jsx(We,{onClick:()=>l.mutate(),disabled:!i||l.isPending,className:"flex-1",children:l.isPending?f.jsxs(f.Fragment,{children:[f.jsx(Vt,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):f.jsxs(f.Fragment,{children:[f.jsx(nl,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function j1e({onClose:t,initialFiles:e}){const n=Rn(),{showToast:r}=Ki(),i=E.useRef(null),[s,a]=E.useState(()=>e?.filter(C=>C.name.endsWith(".3mf")).map(C=>({file:C,status:"pending"}))||[]),[o,l]=E.useState(!1),[c,u]=E.useState(),[h,g]=E.useState(null);E.useEffect(()=>{const C=j=>{j.key==="Escape"&&t()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t]);const{data:m}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),b=Tt({mutationFn:C=>Ue.uploadArchivesBulk(C,c),onSuccess:C=>{g(C),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),a(j=>j.map(N=>{const k=C.results.find(I=>I.filename===N.file.name),F=C.errors.find(I=>I.filename===N.file.name);return k?{...N,status:"success",archiveId:k.id}:F?{...N,status:"error",error:F.error}:N})),C.failed===0?r(`${C.uploaded} file${C.uploaded!==1?"s":""} uploaded`):C.uploaded===0?r(`Failed to upload ${C.failed} file${C.failed!==1?"s":""}`,"error"):r(`${C.uploaded} uploaded, ${C.failed} failed`,"warning")},onError:()=>{a(C=>C.map(j=>({...j,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=E.useCallback(C=>{C.preventDefault(),l(!0)},[]),v=E.useCallback(C=>{C.preventDefault(),l(!1)},[]),x=E.useCallback(C=>{C.preventDefault(),l(!1);const j=Array.from(C.dataTransfer.files).filter(N=>N.name.endsWith(".3mf"));j.length>0&&a(N=>[...N,...j.map(k=>({file:k,status:"pending"}))])},[]),M=E.useCallback(C=>{const j=Array.from(C.target.files||[]).filter(N=>N.name.endsWith(".3mf"));j.length>0&&a(N=>[...N,...j.map(k=>({file:k,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=E.useCallback(C=>{a(j=>j.filter((N,k)=>k!==C))},[]),T=()=>{if(s.length===0)return;const C=s.filter(j=>j.status==="pending");C.length!==0&&(a(j=>j.map(N=>N.status==="pending"?{...N,status:"uploading"}:N)),b.mutate(C.map(j=>j.file)))},A=s.filter(C=>C.status==="pending").length,P=b.isPending;return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ft,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:f.jsxs($t,{className:"p-0 flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"p-4",children:f.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:v,onDrop:x,children:[f.jsx(Yu,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),f.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),f.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),f.jsx(We,{variant:"secondary",onClick:()=>i.current?.click(),disabled:P,children:"Browse Files"}),f.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),f.jsxs("div",{className:"px-4 pb-4",children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),f.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c||"",onChange:C=>u(C.target.value?Number(C.target.value):void 0),disabled:P,children:[f.jsx("option",{value:"",children:"No printer"}),m?.map(C=>f.jsx("option",{value:C.id,children:C.name},C.id))]})]}),s.length>0&&f.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:f.jsx("div",{className:"space-y-2",children:s.map((C,j)=>f.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[f.jsx(c9,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),f.jsx("span",{className:"flex-1 text-white text-sm truncate",children:C.file.name}),f.jsxs("span",{className:"text-xs text-bambu-gray",children:[(C.file.size/(1024*1024)).toFixed(1)," MB"]}),C.status==="pending"&&f.jsx("button",{onClick:()=>w(j),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:P,children:f.jsx(tn,{className:"w-4 h-4"})}),C.status==="uploading"&&f.jsx(Vt,{className:"w-4 h-4 text-bambu-green animate-spin"}),C.status==="success"&&f.jsx(mc,{className:"w-4 h-4 text-bambu-green"}),C.status==="error"&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xs text-red-400",children:C.error}),f.jsx(Eo,{className:"w-4 h-4 text-red-400"})]})]},`${C.file.name}-${j}`))})}),h&&f.jsx("div",{className:"px-4 pb-4",children:f.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:f.jsxs("p",{className:"text-sm text-white",children:[f.jsx("span",{className:"text-bambu-green",children:h.uploaded})," uploaded",h.failed>0&&f.jsxs(f.Fragment,{children:[", ",f.jsx("span",{className:"text-red-400",children:h.failed})," failed"]})]})})}),f.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[f.jsx(We,{variant:"secondary",onClick:t,className:"flex-1",children:h?"Close":"Cancel"}),!h&&f.jsx(We,{onClick:T,disabled:A===0||P,className:"flex-1",children:P?f.jsxs(f.Fragment,{children:[f.jsx(Vt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):f.jsxs(f.Fragment,{children:[f.jsx(Yu,{className:"w-4 h-4"}),"Upload ",A>0&&`(${A})`]})})]})]})})})}const U1e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function F1e({archive:t,onClose:e,existingTags:n=[]}){E.useEffect(()=>{const Z=K=>{K.key==="Escape"&&e()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[e]);const r=Rn(),[i,s]=E.useState(t.print_name||""),[a,o]=E.useState(t.printer_id),[l,c]=E.useState(t.notes||""),[u,h]=E.useState(t.tags||""),[g,m]=E.useState(t.failure_reason||""),[b,y]=E.useState(t.photos||[]),[v,x]=E.useState(!1),[M,w]=E.useState(!1),T=E.useRef(null),A=E.useRef(null),P=E.useRef(null),{data:C}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),{data:j}=At({queryKey:["archives"],queryFn:()=>Ue.getArchives(void 0,1e3,0),enabled:n.length===0}),N=n.length>0?n:[...new Set(j?.flatMap(Z=>Z.tags?.split(",").map(K=>K.trim())||[]).filter(Boolean)||[])].sort(),k=u.split(",").map(Z=>Z.trim()).filter(Boolean),F=N.filter(Z=>!k.includes(Z)),I=Z=>{if(!k.includes(Z)){const K=[...k,Z].join(", ");h(K)}P.current!==null&&clearTimeout(P.current),T.current?.focus()},W=Z=>{const K=k.filter(ee=>ee!==Z).join(", ");h(K)},D=Tt({mutationFn:Z=>Ue.updateArchive(t.id,Z),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),e()}}),$=async Z=>{const K=Z.target.files?.[0];if(K){x(!0);try{const ee=await Ue.uploadArchivePhoto(t.id,K);y(ee.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ee){console.error("Failed to upload photo:",ee)}finally{x(!1),A.current&&(A.current.value="")}}},G=async Z=>{try{const K=await Ue.deleteArchivePhoto(t.id,Z);y(K.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(K){console.error("Failed to delete photo:",K)}},V=Z=>{Z.preventDefault(),D.mutate({print_name:i||void 0,printer_id:a,notes:l||void 0,tags:u||void 0,failure_reason:t.status==="failed"&&g||void 0})};return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:Z=>Z.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:V,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),f.jsx("input",{type:"text",value:i,onChange:Z=>s(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),f.jsxs("select",{value:a??"",onChange:Z=>o(Z.target.value?Number(Z.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"",children:"No printer"}),C?.map(Z=>f.jsx("option",{value:Z.id,children:Z.name},Z.id))]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),f.jsx("textarea",{value:l,onChange:Z=>c(Z.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),k.length>0&&f.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:k.map(Z=>f.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[f.jsx(e0,{className:"w-3 h-3"}),Z,f.jsx("button",{type:"button",onClick:()=>W(Z),className:"ml-0.5 text-bambu-gray hover:text-white",children:f.jsx(tn,{className:"w-3 h-3"})})]},Z))}),f.jsxs("div",{className:"relative",children:[f.jsx("input",{ref:T,type:"text",value:u,onChange:Z=>h(Z.target.value),onFocus:()=>{P.current!==null&&clearTimeout(P.current),w(!0)},onBlur:()=>{P.current=window.setTimeout(()=>w(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:k.length>0?"Add more tags...":"Add tags..."}),M&&F.length>0&&f.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:[f.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),f.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:F.map(Z=>f.jsx("button",{type:"button",onClick:()=>I(Z),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:Z},Z))})]})]})]}),t.status==="failed"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),f.jsxs("select",{value:g,onChange:Z=>m(Z.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"",children:"Select reason..."}),U1e.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[f.jsx(Z_,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),f.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[b.map(Z=>f.jsxs("div",{className:"relative group",children:[f.jsx("img",{src:Ue.getArchivePhotoUrl(t.id,Z),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),f.jsx("button",{type:"button",onClick:()=>G(Z),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:f.jsx(fr,{className:"w-3 h-3 text-white"})})]},Z)),f.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:[f.jsx("input",{ref:A,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:$,className:"hidden",disabled:v}),v?f.jsx(Vt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):f.jsx(ai,{className:"w-6 h-6 text-bambu-gray"})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsxs(We,{type:"submit",disabled:D.isPending,className:"flex-1",children:[f.jsx(Xo,{className:"w-4 h-4"}),D.isPending?"Saving...":"Save"]})]})]})]})})}function z1e({x:t,y:e,items:n,onClose:r}){const i=E.useRef(null);return E.useEffect(()=>{const s=l=>{i.current&&!i.current.contains(l.target)&&r()},a=l=>{l.key==="Escape"&&r()},o=()=>{r()};return document.addEventListener("mousedown",s),document.addEventListener("keydown",a),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",a),document.removeEventListener("scroll",o,!0)}},[r]),E.useEffect(()=>{if(i.current){const s=i.current.getBoundingClientRect(),a=window.innerWidth,o=window.innerHeight;let l=t,c=e;t+s.width>a&&(l=a-s.width-8),e+s.height>o&&(c=o-s.height-8),i.current.style.left=`${l}px`,i.current.style.top=`${c}px`}},[t,e]),f.jsx("div",{ref:i,className:"fixed z-50 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden",style:{left:t,top:e},children:n.map((s,a)=>s.divider?f.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},a):f.jsxs("button",{onClick:()=>{s.disabled||(s.onClick(),r())},disabled:s.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${s.disabled?"text-bambu-gray cursor-not-allowed":s.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[s.icon&&f.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:s.icon}),s.label]},a))})}function B1e({selectedIds:t,existingTags:e,onClose:n}){const r=Rn(),{showToast:i}=Ki(),[s,a]=E.useState(""),[o,l]=E.useState(new Set),[c,u]=E.useState("add");E.useEffect(()=>{const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const h=Tt({mutationFn:async()=>{const y=Array.from(o);let v=0;for(const x of t)try{const M=await Ue.getArchive(x),w=M.tags?M.tags.split(",").map(A=>A.trim()).filter(Boolean):[];let T;c==="add"?T=[...new Set([...w,...y])]:T=w.filter(A=>!o.has(A)),await Ue.updateArchive(x,{tags:T.join(", ")}),v++}catch(M){throw console.error(`Failed to update archive ${x}:`,M),new Error(`Failed on archive ${x}: ${M instanceof Error?M.message:"Unknown error"}`)}return{count:v,mode:c,tags:y}},onSuccess:({count:y,mode:v,tags:x})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${v==="add"?"Added":"Removed"} ${x.length} tag${x.length!==1?"s":""} ${v==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),g=y=>{l(v=>{const x=new Set(v);return x.has(y)?x.delete(y):x.add(y),x})},m=()=>{s.trim()&&!o.has(s.trim())&&(l(y=>new Set([...y,s.trim()])),a(""))},b=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ft,{className:"w-full max-w-md",children:f.jsxs($t,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(e0,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:c==="add"?"Add Tags":"Remove Tags"})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"p-4 space-y-4",children:[f.jsxs("p",{className:"text-sm text-bambu-gray",children:[c==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(We,{size:"sm",variant:c==="add"?"primary":"secondary",onClick:()=>u("add"),children:"Add Tags"}),f.jsx(We,{size:"sm",variant:c==="remove"?"primary":"secondary",onClick:()=>u("remove"),children:"Remove Tags"})]}),c==="add"&&f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:s,onChange:y=>a(y.target.value),onKeyDown:b}),f.jsx(We,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:f.jsx(ai,{className:"w-4 h-4"})})]}),e.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),f.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>f.jsx("button",{onClick:()=>g(y),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),o.size>0&&f.jsxs("div",{children:[f.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",c==="add"?"add":"remove",":"]}),f.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(y=>f.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${c==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,f.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:f.jsx(tn,{className:"w-3 h-3"})})]},y))})]})]}),f.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[f.jsx(We,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),f.jsx(We,{onClick:()=>h.mutate(),disabled:o.size===0||h.isPending,className:"flex-1",children:h.isPending?f.jsxs(f.Fragment,{children:[f.jsx(Vt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):f.jsxs(f.Fragment,{children:[f.jsx(e0,{className:"w-4 h-4"}),c==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function H1e(t,e){return new Date(t,e+1,0).getDate()}function $1e(t,e){return new Date(t,e,1).getDay()}const V1e=["January","February","March","April","May","June","July","August","September","October","November","December"],G1e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function W1e({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=E.useState(n.getMonth()),[s,a]=E.useState(n.getFullYear()),[o,l]=E.useState(null),c=E.useMemo(()=>{const x=new Map;return t.forEach(M=>{const w=new Date(M.completed_at||M.created_at),T=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,A=x.get(T)||[];A.push(M),x.set(T,A)}),x},[t]),u=H1e(s,r),h=$1e(s,r),g=()=>{r===0?(i(11),a(s-1)):i(r-1)},m=()=>{r===11?(i(0),a(s+1)):i(r+1)},b=()=>{i(n.getMonth()),a(n.getFullYear())},y=[];for(let x=0;x<h;x++)y.push(null);for(let x=1;x<=u;x++)y.push(x);const v=o?c.get(o)||[]:[];return f.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[f.jsxs("div",{className:"flex-1",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(Af,{className:"w-5 h-5 text-bambu-gray"})}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white",children:[V1e[r]," ",s]}),f.jsx("button",{onClick:b,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"})]}),f.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(Cm,{className:"w-5 h-5 text-bambu-gray"})})]}),f.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:G1e.map(x=>f.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:x},x))}),f.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((x,M)=>{if(x===null)return f.jsx("div",{className:"aspect-square"},`empty-${M}`);const w=`${s}-${String(r+1).padStart(2,"0")}-${String(x).padStart(2,"0")}`,T=c.get(w)||[],A=T.length>0,P=x===n.getDate()&&r===n.getMonth()&&s===n.getFullYear(),C=w===o,j=T.filter(k=>k.status==="completed").length,N=T.filter(k=>k.status==="failed").length;return f.jsxs("button",{onClick:()=>l(C?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${C?"bg-bambu-green text-white":P?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":A?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[f.jsx("span",{className:`text-sm font-medium ${P&&!C?"text-bambu-green":""}`,children:x}),A&&f.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[f.jsx("div",{className:`w-2 h-2 rounded-full ${N>0&&j===0?"bg-red-400":N>0?"bg-yellow-400":"bg-green-400"}`}),f.jsx("span",{className:"text-xs font-medium",children:T.length})]})]},x)})}),f.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===s}).length}),f.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===s&&x.status==="completed"}).length}),f.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===r&&M.getFullYear()===s&&x.status==="failed"}).length}),f.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),f.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?f.jsxs(f.Fragment,{children:[f.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"})}),v.length>0?f.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(x=>f.jsxs("button",{onClick:()=>e?.(x),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[x.thumbnail_path?f.jsx("img",{src:Ue.getArchiveThumbnail(x.id),alt:"",className:"w-12 h-12 rounded object-cover"}):f.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:f.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-sm text-white truncate",children:x.print_name||x.filename}),f.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[f.jsx("span",{className:x.status==="failed"?"text-red-400":"text-green-400",children:x.status==="failed"?"Failed":"Completed"}),x.filament_color&&f.jsx("div",{className:"flex gap-0.5",children:x.filament_color.split(",").map((M,w)=>f.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},w))})]})]})]},x.id))}):f.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):f.jsx("div",{className:"text-center py-8",children:f.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function q1e({archiveId:t,archiveName:e,onClose:n}){const r=Ue.getArchiveQRCodeUrl(t,300);E.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]);const i=()=>{const s=document.createElement("a");s.href=r,s.download=`${e}_qrcode.png`,s.click()};return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"p-6 flex flex-col items-center",children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),f.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:f.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),f.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),f.jsxs(We,{onClick:i,className:"w-full",children:[f.jsx(tl,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function X1e({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,a]=E.useState(0),[o,l]=E.useState(!1);if(E.useEffect(()=>{const m=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&a(y=>Math.max(0,y-1)),b.key==="ArrowRight"&&a(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),E.useEffect(()=>{s>=n.length&&a(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const c=n[s],u=Ue.getArchivePhotoUrl(t,c),h=()=>{const m=document.createElement("a");m.href=u,m.download=`${e}_photo_${s+1}.jpg`,m.click()},g=()=>{i&&l(!0)};return f.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[f.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),f.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(We,{variant:"secondary",size:"sm",onClick:h,children:[f.jsx(tl,{className:"w-4 h-4"}),"Download"]}),i&&f.jsx(We,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:f.jsx(fr,{className:"w-4 h-4"})}),f.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-6 h-6"})})]})]}),f.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&f.jsx("button",{onClick:()=>a(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:f.jsx(Af,{className:"w-8 h-8 text-white"})}),f.jsx("img",{src:u,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&f.jsx("button",{onClick:()=>a(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:f.jsx(Cm,{className:"w-8 h-8 text-white"})})]}),n.length>1&&f.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,b)=>f.jsx("button",{onClick:()=>a(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:f.jsx("img",{src:Ue.getArchivePhotoUrl(t,m),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&f.jsx(zs,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(c),l(!1)},onCancel:()=>l(!1)})]})}function $i(t){this.content=t}$i.prototype={constructor:$i,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new $i(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new $i(n)},addToStart:function(t,e){return new $i([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new $i(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new $i(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=$i.from(t),t.size?new $i(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=$i.from(t),t.size?new $i(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=$i.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}};$i.from=function(t){if(t instanceof $i)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new $i(e)};function X7(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let a=0;i.text[a]==s.text[a];a++)n++;return n}if(i.content.size||s.content.size){let a=X7(i.content,s.content,n+1);if(a!=null)return a}n+=i.nodeSize}}function K7(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let a=t.child(--i),o=e.child(--s),l=a.nodeSize;if(a==o){n-=l,r-=l;continue}if(!a.sameMarkup(o))return{a:n,b:r};if(a.isText&&a.text!=o.text){let c=0,u=Math.min(a.text.length,o.text.length);for(;c<u&&a.text[a.text.length-c-1]==o.text[o.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(a.content.size||o.content.size){let c=K7(a.content,o.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class pt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let a=0,o=0;o<n;a++){let l=this.content[a],c=o+l.nodeSize;if(c>e&&r(l,i+o,s||null,a)!==!1&&l.content.size){let u=o+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,i+u)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",a=!0;return this.nodesBetween(e,n,(o,l)=>{let c=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&r&&(a?a=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new pt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,a=0;a<n;s++){let o=this.content[s],l=a+o.nodeSize;l>e&&((a<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-a),Math.min(o.text.length,n-a)):o=o.cut(Math.max(0,e-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=l}return new pt(r,i)}cutByIndex(e,n){return e==n?pt.empty:e==0&&n==this.content.length?this:new pt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new pt(i,s)}addToStart(e){return new pt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new pt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return X7(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return K7(this,e,n,r)}findIndex(e){if(e==0)return Hy(0,e);if(e==this.size)return Hy(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?Hy(n+1,s):Hy(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return pt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new pt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return pt.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new pt(n||e,r)}static from(e){if(!e)return pt.empty;if(e instanceof pt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new pt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}pt.empty=new pt([],0);const f2={index:0,offset:0};function Hy(t,e){return f2.index=t,f2.offset=e,f2}function m1(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(!m1(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!m1(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Kn=class W3{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&m1(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 W3.none;if(e instanceof W3)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Kn.none=[];class g1 extends Error{}class Mt{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=Z7(this.content,e+this.openStart,n);return r&&new Mt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Mt(Y7(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 Mt.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 Mt(pt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Mt(e,r,i)}}Mt.empty=new Mt(pt.empty,0,0);function Y7(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:a,offset:o}=t.findIndex(n);if(i==e||s.isText){if(o!=n&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Y7(s.content,e-i-1,n-i-1)))}function Z7(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),a=t.maybeChild(i);if(s==e||a.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Z7(a.content,e-s-1,n,a);return o&&t.replaceChild(i,a.copy(o))}function K1e(t,e,n){if(n.openStart>t.depth)throw new g1("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new g1("Inconsistent open depths");return Q7(t,e,n,0)}function Q7(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let a=Q7(t,e,n,r+1);return s.copy(s.content.replaceChild(i,a))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let a=t.parent,o=a.content;return pf(a,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:a,end:o}=Y1e(n,t);return pf(s,eW(t,a,o,e,r))}else return pf(s,x1(t,e,r))}function J7(t,e){if(!e.type.compatibleContent(t.type))throw new g1("Cannot join "+e.type.name+" onto "+t.type.name)}function q3(t,e,n){let r=t.node(n);return J7(r,e.node(n)),r}function hf(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Px(t,e,n,r){let i=(e||t).node(n),s=0,a=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(hf(t.nodeAfter,r),s++));for(let o=s;o<a;o++)hf(i.child(o),r);e&&e.depth==n&&e.textOffset&&hf(e.nodeBefore,r)}function pf(t,e){return t.type.checkContent(e),t.copy(e)}function eW(t,e,n,r,i){let s=t.depth>i&&q3(t,e,i+1),a=r.depth>i&&q3(n,r,i+1),o=[];return Px(null,t,i,o),s&&a&&e.index(i)==n.index(i)?(J7(s,a),hf(pf(s,eW(t,e,n,r,i+1)),o)):(s&&hf(pf(s,x1(t,e,i+1)),o),Px(e,n,i,o),a&&hf(pf(a,x1(n,r,i+1)),o)),Px(r,null,i,o),new pt(o)}function x1(t,e,n){let r=[];if(Px(null,t,n,r),t.depth>n){let i=q3(t,e,n+1);hf(pf(i,x1(t,e,n+1)),r)}return Px(e,null,n,r),new pt(r)}function Y1e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(pt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class d0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Kn.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let s=r.marks;for(var a=0;a<s.length;a++)s[a].type.spec.inclusive===!1&&(!i||!s[a].isInSet(i.marks))&&(s=s[a--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new v1(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let a=e;;){let{index:o,offset:l}=a.content.findIndex(s),c=s-l;if(r.push(a,o,i+l),!c||(a=a.child(o),a.isText))break;s=c-1,i+=l+1}return new d0(n,r,s)}static resolveCached(e,n){let r=mB.get(e);if(r)for(let s=0;s<r.elts.length;s++){let a=r.elts[s];if(a.pos==n)return a}else mB.set(e,r=new Z1e);let i=r.elts[r.i]=d0.resolve(e,n);return r.i=(r.i+1)%Q1e,i}}class Z1e{constructor(){this.elts=[],this.i=0}}const Q1e=12,mB=new WeakMap;class v1{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 J1e=Object.create(null);let Vu=class X3{constructor(e,n,r,i=Kn.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||pt.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&m1(this.attrs,n||e.defaultAttrs||J1e)&&Kn.sameSet(this.marks,r||Kn.none)}copy(e=null){return e==this.content?this:new X3(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new X3(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 Mt.empty;let i=this.resolve(e),s=this.resolve(n),a=r?0:i.sharedDepth(n),o=i.start(a),c=i.node(a).content.cut(i.pos-o,s.pos-o);return new Mt(c,i.depth-a,s.depth-a)}replace(e,n,r){return K1e(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 d0.resolveCached(this,e)}resolveNoCache(e){return d0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),tW(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=pt.empty,i=0,s=r.childCount){let a=this.contentMatchAt(e).matchFragment(r,i,s),o=a&&a.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),a=s&&s.matchFragment(this.content,n);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Kn.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Kn.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=pt.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Vu.prototype.text=void 0;class b1 extends Vu{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):tW(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 b1(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new b1(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 tW(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class If{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new eSe(e,n);if(r.next==null)return If.empty;let i=nW(r);r.next&&r.err("Unexpected trailing text");let s=oSe(aSe(i));return lSe(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(a,o){let l=a.matchFragment(e,r);if(l&&(!n||l.validEnd))return pt.from(o.map(c=>c.createAndFill()));for(let c=0;c<a.next.length;c++){let{type:u,next:h}=a.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let g=s(h,o.concat(u));if(g)return g}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let a=[];for(let o=i;o.type;o=o.via)a.push(o.type);return a.reverse()}for(let a=0;a<s.next.length;a++){let{type:o,next:l}=s.next[a];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let a=0;a<r.next.length;a++)s+=(a?", ":"")+r.next[a].type.name+"->"+e.indexOf(r.next[a].next);return s}).join(`
- `)}}If.empty=new If(!0);class eSe{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 nW(t){let e=[];do e.push(tSe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function tSe(t){let e=[];do e.push(nSe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function nSe(t){let e=sSe(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=rSe(t,e);else break;return e}function gB(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function rSe(t,e){let n=gB(t),r=n;return t.eat(",")&&(t.next!="}"?r=gB(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function iSe(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let a=n[s];a.isInGroup(e)&&i.push(a)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function sSe(t){if(t.eat("(")){let e=nW(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=iSe(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 aSe(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(a,o,l){let c={term:l,to:o};return e[a].push(c),c}function i(a,o){a.forEach(l=>l.to=o)}function s(a,o){if(a.type=="choice")return a.exprs.reduce((l,c)=>l.concat(s(c,o)),[]);if(a.type=="seq")for(let l=0;;l++){let c=s(a.exprs[l],o);if(l==a.exprs.length-1)return c;i(c,o=n())}else if(a.type=="star"){let l=n();return r(o,l),i(s(a.expr,l),l),[r(l)]}else if(a.type=="plus"){let l=n();return i(s(a.expr,o),l),i(s(a.expr,l),l),[r(l)]}else{if(a.type=="opt")return[r(o)].concat(s(a.expr,o));if(a.type=="range"){let l=o;for(let c=0;c<a.min;c++){let u=n();i(s(a.expr,l),u),l=u}if(a.max==-1)i(s(a.expr,l),l);else for(let c=a.min;c<a.max;c++){let u=n();r(l,u),i(s(a.expr,l),u),l=u}return[r(l)]}else{if(a.type=="name")return[r(o,void 0,a.value)];throw new Error("Unknown expr type")}}}}function rW(t,e){return e-t}function xB(t,e){let n=[];return r(e),n.sort(rW);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let a=0;a<s.length;a++){let{term:o,to:l}=s[a];!o&&n.indexOf(l)==-1&&r(l)}}}function oSe(t){let e=Object.create(null);return n(xB(t,0));function n(r){let i=[];r.forEach(a=>{t[a].forEach(({term:o,to:l})=>{if(!o)return;let c;for(let u=0;u<i.length;u++)i[u][0]==o&&(c=i[u][1]);xB(t,l).forEach(u=>{c||i.push([o,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new If(r.indexOf(t.length-1)>-1);for(let a=0;a<i.length;a++){let o=i[a][1].sort(rW);s.next.push({type:i[a][0],next:e[o.join(",")]||n(o)})}return s}}function lSe(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,a=[];for(let o=0;o<i.next.length;o++){let{type:l,next:c}=i.next[o];a.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function iW(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 sW(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function aW(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function oW(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new uSe(t,r,e[r]);return n}let vB=class lW{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=oW(e,r.attrs),this.defaultAttrs=iW(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==If.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:sW(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Vu(this,this.computeAttrs(e),pt.from(n),Kn.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new Vu(this,this.computeAttrs(e),n,Kn.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=pt.from(n),n.size){let a=this.contentMatch.fillBefore(n);if(!a)return null;n=a.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(pt.empty,!0);return s?new Vu(this,e,n.append(s),Kn.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){aW(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Kn.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,a)=>r[s]=new lW(s,n,a));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function cSe(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class uSe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?cSe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class vw{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=oW(e,i.attrs),this.excluded=null;let s=iW(this.attrs);this.instance=s?new Kn(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Kn(this,sW(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,a)=>r[s]=new vw(s,i++,n,a)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){aW(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class cW{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=$i.from(e.nodes),n.marks=$i.from(e.marks||{}),this.nodes=vB.compile(this.spec.nodes,this),this.marks=vw.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],a=s.spec.content||"",o=s.spec.marks;if(s.contentMatch=r[a]||(r[a]=If.parse(a,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=o=="_"?null:o?bB(this,o.split(" ")):o==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],a=s.spec.excludes;s.excluded=a==null?[s]:a==""?[]:bB(this,a.split(" "))}this.nodeFromJSON=i=>Vu.fromJSON(this,i),this.markFromJSON=i=>Kn.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof vB){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 b1(r,r.defaultAttrs,e,Kn.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function bB(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],a=s;if(s)n.push(s);else for(let o in t.marks){let l=t.marks[o];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(a=l)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function dSe(t){return t.tag!=null}function fSe(t){return t.style!=null}let kx=class K3{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(dSe(i))this.tags.push(i);else if(fSe(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new _B(this,n,!1);return r.addAll(e,Kn.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new _B(this,n,!0);return r.addAll(e,Kn.none,n.from,n.to),Mt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(mSe(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let a=s.getAttrs(e);if(a===!1)continue;s.attrs=a||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let a=this.styles[s],o=a.style;if(!(o.indexOf(e)!=0||a.context&&!r.matchesContext(a.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(a.getAttrs){let l=a.getAttrs(n);if(l===!1)continue;a.attrs=l||void 0}return a}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,a=0;for(;a<n.length;a++){let o=n[a];if((o.priority==null?50:o.priority)<s)break}n.splice(a,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(a=>{r(a=SB(a)),a.mark||a.ignore||a.clearMark||(a.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(a=>{r(a=SB(a)),a.node||a.ignore||a.mark||(a.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new K3(e,K3.schemaRules(e)))}};const uW={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},hSe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dW={ol:!0,ul:!0},f0=1,Y3=2,Dx=4;function yB(t,e,n){return e!=null?(e?f0:0)|(e==="full"?Y3:0):t&&t.whitespace=="pre"?f0|Y3:n&~Dx}class $y{constructor(e,n,r,i,s,a){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=a,this.content=[],this.activeMarks=Kn.none,this.match=s||(a&Dx?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(pt.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&f0)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=pt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(pt.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!uW.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _B{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,a=yB(null,n.preserveWhitespace,0)|(r?Dx:0);i?s=new $y(i.type,i.attrs,Kn.none,!0,n.topMatch||i.type.contentMatch,a):r?s=new $y(null,null,Kn.none,!0,null,a):s=new $y(e.schema.topNodeType,null,Kn.none,!0,null,a),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&Y3?"full":this.localPreserveWS||(i.options&f0)>0,{schema:a}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
- `);else if(a.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(a.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(a.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(a.text(o[l]),n,!/\S/.test(o[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(a.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;dW.hasOwnProperty(a)&&this.parser.normalizeLists&&pSe(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:hSe.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(uW.hasOwnProperty(a))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=l&&l.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],a=r.getPropertyValue(s);if(a)for(let o=void 0;;){let l=this.parser.matchStyle(s,a,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,i){let s,a;if(n.node)if(a=this.parser.schema.nodes[n.node],a.isLeaf)this.insertNode(a.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(a,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(o)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let a=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];a!=o;a=a.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(a,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let a=this.open,o=0;a>=0;a--){let l=this.nodes[a],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+o)&&(i=c,s=l,!c.length))break;if(l.solid){if(r)break;o+=2}}if(!i)return null;this.sync(s);for(let a=0;a<i.length;a++)n=this.enterInner(i[a],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let a=Kn.none;for(let o of i.concat(e.marks))(s.type?s.type.allowsMarkType(o.type):wB(o.type,e.type))&&(a=o.addToSet(a));return s.content.push(e.mark(a)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=yB(e,s,a.options);a.options&Dx&&a.content.length==0&&(o|=Dx);let l=Kn.none;return r=r.filter(c=>(a.type?a.type.allowsMarkType(c.type):wB(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new $y(e,n,l,i,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=f0)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),a=(o,l)=>{for(;o>=0;o--){let c=n[o];if(c==""){if(o==n.length-1||o==0)continue;for(;l>=s;l--)if(a(o-1,l))return!0;return!1}else{let u=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return a(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function pSe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&dW.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function mSe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function SB(t){let e={};for(let n in t)e[n]=t[n];return e}function wB(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],a=o=>{s.push(o);for(let l=0;l<o.edgeCount;l++){let{type:c,next:u}=o.edge(l);if(c==e||s.indexOf(u)<0&&a(u))return!0}};if(a(i.contentMatch))return!0}}class Zf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=h2(n).createDocumentFragment());let i=r,s=[];return e.forEach(a=>{if(s.length||a.marks.length){let o=0,l=0;for(;o<s.length&&l<a.marks.length;){let c=a.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[o][0])||c.type.spec.spanning===!1)break;o++,l++}for(;o<s.length;)i=s.pop()[1];for(;l<a.marks.length;){let c=a.marks[l++],u=this.serializeMark(c,a.isInline,n);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=O_(h2(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&O_(h2(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return O_(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Zf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=MB(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return MB(e.marks)}}function MB(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function h2(t){return t.document||window.document}const EB=new WeakMap;function gSe(t){let e=EB.get(t);return e===void 0&&EB.set(t,e=xSe(t)),e}function xSe(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 O_(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=gSe(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let o,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let h in c)if(c[h]!=null){let g=h.indexOf(" ");g>0?l.setAttributeNS(h.slice(0,g),h.slice(g+1),c[h]):h=="style"&&l.style?l.style.cssText=c[h]:l.setAttribute(h,c[h])}}for(let h=u;h<e.length;h++){let g=e[h];if(g===0){if(h<e.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:b}=O_(t,g,n,r);if(l.appendChild(m),b){if(o)throw new RangeError("Multiple content holes");o=b}}}return{dom:l,contentDOM:o}}const fW=65535,hW=Math.pow(2,16);function vSe(t,e){return t+e*hW}function AB(t){return t&fW}function bSe(t){return(t-(t&fW))/hW}const pW=1,mW=2,L_=4,gW=8;class Z3{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&gW)>0}get deletedBefore(){return(this.delInfo&(pW|L_))>0}get deletedAfter(){return(this.delInfo&(mW|L_))>0}get deletedAcross(){return(this.delInfo&L_)>0}}class ca{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ca.empty)return ca.empty}recover(e){let n=0,r=AB(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+bSe(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[o+s],u=this.ranges[o+a],h=l+c;if(e<=h){let g=c?e==l?-1:e==h?1:n:n,m=l+i+(g<0?0:u);if(r)return m;let b=e==(n<0?l:h)?null:vSe(o/3,e-l),y=e==l?mW:e==h?pW:L_;return(n<0?e!=l:e!=h)&&(y|=gW),new Z3(m,y,b)}i+=u-c}return r?e+i:new Z3(e+i,0,null)}touches(e,n){let r=0,i=AB(n),s=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[o+s],u=l+c;if(e<=u&&o==i*3)return!0;r+=this.ranges[o+a]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let a=this.ranges[i],o=a-(this.inverted?s:0),l=a+(this.inverted?0:s),c=this.ranges[i+n],u=this.ranges[i+r];e(o,o+c,l,l+u),s+=u-c}}invert(){return new ca(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ca.empty:new ca(e<0?[0,-e,0]:[0,0,e])}}ca.empty=new ca([]);class h0{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 h0(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 h0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let a=this._maps[s],o=a.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new Z3(e,i,null)}}const p2=Object.create(null);let ds=class{getMap(){return ca.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=p2[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 p2)throw new RangeError("Duplicate use of step JSON ID "+e);return p2[e]=n,n.prototype.jsonID=e,n}};class Wr{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Wr(e,null)}static fail(e){return new Wr(null,e)}static fromReplace(e,n,r,i){try{return Wr.ok(e.replace(n,r,i))}catch(s){if(s instanceof g1)return Wr.fail(s.message);throw s}}}function Rk(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Rk(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return pt.fromArray(r)}class Iu extends ds{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Mt(Rk(n.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),n.openStart,n.openEnd);return Wr.fromReplace(e,this.from,this.to,s)}invert(){return new _o(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Iu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Iu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Iu(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Iu(n.from,n.to,e.markFromJSON(n.mark))}}ds.jsonID("addMark",Iu);class _o extends ds{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 Mt(Rk(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Wr.fromReplace(e,this.from,this.to,r)}invert(){return new Iu(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new _o(n.pos,r.pos,this.mark)}merge(e){return e instanceof _o&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _o(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 _o(n.from,n.to,e.markFromJSON(n.mark))}}ds.jsonID("removeMark",_o);class ju extends ds{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Wr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Wr.fromReplace(e,this.pos,this.pos+1,new Mt(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new ju(this.pos,n.marks[i]);return new ju(this.pos,this.mark)}}return new jf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ju(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ju(n.pos,e.markFromJSON(n.mark))}}ds.jsonID("addNodeMark",ju);class jf extends ds{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Wr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Wr.fromReplace(e,this.pos,this.pos+1,new Mt(pt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ju(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new jf(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 jf(n.pos,e.markFromJSON(n.mark))}}ds.jsonID("removeNodeMark",jf);class Ti extends ds{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Q3(e,this.from,this.to)?Wr.fail("Structure replace would overwrite content"):Wr.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ca([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ti(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 Ti(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ti)||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?Mt.empty:new Mt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ti(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?Mt.empty:new Mt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ti(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 Ti(n.from,n.to,Mt.fromJSON(e,n.slice),!!n.structure)}}ds.jsonID("replace",Ti);class Ni extends ds{constructor(e,n,r,i,s,a,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Q3(e,this.from,this.gapFrom)||Q3(e,this.gapTo,this.to)))return Wr.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Wr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Wr.fromReplace(e,this.from,this.to,r):Wr.fail("Content does not fit in gap")}getMap(){return new ca([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 Ni(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new Ni(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ni(n.from,n.to,n.gapFrom,n.gapTo,Mt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ds.jsonID("replaceAround",Ni);function Q3(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let a=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function ySe(t,e,n,r){let i=[],s=[],a,o;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let h=l.marks;if(!r.isInSet(h)&&u.type.allowsMarkType(r.type)){let g=Math.max(c,e),m=Math.min(c+l.nodeSize,n),b=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(b)||(a&&a.to==g&&a.mark.eq(h[y])?a.to=m:i.push(a=new _o(g,m,h[y])));o&&o.to==g?o.to=m:s.push(o=new Iu(g,m,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function _Se(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(a,o)=>{if(!a.isInline)return;s++;let l=null;if(r instanceof vw){let c=a.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(a.marks)&&(l=[r]):l=a.marks;if(l&&l.length){let c=Math.min(o+a.nodeSize,n);for(let u=0;u<l.length;u++){let h=l[u],g;for(let m=0;m<i.length;m++){let b=i[m];b.step==s-1&&h.eq(i[m].style)&&(g=b)}g?(g.to=c,g.step=s):i.push({style:h,from:Math.max(o,e),to:c,step:s})}}}),i.forEach(a=>t.step(new _o(a.from,a.to,a.style)))}function Pk(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),a=[],o=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),u=o+c.nodeSize,h=r.matchType(c.type);if(!h)a.push(new Ti(o,u,Mt.empty));else{r=h;for(let g=0;g<c.marks.length;g++)n.allowsMarkType(c.marks[g].type)||t.step(new _o(o,u,c.marks[g]));if(i&&c.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,b;for(;g=m.exec(c.text);)b||(b=new Mt(pt.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),a.push(new Ti(o+g.index,o+g.index+g[0].length,b))}}o=u}if(!r.validEnd){let l=r.fillBefore(pt.empty,!0);t.replace(o,o,new Mt(l,0,0))}for(let l=a.length-1;l>=0;l--)t.step(a[l])}function SSe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Om(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let a=t.$from.node(r),o=t.$from.index(r)+i,l=t.$to.indexAfter(r)-s;if(r<t.depth&&a.canReplace(o,l,n))return r;if(r==0||a.type.spec.isolating||!SSe(a,o,l))break;o&&(i=1),l<a.childCount&&(s=1)}return null}function wSe(t,e,n){let{$from:r,$to:i,depth:s}=e,a=r.before(s+1),o=i.after(s+1),l=a,c=o,u=pt.empty,h=0;for(let b=s,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,u=pt.from(r.node(b).copy(u)),h++):l--;let g=pt.empty,m=0;for(let b=s,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!0,g=pt.from(i.node(b).copy(g)),m++):c++;t.step(new Ni(l,c,a,o,new Mt(u.append(g),h,m),u.size-h,!0))}function kk(t,e,n=null,r=t){let i=MSe(t,e),s=i&&ESe(r,e);return s?i.map(TB).concat({type:e,attrs:n}).concat(s.map(TB)):null}function TB(t){return{type:t,attrs:null}}function MSe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let a=s.length?s[0]:e;return n.canReplaceWith(r,i,a)?s:null}function ESe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),a=e.contentMatch.findWrapping(s.type);if(!a)return null;let l=(a.length?a[a.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:a}function ASe(t,e,n){let r=pt.empty;for(let a=n.length-1;a>=0;a--){if(r.size){let o=n[a].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=pt.from(n[a].type.create(n[a].attrs,r))}let i=e.start,s=e.end;t.step(new Ni(i,s,i,s,new Mt(r,0,0),n.length,!0))}function TSe(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(a,o)=>{let l=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(r,l)&&CSe(t.doc,t.mapping.slice(s).map(o),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!b?c=!1:!m&&b&&(c=!0)}c===!1&&vW(t,a,o,s),Pk(t,t.mapping.slice(s).map(o,1),r,void 0,c===null);let u=t.mapping.slice(s),h=u.map(o,1),g=u.map(o+a.nodeSize,1);return t.step(new Ni(h,g,h+1,g-1,new Mt(pt.from(r.create(l,null,a.marks)),0,0),1,!0)),c===!0&&xW(t,a,o,s),!1}})}function xW(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let a,o=/\r?\n|\r/g;for(;a=o.exec(i.text);){let l=t.mapping.slice(r).map(n+1+s+a.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function vW(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let a=t.mapping.slice(r).map(n+1+s);t.replaceWith(a,a+1,e.type.schema.text(`
- `))}})}function CSe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function NSe(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let a=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,a);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ni(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Mt(pt.from(a),0,0),1,!0))}function uc(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,a=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>s;c--,u--){let h=i.node(c),g=i.index(c);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(g,h.childCount),b=r&&r[u+1];b&&(m=m.replaceChild(0,b.type.create(b.attrs)));let y=r&&r[u]||h;if(!h.canReplace(g+1,h.childCount)||!y.type.validContent(m))return!1}let o=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(o,o,l?l.type:i.node(s+1).type)}function RSe(t,e,n=1,r){let i=t.doc.resolve(e),s=pt.empty,a=pt.empty;for(let o=i.depth,l=i.depth-n,c=n-1;o>l;o--,c--){s=pt.from(i.node(o).copy(s));let u=r&&r[c];a=pt.from(u?u.type.create(u.attrs,a):i.node(o).copy(a))}t.step(new Ti(e,e,new Mt(s.append(a),n,n),!0))}function cd(t,e){let n=t.resolve(e),r=n.index();return bW(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function PSe(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),a=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(a),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function bW(t,e){return!!(t&&e&&!t.isLeaf&&PSe(t,e))}function bw(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,a,o=r.index(i);if(i==r.depth?(s=r.nodeBefore,a=r.nodeAfter):n>0?(s=r.node(i+1),o++,a=r.node(i).maybeChild(o)):(s=r.node(i).maybeChild(o-1),a=r.node(i+1)),s&&!s.isTextblock&&bW(s,a)&&r.node(i).canReplace(o,o+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function kSe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),a=s.node().type;if(i&&a.inlineContent){let u=a.whitespace=="pre",h=!!a.contentMatch.matchType(i);u&&!h?r=!1:!u&&h&&(r=!0)}let o=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);vW(t,u.node(),u.before(),o)}a.inlineContent&&Pk(t,e+n-1,a,s.node().contentMatchAt(s.index()),r==null);let l=t.mapping.slice(o),c=l.map(e-n);if(t.step(new Ti(c,l.map(e+n,-1),Mt.empty,!0)),r===!0){let u=t.doc.resolve(c);xW(t,u.node(),u.before(),t.steps.length)}return t}function DSe(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function yW(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let a=r.depth;a>=0;a--){let o=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,l=r.index(a)+(o>0?1:0),c=r.node(a),u=!1;if(s==1)u=c.canReplace(l,l,i);else{let h=c.contentMatchAt(l).findWrapping(i.firstChild.type);u=h&&c.canReplaceWith(l,l,h[0])}if(u)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}function yw(t,e,n=e,r=Mt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return _W(i,s,r)?new Ti(e,n,r):new OSe(i,s,r).fit()}function _W(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class OSe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=pt.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=pt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,a=r.depth,o=i.depth;for(;a&&o&&s.childCount==1;)s=s.firstChild.content,a--,o--;let l=new Mt(s,a,o);return e>-1?new Ni(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Ti(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=m2(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let a=i.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:c}=this.frontier[o],u,h=null;if(n==1&&(a?c.matchType(a.type)||(h=c.fillBefore(pt.from(a),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:o,parent:s,inject:h};if(n==2&&a&&(u=c.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:o,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=m2(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Mt(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=m2(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Mt(gx(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Mt(gx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let a=this.unplaced,o=r?r.content:a.content,l=a.openStart-e,c=0,u=[],{match:h,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)u.push(i.child(y));h=h.matchFragment(i)}let m=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let y=o.child(c),v=h.matchType(y.type);if(!v)break;c++,(c>1||l==0||y.content.size)&&(h=v,u.push(SW(y.mark(g.allowedMarks(y.marks)),c==1?l:0,c==o.childCount?m:-1)))}let b=c==o.childCount;b||(m=-1),this.placed=xx(this.placed,n,pt.from(u)),this.frontier[n].match=h,b&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,v=o;y<m;y++){let x=v.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),v=x.content}this.unplaced=b?e==0?Mt.empty:new Mt(gx(a.content,e-1,1),e-1,m<0?a.openEnd:e-1):new Mt(gx(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!g2(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),a=g2(e,n,i,r,s);if(a){for(let o=n-1;o>=0;o--){let{match:l,type:c}=this.frontier[o],u=g2(e,o,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:a,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=xx(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=xx(this.placed,this.depth,pt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(pt.empty,!0);n.childCount&&(this.placed=xx(this.placed,this.frontier.length,n))}}function gx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(gx(t.firstChild.content,e-1,n)))}function xx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(xx(t.lastChild.content,e-1,n)))}function m2(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function SW(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,SW(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(pt.empty,!0)))),t.copy(r)}function g2(t,e,n,r,i){let s=t.node(e),a=i?t.indexAfter(e):t.index(e);if(a==s.childCount&&!n.compatibleContent(s.type))return null;let o=r.fillBefore(s.content,!0,a);return o&&!LSe(n,s.content,a)?o:null}function LSe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function ISe(t){return t.spec.defining||t.spec.definingForContent}function jSe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(_W(i,s,r))return t.step(new Ti(e,n,r));let a=MW(i,s);a[a.length-1]==0&&a.pop();let o=-(i.depth+1);a.unshift(o);for(let g=i.depth,m=i.pos-1;g>0;g--,m--){let b=i.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;a.indexOf(g)>-1?o=g:i.before(g)==m&&a.splice(1,0,-g)}let l=a.indexOf(o),c=[],u=r.openStart;for(let g=r.content,m=0;;m++){let b=g.firstChild;if(c.push(b),m==r.openStart)break;g=b.content}for(let g=u-1;g>=0;g--){let m=c[g],b=ISe(m.type);if(b&&!m.sameMarkup(i.node(Math.abs(o)-1)))u=g;else if(b||!m.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let m=(g+u+1)%(r.openStart+1),b=c[m];if(b)for(let y=0;y<a.length;y++){let v=a[(y+l)%a.length],x=!0;v<0&&(x=!1,v=-v);let M=i.node(v-1),w=i.index(v-1);if(M.canReplaceWith(w,w,b.type,b.marks))return t.replace(i.before(v),x?s.after(v):n,new Mt(wW(r.content,0,r.openStart,m),m,r.openEnd))}}let h=t.steps.length;for(let g=a.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>h));g--){let m=a[g];m<0||(e=i.before(m),n=s.after(m))}}function wW(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(wW(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),a=s.fillBefore(t).append(t);t=a.append(s.matchFragment(a).fillBefore(pt.empty,!0))}return t}function USe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=DSe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Mt(pt.from(r),0,0))}function FSe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=MW(r,i);for(let a=0;a<s.length;a++){let o=s[a],l=a==s.length-1;if(l&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(l||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(e-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return t.delete(r.before(a),n);t.delete(e,n)}function MW(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class zp extends ds{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 Wr.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Wr.fromReplace(e,this.pos,this.pos+1,new Mt(pt.from(i),0,n.isLeaf?0:1))}getMap(){return ca.empty}invert(e){return new zp(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 zp(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 zp(n.pos,n.attr,n.value)}}ds.jsonID("attr",zp);class p0 extends ds{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 Wr.ok(r)}getMap(){return ca.empty}invert(e){return new p0(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 p0(n.attr,n.value)}}ds.jsonID("docAttr",p0);let om=class extends Error{};om=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};om.prototype=Object.create(Error.prototype);om.prototype.constructor=om;om.prototype.name="TransformError";class EW{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new h0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new om(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=Mt.empty){let i=yw(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Mt(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,Mt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return jSe(this,e,n,r),this}replaceRangeWith(e,n,r){return USe(this,e,n,r),this}deleteRange(e,n){return FSe(this,e,n),this}lift(e,n){return wSe(this,e,n),this}join(e,n=1){return kSe(this,e,n),this}wrap(e,n){return ASe(this,e,n),this}setBlockType(e,n=e,r,i=null){return TSe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return NSe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new zp(e,n,r)),this}setDocAttribute(e,n){return this.step(new p0(e,n)),this}addNodeMark(e,n){return this.step(new ju(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Kn)n.isInSet(r.marks)&&this.step(new jf(e,n));else{let i=r.marks,s,a=[];for(;s=n.isInSet(i);)a.push(new jf(e,s)),i=s.removeFromSet(i);for(let o=a.length-1;o>=0;o--)this.step(a[o])}return this}split(e,n=1,r){return RSe(this,e,n,r),this}addMark(e,n,r){return ySe(this,e,n,r),this}removeMark(e,n,r){return _Se(this,e,n,r),this}clearIncompatible(e,n,r){return Pk(this,e,n,r),this}}const x2=Object.create(null);class ln{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new zSe(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=Mt.empty){let r=n.content.lastChild,i=null;for(let o=0;o<n.openEnd;o++)i=r,r=r.lastChild;let s=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:l,$to:c}=a[o],u=e.mapping.slice(s);e.replaceRange(u.map(l.pos),u.map(c.pos),o?Mt.empty:n),o==0&&RB(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:o}=i[s],l=e.mapping.slice(r),c=l.map(a.pos),u=l.map(o.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),RB(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Wt(e):_p(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let a=n<0?_p(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):_p(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(a)return a}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new pa(e.node(0))}static atStart(e){return _p(e,e,0,0,1)||new pa(e)}static atEnd(e){return _p(e,e,e.content.size,e.childCount,-1)||new pa(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=x2[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 x2)throw new RangeError("Duplicate use of selection JSON ID "+e);return x2[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Wt.between(this.$anchor,this.$head).getBookmark()}}ln.prototype.visible=!0;class zSe{constructor(e,n){this.$from=e,this.$to=n}}let CB=!1;function NB(t){!CB&&!t.parent.inlineContent&&(CB=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Wt extends ln{constructor(e,n=e){NB(e),NB(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ln.near(r);let i=e.resolve(n.map(this.anchor));return new Wt(i.parent.inlineContent?i:r,r)}replace(e,n=Mt.empty){if(super.replace(e,n),n==Mt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Wt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new _w(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Wt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=ln.findFrom(n,r,!0)||ln.findFrom(n,-r,!0);if(s)n=s.$head;else return ln.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ln.findFrom(e,-r,!0)||ln.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Wt(e,n)}}ln.jsonID("text",Wt);class _w{constructor(e,n){this.anchor=e,this.head=n}map(e){return new _w(e.map(this.anchor),e.map(this.head))}resolve(e){return Wt.between(e.resolve(this.anchor),e.resolve(this.head))}}class zt extends ln{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?ln.near(s):new zt(s)}content(){return new Mt(pt.from(this.node),0,0)}eq(e){return e instanceof zt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Dk(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new zt(e.resolve(n.anchor))}static create(e,n){return new zt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}zt.prototype.visible=!1;ln.jsonID("node",zt);class Dk{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new _w(r,r):new Dk(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&zt.isSelectable(r)?new zt(n):ln.near(n)}}class pa extends ln{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Mt.empty){if(n==Mt.empty){e.delete(0,e.doc.content.size);let r=ln.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new pa(e)}map(e){return new pa(e)}eq(e){return e instanceof pa}getBookmark(){return BSe}}ln.jsonID("all",pa);const BSe={map(){return this},resolve(t){return new pa(t)}};function _p(t,e,n,r,i,s=!1){if(e.inlineContent)return Wt.create(t,n);for(let a=r-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let o=e.child(a);if(o.isAtom){if(!s&&zt.isSelectable(o))return zt.create(t,n-(i<0?o.nodeSize:0))}else{let l=_p(t,o,n+i,i<0?o.childCount:0,i,s);if(l)return l}n+=o.nodeSize*i}return null}function RB(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Ti||i instanceof Ni))return;let s=t.mapping.maps[r],a;s.forEach((o,l,c,u)=>{a==null&&(a=u)}),t.setSelection(ln.near(t.doc.resolve(a),n))}const PB=1,Vy=2,kB=4;class HSe extends EW{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|PB)&~Vy,this.storedMarks=null,this}get selectionSet(){return(this.updated&PB)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Vy,this}ensureMarks(e){return Kn.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Vy)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Vy,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Kn.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let a=this.doc.resolve(n);s=r==n?a.marks():a.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ln.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=kB,this}get scrolledIntoView(){return(this.updated&kB)>0}}function DB(t,e){return!e||!t?t:t.bind(e)}class vx{constructor(e,n,r){this.name=e,this.init=DB(n.init,r),this.apply=DB(n.apply,r)}}const $Se=[new vx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new vx("selection",{init(t,e){return t.selection||ln.atStart(e.doc)},apply(t){return t.selection}}),new vx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new vx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class v2{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=$Se.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 vx(r.key,r.spec.state,r))})}}class Cp{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let l=i?i[a].n:0,c=i?i[a].state:this,u=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,a)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<a?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),s=!0}i&&(i[a]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Cp(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new HSe(this)}static create(e){let n=new v2(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Cp(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 v2(this.schema,e.plugins),r=n.fields,i=new Cp(n);for(let s=0;s<r.length;s++){let a=r[s].name;i[a]=this.hasOwnProperty(a)?this[a]:r[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new v2(e.schema,e.plugins),s=new Cp(i);return i.fields.forEach(a=>{if(a.name=="doc")s.doc=Vu.fromJSON(e.schema,n.doc);else if(a.name=="selection")s.selection=ln.fromJSON(s.doc,n.selection);else if(a.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let o in r){let l=r[o],c=l.spec.state;if(l.key==a.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){s[a.name]=c.fromJSON.call(l,e,n[o],s);return}}s[a.name]=a.init(e,s)}}),s}}function AW(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=AW(i,e,{})),n[r]=i}return n}class vr{constructor(e){this.spec=e,this.props={},e.props&&AW(e.props,this,this.props),this.key=e.key?e.key.key:TW("plugin")}getState(e){return e[this.key]}}const b2=Object.create(null);function TW(t){return t in b2?t+"$"+ ++b2[t]:(b2[t]=0,t+"$")}class di{constructor(e="key"){this.key=TW(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ok=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function CW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const NW=(t,e,n)=>{let r=CW(t,n);if(!r)return!1;let i=Lk(r);if(!i){let a=r.blockRange(),o=a&&Om(a);return o==null?!1:(e&&e(t.tr.lift(a,o).scrollIntoView()),!0)}let s=i.nodeBefore;if(UW(t,i,e,-1))return!0;if(r.parent.content.size==0&&(lm(s,"end")||zt.isSelectable(s)))for(let a=r.depth;;a--){let o=yw(t.doc,r.before(a),r.after(a),Mt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(lm(s,"end")?ln.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):zt.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(a==1||r.node(a-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},VSe=(t,e,n)=>{let r=CW(t,n);if(!r)return!1;let i=Lk(r);return i?RW(t,i,e):!1},GSe=(t,e,n)=>{let r=kW(t,n);if(!r)return!1;let i=Ik(r);return i?RW(t,i,e):!1};function RW(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let a=e.nodeAfter,o=a,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let u=o.firstChild;if(!u)return!1;o=u}let c=yw(t.doc,s,l,Mt.empty);if(!c||c.from!=s||c instanceof Ti&&c.slice.size>=l-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(Wt.create(u.doc,s)),n(u.scrollIntoView())}return!0}function lm(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 PW=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Lk(r)}let a=s&&s.nodeBefore;return!a||!zt.isSelectable(a)?!1:(e&&e(t.tr.setSelection(zt.create(t.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function Lk(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 kW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const DW=(t,e,n)=>{let r=kW(t,n);if(!r)return!1;let i=Ik(r);if(!i)return!1;let s=i.nodeAfter;if(UW(t,i,e,1))return!0;if(r.parent.content.size==0&&(lm(s,"start")||zt.isSelectable(s))){let a=yw(t.doc,r.before(),r.after(),Mt.empty);if(a&&a.slice.size<a.to-a.from){if(e){let o=t.tr.step(a);o.setSelection(lm(s,"start")?ln.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):zt.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},OW=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Ik(r)}let a=s&&s.nodeAfter;return!a||!zt.isSelectable(a)?!1:(e&&e(t.tr.setSelection(zt.create(t.doc,s.pos)).scrollIntoView()),!0)};function Ik(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 WSe=(t,e)=>{let n=t.selection,r=n instanceof zt,i;if(r){if(n.node.isTextblock||!cd(t.doc,n.from))return!1;i=n.from}else if(i=bw(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(zt.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},qSe=(t,e)=>{let n=t.selection,r;if(n instanceof zt){if(n.node.isTextblock||!cd(t.doc,n.to))return!1;r=n.to}else if(r=bw(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},XSe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Om(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},LW=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function jk(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 KSe=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),a=jk(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,a.createAndFill());l.setSelection(ln.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},IW=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof pa||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=jk(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let a=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=t.tr.insert(a,s.createAndFill());o.setSelection(Wt.create(o.doc,a+1)),e(o.scrollIntoView())}return!0},jW=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(uc(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Om(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function YSe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof zt&&e.selection.node.isBlock)return!r.parentOffset||!uc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],a,o,l=!1,c=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){l=r.end(m)==r.pos+(r.depth-m),c=r.start(m)==r.pos-(r.depth-m),o=jk(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(l&&o?{type:o}:null),a=m;break}else{if(m==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof Wt||e.selection instanceof pa)&&u.deleteSelection();let h=u.mapping.map(r.pos),g=uc(u.doc,h,s.length,s);if(g||(s[0]=o?{type:o}:null,g=uc(u.doc,h,s.length,s)),!g)return!1;if(u.split(h,s.length,s),!l&&c&&r.node(a).type!=o){let m=u.mapping.map(r.before(a)),b=u.doc.resolve(m);o&&r.node(a-1).canReplaceWith(b.index(),b.index()+1,o)&&u.setNodeMarkup(u.mapping.map(r.before(a)),o)}return n&&n(u.scrollIntoView()),!0}}const ZSe=YSe(),QSe=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(zt.create(t.doc,i))),!0)};function JSe(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||cd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function UW(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,a,o,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&JSe(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(a=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(a[0]||s.type).validEnd){if(n){let m=e.pos+s.nodeSize,b=pt.empty;for(let x=a.length-1;x>=0;x--)b=pt.from(a[x].create(null,b));b=pt.from(i.copy(b));let y=t.tr.step(new Ni(e.pos-1,m,e.pos,m,new Mt(b,1,0),a.length,!0)),v=y.doc.resolve(m+2*a.length);v.nodeAfter&&v.nodeAfter.type==i.type&&cd(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&l?null:ln.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),g=h&&Om(h);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(h,g).scrollIntoView()),!0;if(c&&lm(s,"start",!0)&&lm(i,"end")){let m=i,b=[];for(;b.push(m),!m.isTextblock;)m=m.lastChild;let y=s,v=1;for(;!y.isTextblock;y=y.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let x=pt.empty;for(let w=b.length-1;w>=0;w--)x=pt.from(b[w].copy(x));let M=t.tr.step(new Ni(e.pos-b.length,e.pos+s.nodeSize,e.pos+v,e.pos+s.nodeSize-v,new Mt(x,b.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function FW(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(Wt.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const ewe=FW(-1),twe=FW(1);function nwe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s),o=a&&kk(a,t,e);return o?(r&&r(n.tr.wrap(a,o).scrollIntoView()),!0):!1}}function OB(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[s];n.doc.nodesBetween(a,o,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let u=n.doc.resolve(c),h=u.index();i=u.parent.canReplaceWith(h,h+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let a=0;a<n.selection.ranges.length;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];s.setBlockType(o,l,t,e)}r(s.scrollIntoView())}return!0}}function Uk(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Uk(Ok,NW,PW);Uk(Ok,DW,OW);Uk(LW,IW,jW,ZSe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function rwe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s);if(!a)return!1;let o=r?n.tr:null;return iwe(o,a,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function iwe(t,e,n,r=null){let i=!1,s=e,a=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=a.resolve(e.start-2);s=new v1(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new v1(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=kk(s,n,r,e);return o?(t&&swe(t,e,o,i,n),!0):!1}function swe(t,e,n,r,i){let s=pt.empty;for(let u=n.length-1;u>=0;u--)s=pt.from(n[u].type.create(n[u].attrs,s));t.step(new Ni(e.start-(r?2:0),e.end,e.start,e.end,new Mt(s,0,0),n.length,!0));let a=0;for(let u=0;u<n.length;u++)n[u].type==i&&(a=u+1);let o=n.length-a,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,h=e.endIndex,g=!0;u<h;u++,g=!1)!g&&uc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=c.child(u).nodeSize;return t}function awe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,a=>a.childCount>0&&a.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?owe(e,n,t,s):lwe(e,n,s):!0:!1}}function owe(t,e,n,r){let i=t.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new Ni(s-1,a,s,a,new Mt(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new v1(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));const o=Om(r);if(o==null)return!1;i.lift(r,o);let l=i.doc.resolve(i.mapping.map(s,-1)-1);return cd(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function lwe(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,b=n.endIndex-1,y=n.startIndex;b>y;b--)m-=i.child(b).nodeSize,r.delete(m-1,m+1);let s=r.doc.resolve(n.start),a=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,l=n.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(o?0:1),u+1,a.content.append(l?pt.empty:pt.from(i))))return!1;let h=s.pos,g=h+a.nodeSize;return r.step(new Ni(h-(o?1:0),g+(l?1:0),h+1,g-1,new Mt((o?pt.empty:pt.from(i.copy(pt.empty))).append(l?pt.empty:pt.from(i.copy(pt.empty))),o?0:1,l?0:1),o?0:1)),e(r.scrollIntoView()),!0}function cwe(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let a=s.startIndex;if(a==0)return!1;let o=s.parent,l=o.child(a-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==o.type,u=pt.from(c?t.create():null),h=new Mt(pt.from(t.create(null,pt.from(o.type.create(null,u)))),c?3:1,0),g=s.start,m=s.end;n(e.tr.step(new Ni(g-(c?3:1),m,g,m,h,1,!0)).scrollIntoView())}return!0}}const qi=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},cm=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let J3=null;const Xl=function(t,e,n){let r=J3||(J3=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},uwe=function(){J3=null},Uf=function(t,e,n,r){return n&&(LB(t,e,n,r,-1)||LB(t,e,n,r,1))},dwe=/^(img|br|input|textarea|hr)$/i;function LB(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ha(t))){let a=t.parentNode;if(!a||a.nodeType!=1||Y0(t)||dwe.test(t.nodeName)||t.contentEditable=="false")return!1;e=qi(t)+(i<0?0:1),t=a}else if(t.nodeType==1){let a=t.childNodes[e+(i<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((s=a.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=a,e=i<0?Ha(t):0}else return!1}}function Ha(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function fwe(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=Ha(t)}else if(t.parentNode&&!Y0(t))e=qi(t),t=t.parentNode;else return null}}function hwe(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&&!Y0(t))e=qi(t)+1,t=t.parentNode;else return null}}function pwe(t,e,n){for(let r=e==0,i=e==Ha(t);r||i;){if(t==n)return!0;let s=qi(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Ha(t)}}function Y0(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 Sw=function(t){return t.focusNode&&Uf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Jd(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function mwe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function gwe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ha(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ha(r.startContainer),r.startOffset)}}}const sl=typeof navigator<"u"?navigator:null,IB=typeof document<"u"?document:null,ud=sl&&sl.userAgent||"",eR=/Edge\/(\d+)/.exec(ud),zW=/MSIE \d/.exec(ud),tR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ud),Vs=!!(zW||tR||eR),Gu=zW?document.documentMode:tR?+tR[1]:eR?+eR[1]:0,qa=!Vs&&/gecko\/(\d+)/i.test(ud);qa&&+(/Firefox\/(\d+)/.exec(ud)||[0,0])[1];const nR=!Vs&&/Chrome\/(\d+)/.exec(ud),ls=!!nR,BW=nR?+nR[1]:0,Ss=!Vs&&!!sl&&/Apple Computer/.test(sl.vendor),um=Ss&&(/Mobile\/\w+/.test(ud)||!!sl&&sl.maxTouchPoints>2),Ia=um||(sl?/Mac/.test(sl.platform):!1),xwe=sl?/Win/.test(sl.platform):!1,rc=/Android \d/.test(ud),Z0=!!IB&&"webkitFontSmoothing"in IB.documentElement.style,vwe=Z0?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bwe(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 Hl(t,e){return typeof t=="number"?t:t[e]}function ywe(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 jB(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let a=n||t.dom;a;){if(a.nodeType!=1){a=cm(a);continue}let o=a,l=o==s.body,c=l?bwe(s):ywe(o),u=0,h=0;if(e.top<c.top+Hl(r,"top")?h=-(c.top-e.top+Hl(i,"top")):e.bottom>c.bottom-Hl(r,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+Hl(i,"top")-c.top:e.bottom-c.bottom+Hl(i,"bottom")),e.left<c.left+Hl(r,"left")?u=-(c.left-e.left+Hl(i,"left")):e.right>c.right-Hl(r,"right")&&(u=e.right-c.right+Hl(i,"right")),u||h)if(l)s.defaultView.scrollBy(u,h);else{let m=o.scrollLeft,b=o.scrollTop;h&&(o.scrollTop+=h),u&&(o.scrollLeft+=u);let y=o.scrollLeft-m,v=o.scrollTop-b;e={left:e.left-y,top:e.top-v,right:e.right-y,bottom:e.bottom-v}}let g=l?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(g))break;a=g=="absolute"?a.offsetParent:cm(a)}}function _we(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,a=n+1;a<Math.min(innerHeight,e.bottom);a+=5){let o=t.root.elementFromPoint(s,a);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){r=o,i=l.top;break}}return{refDOM:r,refTop:i,stack:HW(t.dom)}}function HW(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=cm(r));return e}function Swe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;$W(n,r==0?0:r-e)}function $W(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let hp=null;function wwe(t){if(t.setActive)return t.setActive();if(hp)return t.focus(hp);let e=HW(t);t.focus(hp==null?{get preventScroll(){return hp={preventScroll:!0},!0}}:void 0),hp||(hp=!1,$W(e,0))}function VW(t,e){let n,r=2e8,i,s=0,a=e.top,o=e.top,l,c;for(let u=t.firstChild,h=0;u;u=u.nextSibling,h++){let g;if(u.nodeType==1)g=u.getClientRects();else if(u.nodeType==3)g=Xl(u).getClientRects();else continue;for(let m=0;m<g.length;m++){let b=g[m];if(b.top<=a&&b.bottom>=o){a=Math.max(b.bottom,a),o=Math.min(b.top,o);let y=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(y<r){n=u,r=y,i=y&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,u.nodeType==1&&y&&(s=h+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!l&&b.left<=e.left&&b.right>=e.left&&(l=u,c={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(s=h+1)}}return!n&&l&&(n=l,i=c,r=0),n&&n.nodeType==3?Mwe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:VW(n,i)}function Mwe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=vu(r,1);if(s.top!=s.bottom&&Fk(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function Fk(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ewe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Awe(t,e,n){let{node:r,offset:i}=VW(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let a=r.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function Twe(t,e,n,r){let i=-1;for(let s=e,a=!1;s!=t.dom;){let o=t.docView.nearestDesc(s,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!a&&l.left>r.left||l.top>r.top?i=o.posBefore:(!a&&l.right<r.left||l.bottom<r.top)&&(i=o.posAfter),a=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;s=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function GW(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let a=t.childNodes[s];if(a.nodeType==1){let o=a.getClientRects();for(let l=0;l<o.length;l++){let c=o[l];if(Fk(e,c))return GW(a,e,c)}}if((s=(s+1)%r)==i)break}return t}function Cwe(t,e){let n=t.dom.ownerDocument,r,i=0,s=gwe(n,e.left,e.top);s&&({node:r,offset:i}=s);let a=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!a||!t.dom.contains(a.nodeType!=1?a.parentNode:a)){let c=t.dom.getBoundingClientRect();if(!Fk(e,c)||(a=GW(t.dom,e,c),!a))return null}if(Ss)for(let c=a;r&&c;c=cm(c))c.draggable&&(r=void 0);if(a=Ewe(a,e),r){if(qa&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let c;Z0&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(o=Twe(t,r,i,e))}o==null&&(o=Awe(t,a,e));let l=t.docView.nearestDesc(a,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function UB(t){return t.top<t.bottom||t.left<t.right}function vu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(UB(r))return r}return Array.prototype.find.call(n,UB)||t.getBoundingClientRect()}const Nwe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function WW(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),a=Z0||qa;if(r.nodeType==3)if(a&&(Nwe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=vu(Xl(r,i,i),n);if(qa&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=vu(Xl(r,i-1,i-1),-1);if(c.top==l.top){let u=vu(Xl(r,i,i+1),-1);if(u.top!=l.top)return tx(u,u.left<c.left)}}return l}else{let l=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(l--,u=1):n<0?l--:c++,tx(vu(Xl(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Ha(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return y2(l.getBoundingClientRect(),!1)}if(s==null&&i<Ha(r)){let l=r.childNodes[i];if(l.nodeType==1)return y2(l.getBoundingClientRect(),!0)}return y2(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Ha(r))){let l=r.childNodes[i-1],c=l.nodeType==3?Xl(l,Ha(l)-(a?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return tx(vu(c,1),!1)}if(s==null&&i<Ha(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Xl(l,0,a?0:1):l.nodeType==1?l:null:null;if(c)return tx(vu(c,-1),!0)}return tx(vu(r.nodeType==3?Xl(r):r,-n),n>=0)}function tx(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 y2(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qW(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function Rwe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return qW(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(s,!0);if(!o)break;if(o.node.isBlock){s=o.contentDOM||o.dom;break}s=o.dom.parentNode}let a=WW(t,i.pos,1);for(let o=s.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=Xl(o,0,o.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?a.top-u.top>(u.bottom-a.top)*2:u.bottom-a.bottom>(a.bottom-u.top)*2))return!1}}return!0})}const Pwe=/[\u0590-\u08ac]/;function kwe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,a=i==r.parent.content.size,o=t.domSelection();return o?!Pwe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?s:a:qW(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:h}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:y}=t.domSelectionRange(),v=b&&!m.contains(b.nodeType==1?b:b.parentNode)||l==b&&c==y;try{o.collapse(u,h),l&&(l!=u||c!=h)&&o.extend&&o.extend(l,c)}catch{}return g!=null&&(o.caretBidiLevel=g),v}):r.pos==r.start()||r.pos==r.end()}let FB=null,zB=null,BB=!1;function Dwe(t,e,n){return FB==e&&zB==n?BB:(FB=e,zB=n,BB=n=="up"||n=="down"?Rwe(t,e,n):kwe(t,e,n))}const Xa=0,HB=1,nf=2,al=3;class Q0{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Xa,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,a;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(a)+a.size:this.posAtStart}else{let s,a;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(a):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>qi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),a;if(s&&(!n||s.node))if(r&&(a=s.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let a=0;a<i.children.length;a++){let o=i.children[a];if(o.size){i=o;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let a=this.children[r],o=s+a.size;if(o>e||a instanceof KW){i=e-s;break}s=o}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof XW&&s.side>=0;r--);if(n<=0){let s,a=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,a=!1);return s&&n&&a&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?qi(s.dom)+1:0}}else{let s,a=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,a=!1);return s&&a&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?qi(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let a=r,o=0;;o++){let l=this.children[o],c=a+l.size;if(i==-1&&e<=c){let u=a+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=a;for(let h=o;h>0;h--){let g=this.children[h-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=qi(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(c>n||o==this.children.length-1)){n=c;for(let u=o+1;u<this.children.length;u++){let h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=qi(h.dom);break}n+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}a=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let s=Math.min(e,n),a=Math.max(e,n);for(let m=0,b=0;m<this.children.length;m++){let y=this.children[m],v=b+y.size;if(s>b&&a<v)return y.setSelection(e-b-y.border,n-b-y.border,r,i);b=v}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),h=!1;if((qa||Ss)&&e==n){let{node:m,offset:b}=o;if(m.nodeType==3){if(h=!!(b&&m.nodeValue[b-1]==`
- `),h&&b==m.nodeValue.length)for(let y=m,v;y;y=y.parentNode){if(v=y.nextSibling){v.nodeName=="BR"&&(o=l={node:v.parentNode,offset:qi(v)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=m.childNodes[b-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(qa&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let m=u.focusNode.childNodes[u.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||h&&Ss)&&Uf(o.node,o.offset,u.anchorNode,u.anchorOffset)&&Uf(l.node,l.offset,u.focusNode,u.focusOffset))return;let g=!1;if((c.extend||e==n)&&!(h&&qa)){c.collapse(o.node,o.offset);try{e!=n&&c.extend(l.node,l.offset),g=!0}catch{}}if(!g){if(e>n){let b=o;o=l,l=b}let m=document.createRange();m.setEnd(l.node,l.offset),m.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],a=r+s.size;if(r==a?e<=a&&n>=r:e<a&&n>r){let o=r+s.border,l=a-s.border;if(e>=o&&n<=l){this.dirty=e==r||n==a?nf:HB,e==o&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=al:s.markDirty(e-o,n-o);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?nf:al}r=a}this.dirty=nf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?nf:HB;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class XW extends Q0{constructor(e,n,r,i){let s,a=n.type.toDOM;if(typeof a=="function"&&(a=a(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(a.nodeType!=1){let o=document.createElement("span");o.appendChild(a),a=o}a.contentEditable="false",a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Xa&&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 Owe extends Q0{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 Ff extends Q0{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],a=s&&s(n,i,r);return(!a||!a.dom)&&(a=Zf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Ff(e,n,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&al||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=al&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Xa){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xa}}slice(e,n,r){let i=Ff.create(this.parent,this.mark,!0,r),s=this.children,a=this.size;n<a&&(s=iR(s,n,a,r)),e>0&&(s=iR(s,0,e,r));for(let o=0;o<s.length;o++)s[o].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Wu extends Q0{constructor(e,n,r,i,s,a,o,l,c){super(e,[],s,a),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=o}static create(e,n,r,i,s,a){let o=s.nodeViews[n.type.name],l,c=o&&o(n,s,()=>{if(!l)return a;if(l.parent)return l.parent.posBeforeChild(l)},r,i),u=c&&c.dom,h=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=Zf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let g=u;return u=QW(u,r,n),c?l=new Lwe(e,n,r,i,u,h||null,g,c,s,a+1):n.isText?new ww(e,n,r,i,u,g,s):new Wu(e,n,r,i,u,h||null,g,s,a+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>pt.empty)}return e}matchesNode(e,n,r){return this.dirty==Xa&&e.eq(this.node)&&y1(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,a=s&&s.pos>-1?s:null,o=s&&s.pos<0,l=new jwe(this,a&&a.node,e);zwe(this.node,this.innerDeco,(c,u,h)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!h&&l.syncToMarks(u==this.node.childCount?Kn.none:this.node.child(u).marks,r,e),l.placeWidget(c,e,i)},(c,u,h,g)=>{l.syncToMarks(c.marks,r,e);let m;l.findNodeMatch(c,u,h,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(m=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,u,h,m,e)||l.updateNextNode(c,u,h,e,g,i)||l.addNode(c,u,h,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==nf)&&(a&&this.protectLocalComposition(e,a),YW(this.contentDOM,this.children,e),um&&Bwe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Wt)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,o=Hwe(this.node.content,a,r-n,i-n);return o<0?null:{node:s,pos:o,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let a=new Owe(this,s,n,i);e.input.compositionNodes.push(a),this.children=iR(this.children,r,r+i.length,e,a)}update(e,n,r,i){return this.dirty==al||!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=Xa}updateOuterDeco(e){if(y1(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ZW(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 $B(t,e,n,r,i){QW(r,e,t);let s=new Wu(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class ww extends Wu{constructor(e,n,r,i,s,a,o){super(e,n,r,i,s,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==al||this.dirty!=Xa&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Xa||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=Xa,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new ww(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=al)}get domAtom(){return!1}isText(e){return this.node.text==e}}class KW extends Q0{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xa&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Lwe extends Wu{constructor(e,n,r,i,s,a,o,l,c,u){super(e,n,r,i,s,a,o,c,u),this.spec=l}update(e,n,r,i){if(this.dirty==al)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function YW(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let a=e[s],o=a.dom;if(o.parentNode==t){for(;o!=r;)r=VB(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(a instanceof Ff){let l=r?r.previousSibling:t.lastChild;YW(a.contentDOM,a.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=VB(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Ox=function(t){t&&(this.nodeName=t)};Ox.prototype=Object.create(null);const rf=[new Ox];function rR(t,e,n){if(t.length==0)return rf;let r=n?rf[0]:new Ox,i=[r];for(let s=0;s<t.length;s++){let a=t[s].type.attrs;if(a){a.nodeName&&i.push(r=new Ox(a.nodeName));for(let o in a){let l=a[o];l!=null&&(n&&i.length==1&&i.push(r=new Ox(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+l:o=="style"?r.style=(r.style?r.style+";":"")+l:o!="nodeName"&&(r[o]=l))}}}return i}function ZW(t,e,n,r){if(n==rf&&r==rf)return e;let i=e;for(let s=0;s<r.length;s++){let a=r[s],o=n[s];if(s){let l;o&&o.nodeName==a.nodeName&&i!=t&&(l=i.parentNode)&&l.nodeName.toLowerCase()==a.nodeName||(l=document.createElement(a.nodeName),l.pmIsDeco=!0,l.appendChild(i),o=rf[0]),i=l}Iwe(i,o||rf[0],a)}return i}function Iwe(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function QW(t,e,n){return ZW(t,t,rf,rR(e,n,t.nodeType!=1))}function y1(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 VB(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class jwe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Uwe(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;i<a&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Xa,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){o=l;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let l=Ff.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(e,n,r))s=this.top.children.indexOf(a,this.index);else for(let o=this.index,l=Math.min(this.top.children.length,o+5);o<l;o++){let c=this.top.children[o];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){s=o;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let a=this.top.children[i];return a.dirty==al&&a.dom==a.contentDOM&&(a.dirty=nf),a.update(e,n,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,a){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Wu){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let u=l.dom,h,g=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=al&&y1(n,l.outerDeco));if(!g&&l.update(e,n,r,i))return this.destroyBetween(this.index,o),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!g&&(h=this.recreateWrapper(l,e,n,r,i,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=nf,h.updateChildren(i,a+1),h.dirty=Xa),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,a){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!y1(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=Wu.create(this.top,n,r,i,s,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let l of o.children)l.parent=o}return e.destroy(),o}addNode(e,n,r,i,s){let a=Wu.create(this.top,e,n,r,i,s);a.contentDOM&&a.updateChildren(i,s+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new XW(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Ff;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ww)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ss||ls)&&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 KW(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 Uwe(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,a=[];e:for(;i>0;){let o;for(;;)if(r){let c=n.children[r-1];if(c instanceof Ff)n=c,r=c.children.length;else{o=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=o.node;if(l){if(l!=t.child(i-1))break;--i,s.set(o,i),a.push(o)}}return{index:i,matched:s,matches:a.reverse()}}function Fwe(t,e){return t.type.side-e.type.side}function zwe(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let a=0,o=[],l=null;for(let c=0;;){let u,h;for(;a<i.length&&i[a].to==s;){let v=i[a++];v.widget&&(u?(h||(h=[u])).push(v):u=v)}if(u)if(h){h.sort(Fwe);for(let v=0;v<h.length;v++)n(h[v],c,!!l)}else n(u,c,!!l);let g,m;if(l)m=-1,g=l,l=null;else if(c<t.childCount)m=c,g=t.child(c++);else break;for(let v=0;v<o.length;v++)o[v].to<=s&&o.splice(v--,1);for(;a<i.length&&i[a].from<=s&&i[a].to>s;)o.push(i[a++]);let b=s+g.nodeSize;if(g.isText){let v=b;a<i.length&&i[a].from<v&&(v=i[a].from);for(let x=0;x<o.length;x++)o[x].to<v&&(v=o[x].to);v<b&&(l=g.cut(v-s),g=g.cut(0,v-s),b=v,m=-1)}else for(;a<i.length&&i[a].to<b;)a++;let y=g.isInline&&!g.isLeaf?o.filter(v=>!v.inline):o.slice();r(g,y,e.forChild(s,g),m),s=b}}function Bwe(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 Hwe(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let a=t.child(i++),o=s;if(s+=a.nodeSize,!a.isText)continue;let l=a.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=n){if(s>=r&&l.slice(r-e.length-o,r-o)==e)return r-e.length;let c=o<r?l.lastIndexOf(e,r-o-1):-1;if(c>=0&&c+e.length+o>=n)return o+c;if(n==r&&l.length>=r+e.length-o&&l.slice(r-o,r-o+e.length)==e)return r}}return-1}function iR(t,e,n,r,i){let s=[];for(let a=0,o=0;a<t.length;a++){let l=t[a],c=o,u=o+=l.size;c>=n||u<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>n&&s.push(l.slice(n-c,l.size,r)))}return s}function zk(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,a=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let o=r.resolve(a),l,c;if(Sw(n)){for(l=a;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&zt.isSelectable(h)&&i.parent&&!(h.isInline&&pwe(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;c=new zt(a==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=a,g=a;for(let m=0;m<n.rangeCount;m++){let b=n.getRangeAt(m);h=Math.min(h,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(h<0)return null;[l,a]=g==t.state.selection.anchor?[g,h]:[h,g],o=r.resolve(a)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let h=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;c=Bk(t,u,o,h)}return c}function JW(t){return t.editable?t.hasFocus():tq(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function dc(t,e=!1){let n=t.state.selection;if(eq(t,n),!!JW(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ls){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Uf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Vwe(t);else{let{anchor:r,head:i}=n,s,a;GB&&!(n instanceof Wt)&&(n.$from.parent.inlineContent||(s=WB(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=WB(t,n.to))),t.docView.setSelection(r,i,t,e),GB&&(s&&qB(s),a&&qB(a)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&$we(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const GB=Ss||ls&&BW<63;function WB(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Ss&&i&&i.contentEditable=="false")return _2(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return _2(i);if(s)return _2(s)}}function _2(t){return t.contentEditable="true",Ss&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function qB(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function $we(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(()=>{(!JW(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Vwe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,qi(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Vs&&Gu<=11&&(n.disabled=!0,n.disabled=!1)}function eq(t,e){if(e instanceof zt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(XB(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else XB(t)}function XB(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Bk(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Wt.between(e,n,r)}function KB(t){return t.editable&&!t.hasFocus()?!1:tq(t)}function tq(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 Gwe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Uf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function sR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ln.findFrom(s,e)}function _u(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function YB(t,e,n){let r=t.state.selection;if(r instanceof Wt)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let a=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return _u(t,new Wt(r.$anchor,a))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=sR(t.state,e);return i&&i instanceof zt?_u(t,i):!1}else if(!(Ia&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(a=t.docView.descAt(o))&&!a.contentDOM?zt.isSelectable(s)?_u(t,new zt(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Z0?_u(t,new Wt(t.state.doc.resolve(e<0?o:o+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof zt&&r.node.isInline)return _u(t,new Wt(e>0?r.$to:r.$from));{let i=sR(t.state,e);return i?_u(t,i):!1}}}function _1(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Lx(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function pp(t,e){return e<0?Wwe(t):qwe(t)}function Wwe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,a=!1;for(qa&&n.nodeType==1&&r<_1(n)&&Lx(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Lx(o,-1))i=n,s=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(nq(n))break;{let o=n.previousSibling;for(;o&&Lx(o,-1);)i=n.parentNode,s=qi(o),o=o.previousSibling;if(o)n=o,r=_1(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}a?aR(t,n,r):i&&aR(t,i,s)}function qwe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=_1(n),s,a;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Lx(o,1))s=n,a=++r;else break}else{if(nq(n))break;{let o=n.nextSibling;for(;o&&Lx(o,1);)s=o.parentNode,a=qi(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=_1(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&aR(t,s,a)}function nq(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Xwe(t,e){for(;t&&e==t.childNodes.length&&!Y0(t);)e=qi(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 Kwe(t,e){for(;t&&!e&&!Y0(t);)e=qi(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 aR(t,e,n){if(e.nodeType!=3){let s,a;(a=Xwe(e,n))?(e=a,n=0):(s=Kwe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Sw(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&dc(t)},50)}function ZB(t,e){let n=t.state.doc.resolve(e);if(!(ls||xwe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function QB(t,e,n){let r=t.state.selection;if(r instanceof Wt&&!r.empty||n.indexOf("s")>-1||Ia&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let a=sR(t.state,e);if(a&&a instanceof zt)return _u(t,a)}if(!i.parent.inlineContent){let a=e<0?i:s,o=r instanceof pa?ln.near(a,e):ln.findFrom(a,e);return o?_u(t,o):!1}return!1}function JB(t,e){if(!(t.state.selection instanceof Wt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let a=t.state.tr;return e<0?a.delete(n.pos-s.nodeSize,n.pos):a.delete(n.pos,n.pos+s.nodeSize),t.dispatch(a),!0}return!1}function e6(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ywe(t){if(!Ss||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;e6(t,r,"true"),setTimeout(()=>e6(t,r,"false"),20)}return!1}function Zwe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Qwe(t,e){let n=e.keyCode,r=Zwe(e);if(n==8||Ia&&n==72&&r=="c")return JB(t,-1)||pp(t,-1);if(n==46&&!e.shiftKey||Ia&&n==68&&r=="c")return JB(t,1)||pp(t,1);if(n==13||n==27)return!0;if(n==37||Ia&&n==66&&r=="c"){let i=n==37?ZB(t,t.state.selection.from)=="ltr"?-1:1:-1;return YB(t,i,r)||pp(t,i)}else if(n==39||Ia&&n==70&&r=="c"){let i=n==39?ZB(t,t.state.selection.from)=="ltr"?1:-1:1;return YB(t,i,r)||pp(t,i)}else{if(n==38||Ia&&n==80&&r=="c")return QB(t,-1,r)||pp(t,-1);if(n==40||Ia&&n==78&&r=="c")return Ywe(t)||QB(t,1,r)||pp(t,1);if(r==(Ia?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Hk(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let a=t.someProp("clipboardSerializer")||Zf.fromSchema(t.state.schema),o=lq(),l=o.createElement("div");l.appendChild(a.serializeFragment(r,{document:o}));let c=l.firstChild,u,h=0;for(;c&&c.nodeType==1&&(u=oq[c.nodeName.toLowerCase()]);){for(let m=u.length-1;m>=0;m--){let b=o.createElement(u[m]);for(;l.firstChild;)b.appendChild(l.firstChild);l.appendChild(b),h++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:l,text:g,slice:e}}function rq(t,e,n,r,i){let s=i.parent.type.spec.code,a,o;if(!n&&!e)return null;let l=!!e&&(r||s||!n);if(l){if(t.someProp("transformPastedText",g=>{e=g(e,s||r,t)}),s)return o=new Mt(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let h=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(h)o=h;else{let g=i.marks(),{schema:m}=t.state,b=Zf.fromSchema(m);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let v=a.appendChild(document.createElement("p"));y&&v.appendChild(b.serializeNode(m.text(y,g)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),a=nMe(n),Z0&&rMe(a);let c=a&&a.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let g=a.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;a=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||kx.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(l||u),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!Jwe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),u)o=iMe(t6(o,+u[1],+u[2]),u[4]);else if(o=Mt.maxOpen(eMe(o.content,i),!0),o.openStart||o.openEnd){let h=0,g=0;for(let m=o.content.firstChild;h<o.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=o.content.lastChild;g<o.openEnd&&!m.type.spec.isolating;g++,m=m.lastChild);o=t6(o,h,g)}return t.someProp("transformPasted",h=>{o=h(o,t,l)}),o}const Jwe=/^(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 eMe(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,a=[];if(t.forEach(o=>{if(!a)return;let l=i.findWrapping(o.type),c;if(!l)return a=null;if(c=a.length&&s.length&&sq(l,s,o,a[a.length-1],0))a[a.length-1]=c;else{a.length&&(a[a.length-1]=aq(a[a.length-1],s.length));let u=iq(o,l);a.push(u),i=i.matchType(u.type),s=l}}),a)return pt.from(a)}return t}function iq(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function sq(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=sq(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(pt.from(iq(n,t,i+1))))}}function aq(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,aq(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function oR(t,e,n,r,i,s){let a=e<0?t.firstChild:t.lastChild,o=a.content;return t.childCount>1&&(s=0),i<r-1&&(o=oR(o,e,n,r,i+1,s)),i>=n&&(o=e<0?a.contentMatchAt(0).fillBefore(o,s<=i).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(pt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(o))}function t6(t,e,n){return e<t.openStart&&(t=new Mt(oR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Mt(oR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const oq={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 n6=null;function lq(){return n6||(n6=document.implementation.createHTMLDocument("title"))}let S2=null;function tMe(t){let e=window.trustedTypes;return e?(S2||(S2=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),S2.createHTML(t)):t}function nMe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=lq().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&oq[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=tMe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function rMe(t){let e=t.querySelectorAll(ls?"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 iMe(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:a}=t;for(let o=r.length-2;o>=0;o-=2){let l=n.nodes[r[o]];if(!l||l.hasRequiredAttrs())break;i=pt.from(l.create(r[o+1],i)),s++,a++}return new Mt(i,s,a)}const ws={},Ms={},sMe={touchstart:!0,touchmove:!0};class aMe{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 oMe(t){for(let e in ws){let n=ws[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{cMe(t,r)&&!$k(t,r)&&(t.editable||!(r.type in Ms))&&n(t,r)},sMe[e]?{passive:!0}:void 0)}Ss&&t.dom.addEventListener("input",()=>null),lR(t)}function Uu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function lMe(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=>$k(t,r))})}function $k(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function cMe(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 uMe(t,e){!$k(t,e)&&ws[e.type]&&(t.editable||!(e.type in Ms))&&ws[e.type](t,e)}Ms.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!uq(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(rc&&ls&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),um&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Jd(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Qwe(t,n)?n.preventDefault():Uu(t,"key")};Ms.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ms.keypress=(t,e)=>{let n=e;if(uq(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ia&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Wt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",a=>a(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function Mw(t){return{left:t.clientX,top:t.clientY}}function dMe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Vk(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let a=s.depth+1;a>0;a--)if(t.someProp(e,o=>a>s.depth?o(t,n,s.nodeAfter,s.before(a),i,!0):o(t,n,s.node(a),s.before(a),i,!1)))return!0;return!1}function Bp(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 fMe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&zt.isSelectable(r)?(Bp(t,new zt(n)),!0):!1}function hMe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof zt&&(r=n.node);let s=t.state.doc.resolve(e);for(let a=s.depth+1;a>0;a--){let o=a>s.depth?s.nodeAfter:s.node(a);if(zt.isSelectable(o)){r&&n.$from.depth>0&&a>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(a);break}}return i!=null?(Bp(t,zt.create(t.state.doc,i)),!0):!1}function pMe(t,e,n,r,i){return Vk(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?hMe(t,n):fMe(t,n))}function mMe(t,e,n,r){return Vk(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function gMe(t,e,n,r){return Vk(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||xMe(t,n,r)}function xMe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Bp(t,Wt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s),o=i.before(s);if(a.inlineContent)Bp(t,Wt.create(r,o+1,o+1+a.content.size));else if(zt.isSelectable(a))Bp(t,zt.create(r,o));else continue;return!0}}function Gk(t){return S1(t)}const cq=Ia?"metaKey":"ctrlKey";ws.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Gk(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&dMe(n,t.input.lastClick)&&!n[cq]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let a=t.posAtCoords(Mw(n));a&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new vMe(t,a,n,!!r)):(s=="doubleClick"?mMe:gMe)(t,a.pos,a.inside,n)?n.preventDefault():Uu(t,"pointer"))};class vMe{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[cq],this.allowDefault=r.shiftKey;let s,a;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),a=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,a=u.depth?u.before():0}const o=i?null:r.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof zt&&c.from<=a&&c.to>a)&&(this.mightDrag={node:s,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qa&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Uu(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>dc(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Mw(e))),this.updateAllowDefault(e),this.allowDefault||!n?Uu(this.view,"pointer"):pMe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ss&&this.mightDrag&&!this.mightDrag.node.isAtom||ls&&!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)?(Bp(this.view,ln.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Uu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Uu(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ws.touchstart=t=>{t.input.lastTouch=Date.now(),Gk(t),Uu(t,"pointer")};ws.touchmove=t=>{t.input.lastTouch=Date.now(),Uu(t,"pointer")};ws.contextmenu=t=>Gk(t);function uq(t,e){return t.composing?!0:Ss&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const bMe=rc?5e3:-1;Ms.compositionstart=Ms.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Wt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),S1(t,!0),t.markCursor=null;else if(S1(t,!e.selection.empty),qa&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let a=s<0?i.lastChild:i.childNodes[s-1];if(!a)break;if(a.nodeType==3){let o=t.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else i=a,s=-1}}t.input.composing=!0}dq(t,bMe)};Ms.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++,dq(t,20))};function dq(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>S1(t),e))}function fq(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=_Me());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function yMe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=fwe(e.focusNode,e.focusOffset),r=hwe(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let a=n.pmViewDesc;if(!(!a||!a.isText(n.nodeValue)))return r}}return n||r}function _Me(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function S1(t,e=!1){if(!(rc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),fq(t),e||t.docView&&t.docView.dirty){let n=zk(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 SMe(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 m0=Vs&&Gu<15||um&&vwe<604;ws.copy=Ms.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=m0?null:n.clipboardData,a=r.content(),{dom:o,text:l}=Hk(t,a);s?(n.preventDefault(),s.clearData(),s.setData("text/html",o.innerHTML),s.setData("text/plain",l)):SMe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function wMe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function MMe(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?g0(t,r.value,null,i,e):g0(t,r.textContent,r.innerHTML,i,e)},50)}function g0(t,e,n,r,i){let s=rq(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||Mt.empty)))return!0;if(!s)return!1;let a=wMe(s),o=a?t.state.tr.replaceSelectionWith(a,r):t.state.tr.replaceSelection(s);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function hq(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," "):""}Ms.paste=(t,e)=>{let n=e;if(t.composing&&!rc)return;let r=m0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&g0(t,hq(r),r.getData("text/html"),i,n)?n.preventDefault():MMe(t,n)};class pq{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const EMe=Ia?"altKey":"ctrlKey";function mq(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[EMe]}ws.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(Mw(n)),a;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof zt?i.to-1:i.to))){if(r&&r.mightDrag)a=zt.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(a=zt.create(t.state.doc,h.posBefore))}}let o=(a||t.state.selection).content(),{dom:l,text:c,slice:u}=Hk(t,o);(!n.dataTransfer.files.length||!ls||BW>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(m0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",m0||n.dataTransfer.setData("text/plain",c),t.dragging=new pq(u,mq(t,n),a)};ws.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ms.dragover=Ms.dragenter=(t,e)=>e.preventDefault();Ms.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(Mw(n));if(!i)return;let s=t.state.doc.resolve(i.pos),a=r&&r.slice;a?t.someProp("transformPasted",b=>{a=b(a,t,!1)}):a=rq(t,hq(n.dataTransfer),m0?null:n.dataTransfer.getData("text/html"),!1,s);let o=!!(r&&mq(t,n));if(t.someProp("handleDrop",b=>b(t,n,a||Mt.empty,o))){n.preventDefault();return}if(!a)return;n.preventDefault();let l=a?yW(t.state.doc,s.pos,a):s.pos;l==null&&(l=s.pos);let c=t.state.tr;if(o){let{node:b}=r;b?b.replace(c):c.deleteSelection()}let u=c.mapping.map(l),h=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,g=c.doc;if(h?c.replaceRangeWith(u,u,a.content.firstChild):c.replaceRange(u,u,a),c.doc.eq(g))return;let m=c.doc.resolve(u);if(h&&zt.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new zt(m));else{let b=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((y,v,x,M)=>b=M),c.setSelection(Bk(t,m,c.doc.resolve(b)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};ws.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&dc(t)},20))};ws.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)};ws.beforeinput=(t,e)=>{if(ls&&rc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,Jd(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Ms)ws[t]=Ms[t];function x0(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 w1{constructor(e,n){this.toDOM=e,this.spec=n||mf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:a}=e.mapResult(n.from+i,this.side<0?-1:1);return a?null:new bs(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof w1&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&x0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class qu{constructor(e,n){this.attrs=e,this.spec=n||mf}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,a=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=a?null:new bs(s,a,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof qu&&x0(this.attrs,e.attrs)&&x0(this.spec,e.spec)}static is(e){return e.type instanceof qu}destroy(){}}class Wk{constructor(e,n){this.attrs=e,this.spec=n||mf}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let a=e.mapResult(n.to+i,-1);return a.deleted||a.pos<=s.pos?null:new bs(s.pos-r,a.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof Wk&&x0(this.attrs,e.attrs)&&x0(this.spec,e.spec)}destroy(){}}class bs{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new bs(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 bs(e,e,new w1(n,r))}static inline(e,n,r,i){return new bs(e,n,new qu(r,i))}static node(e,n,r,i){return new bs(e,n,new Wk(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof qu}get widget(){return this.type instanceof w1}}const Sp=[],mf={};class mr{constructor(e,n){this.local=e.length?e:Sp,this.children=n.length?n:Sp}static create(e,n){return n.length?M1(n,e,0,mf):rs}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=n&&o.to>=e&&(!s||s(o.spec))&&r.push(o.copy(o.from+i,o.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<n&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,n-o,r,i+o,s)}}map(e,n,r){return this==rs||e.maps.length==0?this:this.mapInner(e,n,0,0,r||mf)}mapInner(e,n,r,i,s){let a;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(e,r,i);l&&l.type.valid(n,l)?(a||(a=[])).push(l):s.onRemove&&s.onRemove(this.local[o].spec)}return this.children.length?AMe(this.children,a||[],e,n,r,i,s):a?new mr(a.sort(gf),Sp):rs}add(e,n){return n.length?this==rs?mr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((o,l)=>{let c=l+r,u;if(u=xq(n,o,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<l;)s+=3;i[s]==l?i[s+2]=i[s+2].addInner(o,u,c+1):i.splice(s,0,l,l+o.nodeSize,M1(u,o,c+1,mf)),s+=3}});let a=gq(s?vq(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||a.splice(o--,1);return new mr(a.length?this.local.concat(a).sort(gf):this.local,i||this.children)}remove(e){return e.length==0||this==rs?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let a,o=r[s]+n,l=r[s+1]+n;for(let u=0,h;u<e.length;u++)(h=e[u])&&h.from>o&&h.to<l&&(e[u]=null,(a||(a=[])).push(h));if(!a)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(a,o+1);c!=rs?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,a;s<e.length;s++)if(a=e[s])for(let o=0;o<i.length;o++)i[o].eq(a,n)&&(i==this.local&&(i=this.local.slice()),i.splice(o--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new mr(i,r):rs}forChild(e,n){if(this==rs)return this;if(n.isLeaf)return mr.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let s=e+1,a=s+n.content.size;for(let o=0;o<this.local.length;o++){let l=this.local[o];if(l.from<a&&l.to>s&&l.type instanceof qu){let c=Math.max(s,l.from)-s,u=Math.min(a,l.to)-s;c<u&&(i||(i=[])).push(l.copy(c,u))}}if(i){let o=new mr(i.sort(gf),Sp);return r?new Cu([o,r]):o}return r||rs}eq(e){if(this==e)return!0;if(!(e instanceof mr)||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 qk(this.localsInner(e))}localsInner(e){if(this==rs)return Sp;if(e.inlineContent||!this.local.some(qu.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof qu||n.push(this.local[r]);return n}forEachSet(e){e(this)}}mr.empty=new mr([],[]);mr.removeOverlap=qk;const rs=mr.empty;class Cu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,mf));return Cu.from(r)}forChild(e,n){if(n.isLeaf)return mr.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=rs&&(s instanceof Cu?r=r.concat(s.members):r.push(s))}return Cu.from(r)}eq(e){if(!(e instanceof Cu)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let a=0;a<s.length;a++)n.push(s[a])}}return n?qk(r?n:n.sort(gf)):Sp}static from(e){switch(e.length){case 0:return rs;case 1:return e[0];default:return new Cu(e.every(n=>n instanceof mr)?e:e.reduce((n,r)=>n.concat(r instanceof mr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function AMe(t,e,n,r,i,s,a){let o=t.slice();for(let c=0,u=s;c<n.maps.length;c++){let h=0;n.maps[c].forEach((g,m,b,y)=>{let v=y-b-(m-g);for(let x=0;x<o.length;x+=3){let M=o[x+1];if(M<0||g>M+u-h)continue;let w=o[x]+u-h;m>=w?o[x+1]=g<=w?-2:-1:g>=u&&v&&(o[x]+=v,o[x+1]+=v)}h+=v}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<o.length;c+=3)if(o[c+1]<0){if(o[c+1]==-2){l=!0,o[c+1]=-1;continue}let u=n.map(t[c]+s),h=u-i;if(h<0||h>=r.content.size){l=!0;continue}let g=n.map(t[c+1]+s,-1),m=g-i,{index:b,offset:y}=r.content.findIndex(h),v=r.maybeChild(b);if(v&&y==h&&y+v.nodeSize==m){let x=o[c+2].mapInner(n,v,u+1,t[c]+s+1,a);x!=rs?(o[c]=h,o[c+1]=m,o[c+2]=x):(o[c+1]=-2,l=!0)}else l=!0}if(l){let c=TMe(o,t,e,n,i,s,a),u=M1(c,r,0,a);e=u.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,g=0;h<u.children.length;h+=3){let m=u.children[h];for(;g<o.length&&o[g]<m;)g+=3;o.splice(g,0,u.children[h],u.children[h+1],u.children[h+2])}}return new mr(e.sort(gf),o)}function gq(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 bs(i.from+e,i.to+e,i.type))}return n}function TMe(t,e,n,r,i,s,a){function o(l,c){for(let u=0;u<l.local.length;u++){let h=l.local[u].map(r,i,c);h?n.push(h):a.onRemove&&a.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)o(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&o(t[l+2],e[l]+s+1);return n}function xq(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,a;s<t.length;s++)(a=t[s])&&a.from>n&&a.to<r&&((i||(i=[])).push(a),t[s]=null);return i}function vq(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function M1(t,e,n,r){let i=[],s=!1;e.forEach((o,l)=>{let c=xq(t,o,l+n);if(c){s=!0;let u=M1(c,o,n+l+1,r);u!=rs&&i.push(l,l+o.nodeSize,u)}});let a=gq(s?vq(t):t,-n).sort(gf);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||(r.onRemove&&r.onRemove(a[o].spec),a.splice(o--,1));return a.length||i.length?new mr(a,i):rs}function gf(t,e){return t.from-e.from||t.to-e.to}function qk(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),r6(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),r6(e,i,r.copy(s.from,r.to)));break}}}return e}function r6(t,e,n){for(;e<t.length&&gf(n,t[e])>0;)e++;t.splice(e,0,n)}function w2(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=rs&&e.push(r)}),t.cursorWrapper&&e.push(mr.create(t.state.doc,[t.cursorWrapper.deco])),Cu.from(e)}const CMe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},NMe=Vs&&Gu<=11;class RMe{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 PMe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new RMe,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]);Vs&&Gu<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),NMe&&(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,CMe)),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(KB(this.view)){if(this.suppressingSelectionUpdates)return dc(this.view);if(Vs&&Gu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Uf(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=cm(s))n.add(s);for(let s=e.anchorNode;s;s=cm(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&KB(e)&&!this.ignoreSelectionChange(r),s=-1,a=-1,o=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let h=this.registerMutation(n[u],l);h&&(s=s<0?h.from:Math.min(h.from,s),a=a<0?h.to:Math.max(h.to,a),h.typeOver&&(o=!0))}if(qa&&l.length){let u=l.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,g]=u;h.parentNode&&h.parentNode.parentNode==g.parentNode?g.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let g of u){let m=g.parentNode;m&&m.nodeName=="LI"&&(!h||OMe(e,h)!=m)&&g.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Sw(r)&&(c=zk(e))&&c.eq(ln.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,dc(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),kMe(e)),this.handleDOMChange(s,a,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||dc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Vs&&Gu<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:g}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(s=g)}let a=i&&i.parentNode==e.target?qi(i)+1:0,o=r.localPosFromDOM(e.target,a,-1),l=s&&s.parentNode==e.target?qi(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:o,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let i6=new WeakMap,s6=!1;function kMe(t){if(!i6.has(t)&&(i6.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=qa,s6)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."),s6=!0}}function a6(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return Uf(a.node,a.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function DMe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return a6(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?a6(t,n):null}function OMe(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 LMe(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:a,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],Sw(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ls&&t.input.lastKeyCode===8)for(let v=s;v>i;v--){let x=r.childNodes[v-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){s=v;break}if(!M||M.size)break}let h=t.state.doc,g=t.someProp("domParser")||kx.fromSchema(t.state.schema),m=h.resolve(a),b=null,y=g.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:IMe,context:m});if(c&&c[0].pos!=null){let v=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=v),b={anchor:v+a,head:x+a}}return{doc:y,sel:b,from:a,to:o}}function IMe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ss&&/^(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||Ss&&/^(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 jMe=/^(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 UMe(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,j=zk(t,C);if(j&&!t.state.selection.eq(j)){if(ls&&rc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",k=>k(t,Jd(13,"Enter"))))return;let N=t.state.tr.setSelection(j);C=="pointer"?N.setMeta("pointer",!0):C=="key"&&N.scrollIntoView(),s&&N.setMeta("composition",s),t.dispatch(N)}return}let a=t.state.doc.resolve(e),o=a.sharedDepth(n);e=a.before(o+1),n=t.state.doc.resolve(n).after(o+1);let l=t.state.selection,c=LMe(t,e,n),u=t.state.doc,h=u.slice(c.from,c.to),g,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,m="end"):(g=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let b=BMe(h.content,c.doc.content,c.from,g,m);if(b&&t.input.domChangeCount++,(um&&t.input.lastIOSEnter>Date.now()-225||rc)&&i.some(C=>C.nodeType==1&&!jMe.test(C.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",C=>C(t,Jd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&l instanceof Wt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))b={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let C=o6(t,t.state.doc,c.sel);if(C&&!C.eq(t.state.selection)){let j=t.state.tr.setSelection(C);s&&j.setMeta("composition",s),t.dispatch(j)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof Wt&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Vs&&Gu<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>c.from&&c.doc.textBetween(b.start-c.from-1,b.start-c.from+1)==" "&&(b.start--,b.endA--,b.endB--);let y=c.doc.resolveNoCache(b.start-c.from),v=c.doc.resolveNoCache(b.endB-c.from),x=u.resolve(b.start),M=y.sameParent(v)&&y.parent.inlineContent&&x.end()>=b.endA;if((um&&t.input.lastIOSEnter>Date.now()-225&&(!M||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!M&&y.pos<c.doc.content.size&&(!y.sameParent(v)||!y.parent.inlineContent)&&y.pos<v.pos&&!/\S/.test(c.doc.textBetween(y.pos,v.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,Jd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&zMe(u,b.start,b.endA,y,v)&&t.someProp("handleKeyDown",C=>C(t,Jd(8,"Backspace")))){rc&&ls&&t.domObserver.suppressSelectionUpdates();return}ls&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),rc&&!M&&y.start()!=v.start()&&v.parentOffset==0&&y.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==b.endA&&(b.endB-=2,v=c.doc.resolveNoCache(b.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,Jd(13,"Enter"))})},20));let w=b.start,T=b.endA,A=C=>{let j=C||t.state.tr.replace(w,T,c.doc.slice(b.start-c.from,b.endB-c.from));if(c.sel){let N=o6(t,j.doc,c.sel);N&&!(ls&&t.composing&&N.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==w||N.head==j.mapping.map(T)-1)||Vs&&N.empty&&N.head==w)&&j.setSelection(N)}return s&&j.setMeta("composition",s),j.scrollIntoView()},P;if(M)if(y.pos==v.pos){Vs&&Gu<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>dc(t),20));let C=A(t.state.tr.delete(w,T)),j=u.resolve(b.start).marksAcross(u.resolve(b.endA));j&&C.ensureMarks(j),t.dispatch(C)}else if(b.endA==b.endB&&(P=FMe(y.parent.content.cut(y.parentOffset,v.parentOffset),x.parent.content.cut(x.parentOffset,b.endA-x.start())))){let C=A(t.state.tr);P.type=="add"?C.addMark(w,T,P.mark):C.removeMark(w,T,P.mark),t.dispatch(C)}else if(y.parent.child(y.index()).isText&&y.index()==v.index()-(v.textOffset?0:1)){let C=y.parent.textBetween(y.parentOffset,v.parentOffset),j=()=>A(t.state.tr.insertText(C,w,T));t.someProp("handleTextInput",N=>N(t,w,T,C,j))||t.dispatch(j())}else t.dispatch(A());else t.dispatch(A())}function o6(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Bk(t,e.resolve(n.anchor),e.resolve(n.head))}function FMe(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,a,o,l;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(i.length==1&&s.length==0)o=i[0],a="add",l=u=>u.mark(o.addToSet(u.marks));else if(i.length==0&&s.length==1)o=s[0],a="remove",l=u=>u.mark(o.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(pt.from(c).eq(t))return{mark:o,type:a}}function zMe(t,e,n,r,i){if(n-e<=i.pos-r.pos||M2(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let o=s.nodeAfter;return o!=null&&n==e+o.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let a=t.resolve(M2(s,!0,!0));return!a.parent.isTextblock||a.pos>n||M2(a,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(a.parent.content)}function M2(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function BMe(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let l=Math.max(0,s-Math.min(a,o));r-=a+l-s}if(a<s&&t.size<e.size){let l=r<=s&&r>=a?s-r:0;s-=l,s&&s<e.size&&l6(e.textBetween(s-1,s+1))&&(s+=l?1:-1),o=s+(o-a),a=s}else if(o<s){let l=r<=s&&r>=o?s-r:0;s-=l,s&&s<t.size&&l6(t.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-o),o=s}return{start:s,endA:a,endB:o}}function l6(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 bq{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 aMe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(h6),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=d6(this),u6(this),this.nodeViews=f6(this),this.docView=$B(this.state.doc,c6(this),w2(this),this.dom,this),this.domObserver=new PMe(this,(r,i,s,a)=>UMe(this,r,i,s,a)),this.domObserver.start(),oMe(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(h6),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,a=!1;e.storedMarks&&this.composing&&(fq(this),a=!0),this.state=e;let o=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=f6(this);$Me(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&lR(this),this.editable=d6(this),u6(this);let l=w2(this),c=c6(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,c,l);(h||!e.selection.eq(i.selection))&&(a=!0);let g=u=="preserve"&&a&&this.dom.style.overflowAnchor==null&&_we(this);if(a){this.domObserver.stop();let m=h&&(Vs||ls)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&HMe(i.selection,e.selection);if(h){let b=ls?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=yMe(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=$B(e.doc,c,l,this.dom,this)),b&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Gwe(this))?dc(this,m):(eq(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():g&&Swe(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof zt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&jB(this,n.getBoundingClientRect(),e)}else jB(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new pq(e.slice,e.move,i<0?void 0:zt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let a=0;a<this.directPlugins.length;a++){let o=this.directPlugins[a].props[e];if(o!=null&&(i=n?n(o):o))return i}let s=this.state.plugins;if(s)for(let a=0;a<s.length;a++){let o=s[a].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Vs){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&&wwe(this.dom),dc(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Cwe(this,e)}coordsAtPos(e,n=1){return WW(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 Dwe(this,n||this.state,e)}pasteHTML(e,n){return g0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return g0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Hk(this,e)}destroy(){this.docView&&(lMe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],w2(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,uwe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return uMe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ss&&this.root.nodeType===11&&mwe(this.dom.ownerDocument)==this.dom&&DMe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}bq.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function c6(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"),[bs.node(0,t.state.doc.content.size,e)]}function u6(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:bs.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function d6(t){return!t.someProp("editable",e=>e(t.state)===!1)}function HMe(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 f6(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 $Me(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 h6(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 td={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:"'"},E1={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},VMe=typeof navigator<"u"&&/Mac/.test(navigator.platform),GMe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Xi=0;Xi<10;Xi++)td[48+Xi]=td[96+Xi]=String(Xi);for(var Xi=1;Xi<=24;Xi++)td[Xi+111]="F"+Xi;for(var Xi=65;Xi<=90;Xi++)td[Xi]=String.fromCharCode(Xi+32),E1[Xi]=String.fromCharCode(Xi);for(var E2 in td)E1.hasOwnProperty(E2)||(E1[E2]=td[E2]);function WMe(t){var e=VMe&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||GMe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?E1:td)[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 qMe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),XMe=typeof navigator<"u"&&/Win/.test(navigator.platform);function KMe(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,a;for(let o=0;o<e.length-1;o++){let l=e[o];if(/^(cmd|meta|m)$/i.test(l))a=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))qMe?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),a&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function YMe(t){let e=Object.create(null);for(let n in t)e[KMe(n)]=t[n];return e}function A2(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 ZMe(t){return new vr({props:{handleKeyDown:yq(t)}})}function yq(t){let e=YMe(t);return function(n,r){let i=WMe(r),s,a=e[A2(i,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[A2(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(XMe&&r.ctrlKey&&r.altKey)&&(s=td[r.keyCode])&&s!=i){let o=e[A2(s,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var QMe=Object.defineProperty,Xk=(t,e)=>{for(var n in e)QMe(t,n,{get:e[n],enumerable:!0})};function Ew(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var Aw=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([a,o])=>[a,(...c)=>{const u=o(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,a=[],o=!!t,l=t||i.tr,c=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),a.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(n).map(([h,g])=>[h,(...b)=>{const y=this.buildProps(l,e),v=g(...b)(y);return a.push(v),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,l])=>[o,(...c)=>l(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,a={tr:t,editor:r,view:s,state:Ew({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>l(...c)(a)]))}};return a}},_q={};Xk(_q,{blur:()=>JMe,clearContent:()=>eEe,clearNodes:()=>tEe,command:()=>nEe,createParagraphNear:()=>rEe,cut:()=>iEe,deleteCurrentNode:()=>sEe,deleteNode:()=>aEe,deleteRange:()=>oEe,deleteSelection:()=>lEe,enter:()=>cEe,exitCode:()=>uEe,extendMarkRange:()=>dEe,first:()=>fEe,focus:()=>pEe,forEach:()=>mEe,insertContent:()=>gEe,insertContentAt:()=>bEe,joinBackward:()=>SEe,joinDown:()=>_Ee,joinForward:()=>wEe,joinItemBackward:()=>MEe,joinItemForward:()=>EEe,joinTextblockBackward:()=>AEe,joinTextblockForward:()=>TEe,joinUp:()=>yEe,keyboardShortcut:()=>NEe,lift:()=>REe,liftEmptyBlock:()=>PEe,liftListItem:()=>kEe,newlineInCode:()=>DEe,resetAttributes:()=>OEe,scrollIntoView:()=>LEe,selectAll:()=>IEe,selectNodeBackward:()=>jEe,selectNodeForward:()=>UEe,selectParentNode:()=>FEe,selectTextblockEnd:()=>zEe,selectTextblockStart:()=>BEe,setContent:()=>HEe,setMark:()=>aAe,setMeta:()=>oAe,setNode:()=>lAe,setNodeSelection:()=>cAe,setTextDirection:()=>uAe,setTextSelection:()=>dAe,sinkListItem:()=>fAe,splitBlock:()=>hAe,splitListItem:()=>pAe,toggleList:()=>mAe,toggleMark:()=>gAe,toggleNode:()=>xAe,toggleWrap:()=>vAe,undoInputRule:()=>bAe,unsetAllMarks:()=>yAe,unsetMark:()=>_Ae,unsetTextDirection:()=>SAe,updateAttributes:()=>wAe,wrapIn:()=>MAe,wrapInList:()=>EAe});var JMe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),eEe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),tEe=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:a})=>{t.doc.nodesBetween(s.pos,a.pos,(o,l)=>{if(o.type.isText)return;const{doc:c,mapping:u}=e,h=c.resolve(u.map(l)),g=c.resolve(u.map(l+o.nodeSize)),m=h.blockRange(g);if(!m)return;const b=Om(m);if(o.type.isTextblock){const{defaultType:y}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(m.start,y)}(b||b===0)&&e.lift(m,b)})}),!0},nEe=t=>e=>t(e),rEe=()=>({state:t,dispatch:e})=>IW(t,e),iEe=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const a=r.mapping.map(e);return r.insert(a,s.content),r.setSelection(new Wt(r.doc.resolve(Math.max(a-1,0)))),!0},sEe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const o=i.before(s),l=i.after(s);t.delete(o,l).scrollIntoView()}return!0}return!1};function Zr(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 aEe=t=>({tr:e,state:n,dispatch:r})=>{const i=Zr(t,n.schema),s=e.selection.$anchor;for(let a=s.depth;a>0;a-=1)if(s.node(a).type===i){if(r){const l=s.before(a),c=s.after(a);e.delete(l,c).scrollIntoView()}return!0}return!1},oEe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},lEe=()=>({state:t,dispatch:e})=>Ok(t,e),cEe=()=>({commands:t})=>t.keyboardShortcut("Enter"),uEe=()=>({state:t,dispatch:e})=>KSe(t,e);function Kk(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function A1(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Kk(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Sq(t,e,n={}){return t.find(r=>r.type===e&&A1(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function p6(t,e,n={}){return!!Sq(t,e,n)}function Yk(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!Sq([...i.node.marks],e,n)))return;let a=i.index,o=t.start()+i.offset,l=a+1,c=o+i.node.nodeSize;for(;a>0&&p6([...t.parent.child(a-1).marks],e,n);)a-=1,o-=t.parent.child(a).nodeSize;for(;l<t.parent.childCount&&p6([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:c}}function Ac(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var dEe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Ac(t,r.schema),{doc:a,selection:o}=n,{$from:l,from:c,to:u}=o;if(i){const h=Yk(l,s,e);if(h&&h.from<=c&&h.to>=u){const g=Wt.create(a,h.from,h.to);n.setSelection(g)}}return!0},fEe=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 wq(t){return t instanceof Wt}function sf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Mq(t,e=null){if(!e)return null;const n=ln.atStart(t),r=ln.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?Wt.create(t,sf(0,i,s),sf(t.content.size,i,s)):Wt.create(t,sf(e,i,s),sf(e,i,s))}function hEe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Zk(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var pEe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const a=()=>{(Zk()||hEe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!wq(n.state.selection))return a(),!0;const o=Mq(i.doc,t)||n.state.selection,l=n.state.selection.eq(o);return s&&(l||i.setSelection(o),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),a()),!0},mEe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),gEe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Eq=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&&Eq(r)}return t};function Gy(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 Eq(n)}function v0(t,e,n){if(t instanceof Vu||t instanceof pt)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return pt.fromArray(t.map(o=>e.nodeFromJSON(o)));const a=e.nodeFromJSON(t);return n.errorOnInvalidContent&&a.check(),a}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),v0("",e,n)}if(i){if(n.errorOnInvalidContent){let a=!1,o="";const l=new cW({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(a=!0,o=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?kx.fromSchema(l).parseSlice(Gy(t),n.parseOptions):kx.fromSchema(l).parse(Gy(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const s=kx.fromSchema(e);return n.slice?s.parseSlice(Gy(t),n.parseOptions).content:s.parse(Gy(t),n.parseOptions)}return v0("",e,n)}function xEe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Ti||i instanceof Ni))return;const s=t.mapping.maps[r];let a=0;s.forEach((o,l,c,u)=>{a===0&&(a=u)}),t.setSelection(ln.near(t.doc.resolve(a),n))}var vEe=t=>!("type"in t),bEe=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var a;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const l=v=>{s.emit("contentError",{editor:s,error:v,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{v0(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(v){l(v)}try{o=v0(e,s.schema,{parseOptions:c,errorOnInvalidContent:(a=n.errorOnInvalidContent)!=null?a:s.options.enableContentCheck})}catch(v){return l(v),!1}let{from:u,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((vEe(o)?o:[o]).forEach(v=>{v.check(),g=g?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),u===h&&m){const{parent:v}=r.doc.resolve(u);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(u-=1,h+=1)}let y;if(g){if(Array.isArray(e))y=e.map(v=>v.text||"").join("");else if(e instanceof pt){let v="";e.forEach(x=>{x.text&&(v+=x.text)}),y=v}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,u,h)}else{y=o;const v=r.doc.resolve(u),x=v.node(),M=v.parentOffset===0,w=x.isText||x.isTextblock,T=x.content.size>0;M&&w&&T&&(u=Math.max(0,u-1)),r.replaceWith(u,h,y)}n.updateSelection&&xEe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:y})}return!0},yEe=()=>({state:t,dispatch:e})=>WSe(t,e),_Ee=()=>({state:t,dispatch:e})=>qSe(t,e),SEe=()=>({state:t,dispatch:e})=>NW(t,e),wEe=()=>({state:t,dispatch:e})=>DW(t,e),MEe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=bw(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},EEe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=bw(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},AEe=()=>({state:t,dispatch:e})=>VSe(t,e),TEe=()=>({state:t,dispatch:e})=>GSe(t,e);function Aq(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function CEe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,a;for(let o=0;o<e.length-1;o+=1){const l=e[o];if(/^(cmd|meta|m)$/i.test(l))a=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Zk()||Aq()?a=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),a&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var NEe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=CEe(t).split(/-(?!$)/),a=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),o=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,o))});return l?.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function nd(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,a=e?Zr(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(h,g)=>{if(h.isText)return;const m=Math.max(r,g),b=Math.min(i,g+h.nodeSize);o.push({node:h,from:m,to:b})});const l=i-r,c=o.filter(h=>a?a.name===h.node.type.name:!0).filter(h=>A1(h.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((h,g)=>h+g.to-g.from,0)>=l}var REe=(t,e={})=>({state:n,dispatch:r})=>{const i=Zr(t,n.schema);return nd(n,i,e)?XSe(n,r):!1},PEe=()=>({state:t,dispatch:e})=>jW(t,e),kEe=t=>({state:e,dispatch:n})=>{const r=Zr(t,e.schema);return awe(r)(e,n)},DEe=()=>({state:t,dispatch:e})=>LW(t,e);function Tw(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function m6(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 OEe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=Tw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=Zr(t,r.schema)),o==="mark"&&(a=Ac(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,h)=>{s&&s===u.type&&(l=!0,i&&n.setNodeMarkup(h,void 0,m6(u.attrs,e))),a&&u.marks.length&&u.marks.forEach(g=>{a===g.type&&(l=!0,i&&n.addMark(h,h+u.nodeSize,a.create(m6(g.attrs,e))))})})}),l},LEe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),IEe=()=>({tr:t,dispatch:e})=>{if(e){const n=new pa(t.doc);t.setSelection(n)}return!0},jEe=()=>({state:t,dispatch:e})=>PW(t,e),UEe=()=>({state:t,dispatch:e})=>OW(t,e),FEe=()=>({state:t,dispatch:e})=>QSe(t,e),zEe=()=>({state:t,dispatch:e})=>twe(t,e),BEe=()=>({state:t,dispatch:e})=>ewe(t,e);function cR(t,e,n={},r={}){return v0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var HEe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:a,commands:o})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const c=cR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return a&&s.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Tq(t,e){const n=Ac(e,t.schema),{from:r,to:i,empty:s}=t.selection,a=[];s?(t.storedMarks&&a.push(...t.storedMarks),a.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,l=>{a.push(...l.marks)});const o=a.find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Cq(t,e){const n=new EW(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function $Ee(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 VEe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function GEe(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 Cw(t){return e=>GEe(e.$from,t)}function Ut(t,e,n){return t.config[e]===void 0&&t.parent?Ut(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ut(t.parent,e,n):null}):t.config[e]}function Qk(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Ut(e,"addExtensions",n);return r?[e,...Qk(r())]:e}).flat(10)}function Jk(t,e){const n=Zf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Nq(t){return typeof t=="function"}function Ln(t,e=void 0,...n){return Nq(t)?e?t.bind(e)(...n):t(...n):t}function WEe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function dm(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 Rq(t){const e=[],{nodeExtensions:n,markExtensions:r}=dm(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(a=>{const o={name:a.name,options:a.options,storage:a.storage,extensions:i},l=Ut(a,"addGlobalAttributes",o);if(!l)return;l().forEach(u=>{u.types.forEach(h=>{Object.entries(u.attributes).forEach(([g,m])=>{e.push({type:h,name:g,attribute:{...s,...m}})})})})}),i.forEach(a=>{const o={name:a.name,options:a.options,storage:a.storage},l=Ut(a,"addAttributes",o);if(!l)return;const c=l();Object.entries(c).forEach(([u,h])=>{const g={...s,...h};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:a.name,name:u,attribute:g})})}),e}function Tr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const o=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],c=o.filter(u=>!l.includes(u));r[i]=[...l,...c].join(" ")}else if(i==="style"){const o=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[h,g]=u.split(":").map(m=>m.trim());c.set(h,g)}),o.forEach(u=>{const[h,g]=u.split(":").map(m=>m.trim());c.set(h,g)}),r[i]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[i]=s}),r},{})}function T1(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)=>Tr(n,r),{})}function qEe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function g6(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,a)=>{const o=a.attribute.parseHTML?a.attribute.parseHTML(n):qEe(n.getAttribute(a.name));return o==null?s:{...s,[a.name]:o}},{});return{...r,...i}}}}function x6(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&WEe(n)?!1:n!=null))}function v6(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function XEe(t,e){var n;const r=Rq(t),{nodeExtensions:i,markExtensions:s}=dm(t),a=(n=i.find(c=>Ut(c,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(c=>{const u=r.filter(x=>x.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((x,M)=>{const w=Ut(M,"extendNodeSchema",h);return{...x,...w?w(c):{}}},{}),m=x6({...g,content:Ln(Ut(c,"content",h)),marks:Ln(Ut(c,"marks",h)),group:Ln(Ut(c,"group",h)),inline:Ln(Ut(c,"inline",h)),atom:Ln(Ut(c,"atom",h)),selectable:Ln(Ut(c,"selectable",h)),draggable:Ln(Ut(c,"draggable",h)),code:Ln(Ut(c,"code",h)),whitespace:Ln(Ut(c,"whitespace",h)),linebreakReplacement:Ln(Ut(c,"linebreakReplacement",h)),defining:Ln(Ut(c,"defining",h)),isolating:Ln(Ut(c,"isolating",h)),attrs:Object.fromEntries(u.map(v6))}),b=Ln(Ut(c,"parseHTML",h));b&&(m.parseDOM=b.map(x=>g6(x,u)));const y=Ut(c,"renderHTML",h);y&&(m.toDOM=x=>y({node:x,HTMLAttributes:T1(x,u)}));const v=Ut(c,"renderText",h);return v&&(m.toText=v),[c.name,m]})),l=Object.fromEntries(s.map(c=>{const u=r.filter(v=>v.type===c.name),h={name:c.name,options:c.options,storage:c.storage,editor:e},g=t.reduce((v,x)=>{const M=Ut(x,"extendMarkSchema",h);return{...v,...M?M(c):{}}},{}),m=x6({...g,inclusive:Ln(Ut(c,"inclusive",h)),excludes:Ln(Ut(c,"excludes",h)),group:Ln(Ut(c,"group",h)),spanning:Ln(Ut(c,"spanning",h)),code:Ln(Ut(c,"code",h)),attrs:Object.fromEntries(u.map(v6))}),b=Ln(Ut(c,"parseHTML",h));b&&(m.parseDOM=b.map(v=>g6(v,u)));const y=Ut(c,"renderHTML",h);return y&&(m.toDOM=v=>y({mark:v,HTMLAttributes:T1(v,u)})),[c.name,m]}));return new cW({topNode:a,nodes:o,marks:l})}function KEe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function eD(t){return t.sort((n,r)=>{const i=Ut(n,"priority")||100,s=Ut(r,"priority")||100;return i>s?-1:i<s?1:0})}function Pq(t){const e=eD(Qk(t)),n=KEe(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 kq(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
- `,textSerializers:a={}}=n||{};let o="";return t.nodesBetween(r,i,(l,c,u,h)=>{var g;l.isBlock&&c>r&&(o+=s);const m=a?.[l.type.name];if(m)return u&&(o+=m({node:l,pos:c,parent:u,index:h,range:e})),!1;l.isText&&(o+=(g=l?.text)==null?void 0:g.slice(Math.max(r,c)-c,i-c))}),o}function YEe(t,e){const n={from:0,to:t.content.size};return kq(t,n,e)}function Dq(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function ZEe(t,e){const n=Zr(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,o=>{s.push(o)});const a=s.reverse().find(o=>o.type.name===n.name);return a?{...a.attrs}:{}}function Oq(t,e){const n=Tw(typeof e=="string"?e:e.name,t.schema);return n==="node"?ZEe(t,e):n==="mark"?Tq(t,e):{}}function QEe(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 JEe(t){const e=QEe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,a)=>a!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function Lq(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const a=[];if(i.ranges.length)i.forEach((o,l)=>{a.push({from:o,to:l})});else{const{from:o,to:l}=n[s];if(o===void 0||l===void 0)return;a.push({from:o,to:l})}a.forEach(({from:o,to:l})=>{const c=e.slice(s).map(o,-1),u=e.slice(s).map(l),h=e.invert().map(c,-1),g=e.invert().map(u);r.push({oldRange:{from:h,to:g},newRange:{from:c,to:u}})})}),JEe(r)}function tD(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),a=Yk(s,i.type);a&&r.push({mark:i,...a})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(a=>({from:s,to:s+i.nodeSize,mark:a})))}),r}var eAe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,a=null;for(;s>0&&a===null;){const o=i.node(s);o?.type.name===e?a=o:s-=1}return[a,s]};function T2(t,e){return e.nodes[t]||e.marks[t]||null}function I_(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var tAe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,a,o)=>{var l,c;const u=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:s,parent:a,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),n};function uR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Ac(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>A1(h.attrs,n,{strict:!1}));let a=0;const o=[];if(i.forEach(({$from:h,$to:g})=>{const m=h.pos,b=g.pos;t.doc.nodesBetween(m,b,(y,v)=>{if(!y.isText&&!y.marks.length)return;const x=Math.max(m,v),M=Math.min(b,v+y.nodeSize),w=M-x;a+=w,o.push(...y.marks.map(T=>({mark:T,from:x,to:M})))})}),a===0)return!1;const l=o.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>A1(h.mark.attrs,n,{strict:!1})).reduce((h,g)=>h+g.to-g.from,0),c=o.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,g)=>h+g.to-g.from,0);return(l>0?l+c:l)>=a}function nAe(t,e,n={}){if(!e)return nd(t,null,n)||uR(t,null,n);const r=Tw(e,t.schema);return r==="node"?nd(t,e,n):r==="mark"?uR(t,e,n):!1}var rAe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=Cw(o=>o.type.name===e)(t.selection);if(!s)return!1;const a=t.doc.resolve(s.pos+1);return i.pos+1===a.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},iAe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function b6(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function y6(t,e){const{nodeExtensions:n}=dm(e),r=n.find(a=>a.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=Ln(Ut(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Nw(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(s=>{i!==!1&&(Nw(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Iq(t){return t instanceof zt}function sAe(t,e,n){var r;const{selection:i}=e;let s=null;if(wq(i)&&(s=i.$cursor),s){const o=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(c=>c.type.excludes(n)))}const{ranges:a}=i;return a.some(({$from:o,$to:l})=>{let c=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(u,h,g)=>{if(c)return!1;if(u.isInline){const m=!g||g.type.allowsMarkType(n),b=!!n.isInSet(u.marks)||!u.marks.some(y=>y.type.excludes(n));c=m&&b}return!c}),c})}var aAe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:a,ranges:o}=s,l=Ac(t,r.schema);if(i)if(a){const c=Tq(r,l);n.addStoredMark(l.create({...c,...e}))}else o.forEach(c=>{const u=c.$from.pos,h=c.$to.pos;r.doc.nodesBetween(u,h,(g,m)=>{const b=Math.max(m,u),y=Math.min(m+g.nodeSize,h);g.marks.find(x=>x.type===l)?g.marks.forEach(x=>{l===x.type&&n.addMark(b,y,l.create({...x.attrs,...e}))}):n.addMark(b,y,l.create(e))})});return sAe(r,n,l)},oAe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),lAe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Zr(t,n.schema);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:o})=>OB(s,{...a,...e})(n)?!0:o.clearNodes()).command(({state:o})=>OB(s,{...a,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},cAe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=sf(t,0,r.content.size),s=zt.create(r,i);e.setSelection(s)}return!0},uAe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let a,o;return typeof e=="number"?(a=e,o=e):e&&"from"in e&&"to"in e?(a=e.from,o=e.to):(a=s.from,o=s.to),i&&n.doc.nodesBetween(a,o,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},dAe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,a=Wt.atStart(r).from,o=Wt.atEnd(r).to,l=sf(i,a,o),c=sf(s,a,o),u=Wt.create(r,l,c);e.setSelection(u)}return!0},fAe=t=>({state:e,dispatch:n})=>{const r=Zr(t,e.schema);return cwe(r)(e,n)};function _6(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 hAe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:a}=e,{$from:o,$to:l}=s,c=i.extensionManager.attributes,u=I_(c,o.node().type.name,o.node().attrs);if(s instanceof zt&&s.node.isBlock)return!o.parentOffset||!uc(a,o.pos)?!1:(r&&(t&&_6(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const h=l.parentOffset===l.parent.content.size,g=o.depth===0?void 0:$Ee(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=h&&g?[{type:g,attrs:u}]:void 0,b=uc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!b&&uc(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(b=!0,m=g?[{type:g,attrs:u}]:void 0),r){if(b&&(s instanceof Wt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!h&&!o.parentOffset&&o.parent.type!==g)){const y=e.mapping.map(o.before()),v=e.doc.resolve(y);o.node(-1).canReplaceWith(v.index(),v.index()+1,g)&&e.setNodeMarkup(e.mapping.map(o.before()),g)}t&&_6(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},pAe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var a;const o=Zr(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==o)return!1;const g=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let x=pt.empty;const M=l.index(-1)?1:l.index(-2)?2:3;for(let j=l.depth-M;j>=l.depth-3;j-=1)x=pt.from(l.node(j).copy(x));const w=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,T={...I_(g,l.node().type.name,l.node().attrs),...e},A=((a=o.contentMatch.defaultType)==null?void 0:a.createAndFill(T))||void 0;x=x.append(pt.from(o.createAndFill(null,A)||void 0));const P=l.before(l.depth-(M-1));n.replace(P,l.after(-w),new Mt(x,4-M,0));let C=-1;n.doc.nodesBetween(P,n.doc.content.size,(j,N)=>{if(C>-1)return!1;j.isTextblock&&j.content.size===0&&(C=N+1)}),C>-1&&n.setSelection(Wt.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const m=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,b={...I_(g,h.type.name,h.attrs),...e},y={...I_(g,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const v=m?[{type:o,attrs:b},{type:m,attrs:y}]:[{type:o,attrs:b}];if(!uc(n.doc,l.pos,2))return!1;if(i){const{selection:x,storedMarks:M}=r,{splittableMarks:w}=s.extensionManager,T=M||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,v).scrollIntoView(),!T||!i)return!0;const A=T.filter(P=>w.includes(P.type.name));n.ensureMarks(A)}return!0},C2=(t,e)=>{const n=Cw(a=>a.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&cd(t.doc,n.pos)&&t.join(n.pos),!0},N2=(t,e)=>{const n=Cw(a=>a.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&cd(t.doc,r)&&t.join(r),!0},mAe=(t,e,n,r={})=>({editor:i,tr:s,state:a,dispatch:o,chain:l,commands:c,can:u})=>{const{extensions:h,splittableMarks:g}=i.extensionManager,m=Zr(t,a.schema),b=Zr(e,a.schema),{selection:y,storedMarks:v}=a,{$from:x,$to:M}=y,w=x.blockRange(M),T=v||y.$to.parentOffset&&y.$from.marks();if(!w)return!1;const A=Cw(P=>y6(P.type.name,h))(y);if(w.depth>=1&&A&&w.depth-A.depth<=1){if(A.node.type===m)return c.liftListItem(b);if(y6(A.node.type.name,h)&&m.validContent(A.node.content)&&o)return l().command(()=>(s.setNodeMarkup(A.pos,m),!0)).command(()=>C2(s,m)).command(()=>N2(s,m)).run()}return!n||!T||!o?l().command(()=>u().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>C2(s,m)).command(()=>N2(s,m)).run():l().command(()=>{const P=u().wrapInList(m,r),C=T.filter(j=>g.includes(j.type.name));return s.ensureMarks(C),P?!0:c.clearNodes()}).wrapInList(m,r).command(()=>C2(s,m)).command(()=>N2(s,m)).run()},gAe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,a=Ac(t,r.schema);return uR(r,a,e)?i.unsetMark(a,{extendEmptyMarkRange:s}):i.setMark(a,e)},xAe=(t,e,n={})=>({state:r,commands:i})=>{const s=Zr(t,r.schema),a=Zr(e,r.schema),o=nd(r,s,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),o?i.setNode(a,l):i.setNode(s,{...l,...n})},vAe=(t,e={})=>({state:n,commands:r})=>{const i=Zr(t,n.schema);return nd(n,i,e)?r.lift(i):r.wrapIn(i,e)},bAe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const a=t.tr,o=s.transform;for(let l=o.steps.length-1;l>=0;l-=1)a.step(o.steps[l].invert(o.docs[l]));if(s.text){const l=a.doc.resolve(s.from).marks();a.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else a.delete(s.from,s.to)}return!0}}return!1},yAe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},_Ae=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:a=!1}=e,{selection:o}=n,l=Ac(t,r.schema),{$from:c,empty:u,ranges:h}=o;if(!i)return!0;if(u&&a){let{from:g,to:m}=o;const b=(s=c.marks().find(v=>v.type===l))==null?void 0:s.attrs,y=Yk(c,l,b);y&&(g=y.from,m=y.to),n.removeMark(g,m,l)}else h.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,l)});return n.removeStoredMark(l),!0},SAe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,a;return typeof t=="number"?(s=t,a=t):t&&"from"in t&&"to"in t?(s=t.from,a=t.to):(s=i.from,a=i.to),r&&e.doc.nodesBetween(s,a,(o,l)=>{if(o.isText)return;const c={...o.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},wAe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=Tw(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=Zr(t,r.schema)),o==="mark"&&(a=Ac(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,h=c.$to.pos;let g,m,b,y;n.selection.empty?r.doc.nodesBetween(u,h,(v,x)=>{s&&s===v.type&&(l=!0,b=Math.max(x,u),y=Math.min(x+v.nodeSize,h),g=x,m=v)}):r.doc.nodesBetween(u,h,(v,x)=>{x<u&&s&&s===v.type&&(l=!0,b=Math.max(x,u),y=Math.min(x+v.nodeSize,h),g=x,m=v),x>=u&&x<=h&&(s&&s===v.type&&(l=!0,i&&n.setNodeMarkup(x,void 0,{...v.attrs,...e})),a&&v.marks.length&&v.marks.forEach(M=>{if(a===M.type&&(l=!0,i)){const w=Math.max(x,u),T=Math.min(x+v.nodeSize,h);n.addMark(w,T,a.create({...M.attrs,...e}))}}))}),m&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),a&&m.marks.length&&m.marks.forEach(v=>{a===v.type&&i&&n.addMark(b,y,a.create({...v.attrs,...e}))}))}),l},MAe=(t,e={})=>({state:n,dispatch:r})=>{const i=Zr(t,n.schema);return nwe(i,e)(n,r)},EAe=(t,e={})=>({state:n,dispatch:r})=>{const i=Zr(t,n.schema);return rwe(i,e)(n,r)},AAe=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}once(e,n){const r=(...i)=>{this.off(e,r),n.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}},Rw=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},TAe=(t,e)=>{if(Kk(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 Wy(t){var e;const{editor:n,from:r,to:i,text:s,rules:a,plugin:o}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let u=!1;const h=tAe(c)+s;return a.forEach(g=>{if(u)return;const m=TAe(h,g.find);if(!m)return;const b=l.state.tr,y=Ew({state:l.state,transaction:b}),v={from:r-(m[0].length-s.length),to:i},{commands:x,chain:M,can:w}=new Aw({editor:n,state:y});g.handler({state:y,range:v,match:m,commands:x,chain:M,can:w})===null||!b.steps.length||(g.undoable&&b.setMeta(o,{transform:b,from:r,to:i,text:s}),l.dispatch(b),u=!0)}),u}function CAe(t){const{editor:e,rules:n}=t,r=new vr({state:{init(){return null},apply(i,s,a){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Jk(pt.from(u),a.schema);const{from:h}=l,g=h+u.length;Wy({editor:e,from:h,to:g,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,a,o){return Wy({editor:e,from:s,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Wy({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:a}=i.state.selection;return a?Wy({editor:e,from:a.pos,to:a.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function NAe(t){return Object.prototype.toString.call(t).slice(8,-1)}function qy(t){return NAe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function jq(t,e){const n={...t};return qy(t)&&qy(e)&&Object.keys(e).forEach(r=>{qy(e[r])&&qy(t[r])?n[r]=jq(t[r],e[r]):n[r]=e[r]}),n}var nD=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Ln(Ut(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ln(Ut(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>jq(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},dd=class Uq extends nD{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Uq(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const a=i.marks();if(!!!a.find(c=>c?.type.name===n.name))return!1;const l=a.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function RAe(t){return typeof t=="number"}var PAe=class{constructor(t){this.find=t.find,this.handler=t.handler}},kAe=(t,e,n)=>{if(Kk(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function DAe(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:a,dropEvent:o}=t,{commands:l,chain:c,can:u}=new Aw({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(m,b)=>{var y,v,x,M,w;if((v=(y=m.type)==null?void 0:y.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const T=(w=(M=(x=m.content)==null?void 0:x.size)!=null?M:m.nodeSize)!=null?w:0,A=Math.max(r,b),P=Math.min(i,b+T);if(A>=P)return;const C=m.isText?m.text||"":m.textBetween(A-b,P-b,void 0,"");kAe(C,s.find,a).forEach(N=>{if(N.index===void 0)return;const k=A+N.index+1,F=k+N[0].length,I={from:n.tr.mapping.map(k),to:n.tr.mapping.map(F)},W=s.handler({state:n,range:I,match:N,commands:l,chain:c,can:u,pasteEvent:a,dropEvent:o});h.push(W)})}),h.every(m=>m!==null)}var Xy=null,OAe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function LAe(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:u,from:h,to:g,rule:m,pasteEvt:b})=>{const y=u.tr,v=Ew({state:u,transaction:y});if(!(!DAe({editor:e,state:v,from:Math.max(h-1,0),to:g.b-1,rule:m,pasteEvent:b,dropEvent:o})||!y.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(u=>new vr({view(h){const g=b=>{var y;r=(y=h.dom.parentElement)!=null&&y.contains(b.target)?h.dom.parentElement:null,r&&(Xy=e)},m=()=>{Xy&&(Xy=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(h,g)=>{if(s=r===h.dom.parentElement,o=g,!s){const m=Xy;m?.isEditable&&setTimeout(()=>{const b=m.state.selection;b&&m.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(h,g)=>{var m;const b=(m=g.clipboardData)==null?void 0:m.getData("text/html");return a=g,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(h,g,m)=>{const b=h[0],y=b.getMeta("uiEvent")==="paste"&&!i,v=b.getMeta("uiEvent")==="drop"&&!s,x=b.getMeta("applyPasteRules"),M=!!x;if(!y&&!v&&!M)return;if(M){let{text:A}=x;typeof A=="string"?A=A:A=Jk(pt.from(A),m.schema);const{from:P}=x,C=P+A.length,j=OAe(A);return l({rule:u,state:m,from:P,to:{b:C},pasteEvt:j})}const w=g.doc.content.findDiffStart(m.doc.content),T=g.doc.content.findDiffEnd(m.doc.content);if(!(!RAe(w)||!T||w===T.b))return l({rule:u,state:m,from:w,to:T,pasteEvt:a})}}))}var Pw=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Pq(t),this.schema=XEe(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:T2(e.name,this.schema)},r=Ut(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return eD([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:T2(r.name,this.schema)},s=[],a=Ut(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Ut(r,"exitable",i)&&(o.ArrowRight=()=>dd.handleExit({editor:t,mark:r})),a){const g=Object.fromEntries(Object.entries(a()).map(([m,b])=>[m,()=>b({editor:t})]));o={...o,...g}}const l=ZMe(o);s.push(l);const c=Ut(r,"addInputRules",i);if(b6(r,t.options.enableInputRules)&&c){const g=c();if(g&&g.length){const m=CAe({editor:t,rules:g}),b=Array.isArray(m)?m:[m];s.push(...b)}}const u=Ut(r,"addPasteRules",i);if(b6(r,t.options.enablePasteRules)&&u){const g=u();if(g&&g.length){const m=LAe({editor:t,rules:g});s.push(...m)}}const h=Ut(r,"addProseMirrorPlugins",i);if(h){const g=h();s.push(...g)}return s})}get attributes(){return Rq(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=dm(this.extensions);return Object.fromEntries(e.filter(n=>!!Ut(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Zr(n.name,this.schema)},s=Ut(n,"addNodeView",i);if(!s)return[];const a=s();if(!a)return[];const o=(l,c,u,h,g)=>{const m=T1(l,r);return a({node:l,view:c,getPos:u,decorations:h,innerDecorations:g,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=dm(this.extensions);return Object.fromEntries(e.filter(n=>!!Ut(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ac(n.name,this.schema)},s=Ut(n,"addMarkView",i);if(!s)return[];const a=(o,l,c)=>{const u=T1(o,r);return s()({mark:o,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:h=>{YAe(o,t,h)}})};return[n.name,a]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:T2(e.name,this.schema)};e.type==="mark"&&((n=Ln(Ut(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Ut(e,"onBeforeCreate",r),s=Ut(e,"onCreate",r),a=Ut(e,"onUpdate",r),o=Ut(e,"onSelectionUpdate",r),l=Ut(e,"onTransaction",r),c=Ut(e,"onFocus",r),u=Ut(e,"onBlur",r),h=Ut(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),a&&this.editor.on("update",a),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}};Pw.resolve=Pq;Pw.sort=eD;Pw.flatten=Qk;var IAe={};Xk(IAe,{ClipboardTextSerializer:()=>zq,Commands:()=>Bq,Delete:()=>Hq,Drop:()=>$q,Editable:()=>Vq,FocusEvents:()=>Wq,Keymap:()=>qq,Paste:()=>Xq,Tabindex:()=>Kq,TextDirection:()=>Yq,focusEventsPluginKey:()=>Gq});var Wn=class Fq extends nD{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Fq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},zq=Wn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new vr({key:new di("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,a=Math.min(...s.map(u=>u.$from.pos)),o=Math.max(...s.map(u=>u.$to.pos)),l=Dq(n);return kq(r,{from:a,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Bq=Wn.create({name:"commands",addCommands(){return{..._q}}}),Hq=Wn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var a,o,l,c;if((c=(l=(o=(a=this.editor.options.coreExtensionOptions)==null?void 0:a.delete)==null?void 0:o.filterTransaction)==null?void 0:l.call(o,t))!=null?c:t.getMeta("y-sync$"))return;const u=Cq(t.before,[t,...e]);Lq(u).forEach(m=>{u.mapping.mapResult(m.oldRange.from).deletedAfter&&u.mapping.mapResult(m.oldRange.to).deletedBefore&&u.before.nodesBetween(m.oldRange.from,m.oldRange.to,(b,y)=>{const v=y+b.nodeSize-2,x=m.oldRange.from<=y&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:y,to:v,newFrom:u.mapping.map(y),newTo:u.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:u})})});const g=u.mapping;u.steps.forEach((m,b)=>{var y,v;if(m instanceof _o){const x=g.slice(b).map(m.from,-1),M=g.slice(b).map(m.to),w=g.invert().map(x,-1),T=g.invert().map(M),A=(y=u.doc.nodeAt(x-1))==null?void 0:y.marks.some(C=>C.eq(m.mark)),P=(v=u.doc.nodeAt(M))==null?void 0:v.marks.some(C=>C.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:w,to:T},newRange:{from:x,to:M},partial:!!(P||A),editor:this.editor,transaction:t,combinedTransform:u})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),$q=Wn.create({name:"drop",addProseMirrorPlugins(){return[new vr({key:new di("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Vq=Wn.create({name:"editable",addProseMirrorPlugins(){return[new vr({key:new di("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Gq=new di("focusEvents"),Wq=Wn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new vr({key:Gq,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),qq=Wn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:o})=>{const{selection:l,doc:c}=o,{empty:u,$anchor:h}=l,{pos:g,parent:m}=h,b=h.parent.isTextblock&&g>0?o.doc.resolve(g-1):h,y=b.parent.type.spec.isolating,v=h.pos-h.parentOffset,x=y&&b.parent.childCount===1?v===h.pos:ln.atStart(c).from===g;return!u||!m.type.isTextblock||m.textContent.length||!x||x&&h.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Zk()||Aq()?s:i},addProseMirrorPlugins(){return[new vr({key:new di("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:a,to:o}=e.selection,l=ln.atStart(e.doc).from,c=ln.atEnd(e.doc).to;if(s||!(a===l&&o===c)||!Nw(n.doc))return;const g=n.tr,m=Ew({state:n,transaction:g}),{commands:b}=new Aw({editor:this.editor,state:m});if(b.clearNodes(),!!g.steps.length)return g}})]}}),Xq=Wn.create({name:"paste",addProseMirrorPlugins(){return[new vr({key:new di("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Kq=Wn.create({name:"tabindex",addProseMirrorPlugins(){return[new vr({key:new di("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Yq=Wn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=dm(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 vr({key:new di("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),jAe=class wp{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 wp(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 wp(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 wp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(a);if(!i&&o.depth<=this.depth)return;const l=new wp(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new wp(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,a=Object.keys(n);for(let o=0;o<a.length;o+=1){const l=a[o];if(s[l]!==n[l])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(a=>{r&&i.length>0||(a.node.type.name===e&&s.every(l=>n[l]===a.node.attrs[l])&&i.push(a),!(r&&i.length>0)&&(i=i.concat(a.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},UAe=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function FAe(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 zAe=class extends AAe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Mq(e,this.options.autofocus);this.editorState=Cp.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=FAe(UAe,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=Nq(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(a=>!a.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Vq,zq.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Bq,Wq,qq,Kq,$q,Xq,Hq,Yq.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 Pw(r,this)}createCommandManager(){this.commandManager=new Aw({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 bq(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const a=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),o=a?.getMeta("focus"),l=a?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:a}),l&&this.emit("blur",{editor:this,event:l.event,transaction:a}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Oq(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return nAe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Jk(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return YEe(this.state.doc,{blockSeparator:e,textSerializers:{...Dq(this.schema),...n}})}get isEmpty(){return Nw(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 jAe(e,this)}get $doc(){return this.$pos(0)}};function fm(t){return new Rw({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ln(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,a=r[r.length-1],o=r[0];if(a){const l=o.search(/\S/),c=n.from+o.indexOf(a),u=c+a.length;if(tD(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>c).length)return null;u<n.to&&s.delete(u,n.to),c>n.from&&s.delete(n.from+l,c);const g=n.from+l+a.length;s.addMark(n.from+l,g,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Zq(t){return new Rw({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Ln(t.getAttributes,void 0,r)||{},{tr:s}=e,a=n.from;let o=n.to;const l=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=a+c;u>o?u=o:o=u+r[1].length;const h=r[0][r[0].length-1];s.insertText(h,a+r[0].length-1),s.replaceWith(u,o,l)}else if(r[0]){const c=t.type.isInline?a:a-1;s.insert(c,t.type.create(i)).delete(s.mapping.map(a),s.mapping.map(o))}s.scrollIntoView()},undoable:t.undoable})}function dR(t){return new Rw({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=Ln(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function hm(t){return new Rw({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Ln(t.getAttributes,void 0,r)||{},a=e.tr.delete(n.from,n.to),l=a.doc.resolve(n.from).blockRange(),c=l&&kk(l,t.type,s);if(!c)return null;if(a.wrap(l,c),t.keepMarks&&t.editor){const{selection:h,storedMarks:g}=e,{splittableMarks:m}=t.editor.extensionManager,b=g||h.$to.parentOffset&&h.$from.marks();if(b){const y=b.filter(v=>m.includes(v.type.name));a.ensureMarks(y)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,s).run()}const u=a.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&cd(a.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&a.join(n.from-1)},undoable:t.undoable})}var BAe=t=>"touches"in t,HAe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=a=>{if(!this.isResizing||!this.activeHandle)return;const o=a.clientX-this.startX,l=a.clientY-this.startY;this.handleResize(o,l)},this.handleTouchMove=a=>{if(!this.isResizing||!this.activeHandle)return;const o=a.touches[0];if(!o)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;const a=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(a,o),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=a=>{a.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(s=t.options)!=null&&s.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,BAe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),a=t.includes("left"),o=t.includes("bottom"),l=t.includes("top");return s?r=this.startWidth+e:a&&(r=this.startWidth-e),o?i=this.startHeight+n:l&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,a;if(!n){let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let o=t,l=e;return o<this.minSize.width&&(o=this.minSize.width,l=o/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,o=l*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&o>this.maxSize.width&&(o=this.maxSize.width,l=o/this.aspectRatio),(a=this.maxSize)!=null&&a.height&&l>this.maxSize.height&&(l=this.maxSize.height,o=l*this.aspectRatio),{width:o,height:l}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function $Ae(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof zt){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var VAe={};Xk(VAe,{createAtomBlockMarkdownSpec:()=>GAe,createBlockMarkdownSpec:()=>WAe,createInlineMarkdownSpec:()=>KAe,parseAttributes:()=>rD,parseIndentedBlocks:()=>fR,renderNestedMarkdownContent:()=>sD,serializeAttributes:()=>iD});function rD(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(u=>u.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const a=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(a)).forEach(([,c,u])=>{var h;const g=parseInt(((h=u.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),m=n[g];m&&(e[c]=m.slice(1,-1))});const l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function iD(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 GAe(t){const{nodeName:e,name:n,parseAttributes:r=rD,serializeAttributes:i=iD,defaultAttributes:s={},requiredAttributes:a=[],allowedAttributes:o}=t,l=n||e,c=u=>{if(!o)return u;const h={};return o.forEach(g=>{g in u&&(h[g]=u[g])}),h};return{parseMarkdown:(u,h)=>{const g={...s,...u.attributes};return h.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(u){var h;const g=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(h=u.match(g))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(u,h,g){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=u.match(m);if(!b)return;const y=b[1]||"",v=r(y);if(!a.find(M=>!(M in v)))return{type:e,raw:b[0],attributes:v}}},renderMarkdown:u=>{const h=c(u.attrs||{}),g=i(h),m=g?` {${g}}`:"";return`:::${l}${m} :::`}}}function WAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=rD,serializeAttributes:s=iD,defaultAttributes:a={},content:o="block",allowedAttributes:l}=t,c=n||e,u=h=>{if(!l)return h;const g={};return l.forEach(m=>{m in h&&(g[m]=h[m])}),g};return{parseMarkdown:(h,g)=>{let m;if(r){const y=r(h);m=typeof y=="string"?[{type:"text",text:y}]:y}else o==="block"?m=g.parseChildren(h.tokens||[]):m=g.parseInline(h.tokens||[]);const b={...a,...h.attributes};return g.createNode(e,b,m)},markdownTokenizer:{name:e,level:"block",start(h){var g;const m=new RegExp(`^:::${c}`,"m"),b=(g=h.match(m))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(h,g,m){var b;const y=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=h.match(y);if(!v)return;const[x,M=""]=v,w=i(M);let T=1;const A=x.length;let P="";const C=/^:::([\w-]*)(\s.*)?/gm,j=h.slice(A);for(C.lastIndex=0;;){const N=C.exec(j);if(N===null)break;const k=N.index,F=N[1];if(!((b=N[2])!=null&&b.endsWith(":::"))){if(F)T+=1;else if(T-=1,T===0){const I=j.slice(0,k);P=I.trim();const W=h.slice(0,A+k+N[0].length);let D=[];if(P)if(o==="block")for(D=m.blockTokens(I),D.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=m.inlineTokens($.text))});D.length>0;){const $=D[D.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))D.pop();else break}else D=m.inlineTokens(P);return{type:e,raw:W,attributes:w,content:P,tokens:D}}}}}},renderMarkdown:(h,g)=>{const m=u(h.attrs||{}),b=s(m),y=b?` {${b}}`:"",v=g.renderChildren(h.content||[],`
- `);return`:::${c}${y}
- ${v}
- :::`}}}function qAe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,a]=r;e[i]=s||a,r=n.exec(t)}return e}function XAe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function KAe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=qAe,serializeAttributes:s=XAe,defaultAttributes:a={},selfClosing:o=!1,allowedAttributes:l}=t,c=n||e,u=g=>{if(!l)return g;const m={};return l.forEach(b=>{b in g&&(m[b]=g[b])}),m},h=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,m)=>{const b={...a,...g.attributes};if(o)return m.createNode(e,b);const y=r?r(g):g.content||"";return y?m.createNode(e,b,[m.createTextNode(y)]):m.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const m=o?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),b=g.match(m),y=b?.index;return y!==void 0?y:-1},tokenize(g,m,b){const y=o?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),v=g.match(y);if(!v)return;let x="",M="";if(o){const[,T]=v;M=T}else{const[,T,A]=v;M=T,x=A||""}const w=i(M.trim());return{type:e,raw:v[0],content:x.trim(),attributes:w}}},renderMarkdown:g=>{let m="";r?m=r(g):g.content&&g.content.length>0&&(m=g.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const b=u(g.attrs||{}),y=s(b),v=y?` ${y}`:"";return o?`[${c}${v}]`:`[${c}${v}]${m}[/${c}]`}}}function fR(t,e,n){var r,i,s,a;const o=t.split(`
- `),l=[];let c="",u=0;const h=e.baseIndentSize||2;for(;u<o.length;){const g=o[u],m=g.match(e.itemPattern);if(!m){if(l.length>0)break;if(g.trim()===""){u+=1,c=`${c}${g}
- `;continue}else return}const b=e.extractItemData(m),{indentLevel:y,mainContent:v}=b;c=`${c}${g}
- `;const x=[v];for(u+=1;u<o.length;){const A=o[u];if(A.trim()===""){const C=o.slice(u+1).findIndex(k=>k.trim()!=="");if(C===-1)break;if((((i=(r=o[u+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){x.push(A),c=`${c}${A}
- `,u+=1;continue}else break}if((((a=(s=A.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:a.length)||0)>y)x.push(A),c=`${c}${A}
- `,u+=1;else break}let M;const w=x.slice(1);if(w.length>0){const A=w.map(P=>P.slice(y+h)).join(`
- `);A.trim()&&(e.customNestedParser?M=e.customNestedParser(A):M=n.blockTokens(A))}const T=e.createToken(b,M);l.push(T)}if(l.length!==0)return{items:l,raw:c}}function sD(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...a]=t.content,o=e.renderChildren([s]),l=[`${i}${o}`];return a&&a.length>0&&a.forEach(c=>{const u=e.renderChildren([c]);if(u){const h=u.split(`
- `).map(g=>g?e.indent(g):"").join(`
- `);l.push(h)}}),l.join(`
- `)}function YAe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,a=t;i.descendants((o,l)=>{const c=s.mapping.map(l),u=s.mapping.map(l)+o.nodeSize;let h=null;if(o.marks.forEach(m=>{if(m!==a)return!1;h=m}),!h)return;let g=!1;if(Object.keys(n).forEach(m=>{n[m]!==h.attrs[m]&&(g=!0)}),g){const m=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,m)}}),s.docChanged&&e.view.dispatch(s)}var Ws=class Qq extends nD{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Qq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function zf(t){return new PAe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Ln(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];let c=n.to;if(o){const u=l.search(/\S/),h=n.from+l.indexOf(o),g=h+o.length;if(tD(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(v=>v===t.type&&v!==b.mark.type)).filter(b=>b.to>h).length)return null;g<n.to&&a.delete(g,n.to),h>n.from&&a.delete(n.from+u,h),c=n.from+u+o.length,a.addMark(n.from+u,c,t.type.create(s||{})),a.removeStoredMark(t.type)}}})}var R2,S6;function ZAe(){return S6||(S6=1,R2=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var a=s[i];if(!(a==="_owner"&&e.$$typeof)&&!t(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}),R2}var QAe=ZAe();const JAe=Ja(QAe);var P2={exports:{}},k2={};var w6;function eTe(){if(w6)return k2;w6=1;var t=Mm(),e=NG();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return k2.useSyncExternalStoreWithSelector=function(c,u,h,g,m){var b=s(null);if(b.current===null){var y={hasValue:!1,value:null};b.current=y}else y=b.current;b=o(function(){function x(P){if(!M){if(M=!0,w=P,P=g(P),m!==void 0&&y.hasValue){var C=y.value;if(m(C,P))return T=C}return T=P}if(C=T,r(w,P))return C;var j=g(P);return m!==void 0&&m(C,j)?(w=P,C):(w=P,T=j)}var M=!1,w,T,A=h===void 0?null:h;return[function(){return x(u())},A===null?void 0:function(){return x(A())}]},[u,h,g,m]);var v=i(c,b[0],b[1]);return a(function(){y.hasValue=!0,y.value=v},[v]),l(v),v},k2}var M6;function tTe(){return M6||(M6=1,P2.exports=eTe()),P2.exports}var Jq=tTe(),nTe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},rTe=({contentComponent:t})=>{const e=LP.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return f.jsx(f.Fragment,{children:Object.values(e)})};function iTe(){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]:ise.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 sTe=class extends ur.Component{constructor(t){var e;super(t),this.editorContentRef=ur.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=iTe(),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 f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:nTe(e,this.editorContentRef),...n}),t?.contentComponent&&f.jsx(rTe,{contentComponent:t.contentComponent})]})}},aTe=E.forwardRef((t,e)=>{const n=ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ur.createElement(sTe,{key:n,innerRef:e,...t})}),oTe=ur.memo(aTe),lTe=typeof window<"u"?E.useLayoutEffect:E.useEffect,cTe=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 uTe(t){var e;const[n]=E.useState(()=>new cTe(t.editor)),r=Jq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:JAe);return lTe(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var dTe=!1,hR=typeof window>"u",fTe=hR||!!(typeof window<"u"&&window.next),hTe=class eX{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?hR||fTe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new zAe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,s)=>{var a;return i===((a=n.extensions)==null?void 0:a[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?eX.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 pTe(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new hTe(n)),i=LP.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),uTe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var mTe=E.createContext({editor:null});mTe.Consumer;var gTe=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),xTe=()=>E.useContext(gTe);ur.forwardRef((t,e)=>{const{onDragStart:n}=xTe(),r=t.as||"div";return f.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ur.createContext({markViewContentRef:()=>{}});var C1=(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]},vTe=/^\s*>\s$/,bTe=Ws.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return C1("blockquote",{...Tr(this.options.HTMLAttributes,t),children:C1("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(`
- `).map(l=>l.trim()===""?n:`${n} ${l}`);r.push(o.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[hm({find:vTe,type:this.type})]}}),yTe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,_Te=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,STe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,wTe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,MTe=dd.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return C1("strong",{...Tr(this.options.HTMLAttributes,t),children:C1("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[fm({find:yTe,type:this.type}),fm({find:STe,type:this.type})]},addPasteRules(){return[zf({find:_Te,type:this.type}),zf({find:wTe,type:this.type})]}}),ETe=/(^|[^`])`([^`]+)`(?!`)$/,ATe=/(^|[^`])`([^`]+)`(?!`)/g,TTe=dd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Tr(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[fm({find:ETe,type:this.type})]},addPasteRules(){return[zf({find:ATe,type:this.type})]}}),D2=4,CTe=/^```([a-z]+)?[\s\n]$/,NTe=/^~~~([a-z]+)?[\s\n]$/,RTe=Ws.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:D2,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(a=>a.startsWith(n)).map(a=>a.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Tr(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:D2,{state:r}=t,{selection:i}=r,{$from:s,empty:a}=i;if(s.parent.type!==this.type)return!1;const o=" ".repeat(n);return a?t.commands.insertContent(o):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,m=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(b=>o+b).join(`
- `);return l.replaceWith(c,u,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:D2,{state:r}=t,{selection:i}=r,{$from:s,empty:a}=i;return s.parent.type!==this.type?!1:a?t.commands.command(({tr:o})=>{var l;const{pos:c}=s,u=s.start(),h=s.end(),m=r.doc.textBetween(u,h,`
- `,`
- `).split(`
- `);let b=0,y=0;const v=c-u;for(let P=0;P<m.length;P+=1){if(y+m[P].length>=v){b=P;break}y+=m[P].length+1}const M=((l=m[b].match(/^ */))==null?void 0:l[0])||"",w=Math.min(M.length,n);if(w===0)return!0;let T=u;for(let P=0;P<b;P+=1)T+=m[P].length+1;return o.delete(T,T+w),c-T<=w&&o.setSelection(Wt.create(o.doc,T)),!0}):t.commands.command(({tr:o})=>{const{from:l,to:c}=i,g=r.doc.textBetween(l,c,`
- `,`
- `).split(`
- `).map(m=>{var b;const y=((b=m.match(/^ */))==null?void 0:b[0])||"",v=Math.min(y.length,n);return m.slice(v)}).join(`
- `);return o.replaceWith(l,c,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
- `);return!s||!a?!1:t.chain().command(({tr:o})=>(o.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const o=i.after();return o===void 0?!1:r.nodeAt(o)?t.commands.command(({tr:c})=>(c.setSelection(ln.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[dR({find:CTe,type:this.type,getAttributes:t=>({language:t[1]})}),dR({find:NTe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new vr({key:new di("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!n||!s)return!1;const{tr:a,schema:o}=t.state,l=o.text(n.replace(/\r\n?/g,`
- `));return a.replaceSelectionWith(this.type.create({language:s},l)),a.selection.$from.parent.type!==this.type&&a.setSelection(Wt.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),PTe=Ws.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),kTe=Ws.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",Tr(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&a){const h=l.filter(g=>o.includes(g.type.name));c.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),DTe=Ws.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]}`,Tr(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}}))}}),OTe=Ws.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Tr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!$Ae(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Iq(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:a,dispatch:o})=>{if(o){const{$to:l}=a.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?a.setSelection(Wt.create(a.doc,l.pos+1)):l.nodeAfter.isBlock?a.setSelection(zt.create(a.doc,l.pos)):a.setSelection(Wt.create(a.doc,l.pos));else{const u=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,h=u?.create();h&&(a.insert(c,h),a.setSelection(Wt.create(a.doc,c+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Zq({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),LTe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ITe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,jTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,UTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,FTe=dd.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Tr(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[fm({find:LTe,type:this.type}),fm({find:jTe,type:this.type})]},addPasteRules(){return[zf({find:ITe,type:this.type}),zf({find:UTe,type:this.type})]}});const zTe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",BTe="ελ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",pR="numeric",mR="ascii",gR="alpha",Ix="asciinumeric",bx="alphanumeric",xR="domain",tX="emoji",HTe="scheme",$Te="slashscheme",O2="whitespace";function VTe(t,e){return t in e||(e[t]=[]),e[t]}function af(t,e,n){e[pR]&&(e[Ix]=!0,e[bx]=!0),e[mR]&&(e[Ix]=!0,e[gR]=!0),e[Ix]&&(e[bx]=!0),e[gR]&&(e[bx]=!0),e[bx]&&(e[xR]=!0),e[tX]&&(e[xR]=!0);for(const r in e){const i=VTe(r,n);i.indexOf(t)<0&&i.push(t)}}function GTe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Us(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Us.groups={};Us.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Us.groups;let i;return e&&e.j?i=e:(i=new Us(e),n&&r&&af(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let a=0;a<s-1;a++)i=i.tt(t[a]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Us.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let a,o=i.go(t);if(o?(a=new Us,Object.assign(a.j,o.j),a.jr.push.apply(a.jr,o.jr),a.jd=o.jd,a.t=o.t):a=new Us,s){if(r)if(a.t&&typeof a.t=="string"){const l=Object.assign(GTe(a.t,r),n);af(s,l,r)}else n&&af(s,n,r);a.t=s}return i.j[t]=a,a}};const rn=(t,e,n,r,i)=>t.ta(e,n,r,i),wr=(t,e,n,r,i)=>t.tr(e,n,r,i),E6=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),ql="WORD",vR="UWORD",nX="ASCIINUMERICAL",rX="ALPHANUMERICAL",b0="LOCALHOST",bR="TLD",yR="UTLD",j_="SCHEME",Mp="SLASH_SCHEME",aD="NUM",_R="WS",oD="NL",jx="OPENBRACE",Ux="CLOSEBRACE",N1="OPENBRACKET",R1="CLOSEBRACKET",P1="OPENPAREN",k1="CLOSEPAREN",D1="OPENANGLEBRACKET",O1="CLOSEANGLEBRACKET",L1="FULLWIDTHLEFTPAREN",I1="FULLWIDTHRIGHTPAREN",j1="LEFTCORNERBRACKET",U1="RIGHTCORNERBRACKET",F1="LEFTWHITECORNERBRACKET",z1="RIGHTWHITECORNERBRACKET",B1="FULLWIDTHLESSTHAN",H1="FULLWIDTHGREATERTHAN",$1="AMPERSAND",V1="APOSTROPHE",G1="ASTERISK",Su="AT",W1="BACKSLASH",q1="BACKTICK",X1="CARET",Nu="COLON",lD="COMMA",K1="DOLLAR",Bo="DOT",Y1="EQUALS",cD="EXCLAMATION",ka="HYPHEN",Fx="PERCENT",Z1="PIPE",Q1="PLUS",J1="POUND",zx="QUERY",uD="QUOTE",iX="FULLWIDTHMIDDLEDOT",dD="SEMI",Ho="SLASH",Bx="TILDE",eS="UNDERSCORE",sX="EMOJI",tS="SYM";var aX=Object.freeze({__proto__:null,ALPHANUMERICAL:rX,AMPERSAND:$1,APOSTROPHE:V1,ASCIINUMERICAL:nX,ASTERISK:G1,AT:Su,BACKSLASH:W1,BACKTICK:q1,CARET:X1,CLOSEANGLEBRACKET:O1,CLOSEBRACE:Ux,CLOSEBRACKET:R1,CLOSEPAREN:k1,COLON:Nu,COMMA:lD,DOLLAR:K1,DOT:Bo,EMOJI:sX,EQUALS:Y1,EXCLAMATION:cD,FULLWIDTHGREATERTHAN:H1,FULLWIDTHLEFTPAREN:L1,FULLWIDTHLESSTHAN:B1,FULLWIDTHMIDDLEDOT:iX,FULLWIDTHRIGHTPAREN:I1,HYPHEN:ka,LEFTCORNERBRACKET:j1,LEFTWHITECORNERBRACKET:F1,LOCALHOST:b0,NL:oD,NUM:aD,OPENANGLEBRACKET:D1,OPENBRACE:jx,OPENBRACKET:N1,OPENPAREN:P1,PERCENT:Fx,PIPE:Z1,PLUS:Q1,POUND:J1,QUERY:zx,QUOTE:uD,RIGHTCORNERBRACKET:U1,RIGHTWHITECORNERBRACKET:z1,SCHEME:j_,SEMI:dD,SLASH:Ho,SLASH_SCHEME:Mp,SYM:tS,TILDE:Bx,TLD:bR,UNDERSCORE:eS,UTLD:yR,UWORD:vR,WORD:ql,WS:_R});const $l=/[a-z]/,nx=new RegExp("\\p{L}","u"),L2=new RegExp("\\p{Emoji}","u"),Vl=/\d/,I2=/\s/,A6="\r",j2=`
- `,WTe="️",qTe="",U2="";let Ky=null,Yy=null;function XTe(t=[]){const e={};Us.groups=e;const n=new Us;Ky==null&&(Ky=T6(zTe)),Yy==null&&(Yy=T6(BTe)),gt(n,"'",V1),gt(n,"{",jx),gt(n,"}",Ux),gt(n,"[",N1),gt(n,"]",R1),gt(n,"(",P1),gt(n,")",k1),gt(n,"<",D1),gt(n,">",O1),gt(n,"(",L1),gt(n,")",I1),gt(n,"「",j1),gt(n,"」",U1),gt(n,"『",F1),gt(n,"』",z1),gt(n,"<",B1),gt(n,">",H1),gt(n,"&",$1),gt(n,"*",G1),gt(n,"@",Su),gt(n,"`",q1),gt(n,"^",X1),gt(n,":",Nu),gt(n,",",lD),gt(n,"$",K1),gt(n,".",Bo),gt(n,"=",Y1),gt(n,"!",cD),gt(n,"-",ka),gt(n,"%",Fx),gt(n,"|",Z1),gt(n,"+",Q1),gt(n,"#",J1),gt(n,"?",zx),gt(n,'"',uD),gt(n,"/",Ho),gt(n,";",dD),gt(n,"~",Bx),gt(n,"_",eS),gt(n,"\\",W1),gt(n,"・",iX);const r=wr(n,Vl,aD,{[pR]:!0});wr(r,Vl,r);const i=wr(r,$l,nX,{[Ix]:!0}),s=wr(r,nx,rX,{[bx]:!0}),a=wr(n,$l,ql,{[mR]:!0});wr(a,Vl,i),wr(a,$l,a),wr(i,Vl,i),wr(i,$l,i);const o=wr(n,nx,vR,{[gR]:!0});wr(o,$l),wr(o,Vl,s),wr(o,nx,o),wr(s,Vl,s),wr(s,$l),wr(s,nx,s);const l=gt(n,j2,oD,{[O2]:!0}),c=gt(n,A6,_R,{[O2]:!0}),u=wr(n,I2,_R,{[O2]:!0});gt(n,U2,u),gt(c,j2,l),gt(c,U2,u),wr(c,I2,u),gt(u,A6),gt(u,j2),wr(u,I2,u),gt(u,U2,u);const h=wr(n,L2,sX,{[tX]:!0});gt(h,"#"),wr(h,L2,h),gt(h,WTe,h);const g=gt(h,qTe);gt(g,"#"),wr(g,L2,h);const m=[[$l,a],[Vl,i]],b=[[$l,null],[nx,o],[Vl,s]];for(let y=0;y<Ky.length;y++)xu(n,Ky[y],bR,ql,m);for(let y=0;y<Yy.length;y++)xu(n,Yy[y],yR,vR,b);af(bR,{tld:!0,ascii:!0},e),af(yR,{utld:!0,alpha:!0},e),xu(n,"file",j_,ql,m),xu(n,"mailto",j_,ql,m),xu(n,"http",Mp,ql,m),xu(n,"https",Mp,ql,m),xu(n,"ftp",Mp,ql,m),xu(n,"ftps",Mp,ql,m),af(j_,{scheme:!0,ascii:!0},e),af(Mp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,v)=>y[0]>v[0]?1:-1);for(let y=0;y<t.length;y++){const v=t[y][0],M=t[y][1]?{[HTe]:!0}:{[$Te]:!0};v.indexOf("-")>=0?M[xR]=!0:$l.test(v)?Vl.test(v)?M[Ix]=!0:M[mR]=!0:M[pR]=!0,E6(n,v,v,M)}return E6(n,"localhost",b0,{ascii:!0}),n.jd=new Us(tS),{start:n,tokens:Object.assign({groups:e},aX)}}function oX(t,e){const n=KTe(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let s=0,a=0;for(;a<r;){let o=t,l=null,c=0,u=null,h=-1,g=-1;for(;a<r&&(l=o.go(n[a]));)o=l,o.accepts()?(h=0,g=0,u=o):h>=0&&(h+=n[a].length,g++),c+=n[a].length,s+=n[a].length,a++;s-=h,a-=g,c-=h,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function KTe(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,a=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(a),r+=a.length}return e}function xu(t,e,n,r,i){let s;const a=e.length;for(let o=0;o<a-1;o++){const l=e[o];t.j[l]?s=t.j[l]:(s=new Us(r),s.jr=i.slice(),t.j[l]=s),t=s}return s=new Us(n),s.jr=i.slice(),t.j[e[a-1]]=s,s}function T6(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let a=parseInt(t.substring(r,r+s),10);a>0;a--)n.pop();r+=s}else n.push(t[r]),r++}return e}const y0={defaultProtocol:"http",events:null,format:C6,formatHref:C6,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function fD(t,e=null){let n=Object.assign({},y0);t&&(n=Object.assign(n,t instanceof fD?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}fD.prototype={o:y0,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]:y0[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 C6(t){return t}function lX(t,e){this.t="token",this.v=t,this.tk=e}lX.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=y0.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),a={},o=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return a.href=r,o&&(a.class=o),l&&(a.target=l),c&&(a.rel=c),u&&Object.assign(a,u),{tagName:i,attributes:a,content:s,eventListeners:h}}};function kw(t,e){class n extends lX{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const N6=kw("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),R6=kw("text"),YTe=kw("nl"),Zy=kw("url",{isLink:!0,toHref(t=y0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==b0&&t[1].t===Nu}}),Ca=t=>new Us(t);function ZTe({groups:t}){const e=t.domain.concat([$1,G1,Su,W1,q1,X1,K1,Y1,ka,aD,Fx,Z1,Q1,J1,Ho,tS,Bx,eS]),n=[V1,Nu,lD,Bo,cD,Fx,zx,uD,dD,D1,O1,jx,Ux,R1,N1,P1,k1,L1,I1,j1,U1,F1,z1,B1,H1],r=[$1,V1,G1,W1,q1,X1,K1,Y1,ka,jx,Ux,Fx,Z1,Q1,J1,zx,Ho,tS,Bx,eS],i=Ca(),s=gt(i,Bx);rn(s,r,s),rn(s,t.domain,s);const a=Ca(),o=Ca(),l=Ca();rn(i,t.domain,a),rn(i,t.scheme,o),rn(i,t.slashscheme,l),rn(a,r,s),rn(a,t.domain,a);const c=gt(a,Su);gt(s,Su,c),gt(o,Su,c),gt(l,Su,c);const u=gt(s,Bo);rn(u,r,s),rn(u,t.domain,s);const h=Ca();rn(c,t.domain,h),rn(h,t.domain,h);const g=gt(h,Bo);rn(g,t.domain,h);const m=Ca(N6);rn(g,t.tld,m),rn(g,t.utld,m),gt(c,b0,m);const b=gt(h,ka);gt(b,ka,b),rn(b,t.domain,h),rn(m,t.domain,h),gt(m,Bo,g),gt(m,ka,b);const y=gt(m,Nu);rn(y,t.numeric,N6);const v=gt(a,ka),x=gt(a,Bo);gt(v,ka,v),rn(v,t.domain,a),rn(x,r,s),rn(x,t.domain,a);const M=Ca(Zy);rn(x,t.tld,M),rn(x,t.utld,M),rn(M,t.domain,a),rn(M,r,s),gt(M,Bo,x),gt(M,ka,v),gt(M,Su,c);const w=gt(M,Nu),T=Ca(Zy);rn(w,t.numeric,T);const A=Ca(Zy),P=Ca();rn(A,e,A),rn(A,n,P),rn(P,e,A),rn(P,n,P),gt(M,Ho,A),gt(T,Ho,A);const C=gt(o,Nu),j=gt(l,Nu),N=gt(j,Ho),k=gt(N,Ho);rn(o,t.domain,a),gt(o,Bo,x),gt(o,ka,v),rn(l,t.domain,a),gt(l,Bo,x),gt(l,ka,v),rn(C,t.domain,A),gt(C,Ho,A),gt(C,zx,A),rn(k,t.domain,A),rn(k,e,A),gt(k,Ho,A);const F=[[jx,Ux],[N1,R1],[P1,k1],[D1,O1],[L1,I1],[j1,U1],[F1,z1],[B1,H1]];for(let I=0;I<F.length;I++){const[W,D]=F[I],$=gt(A,W);gt(P,W,$),gt($,D,A);const G=Ca(Zy);rn($,e,G);const V=Ca();rn($,n),rn(G,e,G),rn(G,n,V),rn(V,e,G),rn(V,n,V),gt(G,D,A),gt(V,D,A)}return gt(i,b0,M),gt(i,oD,YTe),{start:i,tokens:aX}}function QTe(t,e,n){let r=n.length,i=0,s=[],a=[];for(;i<r;){let o=t,l=null,c=null,u=0,h=null,g=-1;for(;i<r&&!(l=o.go(n[i].t));)a.push(n[i++]);for(;i<r&&(c=l||o.go(n[i].t));)l=null,o=c,o.accepts()?(g=0,h=o):g>=0&&g++,i++,u++;if(g<0)i-=u,i<r&&(a.push(n[i]),i++);else{a.length>0&&(s.push(F2(R6,e,a)),a=[]),i-=g,u-=g;const m=h.t,b=n.slice(i-u,i);s.push(F2(m,e,b))}}return a.length>0&&s.push(F2(R6,e,a)),s}function F2(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const JTe=typeof console<"u"&&console&&console.warn||(()=>{}),e2e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ir={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function t2e(){return Us.groups={},ir.scanner=null,ir.parser=null,ir.tokenQueue=[],ir.pluginQueue=[],ir.customSchemes=[],ir.initialized=!1,ir}function P6(t,e=!1){if(ir.initialized&&JTe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${e2e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);ir.customSchemes.push([t,e])}function n2e(){ir.scanner=XTe(ir.customSchemes);for(let t=0;t<ir.tokenQueue.length;t++)ir.tokenQueue[t][1]({scanner:ir.scanner});ir.parser=ZTe(ir.scanner.tokens);for(let t=0;t<ir.pluginQueue.length;t++)ir.pluginQueue[t][1]({scanner:ir.scanner,parser:ir.parser});return ir.initialized=!0,ir}function hD(t){return ir.initialized||n2e(),QTe(ir.parser.start,t,oX(ir.scanner.start,t))}hD.scan=oX;function cX(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 fD(n),i=hD(t),s=[];for(let a=0;a<i.length;a++){const o=i[a];o.isLink&&(!e||o.t===e)&&r.check(o)&&s.push(o.toFormattedObject(r))}return s}var pD="[\0- -\u2029 ]",r2e=new RegExp(pD),i2e=new RegExp(`${pD}$`),s2e=new RegExp(pD,"g");function a2e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function o2e(t){return new vr({key:new di("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:a}=r,o=Cq(n.doc,[...e]);if(Lq(o).forEach(({newRange:c})=>{const u=VEe(r.doc,c,m=>m.isTextblock);let h,g;if(u.length>1)h=u[0],g=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(u.length){const m=r.doc.textBetween(c.from,c.to," "," ");if(!i2e.test(m))return;h=u[0],g=r.doc.textBetween(h.pos,c.to,void 0," ")}if(h&&g){const m=g.split(r2e).filter(Boolean);if(m.length<=0)return!1;const b=m[m.length-1],y=h.pos+g.lastIndexOf(b);if(!b)return!1;const v=hD(b).map(x=>x.toObject(t.defaultProtocol));if(!a2e(v))return!1;v.filter(x=>x.isLink).map(x=>({...x,from:y+x.start+1,to:y+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{tD(x.from,x.to,r.doc).some(M=>M.mark.type===t.type)||a.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!a.steps.length)return a}})}function l2e(t){return new vr({key:new di("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let a=null;if(r.target instanceof HTMLAnchorElement)a=r.target;else{let u=r.target;const h=[];for(;u.nodeName!=="DIV";)h.push(u),u=u.parentNode;a=h.find(g=>g.nodeName==="A")}if(!a)return!1;const o=Oq(e.state,t.type.name),l=(i=a?.href)!=null?i:o.href,c=(s=a?.target)!=null?s:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),a&&l?(window.open(l,c),!0):!1}}})}function c2e(t){return new vr({key:new di("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:a}=s,{empty:o}=a;if(o)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const c=cX(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||i!==void 0&&!i(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Hd(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(s2e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var uX=dd.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){P6(t);return}P6(t.scheme,t.optionalSlashes)})},onDestroy(){t2e()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Hd(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Hd(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Hd(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Tr(this.options.HTMLAttributes,t),0]:["a",Tr(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Hd(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Hd(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[zf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=cX(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:a=>!!Hd(a,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(o2e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Hd(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(l2e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(c2e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),u2e=uX,d2e=Object.defineProperty,f2e=(t,e)=>{for(var n in e)d2e(t,n,{get:e[n],enumerable:!0})},h2e="listItem",k6="textStyle",D6=/^\s*([-+*])\s$/,dX=Ws.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",Tr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(h2e,this.editor.getAttributes(k6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=hm({find:D6,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=hm({find:D6,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(k6),editor:this.editor})),[t]}}),fX=Ws.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Tr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const a=t.tokens.slice(1),o=e.parseChildren(a);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>sD(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)}}}),p2e={};f2e(p2e,{findListItemPos:()=>J0,getNextListDepth:()=>mD,handleBackspace:()=>SR,handleDelete:()=>wR,hasListBefore:()=>hX,hasListItemAfter:()=>m2e,hasListItemBefore:()=>pX,listItemHasSubList:()=>mX,nextListIsDeeper:()=>gX,nextListIsHigher:()=>xX});var J0=(t,e)=>{const{$from:n}=e.selection,r=Zr(t,e.schema);let i=null,s=n.depth,a=n.pos,o=null;for(;s>0&&o===null;)i=n.node(s),i.type===r?o=s:(s-=1,a-=1);return o===null?null:{$pos:e.doc.resolve(a),depth:o}},mD=(t,e)=>{const n=J0(t,e);if(!n)return!1;const[,r]=eAe(e,t,n.$pos.pos+4);return r},hX=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},pX=(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)},mX=(t,e,n)=>{if(!n)return!1;const r=Zr(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},SR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!nd(t.state,e)&&hX(t.state,e,n)){const{$anchor:o}=t.state.selection,l=t.state.doc.resolve(o.before()-1),c=[];l.node().descendants((g,m)=>{g.type.name===e&&c.push({node:g,pos:m})});const u=c.at(-1);if(!u)return!1;const h=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},h.end()).joinForward().run()}if(!nd(t.state,e)||!iAe(t.state))return!1;const r=J0(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=mX(e,t.state,s);return pX(e,t.state)&&!a?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},gX=(t,e)=>{const n=mD(t,e),r=J0(t,e);return!r||!n?!1:n>r.depth},xX=(t,e)=>{const n=mD(t,e),r=J0(t,e);return!r||!n?!1:n<r.depth},wR=(t,e)=>{if(!nd(t.state,e)||!rAe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:gX(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():xX(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},m2e=(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)},vX=Wn.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&wR(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&&wR(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&&SR(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&&SR(t,n,r)&&(e=!0)}),e}}}}),O6=/^(\s*)(\d+)\.\s+(.*)$/,g2e=/^\s/;function x2e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(O6);if(!s)break;const[,a,o,l]=s,c=a.length;let u=l,h=n+1;const g=[i];for(;h<t.length;){const m=t[h];if(m.match(O6))break;if(m.trim()==="")g.push(m),u+=`
- `,h+=1;else if(m.match(g2e))g.push(m),u+=`
- ${m.slice(c+2)}`,h+=1;else break}e.push({indent:c,number:parseInt(o,10),content:u.trim(),raw:g.join(`
- `)}),r=h,n=h}return[e,r]}function bX(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const a=t[s];if(a.indent===e){const o=a.content.split(`
- `),l=((r=o[0])==null?void 0:r.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=o.slice(1).join(`
- `).trim();if(u){const m=n.blockTokens(u);c.push(...m)}let h=s+1;const g=[];for(;h<t.length&&t[h].indent>e;)g.push(t[h]),h+=1;if(g.length>0){const m=Math.min(...g.map(y=>y.indent)),b=bX(g,m,n);c.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:a.raw,tokens:c}),s=h}else s+=1}return i}function v2e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var b2e="listItem",L6="textStyle",I6=/^(\d+)\.\s$/,yX=Ws.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",Tr(this.options.HTMLAttributes,n),0]:["ol",Tr(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?v2e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[s,a]=x2e(i);if(s.length===0)return;const o=bX(s,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,a).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(b2e,this.editor.getAttributes(L6)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=hm({find:I6,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=hm({find:I6,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(L6)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),y2e=/^\s*(\[([( |x])?\])\s$/,_2e=Ws.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",Tr(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 sD(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),a=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),c=u=>{var h,g;o.ariaLabel=((g=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:g.call(h,u,o.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),s.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",u=>u.preventDefault()),o.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:h}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const m=n();if(typeof m!="number")return!1;const b=g.doc.nodeAt(m);return g.setNodeMarkup(m,void 0,{...b?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,h])=>{i.setAttribute(u,h)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,s.append(o,a),i.append(s,l),Object.entries(e).forEach(([u,h])=>{i.setAttribute(u,h)}),{dom:i,contentDOM:l,update:u=>u.type!==this.type?!1:(i.dataset.checked=u.attrs.checked,o.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[hm({find:y2e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),S2e=Ws.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",Tr(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const a=fR(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return a?[{type:"taskList",raw:a.raw,items:a.items}]:n.blockTokens(s)},i=fR(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,a)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:a}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Wn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(dX.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(fX.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(vX.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(yX.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(_2e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(S2e.configure(this.options.taskList)),t}});var w2e=Ws.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Tr(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()}}}),M2e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,E2e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,A2e=dd.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Tr(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[fm({find:M2e,type:this.type})]},addPasteRules(){return[zf({find:E2e,type:this.type})]}}),T2e=Ws.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),_X=dd.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Tr(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),C2e=_X;function N2e(t={}){return new vr({view(e){return new R2e(e,t)}})}class R2e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=a=>{this[i](a)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),a=s.width/i.offsetWidth,o=s.height/i.offsetHeight;if(n){let h=e.nodeBefore,g=e.nodeAfter;if(h||g){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let b=m.getBoundingClientRect(),y=h?b.bottom:b.top;h&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*o;r={left:b.left,right:b.right,top:y-v,bottom:y+v}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*a;r={left:h.left-g,right:h.left+g,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let h=l.getBoundingClientRect(),g=h.width/l.offsetWidth,m=h.height/l.offsetHeight;c=h.left-l.scrollLeft*g,u=h.top-l.scrollTop*m}this.element.style.left=(r.left-c)/a+"px",this.element.style.top=(r.top-u)/o+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=yW(this.editorView.state.doc,a,this.editorView.dragging.slice);o!=null&&(a=o)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Ar extends ln{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Ar.valid(r)?new Ar(r):ln.near(r)}content(){return Mt.empty}eq(e){return e instanceof Ar&&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 Ar(e.resolve(n.pos))}getBookmark(){return new gD(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!P2e(e)||!k2e(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&&Ar.valid(e))return e;let i=e.pos,s=null;for(let a=e.depth;;a--){let o=e.node(a);if(n>0?e.indexAfter(a)<o.childCount:e.index(a)>0){s=o.child(n>0?e.indexAfter(a):e.index(a)-1);break}else if(a==0)return null;i+=n;let l=e.doc.resolve(i);if(Ar.valid(l))return l}for(;;){let a=n>0?s.firstChild:s.lastChild;if(!a){if(s.isAtom&&!s.isText&&!zt.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=a,i+=n;let o=e.doc.resolve(i);if(Ar.valid(o))return o}return null}}}Ar.prototype.visible=!1;Ar.findFrom=Ar.findGapCursorFrom;ln.jsonID("gapcursor",Ar);class gD{constructor(e){this.pos=e}map(e){return new gD(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Ar.valid(n)?new Ar(n):ln.near(n)}}function SX(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function P2e(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||SX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function k2e(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||SX(i.type))return!0;if(i.inlineContent)return!1}}return!0}function D2e(){return new vr({props:{decorations:j2e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Ar.valid(n)?new Ar(n):null},handleClick:L2e,handleKeyDown:O2e,handleDOMEvents:{beforeinput:I2e}}})}const O2e=yq({ArrowLeft:Qy("horiz",-1),ArrowRight:Qy("horiz",1),ArrowUp:Qy("vert",-1),ArrowDown:Qy("vert",1)});function Qy(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let a=r.selection,o=e>0?a.$to:a.$from,l=a.empty;if(a instanceof Wt){if(!s.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let c=Ar.findGapCursorFrom(o,e,l);return c?(i&&i(r.tr.setSelection(new Ar(c))),!0):!1}}function L2e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Ar.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&zt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Ar(r))),!0)}function I2e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Ar))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=pt.empty;for(let a=r.length-1;a>=0;a--)i=pt.from(r[a].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Mt(i,0,0));return s.setSelection(Wt.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function j2e(t){if(!(t.selection instanceof Ar))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",mr.create(t.doc,[bs.widget(t.selection.head,e,{key:"gapcursor"})])}var nS=200,Ri=function(){};Ri.prototype.append=function(e){return e.length?(e=Ri.from(e),!this.length&&e||e.length<nS&&this.leafAppend(e)||this.length<nS&&e.leafPrepend(this)||this.appendInner(e)):this};Ri.prototype.prepend=function(e){return e.length?Ri.from(e).append(this):this};Ri.prototype.appendInner=function(e){return new U2e(this,e)};Ri.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ri.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ri.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ri.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)};Ri.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,a){return i.push(e(s,a))},n,r),i};Ri.from=function(e){return e instanceof Ri?e:e&&e.length?new wX(e):Ri.empty};var wX=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,a,o){for(var l=s;l<a;l++)if(i(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,a,o){for(var l=s-1;l>=a;l--)if(i(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=nS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=nS)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})(Ri);Ri.empty=new wX([]);var U2e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,a){var o=this.left.length;if(i<o&&this.left.forEachInner(r,i,Math.min(s,o),a)===!1||s>o&&this.right.forEachInner(r,Math.max(i-o,0),Math.min(this.length,s)-o,a+o)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,a){var o=this.left.length;if(i>o&&this.right.forEachInvertedInner(r,i-o,Math.max(s,o)-o,a+o)===!1||s<o&&this.left.forEachInvertedInner(r,Math.min(i,o),s,a)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Ri);const F2e=500;class mo{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let a=e.tr,o,l,c=[],u=[];return this.items.forEach((h,g)=>{if(!h.step){i||(i=this.remapping(r,g+1),s=i.maps.length),s--,u.push(h);return}if(i){u.push(new $o(h.map));let m=h.step.map(i.slice(s)),b;m&&a.maybeStep(m).doc&&(b=a.mapping.maps[a.mapping.maps.length-1],c.push(new $o(b,void 0,void 0,c.length+u.length))),s--,b&&i.appendMap(b,s)}else a.maybeStep(h.step);if(h.selection)return o=i?h.selection.map(i.slice(s)):h.selection,l=new mo(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:a,selection:o}}addTransform(e,n,r,i){let s=[],a=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let h=e.steps[u].invert(e.docs[u]),g=new $o(e.mapping.maps[u],h,n),m;(m=l&&l.merge(g))&&(g=m,u?s.pop():o=o.slice(0,o.length-1)),s.push(g),n&&(a++,n=void 0),i||(l=g)}let c=a-r.depth;return c>B2e&&(o=z2e(o,c),a-=c),new mo(o.append(s),a)}remapping(e,n){let r=new h0;return this.items.forEach((i,s)=>{let a=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,a)},e,n),r}addMaps(e){return this.eventCount==0?this:new mo(this.items.append(e.map(n=>new $o(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,a=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let l=n;this.items.forEach(g=>{let m=s.getMirror(--l);if(m==null)return;a=Math.min(a,m);let b=s.maps[m];if(g.step){let y=e.steps[m].invert(e.docs[m]),v=g.selection&&g.selection.map(s.slice(l+1,m));v&&o++,r.push(new $o(b,y,v))}else r.push(new $o(b))},i);let c=[];for(let g=n;g<a;g++)c.push(new $o(s.maps[g]));let u=this.items.slice(0,i).append(c).append(r),h=new mo(u,o);return h.emptyItemCount()>F2e&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((a,o)=>{if(o>=e)i.push(a),a.selection&&s++;else if(a.step){let l=a.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=a.selection&&a.selection.map(n.slice(r));u&&s++;let h=new $o(c.invert(),l,u),g,m=i.length-1;(g=i.length&&i[m].merge(h))?i[m]=g:i.push(h)}}else a.map&&r--},this.items.length,0),new mo(Ri.from(i.reverse()),s)}}mo.empty=new mo(Ri.empty,0);function z2e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class $o{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 $o(n.getMap().invert(),n,this.selection)}}}class wu{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const B2e=20;function H2e(t,e,n,r){let i=n.getMeta(xf),s;if(i)return i.historyState;n.getMeta(G2e)&&(t=new wu(t.done,t.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(a&&a.getMeta(xf))return a.getMeta(xf).redo?new wu(t.done.addTransform(n,void 0,r,U_(e)),t.undone,j6(n.mapping.maps),t.prevTime,t.prevComposition):new wu(t.done,t.undone.addTransform(n,void 0,r,U_(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!a&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!$2e(n,t.prevRanges)),c=a?z2(t.prevRanges,n.mapping):j6(n.mapping.maps);return new wu(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,U_(e)),mo.empty,c,n.time,o??t.prevComposition)}else return(s=n.getMeta("rebased"))?new wu(t.done.rebased(n,s),t.undone.rebased(n,s),z2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new wu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),z2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function $2e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function j6(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,a)=>e.push(s,a));return e}function z2(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function V2e(t,e,n){let r=U_(e),i=xf.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let a=s.selection.resolve(s.transform.doc),o=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),l=new wu(n?o:s.remaining,n?s.remaining:o,null,0,-1);return s.transform.setSelection(a).setMeta(xf,{redo:n,historyState:l})}let B2=!1,U6=null;function U_(t){let e=t.plugins;if(U6!=e){B2=!1,U6=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){B2=!0;break}}return B2}const xf=new di("history"),G2e=new di("closeHistory");function W2e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new vr({key:xf,state:{init(){return new wu(mo.empty,mo.empty,null,0,-1)},apply(e,n,r){return H2e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?EX:r=="historyRedo"?AX:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function MX(t,e){return(n,r)=>{let i=xf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=V2e(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const EX=MX(!1,!0),AX=MX(!0,!0);Wn.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new vr({key:new di("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const a=s-i,o=0,l=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(o,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=s-r,c=o-l,u=o;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var q2e=Wn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[N2e(this.options)]}});Wn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new vr({key:new di("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return mr.create(t,[]);let a=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;a+=1});let o=0;return t.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=c+l.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&a-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";s.push(bs.node(c,c+l.nodeSize,{class:this.options.className}))}),mr.create(t,s)}}})]}});var X2e=Wn.create({name:"gapCursor",addProseMirrorPlugins(){return[D2e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ln(Ut(t,"allowGapCursor",n)))!=null?e:null}}});Wn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new vr({key:new di("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((a,o)=>{const l=r>=o&&r<=o+a.nodeSize,c=!a.isLeaf&&Nw(a);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];s&&u.push(this.options.emptyEditorClass);const h=bs.node(o,o+a.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:o,hasAnchor:l}):this.options.placeholder});i.push(h)}return this.options.includeChildren}),mr.create(t,i)}}})]}});Wn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new vr({key:new di("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Iq(n.selection)||t.view.dragging?null:mr.create(n.doc,[bs.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function F6({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var K2e=Wn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new di(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 vr({key:e,appendTransaction:(i,s,a)=>{const{doc:o,tr:l,schema:c}=a,u=e.getState(a),h=o.content.size,g=c.nodes[n];if(u)return l.insert(h,g.create())},state:{init:(i,s)=>{const a=s.tr.doc.lastChild;return!F6({node:a,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const a=i.doc.lastChild;return!F6({node:a,types:r})}}})]}}),Y2e=Wn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>EX(t,e),redo:()=>({state:t,dispatch:e})=>AX(t,e)}},addProseMirrorPlugins(){return[W2e(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()}}}),Z2e=Wn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(MTe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(bTe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(dX.configure(this.options.bulletList)),this.options.code!==!1&&i.push(TTe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(RTe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(PTe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(q2e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(X2e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(kTe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(DTe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(Y2e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(OTe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(FTe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(fX.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(vX.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(uX.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(yX.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(w2e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(A2e.configure(this.options.strike)),this.options.text!==!1&&i.push(T2e.configure(this.options.text)),this.options.underline!==!1&&i.push(_X.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(K2e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),Q2e=Z2e,J2e=Wn.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),eCe=J2e,tCe=20,TX=(t,e=0)=>{const n=[];return!t.children.length||e>tCe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...TX(r,e+1))}),n},nCe=t=>{if(!t.children.length)return;const e=TX(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),a=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${a};${s}`)})},CX=dd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&nCe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Tr(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),rCe=Wn.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),NX=Wn.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const a=s[0].trim().toLowerCase(),o=s.slice(1).join(":").trim();if(a==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),iCe=Wn.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),sCe=Wn.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),aCe=Wn.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Wn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(rCe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(NX.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(iCe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(sCe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(aCe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(CX.configure(this.options.textStyle)),t}});var oCe=NX,lCe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cCe=Ws.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",Tr(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,a;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",l=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",c=(a=(s=t.attrs)==null?void 0:s.title)!=null?a:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:a})=>{const o=document.createElement("img");Object.entries(a).forEach(([u,h])=>{if(h!=null)switch(u){case"width":case"height":break;default:o.setAttribute(u,h);break}}),o.src=a.src;const l=new HAe({element:o,node:i,getPos:s,onResize:(u,h)=>{o.style.width=`${u}px`,o.style.height=`${h}px`},onCommit:(u,h)=>{const g=s();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:u,height:h}).run()},onUpdate:(u,h,g)=>u.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),c=l.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",o.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},l}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Zq({find:lCe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),uCe=cCe;function z6({content:t,onChange:e,placeholder:n}){const r=pTe({extensions:[Q2e.configure({heading:!1,codeBlock:!1,code:!1}),C2e,u2e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),eCe.configure({types:["paragraph"]}),CX,oCe,uCe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:a})=>{e(a.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:a,isActive:o=!1,children:l,title:c})=>f.jsx("button",{type:"button",onClick:a,title:c,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:l}),s=()=>{const a=window.prompt("Enter URL:");a&&r.chain().focus().setLink({href:a}).run()};return f.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[f.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[f.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:f.jsx(eae,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:f.jsx(goe,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:f.jsx($le,{className:"w-4 h-4"})}),f.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),f.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:f.jsx(JP,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:f.jsx(p9,{className:"w-4 h-4"})}),f.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),f.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:f.jsx(jle,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:f.jsx(Dle,{className:"w-4 h-4"})}),f.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:f.jsx(Lle,{className:"w-4 h-4"})}),f.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),f.jsx(i,{onClick:s,isActive:r.isActive("link"),title:"Add Link",children:f.jsx(h9,{className:"w-4 h-4"})}),r.isActive("link")&&f.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:f.jsx(_9,{className:"w-4 h-4"})})]}),f.jsx(oTe,{editor:r})]})}function dCe({archiveId:t,archiveName:e,onClose:n}){const r=Rn(),[i,s]=E.useState(!1),[a,o]=E.useState(null),[l,c]=E.useState({}),{data:u,isLoading:h,error:g}=At({queryKey:["archive-project-page",t],queryFn:()=>Ue.getArchiveProjectPage(t)}),m=Tt({mutationFn:A=>Ue.updateArchiveProjectPage(t,A),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),c({})}});E.useEffect(()=>{const A=P=>{P.key==="Escape"&&(a!==null?o(null):i?x():n())};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[a,i,n]);const b=[...u?.model_pictures||[],...u?.profile_pictures||[]],y=()=>{c({title:u?.title||"",description:u?.description||"",designer:u?.designer||"",license:u?.license||"",profile_title:u?.profile_title||"",profile_description:u?.profile_description||""}),s(!0)},v=()=>{m.mutate(l)},x=()=>{s(!1),c({})},M=A=>{const P=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],C=new DOMParser().parseFromString(A,"text/html"),j=N=>{if(N.nodeType===Node.TEXT_NODE)return N.textContent||"";if(N.nodeType===Node.ELEMENT_NODE){const k=N,F=k.tagName.toLowerCase();if(!P.includes(F))return Array.from(k.childNodes).map(j).join("");let I="";if(F==="a"&&k.getAttribute("href")){const D=k.getAttribute("href");D?.toLowerCase().startsWith("http")&&(I=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const D=k.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";I=` src="${D}" style="max-width: 100%; height: auto;"`}const W=Array.from(k.childNodes).map(j).join("");return["br","img"].includes(F)?`<${F}${I} />`:`<${F}${I}>${W}</${F}>`}return""};return Array.from(C.body.childNodes).map(j).join("")},w=u&&(u.title||u.description||u.designer||u.profile_title||b.length>0),T=A=>{A.target===A.currentTarget&&n()};return f.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(Pu,{className:"w-5 h-5 text-bambu-green"}),f.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&f.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&f.jsxs(We,{variant:"ghost",size:"sm",onClick:y,children:[f.jsx(t1,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&f.jsxs(f.Fragment,{children:[f.jsx(We,{variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),f.jsxs(We,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[f.jsx(Xo,{className:"w-4 h-4 mr-1"}),"Save"]})]}),f.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(tn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[h&&f.jsx("div",{className:"flex items-center justify-center py-12",children:f.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&f.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),u&&!w&&f.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[f.jsx(Pu,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),f.jsx("p",{children:"No project page data found in this 3MF file."}),f.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),u&&w&&f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"space-y-4",children:[i?f.jsx("input",{type:"text",value:l.title||"",onChange:A=>c({...l,title:A.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):u.title&&f.jsx("h3",{className:"text-xl font-semibold text-white",children:u.title}),f.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(uF,{className:"w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:l.designer||"",onChange:A=>c({...l,designer:A.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.designer&&f.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[f.jsx(uF,{className:"w-4 h-4"}),f.jsx("span",{children:u.designer}),u.designer_user_id&&f.jsx("a",{href:`https://makerworld.com/en/@${u.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:f.jsx(gc,{className:"w-3 h-3"})})]}),u.creation_date&&f.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[f.jsx(as,{className:"w-4 h-4"}),f.jsx("span",{children:u.creation_date})]}),i?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Pu,{className:"w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:l.license||"",onChange:A=>c({...l,license:A.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):u.license&&f.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[f.jsx(Pu,{className:"w-4 h-4"}),f.jsx("span",{children:u.license})]}),u.origin&&f.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:u.origin})]})]}),(u.description||i)&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?f.jsx(z6,{content:l.description||"",onChange:A=>c({...l,description:A}),placeholder:"Enter description..."}):f.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.description||"")}})]}),(u.profile_title||u.profile_description||i)&&f.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?f.jsxs("div",{className:"space-y-2",children:[f.jsx("input",{type:"text",value:l.profile_title||"",onChange:A=>c({...l,profile_title:A.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),f.jsx(z6,{content:l.profile_description||"",onChange:A=>c({...l,profile_description:A}),placeholder:"Profile description..."})]}):f.jsxs(f.Fragment,{children:[u.profile_title&&f.jsx("p",{className:"text-white font-medium",children:u.profile_title}),u.profile_description&&f.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.profile_description)}}),u.profile_user_name&&f.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",u.profile_user_name]})]})]}),b.length>0&&f.jsxs("div",{className:"space-y-2",children:[f.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[f.jsx(sw,{className:"w-4 h-4"}),"Images (",b.length,")"]}),f.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:b.map((A,P)=>f.jsx("button",{onClick:()=>o(P),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:f.jsx("img",{src:A.url,alt:A.name,className:"w-full h-full object-cover"})},A.path))})]}),u.design_model_id&&f.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("a",{href:`https://makerworld.com/en/models/${u.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[f.jsx(gc,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),a!==null&&b[a]&&f.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[f.jsx("button",{onClick:A=>{A.stopPropagation(),o(Math.max(0,a-1))},disabled:a===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:f.jsx(Af,{className:"w-6 h-6 text-white"})}),f.jsx("img",{src:b[a].url,alt:b[a].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:A=>A.stopPropagation()}),f.jsx("button",{onClick:A=>{A.stopPropagation(),o(Math.min(b.length-1,a+1))},disabled:a===b.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:f.jsx(Cm,{className:"w-6 h-6 text-white"})}),f.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:f.jsx(tn,{className:"w-6 h-6 text-white"})}),f.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[a+1," / ",b.length]})]})]})}const fCe=[.25,.5,.75,1,1.5,2,3,4];function hCe({src:t,title:e,downloadFilename:n,onClose:r}){const i=E.useRef(null),[s,a]=E.useState(!0),[o,l]=E.useState(.5),[c,u]=E.useState(0),[h,g]=E.useState(0);E.useEffect(()=>{const w=i.current;w&&(w.playbackRate=o)},[o]),E.useEffect(()=>{const w=T=>{T.key==="Escape"&&r()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[r]),E.useEffect(()=>{const w=i.current;if(!w)return;const T=()=>u(w.currentTime),A=()=>g(w.duration),P=()=>a(!0),C=()=>a(!1);return w.addEventListener("timeupdate",T),w.addEventListener("durationchange",A),w.addEventListener("play",P),w.addEventListener("pause",C),()=>{w.removeEventListener("timeupdate",T),w.removeEventListener("durationchange",A),w.removeEventListener("play",P),w.removeEventListener("pause",C)}},[]);const m=()=>{const w=i.current;w&&(s?w.pause():w.play())},b=w=>{const T=i.current;T&&(T.currentTime=parseFloat(w.target.value))},y=()=>{const w=i.current;w&&(w.currentTime=Math.max(0,w.currentTime-5))},v=()=>{const w=i.current;w&&(w.currentTime=Math.min(h,w.currentTime+5))},x=w=>{const T=Math.floor(w/60),A=Math.floor(w%60);return`${T}:${A.toString().padStart(2,"0")}`},M=()=>{const w=document.createElement("a");w.href=t,w.download=n,w.click()};return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:f.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(kp,{className:"w-5 h-5 text-bambu-green"}),e]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(We,{variant:"secondary",size:"sm",onClick:M,children:[f.jsx(tl,{className:"w-4 h-4"}),"Download"]}),f.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:f.jsx(tn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),f.jsxs("div",{className:"p-4",children:[f.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),f.jsxs("div",{className:"mt-4 space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:x(c)}),f.jsx("input",{type:"range",min:0,max:h||100,value:c,onChange:b,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),f.jsx("span",{className:"text-xs text-bambu-gray w-12",children:x(h)})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:f.jsx(ble,{className:"w-5 h-5 text-bambu-gray"})}),f.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:s?f.jsx(qoe,{className:"w-5 h-5 text-white"}):f.jsx(aw,{className:"w-5 h-5 text-white"})}),f.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:f.jsx(v9,{className:"w-5 h-5 text-bambu-gray"})})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),f.jsx("div",{className:"flex gap-1",children:fCe.map(w=>f.jsxs("button",{onClick:()=>l(w),className:`px-2 py-1 text-xs rounded transition-colors ${o===w?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[w,"x"]},w))})]})]})]})]})]})})}function pCe({archiveId:t,archiveName:e,onClose:n}){const r=Rn(),{showToast:i}=Ki(),[s,a]=E.useState(null),[o,l]=E.useState("asap"),[c,u]=E.useState(""),[h,g]=E.useState(!1),[m,b]=E.useState(!1),{data:y}=At({queryKey:["printers"],queryFn:()=>Ue.getPrinters()});E.useEffect(()=>{y?.length===1&&!s&&a(y[0].id)},[y,s]),E.useEffect(()=>{const w=T=>{T.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const v=Tt({mutationFn:w=>Ue.addToQueue(w),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:w=>{i(w.message||"Failed to add to queue","error")}}),x=w=>{if(w.preventDefault(),!s){i("Please select a printer","error");return}const T={printer_id:s,archive_id:t,require_previous_success:h,auto_off_after:m};o==="scheduled"&&c&&(T.scheduled_time=new Date(c).toISOString()),v.mutate(T)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:f.jsx(Ft,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:f.jsxs($t,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(as,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),f.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),f.jsx("p",{className:"text-white font-medium truncate",children:e})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?f.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[f.jsx(Eo,{className:"w-4 h-4"}),"No printers configured"]}):f.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s||"",onChange:w=>a(w.target.value?Number(w.target.value):null),required:!0,children:[f.jsx("option",{value:"",children:"Select printer..."}),y?.map(w=>f.jsx("option",{value:w.id,children:w.name},w.id))]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[f.jsx(Pi,{className:"w-4 h-4"}),"ASAP (when idle)"]}),f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[f.jsx(as,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),f.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:w=>u(w.target.value),min:M(),required:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"requirePrevious",checked:h,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>b(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[f.jsx(Xf,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),f.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."}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),f.jsx(We,{type:"submit",className:"flex-1",disabled:v.isPending||!s||y?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function MR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function rx(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function B6(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function mCe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i}){const s=Rn(),{showToast:a}=Ki(),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[h,g]=E.useState(!1),[m,b]=E.useState(!1),[y,v]=E.useState(!1),[x,M]=E.useState(!1),[w,T]=E.useState([]),[A,P]=E.useState(!1),[C,j]=E.useState(!1),[N,k]=E.useState(!1),[F,I]=E.useState(!1),[W,D]=E.useState(!1),[$,G]=E.useState(null),V=E.useRef(null),Z=Tt({mutationFn:Q=>Ue.uploadSource3mf(t.id,Q),onSuccess:Q=>{s.invalidateQueries({queryKey:["archives"]}),a(`Source 3MF attached: ${Q.filename}`)},onError:Q=>{a(Q.message||"Failed to upload source 3MF","error")}}),K=Tt({mutationFn:()=>Ue.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),a("Source 3MF removed")},onError:Q=>{a(Q.message||"Failed to remove source 3MF","error")}}),ee=Tt({mutationFn:()=>Ue.scanArchiveTimelapse(t.id),onSuccess:Q=>{Q.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),a(`Timelapse attached: ${Q.filename}`)):Q.status==="exists"?a("Timelapse already attached"):Q.status==="not_found"&&Q.available_files&&Q.available_files.length>0?(T(Q.available_files),M(!0)):a(Q.message||"No matching timelapse found","warning")},onError:Q=>{a(Q.message||"Failed to scan for timelapse","error")}}),H=Tt({mutationFn:Q=>Ue.selectArchiveTimelapse(t.id,Q),onSuccess:Q=>{s.invalidateQueries({queryKey:["archives"]}),a(`Timelapse attached: ${Q.filename}`),M(!1),T([])},onError:Q=>{a(Q.message||"Failed to attach timelapse","error")}}),Y=Tt({mutationFn:()=>Ue.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),a("Archive deleted")},onError:()=>{a("Failed to delete archive","error")}}),te=Tt({mutationFn:()=>Ue.toggleFavorite(t.id),onSuccess:Q=>{s.invalidateQueries({queryKey:["archives"]}),a(Q.is_favorite?"Added to favorites":"Removed from favorites")}}),ae=Q=>{Q.preventDefault(),G({x:Q.clientX,y:Q.clientY})},fe=[{label:"Print",icon:f.jsx(nl,{className:"w-4 h-4"}),onClick:()=>u(!0)},{label:"Schedule",icon:f.jsx(as,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:"Open in Bambu Studio",icon:f.jsx(gc,{className:"w-4 h-4"}),onClick:()=>{const Q=t.print_name||t.filename||"model",me=`${window.location.origin}${Ue.getArchiveForSlicer(t.id,Q)}`;window.location.href=`bambustudioopen://${encodeURIComponent(me)}`}},{label:"View on MakerWorld",icon:f.jsx(Q_,{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:f.jsx(qp,{className:"w-4 h-4"}),onClick:()=>l(!0)},{label:"View Timelapse",icon:f.jsx(kp,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:f.jsx(dle,{className:"w-4 h-4"}),onClick:()=>ee.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ee.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:f.jsx(iF,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const Q=document.createElement("a");Q.href=Ue.getSource3mfDownloadUrl(t.id),Q.download=`${t.print_name||t.filename}_source.3mf`,Q.click()}else V.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:f.jsx(Yu,{className:"w-4 h-4"}),onClick:()=>V.current?.click()},{label:"Remove Source 3MF",icon:f.jsx(fr,{className:"w-4 h-4"}),onClick:()=>D(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:f.jsx(tl,{className:"w-4 h-4"}),onClick:()=>{const Q=document.createElement("a");Q.href=Ue.getArchiveDownload(t.id),Q.download=`${t.print_name||t.filename}.3mf`,Q.click()}},{label:"Copy Download Link",icon:f.jsx(Kp,{className:"w-4 h-4"}),onClick:()=>{const Q=`${window.location.origin}${Ue.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(Q).then(()=>{a("Link copied to clipboard")}).catch(()=>{a("Failed to copy link","error")})}},{label:"QR Code",icon:f.jsx(ile,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:f.jsx(Z_,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:f.jsx(Pu,{className:"w-4 h-4"}),onClick:()=>k(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:f.jsx(Jx,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>te.mutate()},{label:"Edit",icon:f.jsx(Cf,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:n?"Deselect":"Select",icon:n?f.jsx(Nf,{className:"w-4 h-4"}):f.jsx(Yp,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:f.jsx(fr,{className:"w-4 h-4"}),onClick:()=>g(!0),danger:!0}];return f.jsxs(Ft,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:ae,onClick:i?()=>r(t.id):void 0,children:[i&&f.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:Q=>{Q.stopPropagation(),r(t.id)},children:n?f.jsx(Nf,{className:"w-5 h-5 text-bambu-green"}):f.jsx(Yp,{className:"w-5 h-5 text-white"})}),f.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?f.jsx("img",{src:Ue.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):f.jsx("div",{className:"w-full h-full flex items-center justify-center",children:f.jsx(sw,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),f.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:Q=>{Q.stopPropagation(),te.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:f.jsx(Jx,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&f.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:"failed"}),t.duplicate_count>0&&f.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:[f.jsx(Kp,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&f.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Q=>{Q.stopPropagation();const me=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Ee=`${window.location.origin}${Ue.getSource3mfForSlicer(t.id,me)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Ee)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:f.jsx(iF,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&f.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:Q=>{Q.stopPropagation(),v(!0)},title:"View timelapse",children:f.jsx(kp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&f.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:Q=>{Q.stopPropagation(),j(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[f.jsx(Z_,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&f.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})]})]}),f.jsxs($t,{className:"p-4 flex-1 flex flex-col",children:[f.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),f.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:e}),f.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)&&f.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${rx(t.print_time_seconds||0)}
- Actual: ${rx(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${rx(t.actual_time_seconds)}`:`Estimated: ${rx(t.print_time_seconds||0)}`,children:[f.jsx(Pi,{className:"w-3 h-3"}),rx(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&f.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&&f.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[f.jsx(e1,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&f.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[f.jsx(Tf,{className:"w-3 h-3"}),t.total_layers&&f.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&f.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&f.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&f.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[f.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&f.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((Q,me)=>f.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:Q},title:Q},me))})]})]}),(t.tags||t.notes)&&f.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&f.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:f.jsx(b9,{className:"w-3 h-3"})}),t.tags?.split(",").map((Q,me)=>f.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:Q.trim()},me))]}),f.jsx("div",{className:"flex-1"}),f.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[f.jsx("span",{children:B6(t.created_at)}),f.jsx("span",{children:MR(t.file_size)})]}),f.jsxs("div",{className:"flex gap-1 mt-3",children:[f.jsxs(We,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>u(!0),children:[f.jsx(nl,{className:"w-3 h-3 flex-shrink-0"}),f.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),f.jsx(We,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Q=t.print_name||t.filename||"model",me=`${window.location.origin}${Ue.getArchiveForSlicer(t.id,Q)}`;window.location.href=`bambustudioopen://${encodeURIComponent(me)}`},title:"Open in Bambu Studio",children:f.jsx(gc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(We,{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:f.jsx(Q_,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),f.jsx(We,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>l(!0),title:"3D Preview",children:f.jsx(qp,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(We,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const Q=document.createElement("a");Q.href=Ue.getArchiveDownload(t.id),Q.download=`${t.print_name||t.filename}.3mf`,Q.click()},title:"Download",children:f.jsx(tl,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(We,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Edit",children:f.jsx(Cf,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),f.jsx(We,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>g(!0),title:"Delete",children:f.jsx(fr,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),m&&f.jsx(F1e,{archive:t,onClose:()=>b(!1)}),o&&f.jsx(L1e,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>l(!1)}),c&&f.jsx(I1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>u(!1),onSuccess:()=>{}}),h&&f.jsx(zs,{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:()=>{Y.mutate(),g(!1)},onCancel:()=>g(!1)}),W&&f.jsx(zs,{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:()=>{K.mutate(),D(!1)},onCancel:()=>D(!1)}),$&&f.jsx(z1e,{x:$.x,y:$.y,items:fe,onClose:()=>G(null)}),y&&t.timelapse_path&&f.jsx(hCe,{src:Ue.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>v(!1)}),x&&w.length>0&&f.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:f.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),f.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),f.jsx("button",{onClick:()=>{M(!1),T([])},className:"text-gray-400 hover:text-white p-1",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:w.map(Q=>f.jsxs("button",{onClick:()=>H.mutate(Q.name),disabled:H.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[f.jsx(kp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-white font-medium truncate",children:Q.name}),f.jsxs("p",{className:"text-sm text-gray-400",children:[MR(Q.size),Q.mtime&&` • ${B6(Q.mtime)}`]})]})]},Q.name))}),f.jsx("div",{className:"p-4 border-t border-gray-700",children:f.jsx(We,{variant:"secondary",onClick:()=>{M(!1),T([])},className:"w-full",children:"Cancel"})})]})}),A&&f.jsx(q1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),C&&t.photos&&t.photos.length>0&&f.jsx(X1e,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async Q=>{try{await Ue.deleteArchivePhoto(t.id,Q),s.invalidateQueries({queryKey:["archives"]}),a("Photo deleted")}catch{a("Failed to delete photo","error")}}}),N&&f.jsx(dCe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>k(!1)}),F&&f.jsx(pCe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),f.jsx("input",{ref:V,type:"file",accept:".3mf",className:"hidden",onChange:Q=>{const me=Q.target.files?.[0];me&&Z.mutate(me),Q.target.value=""}})]})}const gCe=[{id:"all",label:"All Archives",icon:f.jsx(roe,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:f.jsx(Pi,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:f.jsx(as,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:f.jsx(as,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:f.jsx(Jx,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:f.jsx(Eo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:f.jsx(Kp,{className:"w-4 h-4"})}];function xCe(){const t=Rn(),{showToast:e}=Ki(),n=E.useRef(null),[r,i]=E.useState(""),[s,a]=E.useState(null),[o,l]=E.useState(null),[c,u]=E.useState(new Set),[h,g]=E.useState("or"),[m,b]=E.useState(!1),[y,v]=E.useState(null),[x,M]=E.useState(!1),[w,T]=E.useState([]),[A,P]=E.useState(!1),[C,j]=E.useState(new Set),[N,k]=E.useState(!1),[F,I]=E.useState(!1),[W,D]=E.useState(!1),[$,G]=E.useState("grid"),[V,Z]=E.useState("date-desc"),[K,ee]=E.useState("all"),{data:H,isLoading:Y}=At({queryKey:["archives",s],queryFn:()=>Ue.getArchives(s||void 0)}),{data:te}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),ae=Tt({mutationFn:async se=>(await Promise.all(se.map(U=>Ue.deleteArchive(U))),se.length),onSuccess:se=>{t.invalidateQueries({queryKey:["archives"]}),j(new Set),e(`${se} archive${se!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),fe=new Map(te?.map(se=>[se.id,se.name])||[]),Q=[...new Set(H?.flatMap(se=>se.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),me=[...new Set(H?.flatMap(se=>se.filament_color?.split(",")||[]).filter(Boolean)||[])],Ee=[...new Set(H?.flatMap(se=>se.tags?.split(",").map(U=>U.trim())||[]).filter(Boolean)||[])].sort(),he=H?.filter(se=>{const U=new Date,L=new Date(se.created_at);let ne=!0;switch(K){case"recent":ne=U.getTime()-L.getTime()<1440*60*1e3;break;case"this-week":ne=U.getTime()-L.getTime()<10080*60*1e3;break;case"this-month":ne=L.getMonth()===U.getMonth()&&L.getFullYear()===U.getFullYear();break;case"favorites":ne=se.is_favorite===!0;break;case"failed":ne=se.status==="failed";break;case"duplicates":ne=se.duplicate_count>0;break}const ve=(se.print_name||se.filename).toLowerCase().includes(r.toLowerCase()),ye=!o||se.filament_type?.split(", ").includes(o),xe=se.filament_color?.split(",")||[],tt=c.size===0||(h==="or"?xe.some(Fe=>c.has(Fe)):[...c].every(Fe=>xe.includes(Fe))),je=K==="favorites"||!m||se.is_favorite,Ye=se.tags?.split(",").map(Fe=>Fe.trim())||[],ot=!y||Ye.includes(y);return ne&&ve&&ye&&tt&&je&&ot}).sort((se,U)=>{switch(V){case"date-desc":return new Date(U.created_at).getTime()-new Date(se.created_at).getTime();case"date-asc":return new Date(se.created_at).getTime()-new Date(U.created_at).getTime();case"name-asc":return(se.print_name||se.filename).localeCompare(U.print_name||U.filename);case"name-desc":return(U.print_name||U.filename).localeCompare(se.print_name||se.filename);case"size-desc":return U.file_size-se.file_size;case"size-asc":return se.file_size-U.file_size;default:return 0}}),we=N||C.size>0,De=se=>{j(U=>{const L=new Set(U);return L.has(se)?L.delete(se):L.add(se),L})},de=()=>{he&&j(new Set(he.map(se=>se.id)))},Le=()=>{j(new Set),k(!1)},B=se=>{u(U=>{const L=new Set(U);return L.has(se)?L.delete(se):L.add(se),L})},z=()=>{u(new Set)},ie=()=>{i(""),a(null),l(null),b(!1),v(null)},X=r||s||o||m||y,J=E.useCallback(se=>{se.preventDefault(),se.dataTransfer.types.includes("Files")&&P(!0)},[]),le=E.useCallback(se=>{se.preventDefault(),se.currentTarget===se.target&&P(!1)},[]),Re=E.useCallback(se=>{se.preventDefault(),P(!1);const U=Array.from(se.dataTransfer.files).filter(L=>L.name.endsWith(".3mf"));U.length>0?(T(U),M(!0)):se.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Ae=E.useCallback(se=>{const U=se.target;if(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable){se.key==="Escape"&&U.blur();return}switch(se.key){case"/":se.preventDefault(),n.current?.focus();break;case"u":case"U":!se.metaKey&&!se.ctrlKey&&(se.preventDefault(),M(!0));break;case"Escape":we&&Le();break}},[we]);return E.useEffect(()=>(document.addEventListener("keydown",Ae),()=>document.removeEventListener("keydown",Ae)),[Ae]),f.jsxs("div",{className:"p-8 relative min-h-full",onDragOver:J,onDragLeave:le,onDrop:Re,children:[A&&f.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:f.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[f.jsx(Yu,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),f.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),f.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),we&&f.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:[f.jsxs(We,{variant:"secondary",size:"sm",onClick:Le,children:[f.jsx(tn,{className:"w-4 h-4"}),"Close"]}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsxs("span",{className:"text-white font-medium",children:[C.size," selected"]}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsx(We,{variant:"secondary",size:"sm",onClick:de,children:"Select All"}),f.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>D(!0),children:[f.jsx(e0,{className:"w-4 h-4"}),"Tags"]}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>{const se=Array.from(C);Promise.all(se.map(U=>Ue.toggleFavorite(U))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${se.length} archive${se.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[f.jsx(Jx,{className:"w-4 h-4"}),"Favorite"]}),f.jsxs(We,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>I(!0),children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]}),f.jsxs("div",{className:"flex items-center justify-between mb-8",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),f.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:K,onChange:se=>ee(se.target.value),children:gCe.map(se=>f.jsx("option",{value:se.id,children:se.label},se.id))})]}),f.jsxs("p",{className:"text-bambu-gray",children:[he?.length||0," of ",H?.length||0," prints"]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[!we&&f.jsxs(We,{variant:"secondary",onClick:()=>k(!0),children:[f.jsx(Nf,{className:"w-4 h-4"}),"Select"]}),f.jsxs(We,{onClick:()=>M(!0),children:[f.jsx(Yu,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),f.jsx(Ft,{className:"mb-6",children:f.jsxs($t,{className:"py-4",children:[f.jsxs("div",{className:"flex gap-4 items-center flex-wrap",children:[f.jsxs("div",{className:"flex-1 relative min-w-[200px]",children:[f.jsx(Ku,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{ref:n,type:"text",placeholder:"Search archives... (press /)",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:se=>i(se.target.value)})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(YP,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s||"",onChange:se=>a(se.target.value?Number(se.target.value):null),children:[f.jsx("option",{value:"",children:"All Printers"}),te?.map(se=>f.jsx("option",{value:se.id,children:se.name},se.id))]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(e1,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o||"",onChange:se=>l(se.target.value||null),children:[f.jsx("option",{value:"",children:"All Materials"}),Q.map(se=>f.jsx("option",{value:se,children:se},se))]})]}),f.jsxs("button",{onClick:()=>b(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${m?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:m?"Show all":"Show favorites only",children:[f.jsx(Jx,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),f.jsx("span",{className:"text-sm",children:"Favorites"})]}),Ee.length>0&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(e0,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:y||"",onChange:se=>v(se.target.value||null),children:[f.jsx("option",{value:"",children:"All Tags"}),Ee.map(se=>f.jsx("option",{value:se,children:se},se))]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Yse,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:V,onChange:se=>Z(se.target.value),children:[f.jsx("option",{value:"date-desc",children:"Newest first"}),f.jsx("option",{value:"date-asc",children:"Oldest first"}),f.jsx("option",{value:"name-asc",children:"Name A-Z"}),f.jsx("option",{value:"name-desc",children:"Name Z-A"}),f.jsx("option",{value:"size-desc",children:"Largest first"}),f.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),f.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[f.jsx("button",{className:`p-2 ${$==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("grid"),title:"Grid view",children:f.jsx(f9,{className:"w-4 h-4"})}),f.jsx("button",{className:`p-2 ${$==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("list"),title:"List view",children:f.jsx(JP,{className:"w-4 h-4"})}),f.jsx("button",{className:`p-2 ${$==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>G("calendar"),title:"Calendar view",children:f.jsx(sae,{className:"w-4 h-4"})})]}),X&&f.jsxs(We,{variant:"ghost",size:"sm",onClick:ie,className:"text-bambu-gray hover:text-white",children:[f.jsx(tn,{className:"w-4 h-4"}),"Reset"]})]}),me.length>0&&f.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),c.size>1&&f.jsx("button",{onClick:()=>g(se=>se==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${h==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:h==="or"?"Match ANY selected color":"Match ALL selected colors",children:h.toUpperCase()}),f.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:me.map(se=>f.jsx("button",{onClick:()=>B(se),className:`w-6 h-6 rounded-full border-2 transition-all ${c.has(se)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:se},title:se},se))}),c.size>0&&f.jsxs("button",{onClick:z,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[f.jsx(tn,{className:"w-3 h-3"}),"Clear"]})]})]})}),Y?f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):he?.length===0?f.jsx(Ft,{children:f.jsxs($t,{className:"text-center py-12",children:[f.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):$==="calendar"?f.jsx(Ft,{className:"p-6",children:f.jsx(W1e,{archives:he||[],onArchiveClick:se=>{i(se.print_name||se.filename),G("grid")}})}):$==="grid"?f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:he?.map(se=>f.jsx(mCe,{archive:se,printerName:se.printer_id?fe.get(se.printer_id)||"Unknown":"No Printer",isSelected:C.has(se.id),onSelect:De,selectionMode:we},se.id))}):$==="list"?f.jsx(Ft,{children:f.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[f.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[f.jsx("div",{className:"col-span-1"}),f.jsx("div",{className:"col-span-4",children:"Name"}),f.jsx("div",{className:"col-span-2",children:"Printer"}),f.jsx("div",{className:"col-span-2",children:"Date"}),f.jsx("div",{className:"col-span-1",children:"Size"}),f.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),he?.map(se=>f.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${C.has(se.id)?"bg-bambu-green/10":""}`,children:[f.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[we&&f.jsx("button",{onClick:()=>De(se.id),children:C.has(se.id)?f.jsx(Nf,{className:"w-4 h-4 text-bambu-green"}):f.jsx(Yp,{className:"w-4 h-4 text-bambu-gray"})}),se.thumbnail_path?f.jsx("img",{src:Ue.getArchiveThumbnail(se.id),alt:"",className:"w-10 h-10 object-cover rounded"}):f.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:f.jsx(sw,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),f.jsxs("div",{className:"col-span-4",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("p",{className:"text-white text-sm truncate",children:se.print_name||se.filename}),se.timelapse_path&&f.jsx("span",{title:"Has timelapse",children:f.jsx(kp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),se.filament_type&&f.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:se.filament_type}),se.filament_color&&f.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:se.filament_color.split(",").map((U,L)=>f.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:U},title:U},L))})]})]}),f.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:se.printer_id?fe.get(se.printer_id)||"Unknown":"No Printer"}),f.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(se.created_at).toLocaleDateString()}),f.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:MR(se.file_size)}),f.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[f.jsx(We,{variant:"ghost",size:"sm",onClick:()=>{const U=se.print_name||se.filename||"model",L=`${window.location.origin}${Ue.getArchiveForSlicer(se.id,U)}`;window.location.href=`bambustudioopen://${encodeURIComponent(L)}`},title:"Open in Slicer",children:f.jsx(gc,{className:"w-4 h-4"})}),se.makerworld_url&&f.jsx(We,{variant:"ghost",size:"sm",onClick:()=>window.open(se.makerworld_url,"_blank"),title:"MakerWorld",children:f.jsx(Q_,{className:"w-4 h-4"})}),f.jsx(We,{variant:"ghost",size:"sm",onClick:()=>{const U=document.createElement("a");U.href=Ue.getArchiveDownload(se.id),U.download=`${se.print_name||se.filename}.3mf`,U.click()},title:"Download",children:f.jsx(tl,{className:"w-4 h-4"})})]})]},se.id))]})}):null,x&&f.jsx(j1e,{onClose:()=>{M(!1),T([])},initialFiles:w}),F&&f.jsx(zs,{title:"Delete Archives",message:`Are you sure you want to delete ${C.size} archive${C.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${C.size}`,variant:"danger",onConfirm:()=>{ae.mutate(Array.from(C)),I(!1)},onCancel:()=>I(!1)}),W&&f.jsx(B1e,{selectedIds:Array.from(C),existingTags:Ee,onClose:()=>D(!1)})]})}function vCe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const Dw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Lm(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function xD(t){return"nodeType"in t}function qs(t){var e,n;return t?Lm(t)?t:xD(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function vD(t){const{Document:e}=qs(t);return t instanceof e}function ev(t){return Lm(t)?!1:t instanceof qs(t).HTMLElement}function RX(t){return t instanceof qs(t).SVGElement}function Im(t){return t?Lm(t)?t.document:xD(t)?vD(t)?t:ev(t)||RX(t)?t.ownerDocument:document:document:document}const ol=Dw?E.useLayoutEffect:E.useEffect;function bD(t){const e=E.useRef(t);return ol(()=>{e.current=t}),E.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function bCe(){const t=E.useRef(null),e=E.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=E.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function _0(t,e){e===void 0&&(e=[t]);const n=E.useRef(t);return ol(()=>{n.current!==t&&(n.current=t)},e),n}function tv(t,e){const n=E.useRef();return E.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function rS(t){const e=bD(t),n=E.useRef(null),r=E.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function ER(t){const e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}let H2={};function nv(t,e){return E.useMemo(()=>{if(e)return e;const n=H2[t]==null?0:H2[t]+1;return H2[t]=n,t+"-"+n},[t,e])}function PX(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,a)=>{const o=Object.entries(a);for(const[l,c]of o){const u=s[l];u!=null&&(s[l]=u+t*c)}return s},{...e})}}const Hp=PX(1),S0=PX(-1);function yCe(t){return"clientX"in t&&"clientY"in t}function yD(t){if(!t)return!1;const{KeyboardEvent:e}=qs(t.target);return e&&t instanceof e}function _Ce(t){if(!t)return!1;const{TouchEvent:e}=qs(t.target);return e&&t instanceof e}function AR(t){if(_Ce(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 yCe(t)?{x:t.clientX,y:t.clientY}:null}const pm=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[pm.Translate.toString(t),pm.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),H6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function SCe(t){return t.matches(H6)?t:t.querySelector(H6)}const wCe={display:"none"};function MCe(t){let{id:e,value:n}=t;return ur.createElement("div",{id:e,style:wCe},n)}function ECe(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ur.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function ACe(){const[t,e]=E.useState("");return{announce:E.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const kX=E.createContext(null);function TCe(t){const e=E.useContext(kX);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function CCe(){const[t]=E.useState(()=>new Set),e=E.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[E.useCallback(r=>{let{type:i,event:s}=r;t.forEach(a=>{var o;return(o=a[i])==null?void 0:o.call(a,s)})},[t]),e]}const NCe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},RCe={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 PCe(t){let{announcements:e=RCe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=NCe}=t;const{announce:s,announcement:a}=ACe(),o=nv("DndLiveRegion"),[l,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),TCe(E.useMemo(()=>({onDragStart(h){let{active:g}=h;s(e.onDragStart({active:g}))},onDragMove(h){let{active:g,over:m}=h;e.onDragMove&&s(e.onDragMove({active:g,over:m}))},onDragOver(h){let{active:g,over:m}=h;s(e.onDragOver({active:g,over:m}))},onDragEnd(h){let{active:g,over:m}=h;s(e.onDragEnd({active:g,over:m}))},onDragCancel(h){let{active:g,over:m}=h;s(e.onDragCancel({active:g,over:m}))}}),[s,e])),!l)return null;const u=ur.createElement(ur.Fragment,null,ur.createElement(MCe,{id:r,value:i.draggable}),ur.createElement(ECe,{id:o,announcement:a}));return n?Jl.createPortal(u,n):u}var ii;(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"})(ii||(ii={}));function iS(){}function sS(t,e){return E.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function DX(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const To=Object.freeze({x:0,y:0});function OX(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function LX(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function kCe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function $6(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 IX(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function V6(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 jX=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=V6(e,e.left,e.top),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=OX(V6(l),i);s.push({id:o,data:{droppableContainer:a,value:c}})}}return s.sort(LX)},DCe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=$6(e),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=$6(l),u=i.reduce((g,m,b)=>g+OX(c[b],m),0),h=Number((u/4).toFixed(4));s.push({id:o,data:{droppableContainer:a,value:h}})}}return s.sort(LX)};function OCe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),a=i-r,o=s-n;if(r<i&&n<s){const l=e.width*e.height,c=t.width*t.height,u=a*o,h=u/(l+c-u);return Number(h.toFixed(4))}return 0}const LCe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const s of r){const{id:a}=s,o=n.get(a);if(o){const l=OCe(o,e);l>0&&i.push({id:a,data:{droppableContainer:s,value:l}})}}return i.sort(kCe)};function ICe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function UX(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:To}function jCe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return i.reduce((a,o)=>({...a,top:a.top+t*o.y,bottom:a.bottom+t*o.y,left:a.left+t*o.x,right:a.right+t*o.x}),{...n})}}const UCe=jCe(1);function FCe(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 zCe(t,e,n){const r=FCe(e);if(!r)return t;const{scaleX:i,scaleY:s,x:a,y:o}=r,l=t.left-a-(1-i)*parseFloat(n),c=t.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),u=i?t.width/i:t.width,h=s?t.height/s:t.height;return{width:u,height:h,top:c,right:l+u,bottom:c+h,left:l}}const BCe={ignoreTransform:!1};function jm(t,e){e===void 0&&(e=BCe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=qs(t).getComputedStyle(t);c&&(n=zCe(n,c,u))}const{top:r,left:i,width:s,height:a,bottom:o,right:l}=n;return{top:r,left:i,width:s,height:a,bottom:o,right:l}}function G6(t){return jm(t,{ignoreTransform:!0})}function HCe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function $Ce(t,e){return e===void 0&&(e=qs(t).getComputedStyle(t)),e.position==="fixed"}function VCe(t,e){e===void 0&&(e=qs(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=e[i];return typeof s=="string"?n.test(s):!1})}function Ow(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(vD(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!ev(i)||RX(i)||n.includes(i))return n;const s=qs(t).getComputedStyle(i);return i!==t&&VCe(i,s)&&n.push(i),$Ce(i,s)?n:r(i.parentNode)}return t?r(t):n}function FX(t){const[e]=Ow(t,1);return e??null}function $2(t){return!Dw||!t?null:Lm(t)?t:xD(t)?vD(t)||t===Im(t).scrollingElement?window:ev(t)?t:null:null}function zX(t){return Lm(t)?t.scrollX:t.scrollLeft}function BX(t){return Lm(t)?t.scrollY:t.scrollTop}function TR(t){return{x:zX(t),y:BX(t)}}var Ai;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ai||(Ai={}));function HX(t){return!Dw||!t?!1:t===document.scrollingElement}function $X(t){const e={x:0,y:0},n=HX(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,s=t.scrollLeft<=e.x,a=t.scrollTop>=r.y,o=t.scrollLeft>=r.x;return{isTop:i,isLeft:s,isBottom:a,isRight:o,maxScroll:r,minScroll:e}}const GCe={x:.2,y:.2};function WCe(t,e,n,r,i){let{top:s,left:a,right:o,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=GCe);const{isTop:c,isBottom:u,isLeft:h,isRight:g}=$X(t),m={x:0,y:0},b={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!c&&s<=e.top+y.height?(m.y=Ai.Backward,b.y=r*Math.abs((e.top+y.height-s)/y.height)):!u&&l>=e.bottom-y.height&&(m.y=Ai.Forward,b.y=r*Math.abs((e.bottom-y.height-l)/y.height)),!g&&o>=e.right-y.width?(m.x=Ai.Forward,b.x=r*Math.abs((e.right-y.width-o)/y.width)):!h&&a<=e.left+y.width&&(m.x=Ai.Backward,b.x=r*Math.abs((e.left+y.width-a)/y.width)),{direction:m,speed:b}}function qCe(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function VX(t){return t.reduce((e,n)=>Hp(e,TR(n)),To)}function XCe(t){return t.reduce((e,n)=>e+zX(n),0)}function KCe(t){return t.reduce((e,n)=>e+BX(n),0)}function YCe(t,e){if(e===void 0&&(e=jm),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);FX(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const ZCe=[["x",["left","right"],XCe],["y",["top","bottom"],KCe]];class _D{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=Ow(n),i=VX(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,o]of ZCe)for(const l of a)Object.defineProperty(this,l,{get:()=>{const c=o(r),u=i[s]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Hx{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 QCe(t){const{EventTarget:e}=qs(t);return t instanceof e?t:Im(t)}function V2(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 ja;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ja||(ja={}));function W6(t){t.preventDefault()}function JCe(t){t.stopPropagation()}var _n;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(_n||(_n={}));const GX={start:[_n.Space,_n.Enter],cancel:[_n.Esc],end:[_n.Space,_n.Enter,_n.Tab]},eNe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case _n.Right:return{...n,x:n.x+25};case _n.Left:return{...n,x:n.x-25};case _n.Down:return{...n,y:n.y+25};case _n.Up:return{...n,y:n.y-25}}};class Lw{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 Hx(Im(n)),this.windowListeners=new Hx(qs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ja.Resize,this.handleCancel),this.windowListeners.add(ja.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ja.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&YCe(r),n(To)}handleKeyDown(e){if(yD(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=GX,coordinateGetter:a=eNe,scrollBehavior:o="smooth"}=i,{code:l}=e;if(s.end.includes(l)){this.handleEnd(e);return}if(s.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:To;this.referenceCoordinates||(this.referenceCoordinates=u);const h=a(e,{active:n,context:r.current,currentCoordinates:u});if(h){const g=S0(h,u),m={x:0,y:0},{scrollableAncestors:b}=r.current;for(const y of b){const v=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:T,maxScroll:A,minScroll:P}=$X(y),C=qCe(y),j={x:Math.min(v===_n.Right?C.right-C.width/2:C.right,Math.max(v===_n.Right?C.left:C.left+C.width/2,h.x)),y:Math.min(v===_n.Down?C.bottom-C.height/2:C.bottom,Math.max(v===_n.Down?C.top:C.top+C.height/2,h.y))},N=v===_n.Right&&!M||v===_n.Left&&!w,k=v===_n.Down&&!T||v===_n.Up&&!x;if(N&&j.x!==h.x){const F=y.scrollLeft+g.x,I=v===_n.Right&&F<=A.x||v===_n.Left&&F>=P.x;if(I&&!g.y){y.scrollTo({left:F,behavior:o});return}I?m.x=y.scrollLeft-F:m.x=v===_n.Right?y.scrollLeft-A.x:y.scrollLeft-P.x,m.x&&y.scrollBy({left:-m.x,behavior:o});break}else if(k&&j.y!==h.y){const F=y.scrollTop+g.y,I=v===_n.Down&&F<=A.y||v===_n.Up&&F>=P.y;if(I&&!g.x){y.scrollTo({top:F,behavior:o});return}I?m.y=y.scrollTop-F:m.y=v===_n.Down?y.scrollTop-A.y:y.scrollTop-P.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,Hp(S0(h,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Lw.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=GX,onActivation:i}=e,{active:s}=n;const{code:a}=t.nativeEvent;if(r.start.includes(a)){const o=s.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function q6(t){return!!(t&&"distance"in t)}function X6(t){return!!(t&&"delay"in t)}class SD{constructor(e,n,r){var i;r===void 0&&(r=QCe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:s}=e,{target:a}=s;this.props=e,this.events=n,this.document=Im(a),this.documentListeners=new Hx(this.document),this.listeners=new Hx(r),this.windowListeners=new Hx(qs(a)),this.initialCoordinates=(i=AR(s))!=null?i:To,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(ja.Resize,this.handleCancel),this.windowListeners.add(ja.DragStart,W6),this.windowListeners.add(ja.VisibilityChange,this.handleCancel),this.windowListeners.add(ja.ContextMenu,W6),this.documentListeners.add(ja.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(X6(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(q6(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(ja.Click,JCe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ja.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:s}=this,{onMove:a,options:{activationConstraint:o}}=s;if(!i)return;const l=(n=AR(e))!=null?n:To,c=S0(i,l);if(!r&&o){if(q6(o)){if(o.tolerance!=null&&V2(c,o.tolerance))return this.handleCancel();if(V2(c,o.distance))return this.handleStart()}if(X6(o)&&V2(c,o.tolerance))return this.handleCancel();this.handlePending(o,c);return}e.cancelable&&e.preventDefault(),a(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===_n.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const tNe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Iw extends SD{constructor(e){const{event:n}=e,r=Im(n.target);super(e,tNe,r)}}Iw.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 nNe={move:{name:"mousemove"},end:{name:"mouseup"}};var CR;(function(t){t[t.RightClick=2]="RightClick"})(CR||(CR={}));class rNe extends SD{constructor(e){super(e,nNe,Im(e.event.target))}}rNe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===CR.RightClick?!1:(r?.({event:n}),!0)}}];const G2={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class iNe extends SD{constructor(e){super(e,G2)}static setup(){return window.addEventListener(G2.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(G2.move.name,e)};function e(){}}}iNe.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 $x;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})($x||($x={}));var aS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(aS||(aS={}));function sNe(t){let{acceleration:e,activator:n=$x.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:a=5,order:o=aS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:h,threshold:g}=t;const m=oNe({delta:h,disabled:!s}),[b,y]=bCe(),v=E.useRef({x:0,y:0}),x=E.useRef({x:0,y:0}),M=E.useMemo(()=>{switch(n){case $x.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case $x.DraggableRect:return i}},[n,i,l]),w=E.useRef(null),T=E.useCallback(()=>{const P=w.current;if(!P)return;const C=v.current.x*x.current.x,j=v.current.y*x.current.y;P.scrollBy(C,j)},[]),A=E.useMemo(()=>o===aS.TreeOrder?[...c].reverse():c,[o,c]);E.useEffect(()=>{if(!s||!c.length||!M){y();return}for(const P of A){if(r?.(P)===!1)continue;const C=c.indexOf(P),j=u[C];if(!j)continue;const{direction:N,speed:k}=WCe(P,j,M,e,g);for(const F of["x","y"])m[F][N[F]]||(k[F]=0,N[F]=0);if(k.x>0||k.y>0){y(),w.current=P,b(T,a),v.current=k,x.current=N;return}}v.current={x:0,y:0},x.current={x:0,y:0},y()},[e,T,r,y,s,a,JSON.stringify(M),JSON.stringify(m),b,c,A,u,JSON.stringify(g)])}const aNe={x:{[Ai.Backward]:!1,[Ai.Forward]:!1},y:{[Ai.Backward]:!1,[Ai.Forward]:!1}};function oNe(t){let{delta:e,disabled:n}=t;const r=ER(e);return tv(i=>{if(n||!r||!i)return aNe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ai.Backward]:i.x[Ai.Backward]||s.x===-1,[Ai.Forward]:i.x[Ai.Forward]||s.x===1},y:{[Ai.Backward]:i.y[Ai.Backward]||s.y===-1,[Ai.Forward]:i.y[Ai.Forward]||s.y===1}}},[n,e,r])}function lNe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return tv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function cNe(t,e){return E.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,s=i.activators.map(a=>({eventName:a.eventName,handler:e(a.handler,r)}));return[...n,...s]},[]),[t,e])}var w0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(w0||(w0={}));var NR;(function(t){t.Optimized="optimized"})(NR||(NR={}));const K6=new Map;function uNe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,a]=E.useState(null),{frequency:o,measure:l,strategy:c}=i,u=E.useRef(t),h=v(),g=_0(h),m=E.useCallback(function(x){x===void 0&&(x=[]),!g.current&&a(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[g]),b=E.useRef(null),y=tv(x=>{if(h&&!n)return K6;if(!x||x===K6||u.current!==t||s!=null){const M=new Map;for(let w of t){if(!w)continue;if(s&&s.length>0&&!s.includes(w.id)&&w.rect.current){M.set(w.id,w.rect.current);continue}const T=w.node.current,A=T?new _D(l(T),T):null;w.rect.current=A,A&&M.set(w.id,A)}return M}return x},[t,s,n,h,l]);return E.useEffect(()=>{u.current=t},[t]),E.useEffect(()=>{h||m()},[n,h]),E.useEffect(()=>{s&&s.length>0&&a(null)},[JSON.stringify(s)]),E.useEffect(()=>{h||typeof o!="number"||b.current!==null||(b.current=setTimeout(()=>{m(),b.current=null},o))},[o,h,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:s!=null};function v(){switch(c){case w0.Always:return!1;case w0.BeforeDragging:return n;default:return!n}}}function WX(t,e){return tv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function dNe(t,e){return WX(t,e)}function fNe(t){let{callback:e,disabled:n}=t;const r=bD(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function jw(t){let{callback:e,disabled:n}=t;const r=bD(e),i=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return E.useEffect(()=>()=>i?.disconnect(),[i]),i}function hNe(t){return new _D(jm(t),t)}function Y6(t,e,n){e===void 0&&(e=hNe);const[r,i]=E.useState(null);function s(){i(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const a=fNe({callback(l){if(t)for(const c of l){const{type:u,target:h}=c;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),o=jw({callback:s});return ol(()=>{s(),t?(o?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),a?.disconnect())},[t]),r}function pNe(t){const e=WX(t);return UX(t,e)}const Z6=[];function mNe(t){const e=E.useRef(t),n=tv(r=>t?r&&r!==Z6&&t&&e.current&&t.parentNode===e.current.parentNode?r:Ow(t):Z6,[t]);return E.useEffect(()=>{e.current=t},[t]),n}function gNe(t){const[e,n]=E.useState(null),r=E.useRef(t),i=E.useCallback(s=>{const a=$2(s.target);a&&n(o=>o?(o.set(a,TR(a)),new Map(o)):null)},[]);return E.useEffect(()=>{const s=r.current;if(t!==s){a(s);const o=t.map(l=>{const c=$2(l);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,TR(c)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),r.current=t}return()=>{a(t),a(s)};function a(o){o.forEach(l=>{const c=$2(l);c?.removeEventListener("scroll",i)})}},[i,t]),E.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,a)=>Hp(s,a),To):VX(t):To,[t,e])}function Q6(t,e){e===void 0&&(e=[]);const n=E.useRef(null);return E.useEffect(()=>{n.current=null},e),E.useEffect(()=>{const r=t!==To;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?S0(t,n.current):To}function xNe(t){E.useEffect(()=>{if(!Dw)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 vNe(t,e){return E.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=a=>{s(a,e)},n},{}),[t,e])}function qX(t){return E.useMemo(()=>t?HCe(t):null,[t])}const J6=[];function bNe(t,e){e===void 0&&(e=jm);const[n]=t,r=qX(n?qs(n):null),[i,s]=E.useState(J6);function a(){s(()=>t.length?t.map(l=>HX(l)?r:new _D(e(l),l)):J6)}const o=jw({callback:a});return ol(()=>{o?.disconnect(),a(),t.forEach(l=>o?.observe(l))},[t]),i}function yNe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return ev(e)?e:t}function _Ne(t){let{measure:e}=t;const[n,r]=E.useState(null),i=E.useCallback(c=>{for(const{target:u}of c)if(ev(u)){r(h=>{const g=e(u);return h?{...h,width:g.width,height:g.height}:g});break}},[e]),s=jw({callback:i}),a=E.useCallback(c=>{const u=yNe(c);s?.disconnect(),u&&s?.observe(u),r(u?e(u):null)},[e,s]),[o,l]=rS(a);return E.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const SNe=[{sensor:Iw,options:{}},{sensor:Lw,options:{}}],wNe={current:{}},F_={draggable:{measure:G6},droppable:{measure:G6,strategy:w0.WhileDragging,frequency:NR.Optimized},dragOverlay:{measure:jm}};class Vx 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 MNe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Vx,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:iS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:F_,measureDroppableContainers:iS,windowRect:null,measuringScheduled:!1},ENe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:iS,draggableNodes:new Map,over:null,measureDroppableContainers:iS},Uw=E.createContext(ENe),XX=E.createContext(MNe);function ANe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Vx}}}function TNe(t,e){switch(e.type){case ii.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ii.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 ii.DragEnd:case ii.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ii.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Vx(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ii.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const a=new Vx(t.droppable.containers);return a.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case ii.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new Vx(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function CNe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=E.useContext(Uw),s=ER(r),a=ER(n?.id);return E.useEffect(()=>{if(!e&&!r&&s&&a!=null){if(!yD(s)||document.activeElement===s.target)return;const o=i.get(a);if(!o)return;const{activatorNode:l,node:c}=o;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const h=SCe(u);if(h){h.focus();break}}})}},[r,e,i,a,s]),null}function NNe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function RNe(t){return E.useMemo(()=>({draggable:{...F_.draggable,...t?.draggable},droppable:{...F_.droppable,...t?.droppable},dragOverlay:{...F_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function PNe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=E.useRef(!1),{x:a,y:o}=typeof i=="boolean"?{x:i,y:i}:i;ol(()=>{if(!a&&!o||!e){s.current=!1;return}if(s.current||!r)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),h=UX(u,r);if(a||(h.x=0),o||(h.y=0),s.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const g=FX(c);g&&g.scrollBy({top:h.y,left:h.x})}},[e,a,o,r,n])}const KX=E.createContext({...To,scaleX:1,scaleY:1});var Mu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Mu||(Mu={}));const YX=E.memo(function(e){var n,r,i,s;let{id:a,accessibility:o,autoScroll:l=!0,children:c,sensors:u=SNe,collisionDetection:h=LCe,measuring:g,modifiers:m,...b}=e;const y=E.useReducer(TNe,void 0,ANe),[v,x]=y,[M,w]=CCe(),[T,A]=E.useState(Mu.Uninitialized),P=T===Mu.Initialized,{draggable:{active:C,nodes:j,translate:N},droppable:{containers:k}}=v,F=C!=null?j.get(C):null,I=E.useRef({initial:null,translated:null}),W=E.useMemo(()=>{var Ie;return C!=null?{id:C,data:(Ie=F?.data)!=null?Ie:wNe,rect:I}:null},[C,F]),D=E.useRef(null),[$,G]=E.useState(null),[V,Z]=E.useState(null),K=_0(b,Object.values(b)),ee=nv("DndDescribedBy",a),H=E.useMemo(()=>k.getEnabled(),[k]),Y=RNe(g),{droppableRects:te,measureDroppableContainers:ae,measuringScheduled:fe}=uNe(H,{dragging:P,dependencies:[N.x,N.y],config:Y.droppable}),Q=lNe(j,C),me=E.useMemo(()=>V?AR(V):null,[V]),Ee=ge(),he=dNe(Q,Y.draggable.measure);PNe({activeNode:C!=null?j.get(C):null,config:Ee.layoutShiftCompensation,initialRect:he,measure:Y.draggable.measure});const we=Y6(Q,Y.draggable.measure,he),De=Y6(Q?Q.parentElement:null),de=E.useRef({activatorEvent:null,active:null,activeNode:Q,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Le=k.getNodeFor((n=de.current.over)==null?void 0:n.id),B=_Ne({measure:Y.dragOverlay.measure}),z=(r=B.nodeRef.current)!=null?r:Q,ie=P?(i=B.rect)!=null?i:we:null,X=!!(B.nodeRef.current&&B.rect),J=pNe(X?null:we),le=qX(z?qs(z):null),Re=mNe(P?Le??Q:null),Ae=bNe(Re),se=NNe(m,{transform:{x:N.x-J.x,y:N.y-J.y,scaleX:1,scaleY:1},activatorEvent:V,active:W,activeNodeRect:we,containerNodeRect:De,draggingNodeRect:ie,over:de.current.over,overlayNodeRect:B.rect,scrollableAncestors:Re,scrollableAncestorRects:Ae,windowRect:le}),U=me?Hp(me,N):null,L=gNe(Re),ne=Q6(L),ve=Q6(L,[we]),ye=Hp(se,ne),xe=ie?UCe(ie,se):null,tt=W&&xe?h({active:W,collisionRect:xe,droppableRects:te,droppableContainers:H,pointerCoordinates:U}):null,je=IX(tt,"id"),[Ye,ot]=E.useState(null),Fe=X?se:Hp(se,ve),ce=ICe(Fe,(s=Ye?.rect)!=null?s:null,we),Qe=E.useRef(null),Be=E.useCallback((Ie,Te)=>{let{sensor:be,options:Ve}=Te;if(D.current==null)return;const ft=j.get(D.current);if(!ft)return;const yt=Ie.nativeEvent,Pt=new be({active:D.current,activeNode:ft,event:yt,options:Ve,context:de,onAbort(Ot){if(!j.get(Ot))return;const{onDragAbort:qn}=K.current,gi={id:Ot};qn?.(gi),M({type:"onDragAbort",event:gi})},onPending(Ot,Pn,qn,gi){if(!j.get(Ot))return;const{onDragPending:xi}=K.current,Di={id:Ot,constraint:Pn,initialCoordinates:qn,offset:gi};xi?.(Di),M({type:"onDragPending",event:Di})},onStart(Ot){const Pn=D.current;if(Pn==null)return;const qn=j.get(Pn);if(!qn)return;const{onDragStart:gi}=K.current,Jr={activatorEvent:yt,active:{id:Pn,data:qn.data,rect:I}};Jl.unstable_batchedUpdates(()=>{gi?.(Jr),A(Mu.Initializing),x({type:ii.DragStart,initialCoordinates:Ot,active:Pn}),M({type:"onDragStart",event:Jr}),G(Qe.current),Z(yt)})},onMove(Ot){x({type:ii.DragMove,coordinates:Ot})},onEnd:cn(ii.DragEnd),onCancel:cn(ii.DragCancel)});Qe.current=Pt;function cn(Ot){return async function(){const{active:qn,collisions:gi,over:Jr,scrollAdjustedTranslate:xi}=de.current;let Di=null;if(qn&&xi){const{cancelDrop:Yi}=K.current;Di={activatorEvent:yt,active:qn,collisions:gi,delta:xi,over:Jr},Ot===ii.DragEnd&&typeof Yi=="function"&&await Promise.resolve(Yi(Di))&&(Ot=ii.DragCancel)}D.current=null,Jl.unstable_batchedUpdates(()=>{x({type:Ot}),A(Mu.Uninitialized),ot(null),G(null),Z(null),Qe.current=null;const Yi=Ot===ii.DragEnd?"onDragEnd":"onDragCancel";if(Di){const jr=K.current[Yi];jr?.(Di),M({type:Yi,event:Di})}})}}},[j]),Ke=E.useCallback((Ie,Te)=>(be,Ve)=>{const ft=be.nativeEvent,yt=j.get(Ve);if(D.current!==null||!yt||ft.dndKit||ft.defaultPrevented)return;const Pt={active:yt};Ie(be,Te.options,Pt)===!0&&(ft.dndKit={capturedBy:Te.sensor},D.current=Ve,Be(be,Te))},[j,Be]),ct=cNe(u,Ke);xNe(u),ol(()=>{we&&T===Mu.Initializing&&A(Mu.Initialized)},[we,T]),E.useEffect(()=>{const{onDragMove:Ie}=K.current,{active:Te,activatorEvent:be,collisions:Ve,over:ft}=de.current;if(!Te||!be)return;const yt={active:Te,activatorEvent:be,collisions:Ve,delta:{x:ye.x,y:ye.y},over:ft};Jl.unstable_batchedUpdates(()=>{Ie?.(yt),M({type:"onDragMove",event:yt})})},[ye.x,ye.y]),E.useEffect(()=>{const{active:Ie,activatorEvent:Te,collisions:be,droppableContainers:Ve,scrollAdjustedTranslate:ft}=de.current;if(!Ie||D.current==null||!Te||!ft)return;const{onDragOver:yt}=K.current,Pt=Ve.get(je),cn=Pt&&Pt.rect.current?{id:Pt.id,rect:Pt.rect.current,data:Pt.data,disabled:Pt.disabled}:null,Ot={active:Ie,activatorEvent:Te,collisions:be,delta:{x:ft.x,y:ft.y},over:cn};Jl.unstable_batchedUpdates(()=>{ot(cn),yt?.(Ot),M({type:"onDragOver",event:Ot})})},[je]),ol(()=>{de.current={activatorEvent:V,active:W,activeNode:Q,collisionRect:xe,collisions:tt,droppableRects:te,draggableNodes:j,draggingNode:z,draggingNodeRect:ie,droppableContainers:k,over:Ye,scrollableAncestors:Re,scrollAdjustedTranslate:ye},I.current={initial:ie,translated:xe}},[W,Q,tt,xe,j,z,ie,te,k,Ye,Re,ye]),sNe({...Ee,delta:N,draggingRect:xe,pointerCoordinates:U,scrollableAncestors:Re,scrollableAncestorRects:Ae});const ue=E.useMemo(()=>({active:W,activeNode:Q,activeNodeRect:we,activatorEvent:V,collisions:tt,containerNodeRect:De,dragOverlay:B,draggableNodes:j,droppableContainers:k,droppableRects:te,over:Ye,measureDroppableContainers:ae,scrollableAncestors:Re,scrollableAncestorRects:Ae,measuringConfiguration:Y,measuringScheduled:fe,windowRect:le}),[W,Q,we,V,tt,De,B,j,k,te,Ye,ae,Re,Ae,Y,fe,le]),Je=E.useMemo(()=>({activatorEvent:V,activators:ct,active:W,activeNodeRect:we,ariaDescribedById:{draggable:ee},dispatch:x,draggableNodes:j,over:Ye,measureDroppableContainers:ae}),[V,ct,W,we,x,ee,j,Ye,ae]);return ur.createElement(kX.Provider,{value:w},ur.createElement(Uw.Provider,{value:Je},ur.createElement(XX.Provider,{value:ue},ur.createElement(KX.Provider,{value:ce},c)),ur.createElement(CNe,{disabled:o?.restoreFocus===!1})),ur.createElement(PCe,{...o,hiddenTextDescribedById:ee}));function ge(){const Ie=$?.autoScrollEnabled===!1,Te=typeof l=="object"?l.enabled===!1:l===!1,be=P&&!Ie&&!Te;return typeof l=="object"?{...l,enabled:be}:{enabled:be}}}),kNe=E.createContext(null),e8="button",DNe="Draggable";function ONe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=nv(DNe),{activators:a,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:h,over:g}=E.useContext(Uw),{role:m=e8,roleDescription:b="draggable",tabIndex:y=0}=i??{},v=l?.id===e,x=E.useContext(v?KX:kNe),[M,w]=rS(),[T,A]=rS(),P=vNe(a,e),C=_0(n);ol(()=>(h.set(e,{id:e,key:s,node:M,activatorNode:T,data:C}),()=>{const N=h.get(e);N&&N.key===s&&h.delete(e)}),[h,e]);const j=E.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&m===e8?!0:void 0,"aria-roledescription":b,"aria-describedby":u.draggable}),[r,m,y,v,b,u.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:j,isDragging:v,listeners:r?void 0:P,node:M,over:g,setNodeRef:w,setActivatorNodeRef:A,transform:x}}function LNe(){return E.useContext(XX)}const INe="Droppable",jNe={timeout:25};function UNe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=nv(INe),{active:a,dispatch:o,over:l,measureDroppableContainers:c}=E.useContext(Uw),u=E.useRef({disabled:n}),h=E.useRef(!1),g=E.useRef(null),m=E.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:v}={...jNe,...i},x=_0(y??r),M=E.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),m.current=null},v)},[v]),w=jw({callback:M,disabled:b||!a}),T=E.useCallback((j,N)=>{w&&(N&&(w.unobserve(N),h.current=!1),j&&w.observe(j))},[w]),[A,P]=rS(T),C=_0(e);return E.useEffect(()=>{!w||!A.current||(w.disconnect(),h.current=!1,w.observe(A.current))},[A,w]),E.useEffect(()=>(o({type:ii.RegisterDroppable,element:{id:r,key:s,disabled:n,node:A,rect:g,data:C}}),()=>o({type:ii.UnregisterDroppable,key:s,id:r})),[r]),E.useEffect(()=>{n!==u.current.disabled&&(o({type:ii.SetDroppableDisabled,id:r,key:s,disabled:n}),u.current.disabled=n)},[r,s,n,o]),{active:a,rect:g,isOver:l?.id===r,node:A,over:l,setNodeRef:P}}function Fw(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function FNe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function Jy(t){return t!==null&&t>=0}function zNe(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 BNe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const wD=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=Fw(e,r,n),a=e[i],o=s[i];return!o||!a?null:{x:o.left-a.left,y:o.top-a.top,scaleX:o.width/a.width,scaleY:o.height/a.height}},e_={scaleX:1,scaleY:1},HNe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:s,overIndex:a}=t;const o=(e=s[n])!=null?e:r;if(!o)return null;if(i===n){const c=s[a];return c?{x:0,y:n<a?c.top+c.height-(o.top+o.height):c.top-o.top,...e_}:null}const l=$Ne(s,i,n);return i>n&&i<=a?{x:0,y:-o.height-l,...e_}:i<n&&i>=a?{x:0,y:o.height+l,...e_}:{x:0,y:0,...e_}};function $Ne(t,e,n){const r=t[e],i=t[e-1],s=t[e+1];return r?n<e?i?r.top-(i.top+i.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const ZX="Sortable",QX=ur.createContext({activeIndex:-1,containerId:ZX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:wD,disabled:{draggable:!1,droppable:!1}});function JX(t){let{children:e,id:n,items:r,strategy:i=wD,disabled:s=!1}=t;const{active:a,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:u}=LNe(),h=nv(ZX,n),g=o.rect!==null,m=E.useMemo(()=>r.map(P=>typeof P=="object"&&"id"in P?P.id:P),[r]),b=a!=null,y=a?m.indexOf(a.id):-1,v=c?m.indexOf(c.id):-1,x=E.useRef(m),M=!zNe(m,x.current),w=v!==-1&&y===-1||M,T=BNe(s);ol(()=>{M&&b&&u(m)},[M,m,b,u]),E.useEffect(()=>{x.current=m},[m]);const A=E.useMemo(()=>({activeIndex:y,containerId:h,disabled:T,disableTransforms:w,items:m,overIndex:v,useDragOverlay:g,sortedRects:FNe(m,l),strategy:i}),[y,h,T.draggable,T.droppable,w,m,v,l,g,i]);return ur.createElement(QX.Provider,{value:A},e)}const VNe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return Fw(n,r,i).indexOf(e)},GNe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:a,previousItems:o,previousContainerId:l,transition:c}=t;return!c||!r||o!==s&&i===a?!1:n?!0:a!==i&&e===l},WNe={duration:200,easing:"ease"},eK="transform",qNe=pm.Transition.toString({property:eK,duration:0,easing:"linear"}),XNe={roleDescription:"sortable"};function KNe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,a]=E.useState(null),o=E.useRef(n);return ol(()=>{if(!e&&n!==o.current&&r.current){const l=i.current;if(l){const c=jm(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&a(u)}}n!==o.current&&(o.current=n)},[e,n,r,i]),E.useEffect(()=>{s&&a(null)},[s]),s}function tK(t){let{animateLayoutChanges:e=GNe,attributes:n,disabled:r,data:i,getNewIndex:s=VNe,id:a,strategy:o,resizeObserverConfig:l,transition:c=WNe}=t;const{items:u,containerId:h,activeIndex:g,disabled:m,disableTransforms:b,sortedRects:y,overIndex:v,useDragOverlay:x,strategy:M}=E.useContext(QX),w=YNe(r,m),T=u.indexOf(a),A=E.useMemo(()=>({sortable:{containerId:h,index:T,items:u},...i}),[h,i,T,u]),P=E.useMemo(()=>u.slice(u.indexOf(a)),[u,a]),{rect:C,node:j,isOver:N,setNodeRef:k}=UNe({id:a,data:A,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:P,...l}}),{active:F,activatorEvent:I,activeNodeRect:W,attributes:D,setNodeRef:$,listeners:G,isDragging:V,over:Z,setActivatorNodeRef:K,transform:ee}=ONe({id:a,data:A,attributes:{...XNe,...n},disabled:w.draggable}),H=vCe(k,$),Y=!!F,te=Y&&!b&&Jy(g)&&Jy(v),ae=!x&&V,fe=ae&&te?ee:null,me=te?fe??(o??M)({rects:y,activeNodeRect:W,activeIndex:g,overIndex:v,index:T}):null,Ee=Jy(g)&&Jy(v)?s({id:a,items:u,activeIndex:g,overIndex:v}):T,he=F?.id,we=E.useRef({activeId:he,items:u,newIndex:Ee,containerId:h}),De=u!==we.current.items,de=e({active:F,containerId:h,isDragging:V,isSorting:Y,id:a,index:T,items:u,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:c,wasDragging:we.current.activeId!=null}),Le=KNe({disabled:!de,index:T,node:j,rect:C});return E.useEffect(()=>{Y&&we.current.newIndex!==Ee&&(we.current.newIndex=Ee),h!==we.current.containerId&&(we.current.containerId=h),u!==we.current.items&&(we.current.items=u)},[Y,Ee,h,u]),E.useEffect(()=>{if(he===we.current.activeId)return;if(he!=null&&we.current.activeId==null){we.current.activeId=he;return}const z=setTimeout(()=>{we.current.activeId=he},50);return()=>clearTimeout(z)},[he]),{active:F,activeIndex:g,attributes:D,data:A,rect:C,index:T,newIndex:Ee,items:u,isOver:N,isSorting:Y,isDragging:V,listeners:G,node:j,overIndex:v,over:Z,setNodeRef:H,setActivatorNodeRef:K,setDroppableNodeRef:k,setDraggableNodeRef:$,transform:Le??me,transition:B()};function B(){if(Le||De&&we.current.newIndex===T)return qNe;if(!(ae&&!yD(I)||!c)&&(Y||de))return pm.Transition.toString({...c,property:eK})}}function YNe(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 oS(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 ZNe=[_n.Down,_n.Right,_n.Up,_n.Left],nK=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:a,scrollableAncestors:o}}=e;if(ZNe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const g=i.get(h.id);if(g)switch(t.code){case _n.Down:r.top<g.top&&l.push(h);break;case _n.Up:r.top>g.top&&l.push(h);break;case _n.Left:r.left>g.left&&l.push(h);break;case _n.Right:r.left<g.left&&l.push(h);break}});const c=DCe({collisionRect:r,droppableRects:i,droppableContainers:l});let u=IX(c,"id");if(u===a?.id&&c.length>1&&(u=c[1].id),u!=null){const h=s.get(n.id),g=s.get(u),m=g?i.get(g.id):null,b=g?.node.current;if(b&&m&&h&&g){const v=Ow(b).some((P,C)=>o[C]!==P),x=rK(h,g),M=QNe(h,g),w=v||!x?{x:0,y:0}:{x:M?r.width-m.width:0,y:M?r.height-m.height:0},T={x:m.left,y:m.top};return w.x&&w.y?T:S0(T,w)}}}};function rK(t,e){return!oS(t)||!oS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function QNe(t,e){return!oS(t)||!oS(e)||!rK(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function JNe({item:t,onClose:e}){const n=Rn(),{showToast:r}=Ki(),[i,s]=E.useState(t.printer_id),a=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,l]=E.useState(t.scheduled_time&&!a?"scheduled":"asap"),[c,u]=E.useState(()=>t.scheduled_time&&!a?new Date(t.scheduled_time).toISOString().slice(0,16):""),[h,g]=E.useState(t.require_previous_success),[m,b]=E.useState(t.auto_off_after),{data:y}=At({queryKey:["printers"],queryFn:()=>Ue.getPrinters()});E.useEffect(()=>{const w=T=>{T.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const v=Tt({mutationFn:w=>Ue.updateQueueItem(t.id,w),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:w=>{r(w.message||"Failed to update queue item","error")}}),x=w=>{w.preventDefault();const T={printer_id:i,require_previous_success:h,auto_off_after:m};o==="scheduled"&&c?T.scheduled_time=new Date(c).toISOString():T.scheduled_time=null,v.mutate(T)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:f.jsx(Ft,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:f.jsxs($t,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Cf,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),f.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?f.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[f.jsx(Eo,{className:"w-4 h-4"}),"No printers configured"]}):f.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:w=>s(Number(w.target.value)),required:!0,children:y?.map(w=>f.jsx("option",{value:w.id,children:w.name},w.id))})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[f.jsx(Pi,{className:"w-4 h-4"}),"ASAP (when idle)"]}),f.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[f.jsx(as,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),f.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:w=>u(w.target.value),min:M(),required:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"requirePrevious",checked:h,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>b(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),f.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[f.jsx(Xf,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),f.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."}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsx(We,{type:"submit",className:"flex-1",disabled:v.isPending||y?.length===0,children:v.isPending?"Saving...":"Save Changes"})]})]})]})})})}function iK(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 e3e(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 t3e({status:t}){const e={pending:{icon:Pi,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:aw,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:mc,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:V0,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:v9,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:tn,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return f.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[f.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function W2({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:a}){const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:h,isDragging:g}=tK({id:t.id,disabled:t.status!=="pending"}),m={transform:pm.Transform.toString(u),transition:h},b=t.status==="printing",y=t.status==="pending",v=["completed","failed","skipped","cancelled"].includes(t.status);return f.jsx("div",{ref:c,style:m,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${b?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:f.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?f.jsx("div",{...o,...l,className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors",children:f.jsx(QP,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?f.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]}):f.jsx("div",{className:"w-8"}),f.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?f.jsx("img",{src:Ue.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):f.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:f.jsx(Tf,{className:"w-6 h-6"})})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),f.jsx(iw,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:f.jsx(gc,{className:"w-3.5 h-3.5"})})]}),f.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(nl,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(ku,{className:"w-3.5 h-3.5"}),iK(t.print_time_seconds)]}),y&&f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(Pi,{className:"w-3.5 h-3.5"}),e3e(t.scheduled_time)]})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&f.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&&f.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:[f.jsx(Xf,{className:"w-3 h-3"}),"Auto power off"]})]}),b&&f.jsxs("div",{className:"mt-3",children:[f.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&f.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[f.jsx(Eo,{className:"w-3 h-3"}),t.error_message]})]}),f.jsx(t3e,{status:t.status}),f.jsxs("div",{className:"flex items-center gap-1",children:[b&&f.jsx(We,{variant:"ghost",size:"sm",onClick:s,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:f.jsx(_ae,{className:"w-4 h-4"})}),y&&f.jsxs(f.Fragment,{children:[f.jsx(We,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:f.jsx(Cf,{className:"w-4 h-4"})}),f.jsx(We,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:f.jsx(tn,{className:"w-4 h-4"})})]}),v&&f.jsxs(f.Fragment,{children:[f.jsx(We,{variant:"ghost",size:"sm",onClick:a,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:f.jsx(Ka,{className:"w-4 h-4"})}),f.jsx(We,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:f.jsx(fr,{className:"w-4 h-4"})})]})]})]})})}function n3e(){const t=Rn(),{showToast:e}=Ki(),[n,r]=E.useState(null),[i,s]=E.useState(""),[a,o]=E.useState(!1),[l,c]=E.useState(null),[u,h]=E.useState(null),[g,m]=E.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[b,y]=E.useState(()=>{const K=localStorage.getItem("queue.historySortAsc");return K!==null?K==="true":!1}),[v,x]=E.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[M,w]=E.useState(()=>{const K=localStorage.getItem("queue.pendingSortAsc");return K!==null?K==="true":!0});E.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),E.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(b))},[b]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",v)},[v]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(M))},[M]);const T=DX(sS(Iw,{activationConstraint:{distance:8}}),sS(Lw,{coordinateGetter:nK})),{data:A,isLoading:P}=At({queryKey:["queue",n,i],queryFn:()=>Ue.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:C}=At({queryKey:["printers"],queryFn:()=>Ue.getPrinters()}),j=Tt({mutationFn:K=>Ue.cancelQueueItem(K),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),N=Tt({mutationFn:K=>Ue.removeFromQueue(K),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),k=Tt({mutationFn:K=>Ue.stopQueueItem(K),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=Tt({mutationFn:K=>Ue.reorderQueue(K),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),I=Tt({mutationFn:K=>{const ee=new Date;return ee.setFullYear(ee.getFullYear()+1),Ue.addToQueue({printer_id:K.printer_id,archive_id:K.archive_id,scheduled_time:ee.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:K=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),c(K)},onError:K=>e(K.message||"Failed to re-queue item","error")}),W=Tt({mutationFn:async()=>{const K=A?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[];for(const ee of K)await Ue.removeFromQueue(ee.id);return K.length},onSuccess:K=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${K} history item${K!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),D=E.useMemo(()=>{const K=A?.filter(H=>H.status==="pending")||[],ee=H=>{if(!H.scheduled_time)return 0;const Y=new Date(H.scheduled_time).getTime(),te=Date.now()+4320*60*60*1e3;return Y>te?0:Y};return[...K].sort((H,Y)=>{let te;return v==="name"?te=(H.archive_name||"").localeCompare(Y.archive_name||""):v==="printer"?te=(H.printer_name||"").localeCompare(Y.printer_name||""):v==="time"?te=ee(H)-ee(Y):te=H.position-Y.position,M?te:-te})},[A,v,M]),$=A?.filter(K=>K.status==="printing")||[],G=E.useMemo(()=>[...A?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[]].sort((ee,H)=>{let Y;return g==="name"?Y=(ee.archive_name||"").localeCompare(H.archive_name||""):g==="printer"?Y=(ee.printer_name||"").localeCompare(H.printer_name||""):Y=new Date(H.completed_at||H.created_at).getTime()-new Date(ee.completed_at||ee.created_at).getTime(),b?-Y:Y}),[A,g,b]),V=E.useMemo(()=>D.reduce((K,ee)=>K+(ee.print_time_seconds||0),0),[D]),Z=K=>{const{active:ee,over:H}=K;if(!H||ee.id===H.id)return;const Y=D.findIndex(ae=>ae.id===ee.id),te=D.findIndex(ae=>ae.id===H.id);if(Y!==-1&&te!==-1){const fe=Fw(D,Y,te).map((Q,me)=>({id:Q.id,position:me+1}));F.mutate(fe)}};return f.jsxs("div",{className:"p-8",children:[f.jsx("div",{className:"flex items-center justify-between mb-8",children:f.jsxs("div",{children:[f.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[f.jsx(p9,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),f.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[f.jsx(Ft,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:f.jsx($t,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:f.jsx(aw,{className:"w-5 h-5 text-blue-400"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:$.length}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),f.jsx(Ft,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:f.jsx($t,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:f.jsx(Pi,{className:"w-5 h-5 text-yellow-400"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:D.length}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),f.jsx(Ft,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:f.jsx($t,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:f.jsx(ku,{className:"w-5 h-5 text-bambu-green"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:iK(V)}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),f.jsx(Ft,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:f.jsx($t,{className:"p-4",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:f.jsx(mc,{className:"w-5 h-5 text-gray-400"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-2xl font-bold text-white",children:G.length}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),f.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[f.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:K=>r(K.target.value?Number(K.target.value):null),children:[f.jsx("option",{value:"",children:"All Printers"}),C?.map(K=>f.jsx("option",{value:K.id,children:K.name},K.id))]}),f.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:K=>s(K.target.value),children:[f.jsx("option",{value:"",children:"All Status"}),f.jsx("option",{value:"pending",children:"Pending"}),f.jsx("option",{value:"printing",children:"Printing"}),f.jsx("option",{value:"completed",children:"Completed"}),f.jsx("option",{value:"failed",children:"Failed"}),f.jsx("option",{value:"skipped",children:"Skipped"}),f.jsx("option",{value:"cancelled",children:"Cancelled"})]}),f.jsx("div",{className:"flex-1"}),G.length>0&&f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[f.jsx(fr,{className:"w-4 h-4"}),"Clear History"]})]}),P?f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):A?.length===0?f.jsxs(Ft,{className:"p-12 text-center border-dashed",children:[f.jsx(as,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),f.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),f.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.'})]}):f.jsxs("div",{className:"space-y-8",children:[$.length>0&&f.jsxs("div",{children:[f.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),f.jsx("div",{className:"space-y-3",children:$.map(K=>f.jsx(W2,{item:K,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>h({type:"stop",item:K}),onRequeue:()=>{}},K.id))})]}),D.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(Pi,{className:"w-5 h-5 text-yellow-400"}),"Queued",f.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",D.length," item",D.length!==1?"s":"",")"]}),f.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)"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.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:v,onChange:K=>x(K.target.value),children:[f.jsx("option",{value:"position",children:"Sort by Position"}),f.jsx("option",{value:"name",children:"Sort by Name"}),f.jsx("option",{value:"printer",children:"Sort by Printer"}),f.jsx("option",{value:"time",children:"Sort by Schedule"})]}),f.jsx(We,{variant:"ghost",size:"sm",onClick:()=>w(!M),title:M?"Ascending":"Descending",className:"px-2",children:M?f.jsx(Wp,{className:"w-4 h-4"}):f.jsx(Yx,{className:"w-4 h-4"})})]})]}),f.jsx(YX,{sensors:T,collisionDetection:jX,onDragEnd:Z,children:f.jsx(JX,{items:D.map(K=>K.id),strategy:HNe,children:f.jsx("div",{className:"space-y-3",children:D.map((K,ee)=>f.jsx(W2,{item:K,position:ee+1,onEdit:()=>c(K),onCancel:()=>h({type:"cancel",item:K}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},K.id))})})})]}),G.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(mc,{className:"w-5 h-5 text-bambu-gray"}),"History",f.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",G.length," item",G.length!==1?"s":"",")"]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.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:K=>m(K.target.value),children:[f.jsx("option",{value:"date",children:"Sort by Date"}),f.jsx("option",{value:"name",children:"Sort by Name"}),f.jsx("option",{value:"printer",children:"Sort by Printer"})]}),f.jsx(We,{variant:"ghost",size:"sm",onClick:()=>y(!b),title:b?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:b?f.jsx(Wp,{className:"w-4 h-4"}):f.jsx(Yx,{className:"w-4 h-4"})})]})]}),f.jsx("div",{className:"space-y-3",children:G.slice(0,20).map((K,ee)=>f.jsx(W2,{item:K,position:ee+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>h({type:"remove",item:K}),onStop:()=>{},onRequeue:()=>I.mutate(K)},K.id))})]})]}),l&&f.jsx(JNe,{item:l,onClose:()=>c(null)}),u&&f.jsx(zs,{title:u.type==="cancel"?"Cancel Scheduled Print":u.type==="stop"?"Stop Print":"Remove from History",message:u.type==="cancel"?`Are you sure you want to cancel "${u.item.archive_name||"this print"}"?`:u.type==="stop"?`Are you sure you want to stop the current print "${u.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${u.item.archive_name||"this item"}" from the queue history?`,confirmText:u.type==="cancel"?"Cancel Print":u.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{u.type==="cancel"?j.mutate(u.item.id):u.type==="stop"?k.mutate(u.item.id):N.mutate(u.item.id),h(null)},onCancel:()=>h(null)}),a&&f.jsx(zs,{title:"Clear History",message:`Are you sure you want to remove all ${G.length} item${G.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{W.mutate(),o(!1)},onCancel:()=>o(!1)})]})}function r3e({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=E.useMemo(()=>{const l={};t.forEach(x=>{const M=x.split("T")[0];l[M]=(l[M]||0)+1});const c=new Date,u=new Date(c);u.setMonth(u.getMonth()-e),u.setDate(u.getDate()-u.getDay());const h=[],g=[];let m=[],b=-1;const y=new Date(u);let v=0;for(;y<=c;)y.getDay()===0&&m.length>0&&(h.push(m),m=[],v++),y.getMonth()!==b&&(g.push({month:y.toLocaleDateString("en-US",{month:"short"}),weekIndex:v}),b=y.getMonth()),m.push(new Date(y)),y.setDate(y.getDate()+1);return m.length>0&&h.push(m),{weeks:h,monthLabels:g,printCounts:l}},[t,e]),s=Math.max(1,...Object.values(i)),a=l=>{if(l===0)return"bg-bambu-dark";const c=l/s;return c<=.25?"bg-bambu-green/30":c<=.5?"bg-bambu-green/50":c<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return f.jsxs("div",{className:"overflow-x-auto",children:[f.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:l,weekIndex:c},u)=>f.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:u===0?0:`${(c-(r[u-1]?.weekIndex||0))*14-24}px`},children:l},u))}),f.jsxs("div",{className:"flex gap-0.5",children:[f.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,c)=>f.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:c%2===1?"visible":"hidden"},children:l},l))}),n.map((l,c)=>f.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(u=>{const h=l.find(y=>y.getDay()===u);if(!h)return f.jsx("div",{className:"w-3 h-3"},u);const g=h.toISOString().split("T")[0],m=i[g]||0,b=g===new Date().toISOString().split("T")[0];return f.jsx("div",{className:`w-3 h-3 rounded-sm ${a(m)} ${b?"ring-1 ring-white":""}`,title:`${h.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},u)})},c))]}),f.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[f.jsx("span",{children:"Less"}),f.jsxs("div",{className:"flex gap-0.5",children:[f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),f.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),f.jsx("span",{children:"More"})]})]})}function sK(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=sK(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function An(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=sK(t))&&(r&&(r+=" "),r+=e);return r}var i3e=["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 MD(t){if(typeof t!="string")return!1;var e=i3e;return e.includes(t)}var s3e=["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"],a3e=new Set(s3e);function aK(t){return typeof t!="string"?!1:a3e.has(t)}function oK(t){return typeof t=="string"&&t.startsWith("data-")}function Gs(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(aK(n)||oK(n))&&(e[n]=t[n]);return e}function Bf(t){if(t==null)return null;if(E.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Gs(e)}return typeof t=="object"&&!Array.isArray(t)?Gs(t):null}function Es(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(aK(n)||oK(n)||MD(n))&&(e[n]=t[n]);return e}function o3e(t){return t==null?null:E.isValidElement(t)?Es(t.props):typeof t=="object"&&!Array.isArray(t)?Es(t):null}var l3e=["children","width","height","viewBox","className","style","title","desc"];function RR(){return RR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},RR.apply(null,arguments)}function c3e(t,e){if(t==null)return{};var n,r,i=u3e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function u3e(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 ED=E.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:a,style:o,title:l,desc:c}=t,u=c3e(t,l3e),h=s||{width:r,height:i,x:0,y:0},g=An("recharts-surface",a);return E.createElement("svg",RR({},Es(u),{className:g,width:r,height:i,style:o,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height),ref:e}),E.createElement("title",null,l),E.createElement("desc",null,c),n)}),d3e=["children","className"];function PR(){return PR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},PR.apply(null,arguments)}function f3e(t,e){if(t==null)return{};var n,r,i=h3e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function h3e(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 Ir=E.forwardRef((t,e)=>{var{children:n,className:r}=t,i=f3e(t,d3e),s=An("recharts-layer",r);return E.createElement("g",PR({className:s},Es(i),{ref:e}),n)}),lK=E.createContext(null),p3e=()=>E.useContext(lK);function Qn(t){return function(){return t}}const cK=Math.cos,lS=Math.sin,Po=Math.sqrt,cS=Math.PI,zw=2*cS,kR=Math.PI,DR=2*kR,Vd=1e-6,m3e=DR-Vd;function uK(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function g3e(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return uK;const n=10**e;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class x3e{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?uK:g3e(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,s,a){this._append`C${+e},${+n},${+r},${+i},${this._x1=+s},${this._y1=+a}`}arcTo(e,n,r,i,s){if(e=+e,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let a=this._x1,o=this._y1,l=r-e,c=i-n,u=a-e,h=o-n,g=u*u+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>Vd)if(!(Math.abs(h*l-c*u)>Vd)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-a,b=i-o,y=l*l+c*c,v=m*m+b*b,x=Math.sqrt(y),M=Math.sqrt(g),w=s*Math.tan((kR-Math.acos((y+g-v)/(2*x*M)))/2),T=w/M,A=w/x;Math.abs(T-1)>Vd&&this._append`L${e+T*u},${n+T*h}`,this._append`A${s},${s},0,0,${+(h*m>u*b)},${this._x1=e+A*l},${this._y1=n+A*c}`}}arc(e,n,r,i,s,a){if(e=+e,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),c=e+o,u=n+l,h=1^a,g=a?i-s:s-i;this._x1===null?this._append`M${c},${u}`:(Math.abs(this._x1-c)>Vd||Math.abs(this._y1-u)>Vd)&&this._append`L${c},${u}`,r&&(g<0&&(g=g%DR+DR),g>m3e?this._append`A${r},${r},0,1,${h},${e-o},${n-l}A${r},${r},0,1,${h},${this._x1=c},${this._y1=u}`:g>Vd&&this._append`A${r},${r},0,${+(g>=kR)},${h},${this._x1=e+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function AD(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 x3e(e)}function TD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function dK(t){this._context=t}dK.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 Bw(t){return new dK(t)}function fK(t){return t[0]}function hK(t){return t[1]}function pK(t,e){var n=Qn(!0),r=null,i=Bw,s=null,a=AD(o);t=typeof t=="function"?t:t===void 0?fK:Qn(t),e=typeof e=="function"?e:e===void 0?hK:Qn(e);function o(l){var c,u=(l=TD(l)).length,h,g=!1,m;for(r==null&&(s=i(m=a())),c=0;c<=u;++c)!(c<u&&n(h=l[c],c,l))===g&&((g=!g)?s.lineStart():s.lineEnd()),g&&s.point(+t(h,c,l),+e(h,c,l));if(m)return s=null,m+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Qn(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Qn(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Qn(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(s=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=s=null:s=i(r=l),o):r},o}function t_(t,e,n){var r=null,i=Qn(!0),s=null,a=Bw,o=null,l=AD(c);t=typeof t=="function"?t:t===void 0?fK:Qn(+t),e=typeof e=="function"?e:Qn(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?hK:Qn(+n);function c(h){var g,m,b,y=(h=TD(h)).length,v,x=!1,M,w=new Array(y),T=new Array(y);for(s==null&&(o=a(M=l())),g=0;g<=y;++g){if(!(g<y&&i(v=h[g],g,h))===x)if(x=!x)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),b=g-1;b>=m;--b)o.point(w[b],T[b]);o.lineEnd(),o.areaEnd()}x&&(w[g]=+t(v,g,h),T[g]=+e(v,g,h),o.point(r?+r(v,g,h):w[g],n?+n(v,g,h):T[g]))}if(M)return o=null,M+""||null}function u(){return pK().defined(i).curve(a).context(s)}return c.x=function(h){return arguments.length?(t=typeof h=="function"?h:Qn(+h),r=null,c):t},c.x0=function(h){return arguments.length?(t=typeof h=="function"?h:Qn(+h),c):t},c.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:Qn(+h),c):r},c.y=function(h){return arguments.length?(e=typeof h=="function"?h:Qn(+h),n=null,c):e},c.y0=function(h){return arguments.length?(e=typeof h=="function"?h:Qn(+h),c):e},c.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:Qn(+h),c):n},c.lineX0=c.lineY0=function(){return u().x(t).y(e)},c.lineY1=function(){return u().x(t).y(n)},c.lineX1=function(){return u().x(r).y(e)},c.defined=function(h){return arguments.length?(i=typeof h=="function"?h:Qn(!!h),c):i},c.curve=function(h){return arguments.length?(a=h,s!=null&&(o=a(s)),c):a},c.context=function(h){return arguments.length?(h==null?s=o=null:o=a(s=h),c):s},c}class mK{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 v3e(t){return new mK(t,!0)}function b3e(t){return new mK(t,!1)}const CD={draw(t,e){const n=Po(e/cS);t.moveTo(n,0),t.arc(0,0,n,0,zw)}},y3e={draw(t,e){const n=Po(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()}},gK=Po(1/3),_3e=gK*2,S3e={draw(t,e){const n=Po(e/_3e),r=n*gK;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},w3e={draw(t,e){const n=Po(e),r=-n/2;t.rect(r,r,n,n)}},M3e=.8908130915292852,xK=lS(cS/10)/lS(7*cS/10),E3e=lS(zw/10)*xK,A3e=-cK(zw/10)*xK,T3e={draw(t,e){const n=Po(e*M3e),r=E3e*n,i=A3e*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const a=zw*s/5,o=cK(a),l=lS(a);t.lineTo(l*n,-o*n),t.lineTo(o*r-l*i,l*r+o*i)}t.closePath()}},q2=Po(3),C3e={draw(t,e){const n=-Po(e/(q2*3));t.moveTo(0,n*2),t.lineTo(-q2*n,-n),t.lineTo(q2*n,-n),t.closePath()}},Na=-.5,Ra=Po(3)/2,OR=1/Po(12),N3e=(OR/2+1)*3,R3e={draw(t,e){const n=Po(e/N3e),r=n/2,i=n*OR,s=r,a=n*OR+n,o=-s,l=a;t.moveTo(r,i),t.lineTo(s,a),t.lineTo(o,l),t.lineTo(Na*r-Ra*i,Ra*r+Na*i),t.lineTo(Na*s-Ra*a,Ra*s+Na*a),t.lineTo(Na*o-Ra*l,Ra*o+Na*l),t.lineTo(Na*r+Ra*i,Na*i-Ra*r),t.lineTo(Na*s+Ra*a,Na*a-Ra*s),t.lineTo(Na*o+Ra*l,Na*l-Ra*o),t.closePath()}};function P3e(t,e){let n=null,r=AD(i);t=typeof t=="function"?t:Qn(t||CD),e=typeof e=="function"?e:Qn(e===void 0?64:+e);function i(){let s;if(n||(n=s=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),s)return n=null,s+""||null}return i.type=function(s){return arguments.length?(t=typeof s=="function"?s:Qn(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:Qn(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function uS(){}function dS(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 vK(t){this._context=t}vK.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:dS(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:dS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function k3e(t){return new vK(t)}function bK(t){this._context=t}bK.prototype={areaStart:uS,areaEnd:uS,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:dS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function D3e(t){return new bK(t)}function yK(t){this._context=t}yK.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:dS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function O3e(t){return new yK(t)}function _K(t){this._context=t}_K.prototype={areaStart:uS,areaEnd:uS,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 L3e(t){return new _K(t)}function t8(t){return t<0?-1:1}function n8(t,e,n){var r=t._x1-t._x0,i=e-t._x1,s=(t._y1-t._y0)/(r||i<0&&-0),a=(n-t._y1)/(i||r<0&&-0),o=(s*i+a*r)/(r+i);return(t8(s)+t8(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function r8(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function X2(t,e,n){var r=t._x0,i=t._y0,s=t._x1,a=t._y1,o=(s-r)/3;t._context.bezierCurveTo(r+o,i+o*e,s-o,a-o*n,s,a)}function fS(t){this._context=t}fS.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:X2(this,this._t0,r8(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,X2(this,r8(this,n=n8(this,t,e)),n);break;default:X2(this,this._t0,n=n8(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function SK(t){this._context=new wK(t)}(SK.prototype=Object.create(fS.prototype)).point=function(t,e){fS.prototype.point.call(this,e,t)};function wK(t){this._context=t}wK.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,s){this._context.bezierCurveTo(e,t,r,n,s,i)}};function I3e(t){return new fS(t)}function j3e(t){return new SK(t)}function MK(t){this._context=t}MK.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=i8(t),i=i8(e),s=0,a=1;a<n;++s,++a)this._context.bezierCurveTo(r[0][s],i[0][s],r[1][s],i[1][s],t[a],e[a]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function i8(t){var e,n=t.length-1,r,i=new Array(n),s=new Array(n),a=new Array(n);for(i[0]=0,s[0]=2,a[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,s[e]=4,a[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,s[n-1]=7,a[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/s[e-1],s[e]-=r,a[e]-=r*a[e-1];for(i[n-1]=a[n-1]/s[n-1],e=n-2;e>=0;--e)i[e]=(a[e]-i[e+1])/s[e];for(s[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)s[e]=2*t[e+1]-i[e+1];return[i,s]}function U3e(t){return new MK(t)}function Hw(t,e){this._context=t,this._t=e}Hw.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 F3e(t){return new Hw(t,.5)}function z3e(t){return new Hw(t,0)}function B3e(t){return new Hw(t,1)}function mm(t,e){if((a=t.length)>1)for(var n=1,r,i,s=t[e[0]],a,o=s.length;n<a;++n)for(i=s,s=t[e[n]],r=0;r<o;++r)s[r][1]+=s[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function LR(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function H3e(t,e){return t[e]}function $3e(t){const e=[];return e.key=t,e}function V3e(){var t=Qn([]),e=LR,n=mm,r=H3e;function i(s){var a=Array.from(t.apply(this,arguments),$3e),o,l=a.length,c=-1,u;for(const h of s)for(o=0,++c;o<l;++o)(a[o][c]=[0,+r(h,a[o].key,c,s)]).data=h;for(o=0,u=TD(e(a));o<l;++o)a[u[o]].index=o;return n(a,u),a}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:Qn(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:Qn(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?LR:typeof s=="function"?s:Qn(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??mm,i):n},i}function G3e(t,e){if((r=t.length)>0){for(var n,r,i=0,s=t[0].length,a;i<s;++i){for(a=n=0;n<r;++n)a+=t[n][i][1]||0;if(a)for(n=0;n<r;++n)t[n][i][1]/=a}mm(t,e)}}function W3e(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,s=r.length;n<s;++n){for(var a=0,o=0;a<i;++a)o+=t[a][n][1]||0;r[n][1]+=r[n][0]=-o/2}mm(t,e)}}function q3e(t,e){if(!(!((a=t.length)>0)||!((s=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,s,a;r<s;++r){for(var o=0,l=0,c=0;o<a;++o){for(var u=t[e[o]],h=u[r][1]||0,g=u[r-1][1]||0,m=(h-g)/2,b=0;b<o;++b){var y=t[e[b]],v=y[r][1]||0,x=y[r-1][1]||0;m+=v-x}l+=h,c+=m*h}i[r-1][1]+=i[r-1][0]=n,l&&(n-=c/l)}i[r-1][1]+=i[r-1][0]=n,mm(t,e)}}var K2={},Y2={},s8;function X3e(){return s8||(s8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(Y2)),Y2}var Z2={},a8;function EK(){return a8||(a8=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})(Z2)),Z2}var Q2={},o8;function ND(){return o8||(o8=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})(Q2)),Q2}var J2={},eC={},l8;function K3e(){return l8||(l8=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})(eC)),eC}var c8;function RD(){return c8||(c8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=K3e(),n=ND();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const s=[],a=i.length;if(a===0)return s;let o=0,l="",c="",u=!1;for(i.charCodeAt(0)===46&&(s.push(""),o++);o<a;){const h=i[o];c?h==="\\"&&o+1<a?(o++,l+=i[o]):h===c?c="":l+=h:u?h==='"'||h==="'"?c=h:h==="]"?(u=!1,s.push(l),l=""):l+=h:h==="["?(u=!0,l&&(s.push(l),l="")):h==="."?l&&(s.push(l),l=""):l+=h,o++}return l&&s.push(l),s}t.toPath=r})(J2)),J2}var u8;function PD(){return u8||(u8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=X3e(),n=EK(),r=ND(),i=RD();function s(o,l,c){if(o==null)return c;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return c;const u=o[l];return u===void 0?n.isDeepKey(l)?s(o,i.toPath(l),c):c:u}case"number":case"symbol":{typeof l=="number"&&(l=r.toKey(l));const u=o[l];return u===void 0?c:u}default:{if(Array.isArray(l))return a(o,l,c);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),e.isUnsafeProperty(l))return c;const u=o[l];return u===void 0?c:u}}}function a(o,l,c){if(l.length===0)return c;let u=o;for(let h=0;h<l.length;h++){if(u==null||e.isUnsafeProperty(l[h]))return c;u=u[l[h]]}return u===void 0?c:u}t.get=s})(K2)),K2}var tC,d8;function Y3e(){return d8||(d8=1,tC=PD().get),tC}var Z3e=Y3e();const Hf=Ja(Z3e);var Ci=t=>t===0?0:t>0?1:-1,Ya=t=>typeof t=="number"&&t!=+t,bc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Et=t=>(typeof t=="number"||t instanceof Number)&&!Ya(t),ll=t=>Et(t)||typeof t=="string",Q3e=0,M0=t=>{var e=++Q3e;return"".concat(t||"").concat(e)},cs=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(!Et(e)&&typeof e!="string")return r;var s;if(bc(e)){if(n==null)return r;var a=e.indexOf("%");s=n*parseFloat(e.slice(0,a))/100}else s=+e;return Ya(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},AK=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 ar(t,e,n){return Et(t)&&Et(e)?t+n*(e-t):e}function TK(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Hf(r,e))===n)}var xr=t=>t===null||typeof t>"u",rv=t=>xr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function J3e(t){return t!=null}function iv(){}var eRe=["type","size","sizeType"];function IR(){return IR=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},IR.apply(null,arguments)}function f8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function h8(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){tRe(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 tRe(t,e,n){return(e=nRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nRe(t){var e=rRe(t,"string");return typeof e=="symbol"?e:e+""}function rRe(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 iRe(t,e){if(t==null)return{};var n,r,i=sRe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function sRe(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 CK={symbolCircle:CD,symbolCross:y3e,symbolDiamond:S3e,symbolSquare:w3e,symbolStar:T3e,symbolTriangle:C3e,symbolWye:R3e},aRe=Math.PI/180,oRe=t=>{var e="symbol".concat(rv(t));return CK[e]||CD},lRe=(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*aRe;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}},cRe=(t,e)=>{CK["symbol".concat(rv(t))]=e},kD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=iRe(t,eRe),s=h8(h8({},i),{},{type:e,size:n,sizeType:r}),a="circle";typeof e=="string"&&(a=e);var o=()=>{var g=oRe(a),m=P3e().type(g).size(lRe(n,r,a)),b=m();if(b!==null)return b},{className:l,cx:c,cy:u}=s,h=Es(s);return Et(c)&&Et(u)&&Et(n)?E.createElement("path",IR({},h,{className:An("recharts-symbols",l),transform:"translate(".concat(c,", ").concat(u,")"),d:o()})):null};kD.registerSymbol=cRe;var NK=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,DD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(E.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{MD(i)&&(r[i]=(s=>n[i](n,s)))}),r},uRe=(t,e,n)=>r=>(t(e,n,r),null),sv=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var s=t[i];MD(i)&&typeof s=="function"&&(r||(r={}),r[i]=uRe(s,e,n))}),r};function p8(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 dRe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p8(Object(n),!0).forEach(function(r){fRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fRe(t,e,n){return(e=hRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hRe(t){var e=pRe(t,"string");return typeof e=="symbol"?e:e+""}function pRe(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 Qr(t,e){var n=dRe({},t),r=e,i=Object.keys(e),s=i.reduce((a,o)=>(a[o]===void 0&&r[o]!==void 0&&(a[o]=r[o]),a),n);return s}function hS(){return hS=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},hS.apply(null,arguments)}function m8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function mRe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m8(Object(n),!0).forEach(function(r){gRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gRe(t,e,n){return(e=xRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xRe(t){var e=vRe(t,"string");return typeof e=="symbol"?e:e+""}function vRe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Da=32,bRe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function yRe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Da/2,s=Da/6,a=Da/3,o=e.inactive?r:e.color,l=n??e.type;if(l==="none")return null;if(l==="plainline"){var c;return E.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(c=e.payload)===null||c===void 0?void 0:c.strokeDasharray,x1:0,y1:i,x2:Da,y2:i,className:"recharts-legend-icon"})}if(l==="line")return E.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(a,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(2*a,",").concat(i,`
- H`).concat(Da,"M").concat(2*a,",").concat(i,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(a,",").concat(i),className:"recharts-legend-icon"});if(l==="rect")return E.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Da/8,"h").concat(Da,"v").concat(Da*3/4,"h").concat(-Da,"z"),className:"recharts-legend-icon"});if(E.isValidElement(e.legendIcon)){var u=mRe({},e);return delete u.legendIcon,E.cloneElement(e.legendIcon,u)}return E.createElement(kD,{fill:o,cx:i,cy:i,size:Da,sizeType:"diameter",type:l})}function _Re(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:a}=t,o={x:0,y:0,width:Da,height:Da},l={display:r==="horizontal"?"inline-block":"block",marginRight:10},c={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((u,h)=>{var g=u.formatter||i,m=An({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:u.inactive});if(u.type==="none")return null;var b=u.inactive?s:u.color,y=g?g(u.value,u,h):u.value;return E.createElement("li",hS({className:m,style:l,key:"legend-item-".concat(h)},sv(t,u,h)),E.createElement(ED,{width:n,height:n,viewBox:o,style:c,"aria-label":"".concat(y," legend icon")},E.createElement(yRe,{data:u,iconType:a,inactiveColor:s})),E.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},y))})}var SRe=t=>{var e=Qr(t,bRe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var s={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return E.createElement("ul",{className:"recharts-default-legend",style:s},E.createElement(_Re,hS({},e,{payload:n})))},nC={},rC={},g8;function wRe(){return g8||(g8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let s=0;s<n.length;s++){const a=n[s],o=r(a);i.has(o)||i.set(o,a)}return Array.from(i.values())}t.uniqBy=e})(rC)),rC}var iC={},x8;function RK(){return x8||(x8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(iC)),iC}var sC={},aC={},oC={},v8;function MRe(){return v8||(v8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(oC)),oC}var b8;function OD(){return b8||(b8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MRe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(aC)),aC}var lC={},y8;function ERe(){return y8||(y8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(lC)),lC}var _8;function ARe(){return _8||(_8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OD(),n=ERe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(sC)),sC}var cC={},uC={},S8;function TRe(){return S8||(S8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PD();function n(r){return function(i){return e.get(i,r)}}t.property=n})(uC)),uC}var dC={},fC={},hC={},pC={},w8;function PK(){return w8||(w8=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})(pC)),pC}var mC={},M8;function kK(){return M8||(M8=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})(mC)),mC}var gC={},E8;function DK(){return E8||(E8=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})(gC)),gC}var A8;function CRe(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PK(),n=kK(),r=DK();function i(u,h,g){return typeof g!="function"?i(u,h,()=>{}):s(u,h,function m(b,y,v,x,M,w){const T=g(b,y,v,x,M,w);return T!==void 0?!!T:s(b,y,m,w)},new Map)}function s(u,h,g,m){if(h===u)return!0;switch(typeof h){case"object":return a(u,h,g,m);case"function":return Object.keys(h).length>0?s(u,{...h},g,m):r.eq(u,h);default:return e.isObject(u)?typeof h=="string"?h==="":!0:r.eq(u,h)}}function a(u,h,g,m){if(h==null)return!0;if(Array.isArray(h))return l(u,h,g,m);if(h instanceof Map)return o(u,h,g,m);if(h instanceof Set)return c(u,h,g,m);const b=Object.keys(h);if(u==null)return b.length===0;if(b.length===0)return!0;if(m?.has(h))return m.get(h)===u;m?.set(h,u);try{for(let y=0;y<b.length;y++){const v=b[y];if(!n.isPrimitive(u)&&!(v in u)||h[v]===void 0&&u[v]!==void 0||h[v]===null&&u[v]!==null||!g(u[v],h[v],v,u,h,m))return!1}return!0}finally{m?.delete(h)}}function o(u,h,g,m){if(h.size===0)return!0;if(!(u instanceof Map))return!1;for(const[b,y]of h.entries()){const v=u.get(b);if(g(v,y,b,u,h,m)===!1)return!1}return!0}function l(u,h,g,m){if(h.length===0)return!0;if(!Array.isArray(u))return!1;const b=new Set;for(let y=0;y<h.length;y++){const v=h[y];let x=!1;for(let M=0;M<u.length;M++){if(b.has(M))continue;const w=u[M];let T=!1;if(g(w,v,y,u,h,m)&&(T=!0),T){b.add(M),x=!0;break}}if(!x)return!1}return!0}function c(u,h,g,m){return h.size===0?!0:u instanceof Set?l([...u],[...h],g,m):!1}t.isMatchWith=i,t.isSetMatch=c})(hC)),hC}var T8;function OK(){return T8||(T8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CRe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(fC)),fC}var xC={},vC={},bC={},C8;function NRe(){return C8||(C8=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})(bC)),bC}var yC={},N8;function LK(){return N8||(N8=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})(yC)),yC}var _C={},R8;function IK(){return R8||(R8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",s="[object Arguments]",a="[object Symbol]",o="[object Date]",l="[object Map]",c="[object Set]",u="[object Array]",h="[object Function]",g="[object ArrayBuffer]",m="[object Object]",b="[object Error]",y="[object DataView]",v="[object Uint8Array]",x="[object Uint8ClampedArray]",M="[object Uint16Array]",w="[object Uint32Array]",T="[object BigUint64Array]",A="[object Int8Array]",P="[object Int16Array]",C="[object Int32Array]",j="[object BigInt64Array]",N="[object Float32Array]",k="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=g,t.arrayTag=u,t.bigInt64ArrayTag=j,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=y,t.dateTag=o,t.errorTag=b,t.float32ArrayTag=N,t.float64ArrayTag=k,t.functionTag=h,t.int16ArrayTag=P,t.int32ArrayTag=C,t.int8ArrayTag=A,t.mapTag=l,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=c,t.stringTag=n,t.symbolTag=a,t.uint16ArrayTag=M,t.uint32ArrayTag=w,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=x})(_C)),_C}var SC={},P8;function RRe(){return P8||(P8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(SC)),SC}var k8;function jK(){return k8||(k8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=NRe(),n=LK(),r=IK(),i=kK(),s=RRe();function a(u,h){return o(u,void 0,u,new Map,h)}function o(u,h,g,m=new Map,b=void 0){const y=b?.(u,h,g,m);if(y!==void 0)return y;if(i.isPrimitive(u))return u;if(m.has(u))return m.get(u);if(Array.isArray(u)){const v=new Array(u.length);m.set(u,v);for(let x=0;x<u.length;x++)v[x]=o(u[x],x,g,m,b);return Object.hasOwn(u,"index")&&(v.index=u.index),Object.hasOwn(u,"input")&&(v.input=u.input),v}if(u instanceof Date)return new Date(u.getTime());if(u instanceof RegExp){const v=new RegExp(u.source,u.flags);return v.lastIndex=u.lastIndex,v}if(u instanceof Map){const v=new Map;m.set(u,v);for(const[x,M]of u)v.set(x,o(M,x,g,m,b));return v}if(u instanceof Set){const v=new Set;m.set(u,v);for(const x of u)v.add(o(x,void 0,g,m,b));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(u))return u.subarray();if(s.isTypedArray(u)){const v=new(Object.getPrototypeOf(u)).constructor(u.length);m.set(u,v);for(let x=0;x<u.length;x++)v[x]=o(u[x],x,g,m,b);return v}if(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer)return u.slice(0);if(u instanceof DataView){const v=new DataView(u.buffer.slice(0),u.byteOffset,u.byteLength);return m.set(u,v),l(v,u,g,m,b),v}if(typeof File<"u"&&u instanceof File){const v=new File([u],u.name,{type:u.type});return m.set(u,v),l(v,u,g,m,b),v}if(typeof Blob<"u"&&u instanceof Blob){const v=new Blob([u],{type:u.type});return m.set(u,v),l(v,u,g,m,b),v}if(u instanceof Error){const v=new u.constructor;return m.set(u,v),v.message=u.message,v.name=u.name,v.stack=u.stack,v.cause=u.cause,l(v,u,g,m,b),v}if(u instanceof Boolean){const v=new Boolean(u.valueOf());return m.set(u,v),l(v,u,g,m,b),v}if(u instanceof Number){const v=new Number(u.valueOf());return m.set(u,v),l(v,u,g,m,b),v}if(u instanceof String){const v=new String(u.valueOf());return m.set(u,v),l(v,u,g,m,b),v}if(typeof u=="object"&&c(u)){const v=Object.create(Object.getPrototypeOf(u));return m.set(u,v),l(v,u,g,m,b),v}return u}function l(u,h,g=u,m,b){const y=[...Object.keys(h),...e.getSymbols(h)];for(let v=0;v<y.length;v++){const x=y[v],M=Object.getOwnPropertyDescriptor(u,x);(M==null||M.writable)&&(u[x]=o(h[x],x,g,m,b))}}function c(u){switch(n.getTag(u)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=a,t.cloneDeepWithImpl=o,t.copyProperties=l})(vC)),vC}var D8;function PRe(){return D8||(D8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(xC)),xC}var O8;function kRe(){return O8||(O8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OK(),n=PRe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(dC)),dC}var wC={},MC={},EC={},L8;function DRe(){return L8||(L8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jK(),n=IK();function r(i,s){return e.cloneDeepWith(i,(a,o,l,c)=>{const u=s?.(a,o,l,c);if(u!==void 0)return u;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const h=new i.constructor(i?.valueOf());return e.copyProperties(h,i),h}case n.argumentsTag:{const h={};return e.copyProperties(h,i),h.length=i.length,h[Symbol.iterator]=i[Symbol.iterator],h}default:return}})}t.cloneDeepWith=r})(EC)),EC}var I8;function ORe(){return I8||(I8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=DRe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(MC)),MC}var AC={},TC={},j8;function UK(){return j8||(j8=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})(TC)),TC}var CC={},U8;function LRe(){return U8||(U8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(CC)),CC}var F8;function IRe(){return F8||(F8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=EK(),n=UK(),r=LRe(),i=RD();function s(a,o){let l;if(Array.isArray(o)?l=o:typeof o=="string"&&e.isDeepKey(o)&&a?.[o]==null?l=i.toPath(o):l=[o],l.length===0)return!1;let c=a;for(let u=0;u<l.length;u++){const h=l[u];if((c==null||!Object.hasOwn(c,h))&&!((Array.isArray(c)||r.isArguments(c))&&n.isIndex(h)&&h<c.length))return!1;c=c[h]}return!0}t.has=s})(AC)),AC}var z8;function jRe(){return z8||(z8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OK(),n=ND(),r=ORe(),i=PD(),s=IRe();function a(o,l){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return l=r.cloneDeep(l),function(c){const u=i.get(c,o);return u===void 0?s.has(c,o):l===void 0?u===void 0:e.isMatch(u,l)}}t.matchesProperty=a})(wC)),wC}var B8;function URe(){return B8||(B8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RK(),n=TRe(),r=kRe(),i=jRe();function s(a){if(a==null)return e.identity;switch(typeof a){case"function":return a;case"object":return Array.isArray(a)&&a.length===2?i.matchesProperty(a[0],a[1]):r.matches(a);case"string":case"symbol":case"number":return n.property(a)}}t.iteratee=s})(cC)),cC}var H8;function FRe(){return H8||(H8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wRe(),n=RK(),r=ARe(),i=URe();function s(a,o=n.identity){return r.isArrayLikeObject(a)?e.uniqBy(Array.from(a),i.iteratee(o)):[]}t.uniqBy=s})(nC)),nC}var NC,$8;function zRe(){return $8||($8=1,NC=FRe().uniqBy),NC}var BRe=zRe();const V8=Ja(BRe);function FK(t,e,n){return e===!0?V8(t,n):typeof e=="function"?V8(t,e):t}var LD=E.createContext(null),HRe=t=>t,er=()=>{var t=E.useContext(LD);return t?t.store.dispatch:HRe},z_=()=>{},$Re=()=>z_,VRe=(t,e)=>t===e;function Ct(t){var e=E.useContext(LD);return Jq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:$Re,e?e.store.getState:z_,e?e.store.getState:z_,e?t:z_,VRe)}function GRe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function WRe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function qRe(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 G8=t=>Array.isArray(t)?t:[t];function XRe(t){const e=Array.isArray(t[0])?t[0]:t;return qRe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function KRe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var YRe=class{constructor(t){this.value=t}deref(){return this.value}},ZRe=typeof WeakRef<"u"?WeakRef:YRe,QRe=0,W8=1;function n_(){return{s:QRe,v:void 0,o:null,p:null}}function zK(t,e={}){let n=n_();const{resultEqualityCheck:r}=e;let i,s=0;function a(){let o=n;const{length:l}=arguments;for(let h=0,g=l;h<g;h++){const m=arguments[h];if(typeof m=="function"||typeof m=="object"&&m!==null){let b=o.o;b===null&&(o.o=b=new WeakMap);const y=b.get(m);y===void 0?(o=n_(),b.set(m,o)):o=y}else{let b=o.p;b===null&&(o.p=b=new Map);const y=b.get(m);y===void 0?(o=n_(),b.set(m,o)):o=y}}const c=o;let u;if(o.s===W8)u=o.v;else if(u=t.apply(null,arguments),s++,r){const h=i?.deref?.()??i;h!=null&&r(h,u)&&(u=h,s!==0&&s--),i=typeof u=="object"&&u!==null||typeof u=="function"?new ZRe(u):u}return c.s=W8,c.v=u,u}return a.clearCache=()=>{n=n_(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function JRe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,a=0,o,l={},c=i.pop();typeof c=="object"&&(l=c,c=i.pop()),GRe(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:h,memoizeOptions:g=[],argsMemoize:m=zK,argsMemoizeOptions:b=[]}=u,y=G8(g),v=G8(b),x=XRe(i),M=h(function(){return s++,c.apply(null,arguments)},...y),w=m(function(){a++;const A=KRe(x,arguments);return o=M.apply(null,A),o},...v);return Object.assign(w,{resultFunc:c,memoizedResultFunc:M,dependencies:x,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>o,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:h,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var Ge=JRe(zK),ePe=Object.assign((t,e=Ge)=>{WRe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(s=>t[s]);return e(r,(...s)=>s.reduce((a,o,l)=>(a[n[l]]=o,a),{}))},{withTypes:()=>ePe}),RC={},PC={},kC={},q8;function tPe(){return q8||(q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,s)=>{if(r!==i){const a=e(r),o=e(i);if(a===o&&a===0){if(r<i)return s==="desc"?1:-1;if(r>i)return s==="desc"?-1:1}return s==="desc"?o-a:a-o}return 0};t.compareValues=n})(kC)),kC}var DC={},OC={},X8;function BK(){return X8||(X8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(OC)),OC}var K8;function nPe(){return K8||(K8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=BK(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,a){return Array.isArray(s)?!1:typeof s=="number"||typeof s=="boolean"||s==null||e.isSymbol(s)?!0:typeof s=="string"&&(r.test(s)||!n.test(s))||a!=null&&Object.hasOwn(a,s)}t.isKey=i})(DC)),DC}var Y8;function rPe(){return Y8||(Y8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tPe(),n=nPe(),r=RD();function i(s,a,o,l){if(s==null)return[];o=l?void 0:o,Array.isArray(s)||(s=Object.values(s)),Array.isArray(a)||(a=a==null?[null]:[a]),a.length===0&&(a=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const c=(m,b)=>{let y=m;for(let v=0;v<b.length&&y!=null;++v)y=y[b[v]];return y},u=(m,b)=>b==null||m==null?b:typeof m=="object"&&"key"in m?Object.hasOwn(b,m.key)?b[m.key]:c(b,m.path):typeof m=="function"?m(b):Array.isArray(m)?c(b,m):typeof b=="object"?b[m]:b,h=a.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return s.map(m=>({original:m,criteria:h.map(b=>u(b,m))})).slice().sort((m,b)=>{for(let y=0;y<h.length;y++){const v=e.compareValues(m.criteria[y],b.criteria[y],o[y]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=i})(PC)),PC}var LC={},Z8;function iPe(){return Z8||(Z8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),a=(o,l)=>{for(let c=0;c<o.length;c++){const u=o[c];Array.isArray(u)&&l<s?a(u,l+1):i.push(u)}};return a(n,0),i}t.flatten=e})(LC)),LC}var IC={},Q8;function HK(){return Q8||(Q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UK(),n=OD(),r=PK(),i=DK();function s(a,o,l){return r.isObject(l)&&(typeof o=="number"&&n.isArrayLike(l)&&e.isIndex(o)&&o<l.length||typeof o=="string"&&o in l)?i.eq(l[o],a):!1}t.isIterateeCall=s})(IC)),IC}var J8;function sPe(){return J8||(J8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rPe(),n=iPe(),r=HK();function i(s,...a){const o=a.length;return o>1&&r.isIterateeCall(s,a[0],a[1])?a=[]:o>2&&r.isIterateeCall(a[0],a[1],a[2])&&(a=[a[0]]),e.orderBy(s,n.flatten(a),["asc"])}t.sortBy=i})(RC)),RC}var jC,eH;function aPe(){return eH||(eH=1,jC=sPe().sortBy),jC}var oPe=aPe();const $w=Ja(oPe);var $K=t=>t.legend.settings,lPe=t=>t.legend.size,cPe=t=>t.legend.payload,uPe=Ge([cPe,$K],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?$w(r,n):r});function dPe(){return Ct(uPe)}var r_=1;function VK(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=E.useState({height:0,left:0,top:0,width:0}),r=E.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),a={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(a.height-e.height)>r_||Math.abs(a.left-e.left)>r_||Math.abs(a.top-e.top)>r_||Math.abs(a.width-e.width)>r_)&&n({height:a.height,left:a.left,top:a.top,width:a.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function Hi(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 fPe=typeof Symbol=="function"&&Symbol.observable||"@@observable",tH=fPe,UC=()=>Math.random().toString(36).substring(7).split("").join("."),hPe={INIT:`@@redux/INIT${UC()}`,REPLACE:`@@redux/REPLACE${UC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${UC()}`},pS=hPe;function ID(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 GK(t,e,n){if(typeof t!="function")throw new Error(Hi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Hi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Hi(1));return n(GK)(t,e)}let r=t,i=e,s=new Map,a=s,o=0,l=!1;function c(){a===s&&(a=new Map,s.forEach((v,x)=>{a.set(x,v)}))}function u(){if(l)throw new Error(Hi(3));return i}function h(v){if(typeof v!="function")throw new Error(Hi(4));if(l)throw new Error(Hi(5));let x=!0;c();const M=o++;return a.set(M,v),function(){if(x){if(l)throw new Error(Hi(6));x=!1,c(),a.delete(M),s=null}}}function g(v){if(!ID(v))throw new Error(Hi(7));if(typeof v.type>"u")throw new Error(Hi(8));if(typeof v.type!="string")throw new Error(Hi(17));if(l)throw new Error(Hi(9));try{l=!0,i=r(i,v)}finally{l=!1}return(s=a).forEach(M=>{M()}),v}function m(v){if(typeof v!="function")throw new Error(Hi(10));r=v,g({type:pS.REPLACE})}function b(){const v=h;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(Hi(11));function M(){const T=x;T.next&&T.next(u())}return M(),{unsubscribe:v(M)}},[tH](){return this}}}return g({type:pS.INIT}),{dispatch:g,subscribe:h,getState:u,replaceReducer:m,[tH]:b}}function pPe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:pS.INIT})>"u")throw new Error(Hi(12));if(typeof n(void 0,{type:pS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Hi(13))})}function WK(t){const e=Object.keys(t),n={};for(let s=0;s<e.length;s++){const a=e[s];typeof t[a]=="function"&&(n[a]=t[a])}const r=Object.keys(n);let i;try{pPe(n)}catch(s){i=s}return function(a={},o){if(i)throw i;let l=!1;const c={};for(let u=0;u<r.length;u++){const h=r[u],g=n[h],m=a[h],b=g(m,o);if(typeof b>"u")throw o&&o.type,new Error(Hi(14));c[h]=b,l=l||b!==m}return l=l||r.length!==Object.keys(a).length,l?c:a}}function mS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function mPe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Hi(15))};const a={getState:i.getState,dispatch:(l,...c)=>s(l,...c)},o=t.map(l=>l(a));return s=mS(...o)(i.dispatch),{...i,dispatch:s}}}function qK(t){return ID(t)&&"type"in t&&typeof t.type=="string"}var XK=Symbol.for("immer-nothing"),nH=Symbol.for("immer-draftable"),As=Symbol.for("immer-state");function go(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var da=Object,gm=da.getPrototypeOf,gS="constructor",Vw="prototype",jR="configurable",xS="enumerable",B_="writable",E0="value",yc=t=>!!t&&!!t[As];function Co(t){return t?KK(t)||Gw(t)||!!t[nH]||!!t[gS]?.[nH]||Ww(t)||qw(t):!1}var gPe=da[Vw][gS].toString(),rH=new WeakMap;function KK(t){if(!t||!jD(t))return!1;const e=gm(t);if(e===null||e===da[Vw])return!0;const n=da.hasOwnProperty.call(e,gS)&&e[gS];if(n===Object)return!0;if(!Ep(n))return!1;let r=rH.get(n);return r===void 0&&(r=Function.toString.call(n),rH.set(n,r)),r===gPe}function av(t,e,n=!0){ov(t)===0?(n?Reflect.ownKeys(t):da.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function ov(t){const e=t[As];return e?e.type_:Gw(t)?1:Ww(t)?2:qw(t)?3:0}var iH=(t,e,n=ov(t))=>n===2?t.has(e):da[Vw].hasOwnProperty.call(t,e),UR=(t,e,n=ov(t))=>n===2?t.get(e):t[e],vS=(t,e,n,r=ov(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function xPe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Gw=Array.isArray,Ww=t=>t instanceof Map,qw=t=>t instanceof Set,jD=t=>typeof t=="object",Ep=t=>typeof t=="function",FC=t=>typeof t=="boolean",Kl=t=>t.copy_||t.base_,UD=t=>t.modified_?t.copy_:t.base_;function FR(t,e){if(Ww(t))return new Map(t);if(qw(t))return new Set(t);if(Gw(t))return Array[Vw].slice.call(t);const n=KK(t);if(e===!0||e==="class_only"&&!n){const r=da.getOwnPropertyDescriptors(t);delete r[As];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o[B_]===!1&&(o[B_]=!0,o[jR]=!0),(o.get||o.set)&&(r[a]={[jR]:!0,[B_]:!0,[xS]:o[xS],[E0]:t[a]})}return da.create(gm(t),r)}else{const r=gm(t);if(r!==null&&n)return{...t};const i=da.create(r);return da.assign(i,t)}}function FD(t,e=!1){return Xw(t)||yc(t)||!Co(t)||(ov(t)>1&&da.defineProperties(t,{set:i_,add:i_,clear:i_,delete:i_}),da.freeze(t),e&&av(t,(n,r)=>{FD(r,!0)},!1)),t}function vPe(){go(2)}var i_={[E0]:vPe};function Xw(t){return t===null||!jD(t)?!0:da.isFrozen(t)}var bS="MapSet",zR="Patches",YK={};function xm(t){const e=YK[t];return e||go(0,t),e}var bPe=t=>!!YK[t],A0,ZK=()=>A0,yPe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:bPe(bS)?xm(bS):void 0});function sH(t,e){e&&(t.patchPlugin_=xm(zR),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function BR(t){HR(t),t.drafts_.forEach(_Pe),t.drafts_=null}function HR(t){t===A0&&(A0=t.parent_)}var aH=t=>A0=yPe(A0,t);function _Pe(t){const e=t[As];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function oH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[As].modified_&&(BR(e),go(4)),Co(t)&&(t=lH(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[As].base_,t,e)}else t=lH(e,n);return SPe(e,t,!0),BR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==XK?t:void 0}function lH(t,e){if(Xw(e))return e;const n=e[As];if(!n)return zD(e,t.handledSet_,t);if(!Kw(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);eY(n,t)}return n.copy_}function SPe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&FD(e,n)}function QK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Kw=(t,e)=>t.scope_===e,wPe=[];function JK(t,e,n,r){const i=Kl(t),s=t.type_;if(r!==void 0&&UR(i,r,s)===e){vS(i,r,n,s);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;av(i,(l,c)=>{if(yc(c)){const u=o.get(c)||[];u.push(l),o.set(c,u)}})}const a=t.draftLocations_.get(e)??wPe;for(const o of a)vS(i,o,n,s)}function MPe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!Kw(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const a=UD(s);JK(t,s.draft_??s,a,n),eY(s,i)})}function eY(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)}QK(t)}}function EPe(t,e,n){const{scope_:r}=t;if(yc(n)){const i=n[As];Kw(i,r)&&i.callbacks_.push(function(){H_(t);const a=UD(i);JK(t,n,a,e)})}else Co(n)&&t.callbacks_.push(function(){const s=Kl(t);UR(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&zD(UR(t.copy_,e,t.type_),r.handledSet_,r)})}function zD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||yc(t)||e.has(t)||!Co(t)||Xw(t)||(e.add(t),av(t,(r,i)=>{if(yc(i)){const s=i[As];if(Kw(s,n)){const a=UD(s);vS(t,r,a,t.type_),QK(s)}}else Co(i)&&zD(i,e,n)})),t}function APe(t,e){const n=Gw(t),r={type_:n?1:0,scope_:e?e.scope_:ZK(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,s=BD;n&&(i=[r],s=T0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,[o,r]}var BD={get(t,e){if(e===As)return t;const n=Kl(t);if(!iH(n,e,t.type_))return TPe(t,n,e);const r=n[e];if(t.finalized_||!Co(r))return r;if(r===zC(t.base_,e)){H_(t);const i=t.type_===1?+e:e,s=VR(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in Kl(t)},ownKeys(t){return Reflect.ownKeys(Kl(t))},set(t,e,n){const r=tY(Kl(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=zC(Kl(t),e),s=i?.[As];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(xPe(n,i)&&(n!==void 0||iH(t.base_,e,t.type_)))return!0;H_(t),$R(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),EPe(t,e,n)),!0},deleteProperty(t,e){return H_(t),zC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),$R(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Kl(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[B_]:!0,[jR]:t.type_!==1||e!=="length",[xS]:r[xS],[E0]:n[e]}},defineProperty(){go(11)},getPrototypeOf(t){return gm(t.base_)},setPrototypeOf(){go(12)}},T0={};av(BD,(t,e)=>{T0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});T0.deleteProperty=function(t,e){return T0.set.call(this,t,e,void 0)};T0.set=function(t,e,n){return BD.set.call(this,t[0],e,n,t[0])};function zC(t,e){const n=t[As];return(n?Kl(n):t)[e]}function TPe(t,e,n){const r=tY(e,n);return r?E0 in r?r[E0]:r.get?.call(t.draft_):void 0}function tY(t,e){if(!(e in t))return;let n=gm(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=gm(n)}}function $R(t){t.modified_||(t.modified_=!0,t.parent_&&$R(t.parent_))}function H_(t){t.copy_||(t.assigned_=new Map,t.copy_=FR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var CPe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Ep(n)&&!Ep(r)){const a=r;r=n;const o=this;return function(c=a,...u){return o.produce(c,h=>r.call(this,h,...u))}}Ep(r)||go(6),i!==void 0&&!Ep(i)&&go(7);let s;if(Co(n)){const a=aH(this),o=VR(a,n,void 0);let l=!0;try{s=r(o),l=!1}finally{l?BR(a):HR(a)}return sH(a,i),oH(s,a)}else if(!n||!jD(n)){if(s=r(n),s===void 0&&(s=n),s===XK&&(s=void 0),this.autoFreeze_&&FD(s,!0),i){const a=[],o=[];xm(zR).generateReplacementPatches_(n,s,{patches_:a,inversePatches_:o}),i(a,o)}return s}else go(1,n)},this.produceWithPatches=(n,r)=>{if(Ep(n))return(o,...l)=>this.produceWithPatches(o,c=>n(c,...l));let i,s;return[this.produce(n,r,(o,l)=>{i=o,s=l}),i,s]},FC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),FC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),FC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Co(e)||go(8),yc(e)&&(e=wo(e));const n=aH(this),r=VR(n,e,void 0);return r[As].isManual_=!0,HR(n),r}finishDraft(e,n){const r=e&&e[As];(!r||!r.isManual_)&&go(9);const{scope_:i}=r;return sH(i,n),oH(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const s=n[r];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}r>-1&&(n=n.slice(r+1));const i=xm(zR).applyPatches_;return yc(e)?i(e,n):this.produce(e,s=>i(s,n))}};function VR(t,e,n,r){const[i,s]=Ww(e)?xm(bS).proxyMap_(e,n):qw(e)?xm(bS).proxySet_(e,n):APe(e,n);return(n?.scope_??ZK()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?MPe(n,s,r):s.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:c}=l;s.modified_&&c&&c.generatePatches_(s,[],l)}),i}function wo(t){return yc(t)||go(10,t),nY(t)}function nY(t){if(!Co(t)||Xw(t))return t;const e=t[As];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=FR(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=FR(t,!0);return av(n,(i,s)=>{vS(n,i,nY(s))},r),e&&(e.finalized_=!1),n}var NPe=new CPe,rY=NPe.produce;function iY(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var RPe=iY(),PPe=iY,kPe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?mS:mS.apply(null,arguments)};function Za(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(ma(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>qK(r)&&r.type===t,n}var sY=class yx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,yx.prototype)}static get[Symbol.species](){return yx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new yx(...e[0].concat(this)):new yx(...e.concat(this))}};function cH(t){return Co(t)?rY(t,()=>{}):t}function s_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function DPe(t){return typeof t=="boolean"}var OPe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let a=new sY;return n&&(DPe(n)?a.push(RPe):a.push(PPe(n.extraArgument))),a},aY="RTK_autoBatch",cr=()=>t=>({payload:t,meta:{[aY]:!0}}),uH=t=>e=>{setTimeout(e,t)},oY=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,a=!1;const o=new Set,l=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:uH(10):t.type==="callback"?t.queueNotification:uH(t.timeout),c=()=>{a=!1,s&&(s=!1,o.forEach(u=>u()))};return Object.assign({},r,{subscribe(u){const h=()=>i&&u(),g=r.subscribe(h);return o.add(u),()=>{g(),o.delete(u)}},dispatch(u){try{return i=!u?.meta?.[aY],s=!i,s&&(a||(a=!0,l(c))),r.dispatch(u)}finally{i=!0}}})},LPe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new sY(t);return r&&i.push(oY(typeof r=="object"?r:void 0)),i};function IPe(t){const e=OPe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:a=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(ID(n))o=WK(n);else throw new Error(ma(1));let l;typeof r=="function"?l=r(e):l=e();let c=mS;i&&(c=kPe({trace:!1,...typeof i=="object"&&i}));const u=mPe(...l),h=LPe(u);let g=typeof a=="function"?a(h):h();const m=c(...g);return GK(o,s,m)}function lY(t){const e={},n=[];let r;const i={addCase(s,a){const o=typeof s=="string"?s:s.type;if(!o)throw new Error(ma(28));if(o in e)throw new Error(ma(29));return e[o]=a,i},addAsyncThunk(s,a){return a.pending&&(e[s.pending.type]=a.pending),a.rejected&&(e[s.rejected.type]=a.rejected),a.fulfilled&&(e[s.fulfilled.type]=a.fulfilled),a.settled&&n.push({matcher:s.settled,reducer:a.settled}),i},addMatcher(s,a){return n.push({matcher:s,reducer:a}),i},addDefaultCase(s){return r=s,i}};return t(i),[e,n,r]}function jPe(t){return typeof t=="function"}function UPe(t,e){let[n,r,i]=lY(e),s;if(jPe(t))s=()=>cH(t());else{const o=cH(t);s=()=>o}function a(o=s(),l){let c=[n[l.type],...r.filter(({matcher:u})=>u(l)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[i]),c.reduce((u,h)=>{if(h)if(yc(u)){const m=h(u,l);return m===void 0?u:m}else{if(Co(u))return rY(u,g=>h(g,l));{const g=h(u,l);if(g===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return u},o)}return a.getInitialState=s,a}var FPe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",zPe=(t=21)=>{let e="",n=t;for(;n--;)e+=FPe[Math.random()*64|0];return e},BPe=Symbol.for("rtk-slice-createasyncthunk");function HPe(t,e){return`${t}/${e}`}function $Pe({creators:t}={}){const e=t?.asyncThunk?.[BPe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(ma(11));const a=(typeof r.reducers=="function"?r.reducers(GPe()):r.reducers)||{},o=Object.keys(a),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(w,T){const A=typeof w=="string"?w:w.type;if(!A)throw new Error(ma(12));if(A in l.sliceCaseReducersByType)throw new Error(ma(13));return l.sliceCaseReducersByType[A]=T,c},addMatcher(w,T){return l.sliceMatchers.push({matcher:w,reducer:T}),c},exposeAction(w,T){return l.actionCreators[w]=T,c},exposeCaseReducer(w,T){return l.sliceCaseReducersByName[w]=T,c}};o.forEach(w=>{const T=a[w],A={reducerName:w,type:HPe(i,w),createNotation:typeof r.reducers=="function"};qPe(T)?KPe(A,T,c,e):WPe(A,T,c)});function u(){const[w={},T=[],A=void 0]=typeof r.extraReducers=="function"?lY(r.extraReducers):[r.extraReducers],P={...w,...l.sliceCaseReducersByType};return UPe(r.initialState,C=>{for(let j in P)C.addCase(j,P[j]);for(let j of l.sliceMatchers)C.addMatcher(j.matcher,j.reducer);for(let j of T)C.addMatcher(j.matcher,j.reducer);A&&C.addDefaultCase(A)})}const h=w=>w,g=new Map,m=new WeakMap;let b;function y(w,T){return b||(b=u()),b(w,T)}function v(){return b||(b=u()),b.getInitialState()}function x(w,T=!1){function A(C){let j=C[w];return typeof j>"u"&&T&&(j=s_(m,A,v)),j}function P(C=h){const j=s_(g,T,()=>new WeakMap);return s_(j,C,()=>{const N={};for(const[k,F]of Object.entries(r.selectors??{}))N[k]=VPe(F,C,()=>s_(m,C,v),T);return N})}return{reducerPath:w,getSelectors:P,get selectors(){return P(A)},selectSlice:A}}const M={name:i,reducer:y,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:v,...x(s),injectInto(w,{reducerPath:T,...A}={}){const P=T??s;return w.inject({reducerPath:P,reducer:y},A),{...M,...x(P,!0)}}};return M}}function VPe(t,e,n,r){function i(s,...a){let o=e(s);return typeof o>"u"&&r&&(o=n()),t(o,...a)}return i.unwrapped=t,i}var Xs=$Pe();function GPe(){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 WPe({type:t,reducerName:e,createNotation:n},r,i){let s,a;if("reducer"in r){if(n&&!XPe(r))throw new Error(ma(17));s=r.reducer,a=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,a?Za(t,a):Za(t))}function qPe(t){return t._reducerDefinitionType==="asyncThunk"}function XPe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function KPe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(ma(18));const{payloadCreator:s,fulfilled:a,pending:o,rejected:l,settled:c,options:u}=n,h=i(t,s,u);r.exposeAction(e,h),a&&r.addCase(h.fulfilled,a),o&&r.addCase(h.pending,o),l&&r.addCase(h.rejected,l),c&&r.addMatcher(h.settled,c),r.exposeCaseReducer(e,{fulfilled:a||a_,pending:o||a_,rejected:l||a_,settled:c||a_})}function a_(){}var YPe="task",cY="listener",uY="completed",HD="cancelled",ZPe=`task-${HD}`,QPe=`task-${uY}`,GR=`${cY}-${HD}`,JPe=`${cY}-${uY}`,Yw=class{constructor(t){this.code=t,this.message=`${YPe} ${HD} (reason: ${t})`}name="TaskAbortError";message},$D=(t,e)=>{if(typeof t!="function")throw new TypeError(ma(32))},yS=()=>{},dY=(t,e=yS)=>(t.catch(e),t),fY=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),vf=(t,e)=>{const n=t.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:e,configurable:!0,writable:!0}),t.abort(e))},bf=t=>{if(t.aborted){const{reason:e}=t;throw new Yw(e)}};function hY(t,e){let n=yS;return new Promise((r,i)=>{const s=()=>i(new Yw(t.reason));if(t.aborted){s();return}n=fY(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=yS})}var eke=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof Yw?"cancelled":"rejected",error:n}}finally{e?.()}},_S=t=>e=>dY(hY(t,e).then(n=>(bf(t),n))),pY=t=>{const e=_S(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:$p}=Object,dH={},Zw="listenerMiddleware",tke=(t,e)=>{const n=r=>fY(t,()=>vf(r,t.reason));return(r,i)=>{$D(r);const s=new AbortController;n(s);const a=eke(async()=>{bf(t),bf(s.signal);const o=await r({pause:_S(s.signal),delay:pY(s.signal),signal:s.signal});return bf(s.signal),o},()=>vf(s,QPe));return i?.autoJoin&&e.push(a.catch(yS)),{result:_S(t)(a),cancel(){vf(s,ZPe)}}}},nke=(t,e)=>{const n=async(r,i)=>{bf(e);let s=()=>{};const o=[new Promise((l,c)=>{let u=t({predicate:r,effect:(h,g)=>{g.unsubscribe(),l([h,g.getState(),g.getOriginalState()])}});s=()=>{u(),c()}})];i!=null&&o.push(new Promise(l=>setTimeout(l,i,null)));try{const l=await hY(e,Promise.race(o));return bf(e),l}finally{s()}};return(r,i)=>dY(n(r,i))},mY=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=Za(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(ma(21));return $D(s),{predicate:i,type:e,effect:s}},gY=$p(t=>{const{type:e,predicate:n,effect:r}=mY(t);return{id:zPe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(ma(22))}}},{withTypes:()=>gY}),fH=(t,e)=>{const{type:n,effect:r,predicate:i}=mY(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},WR=t=>{t.pending.forEach(e=>{vf(e,GR)})},rke=(t,e)=>()=>{for(const n of e.keys())WR(n);t.clear()},hH=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},xY=$p(Za(`${Zw}/add`),{withTypes:()=>xY}),ike=Za(`${Zw}/removeAll`),vY=$p(Za(`${Zw}/remove`),{withTypes:()=>vY}),ske=(...t)=>{console.error(`${Zw}/error`,...t)},lv=(t={})=>{const e=new Map,n=new Map,r=m=>{const b=n.get(m)??0;n.set(m,b+1)},i=m=>{const b=n.get(m)??1;b===1?n.delete(m):n.set(m,b-1)},{extra:s,onError:a=ske}=t;$D(a);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),b=>{m.unsubscribe(),b?.cancelActive&&WR(m)}),l=m=>{const b=fH(e,m)??gY(m);return o(b)};$p(l,{withTypes:()=>l});const c=m=>{const b=fH(e,m);return b&&(b.unsubscribe(),m.cancelActive&&WR(b)),!!b};$p(c,{withTypes:()=>c});const u=async(m,b,y,v)=>{const x=new AbortController,M=nke(l,x.signal),w=[];try{m.pending.add(x),r(m),await Promise.resolve(m.effect(b,$p({},y,{getOriginalState:v,condition:(T,A)=>M(T,A).then(Boolean),take:M,delay:pY(x.signal),pause:_S(x.signal),extra:s,signal:x.signal,fork:tke(x.signal,w),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((T,A,P)=>{T!==x&&(vf(T,GR),P.delete(T))})},cancel:()=>{vf(x,GR),m.pending.delete(x)},throwIfCancelled:()=>{bf(x.signal)}})))}catch(T){T instanceof Yw||hH(a,T,{raisedBy:"effect"})}finally{await Promise.all(w),vf(x,JPe),i(m),m.pending.delete(x)}},h=rke(e,n);return{middleware:m=>b=>y=>{if(!qK(y))return b(y);if(xY.match(y))return l(y.payload);if(ike.match(y)){h();return}if(vY.match(y))return c(y.payload);let v=m.getState();const x=()=>{if(v===dH)throw new Error(ma(23));return v};let M;try{if(M=b(y),e.size>0){const w=m.getState(),T=Array.from(e.values());for(const A of T){let P=!1;try{P=A.predicate(y,w,v)}catch(C){P=!1,hH(a,C,{raisedBy:"predicate"})}P&&u(A,y,m,x)}}}finally{v=dH}return M},startListening:l,stopListening:c,clearListeners:h}};function ma(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 ake={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},bY=Xs({name:"chartLayout",initialState:ake,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,s;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(s=e.payload.left)!==null&&s!==void 0?s:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:oke,setLayout:lke,setChartSize:cke,setScale:uke}=bY.actions,dke=bY.reducer;function yY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function pH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Np(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pH(Object(n),!0).forEach(function(r){fke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fke(t,e,n){return(e=hke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hke(t){var e=pke(t,"string");return typeof e=="symbol"?e:e+""}function pke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Yn(t,e,n){return xr(t)||xr(e)?n:ll(e)?Hf(t,e,n):typeof e=="function"?e(t):n}var mke=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:s,verticalAlign:a,layout:o}=e;if((o==="vertical"||o==="horizontal"&&a==="middle")&&s!=="center"&&Et(t[s]))return Np(Np({},t),{},{[s]:t[s]+(r||0)});if((o==="horizontal"||o==="vertical"&&s==="center")&&a!=="middle"&&Et(t[a]))return Np(Np({},t),{},{[a]:t[a]+(i||0)})}return t},Tc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",_Y=(t,e,n,r)=>{if(r)return t.map(o=>o.coordinate);var i,s,a=t.map(o=>(o.coordinate===e&&(i=!0),o.coordinate===n&&(s=!0),o.coordinate));return i||a.push(e),s||a.push(n),a},SY=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:a,realScaleType:o,isCategorical:l,categoricalDomain:c,tickCount:u,ticks:h,niceTicks:g,axisType:m}=t;if(!a)return null;var b=o==="scaleBand"&&a.bandwidth?a.bandwidth()/2:2,y=i==="category"&&a.bandwidth?a.bandwidth()/b:0;if(y=m==="angleAxis"&&s&&s.length>=2?Ci(s[0]-s[1])*2*y:y,h||g){var v=(h||g||[]).map((x,M)=>{var w=r?r.indexOf(x):x;return{coordinate:a(w)+y,value:x,offset:y,index:M}});return v.filter(x=>!Ya(x.coordinate))}return l&&c?c.map((x,M)=>({coordinate:a(x)+y,value:x,index:M,offset:y})):a.ticks&&u!=null?a.ticks(u).map((x,M)=>({coordinate:a(x)+y,value:x,offset:y,index:M})):a.domain().map((x,M)=>({coordinate:a(x)+y,value:r?r[x]:x,index:M,offset:y}))},mH=1e-4,gke=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-mH,s=Math.max(r[0],r[1])+mH,a=t(e[0]),o=t(e[n-1]);(a<i||a>s||o<i||o>s)&&t.domain([e[0],e[n-1]])}},xke=(t,e)=>{if(!e||e.length!==2||!Et(e[0])||!Et(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(!Et(t[0])||t[0]<n)&&(i[0]=n),(!Et(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},vke=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0,a=0;a<e;++a){var o=Ya(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=s,t[a][n][1]=s+o,s=t[a][n][1])}},bke=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,s=0;s<e;++s){var a=Ya(t[s][n][1])?t[s][n][0]:t[s][n][1];a>=0?(t[s][n][0]=i,t[s][n][1]=i+a,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},yke={sign:vke,expand:G3e,none:mm,silhouette:W3e,wiggle:q3e,positive:bke},_ke=(t,e,n)=>{var r=yke[n],i=V3e().keys(e).value((s,a)=>Number(Yn(s,a,0))).order(LR).offset(r);return i(t)};function wY(t){return t==null?void 0:String(t)}function gH(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:a}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!xr(i[e.dataKey])){var o=TK(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var l=Yn(i,xr(a)?e.dataKey:a);return xr(l)?null:e.scale(l)}var xH=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:s,index:a}=t;if(e.type==="category")return n[a]?n[a].coordinate+r:null;var o=Yn(s,e.dataKey,e.scale.domain()[a]);return xr(o)?null:e.scale(o)-i/2+r},Ske=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]},wke=t=>{var e=t.flat(2).filter(Et);return[Math.min(...e),Math.max(...e)]},Mke=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Eke=(t,e,n)=>{if(t!=null)return Mke(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:a}=s,o=a.reduce((l,c)=>{var u=yY(c,e,n),h=wke(u);return[Math.min(l[0],h[0]),Math.max(l[1],h[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},vH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,bH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,vm=(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=$w(e,u=>u.coordinate),s=1/0,a=1,o=i.length;a<o;a++){var l=i[a],c=i[a-1];s=Math.min((l.coordinate||0)-(c.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function yH(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Np(Np({},e),{},{dataKey:n,payload:r,value:i,name:s})}function Um(t,e){if(t)return String(t);if(typeof e=="string")return e}var Ake=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Tke=(t,e)=>e==="centric"?t.angle:t.radius,Cc=t=>t.layout.width,Nc=t=>t.layout.height,Cke=t=>t.layout.scale,MY=t=>t.layout.margin,Qw=Ge(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),Jw=Ge(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),EY="data-recharts-item-index",AY="data-recharts-item-data-key",cv=60;function _H(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function o_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_H(Object(n),!0).forEach(function(r){Nke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_H(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Nke(t,e,n){return(e=Rke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rke(t){var e=Pke(t,"string");return typeof e=="symbol"?e:e+""}function Pke(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 kke=t=>t.brush.height;function Dke(t){var e=Jw(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:cv;return n+i}return n},0)}function Oke(t){var e=Jw(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:cv;return n+i}return n},0)}function Lke(t){var e=Qw(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Ike(t){var e=Qw(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var fi=Ge([Cc,Nc,MY,kke,Dke,Oke,Lke,Ike,$K,lPe],(t,e,n,r,i,s,a,o,l,c)=>{var u={left:(n.left||0)+i,right:(n.right||0)+s},h={top:(n.top||0)+a,bottom:(n.bottom||0)+o},g=o_(o_({},h),u),m=g.bottom;g.bottom+=r,g=mke(g,l,c);var b=t-g.left-g.right,y=e-g.top-g.bottom;return o_(o_({brushBottom:m},g),{},{width:Math.max(b,0),height:Math.max(y,0)})}),jke=Ge(fi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),VD=Ge(Cc,Nc,(t,e)=>({x:0,y:0,width:t,height:e})),Uke=E.createContext(null),fs=()=>E.useContext(Uke)!=null,eM=t=>t.brush,tM=Ge([eM,fi,MY],(t,e,n)=>({height:t.height,x:Et(t.x)?t.x:e.left,y:Et(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Et(t.width)?t.width:e.width})),BC={},HC={},$C={},SH;function Fke(){return SH||(SH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let a,o=null;const l=s!=null&&s.includes("leading"),c=s==null||s.includes("trailing"),u=()=>{o!==null&&(n.apply(a,o),a=void 0,o=null)},h=()=>{c&&u(),y()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,h()},r)},b=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{b(),a=void 0,o=null},v=()=>{u()},x=function(...M){if(i?.aborted)return;a=this,o=M;const w=g==null;m(),l&&w&&u()};return x.schedule=m,x.cancel=y,x.flush=v,i?.addEventListener("abort",y,{once:!0}),x}t.debounce=e})($C)),$C}var wH;function zke(){return wH||(wH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Fke();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:a=!1,trailing:o=!0,maxWait:l}=s,c=Array(2);a&&(c[0]="leading"),o&&(c[1]="trailing");let u,h=null;const g=e.debounce(function(...y){u=r.apply(this,y),h=null},i,{edges:c}),m=function(...y){return l!=null&&(h===null&&(h=Date.now()),Date.now()-h>=l)?(u=r.apply(this,y),h=Date.now(),g.cancel(),g.schedule(),u):(g.apply(this,y),u)},b=()=>(g.flush(),u);return m.cancel=g.cancel,m.flush=b,m}t.debounce=n})(HC)),HC}var MH;function Bke(){return MH||(MH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zke();function n(r,i=0,s={}){const{leading:a=!0,trailing:o=!0}=s;return e.debounce(r,i,{leading:a,maxWait:i,trailing:o})}t.throttle=n})(BC)),BC}var VC,EH;function Hke(){return EH||(EH=1,VC=Bke().throttle),VC}var $ke=Hke();const Vke=Ja($ke);var SS=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var a=0;console.warn(n.replace(/%s/g,()=>i[a++]))}},TY=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:a}=n,o=bc(r)?t:Number(r),l=bc(i)?e:Number(i);return s&&s>0&&(o?l=o/s:l&&(o=l*s),a&&l!=null&&l>a&&(l=a)),{calculatedWidth:o,calculatedHeight:l}},Gke={width:0,height:0,overflow:"visible"},Wke={width:0,overflowX:"visible"},qke={height:0,overflowY:"visible"},Xke={},Kke=t=>{var{width:e,height:n}=t,r=bc(e),i=bc(n);return r&&i?Gke:r?Wke:i?qke:Xke};function Yke(t){var{width:e,height:n,aspect:r}=t,i=e,s=n;return i===void 0&&s===void 0?(i="100%",s="100%"):i===void 0?i=r&&r>0?void 0:"100%":s===void 0&&(s=r&&r>0?void 0:"100%"),{width:i,height:s}}function or(t){return Number.isFinite(t)}function cl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function qR(){return qR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},qR.apply(null,arguments)}function AH(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 TH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AH(Object(n),!0).forEach(function(r){Zke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zke(t,e,n){return(e=Qke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qke(t){var e=Jke(t,"string");return typeof e=="symbol"?e:e+""}function Jke(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 CY=E.createContext({width:-1,height:-1});function eDe(t){return cl(t.width)&&cl(t.height)}function NY(t){var{children:e,width:n,height:r}=t,i=E.useMemo(()=>({width:n,height:r}),[n,r]);return eDe(i)?E.createElement(CY.Provider,{value:i},e):null}var GD=()=>E.useContext(CY),tDe=E.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:a=0,minHeight:o,maxHeight:l,children:c,debounce:u=0,id:h,className:g,onResize:m,style:b={}}=t,y=E.useRef(null),v=E.useRef();v.current=m,E.useImperativeHandle(e,()=>y.current);var[x,M]=E.useState({containerWidth:r.width,containerHeight:r.height}),w=E.useCallback((j,N)=>{M(k=>{var F=Math.round(j),I=Math.round(N);return k.containerWidth===F&&k.containerHeight===I?k:{containerWidth:F,containerHeight:I}})},[]);E.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return iv;var j=I=>{var W,{width:D,height:$}=I[0].contentRect;w(D,$),(W=v.current)===null||W===void 0||W.call(v,D,$)};u>0&&(j=Vke(j,u,{trailing:!0,leading:!1}));var N=new ResizeObserver(j),{width:k,height:F}=y.current.getBoundingClientRect();return w(k,F),N.observe(y.current),()=>{N.disconnect()}},[w,u]);var{containerWidth:T,containerHeight:A}=x;SS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:P,calculatedHeight:C}=TY(T,A,{width:i,height:s,aspect:n,maxHeight:l});return SS(P!=null&&P>0||C!=null&&C>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,P,C,i,s,a,o,n),E.createElement("div",{id:h?"".concat(h):void 0,className:An("recharts-responsive-container",g),style:TH(TH({},b),{},{width:i,height:s,minWidth:a,minHeight:o,maxHeight:l}),ref:y},E.createElement("div",{style:Kke({width:i,height:s})},E.createElement(NY,{width:P,height:C},c)))}),GC=E.forwardRef((t,e)=>{var n=GD();if(cl(n.width)&&cl(n.height))return t.children;var{width:r,height:i}=Yke({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:a}=TY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Et(s)&&Et(a)?E.createElement(NY,{width:s,height:a},t.children):E.createElement(tDe,qR({},t,{width:r,height:i,ref:e}))});function RY(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 nM=()=>{var t,e=fs(),n=Ct(jke),r=Ct(tM),i=(t=Ct(eM))===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}},nDe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},PY=()=>{var t;return(t=Ct(fi))!==null&&t!==void 0?t:nDe},WD=()=>Ct(Cc),qD=()=>Ct(Nc),rDe=()=>Ct(t=>t.layout.margin),Sn=t=>t.layout.layoutType,Fm=()=>Ct(Sn),iDe=()=>{var t=Fm();if(t==="horizontal"||t==="vertical")return t},sDe=()=>{var t=Fm();return t!==void 0},rM=t=>{var e=er(),n=fs(),{width:r,height:i}=t,s=GD(),a=r,o=i;return s&&(a=s.width>0?s.width:r,o=s.height>0?s.height:i),E.useEffect(()=>{!n&&cl(a)&&cl(o)&&e(cke({width:a,height:o}))},[e,n,a,o]),null},kY=Symbol.for("immer-nothing"),CH=Symbol.for("immer-draftable"),xa=Symbol.for("immer-state");function xo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var C0=Object.getPrototypeOf;function bm(t){return!!t&&!!t[xa]}function $f(t){return t?DY(t)||Array.isArray(t)||!!t[CH]||!!t.constructor?.[CH]||uv(t)||sM(t):!1}var aDe=Object.prototype.constructor.toString(),NH=new WeakMap;function DY(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=NH.get(n);return r===void 0&&(r=Function.toString.call(n),NH.set(n,r)),r===aDe}function wS(t,e,n=!0){iM(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 iM(t){const e=t[xa];return e?e.type_:Array.isArray(t)?1:uv(t)?2:sM(t)?3:0}function XR(t,e){return iM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function OY(t,e,n){const r=iM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function oDe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function uv(t){return t instanceof Map}function sM(t){return t instanceof Set}function Gd(t){return t.copy_||t.base_}function KR(t,e){if(uv(t))return new Map(t);if(sM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=DY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[xa];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[a]})}return Object.create(C0(t),r)}else{const r=C0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function XD(t,e=!1){return aM(t)||bm(t)||!$f(t)||(iM(t)>1&&Object.defineProperties(t,{set:l_,add:l_,clear:l_,delete:l_}),Object.freeze(t),e&&Object.values(t).forEach(n=>XD(n,!0))),t}function lDe(){xo(2)}var l_={value:lDe};function aM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var cDe={};function Vf(t){const e=cDe[t];return e||xo(0,t),e}var N0;function LY(){return N0}function uDe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function RH(t,e){e&&(Vf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function YR(t){ZR(t),t.drafts_.forEach(dDe),t.drafts_=null}function ZR(t){t===N0&&(N0=t.parent_)}function PH(t){return N0=uDe(N0,t)}function dDe(t){const e=t[xa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function kH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[xa].modified_&&(YR(e),xo(4)),$f(t)&&(t=MS(e,t),e.parent_||ES(e,t)),e.patches_&&Vf("Patches").generateReplacementPatches_(n[xa].base_,t,e.patches_,e.inversePatches_)):t=MS(e,n,[]),YR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==kY?t:void 0}function MS(t,e,n){if(aM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[xa];if(!i)return wS(e,(s,a)=>DH(t,i,e,s,a,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return ES(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let a=s,o=!1;i.type_===3&&(a=new Set(s),s.clear(),o=!0),wS(a,(l,c)=>DH(t,i,s,l,c,n,o),r),ES(t,s,!1),n&&t.patches_&&Vf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function DH(t,e,n,r,i,s,a){if(i==null||typeof i!="object"&&!a)return;const o=aM(i);if(!(o&&!a)){if(bm(i)){const l=s&&e&&e.type_!==3&&!XR(e.assigned_,r)?s.concat(r):void 0,c=MS(t,i,l);if(OY(n,r,c),bm(c))t.canAutoFreeze_=!1;else return}else a&&n.add(i);if($f(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;MS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(uv(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&ES(t,i)}}}function ES(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&XD(e,n)}function fDe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:LY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=KD;n&&(i=[r],s=R0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}var KD={get(t,e){if(e===xa)return t;const n=Gd(t);if(!XR(n,e))return hDe(t,n,e);const r=n[e];return t.finalized_||!$f(r)?r:r===WC(t.base_,e)?(qC(t),t.copy_[e]=JR(r,t)):r},has(t,e){return e in Gd(t)},ownKeys(t){return Reflect.ownKeys(Gd(t))},set(t,e,n){const r=IY(Gd(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=WC(Gd(t),e),s=i?.[xa];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(oDe(n,i)&&(n!==void 0||XR(t.base_,e)))return!0;qC(t),QR(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 WC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,qC(t),QR(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Gd(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){xo(11)},getPrototypeOf(t){return C0(t.base_)},setPrototypeOf(){xo(12)}},R0={};wS(KD,(t,e)=>{R0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});R0.deleteProperty=function(t,e){return R0.set.call(this,t,e,void 0)};R0.set=function(t,e,n){return KD.set.call(this,t[0],e,n,t[0])};function WC(t,e){const n=t[xa];return(n?Gd(n):t)[e]}function hDe(t,e,n){const r=IY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function IY(t,e){if(!(e in t))return;let n=C0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=C0(n)}}function QR(t){t.modified_||(t.modified_=!0,t.parent_&&QR(t.parent_))}function qC(t){t.copy_||(t.copy_=KR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var pDe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const s=n;n=e;const a=this;return function(l=s,...c){return a.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&xo(6),r!==void 0&&typeof r!="function"&&xo(7);let i;if($f(e)){const s=PH(this),a=JR(e,void 0);let o=!0;try{i=n(a),o=!1}finally{o?YR(s):ZR(s)}return RH(s,r),kH(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===kY&&(i=void 0),this.autoFreeze_&&XD(i,!0),r){const s=[],a=[];Vf("Patches").generateReplacementPatches_(e,i,s,a),r(s,a)}return i}else xo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,l=>e(l,...o));let r,i;return[this.produce(e,n,(a,o)=>{r=a,i=o}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){$f(t)||xo(8),bm(t)&&(t=mDe(t));const e=PH(this),n=JR(t,void 0);return n[xa].isManual_=!0,ZR(e),n}finishDraft(t,e){const n=t&&t[xa];(!n||!n.isManual_)&&xo(9);const{scope_:r}=n;return RH(r,e),kH(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=Vf("Patches").applyPatches_;return bm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function JR(t,e){const n=uv(t)?Vf("MapSet").proxyMap_(t,e):sM(t)?Vf("MapSet").proxySet_(t,e):fDe(t,e);return(e?e.scope_:LY()).drafts_.push(n),n}function mDe(t){return bm(t)||xo(10,t),jY(t)}function jY(t){if(!$f(t)||aM(t))return t;const e=t[xa];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=KR(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=KR(t,!0);return wS(n,(i,s)=>{OY(n,i,jY(s))},r),e&&(e.finalized_=!1),n}var gDe=new pDe;gDe.produce;var xDe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},UY=Xs({name:"legend",initialState:xDe,reducers:{setLegendSize(t,e){t.size.width=e.payload.width,t.size.height=e.payload.height},setLegendSettings(t,e){t.settings.align=e.payload.align,t.settings.layout=e.payload.layout,t.settings.verticalAlign=e.payload.verticalAlign,t.settings.itemSorter=e.payload.itemSorter},addLegendPayload:{reducer(t,e){t.payload.push(e.payload)},prepare:cr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=wo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:cr()},removeLegendPayload:{reducer(t,e){var n=wo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:cr()}}}),{setLegendSize:OH,setLegendSettings:vDe,addLegendPayload:FY,replaceLegendPayload:zY,removeLegendPayload:BY}=UY.actions,bDe=UY.reducer,yDe=["contextPayload"];function eP(){return eP=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},eP.apply(null,arguments)}function LH(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 ym(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LH(Object(n),!0).forEach(function(r){_De(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _De(t,e,n){return(e=SDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SDe(t){var e=wDe(t,"string");return typeof e=="symbol"?e:e+""}function wDe(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 MDe(t,e){if(t==null)return{};var n,r,i=EDe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function EDe(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 ADe(t){return t.value}function TDe(t){var{contextPayload:e}=t,n=MDe(t,yDe),r=FK(e,t.payloadUniqBy,ADe),i=ym(ym({},n),{},{payload:r});return E.isValidElement(t.content)?E.cloneElement(t.content,i):typeof t.content=="function"?E.createElement(t.content,i):E.createElement(SRe,i)}function CDe(t,e,n,r,i,s){var{layout:a,align:o,verticalAlign:l}=e,c,u;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&a==="vertical"?c={left:((r||0)-s.width)/2}:c=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(l==="middle"?u={top:((i||0)-s.height)/2}:u=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),ym(ym({},c),u)}function NDe(t){var e=er();return E.useEffect(()=>{e(vDe(t))},[e,t]),null}function RDe(t){var e=er();return E.useEffect(()=>(e(OH(t)),()=>{e(OH({width:0,height:0}))}),[e,t]),null}function PDe(t,e,n,r){return t==="vertical"&&Et(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var kDe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function HY(t){var e=Qr(t,kDe),n=dPe(),r=p3e(),i=rDe(),{width:s,height:a,wrapperStyle:o,portal:l}=e,[c,u]=VK([n]),h=WD(),g=qD();if(h==null||g==null)return null;var m=h-(i?.left||0)-(i?.right||0),b=PDe(e.layout,a,s,m),y=l?o:ym(ym({position:"absolute",width:b?.width||s||"auto",height:b?.height||a||"auto"},CDe(o,e,i,h,g,c)),o),v=l??r;if(v==null||n==null)return null;var x=E.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:u},E.createElement(NDe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&E.createElement(RDe,{width:c.width,height:c.height}),E.createElement(TDe,eP({},e,b,{margin:i,chartWidth:h,chartHeight:g,contextPayload:n})));return Jl.createPortal(x,v)}HY.displayName="Legend";function tP(){return tP=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},tP.apply(null,arguments)}function IH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IH(Object(n),!0).forEach(function(r){DDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DDe(t,e,n){return(e=ODe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ODe(t){var e=LDe(t,"string");return typeof e=="symbol"?e:e+""}function LDe(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 IDe(t){return Array.isArray(t)&&ll(t[0])&&ll(t[1])?t.join(" ~ "):t}var jDe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:a,itemSorter:o,wrapperClassName:l,labelClassName:c,label:u,labelFormatter:h,accessibilityLayer:g=!1}=t,m=()=>{if(s&&s.length){var A={padding:0,margin:0},P=(o?$w(s,o):s).map((C,j)=>{if(C.type==="none")return null;var N=C.formatter||a||IDe,{value:k,name:F}=C,I=k,W=F;if(N){var D=N(k,F,C,j,s);if(Array.isArray(D))[I,W]=D;else if(D!=null)I=D;else return null}var $=XC({display:"block",paddingTop:4,paddingBottom:4,color:C.color||"#000"},r);return E.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(j),style:$},ll(W)?E.createElement("span",{className:"recharts-tooltip-item-name"},W):null,ll(W)?E.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,E.createElement("span",{className:"recharts-tooltip-item-value"},I),E.createElement("span",{className:"recharts-tooltip-item-unit"},C.unit||""))});return E.createElement("ul",{className:"recharts-tooltip-item-list",style:A},P)}return null},b=XC({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=XC({margin:0},i),v=!xr(u),x=v?u:"",M=An("recharts-default-tooltip",l),w=An("recharts-tooltip-label",c);v&&h&&s!==void 0&&s!==null&&(x=h(u,s));var T=g?{role:"status","aria-live":"assertive"}:{};return E.createElement("div",tP({className:M,style:b},T),E.createElement("p",{className:w,style:y},E.isValidElement(x)?x:"".concat(x)),m())},ix="recharts-tooltip-wrapper",UDe={visibility:"hidden"};function FDe(t){var{coordinate:e,translateX:n,translateY:r}=t;return An(ix,{["".concat(ix,"-right")]:Et(n)&&e&&Et(e.x)&&n>=e.x,["".concat(ix,"-left")]:Et(n)&&e&&Et(e.x)&&n<e.x,["".concat(ix,"-bottom")]:Et(r)&&e&&Et(e.y)&&r>=e.y,["".concat(ix,"-top")]:Et(r)&&e&&Et(e.y)&&r<e.y})}function jH(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:a,tooltipDimension:o,viewBox:l,viewBoxDimension:c}=t;if(s&&Et(s[r]))return s[r];var u=n[r]-o-(i>0?i:0),h=n[r]+i;if(e[r])return a[r]?u:h;var g=l[r];if(g==null)return 0;if(a[r]){var m=u,b=g;return m<b?Math.max(h,g):Math.max(u,g)}if(c==null)return 0;var y=h+o,v=g+c;return y>v?Math.max(u,g):Math.max(h,g)}function zDe(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 BDe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:a,useTranslate3d:o,viewBox:l}=t,c,u,h;return a.height>0&&a.width>0&&n?(u=jH({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.width,viewBox:l,viewBoxDimension:l.width}),h=jH({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.height,viewBox:l,viewBoxDimension:l.height}),c=zDe({translateX:u,translateY:h,useTranslate3d:o})):c=UDe,{cssProperties:c,cssClasses:FDe({translateX:u,translateY:h,coordinate:n})}}function UH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function c_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UH(Object(n),!0).forEach(function(r){nP(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nP(t,e,n){return(e=HDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HDe(t){var e=$De(t,"string");return typeof e=="symbol"?e:e+""}function $De(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 VDe extends E.PureComponent{constructor(){super(...arguments),nP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),nP(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,s;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:s,coordinate:a,hasPayload:o,isAnimationActive:l,offset:c,position:u,reverseDirection:h,useTranslate3d:g,viewBox:m,wrapperStyle:b,lastBoundingBox:y,innerRef:v,hasPortalFromProps:x}=this.props,{cssClasses:M,cssProperties:w}=BDe({allowEscapeViewBox:n,coordinate:a,offsetTopLeft:c,position:u,reverseDirection:h,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),T=x?{}:c_(c_({transition:l&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),A=c_(c_({},T),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},b);return E.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:A,ref:v},s)}}var $Y=()=>{var t;return(t=Ct(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function rP(){return rP=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},rP.apply(null,arguments)}function FH(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 zH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FH(Object(n),!0).forEach(function(r){GDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GDe(t,e,n){return(e=WDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WDe(t){var e=qDe(t,"string");return typeof e=="symbol"?e:e+""}function qDe(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 BH={curveBasisClosed:D3e,curveBasisOpen:O3e,curveBasis:k3e,curveBumpX:v3e,curveBumpY:b3e,curveLinearClosed:L3e,curveLinear:Bw,curveMonotoneX:I3e,curveMonotoneY:j3e,curveNatural:U3e,curveStep:F3e,curveStepAfter:B3e,curveStepBefore:z3e},AS=t=>or(t.x)&&or(t.y),HH=t=>t.base!=null&&AS(t.base)&&AS(t),sx=t=>t.x,ax=t=>t.y,XDe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(rv(t));return(n==="curveMonotone"||n==="curveBump")&&e?BH["".concat(n).concat(e==="vertical"?"Y":"X")]:BH[n]||Bw},KDe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,a=XDe(e,i),o=s?n.filter(AS):n,l;if(Array.isArray(r)){var c=n.map((m,b)=>zH(zH({},m),{},{base:r[b]}));i==="vertical"?l=t_().y(ax).x1(sx).x0(m=>m.base.x):l=t_().x(sx).y1(ax).y0(m=>m.base.y);var u=l.defined(HH).curve(a),h=s?c.filter(HH):c;return u(h)}i==="vertical"&&Et(r)?l=t_().y(ax).x1(sx).x0(r):Et(r)?l=t_().x(sx).y1(ax).y0(r):l=pK().x(sx).y(ax);var g=l.defined(AS).curve(a);return g(o)},Vp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?KDe(t):r;return E.createElement("path",rP({},Gs(t),DD(t),{className:An("recharts-curve",e),d:s===null?void 0:s,ref:i}))},YDe=["x","y","top","left","width","height","className"];function iP(){return iP=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},iP.apply(null,arguments)}function $H(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ZDe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$H(Object(n),!0).forEach(function(r){QDe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$H(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QDe(t,e,n){return(e=JDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JDe(t){var e=eOe(t,"string");return typeof e=="symbol"?e:e+""}function eOe(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 tOe(t,e){if(t==null)return{};var n,r,i=nOe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nOe(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 rOe=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),iOe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:a=0,className:o}=t,l=tOe(t,YDe),c=ZDe({x:e,y:n,top:r,left:i,width:s,height:a},l);return!Et(e)||!Et(n)||!Et(s)||!Et(a)||!Et(r)||!Et(i)?null:E.createElement("path",iP({},Es(c),{className:An("recharts-cross",o),d:rOe(e,n,s,a,r,i)}))};function sOe(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 VH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function GH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VH(Object(n),!0).forEach(function(r){aOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aOe(t,e,n){return(e=oOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oOe(t){var e=lOe(t,"string");return typeof e=="symbol"?e:e+""}function lOe(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 cOe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),VY=(t,e,n)=>t.map(r=>"".concat(cOe(r)," ").concat(e,"ms ").concat(n)).join(","),uOe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),P0=(t,e)=>Object.keys(e).reduce((n,r)=>GH(GH({},n),{},{[r]:t(r,e[r])}),{});function WH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ri(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WH(Object(n),!0).forEach(function(r){dOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dOe(t,e,n){return(e=fOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fOe(t){var e=hOe(t,"string");return typeof e=="symbol"?e:e+""}function hOe(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 TS=(t,e,n)=>t+(e-t)*n,sP=t=>{var{from:e,to:n}=t;return e!==n},GY=(t,e,n)=>{var r=P0((i,s)=>{if(sP(s)){var[a,o]=t(s.from,s.to,s.velocity);return ri(ri({},s),{},{from:a,velocity:o})}return s},e);return n<1?P0((i,s)=>sP(s)?ri(ri({},s),{},{velocity:TS(s.velocity,r[i].velocity,n),from:TS(s.from,r[i].from,n)}):s,e):GY(t,r,n-1)};function pOe(t,e,n,r,i,s){var a,o=r.reduce((g,m)=>ri(ri({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),l=()=>P0((g,m)=>m.from,o),c=()=>!Object.values(o).filter(sP).length,u=null,h=g=>{a||(a=g);var m=g-a,b=m/n.dt;o=GY(n,o,b),i(ri(ri(ri({},t),e),l())),a=g,c()||(u=s.setTimeout(h))};return()=>(u=s.setTimeout(h),()=>{var g;(g=u)===null||g===void 0||g()})}function mOe(t,e,n,r,i,s,a){var o=null,l=i.reduce((h,g)=>ri(ri({},h),{},{[g]:[t[g],e[g]]}),{}),c,u=h=>{c||(c=h);var g=(h-c)/r,m=P0((y,v)=>TS(...v,n(g)),l);if(s(ri(ri(ri({},t),e),m)),g<1)o=a.setTimeout(u);else{var b=P0((y,v)=>TS(...v,n(1)),l);s(ri(ri(ri({},t),e),b))}};return()=>(o=a.setTimeout(u),()=>{var h;(h=o)===null||h===void 0||h()})}const gOe=(t,e,n,r,i,s)=>{var a=uOe(t,e);return n==null?()=>(i(ri(ri({},t),e)),()=>{}):n.isStepper===!0?pOe(t,e,n,a,i,s):mOe(t,e,n,r,a,i,s)};var CS=1e-4,WY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],qY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),qH=(t,e)=>n=>{var r=WY(t,e);return qY(r,n)},xOe=(t,e)=>n=>{var r=WY(t,e),i=[...r.map((s,a)=>s*a).slice(1),0];return qY(i,n)},vOe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,s=n[0].split("(");if(s[0]==="cubic-bezier"&&((i=s[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var a=s[1].split(")")[0].split(",").map(o=>parseFloat(o));return[a[0],a[1],a[2],a[3]]}}}return n.length===4?n:[0,0,1,1]},bOe=(t,e,n,r)=>{var i=qH(t,n),s=qH(e,r),a=xOe(t,n),o=c=>c>1?1:c<0?0:c,l=c=>{for(var u=c>1?1:c,h=u,g=0;g<8;++g){var m=i(h)-u,b=a(h);if(Math.abs(m-u)<CS||b<CS)return s(h);h=o(h-m/b)}return s(h)};return l.isStepper=!1,l},XH=function(){return bOe(...vOe(...arguments))},yOe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,s=(a,o,l)=>{var c=-(a-o)*n,u=l*r,h=l+(c-u)*i/1e3,g=l*i/1e3+a;return Math.abs(g-o)<CS&&Math.abs(h)<CS?[o,0]:[g,h]};return s.isStepper=!0,s.dt=i,s},_Oe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return XH(t);case"spring":return yOe();default:if(t.split("(")[0]==="cubic-bezier")return XH(t)}return typeof t=="function"?t:null};function SOe(t){var e,n=()=>null,r=!1,i=null,s=a=>{if(!r){if(Array.isArray(a)){if(!a.length)return;var o=a,[l,...c]=o;if(typeof l=="number"){i=t.setTimeout(s.bind(null,c),l);return}s(l),i=t.setTimeout(s.bind(null,c));return}typeof a=="string"&&(e=a,n(e)),typeof a=="object"&&(e=a,n(e)),typeof a=="function"&&a()}};return{stop:()=>{r=!0},start:a=>{r=!1,i&&(i(),i=null),s(a)},subscribe:a=>(n=a,()=>{n=()=>null}),getTimeoutController:()=>t}}class wOe{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,s=a=>{a-r>=n?e(a):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>{i!=null&&cancelAnimationFrame(i)}}}function MOe(){return SOe(new wOe)}var EOe=E.createContext(MOe);function AOe(t,e){var n=E.useContext(EOe);return E.useMemo(()=>e??n(t),[t,e,n])}var TOe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),zm={devToolsEnabled:!1,isSsr:TOe()},COe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},KH={t:0},KC={t:1};function dv(t){var e=Qr(t,COe),{isActive:n,canBegin:r,duration:i,easing:s,begin:a,onAnimationEnd:o,onAnimationStart:l,children:c}=e,u=n==="auto"?!zm.isSsr:n,h=AOe(e.animationId,e.animationManager),[g,m]=E.useState(u?KH:KC),b=E.useRef(null);return E.useEffect(()=>{u||m(KC)},[u]),E.useEffect(()=>{if(!u||!r)return iv;var y=gOe(KH,KC,_Oe(s),i,m,h.getTimeoutController()),v=()=>{b.current=y()};return h.start([l,a,v,i,o]),()=>{h.stop(),b.current&&b.current(),o()}},[u,r,i,s,a,l,o,h]),c(g.t)}function fv(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=E.useRef(M0(e)),r=E.useRef(t);return r.current!==t&&(n.current=M0(e),r.current=t),n.current}var NOe=["radius"],ROe=["radius"];function YH(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 ZH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YH(Object(n),!0).forEach(function(r){POe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function POe(t,e,n){return(e=kOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kOe(t){var e=DOe(t,"string");return typeof e=="symbol"?e:e+""}function DOe(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 NS(){return NS=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},NS.apply(null,arguments)}function QH(t,e){if(t==null)return{};var n,r,i=OOe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function OOe(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 JH=(t,e,n,r,i)=>{var s=Math.min(Math.abs(n)/2,Math.abs(r)/2),a=r>=0?1:-1,o=n>=0?1:-1,l=r>=0&&n>=0||r<0&&n<0?1:0,c;if(s>0&&i instanceof Array){for(var u=[0,0,0,0],h=0,g=4;h<g;h++)u[h]=i[h]>s?s:i[h];c="M".concat(t,",").concat(e+a*u[0]),u[0]>0&&(c+="A ".concat(u[0],",").concat(u[0],",0,0,").concat(l,",").concat(t+o*u[0],",").concat(e)),c+="L ".concat(t+n-o*u[1],",").concat(e),u[1]>0&&(c+="A ".concat(u[1],",").concat(u[1],",0,0,").concat(l,`,
- `).concat(t+n,",").concat(e+a*u[1])),c+="L ".concat(t+n,",").concat(e+r-a*u[2]),u[2]>0&&(c+="A ".concat(u[2],",").concat(u[2],",0,0,").concat(l,`,
- `).concat(t+n-o*u[2],",").concat(e+r)),c+="L ".concat(t+o*u[3],",").concat(e+r),u[3]>0&&(c+="A ".concat(u[3],",").concat(u[3],",0,0,").concat(l,`,
- `).concat(t,",").concat(e+r-a*u[3])),c+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);c="M ".concat(t,",").concat(e+a*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+o*m,",").concat(e,`
- L `).concat(t+n-o*m,",").concat(e,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n,",").concat(e+a*m,`
- L `).concat(t+n,",").concat(e+r-a*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n-o*m,",").concat(e+r,`
- L `).concat(t+o*m,",").concat(e+r,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t,",").concat(e+r-a*m," Z")}else c="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return c},e$={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},XY=t=>{var e=Qr(t,e$),n=E.useRef(null),[r,i]=E.useState(-1);E.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var V=n.current.getTotalLength();V&&i(V)}catch{}},[]);var{x:s,y:a,width:o,height:l,radius:c,className:u}=e,{animationEasing:h,animationDuration:g,animationBegin:m,isAnimationActive:b,isUpdateAnimationActive:y}=e,v=E.useRef(o),x=E.useRef(l),M=E.useRef(s),w=E.useRef(a),T=E.useMemo(()=>({x:s,y:a,width:o,height:l,radius:c}),[s,a,o,l,c]),A=fv(T,"rectangle-");if(s!==+s||a!==+a||o!==+o||l!==+l||o===0||l===0)return null;var P=An("recharts-rectangle",u);if(!y){var C=Es(e),{radius:j}=C,N=QH(C,NOe);return E.createElement("path",NS({},N,{radius:typeof c=="number"?c:void 0,className:P,d:JH(s,a,o,l,c)}))}var k=v.current,F=x.current,I=M.current,W=w.current,D="0px ".concat(r===-1?1:r,"px"),$="".concat(r,"px 0px"),G=VY(["strokeDasharray"],g,typeof h=="string"?h:e$.animationEasing);return E.createElement(dv,{animationId:A,key:A,canBegin:r>0,duration:g,easing:h,isActive:y,begin:m},V=>{var Z=ar(k,o,V),K=ar(F,l,V),ee=ar(I,s,V),H=ar(W,a,V);n.current&&(v.current=Z,x.current=K,M.current=ee,w.current=H);var Y;b?V>0?Y={transition:G,strokeDasharray:$}:Y={strokeDasharray:D}:Y={strokeDasharray:$};var te=Es(e),{radius:ae}=te,fe=QH(te,ROe);return E.createElement("path",NS({},fe,{radius:typeof c=="number"?c:void 0,className:P,d:JH(ee,H,Z,K,c),ref:n,style:ZH(ZH({},Y),e.style)}))})};function t$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function n$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t$(Object(n),!0).forEach(function(r){LOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LOe(t,e,n){return(e=IOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IOe(t){var e=jOe(t,"string");return typeof e=="symbol"?e:e+""}function jOe(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 RS=Math.PI/180,UOe=t=>t*180/Math.PI,qr=(t,e,n,r)=>({x:t+Math.cos(-RS*r)*n,y:e+Math.sin(-RS*r)*n}),KY=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},FOe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},zOe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,a=FOe({x:n,y:r},{x:i,y:s});if(a<=0)return{radius:a,angle:0};var o=(n-i)/a,l=Math.acos(o);return r>s&&(l=2*Math.PI-l),{radius:a,angle:UOe(l),angleInRadian:l}},BOe=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),s=Math.min(r,i);return{startAngle:e-s*360,endAngle:n-s*360}},HOe=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),s=Math.floor(r/360),a=Math.min(i,s);return t+a*360},$Oe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=zOe({x:n,y:r},e),{innerRadius:a,outerRadius:o}=e;if(i<a||i>o||i===0)return null;var{startAngle:l,endAngle:c}=BOe(e),u=s,h;if(l<=c){for(;u>c;)u-=360;for(;u<l;)u+=360;h=u>=l&&u<=c}else{for(;u>l;)u-=360;for(;u<c;)u+=360;h=u>=c&&u<=l}return h?n$(n$({},e),{},{radius:i,angle:HOe(u,e)}):null};function YY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,a=qr(e,n,r,i),o=qr(e,n,r,s);return{points:[a,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function aP(){return aP=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},aP.apply(null,arguments)}var VOe=(t,e)=>{var n=Ci(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},u_=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:a,cornerRadius:o,cornerIsExternal:l}=t,c=o*(a?1:-1)+r,u=Math.asin(o/c)/RS,h=l?i:i+s*u,g=qr(e,n,c,h),m=qr(e,n,r,h),b=l?i-s*u:i,y=qr(e,n,c*Math.cos(u*RS),b);return{center:g,circleTangency:m,lineTangency:y,theta:u}},ZY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:a}=t,o=VOe(s,a),l=s+o,c=qr(e,n,i,s),u=qr(e,n,i,l),h="M ".concat(c.x,",").concat(c.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(s>l),`,
- `).concat(u.x,",").concat(u.y,`
- `);if(r>0){var g=qr(e,n,r,s),m=qr(e,n,r,l);h+="L ".concat(m.x,",").concat(m.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(s<=l),`,
- `).concat(g.x,",").concat(g.y," Z")}else h+="L ".concat(e,",").concat(n," Z");return h},GOe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:a,cornerIsExternal:o,startAngle:l,endAngle:c}=t,u=Ci(c-l),{circleTangency:h,lineTangency:g,theta:m}=u_({cx:e,cy:n,radius:i,angle:l,sign:u,cornerRadius:s,cornerIsExternal:o}),{circleTangency:b,lineTangency:y,theta:v}=u_({cx:e,cy:n,radius:i,angle:c,sign:-u,cornerRadius:s,cornerIsExternal:o}),x=o?Math.abs(l-c):Math.abs(l-c)-m-v;if(x<0)return a?"M ".concat(g.x,",").concat(g.y,`
- a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
- a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
- `):ZY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:l,endAngle:c});var M="M ".concat(g.x,",").concat(g.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(h.x,",").concat(h.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(x>180),",").concat(+(u<0),",").concat(b.x,",").concat(b.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(y.x,",").concat(y.y,`
- `);if(r>0){var{circleTangency:w,lineTangency:T,theta:A}=u_({cx:e,cy:n,radius:r,angle:l,sign:u,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),{circleTangency:P,lineTangency:C,theta:j}=u_({cx:e,cy:n,radius:r,angle:c,sign:-u,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),N=o?Math.abs(l-c):Math.abs(l-c)-A-j;if(N<0&&s===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(C.x,",").concat(C.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(P.x,",").concat(P.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(N>180),",").concat(+(u>0),",").concat(w.x,",").concat(w.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(u<0),",").concat(T.x,",").concat(T.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},WOe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},QY=t=>{var e=Qr(t,WOe),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u,className:h}=e;if(s<i||c===u)return null;var g=An("recharts-sector",h),m=s-i,b=cs(a,m,0,!0),y;return b>0&&Math.abs(c-u)<360?y=GOe({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(b,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}):y=ZY({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:c,endAngle:u}),E.createElement("path",aP({},Es(e),{className:g,d:y}))};function qOe(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(NK(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:a,angle:o}=e,l=qr(r,i,s,o),c=qr(r,i,a,o);return[{x:l.x,y:l.y},{x:c.x,y:c.y}]}return YY(e)}}var YC={},ZC={},QC={},r$;function XOe(){return r$||(r$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=BK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(QC)),QC}var i$;function KOe(){return i$||(i$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XOe();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})(ZC)),ZC}var s$;function YOe(){return s$||(s$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=HK(),n=KOe();function r(i,s,a){a&&typeof a!="number"&&e.isIterateeCall(i,s,a)&&(s=a=void 0),i=n.toFinite(i),s===void 0?(s=i,i=0):s=n.toFinite(s),a=a===void 0?i<s?1:-1:n.toFinite(a);const o=Math.max(Math.ceil((s-i)/(a||1)),0),l=new Array(o);for(let c=0;c<o;c++)l[c]=i,i+=a;return l}t.range=r})(YC)),YC}var JC,a$;function ZOe(){return a$||(a$=1,JC=YOe().range),JC}var QOe=ZOe();const JY=Ja(QOe);function Xu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function JOe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function YD(t){let e,n,r;t.length!==2?(e=Xu,n=(o,l)=>Xu(t(o),l),r=(o,l)=>t(o)-l):(e=t===Xu||t===JOe?t:eLe,n=t,r=t);function i(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<0?c=h+1:u=h}while(c<u)}return c}function s(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const h=c+u>>>1;n(o[h],l)<=0?c=h+1:u=h}while(c<u)}return c}function a(o,l,c=0,u=o.length){const h=i(o,l,c,u-1);return h>c&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:i,center:a,right:s}}function eLe(){return 0}function eZ(t){return t===null?NaN:+t}function*tLe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const nLe=YD(Xu),hv=nLe.right;YD(eZ).center;class o$ extends Map{constructor(e,n=sLe){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(l$(this,e))}has(e){return super.has(l$(this,e))}set(e,n){return super.set(rLe(this,e),n)}delete(e){return super.delete(iLe(this,e))}}function l$({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function rLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function iLe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function sLe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function aLe(t=Xu){if(t===Xu)return tZ;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 tZ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const oLe=Math.sqrt(50),lLe=Math.sqrt(10),cLe=Math.sqrt(2);function PS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=oLe?10:s>=lLe?5:s>=cLe?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/a,o=Math.round(t*c),l=Math.round(e*c),o/c<t&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,i)*a,o=Math.round(t/c),l=Math.round(e/c),o*c<t&&++o,l*c>e&&--l),l<o&&.5<=n&&n<2?PS(t,e,n*2):[o,l,c]}function oP(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,s,a]=r?PS(e,t,n):PS(t,e,n);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let c=0;c<o;++c)l[c]=(s-c)/-a;else for(let c=0;c<o;++c)l[c]=(s-c)*a;else if(a<0)for(let c=0;c<o;++c)l[c]=(i+c)/-a;else for(let c=0;c<o;++c)l[c]=(i+c)*a;return l}function lP(t,e,n){return e=+e,t=+t,n=+n,PS(t,e,n)[2]}function cP(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?lP(e,t,n):lP(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function c$(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function u$(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function nZ(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?tZ:aLe(i);r>n;){if(r-n>600){const l=r-n+1,c=e-n+1,u=Math.log(l),h=.5*Math.exp(2*u/3),g=.5*Math.sqrt(u*h*(l-h)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(e-c*h/l+g)),b=Math.min(r,Math.floor(e+(l-c)*h/l+g));nZ(t,e,m,b,i)}const s=t[e];let a=n,o=r;for(ox(t,n,e),i(t[r],s)>0&&ox(t,n,r);a<o;){for(ox(t,a,o),++a,--o;i(t[a],s)<0;)++a;for(;i(t[o],s)>0;)--o}i(t[n],s)===0?ox(t,n,o):(++o,ox(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function ox(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function uLe(t,e,n){if(t=Float64Array.from(tLe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return u$(t);if(e>=1)return c$(t);var r,i=(r-1)*e,s=Math.floor(i),a=c$(nZ(t,s).subarray(0,s+1)),o=u$(t.subarray(s+1));return a+(o-a)*(i-s)}}function dLe(t,e,n=eZ){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,s=Math.floor(i),a=+n(t[s],s,t),o=+n(t[s+1],s+1,t);return a+(o-a)*(i-s)}}function fLe(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,s=new Array(i);++r<i;)s[r]=t+r*n;return s}function eo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Rc(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const uP=Symbol("implicit");function ZD(){var t=new o$,e=[],n=[],r=uP;function i(s){let a=t.get(s);if(a===void 0){if(r!==uP)return r;t.set(s,a=e.push(s)-1)}return n[a%n.length]}return i.domain=function(s){if(!arguments.length)return e.slice();e=[],t=new o$;for(const a of s)t.has(a)||t.set(a,e.push(a)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return ZD(e,n).unknown(r)},eo.apply(i,arguments),i}function QD(){var t=ZD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,a,o=!1,l=0,c=0,u=.5;delete t.unknown;function h(){var g=e().length,m=i<r,b=m?i:r,y=m?r:i;s=(y-b)/Math.max(1,g-l+c*2),o&&(s=Math.floor(s)),b+=(y-b-s*(g-l))*u,a=s*(1-l),o&&(b=Math.round(b),a=Math.round(a));var v=fLe(g).map(function(x){return b+s*x});return n(m?v.reverse():v)}return t.domain=function(g){return arguments.length?(e(g),h()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,h()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,h()},t.bandwidth=function(){return a},t.step=function(){return s},t.round=function(g){return arguments.length?(o=!!g,h()):o},t.padding=function(g){return arguments.length?(l=Math.min(1,c=+g),h()):l},t.paddingInner=function(g){return arguments.length?(l=Math.min(1,g),h()):l},t.paddingOuter=function(g){return arguments.length?(c=+g,h()):c},t.align=function(g){return arguments.length?(u=Math.max(0,Math.min(1,g)),h()):u},t.copy=function(){return QD(e(),[r,i]).round(o).paddingInner(l).paddingOuter(c).align(u)},eo.apply(h(),arguments)}function rZ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return rZ(e())},t}function hLe(){return rZ(QD.apply(null,arguments).paddingInner(1))}function JD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function iZ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function pv(){}var k0=.7,kS=1/k0,Gp="\\s*([+-]?\\d+)\\s*",D0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",el="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",pLe=/^#([0-9a-f]{3,8})$/,mLe=new RegExp(`^rgb\\(${Gp},${Gp},${Gp}\\)$`),gLe=new RegExp(`^rgb\\(${el},${el},${el}\\)$`),xLe=new RegExp(`^rgba\\(${Gp},${Gp},${Gp},${D0}\\)$`),vLe=new RegExp(`^rgba\\(${el},${el},${el},${D0}\\)$`),bLe=new RegExp(`^hsl\\(${D0},${el},${el}\\)$`),yLe=new RegExp(`^hsla\\(${D0},${el},${el},${D0}\\)$`),d$={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};JD(pv,O0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:f$,formatHex:f$,formatHex8:_Le,formatHsl:SLe,formatRgb:h$,toString:h$});function f$(){return this.rgb().formatHex()}function _Le(){return this.rgb().formatHex8()}function SLe(){return sZ(this).formatHsl()}function h$(){return this.rgb().formatRgb()}function O0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=pLe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?p$(e):n===3?new Fs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?d_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?d_(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=mLe.exec(t))?new Fs(e[1],e[2],e[3],1):(e=gLe.exec(t))?new Fs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=xLe.exec(t))?d_(e[1],e[2],e[3],e[4]):(e=vLe.exec(t))?d_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=bLe.exec(t))?x$(e[1],e[2]/100,e[3]/100,1):(e=yLe.exec(t))?x$(e[1],e[2]/100,e[3]/100,e[4]):d$.hasOwnProperty(t)?p$(d$[t]):t==="transparent"?new Fs(NaN,NaN,NaN,0):null}function p$(t){return new Fs(t>>16&255,t>>8&255,t&255,1)}function d_(t,e,n,r){return r<=0&&(t=e=n=NaN),new Fs(t,e,n,r)}function wLe(t){return t instanceof pv||(t=O0(t)),t?(t=t.rgb(),new Fs(t.r,t.g,t.b,t.opacity)):new Fs}function dP(t,e,n,r){return arguments.length===1?wLe(t):new Fs(t,e,n,r??1)}function Fs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}JD(Fs,dP,iZ(pv,{brighter(t){return t=t==null?kS:Math.pow(kS,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?k0:Math.pow(k0,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Fs(yf(this.r),yf(this.g),yf(this.b),DS(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:m$,formatHex:m$,formatHex8:MLe,formatRgb:g$,toString:g$}));function m$(){return`#${of(this.r)}${of(this.g)}${of(this.b)}`}function MLe(){return`#${of(this.r)}${of(this.g)}${of(this.b)}${of((isNaN(this.opacity)?1:this.opacity)*255)}`}function g$(){const t=DS(this.opacity);return`${t===1?"rgb(":"rgba("}${yf(this.r)}, ${yf(this.g)}, ${yf(this.b)}${t===1?")":`, ${t})`}`}function DS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function yf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function of(t){return t=yf(t),(t<16?"0":"")+t.toString(16)}function x$(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new vo(t,e,n,r)}function sZ(t){if(t instanceof vo)return new vo(t.h,t.s,t.l,t.opacity);if(t instanceof pv||(t=O0(t)),!t)return new vo;if(t instanceof vo)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(e===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-e)/o+2:a=(e-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new vo(a,o,l,t.opacity)}function ELe(t,e,n,r){return arguments.length===1?sZ(t):new vo(t,e,n,r??1)}function vo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}JD(vo,ELe,iZ(pv,{brighter(t){return t=t==null?kS:Math.pow(kS,t),new vo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?k0:Math.pow(k0,t),new vo(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Fs(eN(t>=240?t-240:t+120,i,r),eN(t,i,r),eN(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new vo(v$(this.h),f_(this.s),f_(this.l),DS(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=DS(this.opacity);return`${t===1?"hsl(":"hsla("}${v$(this.h)}, ${f_(this.s)*100}%, ${f_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function v$(t){return t=(t||0)%360,t<0?t+360:t}function f_(t){return Math.max(0,Math.min(1,t||0))}function eN(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 eO=t=>()=>t;function ALe(t,e){return function(n){return t+n*e}}function TLe(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 CLe(t){return(t=+t)==1?aZ:function(e,n){return n-e?TLe(e,n,t):eO(isNaN(e)?n:e)}}function aZ(t,e){var n=e-t;return n?ALe(t,n):eO(isNaN(t)?e:t)}const b$=(function t(e){var n=CLe(e);function r(i,s){var a=n((i=dP(i)).r,(s=dP(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),c=aZ(i.opacity,s.opacity);return function(u){return i.r=a(u),i.g=o(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=t,r})(1);function NLe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=t[i]*(1-s)+e[i]*s;return r}}function RLe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function PLe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),s=new Array(n),a;for(a=0;a<r;++a)i[a]=Bm(t[a],e[a]);for(;a<n;++a)s[a]=e[a];return function(o){for(a=0;a<r;++a)s[a]=i[a](o);return s}}function kLe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function OS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function DLe(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]=Bm(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var fP=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,tN=new RegExp(fP.source,"g");function OLe(t){return function(){return t}}function LLe(t){return function(e){return t(e)+""}}function ILe(t,e){var n=fP.lastIndex=tN.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(t=t+"",e=e+"";(r=fP.exec(t))&&(i=tN.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:OS(r,i)})),n=tN.lastIndex;return n<e.length&&(s=e.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?LLe(l[0].x):OLe(e):(e=l.length,function(c){for(var u=0,h;u<e;++u)o[(h=l[u]).i]=h.x(c);return o.join("")})}function Bm(t,e){var n=typeof e,r;return e==null||n==="boolean"?eO(e):(n==="number"?OS:n==="string"?(r=O0(e))?(e=r,b$):ILe:e instanceof O0?b$:e instanceof Date?kLe:RLe(e)?NLe:Array.isArray(e)?PLe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?DLe:OS)(t,e)}function tO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function jLe(t,e){e===void 0&&(e=t,t=Bm);for(var n=0,r=e.length-1,i=e[0],s=new Array(r<0?0:r);n<r;)s[n]=t(i,i=e[++n]);return function(a){var o=Math.max(0,Math.min(r-1,Math.floor(a*=r)));return s[o](a-o)}}function ULe(t){return function(){return t}}function LS(t){return+t}var y$=[0,1];function ys(t){return t}function hP(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:ULe(isNaN(e)?NaN:.5)}function FLe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function zLe(t,e,n){var r=t[0],i=t[1],s=e[0],a=e[1];return i<r?(r=hP(i,r),s=n(a,s)):(r=hP(r,i),s=n(s,a)),function(o){return s(r(o))}}function BLe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),s=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<r;)i[a]=hP(t[a],t[a+1]),s[a]=n(e[a],e[a+1]);return function(o){var l=hv(t,o,1,r)-1;return s[l](i[l](o))}}function mv(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function oM(){var t=y$,e=y$,n=Bm,r,i,s,a=ys,o,l,c;function u(){var g=Math.min(t.length,e.length);return a!==ys&&(a=FLe(t[0],t[g-1])),o=g>2?BLe:zLe,l=c=null,h}function h(g){return g==null||isNaN(g=+g)?s:(l||(l=o(t.map(r),e,n)))(r(a(g)))}return h.invert=function(g){return a(i((c||(c=o(e,t.map(r),OS)))(g)))},h.domain=function(g){return arguments.length?(t=Array.from(g,LS),u()):t.slice()},h.range=function(g){return arguments.length?(e=Array.from(g),u()):e.slice()},h.rangeRound=function(g){return e=Array.from(g),n=tO,u()},h.clamp=function(g){return arguments.length?(a=g?!0:ys,u()):a!==ys},h.interpolate=function(g){return arguments.length?(n=g,u()):n},h.unknown=function(g){return arguments.length?(s=g,h):s},function(g,m){return r=g,i=m,u()}}function nO(){return oM()(ys,ys)}function HLe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function IS(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 _m(t){return t=IS(Math.abs(t)),t?t[1]:NaN}function $Le(t,e){return function(n,r){for(var i=n.length,s=[],a=0,o=t[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=t[a=(a+1)%t.length];return s.reverse().join(e)}}function VLe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var GLe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function L0(t){if(!(e=GLe.exec(t)))throw new Error("invalid format: "+t);var e;return new rO({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}L0.prototype=rO.prototype;function rO(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+""}rO.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 WLe(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 oZ;function qLe(t,e){var n=IS(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(oZ=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+IS(t,Math.max(0,e+s-1))[0]}function _$(t,e){var n=IS(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 S$={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:HLe,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)=>_$(t*100,e),r:_$,s:qLe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function w$(t){return t}var M$=Array.prototype.map,E$=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function XLe(t){var e=t.grouping===void 0||t.thousands===void 0?w$:$Le(M$.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",s=t.numerals===void 0?w$:VLe(M$.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(h){h=L0(h);var g=h.fill,m=h.align,b=h.sign,y=h.symbol,v=h.zero,x=h.width,M=h.comma,w=h.precision,T=h.trim,A=h.type;A==="n"?(M=!0,A="g"):S$[A]||(w===void 0&&(w=12),T=!0,A="g"),(v||g==="0"&&m==="=")&&(v=!0,g="0",m="=");var P=y==="$"?n:y==="#"&&/[boxX]/.test(A)?"0"+A.toLowerCase():"",C=y==="$"?r:/[%p]/.test(A)?a:"",j=S$[A],N=/[defgprs%]/.test(A);w=w===void 0?6:/[gprs]/.test(A)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function k(F){var I=P,W=C,D,$,G;if(A==="c")W=j(F)+W,F="";else{F=+F;var V=F<0||1/F<0;if(F=isNaN(F)?l:j(Math.abs(F),w),T&&(F=WLe(F)),V&&+F==0&&b!=="+"&&(V=!1),I=(V?b==="("?b:o:b==="-"||b==="("?"":b)+I,W=(A==="s"?E$[8+oZ/3]:"")+W+(V&&b==="("?")":""),N){for(D=-1,$=F.length;++D<$;)if(G=F.charCodeAt(D),48>G||G>57){W=(G===46?i+F.slice(D+1):F.slice(D))+W,F=F.slice(0,D);break}}}M&&!v&&(F=e(F,1/0));var Z=I.length+F.length+W.length,K=Z<x?new Array(x-Z+1).join(g):"";switch(M&&v&&(F=e(K+F,K.length?x-W.length:1/0),K=""),m){case"<":F=I+F+W+K;break;case"=":F=I+K+F+W;break;case"^":F=K.slice(0,Z=K.length>>1)+I+F+W+K.slice(Z);break;default:F=K+I+F+W;break}return s(F)}return k.toString=function(){return h+""},k}function u(h,g){var m=c((h=L0(h),h.type="f",h)),b=Math.max(-8,Math.min(8,Math.floor(_m(g)/3)))*3,y=Math.pow(10,-b),v=E$[8+b/3];return function(x){return m(y*x)+v}}return{format:c,formatPrefix:u}}var h_,iO,lZ;KLe({thousands:",",grouping:[3],currency:["$",""]});function KLe(t){return h_=XLe(t),iO=h_.format,lZ=h_.formatPrefix,h_}function YLe(t){return Math.max(0,-_m(Math.abs(t)))}function ZLe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(_m(e)/3)))*3-_m(Math.abs(t)))}function QLe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,_m(e)-_m(t))+1}function cZ(t,e,n,r){var i=cP(t,e,n),s;switch(r=L0(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=ZLe(i,a))&&(r.precision=s),lZ(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=QLe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=YLe(i))&&(r.precision=s-(r.type==="%")*2);break}}return iO(r)}function fd(t){var e=t.domain;return t.ticks=function(n){var r=e();return oP(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return cZ(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,s=r.length-1,a=r[i],o=r[s],l,c,u=10;for(o<a&&(c=a,a=o,o=c,c=i,i=s,s=c);u-- >0;){if(c=lP(a,o,n),c===l)return r[i]=a,r[s]=o,e(r);if(c>0)a=Math.floor(a/c)*c,o=Math.ceil(o/c)*c;else if(c<0)a=Math.ceil(a*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function uZ(){var t=nO();return t.copy=function(){return mv(t,uZ())},eo.apply(t,arguments),fd(t)}function dZ(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,LS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return dZ(t).unknown(e)},t=arguments.length?Array.from(t,LS):[0,1],fd(n)}function fZ(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],s=t[r],a;return s<i&&(a=n,n=r,r=a,a=i,i=s,s=a),t[n]=e.floor(i),t[r]=e.ceil(s),t}function A$(t){return Math.log(t)}function T$(t){return Math.exp(t)}function JLe(t){return-Math.log(-t)}function eIe(t){return-Math.exp(-t)}function tIe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function nIe(t){return t===10?tIe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function rIe(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 C$(t){return(e,n)=>-t(-e,n)}function sO(t){const e=t(A$,T$),n=e.domain;let r=10,i,s;function a(){return i=rIe(r),s=nIe(r),n()[0]<0?(i=C$(i),s=C$(s),t(JLe,eIe)):t(A$,T$),e}return e.base=function(o){return arguments.length?(r=+o,a()):r},e.domain=function(o){return arguments.length?(n(o),a()):n()},e.ticks=o=>{const l=n();let c=l[0],u=l[l.length-1];const h=u<c;h&&([c,u]=[u,c]);let g=i(c),m=i(u),b,y;const v=o==null?10:+o;let x=[];if(!(r%1)&&m-g<v){if(g=Math.floor(g),m=Math.ceil(m),c>0){for(;g<=m;++g)for(b=1;b<r;++b)if(y=g<0?b/s(-g):b*s(g),!(y<c)){if(y>u)break;x.push(y)}}else for(;g<=m;++g)for(b=r-1;b>=1;--b)if(y=g>0?b/s(-g):b*s(g),!(y<c)){if(y>u)break;x.push(y)}x.length*2<v&&(x=oP(c,u,v))}else x=oP(g,m,Math.min(m-g,v)).map(s);return h?x.reverse():x},e.tickFormat=(o,l)=>{if(o==null&&(o=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=L0(l)).precision==null&&(l.trim=!0),l=iO(l)),o===1/0)return l;const c=Math.max(1,r*o/e.ticks().length);return u=>{let h=u/s(Math.round(i(u)));return h*r<r-.5&&(h*=r),h<=c?l(u):""}},e.nice=()=>n(fZ(n(),{floor:o=>s(Math.floor(i(o))),ceil:o=>s(Math.ceil(i(o)))})),e}function hZ(){const t=sO(oM()).domain([1,10]);return t.copy=()=>mv(t,hZ()).base(t.base()),eo.apply(t,arguments),t}function N$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function R$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function aO(t){var e=1,n=t(N$(e),R$(e));return n.constant=function(r){return arguments.length?t(N$(e=+r),R$(e)):e},fd(n)}function pZ(){var t=aO(oM());return t.copy=function(){return mv(t,pZ()).constant(t.constant())},eo.apply(t,arguments)}function P$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function iIe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function sIe(t){return t<0?-t*t:t*t}function oO(t){var e=t(ys,ys),n=1;function r(){return n===1?t(ys,ys):n===.5?t(iIe,sIe):t(P$(n),P$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},fd(e)}function lO(){var t=oO(oM());return t.copy=function(){return mv(t,lO()).exponent(t.exponent())},eo.apply(t,arguments),t}function aIe(){return lO.apply(null,arguments).exponent(.5)}function k$(t){return Math.sign(t)*t*t}function oIe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function mZ(){var t=nO(),e=[0,1],n=!1,r;function i(s){var a=oIe(t(s));return isNaN(a)?r:n?Math.round(a):a}return i.invert=function(s){return t.invert(k$(s))},i.domain=function(s){return arguments.length?(t.domain(s),i):t.domain()},i.range=function(s){return arguments.length?(t.range((e=Array.from(s,LS)).map(k$)),i):e.slice()},i.rangeRound=function(s){return i.range(s).round(!0)},i.round=function(s){return arguments.length?(n=!!s,i):n},i.clamp=function(s){return arguments.length?(t.clamp(s),i):t.clamp()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return mZ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},eo.apply(i,arguments),fd(i)}function gZ(){var t=[],e=[],n=[],r;function i(){var a=0,o=Math.max(1,e.length);for(n=new Array(o-1);++a<o;)n[a-1]=dLe(t,a/o);return s}function s(a){return a==null||isNaN(a=+a)?r:e[hv(n,a)]}return s.invertExtent=function(a){var o=e.indexOf(a);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},s.domain=function(a){if(!arguments.length)return t.slice();t=[];for(let o of a)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(Xu),i()},s.range=function(a){return arguments.length?(e=Array.from(a),i()):e.slice()},s.unknown=function(a){return arguments.length?(r=a,s):r},s.quantiles=function(){return n.slice()},s.copy=function(){return gZ().domain(t).range(e).unknown(r)},eo.apply(s,arguments)}function xZ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function a(l){return l!=null&&l<=l?i[hv(r,l,0,n)]:s}function o(){var l=-1;for(r=new Array(n);++l<n;)r[l]=((l+1)*e-(l-n)*t)/(n+1);return a}return a.domain=function(l){return arguments.length?([t,e]=l,t=+t,e=+e,o()):[t,e]},a.range=function(l){return arguments.length?(n=(i=Array.from(l)).length-1,o()):i.slice()},a.invertExtent=function(l){var c=i.indexOf(l);return c<0?[NaN,NaN]:c<1?[t,r[0]]:c>=n?[r[n-1],e]:[r[c-1],r[c]]},a.unknown=function(l){return arguments.length&&(s=l),a},a.thresholds=function(){return r.slice()},a.copy=function(){return xZ().domain([t,e]).range(i).unknown(s)},eo.apply(fd(a),arguments)}function vZ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[hv(t,s,0,r)]:n}return i.domain=function(s){return arguments.length?(t=Array.from(s),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(s){return arguments.length?(e=Array.from(s),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(s){var a=e.indexOf(s);return[t[a-1],t[a]]},i.unknown=function(s){return arguments.length?(n=s,i):n},i.copy=function(){return vZ().domain(t).range(e).unknown(n)},eo.apply(i,arguments)}const nN=new Date,rN=new Date;function hi(t,e,n,r){function i(s){return t(s=arguments.length===0?new Date:new Date(+s)),s}return i.floor=s=>(t(s=new Date(+s)),s),i.ceil=s=>(t(s=new Date(s-1)),e(s,1),t(s),s),i.round=s=>{const a=i(s),o=i.ceil(s);return s-a<o-s?a:o},i.offset=(s,a)=>(e(s=new Date(+s),a==null?1:Math.floor(a)),s),i.range=(s,a,o)=>{const l=[];if(s=i.ceil(s),o=o==null?1:Math.floor(o),!(s<a)||!(o>0))return l;let c;do l.push(c=new Date(+s)),e(s,o),t(s);while(c<s&&s<a);return l},i.filter=s=>hi(a=>{if(a>=a)for(;t(a),!s(a);)a.setTime(a-1)},(a,o)=>{if(a>=a)if(o<0)for(;++o<=0;)for(;e(a,-1),!s(a););else for(;--o>=0;)for(;e(a,1),!s(a););}),n&&(i.count=(s,a)=>(nN.setTime(+s),rN.setTime(+a),t(nN),t(rN),Math.floor(n(nN,rN))),i.every=s=>(s=Math.floor(s),!isFinite(s)||!(s>0)?null:s>1?i.filter(r?a=>r(a)%s===0:a=>i.count(0,a)%s===0):i)),i}const jS=hi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);jS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?hi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):jS);jS.range;const ic=1e3,Va=ic*60,sc=Va*60,_c=sc*24,cO=_c*7,D$=_c*30,iN=_c*365,lf=hi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*ic)},(t,e)=>(e-t)/ic,t=>t.getUTCSeconds());lf.range;const uO=hi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ic)},(t,e)=>{t.setTime(+t+e*Va)},(t,e)=>(e-t)/Va,t=>t.getMinutes());uO.range;const dO=hi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Va)},(t,e)=>(e-t)/Va,t=>t.getUTCMinutes());dO.range;const fO=hi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*ic-t.getMinutes()*Va)},(t,e)=>{t.setTime(+t+e*sc)},(t,e)=>(e-t)/sc,t=>t.getHours());fO.range;const hO=hi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*sc)},(t,e)=>(e-t)/sc,t=>t.getUTCHours());hO.range;const gv=hi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Va)/_c,t=>t.getDate()-1);gv.range;const lM=hi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_c,t=>t.getUTCDate()-1);lM.range;const bZ=hi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/_c,t=>Math.floor(t/_c));bZ.range;function Qf(t){return hi(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())*Va)/cO)}const cM=Qf(0),US=Qf(1),lIe=Qf(2),cIe=Qf(3),Sm=Qf(4),uIe=Qf(5),dIe=Qf(6);cM.range;US.range;lIe.range;cIe.range;Sm.range;uIe.range;dIe.range;function Jf(t){return hi(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)/cO)}const uM=Jf(0),FS=Jf(1),fIe=Jf(2),hIe=Jf(3),wm=Jf(4),pIe=Jf(5),mIe=Jf(6);uM.range;FS.range;fIe.range;hIe.range;wm.range;pIe.range;mIe.range;const pO=hi(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());pO.range;const mO=hi(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());mO.range;const Sc=hi(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());Sc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:hi(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)});Sc.range;const wc=hi(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());wc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:hi(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)});wc.range;function yZ(t,e,n,r,i,s){const a=[[lf,1,ic],[lf,5,5*ic],[lf,15,15*ic],[lf,30,30*ic],[s,1,Va],[s,5,5*Va],[s,15,15*Va],[s,30,30*Va],[i,1,sc],[i,3,3*sc],[i,6,6*sc],[i,12,12*sc],[r,1,_c],[r,2,2*_c],[n,1,cO],[e,1,D$],[e,3,3*D$],[t,1,iN]];function o(c,u,h){const g=u<c;g&&([c,u]=[u,c]);const m=h&&typeof h.range=="function"?h:l(c,u,h),b=m?m.range(c,+u+1):[];return g?b.reverse():b}function l(c,u,h){const g=Math.abs(u-c)/h,m=YD(([,,v])=>v).right(a,g);if(m===a.length)return t.every(cP(c/iN,u/iN,h));if(m===0)return jS.every(Math.max(cP(c,u,h),1));const[b,y]=a[g/a[m-1][2]<a[m][2]/g?m-1:m];return b.every(y)}return[o,l]}const[gIe,xIe]=yZ(wc,mO,uM,bZ,hO,dO),[vIe,bIe]=yZ(Sc,pO,cM,gv,fO,uO);function sN(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 aN(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 lx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function yIe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,a=t.shortDays,o=t.months,l=t.shortMonths,c=cx(i),u=ux(i),h=cx(s),g=ux(s),m=cx(a),b=ux(a),y=cx(o),v=ux(o),x=cx(l),M=ux(l),w={a:V,A:Z,b:K,B:ee,c:null,d:F$,e:F$,f:$Ie,g:JIe,G:tje,H:zIe,I:BIe,j:HIe,L:_Z,m:VIe,M:GIe,p:H,q:Y,Q:H$,s:$$,S:WIe,u:qIe,U:XIe,V:KIe,w:YIe,W:ZIe,x:null,X:null,y:QIe,Y:eje,Z:nje,"%":B$},T={a:te,A:ae,b:fe,B:Q,c:null,d:z$,e:z$,f:aje,g:gje,G:vje,H:rje,I:ije,j:sje,L:wZ,m:oje,M:lje,p:me,q:Ee,Q:H$,s:$$,S:cje,u:uje,U:dje,V:fje,w:hje,W:pje,x:null,X:null,y:mje,Y:xje,Z:bje,"%":B$},A={a:k,A:F,b:I,B:W,c:D,d:j$,e:j$,f:IIe,g:I$,G:L$,H:U$,I:U$,j:kIe,L:LIe,m:PIe,M:DIe,p:N,q:RIe,Q:UIe,s:FIe,S:OIe,u:EIe,U:AIe,V:TIe,w:MIe,W:CIe,x:$,X:G,y:I$,Y:L$,Z:NIe,"%":jIe};w.x=P(n,w),w.X=P(r,w),w.c=P(e,w),T.x=P(n,T),T.X=P(r,T),T.c=P(e,T);function P(he,we){return function(De){var de=[],Le=-1,B=0,z=he.length,ie,X,J;for(De instanceof Date||(De=new Date(+De));++Le<z;)he.charCodeAt(Le)===37&&(de.push(he.slice(B,Le)),(X=O$[ie=he.charAt(++Le)])!=null?ie=he.charAt(++Le):X=ie==="e"?" ":"0",(J=we[ie])&&(ie=J(De,X)),de.push(ie),B=Le+1);return de.push(he.slice(B,Le)),de.join("")}}function C(he,we){return function(De){var de=lx(1900,void 0,1),Le=j(de,he,De+="",0),B,z;if(Le!=De.length)return null;if("Q"in de)return new Date(de.Q);if("s"in de)return new Date(de.s*1e3+("L"in de?de.L:0));if(we&&!("Z"in de)&&(de.Z=0),"p"in de&&(de.H=de.H%12+de.p*12),de.m===void 0&&(de.m="q"in de?de.q:0),"V"in de){if(de.V<1||de.V>53)return null;"w"in de||(de.w=1),"Z"in de?(B=aN(lx(de.y,0,1)),z=B.getUTCDay(),B=z>4||z===0?FS.ceil(B):FS(B),B=lM.offset(B,(de.V-1)*7),de.y=B.getUTCFullYear(),de.m=B.getUTCMonth(),de.d=B.getUTCDate()+(de.w+6)%7):(B=sN(lx(de.y,0,1)),z=B.getDay(),B=z>4||z===0?US.ceil(B):US(B),B=gv.offset(B,(de.V-1)*7),de.y=B.getFullYear(),de.m=B.getMonth(),de.d=B.getDate()+(de.w+6)%7)}else("W"in de||"U"in de)&&("w"in de||(de.w="u"in de?de.u%7:"W"in de?1:0),z="Z"in de?aN(lx(de.y,0,1)).getUTCDay():sN(lx(de.y,0,1)).getDay(),de.m=0,de.d="W"in de?(de.w+6)%7+de.W*7-(z+5)%7:de.w+de.U*7-(z+6)%7);return"Z"in de?(de.H+=de.Z/100|0,de.M+=de.Z%100,aN(de)):sN(de)}}function j(he,we,De,de){for(var Le=0,B=we.length,z=De.length,ie,X;Le<B;){if(de>=z)return-1;if(ie=we.charCodeAt(Le++),ie===37){if(ie=we.charAt(Le++),X=A[ie in O$?we.charAt(Le++):ie],!X||(de=X(he,De,de))<0)return-1}else if(ie!=De.charCodeAt(de++))return-1}return de}function N(he,we,De){var de=c.exec(we.slice(De));return de?(he.p=u.get(de[0].toLowerCase()),De+de[0].length):-1}function k(he,we,De){var de=m.exec(we.slice(De));return de?(he.w=b.get(de[0].toLowerCase()),De+de[0].length):-1}function F(he,we,De){var de=h.exec(we.slice(De));return de?(he.w=g.get(de[0].toLowerCase()),De+de[0].length):-1}function I(he,we,De){var de=x.exec(we.slice(De));return de?(he.m=M.get(de[0].toLowerCase()),De+de[0].length):-1}function W(he,we,De){var de=y.exec(we.slice(De));return de?(he.m=v.get(de[0].toLowerCase()),De+de[0].length):-1}function D(he,we,De){return j(he,e,we,De)}function $(he,we,De){return j(he,n,we,De)}function G(he,we,De){return j(he,r,we,De)}function V(he){return a[he.getDay()]}function Z(he){return s[he.getDay()]}function K(he){return l[he.getMonth()]}function ee(he){return o[he.getMonth()]}function H(he){return i[+(he.getHours()>=12)]}function Y(he){return 1+~~(he.getMonth()/3)}function te(he){return a[he.getUTCDay()]}function ae(he){return s[he.getUTCDay()]}function fe(he){return l[he.getUTCMonth()]}function Q(he){return o[he.getUTCMonth()]}function me(he){return i[+(he.getUTCHours()>=12)]}function Ee(he){return 1+~~(he.getUTCMonth()/3)}return{format:function(he){var we=P(he+="",w);return we.toString=function(){return he},we},parse:function(he){var we=C(he+="",!1);return we.toString=function(){return he},we},utcFormat:function(he){var we=P(he+="",T);return we.toString=function(){return he},we},utcParse:function(he){var we=C(he+="",!0);return we.toString=function(){return he},we}}}var O$={"-":"",_:" ",0:"0"},ki=/^\s*\d+/,_Ie=/^%/,SIe=/[\\^$*+?|[\]().{}]/g;function Tn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",s=i.length;return r+(s<n?new Array(n-s+1).join(e)+i:i)}function wIe(t){return t.replace(SIe,"\\$&")}function cx(t){return new RegExp("^(?:"+t.map(wIe).join("|")+")","i")}function ux(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function MIe(t,e,n){var r=ki.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function EIe(t,e,n){var r=ki.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function AIe(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function TIe(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function CIe(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function L$(t,e,n){var r=ki.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function I$(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function NIe(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 RIe(t,e,n){var r=ki.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function PIe(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function j$(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function kIe(t,e,n){var r=ki.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function U$(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function DIe(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function OIe(t,e,n){var r=ki.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function LIe(t,e,n){var r=ki.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function IIe(t,e,n){var r=ki.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function jIe(t,e,n){var r=_Ie.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function UIe(t,e,n){var r=ki.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function FIe(t,e,n){var r=ki.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function F$(t,e){return Tn(t.getDate(),e,2)}function zIe(t,e){return Tn(t.getHours(),e,2)}function BIe(t,e){return Tn(t.getHours()%12||12,e,2)}function HIe(t,e){return Tn(1+gv.count(Sc(t),t),e,3)}function _Z(t,e){return Tn(t.getMilliseconds(),e,3)}function $Ie(t,e){return _Z(t,e)+"000"}function VIe(t,e){return Tn(t.getMonth()+1,e,2)}function GIe(t,e){return Tn(t.getMinutes(),e,2)}function WIe(t,e){return Tn(t.getSeconds(),e,2)}function qIe(t){var e=t.getDay();return e===0?7:e}function XIe(t,e){return Tn(cM.count(Sc(t)-1,t),e,2)}function SZ(t){var e=t.getDay();return e>=4||e===0?Sm(t):Sm.ceil(t)}function KIe(t,e){return t=SZ(t),Tn(Sm.count(Sc(t),t)+(Sc(t).getDay()===4),e,2)}function YIe(t){return t.getDay()}function ZIe(t,e){return Tn(US.count(Sc(t)-1,t),e,2)}function QIe(t,e){return Tn(t.getFullYear()%100,e,2)}function JIe(t,e){return t=SZ(t),Tn(t.getFullYear()%100,e,2)}function eje(t,e){return Tn(t.getFullYear()%1e4,e,4)}function tje(t,e){var n=t.getDay();return t=n>=4||n===0?Sm(t):Sm.ceil(t),Tn(t.getFullYear()%1e4,e,4)}function nje(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Tn(e/60|0,"0",2)+Tn(e%60,"0",2)}function z$(t,e){return Tn(t.getUTCDate(),e,2)}function rje(t,e){return Tn(t.getUTCHours(),e,2)}function ije(t,e){return Tn(t.getUTCHours()%12||12,e,2)}function sje(t,e){return Tn(1+lM.count(wc(t),t),e,3)}function wZ(t,e){return Tn(t.getUTCMilliseconds(),e,3)}function aje(t,e){return wZ(t,e)+"000"}function oje(t,e){return Tn(t.getUTCMonth()+1,e,2)}function lje(t,e){return Tn(t.getUTCMinutes(),e,2)}function cje(t,e){return Tn(t.getUTCSeconds(),e,2)}function uje(t){var e=t.getUTCDay();return e===0?7:e}function dje(t,e){return Tn(uM.count(wc(t)-1,t),e,2)}function MZ(t){var e=t.getUTCDay();return e>=4||e===0?wm(t):wm.ceil(t)}function fje(t,e){return t=MZ(t),Tn(wm.count(wc(t),t)+(wc(t).getUTCDay()===4),e,2)}function hje(t){return t.getUTCDay()}function pje(t,e){return Tn(FS.count(wc(t)-1,t),e,2)}function mje(t,e){return Tn(t.getUTCFullYear()%100,e,2)}function gje(t,e){return t=MZ(t),Tn(t.getUTCFullYear()%100,e,2)}function xje(t,e){return Tn(t.getUTCFullYear()%1e4,e,4)}function vje(t,e){var n=t.getUTCDay();return t=n>=4||n===0?wm(t):wm.ceil(t),Tn(t.getUTCFullYear()%1e4,e,4)}function bje(){return"+0000"}function B$(){return"%"}function H$(t){return+t}function $$(t){return Math.floor(+t/1e3)}var mp,EZ,AZ;yje({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 yje(t){return mp=yIe(t),EZ=mp.format,mp.parse,AZ=mp.utcFormat,mp.utcParse,mp}function _je(t){return new Date(t)}function Sje(t){return t instanceof Date?+t:+new Date(+t)}function gO(t,e,n,r,i,s,a,o,l,c){var u=nO(),h=u.invert,g=u.domain,m=c(".%L"),b=c(":%S"),y=c("%I:%M"),v=c("%I %p"),x=c("%a %d"),M=c("%b %d"),w=c("%B"),T=c("%Y");function A(P){return(l(P)<P?m:o(P)<P?b:a(P)<P?y:s(P)<P?v:r(P)<P?i(P)<P?x:M:n(P)<P?w:T)(P)}return u.invert=function(P){return new Date(h(P))},u.domain=function(P){return arguments.length?g(Array.from(P,Sje)):g().map(_je)},u.ticks=function(P){var C=g();return t(C[0],C[C.length-1],P??10)},u.tickFormat=function(P,C){return C==null?A:c(C)},u.nice=function(P){var C=g();return(!P||typeof P.range!="function")&&(P=e(C[0],C[C.length-1],P??10)),P?g(fZ(C,P)):u},u.copy=function(){return mv(u,gO(t,e,n,r,i,s,a,o,l,c))},u}function wje(){return eo.apply(gO(vIe,bIe,Sc,pO,cM,gv,fO,uO,lf,EZ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Mje(){return eo.apply(gO(gIe,xIe,wc,mO,uM,lM,hO,dO,lf,AZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function dM(){var t=0,e=1,n,r,i,s,a=ys,o=!1,l;function c(h){return h==null||isNaN(h=+h)?l:a(i===0?.5:(h=(s(h)-n)*i,o?Math.max(0,Math.min(1,h)):h))}c.domain=function(h){return arguments.length?([t,e]=h,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),c):[t,e]},c.clamp=function(h){return arguments.length?(o=!!h,c):o},c.interpolator=function(h){return arguments.length?(a=h,c):a};function u(h){return function(g){var m,b;return arguments.length?([m,b]=g,a=h(m,b),c):[a(0),a(1)]}}return c.range=u(Bm),c.rangeRound=u(tO),c.unknown=function(h){return arguments.length?(l=h,c):l},function(h){return s=h,n=h(t),r=h(e),i=n===r?0:1/(r-n),c}}function hd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function TZ(){var t=fd(dM()(ys));return t.copy=function(){return hd(t,TZ())},Rc.apply(t,arguments)}function CZ(){var t=sO(dM()).domain([1,10]);return t.copy=function(){return hd(t,CZ()).base(t.base())},Rc.apply(t,arguments)}function NZ(){var t=aO(dM());return t.copy=function(){return hd(t,NZ()).constant(t.constant())},Rc.apply(t,arguments)}function xO(){var t=oO(dM());return t.copy=function(){return hd(t,xO()).exponent(t.exponent())},Rc.apply(t,arguments)}function Eje(){return xO.apply(null,arguments).exponent(.5)}function RZ(){var t=[],e=ys;function n(r){if(r!=null&&!isNaN(r=+r))return e((hv(t,r,1)-1)/(t.length-1))}return n.domain=function(r){if(!arguments.length)return t.slice();t=[];for(let i of r)i!=null&&!isNaN(i=+i)&&t.push(i);return t.sort(Xu),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,s)=>uLe(t,s/r))},n.copy=function(){return RZ(e).domain(t)},Rc.apply(n,arguments)}function fM(){var t=0,e=.5,n=1,r=1,i,s,a,o,l,c=ys,u,h=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+u(y))-s)*(r*y<r*s?o:l),c(h?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=u(t=+t),s=u(e=+e),a=u(n=+n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(h=!!y,m):h},m.interpolator=function(y){return arguments.length?(c=y,m):c};function b(y){return function(v){var x,M,w;return arguments.length?([x,M,w]=v,c=jLe(y,[x,M,w]),m):[c(0),c(.5),c(1)]}}return m.range=b(Bm),m.rangeRound=b(tO),m.unknown=function(y){return arguments.length?(g=y,m):g},function(y){return u=y,i=y(t),s=y(e),a=y(n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m}}function PZ(){var t=fd(fM()(ys));return t.copy=function(){return hd(t,PZ())},Rc.apply(t,arguments)}function kZ(){var t=sO(fM()).domain([.1,1,10]);return t.copy=function(){return hd(t,kZ()).base(t.base())},Rc.apply(t,arguments)}function DZ(){var t=aO(fM());return t.copy=function(){return hd(t,DZ()).constant(t.constant())},Rc.apply(t,arguments)}function vO(){var t=oO(fM());return t.copy=function(){return hd(t,vO()).exponent(t.exponent())},Rc.apply(t,arguments)}function Aje(){return vO.apply(null,arguments).exponent(.5)}const _x=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:QD,scaleDiverging:PZ,scaleDivergingLog:kZ,scaleDivergingPow:vO,scaleDivergingSqrt:Aje,scaleDivergingSymlog:DZ,scaleIdentity:dZ,scaleImplicit:uP,scaleLinear:uZ,scaleLog:hZ,scaleOrdinal:ZD,scalePoint:hLe,scalePow:lO,scaleQuantile:gZ,scaleQuantize:xZ,scaleRadial:mZ,scaleSequential:TZ,scaleSequentialLog:CZ,scaleSequentialPow:xO,scaleSequentialQuantile:RZ,scaleSequentialSqrt:Eje,scaleSequentialSymlog:NZ,scaleSqrt:aIe,scaleSymlog:pZ,scaleThreshold:vZ,scaleTime:wje,scaleUtc:Mje,tickFormat:cZ},Symbol.toStringTag,{value:"Module"}));var pd=t=>t.chartData,bO=Ge([pd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),hM=(t,e,n,r)=>r?bO(t):pd(t);function rd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(or(e)&&or(n))return!0}return!1}function V$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function OZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(or(n))i=n;else if(typeof n=="function")return;if(or(r))s=r;else if(typeof r=="function")return;var a=[i,s];if(rd(a))return a}}function Tje(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(rd(r))return V$(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,s]=t,a,o;if(i==="auto")e!=null&&(a=Math.min(...e));else if(Et(i))a=i;else if(typeof i=="function")try{e!=null&&(a=i(e?.[0]))}catch{}else if(typeof i=="string"&&vH.test(i)){var l=vH.exec(i);if(l==null||e==null)a=void 0;else{var c=+l[1];a=e[0]-c}}else a=e?.[0];if(s==="auto")e!=null&&(o=Math.max(...e));else if(Et(s))o=s;else if(typeof s=="function")try{e!=null&&(o=s(e?.[1]))}catch{}else if(typeof s=="string"&&bH.test(s)){var u=bH.exec(s);if(u==null||e==null)o=void 0;else{var h=+u[1];o=e[1]+h}}else o=e?.[1];var g=[a,o];if(rd(g))return e==null?g:V$(g,e,n)}}}var Hm=1e9,Cje={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},_O,dr=!0,Qa="[DecimalError] ",_f=Qa+"Invalid argument: ",yO=Qa+"Exponent out of range: ",$m=Math.floor,Wd=Math.pow,Nje=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ua,Ei=1e7,sr=7,LZ=9007199254740991,zS=$m(LZ/sr),Nt={};Nt.absoluteValue=Nt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Nt.comparedTo=Nt.cmp=function(t){var e,n,r,i,s=this;if(t=new s.constructor(t),s.s!==t.s)return s.s||-t.s;if(s.e!==t.e)return s.e>t.e^s.s<0?1:-1;for(r=s.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(s.d[e]!==t.d[e])return s.d[e]>t.d[e]^s.s<0?1:-1;return r===i?0:r>i^s.s<0?1:-1};Nt.decimalPlaces=Nt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*sr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Nt.dividedBy=Nt.div=function(t){return fc(this,new this.constructor(t))};Nt.dividedToIntegerBy=Nt.idiv=function(t){var e=this,n=e.constructor;return Zn(fc(e,new n(t),0,1),n.precision)};Nt.equals=Nt.eq=function(t){return!this.cmp(t)};Nt.exponent=function(){return Yr(this)};Nt.greaterThan=Nt.gt=function(t){return this.cmp(t)>0};Nt.greaterThanOrEqualTo=Nt.gte=function(t){return this.cmp(t)>=0};Nt.isInteger=Nt.isint=function(){return this.e>this.d.length-2};Nt.isNegative=Nt.isneg=function(){return this.s<0};Nt.isPositive=Nt.ispos=function(){return this.s>0};Nt.isZero=function(){return this.s===0};Nt.lessThan=Nt.lt=function(t){return this.cmp(t)<0};Nt.lessThanOrEqualTo=Nt.lte=function(t){return this.cmp(t)<1};Nt.logarithm=Nt.log=function(t){var e,n=this,r=n.constructor,i=r.precision,s=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(ua))throw Error(Qa+"NaN");if(n.s<1)throw Error(Qa+(n.s?"NaN":"-Infinity"));return n.eq(ua)?new r(0):(dr=!1,e=fc(I0(n,s),I0(t,s),s),dr=!0,Zn(e,i))};Nt.minus=Nt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?UZ(e,t):IZ(e,(t.s=-t.s,t))};Nt.modulo=Nt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(Qa+"NaN");return n.s?(dr=!1,e=fc(n,t,0,1).times(t),dr=!0,n.minus(e)):Zn(new r(n),i)};Nt.naturalExponential=Nt.exp=function(){return jZ(this)};Nt.naturalLogarithm=Nt.ln=function(){return I0(this)};Nt.negated=Nt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Nt.plus=Nt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?IZ(e,t):UZ(e,(t.s=-t.s,t))};Nt.precision=Nt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(_f+t);if(e=Yr(i)+1,r=i.d.length-1,n=r*sr+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};Nt.squareRoot=Nt.sqrt=function(){var t,e,n,r,i,s,a,o=this,l=o.constructor;if(o.s<1){if(!o.s)return new l(0);throw Error(Qa+"NaN")}for(t=Yr(o),dr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=Zo(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=$m((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new l(e)):r=new l(i.toString()),n=l.precision,i=a=n+3;;)if(s=r,r=s.plus(fc(o,s,a+2)).times(.5),Zo(s.d).slice(0,a)===(e=Zo(r.d)).slice(0,a)){if(e=e.slice(a-3,a+1),i==a&&e=="4999"){if(Zn(s,n+1,0),s.times(s).eq(o)){r=s;break}}else if(e!="9999")break;a+=4}return dr=!0,Zn(r,n)};Nt.times=Nt.mul=function(t){var e,n,r,i,s,a,o,l,c,u=this,h=u.constructor,g=u.d,m=(t=new h(t)).d;if(!u.s||!t.s)return new h(0);for(t.s*=u.s,n=u.e+t.e,l=g.length,c=m.length,l<c&&(s=g,g=m,m=s,a=l,l=c,c=a),s=[],a=l+c,r=a;r--;)s.push(0);for(r=c;--r>=0;){for(e=0,i=l+r;i>r;)o=s[i]+m[r]*g[i-r-1]+e,s[i--]=o%Ei|0,e=o/Ei|0;s[i]=(s[i]+e)%Ei|0}for(;!s[--a];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,dr?Zn(t,h.precision):t};Nt.toDecimalPlaces=Nt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(ul(t,0,Hm),e===void 0?e=r.rounding:ul(e,0,8),Zn(n,t+Yr(n)+1,e))};Nt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Gf(r,!0):(ul(t,0,Hm),e===void 0?e=i.rounding:ul(e,0,8),r=Zn(new i(r),t+1,e),n=Gf(r,!0,t+1)),n};Nt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Gf(i):(ul(t,0,Hm),e===void 0?e=s.rounding:ul(e,0,8),r=Zn(new s(i),t+Yr(i)+1,e),n=Gf(r.abs(),!1,t+Yr(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Nt.toInteger=Nt.toint=function(){var t=this,e=t.constructor;return Zn(new e(t),Yr(t)+1,e.rounding)};Nt.toNumber=function(){return+this};Nt.toPower=Nt.pow=function(t){var e,n,r,i,s,a,o=this,l=o.constructor,c=12,u=+(t=new l(t));if(!t.s)return new l(ua);if(o=new l(o),!o.s){if(t.s<1)throw Error(Qa+"Infinity");return o}if(o.eq(ua))return o;if(r=l.precision,t.eq(ua))return Zn(o,r);if(e=t.e,n=t.d.length-1,a=e>=n,s=o.s,a){if((n=u<0?-u:u)<=LZ){for(i=new l(ua),e=Math.ceil(r/sr+4),dr=!1;n%2&&(i=i.times(o),W$(i.d,e)),n=$m(n/2),n!==0;)o=o.times(o),W$(o.d,e);return dr=!0,t.s<0?new l(ua).div(i):Zn(i,r)}}else if(s<0)throw Error(Qa+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,dr=!1,i=t.times(I0(o,r+c)),dr=!0,i=jZ(i),i.s=s,i};Nt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=Yr(i),r=Gf(i,n<=s.toExpNeg||n>=s.toExpPos)):(ul(t,1,Hm),e===void 0?e=s.rounding:ul(e,0,8),i=Zn(new s(i),t,e),n=Yr(i),r=Gf(i,t<=n||n<=s.toExpNeg,t)),r};Nt.toSignificantDigits=Nt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(ul(t,1,Hm),e===void 0?e=r.rounding:ul(e,0,8)),Zn(new r(n),t,e)};Nt.toString=Nt.valueOf=Nt.val=Nt.toJSON=Nt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Yr(t),n=t.constructor;return Gf(t,e<=n.toExpNeg||e>=n.toExpPos)};function IZ(t,e){var n,r,i,s,a,o,l,c,u=t.constructor,h=u.precision;if(!t.s||!e.s)return e.s||(e=new u(t)),dr?Zn(e,h):e;if(l=t.d,c=e.d,a=t.e,i=e.e,l=l.slice(),s=a-i,s){for(s<0?(r=l,s=-s,o=c.length):(r=c,i=a,o=l.length),a=Math.ceil(h/sr),o=a>o?a+1:o+1,s>o&&(s=o,r.length=1),r.reverse();s--;)r.push(0);r.reverse()}for(o=l.length,s=c.length,o-s<0&&(s=o,r=c,c=l,l=r),n=0;s;)n=(l[--s]=l[s]+c[s]+n)/Ei|0,l[s]%=Ei;for(n&&(l.unshift(n),++i),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=i,dr?Zn(e,h):e}function ul(t,e,n){if(t!==~~t||t<e||t>n)throw Error(_f+t)}function Zo(t){var e,n,r,i=t.length-1,s="",a=t[0];if(i>0){for(s+=a,e=1;e<i;e++)r=t[e]+"",n=sr-r.length,n&&(s+=Eu(n)),s+=r;a=t[e],r=a+"",n=sr-r.length,n&&(s+=Eu(n))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}var fc=(function(){function t(r,i){var s,a=0,o=r.length;for(r=r.slice();o--;)s=r[o]*i+a,r[o]=s%Ei|0,a=s/Ei|0;return a&&r.unshift(a),r}function e(r,i,s,a){var o,l;if(s!=a)l=s>a?1:-1;else for(o=l=0;o<s;o++)if(r[o]!=i[o]){l=r[o]>i[o]?1:-1;break}return l}function n(r,i,s){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*Ei+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,a){var o,l,c,u,h,g,m,b,y,v,x,M,w,T,A,P,C,j,N=r.constructor,k=r.s==i.s?1:-1,F=r.d,I=i.d;if(!r.s)return new N(r);if(!i.s)throw Error(Qa+"Division by zero");for(l=r.e-i.e,C=I.length,A=F.length,m=new N(k),b=m.d=[],c=0;I[c]==(F[c]||0);)++c;if(I[c]>(F[c]||0)&&--l,s==null?M=s=N.precision:a?M=s+(Yr(r)-Yr(i))+1:M=s,M<0)return new N(0);if(M=M/sr+2|0,c=0,C==1)for(u=0,I=I[0],M++;(c<A||u)&&M--;c++)w=u*Ei+(F[c]||0),b[c]=w/I|0,u=w%I|0;else{for(u=Ei/(I[0]+1)|0,u>1&&(I=t(I,u),F=t(F,u),C=I.length,A=F.length),T=C,y=F.slice(0,C),v=y.length;v<C;)y[v++]=0;j=I.slice(),j.unshift(0),P=I[0],I[1]>=Ei/2&&++P;do u=0,o=e(I,y,C,v),o<0?(x=y[0],C!=v&&(x=x*Ei+(y[1]||0)),u=x/P|0,u>1?(u>=Ei&&(u=Ei-1),h=t(I,u),g=h.length,v=y.length,o=e(h,y,g,v),o==1&&(u--,n(h,C<g?j:I,g))):(u==0&&(o=u=1),h=I.slice()),g=h.length,g<v&&h.unshift(0),n(y,h,v),o==-1&&(v=y.length,o=e(I,y,C,v),o<1&&(u++,n(y,C<v?j:I,v))),v=y.length):o===0&&(u++,y=[0]),b[c++]=u,o&&y[0]?y[v++]=F[T]||0:(y=[F[T]],v=1);while((T++<A||y[0]!==void 0)&&M--)}return b[0]||b.shift(),m.e=l,Zn(m,a?s+Yr(m)+1:s)}})();function jZ(t,e){var n,r,i,s,a,o,l=0,c=0,u=t.constructor,h=u.precision;if(Yr(t)>16)throw Error(yO+Yr(t));if(!t.s)return new u(ua);for(dr=!1,o=h,a=new u(.03125);t.abs().gte(.1);)t=t.times(a),c+=5;for(r=Math.log(Wd(2,c))/Math.LN10*2+5|0,o+=r,n=i=s=new u(ua),u.precision=o;;){if(i=Zn(i.times(t),o),n=n.times(++l),a=s.plus(fc(i,n,o)),Zo(a.d).slice(0,o)===Zo(s.d).slice(0,o)){for(;c--;)s=Zn(s.times(s),o);return u.precision=h,e==null?(dr=!0,Zn(s,h)):s}s=a}}function Yr(t){for(var e=t.e*sr,n=t.d[0];n>=10;n/=10)e++;return e}function oN(t,e,n){if(e>t.LN10.sd())throw dr=!0,n&&(t.precision=n),Error(Qa+"LN10 precision limit exceeded");return Zn(new t(t.LN10),e)}function Eu(t){for(var e="";t--;)e+="0";return e}function I0(t,e){var n,r,i,s,a,o,l,c,u,h=1,g=10,m=t,b=m.d,y=m.constructor,v=y.precision;if(m.s<1)throw Error(Qa+(m.s?"NaN":"-Infinity"));if(m.eq(ua))return new y(0);if(e==null?(dr=!1,c=v):c=e,m.eq(10))return e==null&&(dr=!0),oN(y,c);if(c+=g,y.precision=c,n=Zo(b),r=n.charAt(0),s=Yr(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=Zo(m.d),r=n.charAt(0),h++;s=Yr(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return l=oN(y,c+2,v).times(s+""),m=I0(new y(r+"."+n.slice(1)),c-g).plus(l),y.precision=v,e==null?(dr=!0,Zn(m,v)):m;for(o=a=m=fc(m.minus(ua),m.plus(ua),c),u=Zn(m.times(m),c),i=3;;){if(a=Zn(a.times(u),c),l=o.plus(fc(a,new y(i),c)),Zo(l.d).slice(0,c)===Zo(o.d).slice(0,c))return o=o.times(2),s!==0&&(o=o.plus(oN(y,c+2,v).times(s+""))),o=fc(o,new y(h),c),y.precision=v,e==null?(dr=!0,Zn(o,v)):o;o=l,i+=2}}function G$(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=$m(n/sr),t.d=[],r=(n+1)%sr,n<0&&(r+=sr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=sr;r<i;)t.d.push(+e.slice(r,r+=sr));e=e.slice(r),r=sr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),dr&&(t.e>zS||t.e<-zS))throw Error(yO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Zn(t,e,n){var r,i,s,a,o,l,c,u,h=t.d;for(a=1,s=h[0];s>=10;s/=10)a++;if(r=e-a,r<0)r+=sr,i=e,c=h[u=0];else{if(u=Math.ceil((r+1)/sr),s=h.length,u>=s)return t;for(c=s=h[u],a=1;s>=10;s/=10)a++;r%=sr,i=r-sr+a}if(n!==void 0&&(s=Wd(10,a-i-1),o=c/s%10|0,l=e<0||h[u+1]!==void 0||c%s,l=n<4?(o||l)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||l||n==6&&(r>0?i>0?c/Wd(10,a-i):0:h[u-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return l?(s=Yr(t),h.length=1,e=e-s-1,h[0]=Wd(10,(sr-e%sr)%sr),t.e=$m(-e/sr)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=u,s=1,u--):(h.length=u+1,s=Wd(10,sr-r),h[u]=i>0?(c/Wd(10,a-i)%Wd(10,i)|0)*s:0),l)for(;;)if(u==0){(h[0]+=s)==Ei&&(h[0]=1,++t.e);break}else{if(h[u]+=s,h[u]!=Ei)break;h[u--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(dr&&(t.e>zS||t.e<-zS))throw Error(yO+Yr(t));return t}function UZ(t,e){var n,r,i,s,a,o,l,c,u,h,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),dr?Zn(e,m):e;if(l=t.d,h=e.d,r=e.e,c=t.e,l=l.slice(),a=c-r,a){for(u=a<0,u?(n=l,a=-a,o=h.length):(n=h,r=c,o=l.length),i=Math.max(Math.ceil(m/sr),o)+2,a>i&&(a=i,n.length=1),n.reverse(),i=a;i--;)n.push(0);n.reverse()}else{for(i=l.length,o=h.length,u=i<o,u&&(o=i),i=0;i<o;i++)if(l[i]!=h[i]){u=l[i]<h[i];break}a=0}for(u&&(n=l,l=h,h=n,e.s=-e.s),o=l.length,i=h.length-o;i>0;--i)l[o++]=0;for(i=h.length;i>a;){if(l[--i]<h[i]){for(s=i;s&&l[--s]===0;)l[s]=Ei-1;--l[s],l[i]+=Ei}l[i]-=h[i]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(e.d=l,e.e=r,dr?Zn(e,m):e):new g(0)}function Gf(t,e,n){var r,i=Yr(t),s=Zo(t.d),a=s.length;return e?(n&&(r=n-a)>0?s=s.charAt(0)+"."+s.slice(1)+Eu(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Eu(-i-1)+s,n&&(r=n-a)>0&&(s+=Eu(r))):i>=a?(s+=Eu(i+1-a),n&&(r=n-i-1)>0&&(s=s+"."+Eu(r))):((r=i+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-a)>0&&(i+1===a&&(s+="."),s+=Eu(r))),t.s<0?"-"+s:s}function W$(t,e){if(t.length>e)return t.length=e,!0}function FZ(t){var e,n,r;function i(s){var a=this;if(!(a instanceof i))return new i(s);if(a.constructor=i,s instanceof i){a.s=s.s,a.e=s.e,a.d=(s=s.d)?s.slice():s;return}if(typeof s=="number"){if(s*0!==0)throw Error(_f+s);if(s>0)a.s=1;else if(s<0)s=-s,a.s=-1;else{a.s=0,a.e=0,a.d=[0];return}if(s===~~s&&s<1e7){a.e=0,a.d=[s];return}return G$(a,s.toString())}else if(typeof s!="string")throw Error(_f+s);if(s.charCodeAt(0)===45?(s=s.slice(1),a.s=-1):a.s=1,Nje.test(s))G$(a,s);else throw Error(_f+s)}if(i.prototype=Nt,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=FZ,i.config=i.set=Rje,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 Rje(t){if(!t||typeof t!="object")throw Error(Qa+"Object expected");var e,n,r,i=["precision",1,Hm,"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($m(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(_f+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(_f+n+": "+r);return this}var _O=FZ(Cje);ua=new _O(1);const In=_O;var Pje=t=>t,zZ={},BZ=t=>t===zZ,q$=t=>function e(){return arguments.length===0||arguments.length===1&&BZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},HZ=(t,e)=>t===1?e:q$(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var s=r.filter(a=>a!==zZ).length;return s>=t?e(...r):HZ(t-s,q$(function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];var c=r.map(u=>BZ(u)?o.shift():u);return e(...c,...o)}))}),kje=t=>HZ(t.length,t),pP=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Dje=kje((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Oje=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Pje;var i=n.reverse(),s=i[0],a=i.slice(1);return function(){return a.reduce((o,l)=>l(o),s(...arguments))}},mP=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function $Z(t){var e;return t===0?e=1:e=Math.floor(new In(t).abs().log(10).toNumber())+1,e}function VZ(t,e,n){for(var r=new In(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var GZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},WZ=(t,e,n)=>{if(t.lte(0))return new In(0);var r=$Z(t.toNumber()),i=new In(10).pow(r),s=t.div(i),a=r!==1?.05:.1,o=new In(Math.ceil(s.div(a).toNumber())).add(n).mul(a),l=o.mul(i);return e?new In(l.toNumber()):new In(Math.ceil(l.toNumber()))},Lje=(t,e,n)=>{var r=new In(1),i=new In(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new In(10).pow($Z(t)-1),i=new In(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new In(Math.floor(t)))}else t===0?i=new In(Math.floor((e-1)/2)):n||(i=new In(Math.floor(t)));var a=Math.floor((e-1)/2),o=Oje(Dje(l=>i.add(new In(l-a).mul(r)).toNumber()),pP);return o(0,e)},qZ=function(e,n,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new In(0),tickMin:new In(0),tickMax:new In(0)};var a=WZ(new In(n).sub(e).div(r-1),i,s),o;e<=0&&n>=0?o=new In(0):(o=new In(e).add(n).div(2),o=o.sub(new In(o).mod(a)));var l=Math.ceil(o.sub(e).div(a).toNumber()),c=Math.ceil(new In(n).sub(o).div(a).toNumber()),u=l+c+1;return u>r?qZ(e,n,r,i,s+1):(u<r&&(c=n>0?c+(r-u):c,l=n>0?l:l+(r-u)),{step:a,tickMin:o.sub(new In(l).mul(a)),tickMax:o.add(new In(c).mul(a))})},Ije=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=Math.max(i,2),[o,l]=GZ([n,r]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...pP(0,i-1).map(()=>1/0)]:[...pP(0,i-1).map(()=>-1/0),l];return n>r?mP(c):c}if(o===l)return Lje(o,i,s);var{step:u,tickMin:h,tickMax:g}=qZ(o,l,a,s,0),m=VZ(h,g.add(new In(.1).mul(u)),u);return n>r?mP(m):m},jje=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=GZ([r,i]);if(a===-1/0||o===1/0)return[r,i];if(a===o)return[a];var l=Math.max(n,2),c=WZ(new In(o).sub(a).div(l-1),s,0),u=[...VZ(new In(a),new In(o),c),o];return s===!1&&(u=u.map(h=>Math.round(h))),r>i?mP(u):u},XZ=t=>t.rootProps.maxBarSize,Uje=t=>t.rootProps.barGap,KZ=t=>t.rootProps.barCategoryGap,Fje=t=>t.rootProps.barSize,xv=t=>t.rootProps.stackOffset,YZ=t=>t.rootProps.reverseStackOrder,SO=t=>t.options.chartName,wO=t=>t.rootProps.syncId,ZZ=t=>t.rootProps.syncMethod,MO=t=>t.options.eventEmitter,zje=t=>t.rootProps.baseValue,Xr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Zl={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},oa={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},pM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Bje={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Zl.angleAxisId,includeHidden:!1,name:void 0,reversed:Zl.reversed,scale:Zl.scale,tick:Zl.tick,tickCount:void 0,ticks:void 0,type:Zl.type,unit:void 0},Hje={allowDataOverflow:oa.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:oa.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:oa.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:oa.scale,tick:oa.tick,tickCount:oa.tickCount,ticks:void 0,type:oa.type,unit:void 0},$je={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Zl.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Zl.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Zl.scale,tick:Zl.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Vje={allowDataOverflow:oa.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:oa.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:oa.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:oa.scale,tick:oa.tick,tickCount:oa.tickCount,ticks:void 0,type:"category",unit:void 0},EO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?$je:Bje,AO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Vje:Hje,mM=t=>t.polarOptions,TO=Ge([Cc,Nc,fi],KY),QZ=Ge([mM,TO],(t,e)=>{if(t!=null)return cs(t.innerRadius,e,0)}),JZ=Ge([mM,TO],(t,e)=>{if(t!=null)return cs(t.outerRadius,e,e*.8)}),Gje=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},eQ=Ge([mM],Gje);Ge([EO,eQ],pM);var tQ=Ge([TO,QZ,JZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ge([AO,tQ],pM);var nQ=Ge([Sn,mM,QZ,JZ,Cc,Nc],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:a,cy:o,startAngle:l,endAngle:c}=e;return{cx:cs(a,i,i/2),cy:cs(o,s,s/2),innerRadius:n,outerRadius:r,startAngle:l,endAngle:c,clockWise:!1}}}),hr=(t,e)=>e,vv=(t,e,n)=>n;function gM(t){return t?.id}function rQ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,a=new Map;return t.forEach(o=>{var l,c=(l=o.data)!==null&&l!==void 0?l:r;if(!(c==null||c.length===0)){var u=gM(o);c.forEach((h,g)=>{var m=s==null||i?g:String(Yn(h,s,null)),b=Yn(h,o.dataKey,0),y;a.has(m)?y=a.get(m):y={},Object.assign(y,{[u]:b}),a.set(m,y)})}}),Array.from(a.values())}function xM(t){return t.stackId!=null&&t.dataKey!=null}var vM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function bM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Wje(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 pi=t=>{var e=Sn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Vm=t=>t.tooltip.settings.axisId;function X$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function BS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X$(Object(n),!0).forEach(function(r){qje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qje(t,e,n){return(e=Xje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Xje(t){var e=Kje(t,"string");return typeof e=="symbol"?e:e+""}function Kje(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var gP=[0,"auto"],wi={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},iQ=(t,e)=>t.cartesianAxis.xAxis[e],Pc=(t,e)=>{var n=iQ(t,e);return n??wi},Mi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:gP,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:cv},sQ=(t,e)=>t.cartesianAxis.yAxis[e],kc=(t,e)=>{var n=sQ(t,e);return n??Mi},Yje={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:""},CO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Yje},br=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);case"zAxis":return CO(t,n);case"angleAxis":return EO(t,n);case"radiusAxis":return AO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Zje=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},bv=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);case"angleAxis":return EO(t,n);case"radiusAxis":return AO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},aQ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function NO(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 yM=t=>t.graphicalItems.cartesianItems,Qje=Ge([hr,vv],NO),RO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),yv=Ge([yM,br,Qje],RO,{memoizeOptions:{resultEqualityCheck:bM}}),oQ=Ge([yv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(xM)),lQ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Jje=Ge([yv],lQ),PO=t=>t.map(e=>e.data).filter(Boolean).flat(1),e4e=Ge([yv],PO,{memoizeOptions:{resultEqualityCheck:bM}}),kO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},DO=Ge([e4e,hM],kO),OO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Yn(i,r)}))):t.map(r=>({value:r})),_M=Ge([DO,br,yv],OO);function cQ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function $_(t){if(ll(t)||t instanceof Date){var e=Number(t);if(or(e))return e}}function K$(t){if(Array.isArray(t)){var e=[$_(t[0]),$_(t[1])];return rd(e)?e:void 0}var n=$_(t);if(n!=null)return[n,n]}function Mc(t){return t.map($_).filter(J3e)}function t4e(t,e,n){return!n||typeof e!="number"||Ya(e)?[]:n.length?Mc(n.flatMap(r=>{var i=Yn(t,r.dataKey),s,a;if(Array.isArray(i)?[s,a]=i:s=a=i,!(!or(s)||!or(a)))return[e-s,e+a]})):[]}var mi=t=>{var e=pi(t),n=Vm(t);return bv(t,e,n)},_v=Ge([mi],t=>t?.dataKey),n4e=Ge([oQ,hM,mi],rQ),uQ=(t,e,n,r)=>{var i={},s=e.reduce((a,o)=>(o.stackId==null||(a[o.stackId]==null&&(a[o.stackId]=[]),a[o.stackId].push(o)),a),i);return Object.fromEntries(Object.entries(s).map(a=>{var[o,l]=a,c=r?[...l].reverse():l,u=c.map(gM);return[o,{stackedData:_ke(t,u,n),graphicalItems:c}]}))},j0=Ge([n4e,oQ,xv,YZ],uQ),dQ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var a=Eke(t,i,s);if(!(a!=null&&a[0]===0&&a[1]===0))return a}},r4e=Ge([br],t=>t.allowDataOverflow),LO=t=>{var e;if(t==null||!("domain"in t))return gP;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Mc(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:gP},IO=Ge([br],LO),jO=Ge([IO,r4e],OZ),i4e=Ge([j0,pd,hr,jO],dQ,{memoizeOptions:{resultEqualityCheck:vM}}),SM=t=>t.errorBars,s4e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>cQ(n,r)),HS=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var s=i.flat(),a=Math.min(...s),o=Math.max(...s);return[a,o]}},UO=(t,e,n,r,i)=>{var s,a;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var c,u,h=(c=r[l.id])===null||c===void 0?void 0:c.filter(x=>cQ(i,x)),g=Yn(o,(u=e.dataKey)!==null&&u!==void 0?u:l.dataKey),m=t4e(o,g,h);if(m.length>=2){var b=Math.min(...m),y=Math.max(...m);(s==null||b<s)&&(s=b),(a==null||y>a)&&(a=y)}var v=K$(g);v!=null&&(s=s==null?v[0]:Math.min(s,v[0]),a=a==null?v[1]:Math.max(a,v[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var l=K$(Yn(o,e.dataKey));l!=null&&(s=s==null?l[0]:Math.min(s,l[0]),a=a==null?l[1]:Math.max(a,l[1]))}),or(s)&&or(a))return[s,a]},a4e=Ge([DO,br,Jje,SM,hr],UO,{memoizeOptions:{resultEqualityCheck:vM}});function o4e(t){var{value:e}=t;if(ll(e)||e instanceof Date)return e}var l4e=(t,e,n)=>{var r=t.map(o4e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&AK(r))?JY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},fQ=t=>t.referenceElements.dots,Gm=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),c4e=Ge([fQ,hr,vv],Gm),hQ=t=>t.referenceElements.areas,u4e=Ge([hQ,hr,vv],Gm),pQ=t=>t.referenceElements.lines,d4e=Ge([pQ,hr,vv],Gm),mQ=(t,e)=>{var n=Mc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},f4e=Ge(c4e,hr,mQ),gQ=(t,e)=>{var n=Mc(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)]},h4e=Ge([u4e,hr],gQ);function p4e(t){var e;if(t.x!=null)return Mc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Mc(n)}function m4e(t){var e;if(t.y!=null)return Mc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Mc(n)}var xQ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?p4e(r):m4e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},g4e=Ge([d4e,hr],xQ),x4e=Ge(f4e,g4e,h4e,(t,e,n)=>HS(t,n,e)),FO=(t,e,n,r,i,s,a,o)=>{if(n!=null)return n;var l=a==="vertical"&&o==="xAxis"||a==="horizontal"&&o==="yAxis",c=l?HS(r,s,i):HS(s,i);return Tje(e,c,t.allowDataOverflow)},v4e=Ge([br,IO,jO,i4e,a4e,x4e,Sn,hr],FO,{memoizeOptions:{resultEqualityCheck:vM}}),b4e=[0,1],zO=(t,e,n,r,i,s,a)=>{if(!((t==null||n==null||n.length===0)&&a===void 0)){var{dataKey:o,type:l}=t,c=Tc(e,s);if(c&&o==null){var u;return JY(0,(u=n?.length)!==null&&u!==void 0?u:0)}return l==="category"?l4e(r,t,c):i==="expand"?b4e:a}},BO=Ge([br,Sn,DO,_M,xv,hr,v4e],zO),vQ=(t,e,n,r,i)=>{if(t!=null){var{scale:s,type:a}=t;if(s==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":a==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":a==="category"?"band":"linear";if(typeof s=="string"){var o="scale".concat(rv(s));return o in _x?o:"point"}}},Wm=Ge([br,Sn,aQ,SO,hr],vQ);function y4e(t){if(t!=null){if(t in _x)return _x[t]();var e="scale".concat(rv(t));if(e in _x)return _x[e]()}}function HO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=y4e(e);if(i!=null){var s=i.domain(n).range(r);return gke(s),s}}}var $O=(t,e,n)=>{var r=LO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&rd(t))return Ije(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&rd(t))return jje(t,e.tickCount,e.allowDecimals)}},VO=Ge([BO,bv,Wm],$O),GO=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&rd(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],a=e[1],o=n[n.length-1];return[Math.min(i,s),Math.max(a,o)]}return e},_4e=Ge([br,BO,VO,hr],GO),S4e=Ge(_M,br,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Mc(t.map(o=>o.value))).sort((o,l)=>o-l);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var s=0;s<r.length-1;s++){var a=r[s+1]-r[s];n=Math.min(n,a)}return n/i}}),bQ=Ge(S4e,Sn,KZ,fi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!or(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var a=cs(n,t*s),o=t*s/2;return o-a-(o-a)/s*a}return 0}),w4e=(t,e)=>{var n=Pc(t,e);return n==null||typeof n.padding!="string"?0:bQ(t,"xAxis",e,n.padding)},M4e=(t,e)=>{var n=kc(t,e);return n==null||typeof n.padding!="string"?0:bQ(t,"yAxis",e,n.padding)},E4e=Ge(Pc,w4e,(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}}),A4e=Ge(kc,M4e,(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}}),T4e=Ge([fi,E4e,tM,eM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:s}=r;return i?[s.left,n.width-s.right]:[t.left+e.left,t.left+t.width-e.right]}),C4e=Ge([fi,Sn,A4e,tM,eM,(t,e,n)=>n],(t,e,n,r,i,s)=>{var{padding:a}=i;return s?[r.height-a.bottom,a.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Sv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return T4e(t,n,r);case"yAxis":return C4e(t,n,r);case"zAxis":return(i=CO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return eQ(t);case"radiusAxis":return tQ(t,n);default:return}},yQ=Ge([br,Sv],pM),qm=Ge([br,Wm,_4e,yQ],HO);Ge([yv,SM,hr],s4e);function _Q(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var wM=(t,e)=>e,MM=(t,e,n)=>n,N4e=Ge(Qw,wM,MM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(_Q)),R4e=Ge(Jw,wM,MM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(_Q)),SQ=(t,e)=>({width:t.width,height:e.height}),P4e=(t,e)=>{var n=typeof e.width=="number"?e.width:cv;return{width:n,height:t.height}},wQ=Ge(fi,Pc,SQ),k4e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},D4e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},O4e=Ge(Nc,fi,N4e,wM,MM,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=SQ(e,o);a==null&&(a=k4e(e,r,t));var c=r==="top"&&!i||r==="bottom"&&i;s[o.id]=a-Number(c)*l.height,a+=(c?-1:1)*l.height}),s}),L4e=Ge(Cc,fi,R4e,wM,MM,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=P4e(e,o);a==null&&(a=D4e(e,r,t));var c=r==="left"&&!i||r==="right"&&i;s[o.id]=a-Number(c)*l.width,a+=(c?-1:1)*l.width}),s}),I4e=(t,e)=>{var n=Pc(t,e);if(n!=null)return O4e(t,n.orientation,n.mirror)},j4e=Ge([fi,Pc,I4e,(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}}}),U4e=(t,e)=>{var n=kc(t,e);if(n!=null)return L4e(t,n.orientation,n.mirror)},F4e=Ge([fi,kc,U4e,(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}}}),MQ=Ge(fi,kc,(t,e)=>{var n=typeof e.width=="number"?e.width:cv;return{width:n,height:t.height}}),Y$=(t,e,n)=>{switch(e){case"xAxis":return wQ(t,n).width;case"yAxis":return MQ(t,n).height;default:return}},EQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:a}=n,o=Tc(t,r),l=e.map(c=>c.value);if(a&&o&&s==="category"&&i&&AK(l))return l}},WO=Ge([Sn,_M,br,hr],EQ),AQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,a=Tc(t,r);if(a&&(i==="number"||s!=="auto"))return e.map(o=>o.value)}},qO=Ge([Sn,_M,bv,hr],AQ),Z$=Ge([Sn,Zje,Wm,qm,WO,qO,Sv,VO,hr],(t,e,n,r,i,s,a,o,l)=>{if(e!=null){var c=Tc(t,l);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:l,categoricalDomain:s,duplicateDomain:i,isCategorical:c,niceTicks:o,range:a,realScaleType:n,scale:r}}}),z4e=(t,e,n,r,i,s,a,o,l)=>{if(!(e==null||r==null)){var c=Tc(t,l),{type:u,ticks:h,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=u==="category"&&r.bandwidth?r.bandwidth()/m:0;b=l==="angleAxis"&&s!=null&&s.length>=2?Ci(s[0]-s[1])*2*b:b;var y=h||i;if(y){var v=y.map((x,M)=>{var w=a?a.indexOf(x):x;return{index:M,coordinate:r(w)+b,value:x,offset:b}});return v.filter(x=>or(x.coordinate))}return c&&o?o.map((x,M)=>({coordinate:r(x)+b,value:x,index:M,offset:b})).filter(x=>or(x.coordinate)):r.ticks?r.ticks(g).map(x=>({coordinate:r(x)+b,value:x,offset:b})):r.domain().map((x,M)=>({coordinate:r(x)+b,value:a?a[x]:x,index:M,offset:b}))}},TQ=Ge([Sn,bv,Wm,qm,VO,Sv,WO,qO,hr],z4e),B4e=(t,e,n,r,i,s,a)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=Tc(t,a),{tickCount:l}=e,c=0;return c=a==="angleAxis"&&r?.length>=2?Ci(r[0]-r[1])*2*c:c,o&&s?s.map((u,h)=>({coordinate:n(u)+c,value:u,index:h,offset:c})):n.ticks?n.ticks(l).map(u=>({coordinate:n(u)+c,value:u,offset:c})):n.domain().map((u,h)=>({coordinate:n(u)+c,value:i?i[u]:u,index:h,offset:c}))}},id=Ge([Sn,bv,qm,Sv,WO,qO,hr],B4e),sd=Ge(br,qm,(t,e)=>{if(!(t==null||e==null))return BS(BS({},t),{},{scale:e})}),H4e=Ge([br,Wm,BO,yQ],HO);Ge((t,e,n)=>CO(t,n),H4e,(t,e)=>{if(!(t==null||e==null))return BS(BS({},t),{},{scale:e})});var $4e=Ge([Sn,Qw,Jw],(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}}),CQ=t=>t.options.defaultTooltipEventType,NQ=t=>t.options.validateTooltipEventTypes;function RQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function XO(t,e){var n=CQ(t),r=NQ(t);return RQ(e,n,r)}function V4e(t){return Ct(e=>XO(e,t))}var PQ=(t,e)=>{var n,r=Number(e);if(!(Ya(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},G4e=t=>t.tooltip.settings,Ru={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},W4e={itemInteraction:{click:Ru,hover:Ru},axisInteraction:{click:Ru,hover:Ru},keyboardInteraction:Ru,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}},kQ=Xs({name:"tooltip",initialState:W4e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:cr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=wo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:cr()},removeTooltipEntrySettings:{reducer(t,e){var n=wo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:cr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:q4e,replaceTooltipEntrySettings:X4e,removeTooltipEntrySettings:K4e,setTooltipSettingsState:Y4e,setActiveMouseOverItemIndex:DQ,mouseLeaveItem:Z4e,mouseLeaveChart:OQ,setActiveClickItemIndex:Q4e,setMouseOverAxisIndex:LQ,setMouseClickAxisIndex:J4e,setSyncInteraction:xP,setKeyboardInteraction:vP}=kQ.actions,eUe=kQ.reducer;function Q$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function p_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q$(Object(n),!0).forEach(function(r){tUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tUe(t,e,n){return(e=nUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nUe(t){var e=rUe(t,"string");return typeof e=="symbol"?e:e+""}function rUe(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 iUe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function sUe(t){return t.index!=null}var IQ=(t,e,n,r)=>{if(e==null)return Ru;var i=iUe(t,e,n);if(i==null)return Ru;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(sUe(i)){if(s)return p_(p_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return p_(p_({},Ru),{},{coordinate:i.coordinate})};function aUe(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 oUe(t,e){var n=aUe(t),r=e[0],i=e[1];if(n===void 0)return!1;var s=Math.min(r,i),a=Math.max(r,i);return n>=s&&n<=a}function lUe(t,e,n){if(n==null||e==null)return!0;var r=Yn(t,e);return r==null||!rd(n)?!0:oUe(r,n)}var KO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!or(s))return i;var a=0,o=1/0;e.length>0&&(o=e.length-1);var l=Math.max(a,Math.min(s,o)),c=e[l];return c==null||lUe(c,n,r)?String(l):null},jQ=(t,e,n,r,i,s,a,o)=>{if(!(s==null||o==null)){var l=a[0],c=l==null?void 0:o(l.positions,s);if(c!=null)return c;var u=i?.[Number(s)];if(u)switch(n){case"horizontal":return{x:u.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:u.coordinate}}}},UQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(s=>{var a;return((a=s.settings)===null||a===void 0?void 0:a.dataKey)===i})},wv=t=>t.options.tooltipPayloadSearcher,Xm=t=>t.tooltip;function J$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J$(Object(n),!0).forEach(function(r){cUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cUe(t,e,n){return(e=uUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uUe(t){var e=dUe(t,"string");return typeof e=="symbol"?e:e+""}function dUe(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 fUe(t,e){return t??e}var FQ=(t,e,n,r,i,s,a)=>{if(!(e==null||s==null)){var{chartData:o,computedData:l,dataStartIndex:c,dataEndIndex:u}=n,h=[];return t.reduce((g,m)=>{var b,{dataDefinedOnItem:y,settings:v}=m,x=fUe(y,o),M=Array.isArray(x)?yY(x,c,u):x,w=(b=v?.dataKey)!==null&&b!==void 0?b:r,T=v?.nameKey,A;if(r&&Array.isArray(M)&&!Array.isArray(M[0])&&a==="axis"?A=TK(M,r,i):A=s(M,e,l,T),Array.isArray(A))A.forEach(C=>{var j=eV(eV({},v),{},{name:C.name,unit:C.unit,color:void 0,fill:void 0});g.push(yH({tooltipEntrySettings:j,dataKey:C.dataKey,payload:C.payload,value:Yn(C.payload,C.dataKey),name:C.name}))});else{var P;g.push(yH({tooltipEntrySettings:v,dataKey:w,payload:A,value:Yn(A,w),name:(P=Yn(A,T))!==null&&P!==void 0?P:v?.name}))}return g},h)}},YO=Ge([mi,Sn,aQ,SO,pi],vQ),hUe=Ge([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),pUe=Ge([pi,Vm],NO),Mv=Ge([hUe,mi,pUe],RO,{memoizeOptions:{resultEqualityCheck:bM}}),mUe=Ge([Mv],t=>t.filter(xM)),gUe=Ge([Mv],PO,{memoizeOptions:{resultEqualityCheck:bM}}),Km=Ge([gUe,pd],kO),xUe=Ge([mUe,pd,mi],rQ),ZO=Ge([Km,mi,Mv],OO),zQ=Ge([mi],LO),vUe=Ge([mi],t=>t.allowDataOverflow),BQ=Ge([zQ,vUe],OZ),bUe=Ge([Mv],t=>t.filter(xM)),yUe=Ge([xUe,bUe,xv,YZ],uQ),_Ue=Ge([yUe,pd,pi,BQ],dQ),SUe=Ge([Mv],lQ),wUe=Ge([Km,mi,SUe,SM,pi],UO,{memoizeOptions:{resultEqualityCheck:vM}}),MUe=Ge([fQ,pi,Vm],Gm),EUe=Ge([MUe,pi],mQ),AUe=Ge([hQ,pi,Vm],Gm),TUe=Ge([AUe,pi],gQ),CUe=Ge([pQ,pi,Vm],Gm),NUe=Ge([CUe,pi],xQ),RUe=Ge([EUe,NUe,TUe],HS),PUe=Ge([mi,zQ,BQ,_Ue,wUe,RUe,Sn,pi],FO),Ev=Ge([mi,Sn,Km,ZO,xv,pi,PUe],zO),kUe=Ge([Ev,mi,YO],$O),DUe=Ge([mi,Ev,kUe,pi],GO),HQ=t=>{var e=pi(t),n=Vm(t),r=!1;return Sv(t,e,n,r)},$Q=Ge([mi,HQ],pM),VQ=Ge([mi,YO,DUe,$Q],HO),OUe=Ge([Sn,ZO,mi,pi],EQ),LUe=Ge([Sn,ZO,mi,pi],AQ),IUe=(t,e,n,r,i,s,a,o)=>{if(e){var{type:l}=e,c=Tc(t,o);if(r){var u=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=l==="category"&&r.bandwidth?r.bandwidth()/u:0;return h=o==="angleAxis"&&i!=null&&i?.length>=2?Ci(i[0]-i[1])*2*h:h,c&&a?a.map((g,m)=>({coordinate:r(g)+h,value:g,index:m,offset:h})):r.domain().map((g,m)=>({coordinate:r(g)+h,value:s?s[g]:g,index:m,offset:h}))}}},Dc=Ge([Sn,mi,YO,VQ,HQ,OUe,LUe,pi],IUe),QO=Ge([CQ,NQ,G4e],(t,e,n)=>RQ(n.shared,t,e)),GQ=t=>t.tooltip.settings.trigger,JO=t=>t.tooltip.settings.defaultIndex,Av=Ge([Xm,QO,GQ,JO],IQ),ad=Ge([Av,Km,_v,Ev],KO),WQ=Ge([Dc,ad],PQ),eL=Ge([Av],t=>{if(t)return t.dataKey}),jUe=Ge([Av],t=>{if(t)return t.graphicalItemId}),qQ=Ge([Xm,QO,GQ,JO],UQ),UUe=Ge([Cc,Nc,Sn,fi,Dc,JO,qQ,wv],jQ),FUe=Ge([Av,UUe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),zUe=Ge([Av],t=>t.active),BUe=Ge([qQ,ad,pd,_v,WQ,wv,QO],FQ),HUe=Ge([BUe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function tV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tV(Object(n),!0).forEach(function(r){$Ue(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Ue(t,e,n){return(e=VUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VUe(t){var e=GUe(t,"string");return typeof e=="symbol"?e:e+""}function GUe(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 WUe=()=>Ct(mi),qUe=()=>{var t=WUe(),e=Ct(Dc),n=Ct(VQ);return vm(!t||!n?void 0:nV(nV({},t),{},{scale:n}),e)};function rV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function gp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rV(Object(n),!0).forEach(function(r){XUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XUe(t,e,n){return(e=KUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KUe(t){var e=YUe(t,"string");return typeof e=="symbol"?e:e+""}function YUe(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 ZUe=(t,e,n,r)=>{var i=e.find(s=>s&&s.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},QUe=(t,e,n,r)=>{var i=e.find(c=>c&&c.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:a}=r;return gp(gp(gp({},r),qr(r.cx,r.cy,a,s)),{},{angle:s,radius:a})}var o=i.coordinate,{angle:l}=r;return gp(gp(gp({},r),qr(r.cx,r.cy,o,l)),{},{angle:l,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function JUe(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 XQ=(t,e,n,r,i)=>{var s,a=-1,o=(s=e?.length)!==null&&s!==void 0?s:0;if(o<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var l=0;l<o;l++){var c=l>0?n[l-1].coordinate:n[o-1].coordinate,u=n[l].coordinate,h=l>=o-1?n[0].coordinate:n[l+1].coordinate,g=void 0;if(Ci(u-c)!==Ci(h-u)){var m=[];if(Ci(h-u)===Ci(i[1]-i[0])){g=h;var b=u+i[1]-i[0];m[0]=Math.min(b,(b+c)/2),m[1]=Math.max(b,(b+c)/2)}else{g=c;var y=h+i[1]-i[0];m[0]=Math.min(u,(y+u)/2),m[1]=Math.max(u,(y+u)/2)}var v=[Math.min(u,(g+u)/2),Math.max(u,(g+u)/2)];if(t>v[0]&&t<=v[1]||t>=m[0]&&t<=m[1]){({index:a}=n[l]);break}}else{var x=Math.min(c,h),M=Math.max(c,h);if(t>(x+u)/2&&t<=(M+u)/2){({index:a}=n[l]);break}}}else if(e){for(var w=0;w<o;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:a}=e[w]);break}}return a},KQ=()=>Ct(SO),tL=(t,e)=>e,YQ=(t,e,n)=>n,nL=(t,e,n,r)=>r,eFe=Ge(Dc,t=>$w(t,e=>e.coordinate)),rL=Ge([Xm,tL,YQ,nL],IQ),iL=Ge([rL,Km,_v,Ev],KO),tFe=(t,e,n)=>{if(e!=null){var r=Xm(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},ZQ=Ge([Xm,tL,YQ,nL],UQ),$S=Ge([Cc,Nc,Sn,fi,Dc,nL,ZQ,wv],jQ),nFe=Ge([rL,$S],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),QQ=Ge([Dc,iL],PQ),rFe=Ge([ZQ,iL,pd,_v,QQ,wv,tL],FQ),iFe=Ge([rL,iL],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),sFe=(t,e,n,r,i,s,a)=>{if(!(!t||!n||!r||!i)&&JUe(t,a)){var o=Ake(t,e),l=XQ(o,s,i,n,r),c=ZUe(e,i,l,t);return{activeIndex:String(l),activeCoordinate:c}}},aFe=(t,e,n,r,i,s,a)=>{if(!(!t||!r||!i||!s||!n)){var o=$Oe(t,n);if(o){var l=Tke(o,e),c=XQ(l,a,s,r,i),u=QUe(e,s,c,o);return{activeIndex:String(c),activeCoordinate:u}}}},oFe=(t,e,n,r,i,s,a,o)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?sFe(t,e,r,i,s,a,o):aFe(t,e,n,r,i,s,a)},lFe=Ge(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}}),cFe=Ge(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Xr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Wje}});function iV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function sV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?iV(Object(n),!0).forEach(function(r){uFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uFe(t,e,n){return(e=dFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dFe(t){var e=fFe(t,"string");return typeof e=="symbol"?e:e+""}function fFe(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 hFe={},pFe={zIndexMap:Object.values(Xr).reduce((t,e)=>sV(sV({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),hFe)},mFe=new Set(Object.values(Xr));function gFe(t){return mFe.has(t)}var JQ=Xs({name:"zIndex",initialState:pFe,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:cr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!gFe(n)&&delete t.zIndexMap[n])},prepare:cr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:cr()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:cr()}}}),{registerZIndexPortal:xFe,unregisterZIndexPortal:vFe,registerZIndexPortalId:bFe,unregisterZIndexPortalId:yFe}=JQ.actions,_Fe=JQ.reducer;function Ks(t){var{zIndex:e,children:n}=t,r=sDe(),i=r&&e!==void 0&&e!==0,s=fs(),a=er();E.useLayoutEffect(()=>i?(a(xFe({zIndex:e})),()=>{a(vFe({zIndex:e}))}):iv,[a,e,i]);var o=Ct(c=>lFe(c,e,s));if(!i)return n;if(!o)return null;var l=document.getElementById(o);return l?Jl.createPortal(n,l):null}function bP(){return bP=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},bP.apply(null,arguments)}function aV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function m_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aV(Object(n),!0).forEach(function(r){SFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SFe(t,e,n){return(e=wFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wFe(t){var e=MFe(t,"string");return typeof e=="symbol"?e:e+""}function MFe(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 EFe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return E.isValidElement(e)?E.cloneElement(e,r):E.createElement(n,r)}function AFe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:a,layout:o,cursor:l,tooltipEventType:c,chartName:u}=t,h=n,g=r,m=i;if(!l||!h||u!=="ScatterChart"&&c!=="axis")return null;var b,y,v;if(u==="ScatterChart")b=h,y=iOe,v=Xr.cursorLine;else if(u==="BarChart")b=sOe(o,h,s,a),y=XY,v=Xr.cursorRectangle;else if(o==="radial"&&NK(h)){var{cx:x,cy:M,radius:w,startAngle:T,endAngle:A}=YY(h);b={cx:x,cy:M,startAngle:T,endAngle:A,innerRadius:w,outerRadius:w},y=QY,v=Xr.cursorLine}else b={points:qOe(o,h,s)},y=Vp,v=Xr.cursorLine;var P=typeof l=="object"&&"className"in l?l.className:void 0,C=m_(m_(m_(m_({stroke:"#ccc",pointerEvents:"none"},s),b),Bf(l)),{},{payload:g,payloadIndex:m,className:An("recharts-tooltip-cursor",P)});return E.createElement(Ks,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},E.createElement(EFe,{cursor:l,cursorComp:y,cursorProps:C}))}function TFe(t){var e=qUe(),n=PY(),r=Fm(),i=KQ();return e==null||n==null||r==null||i==null?null:E.createElement(AFe,bP({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var eJ=E.createContext(null),CFe=()=>E.useContext(eJ),lN={exports:{}},oV;function NFe(){return oV||(oV=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function s(l,c,u,h,g){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new i(u,h||l,g),b=n?n+c:c;return l._events[b]?l._events[b].fn?l._events[b]=[l._events[b],m]:l._events[b].push(m):(l._events[b]=m,l._eventsCount++),l}function a(l,c){--l._eventsCount===0?l._events=new r:delete l._events[c]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,h;if(this._eventsCount===0)return c;for(h in u=this._events)e.call(u,h)&&c.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=n?n+c:c,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,m=h.length,b=new Array(m);g<m;g++)b[g]=h[g].fn;return b},o.prototype.listenerCount=function(c){var u=n?n+c:c,h=this._events[u];return h?h.fn?1:h.length:0},o.prototype.emit=function(c,u,h,g,m,b){var y=n?n+c:c;if(!this._events[y])return!1;var v=this._events[y],x=arguments.length,M,w;if(v.fn){switch(v.once&&this.removeListener(c,v.fn,void 0,!0),x){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,u),!0;case 3:return v.fn.call(v.context,u,h),!0;case 4:return v.fn.call(v.context,u,h,g),!0;case 5:return v.fn.call(v.context,u,h,g,m),!0;case 6:return v.fn.call(v.context,u,h,g,m,b),!0}for(w=1,M=new Array(x-1);w<x;w++)M[w-1]=arguments[w];v.fn.apply(v.context,M)}else{var T=v.length,A;for(w=0;w<T;w++)switch(v[w].once&&this.removeListener(c,v[w].fn,void 0,!0),x){case 1:v[w].fn.call(v[w].context);break;case 2:v[w].fn.call(v[w].context,u);break;case 3:v[w].fn.call(v[w].context,u,h);break;case 4:v[w].fn.call(v[w].context,u,h,g);break;default:if(!M)for(A=1,M=new Array(x-1);A<x;A++)M[A-1]=arguments[A];v[w].fn.apply(v[w].context,M)}}return!0},o.prototype.on=function(c,u,h){return s(this,c,u,h,!1)},o.prototype.once=function(c,u,h){return s(this,c,u,h,!0)},o.prototype.removeListener=function(c,u,h,g){var m=n?n+c:c;if(!this._events[m])return this;if(!u)return a(this,m),this;var b=this._events[m];if(b.fn)b.fn===u&&(!g||b.once)&&(!h||b.context===h)&&a(this,m);else{for(var y=0,v=[],x=b.length;y<x;y++)(b[y].fn!==u||g&&!b[y].once||h&&b[y].context!==h)&&v.push(b[y]);v.length?this._events[m]=v.length===1?v[0]:v:a(this,m)}return this},o.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(lN)),lN.exports}var RFe=NFe();const PFe=Ja(RFe);var U0=new PFe,yP="recharts.syncEvent.tooltip",lV="recharts.syncEvent.brush";function sL(t,e){if(e){var n=Number.parseInt(e,10);if(!Ya(n))return t?.[n]}}var kFe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},tJ=Xs({name:"options",initialState:kFe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),DFe=tJ.reducer,{createEventEmitter:OFe}=tJ.actions;function LFe(t){return t.tooltip.syncInteraction}var IFe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},nJ=Xs({name:"chartData",initialState:IFe,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:cV,setDataStartEndIndexes:jFe,setComputedData:n9e}=nJ.actions,UFe=nJ.reducer,FFe=["x","y"];function uV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uV(Object(n),!0).forEach(function(r){zFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zFe(t,e,n){return(e=BFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BFe(t){var e=HFe(t,"string");return typeof e=="symbol"?e:e+""}function HFe(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 $Fe(t,e){if(t==null)return{};var n,r,i=VFe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function VFe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function GFe(){var t=Ct(wO),e=Ct(MO),n=er(),r=Ct(ZZ),i=Ct(Dc),s=Fm(),a=nM(),o=Ct(l=>l.rootProps.className);E.useEffect(()=>{if(t==null)return iv;var l=(c,u,h)=>{if(e!==h&&t===c){if(r==="index"){var g;if(a&&u!==null&&u!==void 0&&(g=u.payload)!==null&&g!==void 0&&g.coordinate&&u.payload.sourceViewBox){var m=u.payload.coordinate,{x:b,y}=m,v=$Fe(m,FFe),{x,y:M,width:w,height:T}=u.payload.sourceViewBox,A=xp(xp({},v),{},{x:a.x+(w?(b-x)/w:0)*a.width,y:a.y+(T?(y-M)/T:0)*a.height});n(xp(xp({},u),{},{payload:xp(xp({},u.payload),{},{coordinate:A})}))}else n(u);return}if(i!=null){var P;if(typeof r=="function"){var C={activeTooltipIndex:u.payload.index==null?void 0:Number(u.payload.index),isTooltipActive:u.payload.active,activeIndex:u.payload.index==null?void 0:Number(u.payload.index),activeLabel:u.payload.label,activeDataKey:u.payload.dataKey,activeCoordinate:u.payload.coordinate},j=r(i,C);P=i[j]}else r==="value"&&(P=i.find(G=>String(G.value)===u.payload.label));var{coordinate:N}=u.payload;if(P==null||u.payload.active===!1||N==null||a==null){n(xP({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:k,y:F}=N,I=Math.min(k,a.x+a.width),W=Math.min(F,a.y+a.height),D={x:s==="horizontal"?P.coordinate:I,y:s==="horizontal"?W:P.coordinate},$=xP({active:u.payload.active,coordinate:D,dataKey:u.payload.dataKey,index:String(P.index),label:u.payload.label,sourceViewBox:u.payload.sourceViewBox,graphicalItemId:u.payload.graphicalItemId});n($)}}};return U0.on(yP,l),()=>{U0.off(yP,l)}},[o,n,e,t,r,i,s,a])}function WFe(){var t=Ct(wO),e=Ct(MO),n=er();E.useEffect(()=>{if(t==null)return iv;var r=(i,s,a)=>{e!==a&&t===i&&n(jFe(s))};return U0.on(lV,r),()=>{U0.off(lV,r)}},[n,e,t])}function qFe(){var t=er();E.useEffect(()=>{t(OFe())},[t]),GFe(),WFe()}function XFe(t,e,n,r,i,s){var a=Ct(m=>tFe(m,t,e)),o=Ct(MO),l=Ct(wO),c=Ct(ZZ),u=Ct(LFe),h=u?.active,g=nM();E.useEffect(()=>{if(!h&&l!=null&&o!=null){var m=xP({active:s,coordinate:n,dataKey:a,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});U0.emit(yP,l,m,o)}},[h,n,a,i,r,o,l,c,s,g])}function dV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dV(Object(n),!0).forEach(function(r){KFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KFe(t,e,n){return(e=YFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YFe(t){var e=ZFe(t,"string");return typeof e=="symbol"?e:e+""}function ZFe(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 QFe(t){return t.dataKey}function JFe(t,e){return E.isValidElement(t)?E.cloneElement(t,e):typeof t=="function"?E.createElement(t,e):E.createElement(jDe,e)}var hV=[],eze={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 cN(t){var e,n,r=Qr(t,eze),{active:i,allowEscapeViewBox:s,animationDuration:a,animationEasing:o,content:l,filterNull:c,isAnimationActive:u,offset:h,payloadUniqBy:g,position:m,reverseDirection:b,useTranslate3d:y,wrapperStyle:v,cursor:x,shared:M,trigger:w,defaultIndex:T,portal:A,axisId:P}=r,C=er(),j=typeof T=="number"?String(T):T;E.useEffect(()=>{C(Y4e({shared:M,trigger:w,axisId:P,active:i,defaultIndex:j}))},[C,M,w,P,i,j]);var N=nM(),k=$Y(),F=V4e(M),{activeIndex:I,isActive:W}=(e=Ct(me=>iFe(me,F,w,j)))!==null&&e!==void 0?e:{},D=Ct(me=>rFe(me,F,w,j)),$=Ct(me=>QQ(me,F,w,j)),G=Ct(me=>nFe(me,F,w,j)),V=D,Z=CFe(),K=(n=i??W)!==null&&n!==void 0?n:!1,[ee,H]=VK([V,K]),Y=F==="axis"?$:void 0;XFe(F,w,G,Y,I,K);var te=A??Z;if(te==null||N==null||F==null)return null;var ae=V??hV;K||(ae=hV),c&&ae.length&&(ae=FK(ae.filter(me=>me.value!=null&&(me.hide!==!0||r.includeHidden)),g,QFe));var fe=ae.length>0,Q=E.createElement(VDe,{allowEscapeViewBox:s,animationDuration:a,animationEasing:o,isAnimationActive:u,active:K,coordinate:G,hasPayload:fe,offset:h,position:m,reverseDirection:b,useTranslate3d:y,viewBox:N,wrapperStyle:v,lastBoundingBox:ee,innerRef:H,hasPortalFromProps:!!A},JFe(l,fV(fV({},r),{},{payload:ae,label:Y,active:K,activeIndex:I,coordinate:G,accessibilityLayer:k})));return E.createElement(E.Fragment,null,Jl.createPortal(Q,te),K&&E.createElement(TFe,{cursor:x,tooltipEventType:F,coordinate:G,payload:ae,index:I}))}var Tv=t=>null;Tv.displayName="Cell";function tze(t,e,n){return(e=nze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nze(t){var e=rze(t,"string");return typeof e=="symbol"?e:e+""}function rze(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 ize{constructor(e){tze(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 pV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function sze(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pV(Object(n),!0).forEach(function(r){aze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aze(t,e,n){return(e=oze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oze(t){var e=lze(t,"string");return typeof e=="symbol"?e:e+""}function lze(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 cze={cacheSize:2e3,enableCache:!0},rJ=sze({},cze),mV=new ize(rJ.cacheSize),uze={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},gV="recharts_measurement_span";function dze(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",s=e.fontStyle||"",a=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(s,"|").concat(a,"|").concat(o)}var xV=(t,e)=>{try{var n=document.getElementById(gV);n||(n=document.createElement("span"),n.setAttribute("id",gV),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,uze,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Gx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||zm.isSsr)return{width:0,height:0};if(!rJ.enableCache)return xV(e,n);var r=dze(e,n),i=mV.get(r);if(i)return i;var s=xV(e,n);return mV.set(r,s),s},vV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,bV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,fze=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,hze=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,iJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},pze=Object.keys(iJ),Rp="NaN";function mze(t,e){return t*iJ[e]}class Is{static parse(e){var n,[,r,i]=(n=hze.exec(e))!==null&&n!==void 0?n:[];return new Is(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Ya(e)&&(this.unit=""),n!==""&&!fze.test(n)&&(this.num=NaN,this.unit=""),pze.includes(n)&&(this.num=mze(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Is(NaN,""):new Is(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Is(NaN,""):new Is(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Is(NaN,""):new Is(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Is(NaN,""):new Is(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Ya(this.num)}}function sJ(t){if(t.includes(Rp))return Rp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=vV.exec(e))!==null&&n!==void 0?n:[],a=Is.parse(r??""),o=Is.parse(s??""),l=i==="*"?a.multiply(o):a.divide(o);if(l.isNaN())return Rp;e=e.replace(vV,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var c,[,u,h,g]=(c=bV.exec(e))!==null&&c!==void 0?c:[],m=Is.parse(u??""),b=Is.parse(g??""),y=h==="+"?m.add(b):m.subtract(b);if(y.isNaN())return Rp;e=e.replace(bV,y.toString())}return e}var yV=/\(([^()]*)\)/;function gze(t){for(var e=t,n;(n=yV.exec(e))!=null;){var[,r]=n;e=e.replace(yV,sJ(r))}return e}function xze(t){var e=t.replace(/\s+/g,"");return e=gze(e),e=sJ(e),e}function vze(t){try{return xze(t)}catch{return Rp}}function uN(t){var e=vze(t.slice(5,-1));return e===Rp?"":e}var bze=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],yze=["dx","dy","angle","className","breakAll"];function _P(){return _P=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_P.apply(null,arguments)}function _V(t,e){if(t==null)return{};var n,r,i=_ze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _ze(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=/[ \f\n\r\t\v\u2028\u2029]+/,oJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];xr(e)||(n?i=e.toString().split(""):i=e.toString().split(aJ));var s=i.map(o=>({word:o,width:Gx(o,r).width})),a=n?0:Gx(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:a}}catch{return null}};function Sze(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var lJ=(t,e,n,r)=>t.reduce((i,s)=>{var{word:a,width:o}=s,l=i[i.length-1];if(l&&o!=null&&(e==null||r||l.width+o+n<Number(e)))l.words.push(a),l.width+=o+n;else{var c={words:[a],width:o};i.push(c)}return i},[]),cJ=t=>t.reduce((e,n)=>e.width>n.width?e:n),wze="…",SV=(t,e,n,r,i,s,a,o)=>{var l=t.slice(0,e),c=oJ({breakAll:n,style:r,children:l+wze});if(!c)return[!1,[]];var u=lJ(c.wordsWithComputedWidth,s,a,o),h=u.length>i||cJ(u).width>Number(s);return[h,u]},Mze=(t,e,n,r,i)=>{var{maxLines:s,children:a,style:o,breakAll:l}=t,c=Et(s),u=String(a),h=lJ(e,r,n,i);if(!c||i)return h;var g=h.length>s||cJ(h).width>Number(r);if(!g)return h;for(var m=0,b=u.length-1,y=0,v;m<=b&&y<=u.length-1;){var x=Math.floor((m+b)/2),M=x-1,[w,T]=SV(u,M,l,o,s,r,n,i),[A]=SV(u,x,l,o,s,r,n,i);if(!w&&!A&&(m=x+1),w&&A&&(b=x-1),!w&&A){v=T;break}y++}return v||h},wV=t=>{var e=xr(t)?[]:t.toString().split(aJ);return[{words:e,width:void 0}]},Eze=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:a}=t;if((e||n)&&!zm.isSsr){var o,l,c=oJ({breakAll:s,children:r,style:i});if(c){var{wordsWithComputedWidth:u,spaceWidth:h}=c;o=u,l=h}else return wV(r);return Mze({breakAll:s,children:r,maxLines:a,style:i},o,l,e,!!n)}return wV(r)},uJ="#808080",Aze={angle:0,breakAll:!1,capHeight:"0.71em",fill:uJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},EM=E.forwardRef((t,e)=>{var n=Qr(t,Aze),{x:r,y:i,lineHeight:s,capHeight:a,fill:o,scaleToFit:l,textAnchor:c,verticalAnchor:u}=n,h=_V(n,bze),g=E.useMemo(()=>Eze({breakAll:h.breakAll,children:h.children,maxLines:h.maxLines,scaleToFit:l,style:h.style,width:h.width}),[h.breakAll,h.children,h.maxLines,l,h.style,h.width]),{dx:m,dy:b,angle:y,className:v,breakAll:x}=h,M=_V(h,yze);if(!ll(r)||!ll(i)||g.length===0)return null;var w=Number(r)+(Et(m)?m:0),T=Number(i)+(Et(b)?b:0);if(!or(w)||!or(T))return null;var A;switch(u){case"start":A=uN("calc(".concat(a,")"));break;case"middle":A=uN("calc(".concat((g.length-1)/2," * -").concat(s," + (").concat(a," / 2))"));break;default:A=uN("calc(".concat(g.length-1," * -").concat(s,")"));break}var P=[];if(l){var C=g[0].width,{width:j}=h;P.push("scale(".concat(Et(j)&&Et(C)?j/C:1,")"))}return y&&P.push("rotate(".concat(y,", ").concat(w,", ").concat(T,")")),P.length&&(M.transform=P.join(" ")),E.createElement("text",_P({},Es(M),{ref:e,x:w,y:T,className:An("recharts-text",v),textAnchor:c,fill:o.includes("url")?uJ:o}),g.map((N,k)=>{var F=N.words.join(x?"":" ");return E.createElement("tspan",{x:w,dy:k===0?A:s,key:"".concat(F,"-").concat(k)},F)}))});EM.displayName="Text";var Tze=["labelRef"];function Cze(t,e){if(t==null)return{};var n,r,i=Nze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Nze(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 MV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Dr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MV(Object(n),!0).forEach(function(r){Rze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rze(t,e,n){return(e=Pze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Pze(t){var e=kze(t,"string");return typeof e=="symbol"?e:e+""}function kze(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ql(){return Ql=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Ql.apply(null,arguments)}var dJ=E.createContext(null),Dze=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a,children:o}=t,l=E.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a}),[e,n,r,i,s,a]);return E.createElement(dJ.Provider,{value:l},o)},fJ=()=>{var t=E.useContext(dJ),e=nM();return t||RY(e)},Oze=E.createContext(null),Lze=()=>{var t=E.useContext(Oze),e=Ct(nQ);return t||e},Ize=t=>{var{value:e,formatter:n}=t,r=xr(t.children)?e:t.children;return typeof n=="function"?n(r):r},aL=t=>t!=null&&typeof t=="function",jze=(t,e)=>{var n=Ci(e-t),r=Math.min(Math.abs(e-t),360);return n*r},Uze=(t,e,n,r,i)=>{var{offset:s,className:a}=t,{cx:o,cy:l,innerRadius:c,outerRadius:u,startAngle:h,endAngle:g,clockWise:m}=i,b=(c+u)/2,y=jze(h,g),v=y>=0?1:-1,x,M;switch(e){case"insideStart":x=h+v*s,M=m;break;case"insideEnd":x=g-v*s,M=!m;break;case"end":x=g+v*s,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=y<=0?M:!M;var w=qr(o,l,b,x),T=qr(o,l,b,x+(M?1:-1)*359),A="M".concat(w.x,",").concat(w.y,`
- A`).concat(b,",").concat(b,",0,1,").concat(M?0:1,`,
- `).concat(T.x,",").concat(T.y),P=xr(t.id)?M0("recharts-radial-line-"):t.id;return E.createElement("text",Ql({},r,{dominantBaseline:"central",className:An("recharts-radial-bar-label",a)}),E.createElement("defs",null,E.createElement("path",{id:P,d:A})),E.createElement("textPath",{xlinkHref:"#".concat(P)},n))},Fze=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:a,startAngle:o,endAngle:l}=t,c=(o+l)/2;if(n==="outside"){var{x:u,y:h}=qr(r,i,a+e,c);return{x:u,y:h,textAnchor:u>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(s+a)/2,{x:m,y:b}=qr(r,i,g,c);return{x:m,y:b,textAnchor:"middle",verticalAnchor:"middle"}},SP=t=>"cx"in t&&Et(t.cx),zze=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!SP(n)&&(s=n);var{x:a,y:o,upperWidth:l,lowerWidth:c,height:u}=e,h=a,g=a+(l-c)/2,m=(h+g)/2,b=(l+c)/2,y=h+l/2,v=u>=0?1:-1,x=v*r,M=v>0?"end":"start",w=v>0?"start":"end",T=l>=0?1:-1,A=T*r,P=T>0?"end":"start",C=T>0?"start":"end";if(i==="top"){var j={x:h+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return Dr(Dr({},j),s?{height:Math.max(o-s.y,0),width:l}:{})}if(i==="bottom"){var N={x:g+c/2,y:o+u+x,textAnchor:"middle",verticalAnchor:w};return Dr(Dr({},N),s?{height:Math.max(s.y+s.height-(o+u),0),width:c}:{})}if(i==="left"){var k={x:m-A,y:o+u/2,textAnchor:P,verticalAnchor:"middle"};return Dr(Dr({},k),s?{width:Math.max(k.x-s.x,0),height:u}:{})}if(i==="right"){var F={x:m+b+A,y:o+u/2,textAnchor:C,verticalAnchor:"middle"};return Dr(Dr({},F),s?{width:Math.max(s.x+s.width-F.x,0),height:u}:{})}var I=s?{width:b,height:u}:{};return i==="insideLeft"?Dr({x:m+A,y:o+u/2,textAnchor:C,verticalAnchor:"middle"},I):i==="insideRight"?Dr({x:m+b-A,y:o+u/2,textAnchor:P,verticalAnchor:"middle"},I):i==="insideTop"?Dr({x:h+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},I):i==="insideBottom"?Dr({x:g+c/2,y:o+u-x,textAnchor:"middle",verticalAnchor:M},I):i==="insideTopLeft"?Dr({x:h+A,y:o+x,textAnchor:C,verticalAnchor:w},I):i==="insideTopRight"?Dr({x:h+l-A,y:o+x,textAnchor:P,verticalAnchor:w},I):i==="insideBottomLeft"?Dr({x:g+A,y:o+u-x,textAnchor:C,verticalAnchor:M},I):i==="insideBottomRight"?Dr({x:g+c-A,y:o+u-x,textAnchor:P,verticalAnchor:M},I):i&&typeof i=="object"&&(Et(i.x)||bc(i.x))&&(Et(i.y)||bc(i.y))?Dr({x:a+cs(i.x,b),y:o+cs(i.y,u),textAnchor:"end",verticalAnchor:"end"},I):Dr({x:y,y:o+u/2,textAnchor:"middle",verticalAnchor:"middle"},I)},Bze={angle:0,offset:5,zIndex:Xr.label,position:"middle",textBreakAll:!1};function Au(t){var e=Qr(t,Bze),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:l,labelRef:c}=e,u=Lze(),h=fJ(),g=r==="center"?h:u??h,m,b,y;if(n==null?m=g:SP(n)?m=n:m=RY(n),!m||xr(i)&&xr(s)&&!E.isValidElement(a)&&typeof a!="function")return null;var v=Dr(Dr({},e),{},{viewBox:m});if(E.isValidElement(a)){var{labelRef:x}=v,M=Cze(v,Tze);return E.cloneElement(a,M)}if(typeof a=="function"){if(b=E.createElement(a,v),E.isValidElement(b))return b}else b=Ize(e);var w=Es(e);if(SP(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return Uze(e,r,b,w,m);y=Fze(m,e.offset,e.position)}else y=zze(e,m);return E.createElement(Ks,{zIndex:e.zIndex},E.createElement(EM,Ql({ref:c,className:An("recharts-label",o)},w,y,{textAnchor:Sze(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:l}),b))}Au.displayName="Label";var Hze=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?E.createElement(Au,Ql({key:"label-implicit"},r)):ll(t)?E.createElement(Au,Ql({key:"label-implicit",value:t},r)):E.isValidElement(t)?t.type===Au?E.cloneElement(t,Dr({key:"label-implicit"},r)):E.createElement(Au,Ql({key:"label-implicit",content:t},r)):aL(t)?E.createElement(Au,Ql({key:"label-implicit",content:t},r)):t&&typeof t=="object"?E.createElement(Au,Ql({},t,{key:"label-implicit"},r)):null};function $ze(t){var{label:e,labelRef:n}=t,r=fJ();return Hze(e,r,n)||null}var dN={},fN={},EV;function Vze(){return EV||(EV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(fN)),fN}var hN={},AV;function Gze(){return AV||(AV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(hN)),hN}var TV;function Wze(){return TV||(TV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Vze(),n=Gze(),r=OD();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(dN)),dN}var pN,CV;function qze(){return CV||(CV=1,pN=Wze().last),pN}var Xze=qze();const Kze=Ja(Xze);var Yze=["valueAccessor"],Zze=["dataKey","clockWise","id","textBreakAll","zIndex"];function VS(){return VS=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},VS.apply(null,arguments)}function NV(t,e){if(t==null)return{};var n,r,i=Qze(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Qze(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Jze=t=>Array.isArray(t.value)?Kze(t.value):t.value,hJ=E.createContext(void 0),pJ=hJ.Provider,mJ=E.createContext(void 0),e5e=mJ.Provider;function t5e(){return E.useContext(hJ)}function n5e(){return E.useContext(mJ)}function V_(t){var{valueAccessor:e=Jze}=t,n=NV(t,Yze),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,l=NV(n,Zze),c=t5e(),u=n5e(),h=c||u;return!h||!h.length?null:E.createElement(Ks,{zIndex:o??Xr.label},E.createElement(Ir,{className:"recharts-label-list"},h.map((g,m)=>{var b,y=xr(r)?e(g,m):Yn(g&&g.payload,r),v=xr(s)?{}:{id:"".concat(s,"-").concat(m)};return E.createElement(Au,VS({key:"label-".concat(m)},Es(g),l,v,{fill:(b=n.fill)!==null&&b!==void 0?b:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:a,viewBox:g.viewBox,index:m,zIndex:0}))})))}V_.displayName="LabelList";function oL(t){var{label:e}=t;return e?e===!0?E.createElement(V_,{key:"labelList-implicit"}):E.isValidElement(e)||aL(e)?E.createElement(V_,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(V_,VS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function wP(){return wP=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},wP.apply(null,arguments)}var gJ=t=>{var{cx:e,cy:n,r,className:i}=t,s=An("recharts-dot",i);return Et(e)&&Et(n)&&Et(r)?E.createElement("circle",wP({},Gs(t),DD(t),{className:s,cx:e,cy:n,r})):null},xJ=t=>t.graphicalItems.polarItems,r5e=Ge([hr,vv],NO),AM=Ge([xJ,br,r5e],RO),i5e=Ge([AM],PO),TM=Ge([i5e,bO],kO),s5e=Ge([TM,br,AM],OO);Ge([TM,br,AM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=Yn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Yn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var RV=()=>{},a5e=Ge([TM,br,AM,SM,hr],UO),o5e=Ge([br,IO,jO,RV,a5e,RV,Sn,hr],FO),vJ=Ge([br,Sn,TM,s5e,xv,hr,o5e],zO),l5e=Ge([vJ,br,Wm],$O);Ge([br,vJ,l5e,hr],GO);var c5e={radiusAxis:{},angleAxis:{}},bJ=Xs({name:"polarAxis",initialState:c5e,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:r9e,removeRadiusAxis:i9e,addAngleAxis:s9e,removeAngleAxis:a9e}=bJ.actions,u5e=bJ.reducer;function PV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PV(Object(n),!0).forEach(function(r){d5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function d5e(t,e,n){return(e=f5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f5e(t){var e=h5e(t,"string");return typeof e=="symbol"?e:e+""}function h5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var p5e=(t,e)=>e,lL=Ge([xJ,p5e],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),m5e=[],cL=(t,e,n)=>n?.length===0?m5e:n,yJ=Ge([bO,lL,cL],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(s=>kV(kV({},e.presentationProps),s.props))),i!=null)return i}}),g5e=Ge([yJ,lL,cL],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=Yn(r,e.nameKey,e.name),o;return n!=null&&(s=n[i])!==null&&s!==void 0&&(s=s.props)!==null&&s!==void 0&&s.fill?o=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?o=r.fill:o=e.fill,{value:Um(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),x5e=Ge([yJ,lL,cL,fi],(t,e,n,r)=>{if(!(e==null||t==null))return vBe({offset:r,pieSettings:e,displayedData:t,cells:n})}),mN={exports:{}},zn={};var DV;function v5e(){if(DV)return zn;DV=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function b(y){if(typeof y=="object"&&y!==null){var v=y.$$typeof;switch(v){case t:switch(y=y.type,y){case n:case i:case r:case l:case c:case g:return y;default:switch(y=y&&y.$$typeof,y){case a:case o:case h:case u:return y;case s:return y;default:return v}}case e:return v}}}return zn.ContextConsumer=s,zn.ContextProvider=a,zn.Element=t,zn.ForwardRef=o,zn.Fragment=n,zn.Lazy=h,zn.Memo=u,zn.Portal=e,zn.Profiler=i,zn.StrictMode=r,zn.Suspense=l,zn.SuspenseList=c,zn.isContextConsumer=function(y){return b(y)===s},zn.isContextProvider=function(y){return b(y)===a},zn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},zn.isForwardRef=function(y){return b(y)===o},zn.isFragment=function(y){return b(y)===n},zn.isLazy=function(y){return b(y)===h},zn.isMemo=function(y){return b(y)===u},zn.isPortal=function(y){return b(y)===e},zn.isProfiler=function(y){return b(y)===i},zn.isStrictMode=function(y){return b(y)===r},zn.isSuspense=function(y){return b(y)===l},zn.isSuspenseList=function(y){return b(y)===c},zn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===l||y===c||typeof y=="object"&&y!==null&&(y.$$typeof===h||y.$$typeof===u||y.$$typeof===a||y.$$typeof===s||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},zn.typeOf=b,zn}var OV;function b5e(){return OV||(OV=1,mN.exports=v5e()),mN.exports}var y5e=b5e(),LV=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",IV=null,gN=null,_J=t=>{if(t===IV&&Array.isArray(gN))return gN;var e=[];return E.Children.forEach(t,n=>{xr(n)||(y5e.isFragment(n)?e=e.concat(_J(n.props.children)):e.push(n))}),gN=e,IV=t,e};function uL(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>LV(i)):r=[LV(e)],_J(t).forEach(i=>{var s=Hf(i,"type.displayName")||Hf(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var SJ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,xN={},jV;function _5e(){return jV||(jV=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})(xN)),xN}var vN,UV;function S5e(){return UV||(UV=1,vN=_5e().isPlainObject),vN}var w5e=S5e();const M5e=Ja(w5e);function FV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FV(Object(n),!0).forEach(function(r){E5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function E5e(t,e,n){return(e=A5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function A5e(t){var e=T5e(t,"string");return typeof e=="symbol"?e:e+""}function T5e(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 GS(){return GS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},GS.apply(null,arguments)}var BV=(t,e,n,r,i)=>{var s=n-r,a;return a="M ".concat(t,",").concat(e),a+="L ".concat(t+n,",").concat(e),a+="L ".concat(t+n-s/2,",").concat(e+i),a+="L ".concat(t+n-s/2-r,",").concat(e+i),a+="L ".concat(t,",").concat(e," Z"),a},C5e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},N5e=t=>{var e=Qr(t,C5e),{x:n,y:r,upperWidth:i,lowerWidth:s,height:a,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:u,isUpdateAnimationActive:h}=e,g=E.useRef(null),[m,b]=E.useState(-1),y=E.useRef(i),v=E.useRef(s),x=E.useRef(a),M=E.useRef(n),w=E.useRef(r),T=fv(t,"trapezoid-");if(E.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var D=g.current.getTotalLength();D&&b(D)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||a!==+a||i===0&&s===0||a===0)return null;var A=An("recharts-trapezoid",o);if(!h)return E.createElement("g",null,E.createElement("path",GS({},Es(e),{className:A,d:BV(n,r,i,s,a)})));var P=y.current,C=v.current,j=x.current,N=M.current,k=w.current,F="0px ".concat(m===-1?1:m,"px"),I="".concat(m,"px 0px"),W=VY(["strokeDasharray"],c,l);return E.createElement(dv,{animationId:T,key:T,canBegin:m>0,duration:c,easing:l,isActive:h,begin:u},D=>{var $=ar(P,i,D),G=ar(C,s,D),V=ar(j,a,D),Z=ar(N,n,D),K=ar(k,r,D);g.current&&(y.current=$,v.current=G,x.current=V,M.current=Z,w.current=K);var ee=D>0?{transition:W,strokeDasharray:I}:{strokeDasharray:F};return E.createElement("path",GS({},Es(e),{className:A,d:BV(Z,K,$,G,V),ref:g,style:zV(zV({},ee),e.style)}))})},R5e=["option","shapeType","propTransformer","activeClassName"];function P5e(t,e){if(t==null)return{};var n,r,i=k5e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function k5e(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 HV(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 WS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HV(Object(n),!0).forEach(function(r){D5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function D5e(t,e,n){return(e=O5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O5e(t){var e=L5e(t,"string");return typeof e=="symbol"?e:e+""}function L5e(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 I5e(t,e){return WS(WS({},e),t)}function j5e(t,e){return t==="symbols"}function $V(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return E.createElement(XY,n);case"trapezoid":return E.createElement(N5e,n);case"sector":return E.createElement(QY,n);case"symbols":if(j5e(e))return E.createElement(kD,n);break;case"curve":return E.createElement(Vp,n);default:return null}}function U5e(t){return E.isValidElement(t)?t.props:t}function wJ(t){var{option:e,shapeType:n,propTransformer:r=I5e,activeClassName:i="recharts-active-shape"}=t,s=P5e(t,R5e),a;if(E.isValidElement(e))a=E.cloneElement(e,WS(WS({},s),U5e(e)));else if(typeof e=="function")a=e(s,s.index);else if(M5e(e)&&typeof e!="boolean"){var o=r(e,s);a=E.createElement($V,{shapeType:n,elementProps:o})}else{var l=s;a=E.createElement($V,{shapeType:n,elementProps:l})}return s.isActive?E.createElement(Ir,{className:i},a):a}var dL=(t,e,n)=>{var r=er();return(i,s)=>a=>{t?.(i,s,a),r(DQ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},fL=t=>{var e=er();return(n,r)=>i=>{t?.(n,r,i),e(Z4e())}},hL=(t,e,n)=>{var r=er();return(i,s)=>a=>{t?.(i,s,a),r(Q4e({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function pL(t){var{tooltipEntrySettings:e}=t,n=er(),r=fs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(q4e(e)):i.current!==e&&n(X4e({prev:i.current,next:e})),i.current=e)},[e,n,r]),E.useLayoutEffect(()=>()=>{i.current&&(n(K4e(i.current)),i.current=null)},[n]),null}function MJ(t){var{legendPayload:e}=t,n=er(),r=fs(),i=E.useRef(null);return E.useLayoutEffect(()=>{r||(i.current===null?n(FY(e)):i.current!==e&&n(zY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(BY(i.current)),i.current=null)},[n]),null}function F5e(t){var{legendPayload:e}=t,n=er(),r=Ct(Sn),i=E.useRef(null);return E.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(FY(e)):i.current!==e&&n(zY({prev:i.current,next:e})),i.current=e)},[n,r,e]),E.useLayoutEffect(()=>()=>{i.current&&(n(BY(i.current)),i.current=null)},[n]),null}var bN,z5e=()=>{var[t]=E.useState(()=>M0("uid-"));return t},B5e=(bN=wne.useId)!==null&&bN!==void 0?bN:z5e;function EJ(t,e){var n=B5e();return e||(t?"".concat(t,"-").concat(n):n)}var H5e=E.createContext(void 0),mL=t=>{var{id:e,type:n,children:r}=t,i=EJ("recharts-".concat(n),e);return E.createElement(H5e.Provider,{value:i},r(i))},$5e={cartesianItems:[],polarItems:[]},AJ=Xs({name:"graphicalItems",initialState:$5e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:cr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=wo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:cr()},removeCartesianGraphicalItem:{reducer(t,e){var n=wo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:cr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:cr()},removePolarGraphicalItem:{reducer(t,e){var n=wo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:cr()}}}),{addCartesianGraphicalItem:V5e,replaceCartesianGraphicalItem:G5e,removeCartesianGraphicalItem:W5e,addPolarGraphicalItem:q5e,removePolarGraphicalItem:X5e}=AJ.actions,K5e=AJ.reducer,Y5e=t=>{var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(V5e(t)):n.current!==t&&e(G5e({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(W5e(n.current)),n.current=null)},[e]),null},TJ=E.memo(Y5e);function Z5e(t){var e=er();return E.useLayoutEffect(()=>(e(q5e(t)),()=>{e(X5e(t))}),[e,t]),null}var Q5e=["key"],J5e=["onMouseEnter","onClick","onMouseLeave"],eBe=["id"],tBe=["id"];function VV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Er(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VV(Object(n),!0).forEach(function(r){nBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nBe(t,e,n){return(e=rBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rBe(t){var e=iBe(t,"string");return typeof e=="symbol"?e:e+""}function iBe(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 od(){return od=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},od.apply(null,arguments)}function CM(t,e){if(t==null)return{};var n,r,i=sBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function sBe(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 aBe(t){var e=E.useMemo(()=>uL(t.children,Tv),[t.children]),n=Ct(r=>g5e(r,t.id,e));return n==null?null:E.createElement(F5e,{legendPayload:n})}var oBe=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:a,name:o,hide:l,tooltipType:c}=t,u={dataDefinedOnItem:r.map(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:a,dataKey:e,nameKey:n,name:Um(o,e),hide:l,type:c,color:a,unit:""}};return E.createElement(pL,{tooltipEntrySettings:u})}),lBe=(t,e)=>t>e?"start":t<e?"end":"middle",cBe=(t,e,n)=>cs(typeof e=="function"?e(t):e,n,n*.8),uBe=(t,e,n)=>{var{top:r,left:i,width:s,height:a}=e,o=KY(s,a),l=i+cs(t.cx,s,s/2),c=r+cs(t.cy,a,a/2),u=cs(t.innerRadius,o,0),h=cBe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(s*s+a*a)/2;return{cx:l,cy:c,innerRadius:u,outerRadius:h,maxRadius:g}},dBe=(t,e)=>{var n=Ci(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function fBe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var hBe=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=An("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=CM(e,Q5e);return E.createElement(Vp,od({},i,{type:"linear",className:n}))},pBe=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),E.isValidElement(r)))return r;var i=An("recharts-pie-label-text",fBe(t));return E.createElement(EM,od({},e,{alignmentBaseline:"middle",className:i}),r)};function mBe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:a}=n;if(!r||!i||!e)return null;var o=Gs(n),l=Bf(i),c=Bf(s),u=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((g,m)=>{var b=(g.startAngle+g.endAngle)/2,y=qr(g.cx,g.cy,g.outerRadius+u,b),v=Er(Er(Er(Er({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:lBe(y.x,g.cx)},y),x=Er(Er(Er(Er({},o),g),{},{fill:"none",stroke:g.fill},c),{},{index:m,points:[qr(g.cx,g.cy,g.outerRadius,b),y],key:"line"});return E.createElement(Ks,{zIndex:Xr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},E.createElement(Ir,null,s&&hBe(s,x),pBe(i,v,Yn(g,a))))});return E.createElement(Ir,{className:"recharts-pie-labels"},h)}function gBe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?E.createElement(oL,{label:i}):E.createElement(mBe,{sectors:e,props:n,showLabels:r})}function xBe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=Ct(ad),l=Ct(eL),c=Ct(jUe),{onMouseEnter:u,onClick:h,onMouseLeave:g}=i,m=CM(i,J5e),b=dL(u,i.dataKey,a),y=fL(g),v=hL(h,i.dataKey,a);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var w=c==null||c===a,T=String(M)===o&&(l==null||i.dataKey===l)&&w,A=o?r:null,P=n&&T?n:A,C=Er(Er({},x),{},{stroke:x.stroke,tabIndex:-1,[EY]:M,[AY]:i.dataKey});return E.createElement(Ir,od({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},sv(m,x,M),{onMouseEnter:b(x,M),onMouseLeave:y(x,M),onClick:v(x,M)}),E.createElement(wJ,od({option:s??P,index:M,shapeType:"sector",isActive:T},C)))}))}function vBe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:a,startAngle:o,endAngle:l,dataKey:c,nameKey:u,tooltipType:h}=n,g=Math.abs(n.minAngle),m=dBe(o,l),b=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(P=>Yn(P,c,0)!==0).length,x=(b>=360?v:v-1)*y,M=b-v*g-x,w=r.reduce((P,C)=>{var j=Yn(C,c,0);return P+(Et(j)?j:0)},0),T;if(w>0){var A;T=r.map((P,C)=>{var j=Yn(P,c,0),N=Yn(P,u,C),k=uBe(n,s,P),F=(Et(j)?j:0)/w,I,W=Er(Er({},P),i&&i[C]&&i[C].props);C?I=A.endAngle+Ci(m)*y*(j!==0?1:0):I=o;var D=I+Ci(m)*((j!==0?g:0)+F*M),$=(I+D)/2,G=(k.innerRadius+k.outerRadius)/2,V=[{name:N,value:j,payload:W,dataKey:c,type:h}],Z=qr(k.cx,k.cy,G,$);return A=Er(Er(Er(Er({},n.presentationProps),{},{percent:F,cornerRadius:typeof a=="string"?parseFloat(a):a,name:N,tooltipPayload:V,midAngle:$,middleRadius:G,tooltipPosition:Z},W),k),{},{value:j,dataKey:c,startAngle:I,endAngle:D,payload:W,paddingAngle:Ci(m)*y}),A})}return T}function bBe(t){var{showLabels:e,sectors:n,children:r}=t,i=E.useMemo(()=>!e||!n?[]:n.map(s=>({value:s.value,payload:s.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:s.cx,cy:s.cy,innerRadius:s.innerRadius,outerRadius:s.outerRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockWise:!1},fill:s.fill})),[n,e]);return E.createElement(e5e,{value:e?i:void 0},r)}function yBe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:u,onAnimationStart:h,onAnimationEnd:g}=e,m=fv(e,"recharts-pie-"),b=n.current,[y,v]=E.useState(!1),x=E.useCallback(()=>{typeof g=="function"&&g(),v(!1)},[g]),M=E.useCallback(()=>{typeof h=="function"&&h(),v(!0)},[h]);return E.createElement(bBe,{showLabels:!y,sectors:i},E.createElement(dv,{animationId:m,begin:a,duration:o,isActive:s,easing:l,onAnimationStart:M,onAnimationEnd:x,key:m},w=>{var T=[],A=i&&i[0],P=A?.startAngle;return i?.forEach((C,j)=>{var N=b&&b[j],k=j>0?Hf(C,"paddingAngle",0):0;if(N){var F=ar(N.endAngle-N.startAngle,C.endAngle-C.startAngle,w),I=Er(Er({},C),{},{startAngle:P+k,endAngle:P+F+k});T.push(I),P=I.endAngle}else{var{endAngle:W,startAngle:D}=C,$=ar(0,W-D,w),G=Er(Er({},C),{},{startAngle:P+k,endAngle:P+$+k});T.push(G),P=G.endAngle}}),n.current=T,E.createElement(Ir,null,E.createElement(xBe,{sectors:T,activeShape:c,inactiveShape:u,allOtherPieProps:e,shape:e.shape,id:r}))}),E.createElement(gBe,{showLabels:!y,sectors:i,props:e}),e.children)}var _Be={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Xr.area};function SBe(t){var{id:e}=t,n=CM(t,eBe),{hide:r,className:i,rootTabIndex:s}=t,a=E.useMemo(()=>uL(t.children,Tv),[t.children]),o=Ct(u=>x5e(u,e,a)),l=E.useRef(null),c=An("recharts-pie",i);return r||o==null?(l.current=null,E.createElement(Ir,{tabIndex:s,className:c})):E.createElement(Ks,{zIndex:t.zIndex},E.createElement(oBe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),E.createElement(Ir,{tabIndex:s,className:c},E.createElement(yBe,{props:Er(Er({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function CJ(t){var e=Qr(t,_Be),{id:n}=e,r=CM(e,tBe),i=Gs(r);return E.createElement(mL,{id:n,type:"pie"},s=>E.createElement(E.Fragment,null,E.createElement(Z5e,{type:"pie",id:s,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),E.createElement(aBe,od({},r,{id:s})),E.createElement(SBe,od({},r,{id:s}))))}CJ.displayName="Pie";var wBe=["points"];function GV(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 yN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GV(Object(n),!0).forEach(function(r){MBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MBe(t,e,n){return(e=EBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EBe(t){var e=ABe(t,"string");return typeof e=="symbol"?e:e+""}function ABe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qS(){return qS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},qS.apply(null,arguments)}function TBe(t,e){if(t==null)return{};var n,r,i=CBe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function CBe(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 NBe(t){var{option:e,dotProps:n,className:r}=t;if(E.isValidElement(e))return E.cloneElement(e,n);if(typeof e=="function")return e(n);var i=An(r,typeof e!="boolean"?e.className:""),s=n??{},{points:a}=s,o=TBe(s,wBe);return E.createElement(gJ,qS({},o,{className:i}))}function RBe(t,e){return t==null?!1:e?!0:t.length===1}function PBe(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:a,needClip:o,clipPathId:l,zIndex:c=Xr.scatter}=t;if(!RBe(e,n))return null;var u=SJ(n),h=o3e(n),g=e.map((b,y)=>{var v,x,M=yN(yN(yN({r:3},a),h),{},{index:y,cx:(v=b.x)!==null&&v!==void 0?v:void 0,cy:(x=b.y)!==null&&x!==void 0?x:void 0,dataKey:s,value:b.value,payload:b.payload,points:e});return E.createElement(NBe,{key:"dot-".concat(y),option:n,dotProps:M,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(u?"":"dots-").concat(l,")")),E.createElement(Ks,{zIndex:c},E.createElement(Ir,qS({className:r},m),g))}function WV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function qV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WV(Object(n),!0).forEach(function(r){kBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kBe(t,e,n){return(e=DBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DBe(t){var e=OBe(t,"string");return typeof e=="symbol"?e:e+""}function OBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var LBe={xAxis:{},yAxis:{},zAxis:{}},NJ=Xs({name:"cartesianAxis",initialState:LBe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:cr()},replaceXAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.xAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.xAxis[n.id],t.xAxis[r.id]=r)},prepare:cr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:cr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:cr()},replaceYAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.yAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.yAxis[n.id],t.yAxis[r.id]=r)},prepare:cr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:cr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:cr()},replaceZAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.zAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.zAxis[n.id],t.zAxis[r.id]=r)},prepare:cr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:cr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var s=i.widthHistory||[];if(s.length===3&&s[0]===s[2]&&r===s[1]&&r!==i.width&&Math.abs(r-s[0])<=1)return;var a=[...s,r].slice(-3);t.yAxis[n]=qV(qV({},t.yAxis[n]),{},{width:r,widthHistory:a})}}}}),{addXAxis:IBe,replaceXAxis:jBe,removeXAxis:UBe,addYAxis:FBe,replaceYAxis:zBe,removeYAxis:BBe,addZAxis:o9e,replaceZAxis:l9e,removeZAxis:c9e,updateYAxisWidth:HBe}=NJ.actions,$Be=NJ.reducer,VBe=Ge([fi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),GBe=Ge([VBe,Cc,Nc],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),gL=()=>Ct(GBe),WBe=()=>Ct(HUe);function XV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _N(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XV(Object(n),!0).forEach(function(r){qBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qBe(t,e,n){return(e=XBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XBe(t){var e=KBe(t,"string");return typeof e=="symbol"?e:e+""}function KBe(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 YBe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:s,clipPath:a}=t;if(i===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:s,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},l=_N(_N(_N({},o),Bf(i)),DD(i)),c;return E.isValidElement(i)?c=E.cloneElement(i,l):typeof i=="function"?c=i(l):c=E.createElement(gJ,l),E.createElement(Ir,{className:"recharts-active-dot",clipPath:a},c)};function KV(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:a=Xr.activeDot}=t,o=Ct(ad),l=WBe();if(e==null||l==null)return null;var c=e.find(u=>l.includes(u.payload));return xr(c)?null:E.createElement(Ks,{zIndex:a},E.createElement(YBe,{point:c,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var ZBe="Invariant failed";function QBe(t,e){throw new Error(ZBe)}var JBe=["x","y"];function MP(){return MP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},MP.apply(null,arguments)}function YV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function dx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YV(Object(n),!0).forEach(function(r){e6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function e6e(t,e,n){return(e=t6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t6e(t){var e=n6e(t,"string");return typeof e=="symbol"?e:e+""}function n6e(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 r6e(t,e){if(t==null)return{};var n,r,i=i6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function i6e(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 s6e(t,e){var{x:n,y:r}=t,i=r6e(t,JBe),s="".concat(n),a=parseInt(s,10),o="".concat(r),l=parseInt(o,10),c="".concat(e.height||i.height),u=parseInt(c,10),h="".concat(e.width||i.width),g=parseInt(h,10);return dx(dx(dx(dx(dx({},e),i),a?{x:a}:{}),l?{y:l}:{}),{},{height:u,width:g,name:e.name,radius:e.radius})}function XS(t){return E.createElement(wJ,MP({shapeType:"rectangle",propTransformer:s6e,activeClassName:"recharts-active-bar"},t))}var a6e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Et(e))return e;var s=Et(r)||xr(r);return s?e(r,i):(s||QBe(),n)}},o6e={},RJ=Xs({name:"errorBars",initialState:o6e,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(s=>s.dataKey===r.dataKey&&s.direction===r.direction?i:s))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:u9e,replaceErrorBar:d9e,removeErrorBar:f9e}=RJ.actions,l6e=RJ.reducer,c6e=["children"];function u6e(t,e){if(t==null)return{};var n,r,i=d6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function d6e(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 f6e={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},h6e=E.createContext(f6e);function p6e(t){var{children:e}=t,n=u6e(t,c6e);return E.createElement(h6e.Provider,{value:n},e)}function xL(t,e){var n,r,i=Ct(c=>Pc(c,t)),s=Ct(c=>kc(c,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:wi.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Mi.allowDataOverflow,l=a||o;return{needClip:l,needClipX:a,needClipY:o}}function PJ(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=gL(),{needClipX:s,needClipY:a,needClip:o}=xL(e,n);if(!o||!i)return null;var{x:l,y:c,width:u,height:h}=i;return E.createElement("clipPath",{id:"clipPath-".concat(r)},E.createElement("rect",{x:s?l:l-u/2,y:a?c:c-h/2,width:s?u:u*2,height:a?h:h*2}))}function m6e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&or(t.zIndex)?t.zIndex:e}var SN={exports:{}},wN={};var ZV;function g6e(){if(ZV)return wN;ZV=1;var t=Mm();function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,o=t.useDebugValue;return wN.useSyncExternalStoreWithSelector=function(l,c,u,h,g){var m=i(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=a(function(){function v(A){if(!x){if(x=!0,M=A,A=h(A),g!==void 0&&b.hasValue){var P=b.value;if(g(P,A))return w=P}return w=A}if(P=w,n(M,A))return P;var C=h(A);return g!==void 0&&g(P,C)?(M=A,P):(M=A,w=C)}var x=!1,M,w,T=u===void 0?null:u;return[function(){return v(c())},T===null?void 0:function(){return v(T())}]},[c,u,h,g]);var y=r(l,m[0],m[1]);return s(function(){b.hasValue=!0,b.value=y},[y]),o(y),y},wN}var QV;function x6e(){return QV||(QV=1,SN.exports=g6e()),SN.exports}x6e();function v6e(t){t()}function b6e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){v6e(()=>{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 JV={notify(){},get:()=>[]};function y6e(t,e){let n,r=JV,i=0,s=!1;function a(y){u();const v=r.subscribe(y);let x=!1;return()=>{x||(x=!0,v(),h())}}function o(){r.notify()}function l(){b.onStateChange&&b.onStateChange()}function c(){return s}function u(){i++,n||(n=t.subscribe(l),r=b6e())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=JV)}function g(){s||(s=!0,u())}function m(){s&&(s=!1,h())}const b={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return b}var _6e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",S6e=_6e(),w6e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",M6e=w6e(),E6e=()=>S6e||M6e?E.useLayoutEffect:E.useEffect,A6e=E6e();function eG(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function T6e(t,e){if(eG(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])||!eG(t[n[i]],e[n[i]]))return!1;return!0}var C6e=Symbol.for("react-redux-context"),N6e=typeof globalThis<"u"?globalThis:{};function R6e(){if(!E.createContext)return{};const t=N6e[C6e]??=new Map;let e=t.get(E.createContext);return e||(e=E.createContext(null),t.set(E.createContext,e)),e}var P6e=R6e();function k6e(t){const{children:e,context:n,serverState:r,store:i}=t,s=E.useMemo(()=>{const l=y6e(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),a=E.useMemo(()=>i.getState(),[i]);A6e(()=>{const{subscription:l}=s;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),a!==i.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[s,a]);const o=n||P6e;return E.createElement(o.Provider,{value:s},e)}var D6e=k6e,O6e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function L6e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function NM(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(O6e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!T6e(t[r],e[r]))return!1}else if(!L6e(t[r],e[r]))return!1;return!0}var I6e=["onMouseEnter","onMouseLeave","onClick"],j6e=["value","background","tooltipPosition"],U6e=["id"],F6e=["onMouseEnter","onClick","onMouseLeave"];function Ec(){return Ec=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},Ec.apply(null,arguments)}function tG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tG(Object(n),!0).forEach(function(r){z6e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function z6e(t,e,n){return(e=B6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B6e(t){var e=H6e(t,"string");return typeof e=="symbol"?e:e+""}function H6e(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 KS(t,e){if(t==null)return{};var n,r,i=$6e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function $6e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var V6e=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Um(n,e),payload:t}]},G6e=E.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:a,unit:o,tooltipType:l}=t,c={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Um(s,e),hide:a,type:l,color:i,unit:o}};return E.createElement(pL,{tooltipEntrySettings:c})});function W6e(t){var e=Ct(ad),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:l}=s,c=KS(s,I6e),u=dL(a,r),h=fL(o),g=hL(l,r);if(!i||n==null)return null;var m=Bf(i);return E.createElement(Ks,{zIndex:m6e(i,Xr.barBackground)},n.map((b,y)=>{var{value:v,background:x,tooltipPosition:M}=b,w=KS(b,j6e);if(!x)return null;var T=u(b,y),A=h(b,y),P=g(b,y),C=vs(vs(vs(vs(vs({option:i,isActive:String(y)===e},w),{},{fill:"#eee"},x),m),sv(c,b,y)),{},{onMouseEnter:T,onMouseLeave:A,onClick:P,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return E.createElement(XS,Ec({key:"background-bar-".concat(y)},C))}))}function q6e(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(s=>{var a={x:s.x,y:s.y,width:s.width,lowerWidth:s.width,upperWidth:s.width,height:s.height};return vs(vs({},a),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:a,fill:s.fill})});return E.createElement(pJ,{value:e?i:void 0},n)}function X6e(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=Ct(ad),l=Ct(eL),c=n&&String(s)===o&&(l==null||a===l),u=c?n:e;return c?E.createElement(Ks,{zIndex:Xr.activeBar},E.createElement(XS,Ec({},r,{name:String(r.name)},i,{isActive:c,option:u,index:s,dataKey:a}))):E.createElement(XS,Ec({},r,{name:String(r.name)},i,{isActive:c,option:u,index:s,dataKey:a}))}function K6e(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return E.createElement(XS,Ec({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function Y6e(t){var e,{data:n,props:r}=t,i=(e=Gs(r))!==null&&e!==void 0?e:{},{id:s}=i,a=KS(i,U6e),{shape:o,dataKey:l,activeBar:c}=r,{onMouseEnter:u,onClick:h,onMouseLeave:g}=r,m=KS(r,F6e),b=dL(u,l),y=fL(g),v=hL(h,l);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(Ir,Ec({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},sv(m,x,M),{onMouseEnter:b(x,M),onMouseLeave:y(x,M),onClick:v(x,M)}),c?E.createElement(X6e,{shape:o,activeBar:c,baseProps:a,entry:x,index:M,dataKey:l}):E.createElement(K6e,{shape:o,baseProps:a,entry:x,index:M,dataKey:l})))):null}function Z6e(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:u}=e,h=n.current,g=fv(e,"recharts-bar-"),[m,b]=E.useState(!1),y=!m,v=E.useCallback(()=>{typeof c=="function"&&c(),b(!1)},[c]),x=E.useCallback(()=>{typeof u=="function"&&u(),b(!0)},[u]);return E.createElement(q6e,{showLabels:y,rects:r},E.createElement(dv,{animationId:g,begin:a,duration:o,isActive:s,easing:l,onAnimationEnd:v,onAnimationStart:x,key:g},M=>{var w=M===1?r:r?.map((T,A)=>{var P=h&&h[A];if(P)return vs(vs({},T),{},{x:ar(P.x,T.x,M),y:ar(P.y,T.y,M),width:ar(P.width,T.width,M),height:ar(P.height,T.height,M)});if(i==="horizontal"){var C=ar(0,T.height,M),j=ar(T.stackedBarStart,T.y,M);return vs(vs({},T),{},{y:j,height:C})}var N=ar(0,T.width,M),k=ar(T.stackedBarStart,T.x,M);return vs(vs({},T),{},{width:N,x:k})});return M>0&&(n.current=w??null),w==null?null:E.createElement(Ir,null,E.createElement(Y6e,{props:e,data:w}))}),E.createElement(oL,{label:e.label}),e.children)}function Q6e(t){var e=E.useRef(null);return E.createElement(Z6e,{previousRectanglesRef:e,props:t})}var kJ=0,J6e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Yn(t,e)}};class e8e extends E.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:a,needClip:o,background:l,id:c}=this.props;if(e||n==null)return null;var u=An("recharts-bar",i),h=c;return E.createElement(Ir,{className:u,id:c},o&&E.createElement("defs",null,E.createElement(PJ,{clipPathId:h,xAxisId:s,yAxisId:a})),E.createElement(Ir,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(h,")"):void 0},E.createElement(W6e,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),E.createElement(Q6e,this.props)))}}var t8e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:kJ,xAxisId:0,yAxisId:0,zIndex:Xr.bar};function n8e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u}=t,{needClip:h}=xL(e,n),g=Fm(),m=fs(),b=uL(t.children,Tv),y=Ct(M=>R8e(M,e,n,m,t.id,b));if(g!=="vertical"&&g!=="horizontal")return null;var v,x=y?.[0];return x==null||x.height==null||x.width==null?v=0:v=g==="vertical"?x.height/2:x.width/2,E.createElement(p6e,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:J6e,errorBarOffset:v},E.createElement(e8e,Ec({},t,{layout:g,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u})))}function r8e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:a,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:u,displayedData:h,offset:g,cells:m,parentViewBox:b,dataStartIndex:y}=t,v=e==="horizontal"?o:a,x=u?v.scale.domain():null,M=Ske({numericAxis:v}),w=v.scale(M);return h.map((T,A)=>{var P,C,j,N,k,F;u?P=xke(u[A+y],x):(P=Yn(T,n),Array.isArray(P)||(P=[M,P]));var I=a6e(r,kJ)(P[1],A);if(e==="horizontal"){var W,[D,$]=[o.scale(P[0]),o.scale(P[1])];C=xH({axis:a,ticks:l,bandSize:s,offset:i.offset,entry:T,index:A}),j=(W=$??D)!==null&&W!==void 0?W:void 0,N=i.size;var G=D-$;if(k=Ya(G)?0:G,F={x:C,y:g.top,width:N,height:g.height},Math.abs(I)>0&&Math.abs(k)<Math.abs(I)){var V=Ci(k||I)*(Math.abs(I)-Math.abs(k));j-=V,k+=V}}else{var[Z,K]=[a.scale(P[0]),a.scale(P[1])];if(C=Z,j=xH({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:T,index:A}),N=K-Z,k=i.size,F={x:g.left,y:j,width:g.width,height:k},Math.abs(I)>0&&Math.abs(N)<Math.abs(I)){var ee=Ci(N||I)*(Math.abs(I)-Math.abs(N));N+=ee}}if(C==null||j==null||N==null||k==null)return null;var H=vs(vs({},T),{},{stackedBarStart:w,x:C,y:j,width:N,height:k,value:u?P:P[1],payload:T,background:F,tooltipPosition:{x:C+N/2,y:j+k/2},parentViewBox:b},m&&m[A]&&m[A].props);return H}).filter(Boolean)}function i8e(t){var e=Qr(t,t8e),n=fs();return E.createElement(mL,{id:e.id,type:"bar"},r=>E.createElement(E.Fragment,null,E.createElement(MJ,{legendPayload:V6e(e)}),E.createElement(G6e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(TJ,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:wY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(Ks,{zIndex:e.zIndex},E.createElement(n8e,Ec({},e,{id:r})))))}var DJ=E.memo(i8e,NM);DJ.displayName="Bar";function nG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nG(Object(n),!0).forEach(function(r){s8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function s8e(t,e,n){return(e=a8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a8e(t){var e=o8e(t,"string");return typeof e=="symbol"?e:e+""}function o8e(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 l8e=(t,e)=>e,c8e=(t,e,n)=>n,u8e=(t,e,n,r)=>r,d8e=(t,e,n,r,i)=>i,Cv=Ge([yM,d8e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),f8e=Ge([Cv],t=>t?.maxBarSize),h8e=(t,e,n,r,i,s)=>s,rG=(t,e,n)=>{var r=n??t;if(!xr(r))return cs(r,e,0)},p8e=Ge([Sn,yM,l8e,c8e,u8e],(t,e,n,r,i)=>e.filter(s=>t==="horizontal"?s.xAxisId===n:s.yAxisId===r).filter(s=>s.isPanorama===i).filter(s=>s.hide===!1).filter(s=>s.type==="bar")),m8e=(t,e,n,r)=>{var i=Sn(t);return i==="horizontal"?j0(t,"yAxis",n,r):j0(t,"xAxis",e,r)},g8e=(t,e,n)=>{var r=Sn(t);return r==="horizontal"?Y$(t,"xAxis",e):Y$(t,"yAxis",n)},x8e=(t,e,n)=>{var r={},i=t.filter(xM),s=t.filter(c=>c.stackId==null),a=i.reduce((c,u)=>(c[u.stackId]||(c[u.stackId]=[]),c[u.stackId].push(u),c),r),o=Object.entries(a).map(c=>{var[u,h]=c,g=h.map(b=>b.dataKey),m=rG(e,n,h[0].barSize);return{stackId:u,dataKeys:g,barSize:m}}),l=s.map(c=>{var u=[c.dataKey].filter(g=>g!=null),h=rG(e,n,c.barSize);return{stackId:void 0,dataKeys:u,barSize:h}});return[...o,...l]},v8e=Ge([p8e,Fje,g8e],x8e),b8e=(t,e,n,r,i)=>{var s,a,o=Cv(t,e,n,r,i);if(o!=null){var l=Sn(t),c=XZ(t),{maxBarSize:u}=o,h=xr(u)?c:u,g,m;return l==="horizontal"?(g=sd(t,"xAxis",e,r),m=id(t,"xAxis",e,r)):(g=sd(t,"yAxis",n,r),m=id(t,"yAxis",n,r)),(s=(a=vm(g,m,!0))!==null&&a!==void 0?a:h)!==null&&s!==void 0?s:0}},OJ=(t,e,n,r)=>{var i=Sn(t),s,a;return i==="horizontal"?(s=sd(t,"xAxis",e,r),a=id(t,"xAxis",e,r)):(s=sd(t,"yAxis",n,r),a=id(t,"yAxis",n,r)),vm(s,a)};function y8e(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=cs(t,n,0,!0),o,l=[];if(or(r[0].barSize)){var c=!1,u=n/s,h=r.reduce((x,M)=>x+(M.barSize||0),0);h+=(s-1)*a,h>=n&&(h-=(s-1)*a,a=0),h>=n&&u>0&&(c=!0,u*=.9,h=s*u);var g=(n-h)/2>>0,m={offset:g-a,size:0};o=r.reduce((x,M)=>{var w,T={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+a,size:c?u:(w=M.barSize)!==null&&w!==void 0?w:0}},A=[...x,T];return m=A[A.length-1].position,A},l)}else{var b=cs(e,n,0,!0);n-2*b-(s-1)*a<=0&&(a=0);var y=(n-2*b-(s-1)*a)/s;y>1&&(y>>=0);var v=or(i)?Math.min(y,i):y;o=r.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:b+(y+a)*w+(y-v)/2,size:v}}],l)}return o}}var _8e=(t,e,n,r,i,s,a)=>{var o=xr(a)?e:a,l=y8e(n,r,i!==s?i:s,t,o);return i!==s&&l!=null&&(l=l.map(c=>g_(g_({},c),{},{position:g_(g_({},c.position),{},{offset:c.position.offset-i/2})}))),l},S8e=Ge([v8e,XZ,Uje,KZ,b8e,OJ,f8e],_8e),w8e=(t,e,n,r)=>sd(t,"xAxis",e,r),M8e=(t,e,n,r)=>sd(t,"yAxis",n,r),E8e=(t,e,n,r)=>id(t,"xAxis",e,r),A8e=(t,e,n,r)=>id(t,"yAxis",n,r),T8e=Ge([S8e,Cv],(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}}),C8e=(t,e)=>{var n=gM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(a=>a.key===n)}}}},N8e=Ge([m8e,Cv],C8e),R8e=Ge([fi,VD,w8e,M8e,E8e,A8e,T8e,Sn,hM,OJ,N8e,Cv,h8e],(t,e,n,r,i,s,a,o,l,c,u,h,g)=>{var{chartData:m,dataStartIndex:b,dataEndIndex:y}=l;if(!(h==null||a==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||s==null||c==null)){var{data:v}=h,x;if(v!=null&&v.length>0?x=v:x=m?.slice(b,y+1),x!=null)return r8e({layout:o,barSettings:h,pos:a,parentViewBox:e,bandSize:c,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:u,displayedData:x,offset:t,cells:g,dataStartIndex:b})}}),LJ=t=>{var{chartData:e}=t,n=er(),r=fs();return E.useEffect(()=>r?()=>{}:(n(cV(e)),()=>{n(cV(void 0))}),[e,n,r]),null},iG={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},IJ=Xs({name:"brush",initialState:iG,reducers:{setBrushSettings(t,e){return e.payload==null?iG:e.payload}}}),{setBrushSettings:h9e}=IJ.actions,P8e=IJ.reducer;function k8e(t,e,n){return(e=D8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D8e(t){var e=O8e(t,"string");return typeof e=="symbol"?e:e+""}function O8e(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 vL{static create(e){return new vL(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var s=this.bandwidth?this.bandwidth():0;return this.scale(e)+s}default:return this.scale(e)}if(n){var a=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+a}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}k8e(vL,"EPS",1e-4);function L8e(t){return(t%180+180)%180}var I8e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=L8e(i),a=s*Math.PI/180,o=Math.atan(r/n),l=a>o&&a<Math.PI-o?r/Math.sin(a):n/Math.cos(a);return Math.abs(l)},j8e={dots:[],areas:[],lines:[]},jJ=Xs({name:"referenceElements",initialState:j8e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=wo(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=wo(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=wo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:p9e,removeDot:m9e,addArea:g9e,removeArea:x9e,addLine:v9e,removeLine:b9e}=jJ.actions,U8e=jJ.reducer,F8e=E.createContext(void 0),z8e=t=>{var{children:e}=t,[n]=E.useState("".concat(M0("recharts"),"-clip")),r=gL();if(r==null)return null;var{x:i,y:s,width:a,height:o}=r;return E.createElement(F8e.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:i,y:s,height:o,width:a}))),e)};function UJ(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 B8e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return I8e(r,n)}function H8e(t,e,n){var r=n==="width",{x:i,y:s,width:a,height:o}=t;return e===1?{start:r?i:s,end:r?i+a:s+o}:{start:r?i+a:s+o,end:r?i:s}}function YS(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var s=n();return t*(e-t*s/2-r)>=0&&t*(e+t*s/2-i)<=0}function $8e(t,e){return UJ(t,e+1)}function V8e(t,e,n,r,i){for(var s=(r||[]).slice(),{start:a,end:o}=e,l=0,c=1,u=a,h=function(){var b=r?.[l];if(b===void 0)return{v:UJ(r,c)};var y=l,v,x=()=>(v===void 0&&(v=n(b,y)),v),M=b.coordinate,w=l===0||YS(t,M,x,u,o);w||(l=0,u=a,c+=1),w&&(u=M+t*(x()/2+i),l+=c)},g;c<=s.length;)if(g=h(),g)return g.v;return[]}function sG(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 is(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sG(Object(n),!0).forEach(function(r){G8e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function G8e(t,e,n){return(e=W8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W8e(t){var e=q8e(t,"string");return typeof e=="symbol"?e:e+""}function q8e(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 X8e(t,e,n,r,i){for(var s=(r||[]).slice(),a=s.length,{start:o}=e,{end:l}=e,c=function(g){var m=s[g],b,y=()=>(b===void 0&&(b=n(m,g)),b);if(g===a-1){var v=t*(m.coordinate+t*y()/2-l);s[g]=m=is(is({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else s[g]=m=is(is({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=YS(t,m.tickCoord,y,o,l);x&&(l=m.tickCoord-t*(y()/2+i),s[g]=is(is({},m),{},{isShow:!0}))}},u=a-1;u>=0;u--)c(u);return s}function K8e(t,e,n,r,i,s){var a=(r||[]).slice(),o=a.length,{start:l,end:c}=e;if(s){var u=r[o-1],h=n(u,o-1),g=t*(u.coordinate+t*h/2-c);if(a[o-1]=u=is(is({},u),{},{tickCoord:g>0?u.coordinate-g*t:u.coordinate}),u.tickCoord!=null){var m=YS(t,u.tickCoord,()=>h,l,c);m&&(c=u.tickCoord-t*(h/2+i),a[o-1]=is(is({},u),{},{isShow:!0}))}}for(var b=s?o-1:o,y=function(M){var w=a[M],T,A=()=>(T===void 0&&(T=n(w,M)),T);if(M===0){var P=t*(w.coordinate-t*A()/2-l);a[M]=w=is(is({},w),{},{tickCoord:P<0?w.coordinate-P*t:w.coordinate})}else a[M]=w=is(is({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var C=YS(t,w.tickCoord,A,l,c);C&&(l=w.tickCoord+t*(A()/2+i),a[M]=is(is({},w),{},{isShow:!0}))}},v=0;v<b;v++)y(v);return a}function bL(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:a,orientation:o,interval:l,tickFormatter:c,unit:u,angle:h}=t;if(!i||!i.length||!r)return[];if(Et(l)||zm.isSsr){var g;return(g=$8e(i,Et(l)?l:0))!==null&&g!==void 0?g:[]}var m=[],b=o==="top"||o==="bottom"?"width":"height",y=u&&b==="width"?Gx(u,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(w,T)=>{var A=typeof c=="function"?c(w.value,T):w.value;return b==="width"?B8e(Gx(A,{fontSize:e,letterSpacing:n}),y,h):Gx(A,{fontSize:e,letterSpacing:n})[b]},x=i.length>=2?Ci(i[1].coordinate-i[0].coordinate):1,M=H8e(s,x,b);return l==="equidistantPreserveStart"?V8e(x,M,v,i,a):(l==="preserveStart"||l==="preserveStartEnd"?m=K8e(x,M,v,i,a,l==="preserveStartEnd"):m=X8e(x,M,v,i,a),m.filter(w=>w.isShow))}var Y8e=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,a=0;if(e){Array.from(e).forEach(u=>{if(u){var h=u.getBoundingClientRect();h.width>a&&(a=h.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+s,c=a+l+o+(n?r:0);return Math.round(c)}return 0},Z8e=["axisLine","width","height","className","hide","ticks","axisType"];function Q8e(t,e){if(t==null)return{};var n,r,i=J8e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function J8e(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 Wf(){return Wf=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},Wf.apply(null,arguments)}function aG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Vr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aG(Object(n),!0).forEach(function(r){eHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eHe(t,e,n){return(e=tHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tHe(t){var e=nHe(t,"string");return typeof e=="symbol"?e:e+""}function nHe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var hc={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:Xr.axis};function rHe(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:a,axisLine:o,otherSvgProps:l}=t;if(!o)return null;var c=Vr(Vr(Vr({},l),Gs(o)),{},{fill:"none"});if(s==="top"||s==="bottom"){var u=+(s==="top"&&!a||s==="bottom"&&a);c=Vr(Vr({},c),{},{x1:e,y1:n+u*i,x2:e+r,y2:n+u*i})}else{var h=+(s==="left"&&!a||s==="right"&&a);c=Vr(Vr({},c),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return E.createElement("line",Wf({},c,{className:An("recharts-cartesian-axis-line",Hf(o,"className"))}))}function iHe(t,e,n,r,i,s,a,o,l){var c,u,h,g,m,b,y=o?-1:1,v=t.tickSize||a,x=Et(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":c=u=t.coordinate,g=n+ +!o*i,h=g-y*v,b=h-y*l,m=x;break;case"left":h=g=t.coordinate,u=e+ +!o*r,c=u-y*v,m=c-y*l,b=x;break;case"right":h=g=t.coordinate,u=e+ +o*r,c=u+y*v,m=c+y*l,b=x;break;default:c=u=t.coordinate,g=n+ +o*i,h=g+y*v,b=h+y*l,m=x;break}return{line:{x1:c,y1:h,x2:u,y2:g},tick:{x:m,y:b}}}function sHe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function aHe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function oHe(t){var{option:e,tickProps:n,value:r}=t,i,s=An(n.className,"recharts-cartesian-axis-tick-value");if(E.isValidElement(e))i=E.cloneElement(e,Vr(Vr({},n),{},{className:s}));else if(typeof e=="function")i=e(Vr(Vr({},n),{},{className:s}));else{var a="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(a=An(a,e?.className)),i=E.createElement(EM,Wf({},n,{className:a}),r)}return i}var lHe=E.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:a,unit:o,padding:l,tickTextProps:c,orientation:u,mirror:h,x:g,y:m,width:b,height:y,tickSize:v,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:T,events:A,axisType:P}=t,C=bL(Vr(Vr({},T),{},{ticks:n}),M,w),j=sHe(u,h),N=aHe(u,h),k=Gs(T),F=Bf(r),I={};typeof i=="object"&&(I=i);var W=Vr(Vr({},k),{},{fill:"none"},I),D=C.map(V=>Vr({entry:V},iHe(V,g,m,b,y,u,v,h,x))),$=D.map(V=>{var{entry:Z,line:K}=V;return E.createElement(Ir,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},i&&E.createElement("line",Wf({},W,K,{className:An("recharts-cartesian-axis-tick-line",Hf(i,"className"))})))}),G=D.map((V,Z)=>{var{entry:K,tick:ee}=V,H=Vr(Vr(Vr(Vr({textAnchor:j,verticalAnchor:N},k),{},{stroke:"none",fill:s},F),ee),{},{index:Z,payload:K,visibleTicksCount:C.length,tickFormatter:a,padding:l},c);return E.createElement(Ir,Wf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(K.value,"-").concat(K.coordinate,"-").concat(K.tickCoord)},sv(A,K,Z)),r&&E.createElement(oHe,{option:r,tickProps:H,value:"".concat(typeof a=="function"?a(K.value,Z):K.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(P,"-ticks")},G.length>0&&E.createElement(Ks,{zIndex:Xr.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(P,"-tick-labels"),ref:e},G)),$.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(P,"-tick-lines")},$))}),cHe=E.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:l}=t,c=Q8e(t,Z8e),[u,h]=E.useState(""),[g,m]=E.useState(""),b=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return Y8e({ticks:b.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=E.useCallback(v=>{if(v){var x=v.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),T=w.fontSize,A=w.letterSpacing;(T!==u||A!==g)&&(h(T),m(A))}}},[u,g]);return a||r!=null&&r<=0||i!=null&&i<=0?null:E.createElement(Ks,{zIndex:t.zIndex},E.createElement(Ir,{className:An("recharts-cartesian-axis",s)},E.createElement(rHe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Gs(t)}),E.createElement(lHe,{ref:y,axisType:l,events:c,fontSize:u,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),E.createElement(Dze,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement($ze,{label:t.label,labelRef:t.labelRef}),t.children)))}),yL=E.forwardRef((t,e)=>{var n=Qr(t,hc);return E.createElement(cHe,Wf({},n,{ref:e}))});yL.displayName="CartesianAxis";var uHe=["x1","y1","x2","y2","key"],dHe=["offset"],fHe=["xAxisId","yAxisId"],hHe=["xAxisId","yAxisId"];function oG(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 ss(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oG(Object(n),!0).forEach(function(r){pHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pHe(t,e,n){return(e=mHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mHe(t){var e=gHe(t,"string");return typeof e=="symbol"?e:e+""}function gHe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function cf(){return cf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},cf.apply(null,arguments)}function ZS(t,e){if(t==null)return{};var n,r,i=xHe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function xHe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var vHe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:s,height:a,ry:o}=t;return E.createElement("rect",{x:r,y:i,ry:o,width:s,height:a,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function FJ(t){var{option:e,lineItemProps:n}=t,r;if(E.isValidElement(e))r=E.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:a,x2:o,y2:l,key:c}=n,u=ZS(n,uHe),h=(i=Gs(u))!==null&&i!==void 0?i:{},{offset:g}=h,m=ZS(h,dHe);r=E.createElement("line",cf({},m,{x1:s,y1:a,x2:o,y2:l,fill:"none",key:c}))}return r}function bHe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ZS(t,fHe),l=i.map((c,u)=>{var h=ss(ss({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(u),index:u});return E.createElement(FJ,{key:"line-".concat(u),option:r,lineItemProps:h})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function yHe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:s,yAxisId:a}=t,o=ZS(t,hHe),l=i.map((c,u)=>{var h=ss(ss({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(u),index:u});return E.createElement(FJ,{option:r,lineItemProps:h,key:"line-".concat(u)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function _He(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:a,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var c=o.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var u=c.map((h,g)=>{var m=!c[g+1],b=m?i+a-h:c[g+1]-h;if(b<=0)return null;var y=g%e.length;return E.createElement("rect",{key:"react-".concat(g),y:h,x:r,height:b,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function SHe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:a,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var c=l.map(h=>Math.round(h+i-i)).sort((h,g)=>h-g);i!==c[0]&&c.unshift(0);var u=c.map((h,g)=>{var m=!c[g+1],b=m?i+a-h:c[g+1]-h;if(b<=0)return null;var y=g%n.length;return E.createElement("rect",{key:"react-".concat(g),x:h,y:s,width:b,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var wHe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return _Y(bL(ss(ss(ss({},hc),n),{},{ticks:SY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},MHe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return _Y(bL(ss(ss(ss({},hc),n),{},{ticks:SY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},EHe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Xr.grid};function EP(t){var e=WD(),n=qD(),r=PY(),i=ss(ss({},Qr(t,EHe)),{},{x:Et(t.x)?t.x:r.left,y:Et(t.y)?t.y:r.top,width:Et(t.width)?t.width:r.width,height:Et(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:l,width:c,height:u,syncWithTicks:h,horizontalValues:g,verticalValues:m}=i,b=fs(),y=Ct(N=>Z$(N,"xAxis",s,b)),v=Ct(N=>Z$(N,"yAxis",a,b));if(!cl(c)||!cl(u)||!Et(o)||!Et(l))return null;var x=i.verticalCoordinatesGenerator||wHe,M=i.horizontalCoordinatesGenerator||MHe,{horizontalPoints:w,verticalPoints:T}=i;if((!w||!w.length)&&typeof M=="function"){var A=g&&g.length,P=M({yAxis:v?ss(ss({},v),{},{ticks:A?g:v.ticks}):void 0,width:e??c,height:n??u,offset:r},A?!0:h);SS(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(w=P)}if((!T||!T.length)&&typeof x=="function"){var C=m&&m.length,j=x({xAxis:y?ss(ss({},y),{},{ticks:C?m:y.ticks}):void 0,width:e??c,height:n??u,offset:r},C?!0:h);SS(Array.isArray(j),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(T=j)}return E.createElement(Ks,{zIndex:i.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(vHe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),E.createElement(_He,cf({},i,{horizontalPoints:w})),E.createElement(SHe,cf({},i,{verticalPoints:T})),E.createElement(bHe,cf({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:v})),E.createElement(yHe,cf({},i,{offset:r,verticalPoints:T,xAxis:y,yAxis:v}))))}EP.displayName="CartesianGrid";function AHe(t){var e=Bf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:s}=e,a=Number(i),o=Number(s);return(Number.isNaN(a)||a<0)&&(a=n),(Number.isNaN(o)||o<0)&&(o=r),{r:a,strokeWidth:o}}return{r:n,strokeWidth:r}}var zJ=(t,e,n,r)=>sd(t,"xAxis",e,r),BJ=(t,e,n,r)=>id(t,"xAxis",e,r),HJ=(t,e,n,r)=>sd(t,"yAxis",n,r),$J=(t,e,n,r)=>id(t,"yAxis",n,r),THe=Ge([Sn,zJ,HJ,BJ,$J],(t,e,n,r,i)=>Tc(t,"xAxis")?vm(e,r,!1):vm(n,i,!1)),CHe=(t,e,n,r,i)=>i,VJ=Ge([yM,CHe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),NHe=(t,e,n,r,i)=>{var s,a=VJ(t,e,n,r,i);if(a!=null){var o=Sn(t),l=Tc(o,"xAxis"),c;if(l?c=j0(t,"yAxis",n,r):c=j0(t,"xAxis",e,r),c!=null){var{stackId:u}=a,h=gM(a);if(!(u==null||h==null)){var g=(s=c[u])===null||s===void 0?void 0:s.stackedData;return g?.find(m=>m.key===h)}}}},RHe=Ge([Sn,zJ,HJ,BJ,$J,NHe,hM,THe,VJ,zje],(t,e,n,r,i,s,a,o,l,c)=>{var{chartData:u,dataStartIndex:h,dataEndIndex:g}=a;if(!(l==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=l,b;if(m&&m.length>0?b=m:b=u?.slice(h,g+1),b!=null)return KHe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:l,stackedData:s,displayedData:b,chartBaseValue:c,bandSize:o})}}),PHe=["id"],kHe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Sf(){return Sf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Sf.apply(null,arguments)}function GJ(t,e){if(t==null)return{};var n,r,i=DHe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function DHe(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 lG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Pp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lG(Object(n),!0).forEach(function(r){OHe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OHe(t,e,n){return(e=LHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LHe(t){var e=IHe(t,"string");return typeof e=="symbol"?e:e+""}function IHe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function QS(t,e){return t&&t!=="none"?t:e}var jHe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:a}=t;return[{inactive:a,dataKey:e,type:s,color:QS(r,i),value:Um(n,e),payload:t}]},UHe=E.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:Um(a,e),hide:o,type:c,color:QS(r,s),unit:l}};return E.createElement(pL,{tooltipEntrySettings:u})});function FHe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:a}=r,o=Gs(r);return E.createElement(PBe,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:a,baseProps:o,needClip:i,clipPathId:e})}function zHe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var a,o,l={x:(a=s.x)!==null&&a!==void 0?a:0,y:(o=s.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return Pp(Pp({},l),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return E.createElement(pJ,{value:e?i:void 0},n)}function cG(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:a,type:o,stroke:l,connectNulls:c,isRange:u}=s,{id:h}=s,g=GJ(s,PHe),m=Gs(g),b=Es(g);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(Ir,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},E.createElement(Vp,Sf({},b,{id:h,points:e,connectNulls:c,type:o,baseLine:n,layout:a,stroke:"none",className:"recharts-area-area"})),l!=="none"&&E.createElement(Vp,Sf({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&u&&E.createElement(Vp,Sf({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:c,fill:"none",points:n}))),E.createElement(FHe,{points:e,props:g,clipPathId:i}))}function BHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!or(s)||!or(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(c=>c.x||0));return Et(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.x||0),l)),Et(l)?E.createElement("rect",{x:0,y:s<a?s:s-o,width:l+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function HHe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,a=r[r.length-1].x;if(!or(s)||!or(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(c=>c.y||0));return Et(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.y||0),l)),Et(l)?E.createElement("rect",{x:s<a?s:s-o,y:0,width:o,height:Math.floor(l+(i?parseInt("".concat(i),10):1))}):null}function $He(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?E.createElement(BHe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):E.createElement(HHe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function VHe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:a,baseLine:o,isAnimationActive:l,animationBegin:c,animationDuration:u,animationEasing:h,onAnimationStart:g,onAnimationEnd:m}=r,b=E.useMemo(()=>({points:a,baseLine:o}),[a,o]),y=fv(b,"recharts-area-"),v=iDe(),[x,M]=E.useState(!1),w=!x,T=E.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),A=E.useCallback(()=>{typeof g=="function"&&g(),M(!0)},[g]);if(v==null)return null;var P=i.current,C=s.current;return E.createElement(zHe,{showLabels:w,points:a},r.children,E.createElement(dv,{animationId:y,begin:c,duration:u,isActive:l,easing:h,onAnimationEnd:T,onAnimationStart:A,key:y},j=>{if(P){var N=P.length/a.length,k=j===1?a:a.map((I,W)=>{var D=Math.floor(W*N);if(P[D]){var $=P[D];return Pp(Pp({},I),{},{x:ar($.x,I.x,j),y:ar($.y,I.y,j)})}return I}),F;return Et(o)?F=ar(C,o,j):xr(o)||Ya(o)?F=ar(C,0,j):F=o.map((I,W)=>{var D=Math.floor(W*N);if(Array.isArray(C)&&C[D]){var $=C[D];return Pp(Pp({},I),{},{x:ar($.x,I.x,j),y:ar($.y,I.y,j)})}return I}),j>0&&(i.current=k,s.current=F),E.createElement(cG,{points:k,baseLine:F,needClip:e,clipPathId:n,props:r})}return j>0&&(i.current=a,s.current=o),E.createElement(Ir,null,l&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement($He,{alpha:j,points:a,baseLine:o,layout:v,strokeWidth:r.strokeWidth}))),E.createElement(Ir,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(cG,{points:a,baseLine:o,needClip:e,clipPathId:n,props:r})))}),E.createElement(oL,{label:r.label}))}function GHe(t){var{needClip:e,clipPathId:n,props:r}=t,i=E.useRef(null),s=E.useRef();return E.createElement(VHe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class WHe extends E.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:a,needClip:o,xAxisId:l,yAxisId:c,width:u,height:h,id:g,baseLine:m,zIndex:b}=this.props;if(e)return null;var y=An("recharts-area",i),v=g,{r:x,strokeWidth:M}=AHe(n),w=SJ(n),T=x*2+M,A=o?"url(#clipPath-".concat(w?"":"dots-").concat(v,")"):void 0;return E.createElement(Ks,{zIndex:b},E.createElement(Ir,{className:y},o&&E.createElement("defs",null,E.createElement(PJ,{clipPathId:v,xAxisId:l,yAxisId:c}),!w&&E.createElement("clipPath",{id:"clipPath-dots-".concat(v)},E.createElement("rect",{x:a-T/2,y:s-T/2,width:u+T,height:h+T}))),E.createElement(GHe,{needClip:o,clipPathId:v,props:this.props})),E.createElement(KV,{points:r,mainColor:QS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}),this.props.isRange&&Array.isArray(m)&&E.createElement(KV,{points:m,mainColor:QS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}))}}var WJ={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:Xr.area};function qHe(t){var e,n=Qr(t,WJ),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:l,fill:c,fillOpacity:u,hide:h,isAnimationActive:g,legendType:m,stroke:b,xAxisId:y,yAxisId:v}=n,x=GJ(n,kHe),M=Fm(),w=KQ(),{needClip:T}=xL(y,v),A=fs(),{points:P,isRange:C,baseLine:j}=(e=Ct(D=>RHe(D,y,v,A,t.id)))!==null&&e!==void 0?e:{},N=gL();if(M!=="horizontal"&&M!=="vertical"||N==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:k,width:F,x:I,y:W}=N;return!P||!P.length?null:E.createElement(WHe,Sf({},x,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,baseLine:j,connectNulls:o,dot:l,fill:c,fillOpacity:u,height:k,hide:h,layout:M,isAnimationActive:g==="auto"?!zm.isSsr:g,isRange:C,legendType:m,needClip:T,points:P,stroke:b,width:F,left:I,top:W,xAxisId:y,yAxisId:v}))}var XHe=(t,e,n,r,i)=>{var s=n??e;if(Et(s))return s;var a=t==="horizontal"?i:r,o=a.scale.domain();if(a.type==="number"){var l=Math.max(o[0],o[1]),c=Math.min(o[0],o[1]);return s==="dataMin"?c:s==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return s==="dataMin"?o[0]:s==="dataMax"?o[1]:o[0]};function KHe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:a,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:u,xAxisTicks:h,yAxisTicks:g,bandSize:m}=t,b=i&&i.length,y=XHe(s,a,n,o,l),v=s==="horizontal",x=!1,M=c.map((T,A)=>{var P;b?P=i[u+A]:(P=Yn(T,r),Array.isArray(P)?x=!0:P=[y,P]);var C=P[1]==null||b&&!e&&Yn(T,r)==null;return v?{x:gH({axis:o,ticks:h,bandSize:m,entry:T,index:A}),y:C?null:l.scale(P[1]),value:P,payload:T}:{x:C?null:o.scale(P[1]),y:gH({axis:l,ticks:g,bandSize:m,entry:T,index:A}),value:P,payload:T}}),w;return b||x?w=M.map(T=>{var A=Array.isArray(T.value)?T.value[0]:null;return v?{x:T.x,y:A!=null&&T.y!=null?l.scale(A):null,payload:T.payload}:{x:A!=null?o.scale(A):null,y:T.y,payload:T.payload}}):w=v?l.scale(y):o.scale(y),{points:M,baseLine:w,isRange:x}}function YHe(t){var e=Qr(t,WJ),n=fs();return E.createElement(mL,{id:e.id,type:"area"},r=>E.createElement(E.Fragment,null,E.createElement(MJ,{legendPayload:jHe(e)}),E.createElement(UHe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(TJ,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:wY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(qHe,Sf({},e,{id:r}))))}var qJ=E.memo(YHe,NM);qJ.displayName="Area";var ZHe=["domain","range"],QHe=["domain","range"];function uG(t,e){if(t==null)return{};var n,r,i=JHe(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function JHe(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 dG(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 XJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=uG(t,ZHe),{domain:s,range:a}=e,o=uG(e,QHe);return!dG(n,s)||!dG(r,a)?!1:NM(i,o)}var e$e=["dangerouslySetInnerHTML","ticks"],t$e=["id"];function AP(){return AP=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},AP.apply(null,arguments)}function fG(t,e){if(t==null)return{};var n,r,i=n$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function n$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function r$e(t){var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(IBe(t)):n.current!==t&&e(jBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(UBe(n.current)),n.current=null)},[e]),null}var i$e=t=>{var{xAxisId:e,className:n}=t,r=Ct(VD),i=fs(),s="xAxis",a=Ct(v=>qm(v,s,e,i)),o=Ct(v=>TQ(v,s,e,i)),l=Ct(v=>wQ(v,e)),c=Ct(v=>j4e(v,e)),u=Ct(v=>iQ(v,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:h,ticks:g}=t,m=fG(t,e$e),{id:b}=u,y=fG(u,t$e);return E.createElement(yL,AP({},m,y,{scale:a,x:c.x,y:c.y,width:l.width,height:l.height,className:An("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},s$e={allowDataOverflow:wi.allowDataOverflow,allowDecimals:wi.allowDecimals,allowDuplicatedCategory:wi.allowDuplicatedCategory,angle:wi.angle,axisLine:hc.axisLine,height:wi.height,hide:!1,includeHidden:wi.includeHidden,interval:wi.interval,minTickGap:wi.minTickGap,mirror:wi.mirror,orientation:wi.orientation,padding:wi.padding,reversed:wi.reversed,scale:wi.scale,tick:wi.tick,tickCount:wi.tickCount,tickLine:hc.tickLine,tickSize:hc.tickSize,type:wi.type,xAxisId:0},a$e=t=>{var e=Qr(t,s$e);return E.createElement(E.Fragment,null,E.createElement(r$e,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),E.createElement(i$e,e))},TP=E.memo(a$e,XJ);TP.displayName="XAxis";var o$e=["dangerouslySetInnerHTML","ticks"],l$e=["id"];function CP(){return CP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},CP.apply(null,arguments)}function hG(t,e){if(t==null)return{};var n,r,i=c$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function c$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function u$e(t){var e=er(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(FBe(t)):n.current!==t&&e(zBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(BBe(n.current)),n.current=null)},[e]),null}var d$e=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=E.useRef(null),a=E.useRef(null),o=Ct(VD),l=fs(),c=er(),u="yAxis",h=Ct(A=>qm(A,u,e,l)),g=Ct(A=>MQ(A,e)),m=Ct(A=>F4e(A,e)),b=Ct(A=>TQ(A,u,e,l)),y=Ct(A=>sQ(A,e));if(E.useLayoutEffect(()=>{if(!(r!=="auto"||!g||aL(i)||E.isValidElement(i)||y==null)){var A=s.current;if(A){var P=A.getCalculatedWidth();Math.round(g.width)!==Math.round(P)&&c(HBe({id:e,width:P}))}}},[b,g,c,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:v,ticks:x}=t,M=hG(t,o$e),{id:w}=y,T=hG(y,l$e);return E.createElement(yL,CP({},M,T,{ref:s,labelRef:a,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:An("recharts-".concat(u," ").concat(u),n),viewBox:o,ticks:b,axisType:u}))},f$e={allowDataOverflow:Mi.allowDataOverflow,allowDecimals:Mi.allowDecimals,allowDuplicatedCategory:Mi.allowDuplicatedCategory,angle:Mi.angle,axisLine:hc.axisLine,hide:!1,includeHidden:Mi.includeHidden,interval:Mi.interval,minTickGap:Mi.minTickGap,mirror:Mi.mirror,orientation:Mi.orientation,padding:Mi.padding,reversed:Mi.reversed,scale:Mi.scale,tick:Mi.tick,tickCount:Mi.tickCount,tickLine:hc.tickLine,tickSize:hc.tickSize,type:Mi.type,width:Mi.width,yAxisId:0},h$e=t=>{var e=Qr(t,f$e);return E.createElement(E.Fragment,null,E.createElement(u$e,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),E.createElement(d$e,e))},NP=E.memo(h$e,XJ);NP.displayName="YAxis";var p$e=(t,e)=>e,_L=Ge([p$e,Sn,nQ,pi,$Q,Dc,eFe,fi],oFe),SL=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)}},KJ=Za("mouseClick"),YJ=lv();YJ.startListening({actionCreator:KJ,effect:(t,e)=>{var n=t.payload,r=_L(e.getState(),SL(n));r?.activeIndex!=null&&e.dispatch(J4e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var RP=Za("mouseMove"),ZJ=lv(),x_=null;ZJ.startListening({actionCreator:RP,effect:(t,e)=>{var n=t.payload;x_!==null&&cancelAnimationFrame(x_);var r=SL(n);x_=requestAnimationFrame(()=>{var i=e.getState(),s=XO(i,i.tooltip.settings.shared);if(s==="axis"){var a=_L(i,r);a?.activeIndex!=null?e.dispatch(LQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):e.dispatch(OQ())}x_=null})}});var pG={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},QJ=Xs({name:"rootProps",initialState:pG,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:pG.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}}}),m$e=QJ.reducer,{updateOptions:g$e}=QJ.actions,JJ=Xs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:x$e}=JJ.actions,v$e=JJ.reducer,eee=Za("keyDown"),tee=Za("focus"),wL=lv();wL.startListening({actionCreator:eee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,s=t.payload;if(!(s!=="ArrowRight"&&s!=="ArrowLeft"&&s!=="Enter")){var a=KO(i,Km(n),_v(n),Ev(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var l=Dc(n);if(s==="Enter"){var c=$S(n,"axis","hover",String(i.index));e.dispatch(vP({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:c}));return}var u=$4e(n),h=u==="left-to-right"?1:-1,g=s==="ArrowRight"?1:-1,m=o+g*h;if(!(l==null||m>=l.length||m<0)){var b=$S(n,"axis","hover",String(m));e.dispatch(vP({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:b}))}}}}}});wL.startListening({actionCreator:tee,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var s="0",a=$S(n,"axis","hover",String(s));e.dispatch(vP({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:a}))}}}});var Pa=Za("externalEvent"),nee=lv(),MN=new Map;nee.startListening({actionCreator:Pa,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=MN.get(i);s!==void 0&&cancelAnimationFrame(s);var a=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:FUe(o),activeDataKey:eL(o),activeIndex:ad(o),activeLabel:WQ(o),activeTooltipIndex:ad(o),isTooltipActive:zUe(o)};n(l,r)}finally{MN.delete(i)}});MN.set(i,a)}}});var b$e=Ge([Xm],t=>t.tooltipItemPayloads),y$e=Ge([b$e,wv,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(o=>o.settings.dataKey===r);if(i!=null){var{positions:s}=i;if(s!=null){var a=e(s,n);return a}}}),ree=Za("touchMove"),iee=lv();iee.startListening({actionCreator:ree,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=XO(r,r.tooltip.settings.shared);if(i==="axis"){var s=_L(r,SL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(LQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate}))}else if(i==="item"){var a,o=n.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(o.clientX,o.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(EY),u=(a=l.getAttribute(AY))!==null&&a!==void 0?a:void 0,h=y$e(e.getState(),c,u);e.dispatch(DQ({activeDataKey:u,activeIndex:c,activeCoordinate:h}))}}}});var _$e=WK({brush:P8e,cartesianAxis:$Be,chartData:UFe,errorBars:l6e,graphicalItems:K5e,layout:dke,legend:bDe,options:DFe,polarAxis:u5e,polarOptions:v$e,referenceElements:U8e,rootProps:m$e,tooltip:eUe,zIndex:_Fe}),S$e=function(e){return IPe({reducer:_$e,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([YJ.middleware,ZJ.middleware,wL.middleware,nee.middleware,iee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(oY({type:"raf"}))},devTools:zm.devToolsEnabled})};function see(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=fs(),s=E.useRef(null);if(i)return n;s.current==null&&(s.current=S$e(e));var a=LD;return E.createElement(D6e,{context:a,store:s.current},n)}function w$e(t){var{layout:e,margin:n}=t,r=er(),i=fs();return E.useEffect(()=>{i||(r(lke(e)),r(oke(n)))},[r,i,e,n]),null}var aee=E.memo(w$e,NM);function oee(t){var e=er();return E.useEffect(()=>{e(g$e(t))},[e,t]),null}function mG(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=EJ("".concat(r).concat(e)),s=er();return E.useLayoutEffect(()=>(s(bFe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(yFe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),E.createElement("g",{tabIndex:-1,id:i})}function gG(t){var{children:e,isPanorama:n}=t,r=Ct(cFe);if(!r||r.length===0)return e;var i=r.filter(a=>a<0),s=r.filter(a=>a>0);return E.createElement(E.Fragment,null,i.map(a=>E.createElement(mG,{key:a,zIndex:a,isPanorama:n})),e,s.map(a=>E.createElement(mG,{key:a,zIndex:a,isPanorama:n})))}var M$e=["children"];function E$e(t,e){if(t==null)return{};var n,r,i=A$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function A$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function JS(){return JS=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},JS.apply(null,arguments)}var T$e={width:"100%",height:"100%",display:"block"},C$e=E.forwardRef((t,e)=>{var n=WD(),r=qD(),i=$Y();if(!cl(n)||!cl(r))return null;var{children:s,otherAttributes:a,title:o,desc:l}=t,c,u;return a!=null&&(typeof a.tabIndex=="number"?c=a.tabIndex:c=i?0:void 0,typeof a.role=="string"?u=a.role:u=i?"application":void 0),E.createElement(ED,JS({},a,{title:o,desc:l,role:u,tabIndex:c,width:n,height:r,style:T$e,ref:e}),s)}),N$e=t=>{var{children:e}=t,n=Ct(tM);if(!n)return null;var{width:r,height:i,y:s,x:a}=n;return E.createElement(ED,{width:r,height:i,x:a,y:s},e)},xG=E.forwardRef((t,e)=>{var{children:n}=t,r=E$e(t,M$e),i=fs();return i?E.createElement(N$e,null,E.createElement(gG,{isPanorama:!0},n)):E.createElement(C$e,JS({ref:e},r),E.createElement(gG,{isPanorama:!1},n))});function R$e(){var t=er(),[e,n]=E.useState(null),r=Ct(Cke);return E.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;or(s)&&s!==r&&t(uke(s))}},[e,t,r]),n}function vG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function P$e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vG(Object(n),!0).forEach(function(r){k$e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function k$e(t,e,n){return(e=D$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D$e(t){var e=O$e(t,"string");return typeof e=="symbol"?e:e+""}function O$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 qf(){return qf=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},qf.apply(null,arguments)}var L$e=()=>(qFe(),null);function ew(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var I$e=E.forwardRef((t,e)=>{var n,r,i=E.useRef(null),[s,a]=E.useState({containerWidth:ew((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:ew((r=t.style)===null||r===void 0?void 0:r.height)}),o=E.useCallback((c,u)=>{a(h=>{var g=Math.round(c),m=Math.round(u);return h.containerWidth===g&&h.containerHeight===m?h:{containerWidth:g,containerHeight:m}})},[]),l=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:u,height:h}=c.getBoundingClientRect();o(u,h);var g=b=>{var{width:y,height:v}=b[0].contentRect;o(y,v)},m=new ResizeObserver(g);m.observe(c),i.current=m}},[e,o]);return E.useEffect(()=>()=>{var c=i.current;c?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(rM,{width:s.containerWidth,height:s.containerHeight}),E.createElement("div",qf({ref:l},t)))}),j$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=E.useState({containerWidth:ew(n),containerHeight:ew(r)}),a=E.useCallback((l,c)=>{s(u=>{var h=Math.round(l),g=Math.round(c);return u.containerWidth===h&&u.containerHeight===g?u:{containerWidth:h,containerHeight:g}})},[]),o=E.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:u}=l.getBoundingClientRect();a(c,u)}},[e,a]);return E.createElement(E.Fragment,null,E.createElement(rM,{width:i.containerWidth,height:i.containerHeight}),E.createElement("div",qf({ref:o},t)))}),U$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return E.createElement(E.Fragment,null,E.createElement(rM,{width:n,height:r}),E.createElement("div",qf({ref:e},t)))}),F$e=E.forwardRef((t,e)=>{var{width:n,height:r}=t;return bc(n)||bc(r)?E.createElement(j$e,qf({},t,{ref:e})):E.createElement(U$e,qf({},t,{ref:e}))});function z$e(t){return t===!0?I$e:F$e}var B$e=E.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:a,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:u,onMouseMove:h,onMouseUp:g,onTouchEnd:m,onTouchMove:b,onTouchStart:y,style:v,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,T=E.useRef(null),A=er(),[P,C]=E.useState(null),[j,N]=E.useState(null),k=R$e(),F=GD(),I=F?.width>0?F.width:x,W=F?.height>0?F.height:i,D=E.useCallback(he=>{k(he),typeof e=="function"&&e(he),C(he),N(he),he!=null&&(T.current=he)},[k,e,C,N]),$=E.useCallback(he=>{A(KJ(he)),A(Pa({handler:s,reactEvent:he}))},[A,s]),G=E.useCallback(he=>{A(RP(he)),A(Pa({handler:c,reactEvent:he}))},[A,c]),V=E.useCallback(he=>{A(OQ()),A(Pa({handler:u,reactEvent:he}))},[A,u]),Z=E.useCallback(he=>{A(RP(he)),A(Pa({handler:h,reactEvent:he}))},[A,h]),K=E.useCallback(()=>{A(tee())},[A]),ee=E.useCallback(he=>{A(eee(he.key))},[A]),H=E.useCallback(he=>{A(Pa({handler:a,reactEvent:he}))},[A,a]),Y=E.useCallback(he=>{A(Pa({handler:o,reactEvent:he}))},[A,o]),te=E.useCallback(he=>{A(Pa({handler:l,reactEvent:he}))},[A,l]),ae=E.useCallback(he=>{A(Pa({handler:g,reactEvent:he}))},[A,g]),fe=E.useCallback(he=>{A(Pa({handler:y,reactEvent:he}))},[A,y]),Q=E.useCallback(he=>{w&&A(ree(he)),A(Pa({handler:b,reactEvent:he}))},[A,w,b]),me=E.useCallback(he=>{A(Pa({handler:m,reactEvent:he}))},[A,m]),Ee=z$e(M);return E.createElement(eJ.Provider,{value:P},E.createElement(lK.Provider,{value:j},E.createElement(Ee,{width:I??v?.width,height:W??v?.height,className:An("recharts-wrapper",r),style:P$e({position:"relative",cursor:"default",width:I,height:W},v),onClick:$,onContextMenu:H,onDoubleClick:Y,onFocus:K,onKeyDown:ee,onMouseDown:te,onMouseEnter:G,onMouseLeave:V,onMouseMove:Z,onMouseUp:ae,onTouchEnd:me,onTouchMove:Q,onTouchStart:fe,ref:D},E.createElement(L$e,null),n)))}),H$e=["width","height","responsive","children","className","style","compact","title","desc"];function $$e(t,e){if(t==null)return{};var n,r,i=V$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function V$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var lee=E.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:a,style:o,compact:l,title:c,desc:u}=t,h=$$e(t,H$e),g=Gs(h);return l?E.createElement(E.Fragment,null,E.createElement(rM,{width:n,height:r}),E.createElement(xG,{otherAttributes:g,title:c,desc:u},s)):E.createElement(B$e,{className:a,style:o,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},E.createElement(xG,{otherAttributes:g,title:c,desc:u,ref:e},E.createElement(z8e,null,s)))});function PP(){return PP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},PP.apply(null,arguments)}var G$e={top:5,right:5,bottom:5,left:5},W$e={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:G$e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},cee=E.forwardRef(function(e,n){var r,i=Qr(e.categoricalChartProps,W$e),{chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:c}=e,u={chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return E.createElement(see,{preloadedState:{options:u},reduxStoreName:(r=c.id)!==null&&r!==void 0?r:s},E.createElement(LJ,{chartData:c.data}),E.createElement(aee,{layout:i.layout,margin:i.margin}),E.createElement(oee,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),E.createElement(lee,PP({},i,{ref:n})))}),q$e=["axis","item"],X$e=E.forwardRef((t,e)=>E.createElement(cee,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:q$e,tooltipPayloadSearcher:sL,categoricalChartProps:t,ref:e}));function K$e(t){var e=er();return E.useEffect(()=>{e(x$e(t))},[e,t]),null}var Y$e=["layout"];function kP(){return kP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},kP.apply(null,arguments)}function Z$e(t,e){if(t==null)return{};var n,r,i=Q$e(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(r=0;r<s.length;r++)n=s[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Q$e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var J$e={top:5,right:5,bottom:5,left:5},uee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:J$e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},eVe=E.forwardRef(function(e,n){var r,i=Qr(e.categoricalChartProps,uee),{layout:s}=i,a=Z$e(i,Y$e),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u}=e,h={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u,eventEmitter:void 0};return E.createElement(see,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},E.createElement(LJ,{chartData:i.data}),E.createElement(aee,{layout:s,margin:i.margin}),E.createElement(oee,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),E.createElement(K$e,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),E.createElement(lee,kP({},a,{ref:n})))});function bG(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 yG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bG(Object(n),!0).forEach(function(r){tVe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tVe(t,e,n){return(e=nVe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nVe(t){var e=rVe(t,"string");return typeof e=="symbol"?e:e+""}function rVe(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 iVe=["item"],sVe=yG(yG({},uee),{},{layout:"centric",startAngle:0,endAngle:360}),aVe=E.forwardRef((t,e)=>{var n=Qr(t,sVe);return E.createElement(eVe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:iVe,tooltipPayloadSearcher:sL,categoricalChartProps:n,ref:e})}),oVe=["axis"],lVe=E.forwardRef((t,e)=>E.createElement(cee,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:oVe,tooltipPayloadSearcher:sL,categoricalChartProps:t,ref:e}));const v_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function cVe(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 uVe({archives:t,currency:e="$"}){const[n,r]=E.useState("30d"),i=E.useMemo(()=>{const g=cVe(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),s=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],v=g.get(y)||{date:y,filament:0,cost:0,prints:0};v.filament+=m.filament_used_grams||0,v.cost+=m.cost||0,v.prints+=1,g.set(y,v)}),Array.from(g.values()).sort((m,b)=>m.date.localeCompare(b.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),a=E.useMemo(()=>{if(n==="7d"||n==="30d")return s;const g=new Map;return i.forEach(m=>{const b=new Date(m.completed_at||m.created_at),y=new Date(b);y.setDate(b.getDate()-b.getDay());const v=y.toISOString().split("T")[0],x=g.get(v)||{week:v,filament:0,cost:0,prints:0};x.filament+=m.filament_used_grams||0,x.cost+=m.cost||0,x.prints+=1,g.set(v,x)}),Array.from(g.values()).sort((m,b)=>m.week.localeCompare(b.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[i,s,n]),o=E.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(v=>{const x=(m.filament_used_grams||0)/y.length;g.set(v,(g.get(v)||0)+x)})}),Array.from(g.entries()).map(([m,b])=>({name:m,value:Math.round(b)})).sort((m,b)=>b.value-m.value)},[i]),l=E.useMemo(()=>{const g=new Date,m=[];for(let b=5;b>=0;b--){const y=new Date(g.getFullYear(),g.getMonth()-b,1),v=new Date(g.getFullYear(),g.getMonth()-b+1,0),x=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const T=new Date(w.completed_at||w.created_at);return T>=y&&T<=v});m.push({month:x,filament:Math.round(M.reduce((w,T)=>w+(T.filament_used_grams||0),0)),cost:M.reduce((w,T)=>w+(T.cost||0),0),prints:M.length})}return m},[t]),c=n==="7d"||n==="30d"?s:a,u=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),h=i.reduce((g,m)=>g+(m.cost||0),0);return f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),f.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>f.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))})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),f.jsxs("p",{className:"text-2xl font-bold text-white",children:[(u/1e3).toFixed(2),"kg"]}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.toFixed(0),"g total"]})]}),f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),f.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,h.toFixed(2)]}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),f.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(u/i.length).toFixed(0):0,"g"]}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(h/i.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),f.jsx(GC,{width:"100%",height:250,children:f.jsxs(lVe,{data:c,children:[f.jsx("defs",{children:f.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[f.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),f.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),f.jsx(EP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),f.jsx(TP,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),f.jsx(NP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),f.jsx(cN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),f.jsx(qJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):f.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),f.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(GC,{width:160,height:160,children:f.jsxs(aVe,{children:[f.jsx(CJ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>f.jsx(Tv,{fill:v_[m%v_.length]},`cell-${m}`))}),f.jsx(cN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),f.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const b=o.reduce((v,x)=>v+x.value,0),y=b>0?(g.value/b*100).toFixed(0):0;return f.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[f.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:v_[m%v_.length]}}),f.jsx("span",{className:"text-white truncate flex-1",children:g.name}),f.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):f.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),f.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[f.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),f.jsx(GC,{width:"100%",height:200,children:f.jsxs(X$e,{data:l,children:[f.jsx(EP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),f.jsx(TP,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),f.jsx(NP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),f.jsx(cN,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,m)=>[m==="filament"?`${g}g`:m==="cost"?`${e}${g.toFixed(2)}`:g,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),f.jsx(HY,{}),f.jsx(DJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function dVe({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:a}){const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:h,isDragging:g}=tK({id:t}),m={transform:pm.Transform.toString(u),transition:h,opacity:g?.5:1};return r?null:f.jsxs("div",{ref:c,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{...o,...l,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:f.jsx(QP,{className:"w-4 h-4 text-bambu-gray"})}),f.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?f.jsx(zoe,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):f.jsx(Ioe,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),f.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:f.jsx(KP,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),f.jsx("div",{className:"p-4",children:n})]})}function fVe({widgets:t,storageKey:e,columns:n=4}){const r=()=>{const v={};return t.forEach(x=>{v[x.id]=x.defaultSize||4}),v},[i,s]=E.useState(()=>{const v=localStorage.getItem(e);if(v)try{const x=JSON.parse(v);return x.sizes||(x.sizes=r()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()}}),[a,o]=E.useState(!1);E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(i))},[i,e]),E.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!i.order.includes(M));x.length>0&&s(M=>({...M,order:[...M.order,...x]}))},[t,i.order]);const l=DX(sS(Iw,{activationConstraint:{distance:8}}),sS(Lw,{coordinateGetter:nK})),c=v=>{const{active:x,over:M}=v;M&&x.id!==M.id&&s(w=>{const T=w.order.indexOf(x.id),A=w.order.indexOf(M.id);return{...w,order:Fw(w.order,T,A)}})},u=v=>{s(x=>({...x,hidden:x.hidden.includes(v)?x.hidden.filter(M=>M!==v):[...x.hidden,v]}))},h=v=>{s(x=>{const M=x.sizes[v]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[v]:w}}})},g=()=>{const v={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:r()};s(v)},m=i.order.map(v=>t.find(x=>x.id===v)).filter(Boolean),b=m.filter(v=>!i.hidden.includes(v.id)),y=m.filter(v=>i.hidden.includes(v.id));return f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-end gap-2",children:[y.length>0&&f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>o(!a),children:[f.jsx(Zx,{className:"w-4 h-4"}),y.length," Hidden"]}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:g,children:[f.jsx(G0,{className:"w-4 h-4"}),"Reset Layout"]})]}),a&&y.length>0&&f.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[f.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),f.jsx("div",{className:"flex flex-wrap gap-2",children:y.map(v=>f.jsxs("button",{onClick:()=>u(v.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:[f.jsx(Zx,{className:"w-3 h-3"}),v.title]},v.id))})]}),f.jsx(YX,{sensors:l,collisionDetection:jX,onDragEnd:c,children:f.jsx(JX,{items:b.map(v=>v.id),strategy:wD,children:f.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(v=>f.jsx(dVe,{id:v.id,title:v.title,isHidden:i.hidden.includes(v.id),size:i.sizes[v.id]||2,onToggleVisibility:()=>u(v.id),onToggleSize:()=>h(v.id),children:v.component},v.id))})})}),b.length===0&&f.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[f.jsx("p",{children:"All widgets are hidden."}),f.jsx(We,{className:"mt-4",onClick:g,children:"Reset Layout"})]})]})}function hVe({stats:t,currency:e}){return f.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:f.jsx(e1,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),f.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:f.jsx(Pi,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:f.jsx(e1,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:f.jsx(rF,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:f.jsx(nk,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:f.jsx(rF,{className:"w-5 h-5"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),f.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function pVe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return f.jsxs("div",{className:"flex items-center gap-6",children:[f.jsxs("div",{className:"relative w-28 h-28",children:[f.jsxs("svg",{className:"w-full h-full -rotate-90",children:[f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),f.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:f.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(mc,{className:"w-4 h-4 text-bambu-green"}),f.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),f.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(V0,{className:"w-4 h-4 text-red-400"}),f.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),f.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function mVe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,a=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return f.jsxs("div",{className:"flex items-center gap-6",children:[f.jsxs("div",{className:"relative w-28 h-28",children:[f.jsxs("svg",{className:"w-full h-full -rotate-90",children:[f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),f.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:a,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),f.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[f.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),f.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),f.jsxs("div",{className:"space-y-2 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[f.jsx(y9,{className:"w-3 h-3"}),f.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&f.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>f.jsxs("div",{className:"flex items-center justify-between text-xs",children:[f.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),f.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function gVe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return f.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 f.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[f.jsx("span",{className:"text-white",children:n}),f.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),f.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:f.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function xVe({printDates:t}){return f.jsx(r3e,{printDates:t,months:4})}function vVe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?f.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>f.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[f.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:f.jsx(nl,{className:"w-4 h-4 text-bambu-green"})}),f.jsxs("div",{children:[f.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),f.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function bVe({archives:t,currency:e}){return!t||t.length===0?f.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):f.jsx(uVe,{archives:t,currency:e})}function yVe(){const{data:t,isLoading:e}=At({queryKey:["archiveStats"],queryFn:Ue.getArchiveStats}),{data:n}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),{data:r}=At({queryKey:["archives"],queryFn:()=>Ue.getArchives(void 0,1e3,0)}),{data:i}=At({queryKey:["settings"],queryFn:Ue.getSettings}),s=i?.currency||"$",a=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=r?.map(c=>c.created_at)||[];if(e)return f.jsx("div",{className:"p-8",children:f.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:f.jsx(hVe,{stats:t,currency:s}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:f.jsx(pVe,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:f.jsx(mVe,{stats:t,printerMap:a}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:f.jsx(gVe,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:f.jsx(xVe,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:f.jsx(vVe,{stats:t,printerMap:a}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:f.jsx(bVe,{archives:r||[],currency:s}),defaultSize:4}];return f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"mb-6",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),f.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),f.jsx(fVe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function _Ve({plug:t,onEdit:e}){const n=Rn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),{data:h,isLoading:g,refetch:m}=At({queryKey:["smart-plug-status",t.id],queryFn:()=>Ue.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),y=b?.find(P=>P.id===t.printer_id),v=Tt({mutationFn:P=>Ue.controlSmartPlug(t.id,P),onSuccess:()=>{m()}}),x=Tt({mutationFn:P=>Ue.updateSmartPlug(t.id,P),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=Tt({mutationFn:()=>Ue.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=h?.state==="ON",T=h?.reachable??!1,A=v.isPending;return f.jsxs(f.Fragment,{children:[f.jsx(Ft,{className:"relative",children:f.jsxs($t,{className:"p-4",children:[f.jsxs("div",{className:"flex items-start justify-between mb-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:`p-2 rounded-lg ${T?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:f.jsx(w_,{className:`w-5 h-5 ${T?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),f.jsxs("div",{children:[f.jsx("h3",{className:"font-medium text-white",children:t.name}),f.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),f.jsx("div",{className:"flex items-center gap-2",children:g?f.jsx(Vt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):T?f.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[f.jsx(S9,{className:"w-4 h-4 text-bambu-green"}),f.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:h?.state||"Unknown"})]}):f.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[f.jsx(tk,{className:"w-4 h-4"}),f.jsx("span",{children:"Offline"})]})})]}),y&&f.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),f.jsx("span",{className:"text-sm text-white",children:y.name})]}),f.jsxs("div",{className:"flex gap-2 mb-3",children:[f.jsxs(We,{size:"sm",variant:w?"primary":"secondary",disabled:!T||A,onClick:()=>a(!0),className:"flex-1",children:[A?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(Xf,{className:"w-4 h-4"}),"On"]}),f.jsxs(We,{size:"sm",variant:w?"secondary":"primary",disabled:!T||A,onClick:()=>l(!0),className:"flex-1",children:[A?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(m9,{className:"w-4 h-4"}),"Off"]})]}),f.jsxs("button",{onClick:()=>u(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx(ow,{className:"w-4 h-4"}),"Automation Settings"]}),f.jsx("span",{children:c?"-":"+"})]}),c&&f.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Enabled"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:t.enabled,onChange:P=>x.mutate({enabled:P.target.checked}),className:"sr-only peer"}),f.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"})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Auto On"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:P=>x.mutate({auto_on:P.target.checked}),className:"sr-only peer"}),f.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"})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:P=>x.mutate({auto_off:P.target.checked}),className:"sr-only peer"}),f.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&&f.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[f.jsx(Pi,{className:"w-4 h-4"}),"Time"]}),f.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[f.jsx(Dp,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),f.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:P=>x.mutate({off_delay_minutes:parseInt(P.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"})]}):f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),f.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:P=>x.mutate({off_temp_threshold:parseInt(P.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"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),f.jsxs("div",{className:"flex gap-2 pt-2",children:[f.jsxs(We,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[f.jsx(ek,{className:"w-4 h-4"}),"Edit"]}),f.jsx(We,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:f.jsx(fr,{className:"w-4 h-4"})})]})]})]})}),r&&f.jsx(zs,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),i(!1)},onCancel:()=>i(!1)}),s&&f.jsx(zs,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),a(!1)},onCancel:()=>a(!1)}),o&&f.jsx(zs,{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:()=>{v.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function SVe({plug:t,onClose:e}){const n=Rn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.ip_address||""),[l,c]=E.useState(t?.username||""),[u,h]=E.useState(t?.password||""),[g,m]=E.useState(t?.printer_id||null),[b,y]=E.useState(null),[v,x]=E.useState(null),{data:M}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),{data:w}=At({queryKey:["smart-plugs"],queryFn:Ue.getSmartPlugs});E.useEffect(()=>{const k=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const T=Tt({mutationFn:()=>Ue.testSmartPlugConnection(a,l||null,u||null),onSuccess:k=>{y(k),x(null),!i&&k.device_name&&s(k.device_name)},onError:k=>{y(null),x(k.message)}}),A=Tt({mutationFn:k=>Ue.createSmartPlug(k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),P=Tt({mutationFn:k=>Ue.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),C=M?.filter(k=>!w?.some(I=>I.printer_id===k.id&&I.id!==t?.id)),j=k=>{if(k.preventDefault(),x(null),!i.trim()){x("Name is required");return}if(!a.trim()){x("IP address is required");return}const F={name:i.trim(),ip_address:a.trim(),username:l.trim()||null,password:u.trim()||null,printer_id:g};r?P.mutate(F):A.mutate(F)},N=A.isPending||P.isPending;return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:k=>k.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[v&&f.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",value:a,onChange:k=>{o(k.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),f.jsxs(We,{type:"button",variant:"secondary",onClick:()=>T.mutate(),disabled:!a.trim()||T.isPending,children:[T.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(S9,{className:"w-4 h-4"}),"Test"]})]})]}),b&&f.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${b.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:b.success?f.jsxs(f.Fragment,{children:[f.jsx(mc,{className:"w-5 h-5"}),f.jsxs("div",{children:[f.jsx("p",{className:"font-medium",children:"Connected!"}),f.jsxs("p",{className:"text-sm opacity-80",children:[b.device_name&&`Device: ${b.device_name} - `,"State: ",b.state]})]})]}):f.jsxs(f.Fragment,{children:[f.jsx(tk,{className:"w-5 h-5"}),f.jsx("span",{children:"Connection failed"})]})}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),f.jsx("input",{type:"text",value:i,onChange:k=>s(k.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),f.jsx("input",{type:"text",value:l,onChange:k=>c(k.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),f.jsx("input",{type:"password",value:u,onChange:k=>h(k.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),f.jsxs("select",{value:g??"",onChange:k=>m(k.target.value?Number(k.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"",children:"No printer (manual control only)"}),C?.map(k=>f.jsx("option",{value:k.id,children:k.name},k.id))]}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsxs(We,{type:"submit",disabled:N,className:"flex-1",children:[N?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(Xo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Mr({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return f.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-9 h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:f.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const wVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email"};function MVe({provider:t,onEdit:e}){const n=Rn(),[r,i]=E.useState(!1),[s,a]=E.useState(!1),[o,l]=E.useState(null),{data:c}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),u=c?.find(y=>y.id===t.printer_id),h=Tt({mutationFn:y=>Ue.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=Tt({mutationFn:()=>Ue.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=Tt({mutationFn:()=>Ue.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),b=y=>y||"";return f.jsxs(f.Fragment,{children:[f.jsx(Ft,{className:"relative",children:f.jsxs($t,{className:"p-4",children:[f.jsxs("div",{className:"flex items-start justify-between mb-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:f.jsx(S_,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),f.jsxs("div",{children:[f.jsx("h3",{className:"font-medium text-white",children:t.name}),f.jsx("p",{className:"text-sm text-bambu-gray",children:wVe[t.provider_type]||t.provider_type})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&f.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&f.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),u&&f.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),f.jsx("span",{className:"text-sm text-white",children:u.name})]}),!u&&!t.printer_id&&f.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:f.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),f.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&f.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&f.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&f.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&f.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&f.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&f.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&f.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&f.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&&f.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&f.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[f.jsx(J_,{className:"w-3 h-3"}),"Quiet"]})]}),f.jsx("div",{className:"mb-3",children:f.jsxs(We,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(g9,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&f.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?f.jsx(mc,{className:"w-4 h-4"}):f.jsx(V0,{className:"w-4 h-4"}),f.jsx("span",{children:o.message})]}),f.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx(ow,{className:"w-4 h-4"}),"Event Settings"]}),s?f.jsx(l9,{className:"w-4 h-4"}):f.jsx($0,{className:"w-4 h-4"})]}),s&&f.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Enabled"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),f.jsx(Mr,{checked:t.enabled,onChange:y=>h.mutate({enabled:y})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Started"}),f.jsx(Mr,{checked:t.on_print_start,onChange:y=>h.mutate({on_print_start:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),f.jsx(Mr,{checked:t.on_print_complete,onChange:y=>h.mutate({on_print_complete:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),f.jsx(Mr,{checked:t.on_print_failed,onChange:y=>h.mutate({on_print_failed:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),f.jsx(Mr,{checked:t.on_print_stopped,onChange:y=>h.mutate({on_print_stopped:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),f.jsx(Mr,{checked:t.on_print_progress,onChange:y=>h.mutate({on_print_progress:y})})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),f.jsx(Mr,{checked:t.on_printer_offline,onChange:y=>h.mutate({on_printer_offline:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),f.jsx(Mr,{checked:t.on_printer_error,onChange:y=>h.mutate({on_printer_error:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),f.jsx(Mr,{checked:t.on_filament_low,onChange:y=>h.mutate({on_filament_low:y})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),f.jsx(Mr,{checked:t.on_maintenance_due??!1,onChange:y=>h.mutate({on_maintenance_due:y})})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(J_,{className:"w-4 h-4 text-purple-400"}),f.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),f.jsx(Mr,{checked:t.quiet_hours_enabled,onChange:y=>h.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&f.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[f.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Pi,{className:"w-4 h-4 text-bambu-gray"}),f.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(t.quiet_hours_end)||"07:00"]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),f.jsxs("div",{className:"flex gap-2 pt-2",children:[f.jsxs(We,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[f.jsx(ek,{className:"w-4 h-4"}),"Edit"]}),f.jsx(We,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:f.jsx(fr,{className:"w-4 h-4"})})]})]})]})}),r&&f.jsx(zs,{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 _G=[{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"email",label:"Email",description:"SMTP email notifications"}];function EVe({provider:t,onClose:e}){const n=Rn(),r=!!t,[i,s]=E.useState(t?.name||""),[a,o]=E.useState(t?.provider_type||"ntfy"),[l,c]=E.useState(t?.printer_id||null),[u,h]=E.useState(t?.quiet_hours_enabled||!1),[g,m]=E.useState(t?.quiet_hours_start||"22:00"),[b,y]=E.useState(t?.quiet_hours_end||"07:00"),[v,x]=E.useState(t?.on_print_start??!1),[M,w]=E.useState(t?.on_print_complete??!0),[T,A]=E.useState(t?.on_print_failed??!0),[P,C]=E.useState(t?.on_print_stopped??!0),[j,N]=E.useState(t?.on_print_progress??!1),[k,F]=E.useState(t?.on_printer_offline??!1),[I,W]=E.useState(t?.on_printer_error??!1),[D,$]=E.useState(t?.on_filament_low??!1),[G,V]=E.useState(t?.on_maintenance_due??!1),[Z,K]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([Le,B])=>[Le,String(B)])):{}),[ee,H]=E.useState(null),[Y,te]=E.useState(null),{data:ae}=At({queryKey:["printers"],queryFn:Ue.getPrinters});E.useEffect(()=>{const Le=B=>{B.key==="Escape"&&e()};return window.addEventListener("keydown",Le),()=>window.removeEventListener("keydown",Le)},[e]);const fe=Tt({mutationFn:()=>Ue.testNotificationConfig({provider_type:a,config:Z}),onSuccess:Le=>{H(Le),te(null)},onError:Le=>{H({success:!1,message:Le.message})}}),Q=Tt({mutationFn:Le=>Ue.createNotificationProvider(Le),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Le=>{te(Le.message)}}),me=Tt({mutationFn:Le=>Ue.updateNotificationProvider(t.id,Le),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:Le=>{te(Le.message)}}),Ee=Le=>{if(Le.preventDefault(),te(null),!i.trim()){te("Name is required");return}const B=De(a);for(const ie of B)if(!Z[ie.key]?.trim()){te(`${ie.label} is required`);return}const z={name:i.trim(),provider_type:a,config:Z,printer_id:l,quiet_hours_enabled:u,quiet_hours_start:u?g:null,quiet_hours_end:u?b:null,on_print_start:v,on_print_complete:M,on_print_failed:T,on_print_stopped:P,on_print_progress:j,on_printer_offline:k,on_printer_error:I,on_filament_low:D,on_maintenance_due:G};r?me.mutate(z):Q.mutate(z)},he=Q.isPending||me.isPending,we=Le=>{switch(Le){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambutrack",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];default:return[]}},De=Le=>we(Le).filter(B=>B.required),de=we(a);return f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:Le=>Le.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),f.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:Ee,className:"p-6 space-y-4",children:[Y&&f.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Y}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),f.jsx("input",{type:"text",value:i,onChange:Le=>s(Le.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),f.jsx("select",{value:a,onChange:Le=>{o(Le.target.value),K({}),H(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:_G.map(Le=>f.jsx("option",{value:Le.value,children:Le.label},Le.value))}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:_G.find(Le=>Le.value===a)?.description})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),de.map(Le=>f.jsxs("div",{children:[f.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[Le.label," ",Le.required&&"*"]}),Le.type==="select"&&Le.options?f.jsx("select",{value:Z[Le.key]||Le.options[0]?.value||"",onChange:B=>{K({...Z,[Le.key]:B.target.value}),H(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:Le.options.map(B=>f.jsx("option",{value:B.value,children:B.label},B.value))}):f.jsx("input",{type:Le.type,value:Z[Le.key]||"",onChange:B=>{K({...Z,[Le.key]:B.target.value}),H(null)},placeholder:Le.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"})]},Le.key))]}),f.jsx("div",{className:"flex gap-2",children:f.jsxs(We,{type:"button",variant:"secondary",onClick:()=>{H(null),fe.mutate()},disabled:fe.isPending||!Z[De(a)[0]?.key],className:"flex-1",children:[fe.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(g9,{className:"w-4 h-4"}),"Test Configuration"]})}),ee&&f.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ee.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:ee.success?f.jsxs(f.Fragment,{children:[f.jsx(mc,{className:"w-5 h-5"}),f.jsx("span",{children:ee.message})]}):f.jsxs(f.Fragment,{children:[f.jsx(V0,{className:"w-5 h-5"}),f.jsx("span",{children:ee.message})]})}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),f.jsxs("select",{value:l??"",onChange:Le=>c(Le.target.value?Number(Le.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"",children:"All printers"}),ae?.map(Le=>f.jsx("option",{value:Le.id,children:Le.name},Le.id))]}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),f.jsx(Mr,{checked:u,onChange:h})]}),u&&f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),f.jsx("input",{type:"time",value:g,onChange:Le=>m(Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),f.jsx("input",{type:"time",value:b,onChange:Le=>y(Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),f.jsxs("div",{className:"space-y-3",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),f.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[f.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),f.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Start"}),f.jsx(Mr,{checked:v,onChange:x})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Complete"}),f.jsx(Mr,{checked:M,onChange:w})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Failed"}),f.jsx(Mr,{checked:T,onChange:A})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Stopped"}),f.jsx(Mr,{checked:P,onChange:C})]}),f.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-sm text-white",children:"Progress"}),f.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),f.jsx(Mr,{checked:j,onChange:N})]})]})]}),f.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[f.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),f.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Offline"}),f.jsx(Mr,{checked:k,onChange:F})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Error"}),f.jsx(Mr,{checked:I,onChange:W})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),f.jsx(Mr,{checked:D,onChange:$})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),f.jsx(Mr,{checked:G,onChange:V})]})]})]})]}),f.jsxs("div",{className:"flex gap-3 pt-2",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),f.jsxs(We,{type:"submit",disabled:he,className:"flex-1",children:[he?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(Xo,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function AVe({template:t,onClose:e}){const n=Rn(),r=E.useRef(null),[i,s]=E.useState(t.title_template),[a,o]=E.useState(t.body_template),[l,c]=E.useState(null),[u,h]=E.useState(!0),{data:g}=At({queryKey:["template-variables"],queryFn:Ue.getTemplateVariables}),m=g?.find(A=>A.event_type===t.event_type),{data:b,isLoading:y}=At({queryKey:["template-preview",t.event_type,i,a],queryFn:()=>Ue.previewTemplate({event_type:t.event_type,title_template:i,body_template:a}),enabled:u&&i.length>0&&a.length>0});E.useEffect(()=>{const A=P=>{P.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e]);const v=Tt({mutationFn:A=>Ue.updateNotificationTemplate(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:A=>{c(A.message)}}),x=Tt({mutationFn:()=>Ue.resetNotificationTemplate(t.id),onSuccess:A=>{s(A.title_template),o(A.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:A=>{c(A.message)}}),M=A=>{if(A.preventDefault(),c(null),!i.trim()){c("Title is required");return}if(!a.trim()){c("Body is required");return}v.mutate({title_template:i,body_template:a})},w=A=>{const P=r.current;if(!P)return;const C=P.selectionStart,j=P.selectionEnd,N=a,k=N.substring(0,C),F=N.substring(j),I=k+`{${A}}`+F;o(I),setTimeout(()=>{P.focus();const W=C+A.length+2;P.setSelectionRange(W,W)},0)},T=i!==t.title_template||a!==t.body_template;return f.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:f.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),f.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:f.jsx(tn,{className:"w-5 h-5 text-bambu-gray"})})]}),f.jsxs("form",{onSubmit:M,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[l&&f.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:l}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),f.jsx("input",{type:"text",value:i,onChange:A=>s(A.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),f.jsx("textarea",{ref:r,value:a,onChange:A=>o(A.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),f.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(A=>f.jsxs("button",{type:"button",onClick:()=>w(A),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[f.jsx(ai,{className:"w-3 h-3"}),A]},A))}),f.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[f.jsx(Zx,{className:"w-4 h-4"}),"Live Preview"]}),f.jsx("button",{type:"button",onClick:()=>h(!u),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:u?"Hide":"Show"})]}),u&&f.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?f.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[f.jsx(Vt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):b?f.jsxs(f.Fragment,{children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),f.jsx("div",{className:"text-white font-medium",children:b.title})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),f.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:b.body})]})]}):f.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),f.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[f.jsxs(We,{type:"button",variant:"ghost",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-orange-400 hover:text-orange-300",children:[x.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin mr-2"}):f.jsx(G0,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),f.jsxs(We,{onClick:M,disabled:v.isPending||!T,children:[v.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin mr-2"}):f.jsx(Xo,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}async function TVe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function CVe(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 NVe(){const t=Rn(),[e,n]=E.useState(!1),[r,i]=E.useState(""),[s,a]=E.useState("auto"),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[h,g]=E.useState("all"),{data:m,isLoading:b}=At({queryKey:["spoolman-settings"],queryFn:TVe}),{data:y,isLoading:v,refetch:x}=At({queryKey:["spoolman-status"],queryFn:Ue.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=At({queryKey:["printers"],queryFn:Ue.getPrinters});E.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),a(m.spoolman_sync_mode||"auto"))},[m]),E.useEffect(()=>{if(m){const I=m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==s;l(I)}},[m,e,r,s]);const w=Tt({mutationFn:()=>CVe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!1),u(!0),setTimeout(()=>u(!1),2e3)}}),T=Tt({mutationFn:Ue.connectSpoolman,onSuccess:()=>{x()}}),A=Tt({mutationFn:Ue.disconnectSpoolman,onSuccess:()=>{x()}}),P=Tt({mutationFn:Ue.syncAllPrintersAms,onSuccess:I=>{I.success}}),C=Tt({mutationFn:I=>Ue.syncPrinterAms(I),onSuccess:I=>{I.success}}),j=()=>{h==="all"?P.mutate():C.mutate(h)},N=P.isPending||C.isPending,k=h==="all"?P.data:C.data,F=h==="all"?P.isSuccess:C.isSuccess;return b?f.jsxs(Ft,{children:[f.jsx(qd,{children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(nF,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),f.jsx($t,{children:f.jsx("div",{className:"flex justify-center py-8",children:f.jsx(Vt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):f.jsxs(Ft,{children:[f.jsx(qd,{children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(nF,{className:"w-5 h-5 text-bambu-green"}),f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),o&&f.jsx(We,{size:"sm",onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):c?f.jsx(Xp,{className:"w-4 h-4"}):"Save"})]})}),f.jsxs($t,{className:"space-y-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Enable Spoolman"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:e,onChange:I=>n(I.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),f.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:I=>i(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),f.jsxs("select",{value:s,onChange:I=>a(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[f.jsx("option",{value:"auto",children:"Automatic"}),f.jsx("option",{value:"manual",children:"Manual Only"})]}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&f.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?f.jsx(Vt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?f.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[f.jsx(Xp,{className:"w-4 h-4"}),"Connected"]}):f.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[f.jsx(tn,{className:"w-4 h-4"}),"Disconnected"]})]}),f.jsx("div",{className:"flex gap-2",children:y?.connected?f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>A.mutate(),disabled:A.isPending,children:[A.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(Eoe,{className:"w-4 h-4"}),"Disconnect"]}):f.jsxs(We,{size:"sm",onClick:()=>T.mutate(),disabled:T.isPending||!r,children:[T.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(Toe,{className:"w-4 h-4"}),"Connect"]})})]}),T.isError&&f.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:T.error.message}),y?.connected&&f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsxs("select",{value:h,onChange:I=>g(I.target.value==="all"?"all":Number(I.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[f.jsx("option",{value:"all",children:"All Printers"}),M?.map(I=>f.jsx("option",{value:I.id,children:I.name},I.id))]}),f.jsx($0,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:j,disabled:N,children:[N?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(Ka,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&k&&f.jsx("div",{className:`mt-2 p-2 rounded text-sm ${k.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:k.success?`Synced ${k.synced_count} trays successfully`:`Synced ${k.synced_count} trays with ${k.errors.length} errors`})]})]})]})}function RVe(){const t=Rn(),{t:e,i18n:n}=IP(),{showToast:r}=Ki(),[i,s]=E.useState(null),[a,o]=E.useState(!1),[l,c]=E.useState(null),[u,h]=E.useState(!1),[g,m]=E.useState(null),[b,y]=E.useState(null),[v,x]=E.useState(E9()),[M,w]=E.useState("general"),T=Q=>{x(Q),dce(Q)},A=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:P,isLoading:C}=At({queryKey:["settings"],queryFn:Ue.getSettings}),{data:j,isLoading:N}=At({queryKey:["smart-plugs"],queryFn:Ue.getSmartPlugs}),{data:k,isLoading:F}=At({queryKey:["notification-providers"],queryFn:Ue.getNotificationProviders}),{data:I,isLoading:W}=At({queryKey:["notification-templates"],queryFn:Ue.getNotificationTemplates}),{data:D}=At({queryKey:["ffmpeg-status"],queryFn:Ue.checkFfmpeg}),{data:$}=At({queryKey:["version"],queryFn:Ue.getVersion}),{data:G,refetch:V,isRefetching:Z}=At({queryKey:["updateCheck"],queryFn:Ue.checkForUpdates,staleTime:300*1e3}),{data:K,refetch:ee}=At({queryKey:["updateStatus"],queryFn:Ue.getUpdateStatus,refetchInterval:Q=>{const me=Q.state.data;return me?.status==="downloading"||me?.status==="installing"?1e3:!1}}),H=Tt({mutationFn:Ue.applyUpdate,onSuccess:()=>{ee()}}),Y=E.useRef(null),te=E.useRef(!0);E.useEffect(()=>{P&&!i&&(s(P),setTimeout(()=>{te.current=!1},100))},[P,i]);const ae=Tt({mutationFn:Ue.updateSettings,onSuccess:Q=>{t.setQueryData(["settings"],Q),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Q=>{r(`Failed to save: ${Q.message}`,"error")}});E.useEffect(()=>{if(!(te.current||!i||!P||!(P.auto_archive!==i.auto_archive||P.save_thumbnails!==i.save_thumbnails||P.capture_finish_photo!==i.capture_finish_photo||P.default_filament_cost!==i.default_filament_cost||P.currency!==i.currency||P.energy_cost_per_kwh!==i.energy_cost_per_kwh||P.energy_tracking_mode!==i.energy_tracking_mode||P.check_updates!==i.check_updates||P.notification_language!==i.notification_language||P.ams_humidity_good!==i.ams_humidity_good||P.ams_humidity_fair!==i.ams_humidity_fair||P.ams_temp_good!==i.ams_temp_good||P.ams_temp_fair!==i.ams_temp_fair)))return Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{ae.mutate(i)},500),()=>{Y.current&&clearTimeout(Y.current)}},[i,P,ae]);const fe=E.useCallback((Q,me)=>{s(Ee=>Ee?{...Ee,[Q]:me}:null)},[]);return C||!i?f.jsx("div",{className:"p-8 flex justify-center",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"mb-8",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),f.jsx("p",{className:"text-bambu-gray",children:"Configure Bambusy"})]}),f.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[f.jsx("button",{onClick:()=>w("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${M==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),f.jsxs("button",{onClick:()=>w("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${M==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(w_,{className:"w-4 h-4"}),"Smart Plugs",j&&j.length>0&&f.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:j.length})]}),f.jsxs("button",{onClick:()=>w("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${M==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(S_,{className:"w-4 h-4"}),"Notifications",k&&k.length>0&&f.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:k.length})]})]}),M==="general"&&f.jsxs("div",{className:"flex gap-8",children:[f.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[f.jsxs(Ft,{children:[f.jsx(qd,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),f.jsxs($t,{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Auto-archive prints"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:Q=>fe("auto_archive",Q.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Save thumbnails"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:Q=>fe("save_thumbnails",Q.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Capture finish photo"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:Q=>fe("capture_finish_photo",Q.target.checked),className:"sr-only peer"}),f.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),i.capture_finish_photo&&D&&!D.installed&&f.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[f.jsx(Ao,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),f.jsxs("div",{className:"text-sm",children:[f.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),f.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",f.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",f.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),f.jsxs(Ft,{children:[f.jsx(qd,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),f.jsxs($t,{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),f.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:Q=>fe("default_filament_cost",parseFloat(Q.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),f.jsxs("select",{value:i.currency,onChange:Q=>fe("currency",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"USD",children:"USD ($)"}),f.jsx("option",{value:"EUR",children:"EUR (€)"}),f.jsx("option",{value:"GBP",children:"GBP (£)"}),f.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),f.jsx("option",{value:"JPY",children:"JPY (¥)"}),f.jsx("option",{value:"CNY",children:"CNY (¥)"}),f.jsx("option",{value:"CAD",children:"CAD ($)"}),f.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),f.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:Q=>fe("energy_cost_per_kwh",parseFloat(Q.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),f.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:Q=>fe("energy_tracking_mode",Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"print",children:"Prints Only"}),f.jsx("option",{value:"total",children:"Total Consumption"})]}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),f.jsxs(Ft,{children:[f.jsx(qd,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),f.jsxs($t,{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[f.jsx(Q_,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),f.jsx("select",{value:n.language,onChange:Q=>n.changeLanguage(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:IU.map(Q=>f.jsxs("option",{value:Q.code,children:[Q.nativeName," (",Q.name,")"]},Q.code))}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),f.jsx("select",{value:v,onChange:Q=>T(Q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:M_.map(Q=>f.jsx("option",{value:Q.to,children:e(Q.labelKey)},Q.id))}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Sidebar order"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:A,children:[f.jsx(G0,{className:"w-4 h-4"}),"Reset"]})]})]})]})]}),f.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[f.jsxs(Ft,{children:[f.jsx(qd,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),f.jsxs($t,{className:"space-y-4",children:[f.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center gap-2 text-white",children:[f.jsx(jae,{className:"w-4 h-4 text-blue-400"}),f.jsx("span",{className:"font-medium",children:"Humidity"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_good??40,onChange:Q=>fe("ams_humidity_good",parseInt(Q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_fair??60,onChange:Q=>fe("ams_humidity_fair",parseInt(Q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),f.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-2 text-white",children:[f.jsx(Dp,{className:"w-4 h-4 text-orange-400"}),f.jsx("span",{className:"font-medium",children:"Temperature"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_good??28,onChange:Q=>fe("ams_temp_good",parseFloat(Q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_fair??35,onChange:Q=>fe("ams_temp_fair",parseFloat(Q.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"}),f.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]})]})]}),f.jsx(NVe,{})]}),f.jsx("div",{className:"space-y-6 flex-1 max-w-sm",children:f.jsxs(Ft,{children:[f.jsx(qd,{children:f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),f.jsxs($t,{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Check for updates"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),f.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:Q=>fe("check_updates",Q.target.checked),className:"sr-only peer"}),f.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.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white",children:"Current version"}),f.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",$?.version||"..."]})]}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>V(),disabled:Z,children:[Z?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(Ka,{className:"w-4 h-4"}),"Check now"]})]}),G?.update_available?f.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[f.jsxs("div",{className:"flex items-start justify-between",children:[f.jsxs("div",{children:[f.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",G.latest_version]}),G.release_name&&G.release_name!==G.latest_version&&f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:G.release_name}),G.release_notes&&f.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:G.release_notes})]}),G.release_url&&f.jsx("a",{href:G.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:f.jsx(gc,{className:"w-4 h-4"})})]}),K?.status==="downloading"||K?.status==="installing"?f.jsxs("div",{className:"mt-3",children:[f.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[f.jsx(Vt,{className:"w-4 h-4 animate-spin"}),f.jsx("span",{children:K.message})]}),f.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:f.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${K.progress}%`}})})]}):K?.status==="complete"?f.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:K.message}):K?.status==="error"?f.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:K.error||K.message}):f.jsxs(We,{className:"mt-3",onClick:()=>H.mutate(),disabled:H.isPending,children:[H.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(tl,{className:"w-4 h-4"}),"Install Update"]})]}):G?.error?f.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: ",G.error]}):G&&!G.update_available?f.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]})})]}),M==="plugs"&&f.jsxs("div",{className:"max-w-4xl",children:[f.jsxs("div",{className:"flex items-center justify-between mb-6",children:[f.jsxs("div",{children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(w_,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),f.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."})]}),f.jsxs(We,{onClick:()=>{c(null),o(!0)},children:[f.jsx(ai,{className:"w-4 h-4"}),"Add Smart Plug"]})]}),N?f.jsx("div",{className:"flex justify-center py-12",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):j&&j.length>0?f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j.map(Q=>f.jsx(_Ve,{plug:Q,onEdit:me=>{c(me),o(!0)}},Q.id))}):f.jsx(Ft,{children:f.jsx($t,{className:"py-12",children:f.jsxs("div",{className:"text-center text-bambu-gray",children:[f.jsx(w_,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),f.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),f.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),f.jsxs(We,{onClick:()=>{c(null),o(!0)},children:[f.jsx(ai,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),M==="notifications"&&f.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(S_,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),f.jsxs(We,{size:"sm",onClick:()=>{m(null),h(!0)},children:[f.jsx(ai,{className:"w-4 h-4"}),"Add"]})]}),f.jsx(Ft,{className:"mb-4",children:f.jsx($t,{className:"py-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),f.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),f.jsx("select",{value:i.notification_language||"en",onChange:Q=>fe("notification_language",Q.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:IU.map(Q=>f.jsx("option",{value:Q.code,children:Q.nativeName},Q.code))})]})})}),F?f.jsx("div",{className:"flex justify-center py-12",children:f.jsx(Vt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):k&&k.length>0?f.jsx("div",{className:"space-y-3",children:k.map(Q=>f.jsx(MVe,{provider:Q,onEdit:me=>{m(me),h(!0)}},Q.id))}):f.jsx(Ft,{children:f.jsx($t,{className:"py-8",children:f.jsxs("div",{className:"text-center text-bambu-gray",children:[f.jsx(S_,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),f.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),f.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),f.jsxs(We,{size:"sm",onClick:()=>{m(null),h(!0)},children:[f.jsx(ai,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),f.jsxs("div",{children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[f.jsx(Pu,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),f.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),W?f.jsx("div",{className:"flex justify-center py-8",children:f.jsx(Vt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):I&&I.length>0?f.jsx("div",{className:"space-y-2",children:I.map(Q=>f.jsx(Ft,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>y(Q),children:f.jsx($t,{className:"py-2.5 px-3",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-white font-medium text-sm truncate",children:Q.name}),f.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Q.title_template})]}),f.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:me=>{me.stopPropagation(),y(Q)},children:f.jsx(ek,{className:"w-4 h-4 text-bambu-gray"})})]})})},Q.id))}):f.jsx(Ft,{children:f.jsx($t,{className:"py-8",children:f.jsxs("div",{className:"text-center text-bambu-gray",children:[f.jsx(Pu,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),f.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),a&&f.jsx(SVe,{plug:l,onClose:()=>{o(!1),c(null)}}),u&&f.jsx(EVe,{provider:g,onClose:()=>{h(!1),m(null)}}),b&&f.jsx(AVe,{template:b,onClose:()=>y(null)})]})}const dee=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},PVe=t=>t.startsWith("HH")?"HF":"S",kVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},DP=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 EN({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:a}){const o=PVe(t.nozzle_id),l=t.nozzle_diameter,c=()=>{r&&s?s():e()};return f.jsxs("div",{className:"flex items-center gap-2",children:[r&&f.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?f.jsx(Nf,{className:"w-4 h-4 text-bambu-green"}):f.jsx(Yp,{className:"w-4 h-4"})}),f.jsxs("button",{onClick:c,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:dee(t.k_value)}),f.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),a&&f.jsx("span",{title:"Has note",children:f.jsx(b9,{className:"w-3 h-3 text-yellow-500"})}),f.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),a&&f.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:a,children:["Note: ",a.length>50?a.substring(0,50)+"...":a]})]}),!r&&n&&f.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:f.jsx(Kp,{className:"w-4 h-4"})})]})}function AN({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:a=null,onClose:o,onSave:l,onSaveNote:c}){const{showToast:u}=Ki(),[h,g]=E.useState(t?.name||""),[m,b]=E.useState(t?.k_value?dee(t.k_value):"0.020"),[y,v]=E.useState(t?.filament_id||""),[x,M]=E.useState(t?.nozzle_id?kVe(t.nozzle_id):"HH00"),[w,T]=E.useState(t?.nozzle_diameter||n),[A,P]=E.useState(t?[t.extruder_id]:i?[0,1]:[0]),[C,j]=E.useState(!1),[N,k]=E.useState({current:0,total:0}),[F,I]=E.useState(s),W=ur.useMemo(()=>{const ee=new Map;for(const H of r)if(H.filament_id&&!ee.has(H.filament_id)){const Y=DP(H.name||"");ee.set(H.filament_id,{id:H.filament_id,name:Y||H.filament_id})}return Array.from(ee.values()).sort((H,Y)=>H.name.localeCompare(Y.name))},[r]),D=Tt({mutationFn:ee=>(console.log("[KProfile] Calling API..."),Ue.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),u("K-profile saved"),c&&F!==s){let H;F===""&&a?H=a:t&&t.slot_id>0?H=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:H=`name_${h}_${y}`,c(H,F)}j(!0),setTimeout(()=>{j(!1),l()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),u(ee.message,"error"),j(!1)}}),$=Tt({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),Ue.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),u("K-profile deleted"),j(!0),setTimeout(()=>{j(!1),o()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),u(ee.message,"error"),j(!1)}}),[G,V]=E.useState(!1),Z=()=>{t&&$.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},K=async ee=>{if(ee.preventDefault(),i&&!t&&A.length===0){u("Please select at least one extruder","error");return}const H=parseFloat(m).toFixed(6),Y=`${x}-${w}`;if(t||A.length===1){const ae={name:h,k_value:H,filament_id:y,nozzle_id:Y,nozzle_diameter:w,extruder_id:t?t.extruder_id:A[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),D.mutate(ae);return}j(!0),k({current:1,total:A.length});const te=A.map(ae=>({name:h,k_value:H,filament_id:y,nozzle_id:Y,nozzle_diameter:w,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${te.length} profiles in batch:`,te);try{if(await Ue.setKProfilesBatch(e,te),u(`K-profile saved to ${A.length} extruders`),c&&F){const ae=`name_${h}_${y}`;c(ae,F)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),u("Failed to save K-profiles","error"),j(!1),k({current:0,total:0});return}k({current:A.length,total:A.length}),setTimeout(()=>{j(!1),k({current:0,total:0}),l()},3e3)};return f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[f.jsxs(Ft,{className:"w-full max-w-md relative",children:[C&&f.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),f.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),f.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),f.jsxs($t,{className:"p-0",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),f.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:C,children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("form",{onSubmit:K,className:"p-4 space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),f.jsx("input",{type:"text",value:h,onChange:ee=>g(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),f.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:ee=>{const H=ee.target.value;(H===""||/^\d*\.?\d*$/.test(H))&&b(H)},onBlur:ee=>{const H=parseFloat(ee.target.value);isNaN(H)||b((Math.trunc(H*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),f.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"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),f.jsxs("select",{value:y,onChange:ee=>{const H=ee.target.value;if(v(H),!t&&H&&!h){const Y=W.find(te=>te.id===H);Y&&g(`${x==="HH00"?"HF":"S"} ${Y.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:[f.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&f.jsx("option",{value:t.filament_id,children:W.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&W.map(ee=>f.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&W.length===0&&f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),f.jsxs("select",{value:x,onChange:ee=>{const H=ee.target.value;if(M(H),!t&&y&&!h){const Y=W.find(te=>te.id===y);Y&&g(`${H==="HS00"?"HF":"S"} ${Y.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:[f.jsx("option",{value:"HH00",children:"High Flow"}),f.jsx("option",{value:"HS00",children:"Standard"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),f.jsxs("select",{value:w,onChange:ee=>T(ee.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[f.jsx("option",{value:"0.2",children:"0.2mm"}),f.jsx("option",{value:"0.4",children:"0.4mm"}),f.jsx("option",{value:"0.6",children:"0.6mm"}),f.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?f.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"}):f.jsxs("div",{className:"flex gap-4",children:[f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:A.includes(1),onChange:ee=>{ee.target.checked?P([...A,1]):P(A.filter(H=>H!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),f.jsx("span",{className:"text-white",children:"Left"})]}),f.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:A.includes(0),onChange:ee=>{ee.target.checked?P([...A,0]):P(A.filter(H=>H!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),f.jsx("span",{className:"text-white",children:"Right"})]})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),f.jsx("textarea",{value:F,onChange:ee=>I(ee.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambusy, not on the printer"})]}),f.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&f.jsx(We,{type:"button",variant:"secondary",onClick:()=>V(!0),disabled:$.isPending||C,className:"text-red-500 hover:bg-red-500/10",children:$.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"})}),f.jsx(We,{type:"button",variant:"secondary",onClick:o,disabled:C,className:"flex-1",children:"Cancel"}),f.jsxs(We,{type:"submit",disabled:D.isPending||C,className:"flex-1",children:[D.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(ZP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),G&&f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:f.jsx(Ft,{className:"w-full max-w-sm",children:f.jsxs($t,{className:"p-6",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:f.jsx(fr,{className:"w-5 h-5 text-red-500"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),f.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",f.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),f.jsxs("div",{className:"flex gap-3",children:[f.jsx(We,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),f.jsxs(We,{onClick:()=>{V(!1),Z()},disabled:$.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[$.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const b_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function DVe(){const{showToast:t}=Ki(),[e,n]=E.useState(null),[r,i]=E.useState(()=>localStorage.getItem(b_.NOZZLE_DIAMETER)||"0.4"),[s,a]=E.useState(null),[o,l]=E.useState(!1),[c,u]=E.useState(null),[h,g]=E.useState(""),[m,b]=E.useState("all"),[y,v]=E.useState("all"),[x,M]=E.useState(()=>localStorage.getItem(b_.SORT_OPTION)||"name"),[w,T]=E.useState(!1),[A,P]=E.useState(new Set),[C,j]=E.useState(!1),[N,k]=E.useState(!1),F=X=>`${X.slot_id}_${X.extruder_id}`;E.useEffect(()=>{localStorage.setItem(b_.NOZZLE_DIAMETER,r)},[r]),E.useEffect(()=>{localStorage.setItem(b_.SORT_OPTION,x)},[x]);const{data:I,isLoading:W}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),{data:D,isLoading:$,isFetching:G,error:V,refetch:Z}=At({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const X=await Ue.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",X?.profiles?.length||0,"profiles"),X},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:K}=At({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Ue.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ee,refetch:H}=At({queryKey:["kprofile-notes",e],queryFn:()=>Ue.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),Y=V?.message?.includes("not connected");E.useEffect(()=>{if(!e&&I&&I.length>0){const X=I.find(J=>J.is_active);X&&n(X.id)}},[e,I]),E.useEffect(()=>{if(e){const X=setTimeout(()=>{Z()},150);return()=>clearTimeout(X)}},[e,r]);const te=I?.filter(X=>X.is_active)||[],ae=ur.useMemo(()=>D?.profiles?D.profiles.filter(J=>{const le=h.toLowerCase(),Re=!le||J.name.toLowerCase().includes(le)||J.filament_id.toLowerCase().includes(le),Ae=m==="all"||m==="left"&&J.extruder_id===1||m==="right"&&J.extruder_id===0,se=y==="all"||y==="hf"&&J.nozzle_id.startsWith("HH")||y==="s"&&J.nozzle_id.startsWith("HS");return Re&&Ae&&se}).sort((J,le)=>{switch(x){case"k_value":return parseFloat(J.k_value)-parseFloat(le.k_value);case"filament":return DP(J.name).localeCompare(DP(le.name));case"name":default:return J.name.localeCompare(le.name)}}):[],[D?.profiles,h,m,y,x]),fe=I?.find(X=>X.id===e),Q=fe?.nozzle_count===2;E.useEffect(()=>{const X=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||s||o||c||(J.key==="r"||J.key==="R"?(J.preventDefault(),Z()):J.key==="n"||J.key==="N"?(J.preventDefault(),l(!0)):J.key==="Escape"&&w&&(J.preventDefault(),T(!1),P(new Set)))};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[s,o,c,w,Z]);const me=E.useCallback(()=>{if(!D?.profiles||D.profiles.length===0){t("No profiles to export","error");return}const X={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:r,profiles:D.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}))},J=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),Re=document.createElement("a");Re.href=le,Re.download=`kprofiles_${fe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Re),Re.click(),document.body.removeChild(Re),URL.revokeObjectURL(le),t(`Exported ${D.profiles.length} profiles`)},[D?.profiles,fe,r,t]),Ee=E.useCallback(()=>{const X=document.createElement("input");X.type="file",X.accept=".json",X.onchange=async J=>{const le=J.target.files?.[0];if(le)try{const Re=await le.text(),Ae=JSON.parse(Re);if(!Ae.profiles||!Array.isArray(Ae.profiles)){t("Invalid file format","error");return}let se=0;for(const U of Ae.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await Ue.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${r}`,nozzle_diameter:U.nozzle_diameter||r,extruder_id:U.extruder_id??0,slot_id:0}),se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",U.name,L)}t(`Imported ${se} of ${Ae.profiles.length} profiles`),Z()}catch(Re){console.error("Import error:",Re),t("Failed to parse import file","error")}},X.click()},[e,r,t,Z]),he=E.useCallback(X=>{P(J=>{const le=new Set(J);return le.has(X)?le.delete(X):le.add(X),le})},[]),we=E.useCallback(()=>{P(new Set(ae.map(X=>F(X))))},[ae,F]),De=E.useCallback(()=>{A.size!==0&&j(!0)},[A.size]),de=E.useCallback(async()=>{const X=ae.filter(le=>A.has(F(le)));k(!0);let J=0;for(const le of X)try{await Ue.deleteKProfile(e,{slot_id:le.slot_id,extruder_id:le.extruder_id,nozzle_id:le.nozzle_id,nozzle_diameter:le.nozzle_diameter,filament_id:le.filament_id,setting_id:le.setting_id}),J++,await new Promise(Re=>setTimeout(Re,300))}catch(Re){console.error("Failed to delete profile:",le.name,Re)}t(`Deleted ${J} profiles`),k(!1),j(!1),T(!1),P(new Set),Z()},[e,A,ae,t,Z,F]),Le=E.useCallback(X=>{const J=[];return X.setting_id&&J.push(X.setting_id),J.push(`slot_${X.slot_id}_${X.filament_id}_${X.extruder_id}`),J.push(`name_${X.name}_${X.filament_id}`),J},[]),B=E.useCallback(async(X,J)=>{if(e)try{await Ue.setKProfileNote(e,X,J),H()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,H,t]),z=E.useCallback(X=>{if(!ee?.notes)return{note:"",key:null};const J=Le(X);for(const le of J)if(ee.notes[le])return{note:ee.notes[le],key:le};return{note:"",key:null}},[ee,Le]),ie=E.useCallback(X=>z(X).note,[z]);return W?f.jsx("div",{className:"flex justify-center py-12",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!I||I.length===0?f.jsx(Ft,{children:f.jsxs($t,{className:"py-12 text-center",children:[f.jsx(Eo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),f.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):te.length===0?f.jsx(Ft,{children:f.jsxs($t,{className:"py-12 text-center",children:[f.jsx(nl,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),f.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):f.jsxs(f.Fragment,{children:[G&&!$&&f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[f.jsx(Vt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),f.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),f.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[f.jsxs("div",{className:"flex-1 min-w-48",children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),f.jsx("select",{value:e||"",onChange:X=>n(parseInt(X.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:te.map(X=>f.jsx("option",{value:X.id,children:X.name},X.id))})]}),f.jsxs("div",{className:"w-32",children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),f.jsxs("select",{value:r,onChange:X=>i(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"0.2",children:"0.2mm"}),f.jsx("option",{value:"0.4",children:"0.4mm"}),f.jsx("option",{value:"0.6",children:"0.6mm"}),f.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),f.jsxs("div",{className:"flex items-end gap-2",children:[f.jsxs(We,{variant:"secondary",onClick:()=>Z(),disabled:G,children:[f.jsx(Ka,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"Refresh"]}),f.jsxs(We,{onClick:()=>l(!0),children:[f.jsx(ai,{className:"w-4 h-4"}),"Add Profile"]})]})]}),f.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[f.jsxs("div",{className:"flex-1 min-w-48 relative",children:[f.jsx(Ku,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:h,onChange:X=>g(X.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"})]}),Q&&f.jsx("div",{className:"w-36",children:f.jsxs("select",{value:m,onChange:X=>b(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"all",children:"All Extruders"}),f.jsx("option",{value:"left",children:"Left Only"}),f.jsx("option",{value:"right",children:"Right Only"})]})}),f.jsx("div",{className:"w-32",children:f.jsxs("select",{value:y,onChange:X=>v(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"all",children:"All Flow"}),f.jsx("option",{value:"hf",children:"HF Only"}),f.jsx("option",{value:"s",children:"S Only"})]})}),f.jsx("div",{className:"w-32",children:f.jsxs("select",{value:x,onChange:X=>M(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"name",children:"Sort: Name"}),f.jsx("option",{value:"k_value",children:"Sort: K-Value"}),f.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),f.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[f.jsxs(We,{variant:"secondary",onClick:me,disabled:!D?.profiles?.length,title:"Export profiles to JSON",children:[f.jsx(tl,{className:"w-4 h-4"}),"Export"]}),f.jsxs(We,{variant:"secondary",onClick:Ee,title:"Import profiles from JSON",children:[f.jsx(Yu,{className:"w-4 h-4"}),"Import"]}),f.jsx("div",{className:"flex-1"}),w?f.jsxs(f.Fragment,{children:[f.jsxs(We,{variant:"secondary",onClick:we,title:"Select all visible profiles",children:[f.jsx(Nf,{className:"w-4 h-4"}),"Select All"]}),f.jsxs(We,{variant:"secondary",onClick:De,disabled:A.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${A.size} selected profiles`,children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete (",A.size,")"]}),f.jsxs(We,{variant:"secondary",onClick:()=>{T(!1),P(new Set)},children:[f.jsx(tn,{className:"w-4 h-4"}),"Cancel"]})]}):f.jsxs(We,{variant:"secondary",onClick:()=>T(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[f.jsx(Nf,{className:"w-4 h-4"}),"Select"]})]}),$?f.jsx("div",{className:"flex justify-center py-12",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Y?f.jsx(Ft,{children:f.jsxs($t,{className:"py-12 text-center",children:[f.jsx(tk,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),f.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),f.jsxs(We,{variant:"secondary",onClick:()=>Z(),children:[f.jsx(Ka,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?Q?f.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),f.jsx("div",{className:"space-y-1",children:ae.filter(X=>X.extruder_id===1).map(X=>f.jsx(EN,{profile:X,onEdit:()=>a(X),onCopy:()=>u(X),selectionMode:w,isSelected:A.has(F(X)),onToggleSelect:()=>he(F(X)),note:ie(X)},F(X)))})]}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),f.jsx("div",{className:"space-y-1",children:ae.filter(X=>X.extruder_id===0).map(X=>f.jsx(EN,{profile:X,onEdit:()=>a(X),onCopy:()=>u(X),selectionMode:w,isSelected:A.has(F(X)),onToggleSelect:()=>he(F(X)),note:ie(X)},F(X)))})]})]}):f.jsx("div",{className:"space-y-1",children:ae.map(X=>f.jsx(EN,{profile:X,onEdit:()=>a(X),onCopy:()=>u(X),selectionMode:w,isSelected:A.has(F(X)),onToggleSelect:()=>he(F(X)),note:ie(X)},F(X)))}):h||m!=="all"||y!=="all"?f.jsx(Ft,{children:f.jsxs($t,{className:"py-12 text-center",children:[f.jsx(Ku,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),f.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):f.jsx(Ft,{children:f.jsxs($t,{className:"py-12 text-center",children:[f.jsx(ZP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),f.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),f.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),f.jsxs(We,{onClick:()=>l(!0),children:[f.jsx(ai,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:X,key:J}=z(s);return f.jsx(AN,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:K?.profiles||D?.profiles,isDualNozzle:Q,initialNote:X,initialNoteKey:J,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),Z()},onSave:()=>{a(null),Z()}})})(),o&&e&&f.jsx(AN,{printerId:e,nozzleDiameter:r,existingProfiles:K?.profiles||D?.profiles,isDualNozzle:Q,onSaveNote:B,onClose:()=>{l(!1),Z()},onSave:()=>{l(!1),Z()}}),c&&e&&f.jsx(AN,{printerId:e,nozzleDiameter:r,existingProfiles:K?.profiles||D?.profiles,isDualNozzle:Q,onSaveNote:B,profile:{...c,slot_id:0,name:`${c.name} (Copy)`},onClose:()=>{u(null),Z()},onSave:()=>{u(null),Z()}}),C&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ft,{className:"w-full max-w-sm",children:f.jsxs($t,{className:"p-6",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:f.jsx(fr,{className:"w-5 h-5 text-red-500"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),f.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",f.jsx("span",{className:"text-white font-medium",children:A.size})," selected profiles from the printer?"]}),f.jsxs("div",{className:"flex gap-3",children:[f.jsx(We,{variant:"secondary",onClick:()=>j(!1),disabled:N,className:"flex-1",children:"Cancel"}),f.jsxs(We,{onClick:de,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function ML(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),a=s?(s[1]||s[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),l=o?o[1]+"mm":null,c=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),u=c?c[1].toUpperCase():null;return{printer:i,nozzle:a,layerHeight:l,filamentType:u}}function F0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function OVe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),s=Math.floor(r/36e5),a=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a<7?`${a}d ago`:e.toLocaleDateString()}function LVe({onSuccess:t}){const{showToast:e}=Ki(),[n,r]=E.useState("email"),[i,s]=E.useState(""),[a,o]=E.useState(""),[l,c]=E.useState(""),[u,h]=E.useState(""),[g,m]=E.useState("global"),b=Tt({mutationFn:()=>Ue.cloudLogin(i,a,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=Tt({mutationFn:()=>Ue.cloudVerify(i,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=Tt({mutationFn:()=>Ue.cloudSetToken(u),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),x=w=>{w.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},M=b.isPending||y.isPending||v.isPending;return f.jsx(Ft,{className:"max-w-md mx-auto",children:f.jsxs($t,{children:[f.jsxs("div",{className:"text-center mb-6",children:[f.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:f.jsx(qP,{className:"w-6 h-6 text-bambu-green"})}),f.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),f.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),f.jsx("input",{type:"email",value:i,onChange:w=>s(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),f.jsx("input",{type:"password",value:a,onChange:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),f.jsxs("select",{value:g,onChange:w=>m(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"global",children:"Global"}),f.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),f.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),f.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),f.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),f.jsx("textarea",{value:u,onChange:w=>h(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),f.jsxs("div",{className:"flex gap-2",children:[n==="code"&&f.jsx(We,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),f.jsxs(We,{type:"submit",disabled:M,className:"flex-1",children:[M?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(aF,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&f.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[f.jsx(voe,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&f.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:f.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[f.jsx(aF,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function vp({label:t,value:e,options:n,onChange:r}){const[i,s]=E.useState(!1),a=n.find(o=>o.value===e);return f.jsxs("div",{className:"relative",children:[f.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[f.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),f.jsx("span",{children:a?.label||"All"}),f.jsx($0,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),f.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=>f.jsxs("button",{onClick:()=>{r(o.value),s(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[f.jsx("span",{children:o.label}),o.count!==void 0&&f.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function IVe(){const[t,e]=E.useState(!1);E.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?f.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:f.jsx(Wp,{className:"w-5 h-5"})}):null}function TN({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:a}){const o=ML(t.name),l=F0(t.setting_id);return f.jsxs("div",{className:"flex items-center gap-2 group",children:[f.jsx("button",{onClick:e,disabled:a,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":a?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!a?"cursor-pointer":""}`,children:f.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&f.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&l&&f.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),f.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),f.jsx("button",{onClick:c=>{c.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:f.jsx(Kp,{className:"w-4 h-4"})})]})}function OP(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(s=>n+" "+s).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+OP(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([s,a])=>n+" "+JSON.stringify(s)+": "+OP(a,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function jVe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:s}=Ki(),a=Rn(),[o,l]=E.useState(!1),{data:c,isLoading:u}=At({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Ue.getCloudSettingDetail(t.setting_id)}),h=Tt({mutationFn:()=>Ue.deleteCloudSetting(t.setting_id),onSuccess:()=>{s("Preset deleted"),a.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>s(b.message,"error")}),g=F0(t.setting_id),m=ML(t.name,c?.setting?.inherits);return f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:f.jsx(Ft,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:f.jsxs($t,{className:"p-0 flex flex-col min-h-0 flex-1",children:[f.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),f.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[f.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"•"}),f.jsx("span",{children:m.printer})]})]})]}),f.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:u?f.jsx("div",{className:"flex items-center justify-center py-16",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c?f.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:OP(c)}):f.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?f.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[f.jsx(Ao,{className:"w-5 h-5"}),f.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),f.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(We,{variant:"secondary",onClick:()=>l(!1),disabled:h.isPending,className:"flex-1",children:"Cancel"}),f.jsxs(We,{variant:"danger",onClick:()=>h.mutate(),disabled:h.isPending,className:"flex-1",children:[h.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]}):f.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:f.jsxs("div",{className:"flex gap-2",children:[f.jsx(We,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),f.jsxs(We,{variant:"secondary",onClick:r,children:[f.jsx(Kp,{className:"w-4 h-4"}),"Duplicate"]}),g&&f.jsxs(f.Fragment,{children:[f.jsxs(We,{variant:"secondary",onClick:i,disabled:u||!c,children:[f.jsx(Cf,{className:"w-4 h-4"}),"Edit"]}),f.jsx(We,{variant:"danger",onClick:()=>l(!0),children:f.jsx(fr,{className:"w-4 h-4"})})]})]})})]})})})}function fee(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function hee(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function UVe({onClose:t,onApply:e}){const{showToast:n}=Ki(),[r,i]=E.useState(fee),[s,a]=E.useState("all"),[o,l]=E.useState(null),[c,u]=E.useState(""),[h,g]=E.useState(""),[m,b]=E.useState("{}"),[y,v]=E.useState(null),[x,M]=E.useState(null),w=s==="all"?r:r.filter(I=>I.type===s),T=I=>{i(I),hee(I)},A=I=>{const W=r.filter(D=>D.id!==I);T(W),M(null),n("Template deleted")},P=I=>{l(I.id),u(I.name),g(I.description),b(JSON.stringify(I.settings,null,2)),v(null)},C=()=>{if(!(!o||!c.trim()))try{const I=JSON.parse(m),W=r.map(D=>D.id===o?{...D,name:c.trim(),description:h.trim(),settings:I}:D);T(W),l(null),n("Template updated")}catch(I){v(I.message)}},j=()=>{l(null),u(""),g(""),b("{}"),v(null)},N=I=>{const W=r.map(D=>D.id===I?{...D,showInModal:!D.showInModal}:D);T(W)},k={filament:{label:"Filament",icon:XP,color:"text-amber-400"},print:{label:"Process",icon:ow,color:"text-blue-400"},printer:{label:"Printer",icon:nl,color:"text-purple-400"}},F=x?r.find(I=>I.id===x):null;return E.useEffect(()=>{const I=W=>{W.key==="Escape"&&(x?M(null):o?j():t())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[x,o,t]),f.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:f.jsx(Ft,{className:"w-full max-w-md",children:f.jsxs($t,{className:"p-6",children:[f.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[f.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:f.jsx(Ao,{className:"w-6 h-6 text-red-400"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),f.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',f.jsx("span",{className:"font-medium",children:F.name}),'"?']}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(We,{variant:"secondary",onClick:()=>M(null),className:"flex-1",children:"Cancel"}),f.jsxs(We,{onClick:()=>A(x),className:"flex-1 bg-red-500 hover:bg-red-600",children:[f.jsx(fr,{className:"w-4 h-4"}),"Delete"]})]})]})})}),f.jsx(Ft,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:f.jsxs($t,{className:"p-0 flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(Qx,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(I=>f.jsx("button",{onClick:()=>a(I),className:`px-3 py-1 text-sm rounded-lg transition-colors ${s===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:I==="all"?"All":k[I].label},I))]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?f.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[f.jsx(Qx,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),f.jsx("p",{children:"No templates yet"}),f.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):f.jsx("div",{className:"space-y-2",children:w.map(I=>{const W=k[I.type],D=W.icon;return o===I.id?f.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[f.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[f.jsx("input",{type:"text",value:c,onChange:$=>u($.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}),f.jsx("input",{type:"text",value:h,onChange:$=>g($.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{className:"mb-3",children:[f.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),f.jsx("textarea",{value:m,onChange:$=>{b($.target.value),v(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&f.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(We,{size:"sm",onClick:C,disabled:!c.trim(),children:[f.jsx(Xo,{className:"w-4 h-4"}),"Save"]}),f.jsx(We,{size:"sm",variant:"secondary",onClick:j,children:"Cancel"})]})]},I.id):f.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:[f.jsx(D,{className:`w-5 h-5 ${W.color} flex-shrink-0`}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-sm font-medium text-white",children:I.name}),f.jsx("p",{className:"text-xs text-bambu-gray truncate",children:I.description})]}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(I.settings).length," fields"]}),f.jsx("button",{onClick:()=>N(I.id),className:`p-1 transition-colors ${I.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:I.showInModal?"Shown in modals":"Hidden in modals",children:I.showInModal?f.jsx(Zx,{className:"w-4 h-4"}):f.jsx(KP,{className:"w-4 h-4"})}),f.jsx("button",{onClick:()=>e(I),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),f.jsx("button",{onClick:()=>P(I),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:f.jsx(Cf,{className:"w-4 h-4"})}),f.jsx("button",{onClick:()=>M(I.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:f.jsx(fr,{className:"w-4 h-4"})})]},I.id)})})})]})})]})}function pee({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[s,a]=E.useState("changes"),[o,l]=E.useState(""),c=E.useMemo(()=>{const m=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const y of m){if(y==="inherits"||y==="version")continue;const v=e[y],x=n[y],M=y in e,w=y in n;let T;!M&&w?T="added":M&&!w?T="removed":JSON.stringify(v)!==JSON.stringify(x)?T="changed":T="same",b.push({key:y,left:v,right:x,status:T})}return b.sort((y,v)=>{const x={changed:0,added:1,removed:2,same:3};return x[y.status]!==x[v.status]?x[y.status]-x[v.status]:y.key.localeCompare(v.key)})},[e,n]),u=E.useMemo(()=>{let m=[...c];if(s==="changes"&&(m=m.filter(b=>b.status!=="same")),o){const b=o.toLowerCase();m=m.filter(y=>y.key.toLowerCase().includes(b)||String(y.left).toLowerCase().includes(b)||String(y.right).toLowerCase().includes(b))}return m},[c,s,o]),h=E.useMemo(()=>({added:c.filter(m=>m.status==="added").length,removed:c.filter(m=>m.status==="removed").length,changed:c.filter(m=>m.status==="changed").length,same:c.filter(m=>m.status==="same").length}),[c]),g=m=>{if(m===void 0)return"—";if(m===null)return"null";if(Array.isArray(m))return m.length===0?"[]":m.length===1?String(m[0]):m.join(", ");if(typeof m=="object")return JSON.stringify(m);const b=String(m);if(b.includes("\\n")||b.length>100){const y=b.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return E.useEffect(()=>{const m=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),f.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:f.jsx(Ft,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:f.jsxs($t,{className:"p-0 flex flex-col min-h-0 flex-1",children:[f.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[f.jsx(Ex,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),f.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:f.jsx(tn,{className:"w-5 h-5"})})]}),f.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[f.jsxs("div",{className:"text-center",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),f.jsx("p",{className:"text-white font-medium truncate",children:r})]}),f.jsxs("div",{className:"text-center",children:[f.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),f.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),f.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[f.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[f.jsx(ai,{className:"w-3.5 h-3.5"}),h.added," added"]}),f.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[f.jsx(oF,{className:"w-3.5 h-3.5"}),h.removed," removed"]}),f.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[f.jsx(BN,{className:"w-3.5 h-3.5"}),h.changed," changed"]}),f.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[f.jsx(WA,{className:"w-3.5 h-3.5"}),h.same," same"]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"relative",children:[f.jsx(Ku,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:o,onChange:m=>l(m.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),h.same>0&&f.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[f.jsx("button",{onClick:()=>a("changes"),className:`px-3 py-1.5 text-sm transition-colors ${s==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),f.jsx("button",{onClick:()=>a("all"),className:`px-3 py-1.5 text-sm transition-colors ${s==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),f.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:u.length===0?f.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[f.jsx(WA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),f.jsx("p",{children:s==="changes"?"No differences found":"No fields match the search"})]}):f.jsxs("table",{className:"w-full",children:[f.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:f.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[f.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),f.jsx("th",{className:"text-left p-3 w-1/3",children:r}),f.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),f.jsx("tbody",{children:u.map(m=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],y={added:f.jsx(ai,{className:"w-3.5 h-3.5 text-green-400"}),removed:f.jsx(oF,{className:"w-3.5 h-3.5 text-red-400"}),changed:f.jsx(BN,{className:"w-3.5 h-3.5 text-amber-400"}),same:f.jsx(WA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[m.status];return f.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[f.jsx("td",{className:"p-3",children:f.jsxs("div",{className:"flex items-center gap-2",children:[y,f.jsx("span",{className:"text-sm text-white font-mono",children:m.key})]})}),f.jsx("td",{className:"p-3",children:f.jsx("span",{className:`text-sm font-mono break-all ${m.status==="removed"?"text-red-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.left)})}),f.jsx("td",{className:"p-3",children:f.jsx("span",{className:`text-sm font-mono break-all ${m.status==="added"?"text-green-300":m.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(m.right)})})]},m.key)})})]})})]})})})}function FVe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Ki(),i=Rn(),s=!!e?.setting_id,[a,o]=E.useState("common"),[l,c]=E.useState(e?.type||"filament"),[u,h]=E.useState(e?.name?s?e.name:`${e.name} (Copy)`:""),[g,m]=E.useState(e?.base_id||""),[b,y]=E.useState(""),[v,x]=E.useState(e?.setting||{inherits:""}),[M,w]=E.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[T,A]=E.useState(null),[P,C]=E.useState(""),[j,N]=E.useState(!1),[k,F]=E.useState(""),[I,W]=E.useState(!1),[D,$]=E.useState(fee),[G,V]=E.useState(!1),[Z,K]=E.useState(""),[ee,H]=E.useState(""),[Y,te]=E.useState(!0),[ae,fe]=E.useState(null),[Q,me]=E.useState(!1),Ee=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[l]||[],[n,l]),he=E.useMemo(()=>Ee.filter(ce=>F0(ce.setting_id)),[Ee]),{data:we}=At({queryKey:["cloudFields",l],queryFn:()=>Ue.getCloudFields(l==="print"?"process":l),staleTime:1e3*60*60}),{data:De}=At({queryKey:["allPresetDetails",l,he.map(ce=>ce.setting_id).join(",")],queryFn:async()=>{const ce={};for(let Be=0;Be<he.length;Be+=5){const Ke=he.slice(Be,Be+5);(await Promise.all(Ke.map(async ue=>{try{const Je=await Ue.getCloudSettingDetail(ue.setting_id);return{id:ue.setting_id,detail:Je}}catch{return null}}))).forEach(ue=>{ue&&(ce[ue.id]=ue.detail)})}return ce},enabled:he.length>0,staleTime:1e3*60*10}),{data:de,isLoading:Le}=At({queryKey:["cloudSettingDetail",g],queryFn:()=>Ue.getCloudSettingDetail(g),enabled:!!g});E.useEffect(()=>{a!=="json"&&w(JSON.stringify(v,null,2))},[v,a]);const B=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[l]||[]).filter(Qe=>!F0(Qe.setting_id)).sort((Qe,Be)=>Qe.name.localeCompare(Be.name)),[n,l]);E.useEffect(()=>{if(!g)return;const ce=B.find(Qe=>Qe.setting_id===g);ce&&(y(ce.name),s||(x({inherits:ce.name}),w(JSON.stringify({inherits:ce.name},null,2))))},[g,B,s]);const z=E.useMemo(()=>{const ce=we?.fields||[],Qe=new Set(ce.map(ue=>ue.key)),Be=new Set,Ke=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);De&&Object.values(De).forEach(ue=>{ue?.setting&&Object.keys(ue.setting).forEach(Je=>{!Qe.has(Je)&&!Ke.has(Je)&&Be.add(Je)})}),Object.keys(v).forEach(ue=>{!Qe.has(ue)&&!Ke.has(ue)&&Be.add(ue)});const ct=Array.from(Be).sort().map(ue=>({key:ue,label:ue.replace(/_/g," ").replace(/\b\w/g,Je=>Je.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ce,...ct]},[we,De,v]),ie=z.filter(ce=>ce.label.toLowerCase().includes(P.toLowerCase())||ce.key.toLowerCase().includes(P.toLowerCase())),X=()=>{if(k.trim()){const ce=k.trim().toLowerCase().replace(/\s+/g,"_");J(ce,""),F(""),W(!1),r(`Field "${ce}" added`)}},J=(ce,Qe)=>{x(Be=>{const Ke={...Be};return Qe===""||Qe===void 0?delete Ke[ce]:Ke[ce]=Qe,Ke})},le=ce=>{x(Qe=>({...Qe,...ce.settings})),fe(ce.name),r("Template applied")},Re=()=>{if(!Z.trim())return;const ce={...v};if(delete ce.inherits,Object.keys(ce).length===0){r("No overrides to save","error");return}const Qe={id:Date.now().toString(),name:Z.trim(),description:ee.trim()||"Custom template",type:l,settings:ce,showInModal:Y},Be=[...D,Qe];$(Be),hee(Be),V(!1),K(""),H(""),te(!0),r("Template saved")},Ae=E.useMemo(()=>D.filter(ce=>ce.type===l&&ce.showInModal),[l,D]),se=ce=>{w(ce);try{const Qe=JSON.parse(ce);x(Qe),A(null)}catch(Qe){A(Qe.message)}},U=ce=>{ce.preventDefault(),N(!1);const Qe=ce.dataTransfer.files[0];if(Qe&&Qe.name.endsWith(".json")){const Be=new FileReader;Be.onload=Ke=>{try{const ct=Ke.target?.result,ue=JSON.parse(ct),Je=ue.setting||ue;x(ge=>({...ge,...Je})),w(JSON.stringify({...v,...Je},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Be.readAsText(Qe)}},L=Tt({mutationFn:()=>{const ce={...v},Qe=l==="filament"?"filament_settings_id":l==="print"?"print_settings_id":"printer_settings_id";ce[Qe]=`"${u}"`;const Be={type:l,name:u,base_id:g,setting:ce};return Ue.createCloudSetting(Be)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),ne=Tt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return Ue.updateCloudSetting(e.setting_id,{name:u,setting:v})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),ve=s?ne:L,ye=de?.setting?.inherits,xe=ye?B.find(ce=>ce.name===ye):void 0,{data:tt}=At({queryKey:["cloudSettingDetail",xe?.setting_id],queryFn:()=>Ue.getCloudSettingDetail(xe.setting_id),enabled:!!xe?.setting_id}),je=E.useMemo(()=>{const ce=tt?.setting||{},Qe=de?.setting||{},Be=g&&De?.[g]?.setting?De[g].setting:{};return{...ce,...Qe,...Be}},[g,de,tt,De]),Ye=ce=>{if(ce==null)return"";if(Array.isArray(ce)){const Qe=[...new Set(ce.map(Be=>String(Be)))];return Qe.length===1?Qe[0]:ce.join(", ")}return String(ce)},ot=ce=>{const Qe=v[ce.key],Be=je[ce.key],Ke=Ye(Be),ct=Le?"Loading...":Ke||"",ue="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(ce.type==="boolean"){const Je=Qe==="1"||Qe===void 0&&Be==="1";return f.jsx("button",{type:"button",onClick:()=>J(ce.key,Qe==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Je?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:f.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Je?"translate-x-3.5":"translate-x-0.5"}`})})}return ce.type==="select"?f.jsxs("select",{value:Qe||"",onChange:Je=>J(ce.key,Je.target.value),className:ue,children:[f.jsx("option",{value:"",children:ct}),ce.options?.map(Je=>f.jsx("option",{value:Je.value,children:Je.label},Je.value))]}):f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:ce.type==="number"?"number":"text",value:Qe!==void 0?String(Qe):"",onChange:Je=>J(ce.key,Je.target.value),step:ce.step,min:ce.min,max:ce.max,placeholder:ct,className:ue}),ce.unit&&f.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ce.unit})]})},Fe=E.useMemo(()=>de?.setting?de.setting:{},[de]);return f.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ce=>{ce.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:U,children:[Q&&g&&f.jsx(pee,{onClose:()=>me(!1),leftPreset:Fe,rightPreset:v,leftLabel:`Base: ${b||g}`,rightLabel:`Current: ${u||"New Preset"}`}),f.jsx(Ft,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:f.jsxs($t,{className:"p-0 flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-xl font-semibold text-white",children:s?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[g&&f.jsxs("button",{onClick:()=>me(!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:[f.jsx(Ex,{className:"w-4 h-4"}),"Compare"]}),f.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:f.jsx(tn,{className:"w-5 h-5"})})]})]}),j&&f.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:f.jsxs("div",{className:"text-center",children:[f.jsx(Yu,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),f.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),f.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[f.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),f.jsxs("select",{value:l,onChange:ce=>{c(ce.target.value),m("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"filament",children:"Filament"}),f.jsx("option",{value:"print",children:"Process"}),f.jsx("option",{value:"printer",children:"Printer"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),f.jsxs("select",{value:g,onChange:ce=>m(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"",children:"Select base preset..."}),B.map(ce=>f.jsx("option",{value:ce.setting_id,children:ce.name},ce.setting_id))]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),f.jsx("input",{type:"text",value:u,onChange:ce=>h(ce.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),b&&f.jsx("div",{className:"text-xs text-bambu-gray",children:f.jsxs("p",{className:"flex items-center gap-1",children:[f.jsx(Xp,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",f.jsx("span",{className:"text-white",children:b}),Le&&f.jsx(Vt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),f.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[f.jsxs("button",{onClick:()=>o("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(lF,{className:"w-4 h-4"}),"Common"]}),f.jsxs("button",{onClick:()=>o("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(JP,{className:"w-4 h-4"}),"All Fields"]}),f.jsxs("button",{onClick:()=>o("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[f.jsx(Cae,{className:"w-4 h-4"}),"JSON",T&&f.jsx(Eo,{className:"w-3 h-3 text-red-400"})]}),f.jsx("div",{className:"flex-1"}),f.jsxs("button",{onClick:()=>{const ce={name:u,type:l,base_id:g,setting:v},Qe=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),Be=URL.createObjectURL(Qe),Ke=document.createElement("a");Ke.href=Be,Ke.download=`${u||"preset"}.json`,document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),URL.revokeObjectURL(Be),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:[f.jsx(tl,{className:"w-4 h-4"}),"Export"]}),f.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:[f.jsx(Yu,{className:"w-4 h-4"}),"Import"]}),f.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ce=>{const Qe=ce.target.files?.[0];if(Qe){const Be=new FileReader;Be.onload=Ke=>{try{const ct=JSON.parse(Ke.target?.result),ue=ct.setting||ct;x(Je=>({...Je,...ue})),r("File imported")}catch{r("Invalid JSON","error")}},Be.readAsText(Qe)}}})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[a==="common"&&f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[f.jsx(Qx,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(v).filter(ce=>ce!=="inherits").length>0&&f.jsxs("button",{onClick:()=>V(!G),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[f.jsx(Xo,{className:"w-3 h-3"}),"Save as template"]})]}),G&&f.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[f.jsx("input",{type:"text",value:Z,onChange:ce=>K(ce.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),f.jsx("input",{type:"text",value:ee,onChange:ce=>H(ce.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(We,{size:"sm",onClick:Re,disabled:!Z.trim(),children:[f.jsx(Xo,{className:"w-3 h-3"}),"Save"]}),f.jsx(We,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),f.jsxs("button",{onClick:()=>te(!Y),className:`flex items-center gap-1.5 text-xs transition-colors ${Y?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[Y?f.jsx(Zx,{className:"w-3.5 h-3.5"}):f.jsx(KP,{className:"w-3.5 h-3.5"}),Y?"Show in modals":"Hidden in modals"]})]})]}),ae&&f.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:[f.jsx(Xp,{className:"w-4 h-4 text-bambu-green"}),f.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",f.jsx("span",{className:"font-medium",children:ae})]}),f.jsx("button",{onClick:()=>fe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:f.jsx(tn,{className:"w-4 h-4"})})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ae.map(ce=>f.jsxs("button",{onClick:()=>le(ce),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[f.jsx("p",{className:"text-sm font-medium text-white",children:ce.name}),f.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ce.description})]},ce.id)),Ae.length===0&&f.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."})]}),f.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),f.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:z.slice(0,10).map(ce=>f.jsxs("div",{className:"flex items-center justify-between gap-4",children:[f.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ce.label}),f.jsx("div",{className:"w-48",children:ot(ce)})]},ce.key))})]}),Object.keys(v).length>1&&f.jsxs("div",{children:[f.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),f.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([ce])=>ce!=="inherits").map(([ce,Qe])=>f.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ce,": ",String(Qe).slice(0,20),f.jsx("button",{onClick:()=>J(ce,void 0),className:"hover:text-white",children:f.jsx(tn,{className:"w-3 h-3"})})]},ce))})]})]}),a==="fields"&&f.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[f.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),f.jsx("span",{className:"text-xs text-bambu-gray",children:De?`${z.length} fields`:"Loading..."})]}),f.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[f.jsx(Ku,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:P,onChange:ce=>C(ce.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[ie.filter(ce=>!(ce.key in v)).map(ce=>{const Qe=je[ce.key],Be=Ye(Qe);return f.jsxs("div",{onClick:()=>{x(Ke=>({...Ke,[ce.key]:Be||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("p",{className:"text-sm text-white truncate",children:ce.label}),f.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ce.key})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Be&&f.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Be,children:[Be.slice(0,20),Be.length>20?"...":""]}),f.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:f.jsx(ai,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ce.key)}),ie.filter(ce=>!(ce.key in v)).length===0&&f.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:P?"No matching fields":"All fields added"})]}),f.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:I?f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",value:k,onChange:ce=>F(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&X(),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}),f.jsx(We,{size:"sm",onClick:X,disabled:!k.trim(),children:f.jsx(ai,{className:"w-4 h-4"})}),f.jsx(We,{size:"sm",variant:"secondary",onClick:()=>{W(!1),F("")},children:f.jsx(tn,{className:"w-4 h-4"})})]}):f.jsxs("button",{onClick:()=>W(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[f.jsx(ai,{className:"w-4 h-4"}),"Add custom field"]})})]}),f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[f.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),f.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(v).filter(ce=>ce!=="inherits").length," fields"]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([ce])=>ce!=="inherits").map(([ce,Qe])=>{const Be=z.find(Ke=>Ke.key===ce);return f.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-sm font-medium text-white",children:Be?.label||ce}),f.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ce})]}),f.jsx("button",{onClick:()=>J(ce,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:f.jsx(tn,{className:"w-4 h-4"})})]}),Be?ot(Be):f.jsx("input",{type:"text",value:String(Qe),onChange:Ke=>J(ce,Ke.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},ce)}),Object.keys(v).filter(ce=>ce!=="inherits").length===0&&f.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[f.jsx(lF,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),f.jsx("p",{className:"text-sm",children:"No overrides yet"}),f.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(v).filter(ce=>ce!=="inherits").length>0&&f.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:f.jsxs("button",{onClick:()=>{V(!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:[f.jsx(Xo,{className:"w-4 h-4"}),"Save as template"]})})]})]}),a==="json"&&f.jsxs("div",{className:"space-y-2",children:[T&&f.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[f.jsx(Eo,{className:"w-4 h-4"}),T]}),f.jsx("textarea",{value:M,onChange:ce=>se(ce.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${T?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),f.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),f.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[f.jsx(We,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),f.jsxs(We,{onClick:()=>ve.mutate(),disabled:ve.isPending||!u.trim()||!s&&!g||!!T,className:"flex-1",children:[ve.isPending?f.jsx(Vt,{className:"w-4 h-4 animate-spin"}):s?f.jsx(Xo,{className:"w-4 h-4"}):f.jsx(ai,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function zVe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[s,a]=E.useState(""),[o,l]=E.useState("all"),[c,u]=E.useState("all"),[h,g]=E.useState("all"),[m,b]=E.useState("all"),[y,v]=E.useState("all"),[x,M]=E.useState("all"),[w,T]=E.useState(null),[A,P]=E.useState(!1),[C,j]=E.useState(!1),[N,k]=E.useState(null),[F,I]=E.useState(null),[W,D]=E.useState(null),[$,G]=E.useState(!1),[V,Z]=E.useState([null,null]),[K,ee]=E.useState(!1),[H,Y]=E.useState(null),te=Rn(),ae=E.useMemo(()=>[...t.filament.map(ie=>({...ie,type:"filament"})),...t.printer.map(ie=>({...ie,type:"printer"})),...t.process.map(ie=>({...ie,type:"process"}))].map(ie=>({...ie,meta:ML(ie.name)})),[t]),fe=E.useMemo(()=>{const z=new Set,ie=new Set,X=new Set;return ae.forEach(J=>{J.meta.nozzle&&z.add(J.meta.nozzle),J.meta.filamentType&&ie.add(J.meta.filamentType),J.meta.layerHeight&&X.add(J.meta.layerHeight)}),{printers:i.map(J=>({id:J.id.toString(),name:J.name})),nozzles:Array.from(z).sort((J,le)=>parseFloat(J)-parseFloat(le)),filaments:Array.from(ie).sort(),layerHeights:Array.from(X).sort((J,le)=>parseFloat(J)-parseFloat(le))}},[ae,i]),Q=E.useMemo(()=>h==="all"?null:i.find(ie=>ie.id.toString()===h)?.model||null,[h,i]),me=E.useMemo(()=>ae.filter(z=>o==="all"||z.type===o).filter(z=>{if(c==="all")return!0;const ie=F0(z.setting_id);return c==="custom"?ie:!ie}).filter(z=>{if(h==="all"||!Q)return!0;const ie=z.meta.printer?.toLowerCase()||"",X=Q.toLowerCase();return ie.includes(X)||X.includes(ie)}).filter(z=>m==="all"||z.meta.nozzle===m).filter(z=>y==="all"||z.meta.filamentType===y).filter(z=>x==="all"||z.meta.layerHeight===x).filter(z=>s===""||z.name.toLowerCase().includes(s.toLowerCase())).sort((z,ie)=>z.name.localeCompare(ie.name)),[ae,o,c,h,Q,m,y,x,s]),Ee=z=>{if($){const ie=V[0]?.setting_id===z.setting_id,X=V[1]?.setting_id===z.setting_id;if(ie)Z([V[1],null]);else if(X)Z([V[0],null]);else if(!V[0])Z([z,null]);else if(V[1]){if(V[0].type!==z.type)return;Z([V[0],z])}else{if(V[0].type!==z.type)return;Z([V[0],z])}}else T(z)},he=z=>{if(V[0]?.setting_id===z.setting_id)return 0;if(V[1]?.setting_id===z.setting_id)return 1},we=async z=>{try{const ie=await Ue.getCloudSettingDetail(z.setting_id),X=z.type==="process"?"print":z.type;k({type:X,name:z.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{}}),T(null)}catch(ie){console.error("Failed to fetch preset details for duplication:",ie)}},De=async z=>{try{te.removeQueries({queryKey:["cloudSettingDetail",z.setting_id]});const ie=await Ue.getCloudSettingDetail(z.setting_id),X=z.type==="process"?"print":z.type;I({type:X,name:z.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{},setting_id:z.setting_id}),T(null)}catch(ie){console.error("Failed to fetch preset details for editing:",ie)}},de=()=>{l("all"),u("all"),g("all"),b("all"),v("all"),M("all"),a("")},Le=o!=="all"||c!=="all"||h!=="all"||m!=="all"||y!=="all"||x!=="all"||s!=="",B=t.filament.length+t.printer.length+t.process.length;return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-4 mb-6",children:[f.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsx(Ku,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),f.jsx("input",{type:"text",value:s,onChange:z=>a(z.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"})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs(We,{variant:$?"primary":"secondary",onClick:()=>{$?(G(!1),Z([null,null])):G(!0)},children:[f.jsx(Ex,{className:"w-4 h-4"}),$?"Cancel":"Compare"]}),f.jsxs(We,{variant:"secondary",onClick:()=>j(!0),children:[f.jsx(Qx,{className:"w-4 h-4"}),"Templates"]}),f.jsxs(We,{variant:"secondary",onClick:n,disabled:r,children:[f.jsx(Ka,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),f.jsxs(We,{onClick:()=>P(!0),children:[f.jsx(ai,{className:"w-4 h-4"}),"New Preset"]})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx(YP,{className:"w-4 h-4 text-bambu-gray"}),f.jsx(vp,{label:"Type",value:o,options:[{value:"all",label:"All",count:B},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:z=>l(z)}),f.jsx(vp,{label:"Owner",value:c,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:z=>u(z)}),fe.printers.length>0&&f.jsx(vp,{label:"Printer",value:h,options:[{value:"all",label:"All"},...fe.printers.map(z=>({value:z.id,label:z.name}))],onChange:g}),fe.nozzles.length>0&&f.jsx(vp,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...fe.nozzles.map(z=>({value:z,label:z}))],onChange:b}),fe.filaments.length>0&&(o==="all"||o==="filament")&&f.jsx(vp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...fe.filaments.map(z=>({value:z,label:z}))],onChange:v}),fe.layerHeights.length>0&&(o==="all"||o==="process")&&f.jsx(vp,{label:"Layer",value:x,options:[{value:"all",label:"All"},...fe.layerHeights.map(z=>({value:z,label:z}))],onChange:M}),Le&&f.jsx("button",{onClick:de,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),$&&f.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx(Ex,{className:"w-5 h-5 text-blue-400"}),f.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),f.jsx("span",{className:"text-bambu-gray",children:V[0]?`Select another ${V[0].type} preset`:"Click two presets of the same type to compare"})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[0]?V[0].name:"1. Select first"}),f.jsx(BN,{className:"w-4 h-4 text-bambu-gray"}),f.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[1]?V[1].name:"2. Select second"})]}),V[0]&&V[1]&&f.jsxs(We,{size:"sm",onClick:async()=>{try{const[z,ie]=await Promise.all([Ue.getCloudSettingDetail(V[0].setting_id),Ue.getCloudSettingDetail(V[1].setting_id)]);Y([z.setting||{},ie.setting||{}]),ee(!0)}catch{}},children:[f.jsx(Ex,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),f.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Pi,{className:"w-3 h-3"}),"Last synced: ",OVe(e.toISOString())]}),f.jsxs("span",{children:["Showing ",me.length," of ",B," presets"]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),f.jsx("span",{children:"= My preset (editable)"})]})]}),me.length===0?f.jsxs("div",{className:"text-center py-16",children:[f.jsx(Tf,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),f.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Le&&f.jsx("button",{onClick:de,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[f.jsx(XP,{className:"w-4 h-4 text-amber-400"}),f.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",me.filter(z=>z.type==="filament").length,")"]})]}),f.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[me.filter(z=>z.type==="filament").map(z=>f.jsx(TN,{setting:z,onClick:()=>Ee(z),onDuplicate:()=>we(z),compareMode:$,isCompareSelected:he(z)!==void 0,compareIndex:he(z),compareDisabled:$&&!!V[0]&&V[0].type!==z.type},z.setting_id)),me.filter(z=>z.type==="filament").length===0&&f.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[f.jsx(ow,{className:"w-4 h-4 text-blue-400"}),f.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",me.filter(z=>z.type==="process").length,")"]})]}),f.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[me.filter(z=>z.type==="process").map(z=>f.jsx(TN,{setting:z,onClick:()=>Ee(z),onDuplicate:()=>we(z),compareMode:$,isCompareSelected:he(z)!==void 0,compareIndex:he(z),compareDisabled:$&&!!V[0]&&V[0].type!==z.type},z.setting_id)),me.filter(z=>z.type==="process").length===0&&f.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[f.jsx(nl,{className:"w-4 h-4 text-purple-400"}),f.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),f.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",me.filter(z=>z.type==="printer").length,")"]})]}),f.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[me.filter(z=>z.type==="printer").map(z=>f.jsx(TN,{setting:z,onClick:()=>Ee(z),onDuplicate:()=>we(z),compareMode:$,isCompareSelected:he(z)!==void 0,compareIndex:he(z),compareDisabled:$&&!!V[0]&&V[0].type!==z.type},z.setting_id)),me.filter(z=>z.type==="printer").length===0&&f.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&f.jsx(jVe,{setting:w,onClose:()=>T(null),onDeleted:()=>T(null),onDuplicate:()=>we(w),onEdit:()=>De(w)}),(A||N||F||W)&&f.jsx(FVe,{onClose:()=>{P(!1),k(null),I(null),D(null)},initialData:F||N||(W?{type:W.type,name:"",base_id:"",setting:W.setting}:void 0),allPresets:t}),C&&f.jsx(UVe,{onClose:()=>j(!1),onApply:z=>{D({type:z.type,setting:z.settings}),j(!1)}}),K&&H&&V[0]&&V[1]&&f.jsx(pee,{onClose:()=>{ee(!1),Y(null)},leftPreset:H[0],rightPreset:H[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function BVe(){const t=Rn(),{showToast:e}=Ki(),[n,r]=E.useState("cloud"),[i,s]=E.useState(),{data:a,isLoading:o}=At({queryKey:["cloudStatus"],queryFn:Ue.getCloudStatus}),{data:l=[]}=At({queryKey:["printers"],queryFn:Ue.getPrinters}),{data:c,isLoading:u,refetch:h,dataUpdatedAt:g}=At({queryKey:["cloudSettings"],queryFn:()=>Ue.getCloudSettings(),enabled:!!a?.is_authenticated,retry:!1,staleTime:1e3*60*5});E.useEffect(()=>{g&&s(new Date(g))},[g]);const m=Tt({mutationFn:Ue.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?f.jsx("div",{className:"p-8 flex items-center justify-center min-h-[400px]",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f.jsxs("div",{className:"p-6 lg:p-8",children:[f.jsxs("div",{className:"mb-6",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),f.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),f.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[f.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:[f.jsx(qP,{className:"w-4 h-4"}),"Cloud Profiles"]}),f.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:[f.jsx(ZP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&f.jsxs(f.Fragment,{children:[a?.is_authenticated&&f.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),f.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",f.jsx("span",{className:"text-white",children:a.email})]})]}),f.jsxs(We,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[f.jsx(Ooe,{className:"w-4 h-4"}),"Logout"]})]}),a?.is_authenticated?u?f.jsx("div",{className:"flex items-center justify-center py-16",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c?f.jsx(zVe,{settings:c,lastSyncTime:i,onRefresh:()=>h(),isRefreshing:u,printers:l}):f.jsxs("div",{className:"text-center py-16",children:[f.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),f.jsx(We,{onClick:()=>h(),children:"Retry"})]}):f.jsx(LVe,{onSuccess:b})]}),n==="kprofiles"&&f.jsx(DVe,{}),f.jsx(IVe,{})]})}const Sx={Droplet:XP,Flame:toe,Ruler:lle,Sparkles:Qx,Square:Yp,Cable:rae,Wrench:Zp,Calendar:as,Timer:ku,Cog:Rae,Fan:Gae,Zap:nk,Wind:Qle,Thermometer:Dp,Layers:Tf,Box:qp,Target:y9,RefreshCw:Ka,Settings:x9,Filter:YP,CircleDot:bae};function Wx(t){return t&&Sx[t]||Zp}function bp(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 CN(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 HVe({item:t,onPerform:e,onToggle:n}){const r=Wx(t.maintenance_type_icon),i=t.interval_type||"hours",a=(()=>{if(i==="days"){const h=t.days_since_maintenance??0;return Math.max(0,Math.min(100,h/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),o=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",l=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",c=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",u=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const h=t.days_until_due??0;return t.is_due?`Overdue by ${bp(Math.abs(h),"days")}`:t.is_warning?`Due in ${bp(h,"days")}`:`${bp(h,"days")} left`}else return t.is_due?`Overdue by ${bp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${bp(t.hours_until_due,"hours")}`:`${bp(t.hours_until_due,"hours")} left`};return f.jsx("div",{className:`rounded-xl border p-4 transition-all ${c()}`,children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.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:[f.jsx(r,{className:`w-5 h-5 ${o()}`}),t.enabled&&(t.is_due||t.is_warning)&&f.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`})]}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&f.jsx("span",{title:"Time-based interval",children:f.jsx(as,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),f.jsx("div",{className:"mt-2 mb-1.5",children:f.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:f.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l()}`,style:{width:`${a}%`}})})}),f.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&f.jsx(Ao,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&f.jsx(Pi,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&f.jsx(Xp,{className:"w-3 h-3"}),u()]})]}),f.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[f.jsx(Mr,{checked:t.enabled,onChange:h=>n(t.id,h)}),f.jsxs(We,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[f.jsx(G0,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function $Ve({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,s]=E.useState(!0),[a,o]=E.useState(!1),[l,c]=E.useState(t.total_print_hours.toFixed(1)),u=[...t.maintenance_items].sort((m,b)=>m.is_due&&!b.is_due?-1:!m.is_due&&b.is_due?1:m.is_warning&&!b.is_warning?-1:!m.is_warning&&b.is_warning?1:m.maintenance_type_id-b.maintenance_type_id),h=u.find(m=>m.enabled&&(m.is_due||m.is_warning)),g=()=>{const m=parseFloat(l);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return f.jsxs(Ft,{className:"overflow-hidden",children:[f.jsxs("div",{className:"p-5",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),f.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&f.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:[f.jsx(Ao,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&f.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:[f.jsx(Pi,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&f.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:[f.jsx(Xp,{className:"w-3 h-3"}),"All good"]})]})]}),f.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?f.jsx(l9,{className:"w-4 h-4"}):f.jsx($0,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),f.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:f.jsx(ku,{className:"w-4 h-4 text-bambu-gray"})}),a?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"number",value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g(),m.key==="Escape"&&o(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),f.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),f.jsx(We,{size:"sm",onClick:g,children:"Save"}),f.jsx(We,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):f.jsxs("button",{onClick:()=>{c(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[f.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",f.jsx(t1,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),f.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),f.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),h&&f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:`p-2 rounded-lg ${h.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const m=Wx(h.maintenance_type_icon);return f.jsx(m,{className:`w-4 h-4 ${h.is_due?"text-red-400":"text-amber-400"}`})})()}),f.jsxs("div",{children:[f.jsx("div",{className:`text-sm font-medium ${h.is_due?"text-red-400":"text-amber-400"}`,children:h.maintenance_type_name}),f.jsx("div",{className:`text-xs ${h.is_due?"text-red-400/70":"text-amber-400/70"}`,children:h.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&f.jsx($t,{className:"pt-0 border-t border-bambu-dark-tertiary",children:f.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:u.map(m=>f.jsx(HVe,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function VVe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s}){const[a,o]=E.useState(null),[l,c]=E.useState(""),[u,h]=E.useState("hours"),[g,m]=E.useState(!1),[b,y]=E.useState(""),[v,x]=E.useState("100"),[M,w]=E.useState("hours"),[T,A]=E.useState("Wrench"),[P,C]=E.useState(null),[j,N]=E.useState(""),[k,F]=E.useState(""),[I,W]=E.useState("hours"),[D,$]=E.useState("Wrench"),G=te=>{C(te),N(te.name),F(te.default_interval_hours.toString()),W(te.interval_type||"hours"),$(te.icon||"Wrench")},V=()=>{P&&j.trim()&&parseFloat(k)>0&&(i(P.id,{name:j.trim(),default_interval_hours:parseFloat(k),interval_type:I,icon:D}),C(null))},Z=(te,ae,fe)=>{const Q=parseFloat(l);if(!isNaN(Q)&&Q>0){const me=Math.abs(Q-ae)<.01?null:Q;n(te,{custom_interval_hours:me,custom_interval_type:u!==fe?u:null})}o(null)},K=te=>{te.preventDefault(),b.trim()&&parseFloat(v)>0&&(r({name:b.trim(),default_interval_hours:parseFloat(v),interval_type:M,icon:T}),y(""),x("100"),w("hours"),m(!1))},ee=t?.map(te=>({printerId:te.printer_id,printerName:te.printer_name,items:te.maintenance_items.sort((ae,fe)=>ae.maintenance_type_id-fe.maintenance_type_id)})).sort((te,ae)=>te.printerName.localeCompare(ae.printerName))||[],H=e.filter(te=>te.is_system),Y=e.filter(te=>!te.is_system);return f.jsxs("div",{className:"space-y-8",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),f.jsxs(We,{onClick:()=>m(!g),children:[f.jsx(ai,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&f.jsx(Ft,{className:"mb-6",children:f.jsx($t,{className:"py-4",children:f.jsxs("form",{onSubmit:K,children:[f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[f.jsxs("div",{className:"lg:col-span-2",children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),f.jsx("input",{type:"text",value:b,onChange:te=>y(te.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),f.jsxs("select",{value:M,onChange:te=>{w(te.target.value),te.target.value==="days"?x("30"):x("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[f.jsx("option",{value:"hours",children:"Print Hours"}),f.jsx("option",{value:"days",children:"Calendar Days"})]})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",M==="days"?"days":"hours",")"]}),f.jsx("input",{type:"number",value:v,onChange:te=>x(te.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),f.jsxs("div",{className:"mt-4 flex items-end justify-between",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),f.jsx("div",{className:"flex gap-1",children:Object.keys(Sx).map(te=>{const ae=Sx[te];return f.jsx("button",{type:"button",onClick:()=>A(te),className:`p-2 rounded-lg transition-colors ${T===te?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:f.jsx(ae,{className:"w-4 h-4"})},te)})})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(We,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),f.jsx(We,{type:"submit",disabled:!b.trim(),children:"Add Type"})]})]})]})})}),f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[H.map(te=>{const ae=Wx(te.icon),fe=te.interval_type||"hours";return f.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:f.jsx(ae,{className:"w-5 h-5 text-bambu-gray"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"text-sm font-medium text-white truncate",children:te.name}),f.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?f.jsx(as,{className:"w-3 h-3"}):f.jsx(ku,{className:"w-3 h-3"}),CN(te.default_interval_hours,fe)]})]})]})},te.id)}),Y.map(te=>{const ae=Wx(te.icon),fe=te.interval_type||"hours";return P?.id===te.id?f.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:f.jsxs("div",{className:"space-y-3",children:[f.jsx("input",{type:"text",value:j,onChange:me=>N(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}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("select",{value:I,onChange:me=>W(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:[f.jsx("option",{value:"hours",children:"Print Hours"}),f.jsx("option",{value:"days",children:"Calendar Days"})]}),f.jsx("input",{type:"number",value:k,onChange:me=>F(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"})]}),f.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Sx).map(me=>{const Ee=Sx[me];return f.jsx("button",{type:"button",onClick:()=>$(me),className:`p-1.5 rounded transition-colors ${D===me?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:f.jsx(Ee,{className:"w-3.5 h-3.5"})},me)})}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(We,{size:"sm",onClick:V,disabled:!j.trim(),children:"Save"}),f.jsx(We,{size:"sm",variant:"secondary",onClick:()=>C(null),children:"Cancel"})]})]})},te.id):f.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:f.jsx(ae,{className:"w-5 h-5 text-bambu-green"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-sm font-medium text-white truncate",children:te.name}),f.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),f.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?f.jsx(as,{className:"w-3 h-3"}):f.jsx(ku,{className:"w-3 h-3"}),CN(te.default_interval_hours,fe)]})]}),f.jsx("button",{onClick:()=>G(te),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:f.jsx(t1,{className:"w-4 h-4"})}),f.jsx("button",{onClick:()=>{confirm(`Delete "${te.name}"?`)&&s(te.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:f.jsx(fr,{className:"w-4 h-4"})})]})},te.id)})]})]}),ee.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"mb-4",children:[f.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),f.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),f.jsx("div",{className:"space-y-4",children:ee.map(te=>f.jsx(Ft,{children:f.jsxs($t,{className:"py-4",children:[f.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:te.printerName}),f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:te.items.map(ae=>{const fe=Wx(ae.maintenance_type_icon),Q=e.find(De=>De.id===ae.maintenance_type_id),me=Q?.default_interval_hours||ae.interval_hours,Ee=Q?.interval_type||"hours",he=ae.interval_type||"hours",we=a===ae.id;return f.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[f.jsx(fe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),f.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:ae.maintenance_type_name}),we?f.jsxs("div",{className:"flex items-center gap-1",children:[u==="days"?f.jsx(as,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):f.jsx(ku,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),f.jsxs("select",{value:u,onChange:De=>h(De.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[f.jsx("option",{value:"hours",children:"Print Hours"}),f.jsx("option",{value:"days",children:"Calendar Days"})]}),f.jsx("input",{type:"number",value:l,onChange:De=>c(De.target.value),onKeyDown:De=>{De.key==="Enter"&&Z(ae.id,me,Ee),De.key==="Escape"&&o(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),f.jsx(We,{size:"sm",onClick:()=>Z(ae.id,me,Ee),children:"OK"})]}):f.jsxs("button",{onClick:()=>{o(ae.id),c(ae.interval_hours.toString()),h(he)},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:[he==="days"?f.jsx(as,{className:"w-3 h-3"}):f.jsx(ku,{className:"w-3 h-3"}),CN(ae.interval_hours,he),f.jsx(t1,{className:"w-3 h-3 text-bambu-gray"})]})]},ae.id)})})]})},te.printerId))})]}),ee.length===0&&f.jsx(Ft,{children:f.jsxs($t,{className:"text-center py-12",children:[f.jsx(Pi,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),f.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),f.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function GVe(){const t=Rn(),{showToast:e}=Ki(),[n,r]=E.useState("status"),{data:i,isLoading:s}=At({queryKey:["maintenanceOverview"],queryFn:Ue.getMaintenanceOverview}),{data:a}=At({queryKey:["maintenanceTypes"],queryFn:Ue.getMaintenanceTypes}),o=Tt({mutationFn:({id:M,notes:w})=>Ue.performMaintenance(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:M=>{e(M.message,"error")}}),l=Tt({mutationFn:({id:M,data:w})=>Ue.updateMaintenanceItem(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),c=Tt({mutationFn:Ue.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:M=>{e(M.message,"error")}}),u=Tt({mutationFn:({id:M,data:w})=>Ue.updateMaintenanceType(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:M=>{e(M.message,"error")}}),h=Tt({mutationFn:Ue.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:M=>{e(M.message,"error")}}),g=Tt({mutationFn:({printerId:M,hours:w})=>Ue.setPrinterHours(M,w),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:M=>{e(M.message,"error")}}),m=M=>{o.mutate({id:M})},b=(M,w)=>{l.mutate({id:M,data:{enabled:w}})},y=(M,w)=>{g.mutate({printerId:M,hours:w})};if(s)return f.jsx("div",{className:"p-8 flex justify-center",children:f.jsx(Vt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((M,w)=>M+w.due_count,0)||0,x=i?.reduce((M,w)=>M+w.warning_count,0)||0;return f.jsxs("div",{className:"p-8",children:[f.jsxs("div",{className:"mb-6",children:[f.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),f.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?f.jsxs(f.Fragment,{children:[v>0&&f.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&x>0&&" · ",x>0&&f.jsxs("span",{className:"text-amber-400",children:[x," due soon"]}),v===0&&x===0&&f.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),f.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[f.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"}),f.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"?f.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((M,w)=>{const T=M.due_count*10+M.warning_count,A=w.due_count*10+w.warning_count;return T!==A?A-T:M.printer_name.localeCompare(w.printer_name)}).map(M=>f.jsx($Ve,{overview:M,onPerform:m,onToggle:b,onSetHours:y},M.printer_id)):f.jsx(Ft,{children:f.jsxs($t,{className:"text-center py-16",children:[f.jsx(Zp,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),f.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),f.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):f.jsx(VVe,{overview:i,types:a||[],onUpdateInterval:(M,w)=>l.mutate({id:M,data:w}),onAddType:M=>c.mutate(M),onUpdateType:(M,w)=>u.mutate({id:M,data:w}),onDeleteType:M=>h.mutate(M)})]})}function WVe(){const{printerId:t}=uie(),e=parseInt(t||"0",10),[n,r]=E.useState("stream"),[i,s]=E.useState(!1),[a,o]=E.useState(!0),[l,c]=E.useState(Date.now()),[u,h]=E.useState(!1),[g,m]=E.useState(!1),b=E.useRef(null),y=E.useRef(null),{data:v}=At({queryKey:["printer",e],queryFn:()=>Ue.getPrinter(e),enabled:e>0});E.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambusy"}),[v]),E.useEffect(()=>()=>{b.current&&(b.current.src="")},[]),E.useEffect(()=>{if(a&&!u){const N=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(N)}},[n,a,l,u]),E.useEffect(()=>{const j=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",j),()=>document.removeEventListener("fullscreenchange",j)},[]);const x=()=>{s(!0),o(!1)},M=()=>{o(!1),s(!1)},w=j=>{n===j||u||(h(!0),o(!0),s(!1),b.current&&(b.current.src=""),setTimeout(()=>{r(j),c(Date.now()),h(!1)},100))},T=()=>{u||(h(!0),o(!0),s(!1),b.current&&(b.current.src=""),setTimeout(()=>{c(Date.now()),h(!1)},100))},A=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},P=u?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${l}`:`/api/v1/printers/${e}/camera/snapshot?t=${l}`,C=a||u;return e?f.jsxs("div",{ref:y,className:"min-h-screen bg-black flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[f.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[f.jsx(Z_,{className:"w-4 h-4"}),v?.name||`Printer ${e}`]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[f.jsx("button",{onClick:()=>w("stream"),disabled:C,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),f.jsx("button",{onClick:()=>w("snapshot"),disabled:C,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),f.jsx("button",{onClick:T,disabled:C,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:f.jsx(Ka,{className:`w-4 h-4 text-bambu-gray ${C?"animate-spin":""}`})}),f.jsx("button",{onClick:A,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?f.jsx(Hoe,{className:"w-4 h-4 text-bambu-gray"}):f.jsx(Uoe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),f.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:f.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(a||u)&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:f.jsxs("div",{className:"text-center",children:[f.jsx(Ka,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),f.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&f.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:f.jsxs("div",{className:"text-center p-4",children:[f.jsx(Ao,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),f.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),f.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),f.jsx("button",{onClick:T,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),f.jsx("img",{ref:b,src:P,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:P?x:void 0,onLoad:P?M:void 0},l)]})})]}):f.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:f.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function qVe(){const t=E.useRef(null),e=E.useRef(null),n=Rn(),[r,i]=E.useState(!1),s=E.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,u=new WebSocket(c);let h=null;u.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),h=window.setInterval(()=>{u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"ping"}))},3e4)},u.onmessage=g=>{try{const m=JSON.parse(g.data);a(m)}catch{}},u.onclose=g=>{console.log("[WebSocket] Closed",g.code,g.reason),h&&(clearInterval(h),h=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{s()},3e3)},u.onerror=g=>{console.error("[WebSocket] Error",g),u.close()},t.current=u},[]),a=E.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],c=>{const u={...c,...l.data};return u.wifi_signal==null&&c?.wifi_signal!=null&&(u.wifi_signal=c.wifi_signal),u});break;case"print_complete":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break;case"archive_created":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break}},[n]);E.useEffect(()=>(s(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[s]);const o=E.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:r,sendMessage:o}}const XVe=new Tse({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function KVe({children:t}){return qVe(),f.jsx(f.Fragment,{children:t})}function YVe(){return f.jsx(ace,{children:f.jsx(mce,{children:f.jsx(Cse,{client:XVe,children:f.jsx(KVe,{children:f.jsx(Kie,{children:f.jsxs(Aie,{children:[f.jsx(zo,{path:"/camera/:printerId",element:f.jsx(WVe,{})}),f.jsxs(zo,{path:"/",element:f.jsx(fce,{}),children:[f.jsx(zo,{index:!0,element:f.jsx(Gce,{})}),f.jsx(zo,{path:"archives",element:f.jsx(xCe,{})}),f.jsx(zo,{path:"queue",element:f.jsx(n3e,{})}),f.jsx(zo,{path:"stats",element:f.jsx(yVe,{})}),f.jsx(zo,{path:"profiles",element:f.jsx(BVe,{})}),f.jsx(zo,{path:"maintenance",element:f.jsx(GVe,{})}),f.jsx(zo,{path:"settings",element:f.jsx(RVe,{})})]})]})})})})})})}Nne.createRoot(document.getElementById("root")).render(f.jsx(E.StrictMode,{children:f.jsx(YVe,{})}));
|