| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611 |
- function mre(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 sy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function lo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var fA={exports:{}},Xg={};var VU;function gre(){if(VU)return Xg;VU=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 Xg.Fragment=e,Xg.jsx=n,Xg.jsxs=n,Xg}var GU;function xre(){return GU||(GU=1,fA.exports=gre()),fA.exports}var c=xre(),pA={exports:{}},Qt={};var WU;function bre(){if(WU)return Qt;WU=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"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function m(U){return U===null||typeof U!="object"?null:(U=g&&U[g]||U["@@iterator"],typeof U=="function"?U:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function b(U,z,ee){this.props=U,this.context=z,this.refs=v,this.updater=ee||x}b.prototype.isReactComponent={},b.prototype.setState=function(U,z){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,z,"setState")},b.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function E(){}E.prototype=b.prototype;function S(U,z,ee){this.props=U,this.context=z,this.refs=v,this.updater=ee||x}var A=S.prototype=new E;A.constructor=S,y(A,b.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function k(){}var N={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function C(U,z,ee){var ae=ee.ref;return{$$typeof:t,type:U,key:z,ref:ae!==void 0?ae:null,props:ee}}function D(U,z){return C(U.type,z,U.props)}function F(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function j(U){var z={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(ee){return z[ee]})}var q=/\/+/g;function R(U,z){return typeof U=="object"&&U!==null&&U.key!=null?j(""+U.key):z.toString(36)}function W(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(k,k):(U.status="pending",U.then(function(z){U.status==="pending"&&(U.status="fulfilled",U.value=z)},function(z){U.status==="pending"&&(U.status="rejected",U.reason=z)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function K(U,z,ee,ae,fe){var de=typeof U;(de==="undefined"||de==="boolean")&&(U=null);var xe=!1;if(U===null)xe=!0;else switch(de){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(U.$$typeof){case t:case e:xe=!0;break;case d:return xe=U._init,K(xe(U._payload),z,ee,ae,fe)}}if(xe)return fe=fe(U),xe=ae===""?"."+R(U,0):ae,T(fe)?(ee="",xe!=null&&(ee=xe.replace(q,"$&/")+"/"),K(fe,z,ee,"",function(ve){return ve})):fe!=null&&(F(fe)&&(fe=D(fe,ee+(fe.key==null||U&&U.key===fe.key?"":(""+fe.key).replace(q,"$&/")+"/")+xe)),z.push(fe)),1;xe=0;var ye=ae===""?".":ae+":";if(T(U))for(var re=0;re<U.length;re++)ae=U[re],de=ye+R(ae,re),xe+=K(ae,z,ee,de,fe);else if(re=m(U),typeof re=="function")for(U=re.call(U),re=0;!(ae=U.next()).done;)ae=ae.value,de=ye+R(ae,re++),xe+=K(ae,z,ee,de,fe);else if(de==="object"){if(typeof U.then=="function")return K(W(U),z,ee,ae,fe);throw z=String(U),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return xe}function V(U,z,ee){if(U==null)return U;var ae=[],fe=0;return K(U,ae,"","",function(de){return z.call(ee,de,fe++)}),ae}function te(U){if(U._status===-1){var z=U._result;z=z(),z.then(function(ee){(U._status===0||U._status===-1)&&(U._status=1,U._result=ee)},function(ee){(U._status===0||U._status===-1)&&(U._status=2,U._result=ee)}),U._status===-1&&(U._status=0,U._result=z)}if(U._status===1)return U._result.default;throw U._result}var Y=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",U);return}console.error(U)},Z={map:V,forEach:function(U,z,ee){V(U,function(){z.apply(this,arguments)},ee)},count:function(U){var z=0;return V(U,function(){z++}),z},toArray:function(U){return V(U,function(z){return z})||[]},only:function(U){if(!F(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return Qt.Activity=f,Qt.Children=Z,Qt.Component=b,Qt.Fragment=n,Qt.Profiler=i,Qt.PureComponent=S,Qt.StrictMode=r,Qt.Suspense=l,Qt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,Qt.__COMPILER_RUNTIME={__proto__:null,c:function(U){return N.H.useMemoCache(U)}},Qt.cache=function(U){return function(){return U.apply(null,arguments)}},Qt.cacheSignal=function(){return null},Qt.cloneElement=function(U,z,ee){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var ae=y({},U.props),fe=U.key;if(z!=null)for(de in z.key!==void 0&&(fe=""+z.key),z)!I.call(z,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&z.ref===void 0||(ae[de]=z[de]);var de=arguments.length-2;if(de===1)ae.children=ee;else if(1<de){for(var xe=Array(de),ye=0;ye<de;ye++)xe[ye]=arguments[ye+2];ae.children=xe}return C(U.type,fe,ae)},Qt.createContext=function(U){return U={$$typeof:a,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:s,_context:U},U},Qt.createElement=function(U,z,ee){var ae,fe={},de=null;if(z!=null)for(ae in z.key!==void 0&&(de=""+z.key),z)I.call(z,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(fe[ae]=z[ae]);var xe=arguments.length-2;if(xe===1)fe.children=ee;else if(1<xe){for(var ye=Array(xe),re=0;re<xe;re++)ye[re]=arguments[re+2];fe.children=ye}if(U&&U.defaultProps)for(ae in xe=U.defaultProps,xe)fe[ae]===void 0&&(fe[ae]=xe[ae]);return C(U,de,fe)},Qt.createRef=function(){return{current:null}},Qt.forwardRef=function(U){return{$$typeof:o,render:U}},Qt.isValidElement=F,Qt.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:te}},Qt.memo=function(U,z){return{$$typeof:u,type:U,compare:z===void 0?null:z}},Qt.startTransition=function(U){var z=N.T,ee={};N.T=ee;try{var ae=U(),fe=N.S;fe!==null&&fe(ee,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(k,Y)}catch(de){Y(de)}finally{z!==null&&ee.types!==null&&(z.types=ee.types),N.T=z}},Qt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},Qt.use=function(U){return N.H.use(U)},Qt.useActionState=function(U,z,ee){return N.H.useActionState(U,z,ee)},Qt.useCallback=function(U,z){return N.H.useCallback(U,z)},Qt.useContext=function(U){return N.H.useContext(U)},Qt.useDebugValue=function(){},Qt.useDeferredValue=function(U,z){return N.H.useDeferredValue(U,z)},Qt.useEffect=function(U,z){return N.H.useEffect(U,z)},Qt.useEffectEvent=function(U){return N.H.useEffectEvent(U)},Qt.useId=function(){return N.H.useId()},Qt.useImperativeHandle=function(U,z,ee){return N.H.useImperativeHandle(U,z,ee)},Qt.useInsertionEffect=function(U,z){return N.H.useInsertionEffect(U,z)},Qt.useLayoutEffect=function(U,z){return N.H.useLayoutEffect(U,z)},Qt.useMemo=function(U,z){return N.H.useMemo(U,z)},Qt.useOptimistic=function(U,z){return N.H.useOptimistic(U,z)},Qt.useReducer=function(U,z,ee){return N.H.useReducer(U,z,ee)},Qt.useRef=function(U){return N.H.useRef(U)},Qt.useState=function(U){return N.H.useState(U)},Qt.useSyncExternalStore=function(U,z,ee){return N.H.useSyncExternalStore(U,z,ee)},Qt.useTransition=function(){return N.H.useTransition()},Qt.version="19.2.0",Qt}var qU;function Im(){return qU||(qU=1,pA.exports=bre()),pA.exports}var M=Im();const mr=lo(M),vre=mre({__proto__:null,default:mr},[M]);var mA={exports:{}},Yg={},gA={exports:{}},xA={};var KU;function yre(){return KU||(KU=1,(function(t){function e(K,V){var te=K.length;K.push(V);e:for(;0<te;){var Y=te-1>>>1,Z=K[Y];if(0<i(Z,V))K[Y]=V,K[te]=Z,te=Y;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var V=K[0],te=K.pop();if(te!==V){K[0]=te;e:for(var Y=0,Z=K.length,U=Z>>>1;Y<U;){var z=2*(Y+1)-1,ee=K[z],ae=z+1,fe=K[ae];if(0>i(ee,te))ae<Z&&0>i(fe,ee)?(K[Y]=fe,K[ae]=te,Y=ae):(K[Y]=ee,K[z]=te,Y=z);else if(ae<Z&&0>i(fe,te))K[Y]=fe,K[ae]=te,Y=ae;else break e}}return V}function i(K,V){var te=K.sortIndex-V.sortIndex;return te!==0?te:K.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=[],u=[],d=1,f=null,g=3,m=!1,x=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=K)r(u),V.sortIndex=V.expirationTime,e(l,V);else break;V=n(u)}}function T(K){if(y=!1,A(K),!x)if(n(l)!==null)x=!0,k||(k=!0,j());else{var V=n(u);V!==null&&W(T,V.startTime-K)}}var k=!1,N=-1,I=5,C=-1;function D(){return v?!0:!(t.unstable_now()-C<I)}function F(){if(v=!1,k){var K=t.unstable_now();C=K;var V=!0;try{e:{x=!1,y&&(y=!1,E(N),N=-1),m=!0;var te=g;try{t:{for(A(K),f=n(l);f!==null&&!(f.expirationTime>K&&D());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,g=f.priorityLevel;var Z=Y(f.expirationTime<=K);if(K=t.unstable_now(),typeof Z=="function"){f.callback=Z,A(K),V=!0;break t}f===n(l)&&r(l),A(K)}else r(l);f=n(l)}if(f!==null)V=!0;else{var U=n(u);U!==null&&W(T,U.startTime-K),V=!1}}break e}finally{f=null,g=te,m=!1}V=void 0}}finally{V?j():k=!1}}}var j;if(typeof S=="function")j=function(){S(F)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=F,j=function(){R.postMessage(null)}}else j=function(){b(F,0)};function W(K,V){N=b(function(){K(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(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(K){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var te=g;g=V;try{return K()}finally{g=te}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(K,V){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var te=g;g=K;try{return V()}finally{g=te}},t.unstable_scheduleCallback=function(K,V,te){var Y=t.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?Y+te:Y):te=Y,K){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=te+Z,K={id:d++,callback:V,priorityLevel:K,startTime:te,expirationTime:Z,sortIndex:-1},te>Y?(K.sortIndex=te,e(u,K),n(l)===null&&K===n(u)&&(y?(E(N),N=-1):y=!0,W(T,te-Y))):(K.sortIndex=Z,e(l,K),x||m||(x=!0,k||(k=!0,j()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var V=g;return function(){var te=g;g=V;try{return K.apply(this,arguments)}finally{g=te}}}})(xA)),xA}var XU;function _re(){return XU||(XU=1,gA.exports=yre()),gA.exports}var bA={exports:{}},ns={};var YU;function wre(){if(YU)return ns;YU=1;var t=Im();function e(l){var u="https://react.dev/errors/"+l;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(l,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:l,containerInfo:u,implementation:d}}var a=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(l,u){if(l==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ns.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ns.createPortal=function(l,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return s(l,u,null,d)},ns.flushSync=function(l){var u=a.T,d=r.p;try{if(a.T=null,r.p=2,l)return l()}finally{a.T=u,r.p=d,r.d.f()}},ns.preconnect=function(l,u){typeof l=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(l,u))},ns.prefetchDNS=function(l){typeof l=="string"&&r.d.D(l)},ns.preinit=function(l,u){if(typeof l=="string"&&u&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(l,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:m}):d==="script"&&r.d.X(l,{crossOrigin:f,integrity:g,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ns.preinitModule=function(l,u){if(typeof l=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=o(u.as,u.crossOrigin);r.d.M(l,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(l)},ns.preload=function(l,u){if(typeof l=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin);r.d.L(l,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},ns.preloadModule=function(l,u){if(typeof l=="string")if(u){var d=o(u.as,u.crossOrigin);r.d.m(l,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(l)},ns.requestFormReset=function(l){r.d.r(l)},ns.unstable_batchedUpdates=function(l,u){return l(u)},ns.useFormState=function(l,u,d){return a.H.useFormState(l,u,d)},ns.useFormStatus=function(){return a.H.useHostTransitionStatus()},ns.version="19.2.0",ns}var ZU;function cG(){if(ZU)return bA.exports;ZU=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(),bA.exports=wre(),bA.exports}var QU;function Sre(){if(QU)return Yg;QU=1;var t=_re(),e=Im(),n=cG();function r(h){var p="https://react.dev/errors/"+h;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)p+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function s(h){var p=h,_=h;if(h.alternate)for(;p.return;)p=p.return;else{h=p;do p=h,(p.flags&4098)!==0&&(_=p.return),h=p.return;while(h)}return p.tag===3?_:null}function a(h){if(h.tag===13){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function o(h){if(h.tag===31){var p=h.memoizedState;if(p===null&&(h=h.alternate,h!==null&&(p=h.memoizedState)),p!==null)return p.dehydrated}return null}function l(h){if(s(h)!==h)throw Error(r(188))}function u(h){var p=h.alternate;if(!p){if(p=s(h),p===null)throw Error(r(188));return p!==h?null:h}for(var _=h,w=p;;){var P=_.return;if(P===null)break;var O=P.alternate;if(O===null){if(w=P.return,w!==null){_=w;continue}break}if(P.child===O.child){for(O=P.child;O;){if(O===_)return l(P),h;if(O===w)return l(P),p;O=O.sibling}throw Error(r(188))}if(_.return!==w.return)_=P,w=O;else{for(var X=!1,oe=P.child;oe;){if(oe===_){X=!0,_=P,w=O;break}if(oe===w){X=!0,w=P,_=O;break}oe=oe.sibling}if(!X){for(oe=O.child;oe;){if(oe===_){X=!0,_=O,w=P;break}if(oe===w){X=!0,w=O,_=P;break}oe=oe.sibling}if(!X)throw Error(r(189))}}if(_.alternate!==w)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:p}function d(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h;for(h=h.child;h!==null;){if(p=d(h),p!==null)return p;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function j(h){return h===null||typeof h!="object"?null:(h=F&&h[F]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function R(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case b:return"Profiler";case v:return"StrictMode";case T:return"Suspense";case k:return"SuspenseList";case C:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case S:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case A:var p=h.render;return h=h.displayName,h||(h=p.displayName||p.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case N:return p=h.displayName||null,p!==null?p:R(h.type)||"Memo";case I:p=h._payload,h=h._init;try{return R(h(p))}catch{}}return null}var W=Array.isArray,K=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,te={pending:!1,data:null,method:null,action:null},Y=[],Z=-1;function U(h){return{current:h}}function z(h){0>Z||(h.current=Y[Z],Y[Z]=null,Z--)}function ee(h,p){Z++,Y[Z]=h.current,h.current=p}var ae=U(null),fe=U(null),de=U(null),xe=U(null);function ye(h,p){switch(ee(de,p),ee(fe,h),ee(ae,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?fU(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=fU(p),h=pU(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}z(ae),ee(ae,h)}function re(){z(ae),z(fe),z(de)}function ve(h){h.memoizedState!==null&&ee(xe,h);var p=ae.current,_=pU(p,h.type);p!==_&&(ee(fe,h),ee(ae,_))}function je(h){fe.current===h&&(z(ae),z(fe)),xe.current===h&&(z(xe),Gg._currentValue=te)}var ue,ut;function $(h){if(ue===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);ue=p&&p[1]||"",ut=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ue+h+ut}var H=!1;function ie(h,p){if(!h||H)return"";H=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var w={DetermineComponentFrameRoot:function(){try{if(p){var dt=function(){throw Error()};if(Object.defineProperty(dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(dt,[])}catch(it){var Qe=it}Reflect.construct(h,[],dt)}else{try{dt.call()}catch(it){Qe=it}h.call(dt.prototype)}}else{try{throw Error()}catch(it){Qe=it}(dt=h())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(it){if(it&&Qe&&typeof it.stack=="string")return[it.stack,Qe.stack]}return[null,null]}};w.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(w.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(w.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=w.DetermineComponentFrameRoot(),X=O[0],oe=O[1];if(X&&oe){var Me=X.split(`
- `),Ke=oe.split(`
- `);for(P=w=0;w<Me.length&&!Me[w].includes("DetermineComponentFrameRoot");)w++;for(;P<Ke.length&&!Ke[P].includes("DetermineComponentFrameRoot");)P++;if(w===Me.length||P===Ke.length)for(w=Me.length-1,P=Ke.length-1;1<=w&&0<=P&&Me[w]!==Ke[P];)P--;for(;1<=w&&0<=P;w--,P--)if(Me[w]!==Ke[P]){if(w!==1||P!==1)do if(w--,P--,0>P||Me[w]!==Ke[P]){var lt=`
- `+Me[w].replace(" at new "," at ");return h.displayName&<.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",h.displayName)),lt}while(1<=w&&0<=P);break}}}finally{H=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?$(_):""}function G(h,p){switch(h.tag){case 26:case 27:case 5:return $(h.type);case 16:return $("Lazy");case 13:return h.child!==p&&p!==null?$("Suspense Fallback"):$("Suspense");case 19:return $("SuspenseList");case 0:case 15:return ie(h.type,!1);case 11:return ie(h.type.render,!1);case 1:return ie(h.type,!0);case 31:return $("Activity");default:return""}}function J(h){try{var p="",_=null;do p+=G(h,_),_=h,h=h.return;while(h);return p}catch(w){return`
- Error generating stack: `+w.message+`
- `+w.stack}}var le=Object.prototype.hasOwnProperty,ke=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,Se=t.unstable_shouldYield,B=t.unstable_requestPaint,L=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,ge=t.unstable_NormalPriority,me=t.unstable_LowPriority,Ae=t.unstable_IdlePriority,ze=t.log,st=t.unstable_setDisableYieldValue,Ve=null,ce=null;function Ye(h){if(typeof ze=="function"&&st(h),ce&&typeof ce.setStrictMode=="function")try{ce.setStrictMode(Ve,h)}catch{}}var $e=Math.clz32?Math.clz32:Q,Ze=Math.log,at=Math.LN2;function Q(h){return h>>>=0,h===0?32:31-(Ze(h)/at|0)|0}var Fe=256,pe=262144,Ue=4194304;function Ce(h){var p=h&42;if(p!==0)return p;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function _e(h,p,_){var w=h.pendingLanes;if(w===0)return 0;var P=0,O=h.suspendedLanes,X=h.pingedLanes;h=h.warmLanes;var oe=w&134217727;return oe!==0?(w=oe&~O,w!==0?P=Ce(w):(X&=oe,X!==0?P=Ce(X):_||(_=oe&~h,_!==0&&(P=Ce(_))))):(oe=w&~O,oe!==0?P=Ce(oe):X!==0?P=Ce(X):_||(_=w&~h,_!==0&&(P=Ce(_)))),P===0?0:p!==0&&p!==P&&(p&O)===0&&(O=P&-P,_=p&-p,O>=_||O===32&&(_&4194048)!==0)?p:P}function He(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function ht(h,p){switch(h){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 wt(){var h=Ue;return Ue<<=1,(Ue&62914560)===0&&(Ue=4194304),h}function Ot(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function cn(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function It(h,p,_,w,P,O){var X=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var oe=h.entanglements,Me=h.expirationTimes,Ke=h.hiddenUpdates;for(_=X&~_;0<_;){var lt=31-$e(_),dt=1<<lt;oe[lt]=0,Me[lt]=-1;var Qe=Ke[lt];if(Qe!==null)for(Ke[lt]=null,lt=0;lt<Qe.length;lt++){var it=Qe[lt];it!==null&&(it.lane&=-536870913)}_&=~dt}w!==0&&Dn(h,w,0),O!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=O&~(X&~p))}function Dn(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var w=31-$e(p);h.entangledLanes|=p,h.entanglements[w]=h.entanglements[w]|1073741824|_&261930}function Qn(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var w=31-$e(_),P=1<<w;P&p|h[w]&p&&(h[w]|=p),_&=~P}}function wi(h,p){var _=p&-p;return _=(_&42)!==0?1:si(_),(_&(h.suspendedLanes|p))!==0?0:_}function si(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Si(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Ui(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:IU(h.type))}function ts(h,p){var _=V.p;try{return V.p=h,p()}finally{V.p=_}}var zr=Math.random().toString(36).slice(2),br="__reactFiber$"+zr,Dr="__reactProps$"+zr,uo="__reactContainer$"+zr,zc="__reactEvents$"+zr,he="__reactListeners$"+zr,Ge="__reactHandles$"+zr,nt="__reactResources$"+zr,rt="__reactMarker$"+zr;function et(h){delete h[br],delete h[Dr],delete h[zc],delete h[he],delete h[Ge]}function St(h){var p=h[br];if(p)return p;for(var _=h.parentNode;_;){if(p=_[uo]||_[br]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=_U(h);h!==null;){if(_=h[br])return _;h=_U(h)}return p}h=_,_=h.parentNode}return null}function se(h){if(h=h[br]||h[uo]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function Ee(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Le(h){var p=h[nt];return p||(p=h[nt]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Oe(h){h[rt]=!0}var Te=new Set,ot={};function ft(h,p){bt(h,p),bt(h+"Capture",p)}function bt(h,p){for(ot[h]=p,h=0;h<p.length;h++)Te.add(p[h])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),jt={},Mt={};function mt(h){return le.call(Mt,h)?!0:le.call(jt,h)?!1:xt.test(h)?Mt[h]=!0:(jt[h]=!0,!1)}function Kt(h,p,_){if(mt(p))if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(p);return;case"boolean":var w=p.toLowerCase().slice(0,5);if(w!=="data-"&&w!=="aria-"){h.removeAttribute(p);return}}h.setAttribute(p,""+_)}}function Ft(h,p,_){if(_===null)h.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(p);return}h.setAttribute(p,""+_)}}function nn(h,p,_,w){if(w===null)h.removeAttribute(_);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(p,_,""+w)}}function dn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function xn(h){var p=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Ut(h,p,_){var w=Object.getOwnPropertyDescriptor(h.constructor.prototype,p);if(!h.hasOwnProperty(p)&&typeof w<"u"&&typeof w.get=="function"&&typeof w.set=="function"){var P=w.get,O=w.set;return Object.defineProperty(h,p,{configurable:!0,get:function(){return P.call(this)},set:function(X){_=""+X,O.call(this,X)}}),Object.defineProperty(h,p,{enumerable:w.enumerable}),{getValue:function(){return _},setValue:function(X){_=""+X},stopTracking:function(){h._valueTracker=null,delete h[p]}}}}function Zt(h){if(!h._valueTracker){var p=xn(h)?"checked":"value";h._valueTracker=Ut(h,p,""+h[p])}}function Jt(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),w="";return h&&(w=xn(h)?h.checked?"true":"false":h.value),h=w,h!==_?(p.setValue(h),!0):!1}function Mr(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var Or=/[\n"\\]/g;function Pn(h){return h.replace(Or,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function ho(h,p,_,w,P,O,X,oe){h.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?h.type=X:h.removeAttribute("type"),p!=null?X==="number"?(p===0&&h.value===""||h.value!=p)&&(h.value=""+dn(p)):h.value!==""+dn(p)&&(h.value=""+dn(p)):X!=="submit"&&X!=="reset"||h.removeAttribute("value"),p!=null?Ei(h,X,dn(p)):_!=null?Ei(h,X,dn(_)):w!=null&&h.removeAttribute("value"),P==null&&O!=null&&(h.defaultChecked=!!O),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),oe!=null&&typeof oe!="function"&&typeof oe!="symbol"&&typeof oe!="boolean"?h.name=""+dn(oe):h.removeAttribute("name")}function On(h,p,_,w,P,O,X,oe){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(h.type=O),p!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||p!=null)){Zt(h);return}_=_!=null?""+dn(_):"",p=p!=null?""+dn(p):_,oe||p===h.value||(h.value=p),h.defaultValue=p}w=w??P,w=typeof w!="function"&&typeof w!="symbol"&&!!w,h.checked=oe?h.checked:!!w,h.defaultChecked=!!w,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(h.name=X),Zt(h)}function Ei(h,p,_){p==="number"&&Mr(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function ai(h,p,_,w){if(h=h.options,p){p={};for(var P=0;P<_.length;P++)p["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=p.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&w&&(h[_].defaultSelected=!0)}else{for(_=""+dn(_),p=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,w&&(h[P].defaultSelected=!0);return}p!==null||h[P].disabled||(p=h[P])}p!==null&&(p.selected=!0)}}function Mi(h,p,_){if(p!=null&&(p=""+dn(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+dn(_):""}function Fi(h,p,_,w){if(p==null){if(w!=null){if(_!=null)throw Error(r(92));if(W(w)){if(1<w.length)throw Error(r(93));w=w[0]}_=w}_==null&&(_=""),p=_}_=dn(p),h.defaultValue=_,w=h.textContent,w===_&&w!==""&&w!==null&&(h.value=w),Zt(h)}function Ho(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var El=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 uL(h,p,_){var w=p.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?w?h.setProperty(p,""):p==="float"?h.cssFloat="":h[p]="":w?h.setProperty(p,_):typeof _!="number"||_===0||El.has(p)?p==="float"?h.cssFloat=_:h[p]=(""+_).trim():h[p]=_+"px"}function dL(h,p,_){if(p!=null&&typeof p!="object")throw Error(r(62));if(h=h.style,_!=null){for(var w in _)!_.hasOwnProperty(w)||p!=null&&p.hasOwnProperty(w)||(w.indexOf("--")===0?h.setProperty(w,""):w==="float"?h.cssFloat="":h[w]="");for(var P in p)w=p[P],p.hasOwnProperty(P)&&_[P]!==w&&uL(h,P,w)}else for(var O in p)p.hasOwnProperty(O)&&uL(h,O,p[O])}function cM(h){if(h.indexOf("-")===-1)return!1;switch(h){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var dte=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"]]),hte=/^[\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 Yb(h){return hte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Ml(){}var uM=null;function dM(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var pf=null,mf=null;function hL(h){var p=se(h);if(p&&(h=p.stateNode)){var _=h[Dr]||null;e:switch(h=p.stateNode,p.type){case"input":if(ho(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Pn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var w=_[p];if(w!==h&&w.form===h.form){var P=w[Dr]||null;if(!P)throw Error(r(90));ho(w,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(p=0;p<_.length;p++)w=_[p],w.form===h.form&&Jt(w)}break e;case"textarea":Mi(h,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&ai(h,!!_.multiple,p,!1)}}}var hM=!1;function fL(h,p,_){if(hM)return h(p,_);hM=!0;try{var w=h(p);return w}finally{if(hM=!1,(pf!==null||mf!==null)&&(Iv(),pf&&(p=pf,h=mf,mf=pf=null,hL(p),h)))for(p=0;p<h.length;p++)hL(h[p])}}function lg(h,p){var _=h.stateNode;if(_===null)return null;var w=_[Dr]||null;if(w===null)return null;_=w[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":(w=!w.disabled)||(h=h.type,w=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!w;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,p,typeof _));return _}var Al=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),fM=!1;if(Al)try{var cg={};Object.defineProperty(cg,"passive",{get:function(){fM=!0}}),window.addEventListener("test",cg,cg),window.removeEventListener("test",cg,cg)}catch{fM=!1}var Bc=null,pM=null,Zb=null;function pL(){if(Zb)return Zb;var h,p=pM,_=p.length,w,P="value"in Bc?Bc.value:Bc.textContent,O=P.length;for(h=0;h<_&&p[h]===P[h];h++);var X=_-h;for(w=1;w<=X&&p[_-w]===P[O-w];w++);return Zb=P.slice(h,1<w?1-w:void 0)}function Qb(h){var p=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&p===13&&(h=13)):h=p,h===10&&(h=13),32<=h||h===13?h:0}function Jb(){return!0}function mL(){return!1}function Ds(h){function p(_,w,P,O,X){this._reactName=_,this._targetInst=P,this.type=w,this.nativeEvent=O,this.target=X,this.currentTarget=null;for(var oe in h)h.hasOwnProperty(oe)&&(_=h[oe],this[oe]=_?_(O):O[oe]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Jb:mL,this.isPropagationStopped=mL,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Jb)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Jb)},persist:function(){},isPersistent:Jb}),p}var Ed={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ev=Ds(Ed),ug=f({},Ed,{view:0,detail:0}),fte=Ds(ug),mM,gM,dg,tv=f({},ug,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bM,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==dg&&(dg&&h.type==="mousemove"?(mM=h.screenX-dg.screenX,gM=h.screenY-dg.screenY):gM=mM=0,dg=h),mM)},movementY:function(h){return"movementY"in h?h.movementY:gM}}),gL=Ds(tv),pte=f({},tv,{dataTransfer:0}),mte=Ds(pte),gte=f({},ug,{relatedTarget:0}),xM=Ds(gte),xte=f({},Ed,{animationName:0,elapsedTime:0,pseudoElement:0}),bte=Ds(xte),vte=f({},Ed,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),yte=Ds(vte),_te=f({},Ed,{data:0}),xL=Ds(_te),wte={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ste={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"},Ete={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mte(h){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(h):(h=Ete[h])?!!p[h]:!1}function bM(){return Mte}var Ate=f({},ug,{key:function(h){if(h.key){var p=wte[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=Qb(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Ste[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bM,charCode:function(h){return h.type==="keypress"?Qb(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Qb(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Tte=Ds(Ate),Cte=f({},tv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),bL=Ds(Cte),Nte=f({},ug,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bM}),kte=Ds(Nte),Pte=f({},Ed,{propertyName:0,elapsedTime:0,pseudoElement:0}),Rte=Ds(Pte),Dte=f({},tv,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),Ote=Ds(Dte),jte=f({},Ed,{newState:0,oldState:0}),Lte=Ds(jte),Ite=[9,13,27,32],vM=Al&&"CompositionEvent"in window,hg=null;Al&&"documentMode"in document&&(hg=document.documentMode);var Ute=Al&&"TextEvent"in window&&!hg,vL=Al&&(!vM||hg&&8<hg&&11>=hg),yL=" ",_L=!1;function wL(h,p){switch(h){case"keyup":return Ite.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function SL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var gf=!1;function Fte(h,p){switch(h){case"compositionend":return SL(p);case"keypress":return p.which!==32?null:(_L=!0,yL);case"textInput":return h=p.data,h===yL&&_L?null:h;default:return null}}function zte(h,p){if(gf)return h==="compositionend"||!vM&&wL(h,p)?(h=pL(),Zb=pM=Bc=null,gf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return vL&&p.locale!=="ko"?null:p.data;default:return null}}var Bte={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 EL(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p==="input"?!!Bte[h.type]:p==="textarea"}function ML(h,p,_,w){pf?mf?mf.push(w):mf=[w]:pf=w,p=Vv(p,"onChange"),0<p.length&&(_=new ev("onChange","change",null,_,w),h.push({event:_,listeners:p}))}var fg=null,pg=null;function Hte(h){oU(h,0)}function nv(h){var p=Ee(h);if(Jt(p))return h}function AL(h,p){if(h==="change")return p}var TL=!1;if(Al){var yM;if(Al){var _M="oninput"in document;if(!_M){var CL=document.createElement("div");CL.setAttribute("oninput","return;"),_M=typeof CL.oninput=="function"}yM=_M}else yM=!1;TL=yM&&(!document.documentMode||9<document.documentMode)}function NL(){fg&&(fg.detachEvent("onpropertychange",kL),pg=fg=null)}function kL(h){if(h.propertyName==="value"&&nv(pg)){var p=[];ML(p,pg,h,dM(h)),fL(Hte,p)}}function $te(h,p,_){h==="focusin"?(NL(),fg=p,pg=_,fg.attachEvent("onpropertychange",kL)):h==="focusout"&&NL()}function Vte(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return nv(pg)}function Gte(h,p){if(h==="click")return nv(p)}function Wte(h,p){if(h==="input"||h==="change")return nv(p)}function qte(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var ea=typeof Object.is=="function"?Object.is:qte;function mg(h,p){if(ea(h,p))return!0;if(typeof h!="object"||h===null||typeof p!="object"||p===null)return!1;var _=Object.keys(h),w=Object.keys(p);if(_.length!==w.length)return!1;for(w=0;w<_.length;w++){var P=_[w];if(!le.call(p,P)||!ea(h[P],p[P]))return!1}return!0}function PL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function RL(h,p){var _=PL(h);h=0;for(var w;_;){if(_.nodeType===3){if(w=h+_.textContent.length,h<=p&&w>=p)return{node:_,offset:p-h};h=w}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=PL(_)}}function DL(h,p){return h&&p?h===p?!0:h&&h.nodeType===3?!1:p&&p.nodeType===3?DL(h,p.parentNode):"contains"in h?h.contains(p):h.compareDocumentPosition?!!(h.compareDocumentPosition(p)&16):!1:!1}function OL(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var p=Mr(h.document);p instanceof h.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)h=p.contentWindow;else break;p=Mr(h.document)}return p}function wM(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p&&(p==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||p==="textarea"||h.contentEditable==="true")}var Kte=Al&&"documentMode"in document&&11>=document.documentMode,xf=null,SM=null,gg=null,EM=!1;function jL(h,p,_){var w=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;EM||xf==null||xf!==Mr(w)||(w=xf,"selectionStart"in w&&wM(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),gg&&mg(gg,w)||(gg=w,w=Vv(SM,"onSelect"),0<w.length&&(p=new ev("onSelect","select",null,p,_),h.push({event:p,listeners:w}),p.target=xf)))}function Md(h,p){var _={};return _[h.toLowerCase()]=p.toLowerCase(),_["Webkit"+h]="webkit"+p,_["Moz"+h]="moz"+p,_}var bf={animationend:Md("Animation","AnimationEnd"),animationiteration:Md("Animation","AnimationIteration"),animationstart:Md("Animation","AnimationStart"),transitionrun:Md("Transition","TransitionRun"),transitionstart:Md("Transition","TransitionStart"),transitioncancel:Md("Transition","TransitionCancel"),transitionend:Md("Transition","TransitionEnd")},MM={},LL={};Al&&(LL=document.createElement("div").style,"AnimationEvent"in window||(delete bf.animationend.animation,delete bf.animationiteration.animation,delete bf.animationstart.animation),"TransitionEvent"in window||delete bf.transitionend.transition);function Ad(h){if(MM[h])return MM[h];if(!bf[h])return h;var p=bf[h],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in LL)return MM[h]=p[_];return h}var IL=Ad("animationend"),UL=Ad("animationiteration"),FL=Ad("animationstart"),Xte=Ad("transitionrun"),Yte=Ad("transitionstart"),Zte=Ad("transitioncancel"),zL=Ad("transitionend"),BL=new Map,AM="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(" ");AM.push("scrollEnd");function fo(h,p){BL.set(h,p),ft(p,[h])}var rv=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=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(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Ea=[],vf=0,TM=0;function iv(){for(var h=vf,p=TM=vf=0;p<h;){var _=Ea[p];Ea[p++]=null;var w=Ea[p];Ea[p++]=null;var P=Ea[p];Ea[p++]=null;var O=Ea[p];if(Ea[p++]=null,w!==null&&P!==null){var X=w.pending;X===null?P.next=P:(P.next=X.next,X.next=P),w.pending=P}O!==0&&HL(_,P,O)}}function sv(h,p,_,w){Ea[vf++]=h,Ea[vf++]=p,Ea[vf++]=_,Ea[vf++]=w,TM|=w,h.lanes|=w,h=h.alternate,h!==null&&(h.lanes|=w)}function CM(h,p,_,w){return sv(h,p,_,w),av(h)}function Td(h,p){return sv(h,null,null,p),av(h)}function HL(h,p,_){h.lanes|=_;var w=h.alternate;w!==null&&(w.lanes|=_);for(var P=!1,O=h.return;O!==null;)O.childLanes|=_,w=O.alternate,w!==null&&(w.childLanes|=_),O.tag===22&&(h=O.stateNode,h===null||h._visibility&1||(P=!0)),h=O,O=O.return;return h.tag===3?(O=h.stateNode,P&&p!==null&&(P=31-$e(_),h=O.hiddenUpdates,w=h[P],w===null?h[P]=[p]:w.push(p),p.lane=_|536870912),O):null}function av(h){if(50<Ug)throw Ug=0,I2=null,Error(r(185));for(var p=h.return;p!==null;)h=p,p=h.return;return h.tag===3?h.stateNode:null}var yf={};function Qte(h,p,_,w){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ta(h,p,_,w){return new Qte(h,p,_,w)}function NM(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Tl(h,p){var _=h.alternate;return _===null?(_=ta(h.tag,p,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=p,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,p=h.dependencies,_.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function $L(h,p){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=p,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,p=_.dependencies,h.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),h}function ov(h,p,_,w,P,O){var X=0;if(w=h,typeof h=="function")NM(h)&&(X=1);else if(typeof h=="string")X=rre(h,_,ae.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case C:return h=ta(31,_,p,P),h.elementType=C,h.lanes=O,h;case y:return Cd(_.children,P,O,p);case v:X=8,P|=24;break;case b:return h=ta(12,_,p,P|2),h.elementType=b,h.lanes=O,h;case T:return h=ta(13,_,p,P),h.elementType=T,h.lanes=O,h;case k:return h=ta(19,_,p,P),h.elementType=k,h.lanes=O,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case S:X=10;break e;case E:X=9;break e;case A:X=11;break e;case N:X=14;break e;case I:X=16,w=null;break e}X=29,_=Error(r(130,h===null?"null":typeof h,"")),w=null}return p=ta(X,_,p,P),p.elementType=h,p.type=w,p.lanes=O,p}function Cd(h,p,_,w){return h=ta(7,h,w,p),h.lanes=_,h}function kM(h,p,_){return h=ta(6,h,null,p),h.lanes=_,h}function VL(h){var p=ta(18,null,null,0);return p.stateNode=h,p}function PM(h,p,_){return p=ta(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}var GL=new WeakMap;function Ma(h,p){if(typeof h=="object"&&h!==null){var _=GL.get(h);return _!==void 0?_:(p={value:h,source:p,stack:J(p)},GL.set(h,p),p)}return{value:h,source:p,stack:J(p)}}var _f=[],wf=0,lv=null,xg=0,Aa=[],Ta=0,Hc=null,$o=1,Vo="";function Cl(h,p){_f[wf++]=xg,_f[wf++]=lv,lv=h,xg=p}function WL(h,p,_){Aa[Ta++]=$o,Aa[Ta++]=Vo,Aa[Ta++]=Hc,Hc=h;var w=$o;h=Vo;var P=32-$e(w)-1;w&=~(1<<P),_+=1;var O=32-$e(p)+P;if(30<O){var X=P-P%5;O=(w&(1<<X)-1).toString(32),w>>=X,P-=X,$o=1<<32-$e(p)+P|_<<P|w,Vo=O+h}else $o=1<<O|_<<P|w,Vo=h}function RM(h){h.return!==null&&(Cl(h,1),WL(h,1,0))}function DM(h){for(;h===lv;)lv=_f[--wf],_f[wf]=null,xg=_f[--wf],_f[wf]=null;for(;h===Hc;)Hc=Aa[--Ta],Aa[Ta]=null,Vo=Aa[--Ta],Aa[Ta]=null,$o=Aa[--Ta],Aa[Ta]=null}function qL(h,p){Aa[Ta++]=$o,Aa[Ta++]=Vo,Aa[Ta++]=Hc,$o=p.id,Vo=p.overflow,Hc=h}var zi=null,ar=null,_n=!1,$c=null,Ca=!1,OM=Error(r(519));function Vc(h){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw bg(Ma(p,h)),OM}function KL(h){var p=h.stateNode,_=h.type,w=h.memoizedProps;switch(p[br]=h,p[Dr]=w,_){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;_<zg.length;_++)pn(zg[_],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),On(p,w.value,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name,!0);break;case"select":pn("invalid",p);break;case"textarea":pn("invalid",p),Fi(p,w.value,w.defaultValue,w.children)}_=w.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||w.suppressHydrationWarning===!0||dU(p.textContent,_)?(w.popover!=null&&(pn("beforetoggle",p),pn("toggle",p)),w.onScroll!=null&&pn("scroll",p),w.onScrollEnd!=null&&pn("scrollend",p),w.onClick!=null&&(p.onclick=Ml),p=!0):p=!1,p||Vc(h,!0)}function XL(h){for(zi=h.return;zi;)switch(zi.tag){case 5:case 31:case 13:Ca=!1;return;case 27:case 3:Ca=!0;return;default:zi=zi.return}}function Sf(h){if(h!==zi)return!1;if(!_n)return XL(h),_n=!0,!1;var p=h.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||Q2(h.type,h.memoizedProps)),_=!_),_&&ar&&Vc(h),XL(h),p===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));ar=yU(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));ar=yU(h)}else p===27?(p=ar,iu(h.type)?(h=rA,rA=null,ar=h):ar=p):ar=zi?ka(h.stateNode.nextSibling):null;return!0}function Nd(){ar=zi=null,_n=!1}function jM(){var h=$c;return h!==null&&(Is===null?Is=h:Is.push.apply(Is,h),$c=null),h}function bg(h){$c===null?$c=[h]:$c.push(h)}var LM=U(null),kd=null,Nl=null;function Gc(h,p,_){ee(LM,p._currentValue),p._currentValue=_}function kl(h){h._currentValue=LM.current,z(LM)}function IM(h,p,_){for(;h!==null;){var w=h.alternate;if((h.childLanes&p)!==p?(h.childLanes|=p,w!==null&&(w.childLanes|=p)):w!==null&&(w.childLanes&p)!==p&&(w.childLanes|=p),h===_)break;h=h.return}}function UM(h,p,_,w){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var O=P.dependencies;if(O!==null){var X=P.child;O=O.firstContext;e:for(;O!==null;){var oe=O;O=P;for(var Me=0;Me<p.length;Me++)if(oe.context===p[Me]){O.lanes|=_,oe=O.alternate,oe!==null&&(oe.lanes|=_),IM(O.return,_,h),w||(X=null);break e}O=oe.next}}else if(P.tag===18){if(X=P.return,X===null)throw Error(r(341));X.lanes|=_,O=X.alternate,O!==null&&(O.lanes|=_),IM(X,_,h),X=null}else X=P.child;if(X!==null)X.return=P;else for(X=P;X!==null;){if(X===h){X=null;break}if(P=X.sibling,P!==null){P.return=X.return,X=P;break}X=X.return}P=X}}function Ef(h,p,_,w){h=null;for(var P=p,O=!1;P!==null;){if(!O){if((P.flags&524288)!==0)O=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var X=P.alternate;if(X===null)throw Error(r(387));if(X=X.memoizedProps,X!==null){var oe=P.type;ea(P.pendingProps.value,X.value)||(h!==null?h.push(oe):h=[oe])}}else if(P===xe.current){if(X=P.alternate,X===null)throw Error(r(387));X.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(Gg):h=[Gg])}P=P.return}h!==null&&UM(p,h,_,w),p.flags|=262144}function cv(h){for(h=h.firstContext;h!==null;){if(!ea(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Pd(h){kd=h,Nl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Bi(h){return YL(kd,h)}function uv(h,p){return kd===null&&Pd(h),YL(h,p)}function YL(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},Nl===null){if(h===null)throw Error(r(308));Nl=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else Nl=Nl.next=p;return _}var Jte=typeof AbortController<"u"?AbortController:function(){var h=[],p=this.signal={aborted:!1,addEventListener:function(_,w){h.push(w)}};this.abort=function(){p.aborted=!0,h.forEach(function(_){return _()})}},ene=t.unstable_scheduleCallback,tne=t.unstable_NormalPriority,Br={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function FM(){return{controller:new Jte,data:new Map,refCount:0}}function vg(h){h.refCount--,h.refCount===0&&ene(tne,function(){h.controller.abort()})}var yg=null,zM=0,Mf=0,Af=null;function nne(h,p){if(yg===null){var _=yg=[];zM=0,Mf=$2(),Af={status:"pending",value:void 0,then:function(w){_.push(w)}}}return zM++,p.then(ZL,ZL),p}function ZL(){if(--zM===0&&yg!==null){Af!==null&&(Af.status="fulfilled");var h=yg;yg=null,Mf=0,Af=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function rne(h,p){var _=[],w={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){w.status="fulfilled",w.value=p;for(var P=0;P<_.length;P++)(0,_[P])(p)},function(P){for(w.status="rejected",w.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),w}var QL=K.S;K.S=function(h,p){j4=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&nne(h,p),QL!==null&&QL(h,p)};var Rd=U(null);function BM(){var h=Rd.current;return h!==null?h:Jn.pooledCache}function dv(h,p){p===null?ee(Rd,Rd.current):ee(Rd,p.pool)}function JL(){var h=BM();return h===null?null:{parent:Br._currentValue,pool:h}}var Tf=Error(r(460)),HM=Error(r(474)),hv=Error(r(542)),fv={then:function(){}};function eI(h){return h=h.status,h==="fulfilled"||h==="rejected"}function tI(h,p,_){switch(_=h[_],_===void 0?h.push(p):_!==p&&(p.then(Ml,Ml),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,rI(h),h;default:if(typeof p.status=="string")p.then(Ml,Ml);else{if(h=Jn,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=p,h.status="pending",h.then(function(w){if(p.status==="pending"){var P=p;P.status="fulfilled",P.value=w}},function(w){if(p.status==="pending"){var P=p;P.status="rejected",P.reason=w}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,rI(h),h}throw Od=p,Tf}}function Dd(h){try{var p=h._init;return p(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Od=_,Tf):_}}var Od=null;function nI(){if(Od===null)throw Error(r(459));var h=Od;return Od=null,h}function rI(h){if(h===Tf||h===hv)throw Error(r(483))}var Cf=null,_g=0;function pv(h){var p=_g;return _g+=1,Cf===null&&(Cf=[]),tI(Cf,h,p)}function wg(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function mv(h,p){throw p.$$typeof===g?Error(r(525)):(h=Object.prototype.toString.call(p),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":h)))}function iI(h){function p(Be,Re){if(h){var qe=Be.deletions;qe===null?(Be.deletions=[Re],Be.flags|=16):qe.push(Re)}}function _(Be,Re){if(!h)return null;for(;Re!==null;)p(Be,Re),Re=Re.sibling;return null}function w(Be){for(var Re=new Map;Be!==null;)Be.key!==null?Re.set(Be.key,Be):Re.set(Be.index,Be),Be=Be.sibling;return Re}function P(Be,Re){return Be=Tl(Be,Re),Be.index=0,Be.sibling=null,Be}function O(Be,Re,qe){return Be.index=qe,h?(qe=Be.alternate,qe!==null?(qe=qe.index,qe<Re?(Be.flags|=67108866,Re):qe):(Be.flags|=67108866,Re)):(Be.flags|=1048576,Re)}function X(Be){return h&&Be.alternate===null&&(Be.flags|=67108866),Be}function oe(Be,Re,qe,ct){return Re===null||Re.tag!==6?(Re=kM(qe,Be.mode,ct),Re.return=Be,Re):(Re=P(Re,qe),Re.return=Be,Re)}function Me(Be,Re,qe,ct){var zt=qe.type;return zt===y?lt(Be,Re,qe.props.children,ct,qe.key):Re!==null&&(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Dd(zt)===Re.type)?(Re=P(Re,qe.props),wg(Re,qe),Re.return=Be,Re):(Re=ov(qe.type,qe.key,qe.props,null,Be.mode,ct),wg(Re,qe),Re.return=Be,Re)}function Ke(Be,Re,qe,ct){return Re===null||Re.tag!==4||Re.stateNode.containerInfo!==qe.containerInfo||Re.stateNode.implementation!==qe.implementation?(Re=PM(qe,Be.mode,ct),Re.return=Be,Re):(Re=P(Re,qe.children||[]),Re.return=Be,Re)}function lt(Be,Re,qe,ct,zt){return Re===null||Re.tag!==7?(Re=Cd(qe,Be.mode,ct,zt),Re.return=Be,Re):(Re=P(Re,qe),Re.return=Be,Re)}function dt(Be,Re,qe){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return Re=kM(""+Re,Be.mode,qe),Re.return=Be,Re;if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case m:return qe=ov(Re.type,Re.key,Re.props,null,Be.mode,qe),wg(qe,Re),qe.return=Be,qe;case x:return Re=PM(Re,Be.mode,qe),Re.return=Be,Re;case I:return Re=Dd(Re),dt(Be,Re,qe)}if(W(Re)||j(Re))return Re=Cd(Re,Be.mode,qe,null),Re.return=Be,Re;if(typeof Re.then=="function")return dt(Be,pv(Re),qe);if(Re.$$typeof===S)return dt(Be,uv(Be,Re),qe);mv(Be,Re)}return null}function Qe(Be,Re,qe,ct){var zt=Re!==null?Re.key:null;if(typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint")return zt!==null?null:oe(Be,Re,""+qe,ct);if(typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case m:return qe.key===zt?Me(Be,Re,qe,ct):null;case x:return qe.key===zt?Ke(Be,Re,qe,ct):null;case I:return qe=Dd(qe),Qe(Be,Re,qe,ct)}if(W(qe)||j(qe))return zt!==null?null:lt(Be,Re,qe,ct,null);if(typeof qe.then=="function")return Qe(Be,Re,pv(qe),ct);if(qe.$$typeof===S)return Qe(Be,Re,uv(Be,qe),ct);mv(Be,qe)}return null}function it(Be,Re,qe,ct,zt){if(typeof ct=="string"&&ct!==""||typeof ct=="number"||typeof ct=="bigint")return Be=Be.get(qe)||null,oe(Re,Be,""+ct,zt);if(typeof ct=="object"&&ct!==null){switch(ct.$$typeof){case m:return Be=Be.get(ct.key===null?qe:ct.key)||null,Me(Re,Be,ct,zt);case x:return Be=Be.get(ct.key===null?qe:ct.key)||null,Ke(Re,Be,ct,zt);case I:return ct=Dd(ct),it(Be,Re,qe,ct,zt)}if(W(ct)||j(ct))return Be=Be.get(qe)||null,lt(Re,Be,ct,zt,null);if(typeof ct.then=="function")return it(Be,Re,qe,pv(ct),zt);if(ct.$$typeof===S)return it(Be,Re,qe,uv(Re,ct),zt);mv(Re,ct)}return null}function Rt(Be,Re,qe,ct){for(var zt=null,Mn=null,Lt=Re,tn=Re=0,vn=null;Lt!==null&&tn<qe.length;tn++){Lt.index>tn?(vn=Lt,Lt=null):vn=Lt.sibling;var An=Qe(Be,Lt,qe[tn],ct);if(An===null){Lt===null&&(Lt=vn);break}h&&Lt&&An.alternate===null&&p(Be,Lt),Re=O(An,Re,tn),Mn===null?zt=An:Mn.sibling=An,Mn=An,Lt=vn}if(tn===qe.length)return _(Be,Lt),_n&&Cl(Be,tn),zt;if(Lt===null){for(;tn<qe.length;tn++)Lt=dt(Be,qe[tn],ct),Lt!==null&&(Re=O(Lt,Re,tn),Mn===null?zt=Lt:Mn.sibling=Lt,Mn=Lt);return _n&&Cl(Be,tn),zt}for(Lt=w(Lt);tn<qe.length;tn++)vn=it(Lt,Be,tn,qe[tn],ct),vn!==null&&(h&&vn.alternate!==null&&Lt.delete(vn.key===null?tn:vn.key),Re=O(vn,Re,tn),Mn===null?zt=vn:Mn.sibling=vn,Mn=vn);return h&&Lt.forEach(function(cu){return p(Be,cu)}),_n&&Cl(Be,tn),zt}function Vt(Be,Re,qe,ct){if(qe==null)throw Error(r(151));for(var zt=null,Mn=null,Lt=Re,tn=Re=0,vn=null,An=qe.next();Lt!==null&&!An.done;tn++,An=qe.next()){Lt.index>tn?(vn=Lt,Lt=null):vn=Lt.sibling;var cu=Qe(Be,Lt,An.value,ct);if(cu===null){Lt===null&&(Lt=vn);break}h&&Lt&&cu.alternate===null&&p(Be,Lt),Re=O(cu,Re,tn),Mn===null?zt=cu:Mn.sibling=cu,Mn=cu,Lt=vn}if(An.done)return _(Be,Lt),_n&&Cl(Be,tn),zt;if(Lt===null){for(;!An.done;tn++,An=qe.next())An=dt(Be,An.value,ct),An!==null&&(Re=O(An,Re,tn),Mn===null?zt=An:Mn.sibling=An,Mn=An);return _n&&Cl(Be,tn),zt}for(Lt=w(Lt);!An.done;tn++,An=qe.next())An=it(Lt,Be,tn,An.value,ct),An!==null&&(h&&An.alternate!==null&&Lt.delete(An.key===null?tn:An.key),Re=O(An,Re,tn),Mn===null?zt=An:Mn.sibling=An,Mn=An);return h&&Lt.forEach(function(pre){return p(Be,pre)}),_n&&Cl(Be,tn),zt}function Vn(Be,Re,qe,ct){if(typeof qe=="object"&&qe!==null&&qe.type===y&&qe.key===null&&(qe=qe.props.children),typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case m:e:{for(var zt=qe.key;Re!==null;){if(Re.key===zt){if(zt=qe.type,zt===y){if(Re.tag===7){_(Be,Re.sibling),ct=P(Re,qe.props.children),ct.return=Be,Be=ct;break e}}else if(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&Dd(zt)===Re.type){_(Be,Re.sibling),ct=P(Re,qe.props),wg(ct,qe),ct.return=Be,Be=ct;break e}_(Be,Re);break}else p(Be,Re);Re=Re.sibling}qe.type===y?(ct=Cd(qe.props.children,Be.mode,ct,qe.key),ct.return=Be,Be=ct):(ct=ov(qe.type,qe.key,qe.props,null,Be.mode,ct),wg(ct,qe),ct.return=Be,Be=ct)}return X(Be);case x:e:{for(zt=qe.key;Re!==null;){if(Re.key===zt)if(Re.tag===4&&Re.stateNode.containerInfo===qe.containerInfo&&Re.stateNode.implementation===qe.implementation){_(Be,Re.sibling),ct=P(Re,qe.children||[]),ct.return=Be,Be=ct;break e}else{_(Be,Re);break}else p(Be,Re);Re=Re.sibling}ct=PM(qe,Be.mode,ct),ct.return=Be,Be=ct}return X(Be);case I:return qe=Dd(qe),Vn(Be,Re,qe,ct)}if(W(qe))return Rt(Be,Re,qe,ct);if(j(qe)){if(zt=j(qe),typeof zt!="function")throw Error(r(150));return qe=zt.call(qe),Vt(Be,Re,qe,ct)}if(typeof qe.then=="function")return Vn(Be,Re,pv(qe),ct);if(qe.$$typeof===S)return Vn(Be,Re,uv(Be,qe),ct);mv(Be,qe)}return typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint"?(qe=""+qe,Re!==null&&Re.tag===6?(_(Be,Re.sibling),ct=P(Re,qe),ct.return=Be,Be=ct):(_(Be,Re),ct=kM(qe,Be.mode,ct),ct.return=Be,Be=ct),X(Be)):_(Be,Re)}return function(Be,Re,qe,ct){try{_g=0;var zt=Vn(Be,Re,qe,ct);return Cf=null,zt}catch(Lt){if(Lt===Tf||Lt===hv)throw Lt;var Mn=ta(29,Lt,null,Be.mode);return Mn.lanes=ct,Mn.return=Be,Mn}finally{}}}var jd=iI(!0),sI=iI(!1),Wc=!1;function $M(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function VM(h,p){h=h.updateQueue,p.updateQueue===h&&(p.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function qc(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Kc(h,p,_){var w=h.updateQueue;if(w===null)return null;if(w=w.shared,(Nn&2)!==0){var P=w.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),w.pending=p,p=av(h),HL(h,null,_),p}return sv(h,w,p,_),av(h)}function Sg(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,Qn(h,_)}}function GM(h,p){var _=h.updateQueue,w=h.alternate;if(w!==null&&(w=w.updateQueue,_===w)){var P=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var X={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?P=O=X:O=O.next=X,_=_.next}while(_!==null);O===null?P=O=p:O=O.next=p}else P=O=p;_={baseState:w.baseState,firstBaseUpdate:P,lastBaseUpdate:O,shared:w.shared,callbacks:w.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=p:h.next=p,_.lastBaseUpdate=p}var WM=!1;function Eg(){if(WM){var h=Af;if(h!==null)throw h}}function Mg(h,p,_,w){WM=!1;var P=h.updateQueue;Wc=!1;var O=P.firstBaseUpdate,X=P.lastBaseUpdate,oe=P.shared.pending;if(oe!==null){P.shared.pending=null;var Me=oe,Ke=Me.next;Me.next=null,X===null?O=Ke:X.next=Ke,X=Me;var lt=h.alternate;lt!==null&&(lt=lt.updateQueue,oe=lt.lastBaseUpdate,oe!==X&&(oe===null?lt.firstBaseUpdate=Ke:oe.next=Ke,lt.lastBaseUpdate=Me))}if(O!==null){var dt=P.baseState;X=0,lt=Ke=Me=null,oe=O;do{var Qe=oe.lane&-536870913,it=Qe!==oe.lane;if(it?(bn&Qe)===Qe:(w&Qe)===Qe){Qe!==0&&Qe===Mf&&(WM=!0),lt!==null&&(lt=lt.next={lane:0,tag:oe.tag,payload:oe.payload,callback:null,next:null});e:{var Rt=h,Vt=oe;Qe=p;var Vn=_;switch(Vt.tag){case 1:if(Rt=Vt.payload,typeof Rt=="function"){dt=Rt.call(Vn,dt,Qe);break e}dt=Rt;break e;case 3:Rt.flags=Rt.flags&-65537|128;case 0:if(Rt=Vt.payload,Qe=typeof Rt=="function"?Rt.call(Vn,dt,Qe):Rt,Qe==null)break e;dt=f({},dt,Qe);break e;case 2:Wc=!0}}Qe=oe.callback,Qe!==null&&(h.flags|=64,it&&(h.flags|=8192),it=P.callbacks,it===null?P.callbacks=[Qe]:it.push(Qe))}else it={lane:Qe,tag:oe.tag,payload:oe.payload,callback:oe.callback,next:null},lt===null?(Ke=lt=it,Me=dt):lt=lt.next=it,X|=Qe;if(oe=oe.next,oe===null){if(oe=P.shared.pending,oe===null)break;it=oe,oe=it.next,it.next=null,P.lastBaseUpdate=it,P.shared.pending=null}}while(!0);lt===null&&(Me=dt),P.baseState=Me,P.firstBaseUpdate=Ke,P.lastBaseUpdate=lt,O===null&&(P.shared.lanes=0),Jc|=X,h.lanes=X,h.memoizedState=dt}}function aI(h,p){if(typeof h!="function")throw Error(r(191,h));h.call(p)}function oI(h,p){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)aI(_[h],p)}var Nf=U(null),gv=U(0);function lI(h,p){h=Fl,ee(gv,h),ee(Nf,p),Fl=h|p.baseLanes}function qM(){ee(gv,Fl),ee(Nf,Nf.current)}function KM(){Fl=gv.current,z(Nf),z(gv)}var na=U(null),Na=null;function Xc(h){var p=h.alternate;ee(jr,jr.current&1),ee(na,h),Na===null&&(p===null||Nf.current!==null||p.memoizedState!==null)&&(Na=h)}function XM(h){ee(jr,jr.current),ee(na,h),Na===null&&(Na=h)}function cI(h){h.tag===22?(ee(jr,jr.current),ee(na,h),Na===null&&(Na=h)):Yc()}function Yc(){ee(jr,jr.current),ee(na,na.current)}function ra(h){z(na),Na===h&&(Na=null),z(jr)}var jr=U(0);function xv(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||tA(_)||nA(_)))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===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var Pl=0,en=null,Hn=null,Hr=null,bv=!1,kf=!1,Ld=!1,vv=0,Ag=0,Pf=null,ine=0;function Ar(){throw Error(r(321))}function YM(h,p){if(p===null)return!1;for(var _=0;_<p.length&&_<h.length;_++)if(!ea(h[_],p[_]))return!1;return!0}function ZM(h,p,_,w,P,O){return Pl=O,en=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,K.H=h===null||h.memoizedState===null?WI:h2,Ld=!1,O=_(w,P),Ld=!1,kf&&(O=dI(p,_,w,P)),uI(h),O}function uI(h){K.H=Ng;var p=Hn!==null&&Hn.next!==null;if(Pl=0,Hr=Hn=en=null,bv=!1,Ag=0,Pf=null,p)throw Error(r(300));h===null||$r||(h=h.dependencies,h!==null&&cv(h)&&($r=!0))}function dI(h,p,_,w){en=h;var P=0;do{if(kf&&(Pf=null),Ag=0,kf=!1,25<=P)throw Error(r(301));if(P+=1,Hr=Hn=null,h.updateQueue!=null){var O=h.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}K.H=qI,O=p(_,w)}while(kf);return O}function sne(){var h=K.H,p=h.useState()[0];return p=typeof p.then=="function"?Tg(p):p,h=h.useState()[0],(Hn!==null?Hn.memoizedState:null)!==h&&(en.flags|=1024),p}function QM(){var h=vv!==0;return vv=0,h}function JM(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function e2(h){if(bv){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}bv=!1}Pl=0,Hr=Hn=en=null,kf=!1,Ag=vv=0,Pf=null}function bs(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Hr===null?en.memoizedState=Hr=h:Hr=Hr.next=h,Hr}function Lr(){if(Hn===null){var h=en.alternate;h=h!==null?h.memoizedState:null}else h=Hn.next;var p=Hr===null?en.memoizedState:Hr.next;if(p!==null)Hr=p,Hn=h;else{if(h===null)throw en.alternate===null?Error(r(467)):Error(r(310));Hn=h,h={memoizedState:Hn.memoizedState,baseState:Hn.baseState,baseQueue:Hn.baseQueue,queue:Hn.queue,next:null},Hr===null?en.memoizedState=Hr=h:Hr=Hr.next=h}return Hr}function yv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Tg(h){var p=Ag;return Ag+=1,Pf===null&&(Pf=[]),h=tI(Pf,h,p),p=en,(Hr===null?p.memoizedState:Hr.next)===null&&(p=p.alternate,K.H=p===null||p.memoizedState===null?WI:h2),h}function _v(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Tg(h);if(h.$$typeof===S)return Bi(h)}throw Error(r(438,String(h)))}function t2(h){var p=null,_=en.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var w=en.alternate;w!==null&&(w=w.updateQueue,w!==null&&(w=w.memoCache,w!=null&&(p={data:w.data.map(function(P){return P.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),_===null&&(_=yv(),en.updateQueue=_),_.memoCache=p,_=p.data[p.index],_===void 0)for(_=p.data[p.index]=Array(h),w=0;w<h;w++)_[w]=D;return p.index++,_}function Rl(h,p){return typeof p=="function"?p(h):p}function wv(h){var p=Lr();return n2(p,Hn,h)}function n2(h,p,_){var w=h.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=_;var P=h.baseQueue,O=w.pending;if(O!==null){if(P!==null){var X=P.next;P.next=O.next,O.next=X}p.baseQueue=P=O,w.pending=null}if(O=h.baseState,P===null)h.memoizedState=O;else{p=P.next;var oe=X=null,Me=null,Ke=p,lt=!1;do{var dt=Ke.lane&-536870913;if(dt!==Ke.lane?(bn&dt)===dt:(Pl&dt)===dt){var Qe=Ke.revertLane;if(Qe===0)Me!==null&&(Me=Me.next={lane:0,revertLane:0,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null}),dt===Mf&&(lt=!0);else if((Pl&Qe)===Qe){Ke=Ke.next,Qe===Mf&&(lt=!0);continue}else dt={lane:0,revertLane:Ke.revertLane,gesture:null,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},Me===null?(oe=Me=dt,X=O):Me=Me.next=dt,en.lanes|=Qe,Jc|=Qe;dt=Ke.action,Ld&&_(O,dt),O=Ke.hasEagerState?Ke.eagerState:_(O,dt)}else Qe={lane:dt,revertLane:Ke.revertLane,gesture:Ke.gesture,action:Ke.action,hasEagerState:Ke.hasEagerState,eagerState:Ke.eagerState,next:null},Me===null?(oe=Me=Qe,X=O):Me=Me.next=Qe,en.lanes|=dt,Jc|=dt;Ke=Ke.next}while(Ke!==null&&Ke!==p);if(Me===null?X=O:Me.next=oe,!ea(O,h.memoizedState)&&($r=!0,lt&&(_=Af,_!==null)))throw _;h.memoizedState=O,h.baseState=X,h.baseQueue=Me,w.lastRenderedState=O}return P===null&&(w.lanes=0),[h.memoizedState,w.dispatch]}function r2(h){var p=Lr(),_=p.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var w=_.dispatch,P=_.pending,O=p.memoizedState;if(P!==null){_.pending=null;var X=P=P.next;do O=h(O,X.action),X=X.next;while(X!==P);ea(O,p.memoizedState)||($r=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),_.lastRenderedState=O}return[O,w]}function hI(h,p,_){var w=en,P=Lr(),O=_n;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=p();var X=!ea((Hn||P).memoizedState,_);if(X&&(P.memoizedState=_,$r=!0),P=P.queue,a2(mI.bind(null,w,P,h),[h]),P.getSnapshot!==p||X||Hr!==null&&Hr.memoizedState.tag&1){if(w.flags|=2048,Rf(9,{destroy:void 0},pI.bind(null,w,P,_,p),null),Jn===null)throw Error(r(349));O||(Pl&127)!==0||fI(w,p,_)}return _}function fI(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=en.updateQueue,p===null?(p=yv(),en.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function pI(h,p,_,w){p.value=_,p.getSnapshot=w,gI(p)&&xI(h)}function mI(h,p,_){return _(function(){gI(p)&&xI(h)})}function gI(h){var p=h.getSnapshot;h=h.value;try{var _=p();return!ea(h,_)}catch{return!0}}function xI(h){var p=Td(h,2);p!==null&&Us(p,h,2)}function i2(h){var p=bs();if(typeof h=="function"){var _=h;if(h=_(),Ld){Ye(!0);try{_()}finally{Ye(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rl,lastRenderedState:h},p}function bI(h,p,_,w){return h.baseState=_,n2(h,Hn,typeof w=="function"?w:Rl)}function ane(h,p,_,w,P){if(Mv(h))throw Error(r(485));if(h=p.action,h!==null){var O={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(X){O.listeners.push(X)}};K.T!==null?_(!0):O.isTransition=!1,w(O),_=p.pending,_===null?(O.next=p.pending=O,vI(p,O)):(O.next=_.next,p.pending=_.next=O)}}function vI(h,p){var _=p.action,w=p.payload,P=h.state;if(p.isTransition){var O=K.T,X={};K.T=X;try{var oe=_(P,w),Me=K.S;Me!==null&&Me(X,oe),yI(h,p,oe)}catch(Ke){s2(h,p,Ke)}finally{O!==null&&X.types!==null&&(O.types=X.types),K.T=O}}else try{O=_(P,w),yI(h,p,O)}catch(Ke){s2(h,p,Ke)}}function yI(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(w){_I(h,p,w)},function(w){return s2(h,p,w)}):_I(h,p,_)}function _I(h,p,_){p.status="fulfilled",p.value=_,wI(p),h.state=_,p=h.pending,p!==null&&(_=p.next,_===p?h.pending=null:(_=_.next,p.next=_,vI(h,_)))}function s2(h,p,_){var w=h.pending;if(h.pending=null,w!==null){w=w.next;do p.status="rejected",p.reason=_,wI(p),p=p.next;while(p!==w)}h.action=null}function wI(h){h=h.listeners;for(var p=0;p<h.length;p++)(0,h[p])()}function SI(h,p){return p}function EI(h,p){if(_n){var _=Jn.formState;if(_!==null){e:{var w=en;if(_n){if(ar){t:{for(var P=ar,O=Ca;P.nodeType!==8;){if(!O){P=null;break t}if(P=ka(P.nextSibling),P===null){P=null;break t}}O=P.data,P=O==="F!"||O==="F"?P:null}if(P){ar=ka(P.nextSibling),w=P.data==="F!";break e}}Vc(w)}w=!1}w&&(p=_[0])}}return _=bs(),_.memoizedState=_.baseState=p,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:SI,lastRenderedState:p},_.queue=w,_=$I.bind(null,en,w),w.dispatch=_,w=i2(!1),O=d2.bind(null,en,!1,w.queue),w=bs(),P={state:p,dispatch:null,action:h,pending:null},w.queue=P,_=ane.bind(null,en,P,O,_),P.dispatch=_,w.memoizedState=h,[p,_,!1]}function MI(h){var p=Lr();return AI(p,Hn,h)}function AI(h,p,_){if(p=n2(h,p,SI)[0],h=wv(Rl)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var w=Tg(p)}catch(X){throw X===Tf?hv:X}else w=p;p=Lr();var P=p.queue,O=P.dispatch;return _!==p.memoizedState&&(en.flags|=2048,Rf(9,{destroy:void 0},one.bind(null,P,_),null)),[w,O,h]}function one(h,p){h.action=p}function TI(h){var p=Lr(),_=Hn;if(_!==null)return AI(p,_,h);Lr(),p=p.memoizedState,_=Lr();var w=_.queue.dispatch;return _.memoizedState=h,[p,w,!1]}function Rf(h,p,_,w){return h={tag:h,create:_,deps:w,inst:p,next:null},p=en.updateQueue,p===null&&(p=yv(),en.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(w=_.next,_.next=h,h.next=w,p.lastEffect=h),h}function CI(){return Lr().memoizedState}function Sv(h,p,_,w){var P=bs();en.flags|=h,P.memoizedState=Rf(1|p,{destroy:void 0},_,w===void 0?null:w)}function Ev(h,p,_,w){var P=Lr();w=w===void 0?null:w;var O=P.memoizedState.inst;Hn!==null&&w!==null&&YM(w,Hn.memoizedState.deps)?P.memoizedState=Rf(p,O,_,w):(en.flags|=h,P.memoizedState=Rf(1|p,O,_,w))}function NI(h,p){Sv(8390656,8,h,p)}function a2(h,p){Ev(2048,8,h,p)}function lne(h){en.flags|=4;var p=en.updateQueue;if(p===null)p=yv(),en.updateQueue=p,p.events=[h];else{var _=p.events;_===null?p.events=[h]:_.push(h)}}function kI(h){var p=Lr().memoizedState;return lne({ref:p,nextImpl:h}),function(){if((Nn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function PI(h,p){return Ev(4,2,h,p)}function RI(h,p){return Ev(4,4,h,p)}function DI(h,p){if(typeof p=="function"){h=h();var _=p(h);return function(){typeof _=="function"?_():p(null)}}if(p!=null)return h=h(),p.current=h,function(){p.current=null}}function OI(h,p,_){_=_!=null?_.concat([h]):null,Ev(4,4,DI.bind(null,p,h),_)}function o2(){}function jI(h,p){var _=Lr();p=p===void 0?null:p;var w=_.memoizedState;return p!==null&&YM(p,w[1])?w[0]:(_.memoizedState=[h,p],h)}function LI(h,p){var _=Lr();p=p===void 0?null:p;var w=_.memoizedState;if(p!==null&&YM(p,w[1]))return w[0];if(w=h(),Ld){Ye(!0);try{h()}finally{Ye(!1)}}return _.memoizedState=[w,p],w}function l2(h,p,_){return _===void 0||(Pl&1073741824)!==0&&(bn&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=I4(),en.lanes|=h,Jc|=h,_)}function II(h,p,_,w){return ea(_,p)?_:Nf.current!==null?(h=l2(h,_,w),ea(h,p)||($r=!0),h):(Pl&42)===0||(Pl&1073741824)!==0&&(bn&261930)===0?($r=!0,h.memoizedState=_):(h=I4(),en.lanes|=h,Jc|=h,p)}function UI(h,p,_,w,P){var O=V.p;V.p=O!==0&&8>O?O:8;var X=K.T,oe={};K.T=oe,d2(h,!1,p,_);try{var Me=P(),Ke=K.S;if(Ke!==null&&Ke(oe,Me),Me!==null&&typeof Me=="object"&&typeof Me.then=="function"){var lt=rne(Me,w);Cg(h,p,lt,aa(h))}else Cg(h,p,w,aa(h))}catch(dt){Cg(h,p,{then:function(){},status:"rejected",reason:dt},aa())}finally{V.p=O,X!==null&&oe.types!==null&&(X.types=oe.types),K.T=X}}function cne(){}function c2(h,p,_,w){if(h.tag!==5)throw Error(r(476));var P=FI(h).queue;UI(h,P,p,te,_===null?cne:function(){return zI(h),_(w)})}function FI(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rl,lastRenderedState:te},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rl,lastRenderedState:_},next:null},h.memoizedState=p,h=h.alternate,h!==null&&(h.memoizedState=p),p}function zI(h){var p=FI(h);p.next===null&&(p=h.alternate.memoizedState),Cg(h,p.next.queue,{},aa())}function u2(){return Bi(Gg)}function BI(){return Lr().memoizedState}function HI(){return Lr().memoizedState}function une(h){for(var p=h.return;p!==null;){switch(p.tag){case 24:case 3:var _=aa();h=qc(_);var w=Kc(p,h,_);w!==null&&(Us(w,p,_),Sg(w,p,_)),p={cache:FM()},h.payload=p;return}p=p.return}}function dne(h,p,_){var w=aa();_={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Mv(h)?VI(p,_):(_=CM(h,p,_,w),_!==null&&(Us(_,h,w),GI(_,p,w)))}function $I(h,p,_){var w=aa();Cg(h,p,_,w)}function Cg(h,p,_,w){var P={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Mv(h))VI(p,P);else{var O=h.alternate;if(h.lanes===0&&(O===null||O.lanes===0)&&(O=p.lastRenderedReducer,O!==null))try{var X=p.lastRenderedState,oe=O(X,_);if(P.hasEagerState=!0,P.eagerState=oe,ea(oe,X))return sv(h,p,P,0),Jn===null&&iv(),!1}catch{}finally{}if(_=CM(h,p,P,w),_!==null)return Us(_,h,w),GI(_,p,w),!0}return!1}function d2(h,p,_,w){if(w={lane:2,revertLane:$2(),gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Mv(h)){if(p)throw Error(r(479))}else p=CM(h,_,w,2),p!==null&&Us(p,h,2)}function Mv(h){var p=h.alternate;return h===en||p!==null&&p===en}function VI(h,p){kf=bv=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function GI(h,p,_){if((_&4194048)!==0){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,Qn(h,_)}}var Ng={readContext:Bi,use:_v,useCallback:Ar,useContext:Ar,useEffect:Ar,useImperativeHandle:Ar,useLayoutEffect:Ar,useInsertionEffect:Ar,useMemo:Ar,useReducer:Ar,useRef:Ar,useState:Ar,useDebugValue:Ar,useDeferredValue:Ar,useTransition:Ar,useSyncExternalStore:Ar,useId:Ar,useHostTransitionStatus:Ar,useFormState:Ar,useActionState:Ar,useOptimistic:Ar,useMemoCache:Ar,useCacheRefresh:Ar};Ng.useEffectEvent=Ar;var WI={readContext:Bi,use:_v,useCallback:function(h,p){return bs().memoizedState=[h,p===void 0?null:p],h},useContext:Bi,useEffect:NI,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,Sv(4194308,4,DI.bind(null,p,h),_)},useLayoutEffect:function(h,p){return Sv(4194308,4,h,p)},useInsertionEffect:function(h,p){Sv(4,2,h,p)},useMemo:function(h,p){var _=bs();p=p===void 0?null:p;var w=h();if(Ld){Ye(!0);try{h()}finally{Ye(!1)}}return _.memoizedState=[w,p],w},useReducer:function(h,p,_){var w=bs();if(_!==void 0){var P=_(p);if(Ld){Ye(!0);try{_(p)}finally{Ye(!1)}}}else P=p;return w.memoizedState=w.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},w.queue=h,h=h.dispatch=dne.bind(null,en,h),[w.memoizedState,h]},useRef:function(h){var p=bs();return h={current:h},p.memoizedState=h},useState:function(h){h=i2(h);var p=h.queue,_=$I.bind(null,en,p);return p.dispatch=_,[h.memoizedState,_]},useDebugValue:o2,useDeferredValue:function(h,p){var _=bs();return l2(_,h,p)},useTransition:function(){var h=i2(!1);return h=UI.bind(null,en,h.queue,!0,!1),bs().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var w=en,P=bs();if(_n){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Jn===null)throw Error(r(349));(bn&127)!==0||fI(w,p,_)}P.memoizedState=_;var O={value:_,getSnapshot:p};return P.queue=O,NI(mI.bind(null,w,O,h),[h]),w.flags|=2048,Rf(9,{destroy:void 0},pI.bind(null,w,O,_,p),null),_},useId:function(){var h=bs(),p=Jn.identifierPrefix;if(_n){var _=Vo,w=$o;_=(w&~(1<<32-$e(w)-1)).toString(32)+_,p="_"+p+"R_"+_,_=vv++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=ine++,p="_"+p+"r_"+_.toString(32)+"_";return h.memoizedState=p},useHostTransitionStatus:u2,useFormState:EI,useActionState:EI,useOptimistic:function(h){var p=bs();p.memoizedState=p.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=d2.bind(null,en,!0,_),_.dispatch=p,[h,p]},useMemoCache:t2,useCacheRefresh:function(){return bs().memoizedState=une.bind(null,en)},useEffectEvent:function(h){var p=bs(),_={impl:h};return p.memoizedState=_,function(){if((Nn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},h2={readContext:Bi,use:_v,useCallback:jI,useContext:Bi,useEffect:a2,useImperativeHandle:OI,useInsertionEffect:PI,useLayoutEffect:RI,useMemo:LI,useReducer:wv,useRef:CI,useState:function(){return wv(Rl)},useDebugValue:o2,useDeferredValue:function(h,p){var _=Lr();return II(_,Hn.memoizedState,h,p)},useTransition:function(){var h=wv(Rl)[0],p=Lr().memoizedState;return[typeof h=="boolean"?h:Tg(h),p]},useSyncExternalStore:hI,useId:BI,useHostTransitionStatus:u2,useFormState:MI,useActionState:MI,useOptimistic:function(h,p){var _=Lr();return bI(_,Hn,h,p)},useMemoCache:t2,useCacheRefresh:HI};h2.useEffectEvent=kI;var qI={readContext:Bi,use:_v,useCallback:jI,useContext:Bi,useEffect:a2,useImperativeHandle:OI,useInsertionEffect:PI,useLayoutEffect:RI,useMemo:LI,useReducer:r2,useRef:CI,useState:function(){return r2(Rl)},useDebugValue:o2,useDeferredValue:function(h,p){var _=Lr();return Hn===null?l2(_,h,p):II(_,Hn.memoizedState,h,p)},useTransition:function(){var h=r2(Rl)[0],p=Lr().memoizedState;return[typeof h=="boolean"?h:Tg(h),p]},useSyncExternalStore:hI,useId:BI,useHostTransitionStatus:u2,useFormState:TI,useActionState:TI,useOptimistic:function(h,p){var _=Lr();return Hn!==null?bI(_,Hn,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:t2,useCacheRefresh:HI};qI.useEffectEvent=kI;function f2(h,p,_,w){p=h.memoizedState,_=_(w,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var p2={enqueueSetState:function(h,p,_){h=h._reactInternals;var w=aa(),P=qc(w);P.payload=p,_!=null&&(P.callback=_),p=Kc(h,P,w),p!==null&&(Us(p,h,w),Sg(p,h,w))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var w=aa(),P=qc(w);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=Kc(h,P,w),p!==null&&(Us(p,h,w),Sg(p,h,w))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=aa(),w=qc(_);w.tag=2,p!=null&&(w.callback=p),p=Kc(h,w,_),p!==null&&(Us(p,h,_),Sg(p,h,_))}};function KI(h,p,_,w,P,O,X){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(w,O,X):p.prototype&&p.prototype.isPureReactComponent?!mg(_,w)||!mg(P,O):!0}function XI(h,p,_,w){h=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(_,w),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(_,w),p.state!==h&&p2.enqueueReplaceState(p,p.state,null)}function Id(h,p){var _=p;if("ref"in p){_={};for(var w in p)w!=="ref"&&(_[w]=p[w])}if(h=h.defaultProps){_===p&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function YI(h){rv(h)}function ZI(h){console.error(h)}function QI(h){rv(h)}function Av(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(w){setTimeout(function(){throw w})}}function JI(h,p,_){try{var w=h.onCaughtError;w(_.value,{componentStack:_.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function m2(h,p,_){return _=qc(_),_.tag=3,_.payload={element:null},_.callback=function(){Av(h,p)},_}function e4(h){return h=qc(h),h.tag=3,h}function t4(h,p,_,w){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var O=w.value;h.payload=function(){return P(O)},h.callback=function(){JI(p,_,w)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(h.callback=function(){JI(p,_,w),typeof P!="function"&&(eu===null?eu=new Set([this]):eu.add(this));var oe=w.stack;this.componentDidCatch(w.value,{componentStack:oe!==null?oe:""})})}function hne(h,p,_,w,P){if(_.flags|=32768,w!==null&&typeof w=="object"&&typeof w.then=="function"){if(p=_.alternate,p!==null&&Ef(p,_,P,!0),_=na.current,_!==null){switch(_.tag){case 31:case 13:return Na===null?Uv():_.alternate===null&&Tr===0&&(Tr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,w===fv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([w]):p.add(w),z2(h,w,P)),!1;case 22:return _.flags|=65536,w===fv?_.flags|=16384:(p=_.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([w])},_.updateQueue=p):(_=p.retryQueue,_===null?p.retryQueue=new Set([w]):_.add(w)),z2(h,w,P)),!1}throw Error(r(435,_.tag))}return z2(h,w,P),Uv(),!1}if(_n)return p=na.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,w!==OM&&(h=Error(r(422),{cause:w}),bg(Ma(h,_)))):(w!==OM&&(p=Error(r(423),{cause:w}),bg(Ma(p,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,w=Ma(w,_),P=m2(h.stateNode,w,P),GM(h,P),Tr!==4&&(Tr=2)),!1;var O=Error(r(520),{cause:w});if(O=Ma(O,_),Ig===null?Ig=[O]:Ig.push(O),Tr!==4&&(Tr=2),p===null)return!0;w=Ma(w,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=m2(_.stateNode,w,h),GM(_,h),!1;case 1:if(p=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(eu===null||!eu.has(O))))return _.flags|=65536,P&=-P,_.lanes|=P,P=e4(P),t4(P,h,_,w),GM(_,P),!1}_=_.return}while(_!==null);return!1}var g2=Error(r(461)),$r=!1;function Hi(h,p,_,w){p.child=h===null?sI(p,null,_,w):jd(p,h.child,_,w)}function n4(h,p,_,w,P){_=_.render;var O=p.ref;if("ref"in w){var X={};for(var oe in w)oe!=="ref"&&(X[oe]=w[oe])}else X=w;return Pd(p),w=ZM(h,p,_,X,O,P),oe=QM(),h!==null&&!$r?(JM(h,p,P),Dl(h,p,P)):(_n&&oe&&RM(p),p.flags|=1,Hi(h,p,w,P),p.child)}function r4(h,p,_,w,P){if(h===null){var O=_.type;return typeof O=="function"&&!NM(O)&&O.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=O,i4(h,p,O,w,P)):(h=ov(_.type,null,w,p,p.mode,P),h.ref=p.ref,h.return=p,p.child=h)}if(O=h.child,!E2(h,P)){var X=O.memoizedProps;if(_=_.compare,_=_!==null?_:mg,_(X,w)&&h.ref===p.ref)return Dl(h,p,P)}return p.flags|=1,h=Tl(O,w),h.ref=p.ref,h.return=p,p.child=h}function i4(h,p,_,w,P){if(h!==null){var O=h.memoizedProps;if(mg(O,w)&&h.ref===p.ref)if($r=!1,p.pendingProps=w=O,E2(h,P))(h.flags&131072)!==0&&($r=!0);else return p.lanes=h.lanes,Dl(h,p,P)}return x2(h,p,_,w,P)}function s4(h,p,_,w){var P=w.children,O=h!==null?h.memoizedState:null;if(h===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),w.mode==="hidden"){if((p.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,h!==null){for(w=p.child=h.child,P=0;w!==null;)P=P|w.lanes|w.childLanes,w=w.sibling;w=P&~O}else w=0,p.child=null;return a4(h,p,O,_,w)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&dv(p,O!==null?O.cachePool:null),O!==null?lI(p,O):qM(),cI(p);else return w=p.lanes=536870912,a4(h,p,O!==null?O.baseLanes|_:_,_,w)}else O!==null?(dv(p,O.cachePool),lI(p,O),Yc(),p.memoizedState=null):(h!==null&&dv(p,null),qM(),Yc());return Hi(h,p,P,_),p.child}function kg(h,p){return h!==null&&h.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function a4(h,p,_,w,P){var O=BM();return O=O===null?null:{parent:Br._currentValue,pool:O},p.memoizedState={baseLanes:_,cachePool:O},h!==null&&dv(p,null),qM(),cI(p),h!==null&&Ef(h,p,w,!0),p.childLanes=P,null}function Tv(h,p){return p=Nv({mode:p.mode,children:p.children},h.mode),p.ref=h.ref,h.child=p,p.return=h,p}function o4(h,p,_){return jd(p,h.child,null,_),h=Tv(p,p.pendingProps),h.flags|=2,ra(p),p.memoizedState=null,h}function fne(h,p,_){var w=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(_n){if(w.mode==="hidden")return h=Tv(p,w),p.lanes=536870912,kg(null,h);if(XM(p),(h=ar)?(h=vU(h,Ca),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Hc!==null?{id:$o,overflow:Vo}:null,retryLane:536870912,hydrationErrors:null},_=VL(h),_.return=p,p.child=_,zi=p,ar=null)):h=null,h===null)throw Vc(p);return p.lanes=536870912,null}return Tv(p,w)}var O=h.memoizedState;if(O!==null){var X=O.dehydrated;if(XM(p),P)if(p.flags&256)p.flags&=-257,p=o4(h,p,_);else if(p.memoizedState!==null)p.child=h.child,p.flags|=128,p=null;else throw Error(r(558));else if($r||Ef(h,p,_,!1),P=(_&h.childLanes)!==0,$r||P){if(w=Jn,w!==null&&(X=wi(w,_),X!==0&&X!==O.retryLane))throw O.retryLane=X,Td(h,X),Us(w,h,X),g2;Uv(),p=o4(h,p,_)}else h=O.treeContext,ar=ka(X.nextSibling),zi=p,_n=!0,$c=null,Ca=!1,h!==null&&qL(p,h),p=Tv(p,w),p.flags|=4096;return p}return h=Tl(h.child,{mode:w.mode,children:w.children}),h.ref=p.ref,p.child=h,h.return=p,h}function Cv(h,p){var _=p.ref;if(_===null)h!==null&&h.ref!==null&&(p.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(p.flags|=4194816)}}function x2(h,p,_,w,P){return Pd(p),_=ZM(h,p,_,w,void 0,P),w=QM(),h!==null&&!$r?(JM(h,p,P),Dl(h,p,P)):(_n&&w&&RM(p),p.flags|=1,Hi(h,p,_,P),p.child)}function l4(h,p,_,w,P,O){return Pd(p),p.updateQueue=null,_=dI(p,w,_,P),uI(h),w=QM(),h!==null&&!$r?(JM(h,p,O),Dl(h,p,O)):(_n&&w&&RM(p),p.flags|=1,Hi(h,p,_,O),p.child)}function c4(h,p,_,w,P){if(Pd(p),p.stateNode===null){var O=yf,X=_.contextType;typeof X=="object"&&X!==null&&(O=Bi(X)),O=new _(w,O),p.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=p2,p.stateNode=O,O._reactInternals=p,O=p.stateNode,O.props=w,O.state=p.memoizedState,O.refs={},$M(p),X=_.contextType,O.context=typeof X=="object"&&X!==null?Bi(X):yf,O.state=p.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(f2(p,_,X,w),O.state=p.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(X=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),X!==O.state&&p2.enqueueReplaceState(O,O.state,null),Mg(p,w,O,P),Eg(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),w=!0}else if(h===null){O=p.stateNode;var oe=p.memoizedProps,Me=Id(_,oe);O.props=Me;var Ke=O.context,lt=_.contextType;X=yf,typeof lt=="object"&<!==null&&(X=Bi(lt));var dt=_.getDerivedStateFromProps;lt=typeof dt=="function"||typeof O.getSnapshotBeforeUpdate=="function",oe=p.pendingProps!==oe,lt||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(oe||Ke!==X)&&XI(p,O,w,X),Wc=!1;var Qe=p.memoizedState;O.state=Qe,Mg(p,w,O,P),Eg(),Ke=p.memoizedState,oe||Qe!==Ke||Wc?(typeof dt=="function"&&(f2(p,_,dt,w),Ke=p.memoizedState),(Me=Wc||KI(p,_,Me,w,Qe,Ke,X))?(lt||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=w,p.memoizedState=Ke),O.props=w,O.state=Ke,O.context=X,w=Me):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),w=!1)}else{O=p.stateNode,VM(h,p),X=p.memoizedProps,lt=Id(_,X),O.props=lt,dt=p.pendingProps,Qe=O.context,Ke=_.contextType,Me=yf,typeof Ke=="object"&&Ke!==null&&(Me=Bi(Ke)),oe=_.getDerivedStateFromProps,(Ke=typeof oe=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(X!==dt||Qe!==Me)&&XI(p,O,w,Me),Wc=!1,Qe=p.memoizedState,O.state=Qe,Mg(p,w,O,P),Eg();var it=p.memoizedState;X!==dt||Qe!==it||Wc||h!==null&&h.dependencies!==null&&cv(h.dependencies)?(typeof oe=="function"&&(f2(p,_,oe,w),it=p.memoizedState),(lt=Wc||KI(p,_,lt,w,Qe,it,Me)||h!==null&&h.dependencies!==null&&cv(h.dependencies))?(Ke||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(w,it,Me),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(w,it,Me)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=1024),p.memoizedProps=w,p.memoizedState=it),O.props=w,O.state=it,O.context=Me,w=lt):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Qe===h.memoizedState||(p.flags|=1024),w=!1)}return O=w,Cv(h,p),w=(p.flags&128)!==0,O||w?(O=p.stateNode,_=w&&typeof _.getDerivedStateFromError!="function"?null:O.render(),p.flags|=1,h!==null&&w?(p.child=jd(p,h.child,null,P),p.child=jd(p,null,_,P)):Hi(h,p,_,P),p.memoizedState=O.state,h=p.child):h=Dl(h,p,P),h}function u4(h,p,_,w){return Nd(),p.flags|=256,Hi(h,p,_,w),p.child}var b2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function v2(h){return{baseLanes:h,cachePool:JL()}}function y2(h,p,_){return h=h!==null?h.childLanes&~_:0,p&&(h|=sa),h}function d4(h,p,_){var w=p.pendingProps,P=!1,O=(p.flags&128)!==0,X;if((X=O)||(X=h!==null&&h.memoizedState===null?!1:(jr.current&2)!==0),X&&(P=!0,p.flags&=-129),X=(p.flags&32)!==0,p.flags&=-33,h===null){if(_n){if(P?Xc(p):Yc(),(h=ar)?(h=vU(h,Ca),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Hc!==null?{id:$o,overflow:Vo}:null,retryLane:536870912,hydrationErrors:null},_=VL(h),_.return=p,p.child=_,zi=p,ar=null)):h=null,h===null)throw Vc(p);return nA(h)?p.lanes=32:p.lanes=536870912,null}var oe=w.children;return w=w.fallback,P?(Yc(),P=p.mode,oe=Nv({mode:"hidden",children:oe},P),w=Cd(w,P,_,null),oe.return=p,w.return=p,oe.sibling=w,p.child=oe,w=p.child,w.memoizedState=v2(_),w.childLanes=y2(h,X,_),p.memoizedState=b2,kg(null,w)):(Xc(p),_2(p,oe))}var Me=h.memoizedState;if(Me!==null&&(oe=Me.dehydrated,oe!==null)){if(O)p.flags&256?(Xc(p),p.flags&=-257,p=w2(h,p,_)):p.memoizedState!==null?(Yc(),p.child=h.child,p.flags|=128,p=null):(Yc(),oe=w.fallback,P=p.mode,w=Nv({mode:"visible",children:w.children},P),oe=Cd(oe,P,_,null),oe.flags|=2,w.return=p,oe.return=p,w.sibling=oe,p.child=w,jd(p,h.child,null,_),w=p.child,w.memoizedState=v2(_),w.childLanes=y2(h,X,_),p.memoizedState=b2,p=kg(null,w));else if(Xc(p),nA(oe)){if(X=oe.nextSibling&&oe.nextSibling.dataset,X)var Ke=X.dgst;X=Ke,w=Error(r(419)),w.stack="",w.digest=X,bg({value:w,source:null,stack:null}),p=w2(h,p,_)}else if($r||Ef(h,p,_,!1),X=(_&h.childLanes)!==0,$r||X){if(X=Jn,X!==null&&(w=wi(X,_),w!==0&&w!==Me.retryLane))throw Me.retryLane=w,Td(h,w),Us(X,h,w),g2;tA(oe)||Uv(),p=w2(h,p,_)}else tA(oe)?(p.flags|=192,p.child=h.child,p=null):(h=Me.treeContext,ar=ka(oe.nextSibling),zi=p,_n=!0,$c=null,Ca=!1,h!==null&&qL(p,h),p=_2(p,w.children),p.flags|=4096);return p}return P?(Yc(),oe=w.fallback,P=p.mode,Me=h.child,Ke=Me.sibling,w=Tl(Me,{mode:"hidden",children:w.children}),w.subtreeFlags=Me.subtreeFlags&65011712,Ke!==null?oe=Tl(Ke,oe):(oe=Cd(oe,P,_,null),oe.flags|=2),oe.return=p,w.return=p,w.sibling=oe,p.child=w,kg(null,w),w=p.child,oe=h.child.memoizedState,oe===null?oe=v2(_):(P=oe.cachePool,P!==null?(Me=Br._currentValue,P=P.parent!==Me?{parent:Me,pool:Me}:P):P=JL(),oe={baseLanes:oe.baseLanes|_,cachePool:P}),w.memoizedState=oe,w.childLanes=y2(h,X,_),p.memoizedState=b2,kg(h.child,w)):(Xc(p),_=h.child,h=_.sibling,_=Tl(_,{mode:"visible",children:w.children}),_.return=p,_.sibling=null,h!==null&&(X=p.deletions,X===null?(p.deletions=[h],p.flags|=16):X.push(h)),p.child=_,p.memoizedState=null,_)}function _2(h,p){return p=Nv({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function Nv(h,p){return h=ta(22,h,null,p),h.lanes=0,h}function w2(h,p,_){return jd(p,h.child,null,_),h=_2(p,p.pendingProps.children),h.flags|=2,p.memoizedState=null,h}function h4(h,p,_){h.lanes|=p;var w=h.alternate;w!==null&&(w.lanes|=p),IM(h.return,p,_)}function S2(h,p,_,w,P,O){var X=h.memoizedState;X===null?h.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:w,tail:_,tailMode:P,treeForkCount:O}:(X.isBackwards=p,X.rendering=null,X.renderingStartTime=0,X.last=w,X.tail=_,X.tailMode=P,X.treeForkCount=O)}function f4(h,p,_){var w=p.pendingProps,P=w.revealOrder,O=w.tail;w=w.children;var X=jr.current,oe=(X&2)!==0;if(oe?(X=X&1|2,p.flags|=128):X&=1,ee(jr,X),Hi(h,p,w,_),w=_n?xg:0,!oe&&h!==null&&(h.flags&128)!==0)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&h4(h,_,p);else if(h.tag===19)h4(h,_,p);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===p)break e;for(;h.sibling===null;){if(h.return===null||h.return===p)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=p.child,P=null;_!==null;)h=_.alternate,h!==null&&xv(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),S2(p,!1,P,_,O,w);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=p.child,p.child=null;P!==null;){if(h=P.alternate,h!==null&&xv(h)===null){p.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}S2(p,!0,_,null,O,w);break;case"together":S2(p,!1,null,null,void 0,w);break;default:p.memoizedState=null}return p.child}function Dl(h,p,_){if(h!==null&&(p.dependencies=h.dependencies),Jc|=p.lanes,(_&p.childLanes)===0)if(h!==null){if(Ef(h,p,_,!1),(_&p.childLanes)===0)return null}else return null;if(h!==null&&p.child!==h.child)throw Error(r(153));if(p.child!==null){for(h=p.child,_=Tl(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=Tl(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function E2(h,p){return(h.lanes&p)!==0?!0:(h=h.dependencies,!!(h!==null&&cv(h)))}function pne(h,p,_){switch(p.tag){case 3:ye(p,p.stateNode.containerInfo),Gc(p,Br,h.memoizedState.cache),Nd();break;case 27:case 5:ve(p);break;case 4:ye(p,p.stateNode.containerInfo);break;case 10:Gc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,XM(p),null;break;case 13:var w=p.memoizedState;if(w!==null)return w.dehydrated!==null?(Xc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?d4(h,p,_):(Xc(p),h=Dl(h,p,_),h!==null?h.sibling:null);Xc(p);break;case 19:var P=(h.flags&128)!==0;if(w=(_&p.childLanes)!==0,w||(Ef(h,p,_,!1),w=(_&p.childLanes)!==0),P){if(w)return f4(h,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ee(jr,jr.current),w)break;return null;case 22:return p.lanes=0,s4(h,p,_,p.pendingProps);case 24:Gc(p,Br,h.memoizedState.cache)}return Dl(h,p,_)}function p4(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps)$r=!0;else{if(!E2(h,_)&&(p.flags&128)===0)return $r=!1,pne(h,p,_);$r=(h.flags&131072)!==0}else $r=!1,_n&&(p.flags&1048576)!==0&&WL(p,xg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var w=p.pendingProps;if(h=Dd(p.elementType),p.type=h,typeof h=="function")NM(h)?(w=Id(h,w),p.tag=1,p=c4(null,p,h,w,_)):(p.tag=0,p=x2(null,p,h,w,_));else{if(h!=null){var P=h.$$typeof;if(P===A){p.tag=11,p=n4(null,p,h,w,_);break e}else if(P===N){p.tag=14,p=r4(null,p,h,w,_);break e}}throw p=R(h)||h,Error(r(306,p,""))}}return p;case 0:return x2(h,p,p.type,p.pendingProps,_);case 1:return w=p.type,P=Id(w,p.pendingProps),c4(h,p,w,P,_);case 3:e:{if(ye(p,p.stateNode.containerInfo),h===null)throw Error(r(387));w=p.pendingProps;var O=p.memoizedState;P=O.element,VM(h,p),Mg(p,w,null,_);var X=p.memoizedState;if(w=X.cache,Gc(p,Br,w),w!==O.cache&&UM(p,[Br],_,!0),Eg(),w=X.element,O.isDehydrated)if(O={element:w,isDehydrated:!1,cache:X.cache},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){p=u4(h,p,w,_);break e}else if(w!==P){P=Ma(Error(r(424)),p),bg(P),p=u4(h,p,w,_);break e}else{switch(h=p.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(ar=ka(h.firstChild),zi=p,_n=!0,$c=null,Ca=!0,_=sI(p,null,w,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Nd(),w===P){p=Dl(h,p,_);break e}Hi(h,p,w,_)}p=p.child}return p;case 26:return Cv(h,p),h===null?(_=MU(p.type,null,p.pendingProps,null))?p.memoizedState=_:_n||(_=p.type,h=p.pendingProps,w=Gv(de.current).createElement(_),w[br]=p,w[Dr]=h,$i(w,_,h),Oe(w),p.stateNode=w):p.memoizedState=MU(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return ve(p),h===null&&_n&&(w=p.stateNode=wU(p.type,p.pendingProps,de.current),zi=p,Ca=!0,P=ar,iu(p.type)?(rA=P,ar=ka(w.firstChild)):ar=P),Hi(h,p,p.pendingProps.children,_),Cv(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&_n&&((P=w=ar)&&(w=Vne(w,p.type,p.pendingProps,Ca),w!==null?(p.stateNode=w,zi=p,ar=ka(w.firstChild),Ca=!1,P=!0):P=!1),P||Vc(p)),ve(p),P=p.type,O=p.pendingProps,X=h!==null?h.memoizedProps:null,w=O.children,Q2(P,O)?w=null:X!==null&&Q2(P,X)&&(p.flags|=32),p.memoizedState!==null&&(P=ZM(h,p,sne,null,null,_),Gg._currentValue=P),Cv(h,p),Hi(h,p,w,_),p.child;case 6:return h===null&&_n&&((h=_=ar)&&(_=Gne(_,p.pendingProps,Ca),_!==null?(p.stateNode=_,zi=p,ar=null,h=!0):h=!1),h||Vc(p)),null;case 13:return d4(h,p,_);case 4:return ye(p,p.stateNode.containerInfo),w=p.pendingProps,h===null?p.child=jd(p,null,w,_):Hi(h,p,w,_),p.child;case 11:return n4(h,p,p.type,p.pendingProps,_);case 7:return Hi(h,p,p.pendingProps,_),p.child;case 8:return Hi(h,p,p.pendingProps.children,_),p.child;case 12:return Hi(h,p,p.pendingProps.children,_),p.child;case 10:return w=p.pendingProps,Gc(p,p.type,w.value),Hi(h,p,w.children,_),p.child;case 9:return P=p.type._context,w=p.pendingProps.children,Pd(p),P=Bi(P),w=w(P),p.flags|=1,Hi(h,p,w,_),p.child;case 14:return r4(h,p,p.type,p.pendingProps,_);case 15:return i4(h,p,p.type,p.pendingProps,_);case 19:return f4(h,p,_);case 31:return fne(h,p,_);case 22:return s4(h,p,_,p.pendingProps);case 24:return Pd(p),w=Bi(Br),h===null?(P=BM(),P===null&&(P=Jn,O=FM(),P.pooledCache=O,O.refCount++,O!==null&&(P.pooledCacheLanes|=_),P=O),p.memoizedState={parent:w,cache:P},$M(p),Gc(p,Br,P)):((h.lanes&_)!==0&&(VM(h,p),Mg(p,null,null,_),Eg()),P=h.memoizedState,O=p.memoizedState,P.parent!==w?(P={parent:w,cache:w},p.memoizedState=P,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=P),Gc(p,Br,w)):(w=O.cache,Gc(p,Br,w),w!==P.cache&&UM(p,[Br],_,!0))),Hi(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function Ol(h){h.flags|=4}function M2(h,p,_,w,P){if((p=(h.mode&32)!==0)&&(p=!1),p){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(B4())h.flags|=8192;else throw Od=fv,HM}else h.flags&=-16777217}function m4(h,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!kU(p))if(B4())h.flags|=8192;else throw Od=fv,HM}function kv(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?wt():536870912,h.lanes|=p,Lf|=p)}function Pg(h,p){if(!_n)switch(h.tailMode){case"hidden":p=h.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var w=null;_!==null;)_.alternate!==null&&(w=_),_=_.sibling;w===null?p||h.tail===null?h.tail=null:h.tail.sibling=null:w.sibling=null}}function or(h){var p=h.alternate!==null&&h.alternate.child===h.child,_=0,w=0;if(p)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,w|=P.subtreeFlags&65011712,w|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,w|=P.subtreeFlags,w|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=w,h.childLanes=_,p}function mne(h,p,_){var w=p.pendingProps;switch(DM(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return or(p),null;case 1:return or(p),null;case 3:return _=p.stateNode,w=null,h!==null&&(w=h.memoizedState.cache),p.memoizedState.cache!==w&&(p.flags|=2048),kl(Br),re(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Sf(p)?Ol(p):h===null||h.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,jM())),or(p),null;case 26:var P=p.type,O=p.memoizedState;return h===null?(Ol(p),O!==null?(or(p),m4(p,O)):(or(p),M2(p,P,null,w,_))):O?O!==h.memoizedState?(Ol(p),or(p),m4(p,O)):(or(p),p.flags&=-16777217):(h=h.memoizedProps,h!==w&&Ol(p),or(p),M2(p,P,h,w,_)),null;case 27:if(je(p),_=de.current,P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ol(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}h=ae.current,Sf(p)?KL(p):(h=wU(P,w,_),p.stateNode=h,Ol(p))}return or(p),null;case 5:if(je(p),P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ol(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}if(O=ae.current,Sf(p))KL(p);else{var X=Gv(de.current);switch(O){case 1:O=X.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:O=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":O=X.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":O=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":O=X.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof w.is=="string"?X.createElement("select",{is:w.is}):X.createElement("select"),w.multiple?O.multiple=!0:w.size&&(O.size=w.size);break;default:O=typeof w.is=="string"?X.createElement(P,{is:w.is}):X.createElement(P)}}O[br]=p,O[Dr]=w;e:for(X=p.child;X!==null;){if(X.tag===5||X.tag===6)O.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===p)break e;for(;X.sibling===null;){if(X.return===null||X.return===p)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}p.stateNode=O;e:switch($i(O,P,w),P){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}w&&Ol(p)}}return or(p),M2(p,p.type,h===null?null:h.memoizedProps,p.pendingProps,_),null;case 6:if(h&&p.stateNode!=null)h.memoizedProps!==w&&Ol(p);else{if(typeof w!="string"&&p.stateNode===null)throw Error(r(166));if(h=de.current,Sf(p)){if(h=p.stateNode,_=p.memoizedProps,w=null,P=zi,P!==null)switch(P.tag){case 27:case 5:w=P.memoizedProps}h[br]=p,h=!!(h.nodeValue===_||w!==null&&w.suppressHydrationWarning===!0||dU(h.nodeValue,_)),h||Vc(p,!0)}else h=Gv(h).createTextNode(w),h[br]=p,p.stateNode=h}return or(p),null;case 31:if(_=p.memoizedState,h===null||h.memoizedState!==null){if(w=Sf(p),_!==null){if(h===null){if(!w)throw Error(r(318));if(h=p.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[br]=p}else Nd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),h=!1}else _=jM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return p.flags&256?(ra(p),p):(ra(p),null);if((p.flags&128)!==0)throw Error(r(558))}return or(p),null;case 13:if(w=p.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Sf(p),w!==null&&w.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=p.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[br]=p}else Nd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),P=!1}else P=jM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return p.flags&256?(ra(p),p):(ra(p),null)}return ra(p),(p.flags&128)!==0?(p.lanes=_,p):(_=w!==null,h=h!==null&&h.memoizedState!==null,_&&(w=p.child,P=null,w.alternate!==null&&w.alternate.memoizedState!==null&&w.alternate.memoizedState.cachePool!==null&&(P=w.alternate.memoizedState.cachePool.pool),O=null,w.memoizedState!==null&&w.memoizedState.cachePool!==null&&(O=w.memoizedState.cachePool.pool),O!==P&&(w.flags|=2048)),_!==h&&_&&(p.child.flags|=8192),kv(p,p.updateQueue),or(p),null);case 4:return re(),h===null&&q2(p.stateNode.containerInfo),or(p),null;case 10:return kl(p.type),or(p),null;case 19:if(z(jr),w=p.memoizedState,w===null)return or(p),null;if(P=(p.flags&128)!==0,O=w.rendering,O===null)if(P)Pg(w,!1);else{if(Tr!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(O=xv(h),O!==null){for(p.flags|=128,Pg(w,!1),h=O.updateQueue,p.updateQueue=h,kv(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)$L(_,h),_=_.sibling;return ee(jr,jr.current&1|2),_n&&Cl(p,w.treeForkCount),p.child}h=h.sibling}w.tail!==null&&L()>jv&&(p.flags|=128,P=!0,Pg(w,!1),p.lanes=4194304)}else{if(!P)if(h=xv(O),h!==null){if(p.flags|=128,P=!0,h=h.updateQueue,p.updateQueue=h,kv(p,h),Pg(w,!0),w.tail===null&&w.tailMode==="hidden"&&!O.alternate&&!_n)return or(p),null}else 2*L()-w.renderingStartTime>jv&&_!==536870912&&(p.flags|=128,P=!0,Pg(w,!1),p.lanes=4194304);w.isBackwards?(O.sibling=p.child,p.child=O):(h=w.last,h!==null?h.sibling=O:p.child=O,w.last=O)}return w.tail!==null?(h=w.tail,w.rendering=h,w.tail=h.sibling,w.renderingStartTime=L(),h.sibling=null,_=jr.current,ee(jr,P?_&1|2:_&1),_n&&Cl(p,w.treeForkCount),h):(or(p),null);case 22:case 23:return ra(p),KM(),w=p.memoizedState!==null,h!==null?h.memoizedState!==null!==w&&(p.flags|=8192):w&&(p.flags|=8192),w?(_&536870912)!==0&&(p.flags&128)===0&&(or(p),p.subtreeFlags&6&&(p.flags|=8192)):or(p),_=p.updateQueue,_!==null&&kv(p,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),w=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(w=p.memoizedState.cachePool.pool),w!==_&&(p.flags|=2048),h!==null&&z(Rd),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),kl(Br),or(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function gne(h,p){switch(DM(p),p.tag){case 1:return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return kl(Br),re(),h=p.flags,(h&65536)!==0&&(h&128)===0?(p.flags=h&-65537|128,p):null;case 26:case 27:case 5:return je(p),null;case 31:if(p.memoizedState!==null){if(ra(p),p.alternate===null)throw Error(r(340));Nd()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 13:if(ra(p),h=p.memoizedState,h!==null&&h.dehydrated!==null){if(p.alternate===null)throw Error(r(340));Nd()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 19:return z(jr),null;case 4:return re(),null;case 10:return kl(p.type),null;case 22:case 23:return ra(p),KM(),h!==null&&z(Rd),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return kl(Br),null;case 25:return null;default:return null}}function g4(h,p){switch(DM(p),p.tag){case 3:kl(Br),re();break;case 26:case 27:case 5:je(p);break;case 4:re();break;case 31:p.memoizedState!==null&&ra(p);break;case 13:ra(p);break;case 19:z(jr);break;case 10:kl(p.type);break;case 22:case 23:ra(p),KM(),h!==null&&z(Rd);break;case 24:kl(Br)}}function Rg(h,p){try{var _=p.updateQueue,w=_!==null?_.lastEffect:null;if(w!==null){var P=w.next;_=P;do{if((_.tag&h)===h){w=void 0;var O=_.create,X=_.inst;w=O(),X.destroy=w}_=_.next}while(_!==P)}}catch(oe){Ln(p,p.return,oe)}}function Zc(h,p,_){try{var w=p.updateQueue,P=w!==null?w.lastEffect:null;if(P!==null){var O=P.next;w=O;do{if((w.tag&h)===h){var X=w.inst,oe=X.destroy;if(oe!==void 0){X.destroy=void 0,P=p;var Me=_,Ke=oe;try{Ke()}catch(lt){Ln(P,Me,lt)}}}w=w.next}while(w!==O)}}catch(lt){Ln(p,p.return,lt)}}function x4(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{oI(p,_)}catch(w){Ln(h,h.return,w)}}}function b4(h,p,_){_.props=Id(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(w){Ln(h,p,w)}}function Dg(h,p){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var w=h.stateNode;break;case 30:w=h.stateNode;break;default:w=h.stateNode}typeof _=="function"?h.refCleanup=_(w):_.current=w}}catch(P){Ln(h,p,P)}}function Go(h,p){var _=h.ref,w=h.refCleanup;if(_!==null)if(typeof w=="function")try{w()}catch(P){Ln(h,p,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Ln(h,p,P)}else _.current=null}function v4(h){var p=h.type,_=h.memoizedProps,w=h.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":_.autoFocus&&w.focus();break e;case"img":_.src?w.src=_.src:_.srcSet&&(w.srcset=_.srcSet)}}catch(P){Ln(h,h.return,P)}}function A2(h,p,_){try{var w=h.stateNode;Une(w,h.type,_,p),w[Dr]=p}catch(P){Ln(h,h.return,P)}}function y4(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&iu(h.type)||h.tag===4}function T2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||y4(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&iu(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function C2(h,p,_){var w=h.tag;if(w===5||w===6)h=h.stateNode,p?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,p):(p=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,p.appendChild(h),_=_._reactRootContainer,_!=null||p.onclick!==null||(p.onclick=Ml));else if(w!==4&&(w===27&&iu(h.type)&&(_=h.stateNode,p=null),h=h.child,h!==null))for(C2(h,p,_),h=h.sibling;h!==null;)C2(h,p,_),h=h.sibling}function Pv(h,p,_){var w=h.tag;if(w===5||w===6)h=h.stateNode,p?_.insertBefore(h,p):_.appendChild(h);else if(w!==4&&(w===27&&iu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Pv(h,p,_),h=h.sibling;h!==null;)Pv(h,p,_),h=h.sibling}function _4(h){var p=h.stateNode,_=h.memoizedProps;try{for(var w=h.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);$i(p,w,_),p[br]=h,p[Dr]=_}catch(O){Ln(h,h.return,O)}}var jl=!1,Vr=!1,N2=!1,w4=typeof WeakSet=="function"?WeakSet:Set,Ai=null;function xne(h,p){if(h=h.containerInfo,Y2=Qv,h=OL(h),wM(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var w=_.getSelection&&_.getSelection();if(w&&w.rangeCount!==0){_=w.anchorNode;var P=w.anchorOffset,O=w.focusNode;w=w.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var X=0,oe=-1,Me=-1,Ke=0,lt=0,dt=h,Qe=null;t:for(;;){for(var it;dt!==_||P!==0&&dt.nodeType!==3||(oe=X+P),dt!==O||w!==0&&dt.nodeType!==3||(Me=X+w),dt.nodeType===3&&(X+=dt.nodeValue.length),(it=dt.firstChild)!==null;)Qe=dt,dt=it;for(;;){if(dt===h)break t;if(Qe===_&&++Ke===P&&(oe=X),Qe===O&&++lt===w&&(Me=X),(it=dt.nextSibling)!==null)break;dt=Qe,Qe=dt.parentNode}dt=it}_=oe===-1||Me===-1?null:{start:oe,end:Me}}else _=null}_=_||{start:0,end:0}}else _=null;for(Z2={focusedElem:h,selectionRange:_},Qv=!1,Ai=p;Ai!==null;)if(p=Ai,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Ai=h;else for(;Ai!==null;){switch(p=Ai,O=p.alternate,h=p.flags,p.tag){case 0:if((h&4)!==0&&(h=p.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&O!==null){h=void 0,_=p,P=O.memoizedProps,O=O.memoizedState,w=_.stateNode;try{var Rt=Id(_.type,P);h=w.getSnapshotBeforeUpdate(Rt,O),w.__reactInternalSnapshotBeforeUpdate=h}catch(Vt){Ln(_,_.return,Vt)}}break;case 3:if((h&1024)!==0){if(h=p.stateNode.containerInfo,_=h.nodeType,_===9)eA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":eA(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=p.sibling,h!==null){h.return=p.return,Ai=h;break}Ai=p.return}}function S4(h,p,_){var w=_.flags;switch(_.tag){case 0:case 11:case 15:Il(h,_),w&4&&Rg(5,_);break;case 1:if(Il(h,_),w&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(X){Ln(_,_.return,X)}else{var P=Id(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(P,p,h.__reactInternalSnapshotBeforeUpdate)}catch(X){Ln(_,_.return,X)}}w&64&&x4(_),w&512&&Dg(_,_.return);break;case 3:if(Il(h,_),w&64&&(h=_.updateQueue,h!==null)){if(p=null,_.child!==null)switch(_.child.tag){case 27:case 5:p=_.child.stateNode;break;case 1:p=_.child.stateNode}try{oI(h,p)}catch(X){Ln(_,_.return,X)}}break;case 27:p===null&&w&4&&_4(_);case 26:case 5:Il(h,_),p===null&&w&4&&v4(_),w&512&&Dg(_,_.return);break;case 12:Il(h,_);break;case 31:Il(h,_),w&4&&A4(h,_);break;case 13:Il(h,_),w&4&&T4(h,_),w&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Ane.bind(null,_),Wne(h,_))));break;case 22:if(w=_.memoizedState!==null||jl,!w){p=p!==null&&p.memoizedState!==null||Vr,P=jl;var O=Vr;jl=w,(Vr=p)&&!O?Ul(h,_,(_.subtreeFlags&8772)!==0):Il(h,_),jl=P,Vr=O}break;case 30:break;default:Il(h,_)}}function E4(h){var p=h.alternate;p!==null&&(h.alternate=null,E4(p)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(p=h.stateNode,p!==null&&et(p)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var hr=null,Os=!1;function Ll(h,p,_){for(_=_.child;_!==null;)M4(h,p,_),_=_.sibling}function M4(h,p,_){if(ce&&typeof ce.onCommitFiberUnmount=="function")try{ce.onCommitFiberUnmount(Ve,_)}catch{}switch(_.tag){case 26:Vr||Go(_,p),Ll(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Vr||Go(_,p);var w=hr,P=Os;iu(_.type)&&(hr=_.stateNode,Os=!1),Ll(h,p,_),Hg(_.stateNode),hr=w,Os=P;break;case 5:Vr||Go(_,p);case 6:if(w=hr,P=Os,hr=null,Ll(h,p,_),hr=w,Os=P,hr!==null)if(Os)try{(hr.nodeType===9?hr.body:hr.nodeName==="HTML"?hr.ownerDocument.body:hr).removeChild(_.stateNode)}catch(O){Ln(_,p,O)}else try{hr.removeChild(_.stateNode)}catch(O){Ln(_,p,O)}break;case 18:hr!==null&&(Os?(h=hr,xU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Vf(h)):xU(hr,_.stateNode));break;case 4:w=hr,P=Os,hr=_.stateNode.containerInfo,Os=!0,Ll(h,p,_),hr=w,Os=P;break;case 0:case 11:case 14:case 15:Zc(2,_,p),Vr||Zc(4,_,p),Ll(h,p,_);break;case 1:Vr||(Go(_,p),w=_.stateNode,typeof w.componentWillUnmount=="function"&&b4(_,p,w)),Ll(h,p,_);break;case 21:Ll(h,p,_);break;case 22:Vr=(w=Vr)||_.memoizedState!==null,Ll(h,p,_),Vr=w;break;default:Ll(h,p,_)}}function A4(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Vf(h)}catch(_){Ln(p,p.return,_)}}}function T4(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Vf(h)}catch(_){Ln(p,p.return,_)}}function bne(h){switch(h.tag){case 31:case 13:case 19:var p=h.stateNode;return p===null&&(p=h.stateNode=new w4),p;case 22:return h=h.stateNode,p=h._retryCache,p===null&&(p=h._retryCache=new w4),p;default:throw Error(r(435,h.tag))}}function Rv(h,p){var _=bne(h);p.forEach(function(w){if(!_.has(w)){_.add(w);var P=Tne.bind(null,h,w);w.then(P,P)}})}function js(h,p){var _=p.deletions;if(_!==null)for(var w=0;w<_.length;w++){var P=_[w],O=h,X=p,oe=X;e:for(;oe!==null;){switch(oe.tag){case 27:if(iu(oe.type)){hr=oe.stateNode,Os=!1;break e}break;case 5:hr=oe.stateNode,Os=!1;break e;case 3:case 4:hr=oe.stateNode.containerInfo,Os=!0;break e}oe=oe.return}if(hr===null)throw Error(r(160));M4(O,X,P),hr=null,Os=!1,O=P.alternate,O!==null&&(O.return=null),P.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)C4(p,h),p=p.sibling}var po=null;function C4(h,p){var _=h.alternate,w=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:js(p,h),Ls(h),w&4&&(Zc(3,h,h.return),Rg(3,h),Zc(5,h,h.return));break;case 1:js(p,h),Ls(h),w&512&&(Vr||_===null||Go(_,_.return)),w&64&&jl&&(h=h.updateQueue,h!==null&&(w=h.callbacks,w!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?w:_.concat(w))));break;case 26:var P=po;if(js(p,h),Ls(h),w&512&&(Vr||_===null||Go(_,_.return)),w&4){var O=_!==null?_.memoizedState:null;if(w=h.memoizedState,_===null)if(w===null)if(h.stateNode===null){e:{w=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(w){case"title":O=P.getElementsByTagName("title")[0],(!O||O[rt]||O[br]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=P.createElement(w),P.head.insertBefore(O,P.querySelector("head > title"))),$i(O,w,_),O[br]=h,Oe(O),w=O;break e;case"link":var X=CU("link","href",P).get(w+(_.href||""));if(X){for(var oe=0;oe<X.length;oe++)if(O=X[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)){X.splice(oe,1);break t}}O=P.createElement(w),$i(O,w,_),P.head.appendChild(O);break;case"meta":if(X=CU("meta","content",P).get(w+(_.content||""))){for(oe=0;oe<X.length;oe++)if(O=X[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)){X.splice(oe,1);break t}}O=P.createElement(w),$i(O,w,_),P.head.appendChild(O);break;default:throw Error(r(468,w))}O[br]=h,Oe(O),w=O}h.stateNode=w}else NU(P,h.type,h.stateNode);else h.stateNode=TU(P,w,h.memoizedProps);else O!==w?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,w===null?NU(P,h.type,h.stateNode):TU(P,w,h.memoizedProps)):w===null&&h.stateNode!==null&&A2(h,h.memoizedProps,_.memoizedProps)}break;case 27:js(p,h),Ls(h),w&512&&(Vr||_===null||Go(_,_.return)),_!==null&&w&4&&A2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(js(p,h),Ls(h),w&512&&(Vr||_===null||Go(_,_.return)),h.flags&32){P=h.stateNode;try{Ho(P,"")}catch(Rt){Ln(h,h.return,Rt)}}w&4&&h.stateNode!=null&&(P=h.memoizedProps,A2(h,P,_!==null?_.memoizedProps:P)),w&1024&&(N2=!0);break;case 6:if(js(p,h),Ls(h),w&4){if(h.stateNode===null)throw Error(r(162));w=h.memoizedProps,_=h.stateNode;try{_.nodeValue=w}catch(Rt){Ln(h,h.return,Rt)}}break;case 3:if(Kv=null,P=po,po=Wv(p.containerInfo),js(p,h),po=P,Ls(h),w&4&&_!==null&&_.memoizedState.isDehydrated)try{Vf(p.containerInfo)}catch(Rt){Ln(h,h.return,Rt)}N2&&(N2=!1,N4(h));break;case 4:w=po,po=Wv(h.stateNode.containerInfo),js(p,h),Ls(h),po=w;break;case 12:js(p,h),Ls(h);break;case 31:js(p,h),Ls(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Rv(h,w)));break;case 13:js(p,h),Ls(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Ov=L()),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Rv(h,w)));break;case 22:P=h.memoizedState!==null;var Me=_!==null&&_.memoizedState!==null,Ke=jl,lt=Vr;if(jl=Ke||P,Vr=lt||Me,js(p,h),Vr=lt,jl=Ke,Ls(h),w&8192)e:for(p=h.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||Me||jl||Vr||Ud(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){Me=_=p;try{if(O=Me.stateNode,P)X=O.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{oe=Me.stateNode;var dt=Me.memoizedProps.style,Qe=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;oe.style.display=Qe==null||typeof Qe=="boolean"?"":(""+Qe).trim()}}catch(Rt){Ln(Me,Me.return,Rt)}}}else if(p.tag===6){if(_===null){Me=p;try{Me.stateNode.nodeValue=P?"":Me.memoizedProps}catch(Rt){Ln(Me,Me.return,Rt)}}}else if(p.tag===18){if(_===null){Me=p;try{var it=Me.stateNode;P?bU(it,!0):bU(Me.stateNode,!1)}catch(Rt){Ln(Me,Me.return,Rt)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===h)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===h)break e;for(;p.sibling===null;){if(p.return===null||p.return===h)break e;_===p&&(_=null),p=p.return}_===p&&(_=null),p.sibling.return=p.return,p=p.sibling}w&4&&(w=h.updateQueue,w!==null&&(_=w.retryQueue,_!==null&&(w.retryQueue=null,Rv(h,_))));break;case 19:js(p,h),Ls(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Rv(h,w)));break;case 30:break;case 21:break;default:js(p,h),Ls(h)}}function Ls(h){var p=h.flags;if(p&2){try{for(var _,w=h.return;w!==null;){if(y4(w)){_=w;break}w=w.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,O=T2(h);Pv(h,O,P);break;case 5:var X=_.stateNode;_.flags&32&&(Ho(X,""),_.flags&=-33);var oe=T2(h);Pv(h,oe,X);break;case 3:case 4:var Me=_.stateNode.containerInfo,Ke=T2(h);C2(h,Ke,Me);break;default:throw Error(r(161))}}catch(lt){Ln(h,h.return,lt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function N4(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var p=h;N4(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),h=h.sibling}}function Il(h,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)S4(h,p.alternate,p),p=p.sibling}function Ud(h){for(h=h.child;h!==null;){var p=h;switch(p.tag){case 0:case 11:case 14:case 15:Zc(4,p,p.return),Ud(p);break;case 1:Go(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&b4(p,p.return,_),Ud(p);break;case 27:Hg(p.stateNode);case 26:case 5:Go(p,p.return),Ud(p);break;case 22:p.memoizedState===null&&Ud(p);break;case 30:Ud(p);break;default:Ud(p)}h=h.sibling}}function Ul(h,p,_){for(_=_&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var w=p.alternate,P=h,O=p,X=O.flags;switch(O.tag){case 0:case 11:case 15:Ul(P,O,_),Rg(4,O);break;case 1:if(Ul(P,O,_),w=O,P=w.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Ke){Ln(w,w.return,Ke)}if(w=O,P=w.updateQueue,P!==null){var oe=w.stateNode;try{var Me=P.shared.hiddenCallbacks;if(Me!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Me.length;P++)aI(Me[P],oe)}catch(Ke){Ln(w,w.return,Ke)}}_&&X&64&&x4(O),Dg(O,O.return);break;case 27:_4(O);case 26:case 5:Ul(P,O,_),_&&w===null&&X&4&&v4(O),Dg(O,O.return);break;case 12:Ul(P,O,_);break;case 31:Ul(P,O,_),_&&X&4&&A4(P,O);break;case 13:Ul(P,O,_),_&&X&4&&T4(P,O);break;case 22:O.memoizedState===null&&Ul(P,O,_),Dg(O,O.return);break;case 30:break;default:Ul(P,O,_)}p=p.sibling}}function k2(h,p){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(h=p.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&vg(_))}function P2(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&vg(h))}function mo(h,p,_,w){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)k4(h,p,_,w),p=p.sibling}function k4(h,p,_,w){var P=p.flags;switch(p.tag){case 0:case 11:case 15:mo(h,p,_,w),P&2048&&Rg(9,p);break;case 1:mo(h,p,_,w);break;case 3:mo(h,p,_,w),P&2048&&(h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&vg(h)));break;case 12:if(P&2048){mo(h,p,_,w),h=p.stateNode;try{var O=p.memoizedProps,X=O.id,oe=O.onPostCommit;typeof oe=="function"&&oe(X,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Me){Ln(p,p.return,Me)}}else mo(h,p,_,w);break;case 31:mo(h,p,_,w);break;case 13:mo(h,p,_,w);break;case 23:break;case 22:O=p.stateNode,X=p.alternate,p.memoizedState!==null?O._visibility&2?mo(h,p,_,w):Og(h,p):O._visibility&2?mo(h,p,_,w):(O._visibility|=2,Df(h,p,_,w,(p.subtreeFlags&10256)!==0||!1)),P&2048&&k2(X,p);break;case 24:mo(h,p,_,w),P&2048&&P2(p.alternate,p);break;default:mo(h,p,_,w)}}function Df(h,p,_,w,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=h,X=p,oe=_,Me=w,Ke=X.flags;switch(X.tag){case 0:case 11:case 15:Df(O,X,oe,Me,P),Rg(8,X);break;case 23:break;case 22:var lt=X.stateNode;X.memoizedState!==null?lt._visibility&2?Df(O,X,oe,Me,P):Og(O,X):(lt._visibility|=2,Df(O,X,oe,Me,P)),P&&Ke&2048&&k2(X.alternate,X);break;case 24:Df(O,X,oe,Me,P),P&&Ke&2048&&P2(X.alternate,X);break;default:Df(O,X,oe,Me,P)}p=p.sibling}}function Og(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,w=p,P=w.flags;switch(w.tag){case 22:Og(_,w),P&2048&&k2(w.alternate,w);break;case 24:Og(_,w),P&2048&&P2(w.alternate,w);break;default:Og(_,w)}p=p.sibling}}var jg=8192;function Of(h,p,_){if(h.subtreeFlags&jg)for(h=h.child;h!==null;)P4(h,p,_),h=h.sibling}function P4(h,p,_){switch(h.tag){case 26:Of(h,p,_),h.flags&jg&&h.memoizedState!==null&&ire(_,po,h.memoizedState,h.memoizedProps);break;case 5:Of(h,p,_);break;case 3:case 4:var w=po;po=Wv(h.stateNode.containerInfo),Of(h,p,_),po=w;break;case 22:h.memoizedState===null&&(w=h.alternate,w!==null&&w.memoizedState!==null?(w=jg,jg=16777216,Of(h,p,_),jg=w):Of(h,p,_));break;default:Of(h,p,_)}}function R4(h){var p=h.alternate;if(p!==null&&(h=p.child,h!==null)){p.child=null;do p=h.sibling,h.sibling=null,h=p;while(h!==null)}}function Lg(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ai=w,O4(w,h)}R4(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)D4(h),h=h.sibling}function D4(h){switch(h.tag){case 0:case 11:case 15:Lg(h),h.flags&2048&&Zc(9,h,h.return);break;case 3:Lg(h);break;case 12:Lg(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,Dv(h)):Lg(h);break;default:Lg(h)}}function Dv(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ai=w,O4(w,h)}R4(h)}for(h=h.child;h!==null;){switch(p=h,p.tag){case 0:case 11:case 15:Zc(8,p,p.return),Dv(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,Dv(p));break;default:Dv(p)}h=h.sibling}}function O4(h,p){for(;Ai!==null;){var _=Ai;switch(_.tag){case 0:case 11:case 15:Zc(8,_,p);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var w=_.memoizedState.cachePool.pool;w!=null&&w.refCount++}break;case 24:vg(_.memoizedState.cache)}if(w=_.child,w!==null)w.return=_,Ai=w;else e:for(_=h;Ai!==null;){w=Ai;var P=w.sibling,O=w.return;if(E4(w),w===_){Ai=null;break e}if(P!==null){P.return=O,Ai=P;break e}Ai=O}}}var vne={getCacheForType:function(h){var p=Bi(Br),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return Bi(Br).controller.signal}},yne=typeof WeakMap=="function"?WeakMap:Map,Nn=0,Jn=null,fn=null,bn=0,jn=0,ia=null,Qc=!1,jf=!1,R2=!1,Fl=0,Tr=0,Jc=0,Fd=0,D2=0,sa=0,Lf=0,Ig=null,Is=null,O2=!1,Ov=0,j4=0,jv=1/0,Lv=null,eu=null,oi=0,tu=null,If=null,zl=0,j2=0,L2=null,L4=null,Ug=0,I2=null;function aa(){return(Nn&2)!==0&&bn!==0?bn&-bn:K.T!==null?$2():Ui()}function I4(){if(sa===0)if((bn&536870912)===0||_n){var h=pe;pe<<=1,(pe&3932160)===0&&(pe=262144),sa=h}else sa=536870912;return h=na.current,h!==null&&(h.flags|=32),sa}function Us(h,p,_){(h===Jn&&(jn===2||jn===9)||h.cancelPendingCommit!==null)&&(Uf(h,0),nu(h,bn,sa,!1)),cn(h,_),((Nn&2)===0||h!==Jn)&&(h===Jn&&((Nn&2)===0&&(Fd|=_),Tr===4&&nu(h,bn,sa,!1)),Wo(h))}function U4(h,p,_){if((Nn&6)!==0)throw Error(r(327));var w=!_&&(p&127)===0&&(p&h.expiredLanes)===0||He(h,p),P=w?Sne(h,p):F2(h,p,!0),O=w;do{if(P===0){jf&&!w&&nu(h,p,0,!1);break}else{if(_=h.current.alternate,O&&!_ne(_)){P=F2(h,p,!1),O=!1;continue}if(P===2){if(O=p,h.errorRecoveryDisabledLanes&O)var X=0;else X=h.pendingLanes&-536870913,X=X!==0?X:X&536870912?536870912:0;if(X!==0){p=X;e:{var oe=h;P=Ig;var Me=oe.current.memoizedState.isDehydrated;if(Me&&(Uf(oe,X).flags|=256),X=F2(oe,X,!1),X!==2){if(R2&&!Me){oe.errorRecoveryDisabledLanes|=O,Fd|=O,P=4;break e}O=Is,Is=P,O!==null&&(Is===null?Is=O:Is.push.apply(Is,O))}P=X}if(O=!1,P!==2)continue}}if(P===1){Uf(h,0),nu(h,p,0,!0);break}e:{switch(w=h,O=P,O){case 0:case 1:throw Error(r(345));case 4:if((p&4194048)!==p)break;case 6:nu(w,p,sa,!Qc);break e;case 2:Is=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=Ov+300-L(),10<P)){if(nu(w,p,sa,!Qc),_e(w,0,!0)!==0)break e;zl=p,w.timeoutHandle=mU(F4.bind(null,w,_,Is,Lv,O2,p,sa,Fd,Lf,Qc,O,"Throttled",-0,0),P);break e}F4(w,_,Is,Lv,O2,p,sa,Fd,Lf,Qc,O,null,-0,0)}}break}while(!0);Wo(h)}function F4(h,p,_,w,P,O,X,oe,Me,Ke,lt,dt,Qe,it){if(h.timeoutHandle=-1,dt=p.subtreeFlags,dt&8192||(dt&16785408)===16785408){dt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Ml},P4(p,O,dt);var Rt=(O&62914560)===O?Ov-L():(O&4194048)===O?j4-L():0;if(Rt=sre(dt,Rt),Rt!==null){zl=O,h.cancelPendingCommit=Rt(q4.bind(null,h,p,O,_,w,P,X,oe,Me,lt,dt,null,Qe,it)),nu(h,O,X,!Ke);return}}q4(h,p,O,_,w,P,X,oe,Me)}function _ne(h){for(var p=h;;){var _=p.tag;if((_===0||_===11||_===15)&&p.flags&16384&&(_=p.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var w=0;w<_.length;w++){var P=_[w],O=P.getSnapshot;P=P.value;try{if(!ea(O(),P))return!1}catch{return!1}}if(_=p.child,p.subtreeFlags&16384&&_!==null)_.return=p,p=_;else{if(p===h)break;for(;p.sibling===null;){if(p.return===null||p.return===h)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function nu(h,p,_,w){p&=~D2,p&=~Fd,h.suspendedLanes|=p,h.pingedLanes&=~p,w&&(h.warmLanes|=p),w=h.expirationTimes;for(var P=p;0<P;){var O=31-$e(P),X=1<<O;w[O]=-1,P&=~X}_!==0&&Dn(h,_,p)}function Iv(){return(Nn&6)===0?(Fg(0),!1):!0}function U2(){if(fn!==null){if(jn===0)var h=fn.return;else h=fn,Nl=kd=null,e2(h),Cf=null,_g=0,h=fn;for(;h!==null;)g4(h.alternate,h),h=h.return;fn=null}}function Uf(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Bne(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),zl=0,U2(),Jn=h,fn=_=Tl(h.current,null),bn=p,jn=0,ia=null,Qc=!1,jf=He(h,p),R2=!1,Lf=sa=D2=Fd=Jc=Tr=0,Is=Ig=null,O2=!1,(p&8)!==0&&(p|=p&32);var w=h.entangledLanes;if(w!==0)for(h=h.entanglements,w&=p;0<w;){var P=31-$e(w),O=1<<P;p|=h[P],w&=~O}return Fl=p,iv(),_}function z4(h,p){en=null,K.H=Ng,p===Tf||p===hv?(p=nI(),jn=3):p===HM?(p=nI(),jn=4):jn=p===g2?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,ia=p,fn===null&&(Tr=1,Av(h,Ma(p,h.current)))}function B4(){var h=na.current;return h===null?!0:(bn&4194048)===bn?Na===null:(bn&62914560)===bn||(bn&536870912)!==0?h===Na:!1}function H4(){var h=K.H;return K.H=Ng,h===null?Ng:h}function $4(){var h=K.A;return K.A=vne,h}function Uv(){Tr=4,Qc||(bn&4194048)!==bn&&na.current!==null||(jf=!0),(Jc&134217727)===0&&(Fd&134217727)===0||Jn===null||nu(Jn,bn,sa,!1)}function F2(h,p,_){var w=Nn;Nn|=2;var P=H4(),O=$4();(Jn!==h||bn!==p)&&(Lv=null,Uf(h,p)),p=!1;var X=Tr;e:do try{if(jn!==0&&fn!==null){var oe=fn,Me=ia;switch(jn){case 8:U2(),X=6;break e;case 3:case 2:case 9:case 6:na.current===null&&(p=!0);var Ke=jn;if(jn=0,ia=null,Ff(h,oe,Me,Ke),_&&jf){X=0;break e}break;default:Ke=jn,jn=0,ia=null,Ff(h,oe,Me,Ke)}}wne(),X=Tr;break}catch(lt){z4(h,lt)}while(!0);return p&&h.shellSuspendCounter++,Nl=kd=null,Nn=w,K.H=P,K.A=O,fn===null&&(Jn=null,bn=0,iv()),X}function wne(){for(;fn!==null;)V4(fn)}function Sne(h,p){var _=Nn;Nn|=2;var w=H4(),P=$4();Jn!==h||bn!==p?(Lv=null,jv=L()+500,Uf(h,p)):jf=He(h,p);e:do try{if(jn!==0&&fn!==null){p=fn;var O=ia;t:switch(jn){case 1:jn=0,ia=null,Ff(h,p,O,1);break;case 2:case 9:if(eI(O)){jn=0,ia=null,G4(p);break}p=function(){jn!==2&&jn!==9||Jn!==h||(jn=7),Wo(h)},O.then(p,p);break e;case 3:jn=7;break e;case 4:jn=5;break e;case 7:eI(O)?(jn=0,ia=null,G4(p)):(jn=0,ia=null,Ff(h,p,O,7));break;case 5:var X=null;switch(fn.tag){case 26:X=fn.memoizedState;case 5:case 27:var oe=fn;if(X?kU(X):oe.stateNode.complete){jn=0,ia=null;var Me=oe.sibling;if(Me!==null)fn=Me;else{var Ke=oe.return;Ke!==null?(fn=Ke,Fv(Ke)):fn=null}break t}}jn=0,ia=null,Ff(h,p,O,5);break;case 6:jn=0,ia=null,Ff(h,p,O,6);break;case 8:U2(),Tr=6;break e;default:throw Error(r(462))}}Ene();break}catch(lt){z4(h,lt)}while(!0);return Nl=kd=null,K.H=w,K.A=P,Nn=_,fn!==null?0:(Jn=null,bn=0,iv(),Tr)}function Ene(){for(;fn!==null&&!Se();)V4(fn)}function V4(h){var p=p4(h.alternate,h,Fl);h.memoizedProps=h.pendingProps,p===null?Fv(h):fn=p}function G4(h){var p=h,_=p.alternate;switch(p.tag){case 15:case 0:p=l4(_,p,p.pendingProps,p.type,void 0,bn);break;case 11:p=l4(_,p,p.pendingProps,p.type.render,p.ref,bn);break;case 5:e2(p);default:g4(_,p),p=fn=$L(p,Fl),p=p4(_,p,Fl)}h.memoizedProps=h.pendingProps,p===null?Fv(h):fn=p}function Ff(h,p,_,w){Nl=kd=null,e2(p),Cf=null,_g=0;var P=p.return;try{if(hne(h,P,p,_,bn)){Tr=1,Av(h,Ma(_,h.current)),fn=null;return}}catch(O){if(P!==null)throw fn=P,O;Tr=1,Av(h,Ma(_,h.current)),fn=null;return}p.flags&32768?(_n||w===1?h=!0:jf||(bn&536870912)!==0?h=!1:(Qc=h=!0,(w===2||w===9||w===3||w===6)&&(w=na.current,w!==null&&w.tag===13&&(w.flags|=16384))),W4(p,h)):Fv(p)}function Fv(h){var p=h;do{if((p.flags&32768)!==0){W4(p,Qc);return}h=p.return;var _=mne(p.alternate,p,Fl);if(_!==null){fn=_;return}if(p=p.sibling,p!==null){fn=p;return}fn=p=h}while(p!==null);Tr===0&&(Tr=5)}function W4(h,p){do{var _=gne(h.alternate,h);if(_!==null){_.flags&=32767,fn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){fn=h;return}fn=h=_}while(h!==null);Tr=6,fn=null}function q4(h,p,_,w,P,O,X,oe,Me){h.cancelPendingCommit=null;do zv();while(oi!==0);if((Nn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(O=p.lanes|p.childLanes,O|=TM,It(h,_,O,X,oe,Me),h===Jn&&(fn=Jn=null,bn=0),If=p,tu=h,zl=_,j2=O,L2=P,L4=w,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Cne(ge,function(){return Q4(),null})):(h.callbackNode=null,h.callbackPriority=0),w=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||w){w=K.T,K.T=null,P=V.p,V.p=2,X=Nn,Nn|=4;try{xne(h,p,_)}finally{Nn=X,V.p=P,K.T=w}}oi=1,K4(),X4(),Y4()}}function K4(){if(oi===1){oi=0;var h=tu,p=If,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var w=V.p;V.p=2;var P=Nn;Nn|=4;try{C4(p,h);var O=Z2,X=OL(h.containerInfo),oe=O.focusedElem,Me=O.selectionRange;if(X!==oe&&oe&&oe.ownerDocument&&DL(oe.ownerDocument.documentElement,oe)){if(Me!==null&&wM(oe)){var Ke=Me.start,lt=Me.end;if(lt===void 0&&(lt=Ke),"selectionStart"in oe)oe.selectionStart=Ke,oe.selectionEnd=Math.min(lt,oe.value.length);else{var dt=oe.ownerDocument||document,Qe=dt&&dt.defaultView||window;if(Qe.getSelection){var it=Qe.getSelection(),Rt=oe.textContent.length,Vt=Math.min(Me.start,Rt),Vn=Me.end===void 0?Vt:Math.min(Me.end,Rt);!it.extend&&Vt>Vn&&(X=Vn,Vn=Vt,Vt=X);var Be=RL(oe,Vt),Re=RL(oe,Vn);if(Be&&Re&&(it.rangeCount!==1||it.anchorNode!==Be.node||it.anchorOffset!==Be.offset||it.focusNode!==Re.node||it.focusOffset!==Re.offset)){var qe=dt.createRange();qe.setStart(Be.node,Be.offset),it.removeAllRanges(),Vt>Vn?(it.addRange(qe),it.extend(Re.node,Re.offset)):(qe.setEnd(Re.node,Re.offset),it.addRange(qe))}}}}for(dt=[],it=oe;it=it.parentNode;)it.nodeType===1&&dt.push({element:it,left:it.scrollLeft,top:it.scrollTop});for(typeof oe.focus=="function"&&oe.focus(),oe=0;oe<dt.length;oe++){var ct=dt[oe];ct.element.scrollLeft=ct.left,ct.element.scrollTop=ct.top}}Qv=!!Y2,Z2=Y2=null}finally{Nn=P,V.p=w,K.T=_}}h.current=p,oi=2}}function X4(){if(oi===2){oi=0;var h=tu,p=If,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var w=V.p;V.p=2;var P=Nn;Nn|=4;try{S4(h,p.alternate,p)}finally{Nn=P,V.p=w,K.T=_}}oi=3}}function Y4(){if(oi===4||oi===3){oi=0,B();var h=tu,p=If,_=zl,w=L4;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?oi=5:(oi=0,If=tu=null,Z4(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(eu=null),Si(_),p=p.stateNode,ce&&typeof ce.onCommitFiberRoot=="function")try{ce.onCommitFiberRoot(Ve,p,void 0,(p.current.flags&128)===128)}catch{}if(w!==null){p=K.T,P=V.p,V.p=2,K.T=null;try{for(var O=h.onRecoverableError,X=0;X<w.length;X++){var oe=w[X];O(oe.value,{componentStack:oe.stack})}}finally{K.T=p,V.p=P}}(zl&3)!==0&&zv(),Wo(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===I2?Ug++:(Ug=0,I2=h):Ug=0,Fg(0)}}function Z4(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,vg(p)))}function zv(){return K4(),X4(),Y4(),Q4()}function Q4(){if(oi!==5)return!1;var h=tu,p=j2;j2=0;var _=Si(zl),w=K.T,P=V.p;try{V.p=32>_?32:_,K.T=null,_=L2,L2=null;var O=tu,X=zl;if(oi=0,If=tu=null,zl=0,(Nn&6)!==0)throw Error(r(331));var oe=Nn;if(Nn|=4,D4(O.current),k4(O,O.current,X,_),Nn=oe,Fg(0,!1),ce&&typeof ce.onPostCommitFiberRoot=="function")try{ce.onPostCommitFiberRoot(Ve,O)}catch{}return!0}finally{V.p=P,K.T=w,Z4(h,p)}}function J4(h,p,_){p=Ma(_,p),p=m2(h.stateNode,p,2),h=Kc(h,p,2),h!==null&&(cn(h,2),Wo(h))}function Ln(h,p,_){if(h.tag===3)J4(h,h,_);else for(;p!==null;){if(p.tag===3){J4(p,h,_);break}else if(p.tag===1){var w=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(eu===null||!eu.has(w))){h=Ma(_,h),_=e4(2),w=Kc(p,_,2),w!==null&&(t4(_,w,p,h),cn(w,2),Wo(w));break}}p=p.return}}function z2(h,p,_){var w=h.pingCache;if(w===null){w=h.pingCache=new yne;var P=new Set;w.set(p,P)}else P=w.get(p),P===void 0&&(P=new Set,w.set(p,P));P.has(_)||(R2=!0,P.add(_),h=Mne.bind(null,h,p,_),p.then(h,h))}function Mne(h,p,_){var w=h.pingCache;w!==null&&w.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,Jn===h&&(bn&_)===_&&(Tr===4||Tr===3&&(bn&62914560)===bn&&300>L()-Ov?(Nn&2)===0&&Uf(h,0):D2|=_,Lf===bn&&(Lf=0)),Wo(h)}function eU(h,p){p===0&&(p=wt()),h=Td(h,p),h!==null&&(cn(h,p),Wo(h))}function Ane(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),eU(h,_)}function Tne(h,p){var _=0;switch(h.tag){case 31:case 13:var w=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:w=h.stateNode;break;case 22:w=h.stateNode._retryCache;break;default:throw Error(r(314))}w!==null&&w.delete(p),eU(h,_)}function Cne(h,p){return ke(h,p)}var Bv=null,zf=null,B2=!1,Hv=!1,H2=!1,ru=0;function Wo(h){h!==zf&&h.next===null&&(zf===null?Bv=zf=h:zf=zf.next=h),Hv=!0,B2||(B2=!0,kne())}function Fg(h,p){if(!H2&&Hv){H2=!0;do for(var _=!1,w=Bv;w!==null;){if(h!==0){var P=w.pendingLanes;if(P===0)var O=0;else{var X=w.suspendedLanes,oe=w.pingedLanes;O=(1<<31-$e(42|h)+1)-1,O&=P&~(X&~oe),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,iU(w,O))}else O=bn,O=_e(w,w===Jn?O:0,w.cancelPendingCommit!==null||w.timeoutHandle!==-1),(O&3)===0||He(w,O)||(_=!0,iU(w,O));w=w.next}while(_);H2=!1}}function Nne(){tU()}function tU(){Hv=B2=!1;var h=0;ru!==0&&zne()&&(h=ru);for(var p=L(),_=null,w=Bv;w!==null;){var P=w.next,O=nU(w,p);O===0?(w.next=null,_===null?Bv=P:_.next=P,P===null&&(zf=_)):(_=w,(h!==0||(O&3)!==0)&&(Hv=!0)),w=P}oi!==0&&oi!==5||Fg(h),ru!==0&&(ru=0)}function nU(h,p){for(var _=h.suspendedLanes,w=h.pingedLanes,P=h.expirationTimes,O=h.pendingLanes&-62914561;0<O;){var X=31-$e(O),oe=1<<X,Me=P[X];Me===-1?((oe&_)===0||(oe&w)!==0)&&(P[X]=ht(oe,p)):Me<=p&&(h.expiredLanes|=oe),O&=~oe}if(p=Jn,_=bn,_=_e(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w=h.callbackNode,_===0||h===p&&(jn===2||jn===9)||h.cancelPendingCommit!==null)return w!==null&&w!==null&&Ne(w),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||He(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(w!==null&&Ne(w),Si(_)){case 2:case 8:_=we;break;case 32:_=ge;break;case 268435456:_=Ae;break;default:_=ge}return w=rU.bind(null,h),_=ke(_,w),h.callbackPriority=p,h.callbackNode=_,p}return w!==null&&w!==null&&Ne(w),h.callbackPriority=2,h.callbackNode=null,2}function rU(h,p){if(oi!==0&&oi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(zv()&&h.callbackNode!==_)return null;var w=bn;return w=_e(h,h===Jn?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w===0?null:(U4(h,w,p),nU(h,L()),h.callbackNode!=null&&h.callbackNode===_?rU.bind(null,h):null)}function iU(h,p){if(zv())return null;U4(h,p,!0)}function kne(){Hne(function(){(Nn&6)!==0?ke(be,Nne):tU()})}function $2(){if(ru===0){var h=Mf;h===0&&(h=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),ru=h}return ru}function sU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Yb(""+h)}function aU(h,p){var _=p.ownerDocument.createElement("input");return _.name=p.name,_.value=p.value,h.id&&_.setAttribute("form",h.id),p.parentNode.insertBefore(_,p),h=new FormData(h),_.parentNode.removeChild(_),h}function Pne(h,p,_,w,P){if(p==="submit"&&_&&_.stateNode===P){var O=sU((P[Dr]||null).action),X=w.submitter;X&&(p=(p=X[Dr]||null)?sU(p.formAction):X.getAttribute("formAction"),p!==null&&(O=p,X=null));var oe=new ev("action","action",null,w,P);h.push({event:oe,listeners:[{instance:null,listener:function(){if(w.defaultPrevented){if(ru!==0){var Me=X?aU(P,X):new FormData(P);c2(_,{pending:!0,data:Me,method:P.method,action:O},null,Me)}}else typeof O=="function"&&(oe.preventDefault(),Me=X?aU(P,X):new FormData(P),c2(_,{pending:!0,data:Me,method:P.method,action:O},O,Me))},currentTarget:P}]})}}for(var V2=0;V2<AM.length;V2++){var G2=AM[V2],Rne=G2.toLowerCase(),Dne=G2[0].toUpperCase()+G2.slice(1);fo(Rne,"on"+Dne)}fo(IL,"onAnimationEnd"),fo(UL,"onAnimationIteration"),fo(FL,"onAnimationStart"),fo("dblclick","onDoubleClick"),fo("focusin","onFocus"),fo("focusout","onBlur"),fo(Xte,"onTransitionRun"),fo(Yte,"onTransitionStart"),fo(Zte,"onTransitionCancel"),fo(zL,"onTransitionEnd"),bt("onMouseEnter",["mouseout","mouseover"]),bt("onMouseLeave",["mouseout","mouseover"]),bt("onPointerEnter",["pointerout","pointerover"]),bt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zg="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),One=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(zg));function oU(h,p){p=(p&4)!==0;for(var _=0;_<h.length;_++){var w=h[_],P=w.event;w=w.listeners;e:{var O=void 0;if(p)for(var X=w.length-1;0<=X;X--){var oe=w[X],Me=oe.instance,Ke=oe.currentTarget;if(oe=oe.listener,Me!==O&&P.isPropagationStopped())break e;O=oe,P.currentTarget=Ke;try{O(P)}catch(lt){rv(lt)}P.currentTarget=null,O=Me}else for(X=0;X<w.length;X++){if(oe=w[X],Me=oe.instance,Ke=oe.currentTarget,oe=oe.listener,Me!==O&&P.isPropagationStopped())break e;O=oe,P.currentTarget=Ke;try{O(P)}catch(lt){rv(lt)}P.currentTarget=null,O=Me}}}}function pn(h,p){var _=p[zc];_===void 0&&(_=p[zc]=new Set);var w=h+"__bubble";_.has(w)||(lU(p,h,2,!1),_.add(w))}function W2(h,p,_){var w=0;p&&(w|=4),lU(_,h,w,p)}var $v="_reactListening"+Math.random().toString(36).slice(2);function q2(h){if(!h[$v]){h[$v]=!0,Te.forEach(function(_){_!=="selectionchange"&&(One.has(_)||W2(_,!1,h),W2(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[$v]||(p[$v]=!0,W2("selectionchange",!1,p))}}function lU(h,p,_,w){switch(IU(p)){case 2:var P=lre;break;case 8:P=cre;break;default:P=lA}_=P.bind(null,p,_,h),P=void 0,!fM||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(P=!0),w?P!==void 0?h.addEventListener(p,_,{capture:!0,passive:P}):h.addEventListener(p,_,!0):P!==void 0?h.addEventListener(p,_,{passive:P}):h.addEventListener(p,_,!1)}function K2(h,p,_,w,P){var O=w;if((p&1)===0&&(p&2)===0&&w!==null)e:for(;;){if(w===null)return;var X=w.tag;if(X===3||X===4){var oe=w.stateNode.containerInfo;if(oe===P)break;if(X===4)for(X=w.return;X!==null;){var Me=X.tag;if((Me===3||Me===4)&&X.stateNode.containerInfo===P)return;X=X.return}for(;oe!==null;){if(X=St(oe),X===null)return;if(Me=X.tag,Me===5||Me===6||Me===26||Me===27){w=O=X;continue e}oe=oe.parentNode}}w=w.return}fL(function(){var Ke=O,lt=dM(_),dt=[];e:{var Qe=BL.get(h);if(Qe!==void 0){var it=ev,Rt=h;switch(h){case"keypress":if(Qb(_)===0)break e;case"keydown":case"keyup":it=Tte;break;case"focusin":Rt="focus",it=xM;break;case"focusout":Rt="blur",it=xM;break;case"beforeblur":case"afterblur":it=xM;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":it=gL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":it=mte;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":it=kte;break;case IL:case UL:case FL:it=bte;break;case zL:it=Rte;break;case"scroll":case"scrollend":it=fte;break;case"wheel":it=Ote;break;case"copy":case"cut":case"paste":it=yte;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":it=bL;break;case"toggle":case"beforetoggle":it=Lte}var Vt=(p&4)!==0,Vn=!Vt&&(h==="scroll"||h==="scrollend"),Be=Vt?Qe!==null?Qe+"Capture":null:Qe;Vt=[];for(var Re=Ke,qe;Re!==null;){var ct=Re;if(qe=ct.stateNode,ct=ct.tag,ct!==5&&ct!==26&&ct!==27||qe===null||Be===null||(ct=lg(Re,Be),ct!=null&&Vt.push(Bg(Re,ct,qe))),Vn)break;Re=Re.return}0<Vt.length&&(Qe=new it(Qe,Rt,null,_,lt),dt.push({event:Qe,listeners:Vt}))}}if((p&7)===0){e:{if(Qe=h==="mouseover"||h==="pointerover",it=h==="mouseout"||h==="pointerout",Qe&&_!==uM&&(Rt=_.relatedTarget||_.fromElement)&&(St(Rt)||Rt[uo]))break e;if((it||Qe)&&(Qe=lt.window===lt?lt:(Qe=lt.ownerDocument)?Qe.defaultView||Qe.parentWindow:window,it?(Rt=_.relatedTarget||_.toElement,it=Ke,Rt=Rt?St(Rt):null,Rt!==null&&(Vn=s(Rt),Vt=Rt.tag,Rt!==Vn||Vt!==5&&Vt!==27&&Vt!==6)&&(Rt=null)):(it=null,Rt=Ke),it!==Rt)){if(Vt=gL,ct="onMouseLeave",Be="onMouseEnter",Re="mouse",(h==="pointerout"||h==="pointerover")&&(Vt=bL,ct="onPointerLeave",Be="onPointerEnter",Re="pointer"),Vn=it==null?Qe:Ee(it),qe=Rt==null?Qe:Ee(Rt),Qe=new Vt(ct,Re+"leave",it,_,lt),Qe.target=Vn,Qe.relatedTarget=qe,ct=null,St(lt)===Ke&&(Vt=new Vt(Be,Re+"enter",Rt,_,lt),Vt.target=qe,Vt.relatedTarget=Vn,ct=Vt),Vn=ct,it&&Rt)t:{for(Vt=jne,Be=it,Re=Rt,qe=0,ct=Be;ct;ct=Vt(ct))qe++;ct=0;for(var zt=Re;zt;zt=Vt(zt))ct++;for(;0<qe-ct;)Be=Vt(Be),qe--;for(;0<ct-qe;)Re=Vt(Re),ct--;for(;qe--;){if(Be===Re||Re!==null&&Be===Re.alternate){Vt=Be;break t}Be=Vt(Be),Re=Vt(Re)}Vt=null}else Vt=null;it!==null&&cU(dt,Qe,it,Vt,!1),Rt!==null&&Vn!==null&&cU(dt,Vn,Rt,Vt,!0)}}e:{if(Qe=Ke?Ee(Ke):window,it=Qe.nodeName&&Qe.nodeName.toLowerCase(),it==="select"||it==="input"&&Qe.type==="file")var Mn=AL;else if(EL(Qe))if(TL)Mn=Wte;else{Mn=Vte;var Lt=$te}else it=Qe.nodeName,!it||it.toLowerCase()!=="input"||Qe.type!=="checkbox"&&Qe.type!=="radio"?Ke&&cM(Ke.elementType)&&(Mn=AL):Mn=Gte;if(Mn&&(Mn=Mn(h,Ke))){ML(dt,Mn,_,lt);break e}Lt&&Lt(h,Qe,Ke),h==="focusout"&&Ke&&Qe.type==="number"&&Ke.memoizedProps.value!=null&&Ei(Qe,"number",Qe.value)}switch(Lt=Ke?Ee(Ke):window,h){case"focusin":(EL(Lt)||Lt.contentEditable==="true")&&(xf=Lt,SM=Ke,gg=null);break;case"focusout":gg=SM=xf=null;break;case"mousedown":EM=!0;break;case"contextmenu":case"mouseup":case"dragend":EM=!1,jL(dt,_,lt);break;case"selectionchange":if(Kte)break;case"keydown":case"keyup":jL(dt,_,lt)}var tn;if(vM)e:{switch(h){case"compositionstart":var vn="onCompositionStart";break e;case"compositionend":vn="onCompositionEnd";break e;case"compositionupdate":vn="onCompositionUpdate";break e}vn=void 0}else gf?wL(h,_)&&(vn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(vn="onCompositionStart");vn&&(vL&&_.locale!=="ko"&&(gf||vn!=="onCompositionStart"?vn==="onCompositionEnd"&&gf&&(tn=pL()):(Bc=lt,pM="value"in Bc?Bc.value:Bc.textContent,gf=!0)),Lt=Vv(Ke,vn),0<Lt.length&&(vn=new xL(vn,h,null,_,lt),dt.push({event:vn,listeners:Lt}),tn?vn.data=tn:(tn=SL(_),tn!==null&&(vn.data=tn)))),(tn=Ute?Fte(h,_):zte(h,_))&&(vn=Vv(Ke,"onBeforeInput"),0<vn.length&&(Lt=new xL("onBeforeInput","beforeinput",null,_,lt),dt.push({event:Lt,listeners:vn}),Lt.data=tn)),Pne(dt,h,Ke,_,lt)}oU(dt,p)})}function Bg(h,p,_){return{instance:h,listener:p,currentTarget:_}}function Vv(h,p){for(var _=p+"Capture",w=[];h!==null;){var P=h,O=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||O===null||(P=lg(h,_),P!=null&&w.unshift(Bg(h,P,O)),P=lg(h,p),P!=null&&w.push(Bg(h,P,O))),h.tag===3)return w;h=h.return}return[]}function jne(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function cU(h,p,_,w,P){for(var O=p._reactName,X=[];_!==null&&_!==w;){var oe=_,Me=oe.alternate,Ke=oe.stateNode;if(oe=oe.tag,Me!==null&&Me===w)break;oe!==5&&oe!==26&&oe!==27||Ke===null||(Me=Ke,P?(Ke=lg(_,O),Ke!=null&&X.unshift(Bg(_,Ke,Me))):P||(Ke=lg(_,O),Ke!=null&&X.push(Bg(_,Ke,Me)))),_=_.return}X.length!==0&&h.push({event:p,listeners:X})}var Lne=/\r\n?/g,Ine=/\u0000|\uFFFD/g;function uU(h){return(typeof h=="string"?h:""+h).replace(Lne,`
- `).replace(Ine,"")}function dU(h,p){return p=uU(p),uU(h)===p}function $n(h,p,_,w,P,O){switch(_){case"children":typeof w=="string"?p==="body"||p==="textarea"&&w===""||Ho(h,w):(typeof w=="number"||typeof w=="bigint")&&p!=="body"&&Ho(h,""+w);break;case"className":Ft(h,"class",w);break;case"tabIndex":Ft(h,"tabindex",w);break;case"dir":case"role":case"viewBox":case"width":case"height":Ft(h,_,w);break;case"style":dL(h,w,O);break;case"data":if(p!=="object"){Ft(h,"data",w);break}case"src":case"href":if(w===""&&(p!=="a"||_!=="href")){h.removeAttribute(_);break}if(w==null||typeof w=="function"||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=Yb(""+w),h.setAttribute(_,w);break;case"action":case"formAction":if(typeof w=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof O=="function"&&(_==="formAction"?(p!=="input"&&$n(h,p,"name",P.name,P,null),$n(h,p,"formEncType",P.formEncType,P,null),$n(h,p,"formMethod",P.formMethod,P,null),$n(h,p,"formTarget",P.formTarget,P,null)):($n(h,p,"encType",P.encType,P,null),$n(h,p,"method",P.method,P,null),$n(h,p,"target",P.target,P,null)));if(w==null||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=Yb(""+w),h.setAttribute(_,w);break;case"onClick":w!=null&&(h.onclick=Ml);break;case"onScroll":w!=null&&pn("scroll",h);break;case"onScrollEnd":w!=null&&pn("scrollend",h);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=w&&typeof w!="function"&&typeof w!="symbol";break;case"muted":h.muted=w&&typeof w!="function"&&typeof w!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(w==null||typeof w=="function"||typeof w=="boolean"||typeof w=="symbol"){h.removeAttribute("xlink:href");break}_=Yb(""+w),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""+w):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":w&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":w===!0?h.setAttribute(_,""):w!==!1&&w!=null&&typeof w!="function"&&typeof w!="symbol"?h.setAttribute(_,w):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":w!=null&&typeof w!="function"&&typeof w!="symbol"&&!isNaN(w)&&1<=w?h.setAttribute(_,w):h.removeAttribute(_);break;case"rowSpan":case"start":w==null||typeof w=="function"||typeof w=="symbol"||isNaN(w)?h.removeAttribute(_):h.setAttribute(_,w);break;case"popover":pn("beforetoggle",h),pn("toggle",h),Kt(h,"popover",w);break;case"xlinkActuate":nn(h,"http://www.w3.org/1999/xlink","xlink:actuate",w);break;case"xlinkArcrole":nn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",w);break;case"xlinkRole":nn(h,"http://www.w3.org/1999/xlink","xlink:role",w);break;case"xlinkShow":nn(h,"http://www.w3.org/1999/xlink","xlink:show",w);break;case"xlinkTitle":nn(h,"http://www.w3.org/1999/xlink","xlink:title",w);break;case"xlinkType":nn(h,"http://www.w3.org/1999/xlink","xlink:type",w);break;case"xmlBase":nn(h,"http://www.w3.org/XML/1998/namespace","xml:base",w);break;case"xmlLang":nn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",w);break;case"xmlSpace":nn(h,"http://www.w3.org/XML/1998/namespace","xml:space",w);break;case"is":Kt(h,"is",w);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=dte.get(_)||_,Kt(h,_,w))}}function X2(h,p,_,w,P,O){switch(_){case"style":dL(h,w,O);break;case"dangerouslySetInnerHTML":if(w!=null){if(typeof w!="object"||!("__html"in w))throw Error(r(61));if(_=w.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof w=="string"?Ho(h,w):(typeof w=="number"||typeof w=="bigint")&&Ho(h,""+w);break;case"onScroll":w!=null&&pn("scroll",h);break;case"onScrollEnd":w!=null&&pn("scrollend",h);break;case"onClick":w!=null&&(h.onclick=Ml);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ot.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),p=_.slice(2,P?_.length-7:void 0),O=h[Dr]||null,O=O!=null?O[_]:null,typeof O=="function"&&h.removeEventListener(p,O,P),typeof w=="function")){typeof O!="function"&&O!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(p,w,P);break e}_ in h?h[_]=w:w===!0?h.setAttribute(_,""):Kt(h,_,w)}}}function $i(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":pn("error",h),pn("load",h);var w=!1,P=!1,O;for(O in _)if(_.hasOwnProperty(O)){var X=_[O];if(X!=null)switch(O){case"src":w=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:$n(h,p,O,X,_,null)}}P&&$n(h,p,"srcSet",_.srcSet,_,null),w&&$n(h,p,"src",_.src,_,null);return;case"input":pn("invalid",h);var oe=O=X=P=null,Me=null,Ke=null;for(w in _)if(_.hasOwnProperty(w)){var lt=_[w];if(lt!=null)switch(w){case"name":P=lt;break;case"type":X=lt;break;case"checked":Me=lt;break;case"defaultChecked":Ke=lt;break;case"value":O=lt;break;case"defaultValue":oe=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,p));break;default:$n(h,p,w,lt,_,null)}}On(h,O,oe,Me,Ke,X,P,!1);return;case"select":pn("invalid",h),w=X=O=null;for(P in _)if(_.hasOwnProperty(P)&&(oe=_[P],oe!=null))switch(P){case"value":O=oe;break;case"defaultValue":X=oe;break;case"multiple":w=oe;default:$n(h,p,P,oe,_,null)}p=O,_=X,h.multiple=!!w,p!=null?ai(h,!!w,p,!1):_!=null&&ai(h,!!w,_,!0);return;case"textarea":pn("invalid",h),O=P=w=null;for(X in _)if(_.hasOwnProperty(X)&&(oe=_[X],oe!=null))switch(X){case"value":w=oe;break;case"defaultValue":P=oe;break;case"children":O=oe;break;case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(91));break;default:$n(h,p,X,oe,_,null)}Fi(h,w,P,O);return;case"option":for(Me in _)if(_.hasOwnProperty(Me)&&(w=_[Me],w!=null))switch(Me){case"selected":h.selected=w&&typeof w!="function"&&typeof w!="symbol";break;default:$n(h,p,Me,w,_,null)}return;case"dialog":pn("beforetoggle",h),pn("toggle",h),pn("cancel",h),pn("close",h);break;case"iframe":case"object":pn("load",h);break;case"video":case"audio":for(w=0;w<zg.length;w++)pn(zg[w],h);break;case"image":pn("error",h),pn("load",h);break;case"details":pn("toggle",h);break;case"embed":case"source":case"link":pn("error",h),pn("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Ke in _)if(_.hasOwnProperty(Ke)&&(w=_[Ke],w!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:$n(h,p,Ke,w,_,null)}return;default:if(cM(p)){for(lt in _)_.hasOwnProperty(lt)&&(w=_[lt],w!==void 0&&X2(h,p,lt,w,_,void 0));return}}for(oe in _)_.hasOwnProperty(oe)&&(w=_[oe],w!=null&&$n(h,p,oe,w,_,null))}function Une(h,p,_,w){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,O=null,X=null,oe=null,Me=null,Ke=null,lt=null;for(it in _){var dt=_[it];if(_.hasOwnProperty(it)&&dt!=null)switch(it){case"checked":break;case"value":break;case"defaultValue":Me=dt;default:w.hasOwnProperty(it)||$n(h,p,it,null,w,dt)}}for(var Qe in w){var it=w[Qe];if(dt=_[Qe],w.hasOwnProperty(Qe)&&(it!=null||dt!=null))switch(Qe){case"type":O=it;break;case"name":P=it;break;case"checked":Ke=it;break;case"defaultChecked":lt=it;break;case"value":X=it;break;case"defaultValue":oe=it;break;case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(r(137,p));break;default:it!==dt&&$n(h,p,Qe,it,w,dt)}}ho(h,X,oe,Me,Ke,lt,O,P);return;case"select":it=X=oe=Qe=null;for(O in _)if(Me=_[O],_.hasOwnProperty(O)&&Me!=null)switch(O){case"value":break;case"multiple":it=Me;default:w.hasOwnProperty(O)||$n(h,p,O,null,w,Me)}for(P in w)if(O=w[P],Me=_[P],w.hasOwnProperty(P)&&(O!=null||Me!=null))switch(P){case"value":Qe=O;break;case"defaultValue":oe=O;break;case"multiple":X=O;default:O!==Me&&$n(h,p,P,O,w,Me)}p=oe,_=X,w=it,Qe!=null?ai(h,!!_,Qe,!1):!!w!=!!_&&(p!=null?ai(h,!!_,p,!0):ai(h,!!_,_?[]:"",!1));return;case"textarea":it=Qe=null;for(oe in _)if(P=_[oe],_.hasOwnProperty(oe)&&P!=null&&!w.hasOwnProperty(oe))switch(oe){case"value":break;case"children":break;default:$n(h,p,oe,null,w,P)}for(X in w)if(P=w[X],O=_[X],w.hasOwnProperty(X)&&(P!=null||O!=null))switch(X){case"value":Qe=P;break;case"defaultValue":it=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==O&&$n(h,p,X,P,w,O)}Mi(h,Qe,it);return;case"option":for(var Rt in _)if(Qe=_[Rt],_.hasOwnProperty(Rt)&&Qe!=null&&!w.hasOwnProperty(Rt))switch(Rt){case"selected":h.selected=!1;break;default:$n(h,p,Rt,null,w,Qe)}for(Me in w)if(Qe=w[Me],it=_[Me],w.hasOwnProperty(Me)&&Qe!==it&&(Qe!=null||it!=null))switch(Me){case"selected":h.selected=Qe&&typeof Qe!="function"&&typeof Qe!="symbol";break;default:$n(h,p,Me,Qe,w,it)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Vt in _)Qe=_[Vt],_.hasOwnProperty(Vt)&&Qe!=null&&!w.hasOwnProperty(Vt)&&$n(h,p,Vt,null,w,Qe);for(Ke in w)if(Qe=w[Ke],it=_[Ke],w.hasOwnProperty(Ke)&&Qe!==it&&(Qe!=null||it!=null))switch(Ke){case"children":case"dangerouslySetInnerHTML":if(Qe!=null)throw Error(r(137,p));break;default:$n(h,p,Ke,Qe,w,it)}return;default:if(cM(p)){for(var Vn in _)Qe=_[Vn],_.hasOwnProperty(Vn)&&Qe!==void 0&&!w.hasOwnProperty(Vn)&&X2(h,p,Vn,void 0,w,Qe);for(lt in w)Qe=w[lt],it=_[lt],!w.hasOwnProperty(lt)||Qe===it||Qe===void 0&&it===void 0||X2(h,p,lt,Qe,w,it);return}}for(var Be in _)Qe=_[Be],_.hasOwnProperty(Be)&&Qe!=null&&!w.hasOwnProperty(Be)&&$n(h,p,Be,null,w,Qe);for(dt in w)Qe=w[dt],it=_[dt],!w.hasOwnProperty(dt)||Qe===it||Qe==null&&it==null||$n(h,p,dt,Qe,w,it)}function hU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Fne(){if(typeof performance.getEntriesByType=="function"){for(var h=0,p=0,_=performance.getEntriesByType("resource"),w=0;w<_.length;w++){var P=_[w],O=P.transferSize,X=P.initiatorType,oe=P.duration;if(O&&oe&&hU(X)){for(X=0,oe=P.responseEnd,w+=1;w<_.length;w++){var Me=_[w],Ke=Me.startTime;if(Ke>oe)break;var lt=Me.transferSize,dt=Me.initiatorType;lt&&hU(dt)&&(Me=Me.responseEnd,X+=lt*(Me<oe?1:(oe-Ke)/(Me-Ke)))}if(--w,p+=8*(O+X)/(P.duration/1e3),h++,10<h)break}}if(0<h)return p/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var Y2=null,Z2=null;function Gv(h){return h.nodeType===9?h:h.ownerDocument}function fU(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function pU(h,p){if(h===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&p==="foreignObject"?0:h}function Q2(h,p){return h==="textarea"||h==="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 J2=null;function zne(){var h=window.event;return h&&h.type==="popstate"?h===J2?!1:(J2=h,!0):(J2=null,!1)}var mU=typeof setTimeout=="function"?setTimeout:void 0,Bne=typeof clearTimeout=="function"?clearTimeout:void 0,gU=typeof Promise=="function"?Promise:void 0,Hne=typeof queueMicrotask=="function"?queueMicrotask:typeof gU<"u"?function(h){return gU.resolve(null).then(h).catch($ne)}:mU;function $ne(h){setTimeout(function(){throw h})}function iu(h){return h==="head"}function xU(h,p){var _=p,w=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(w===0){h.removeChild(P),Vf(p);return}w--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")w++;else if(_==="html")Hg(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Hg(_);for(var O=_.firstChild;O;){var X=O.nextSibling,oe=O.nodeName;O[rt]||oe==="SCRIPT"||oe==="STYLE"||oe==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=X}}else _==="body"&&Hg(h.ownerDocument.body);_=P}while(_);Vf(p)}function bU(h,p){var _=h;h=0;do{var w=_.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||""),w&&w.nodeType===8)if(_=w.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=w}while(_)}function eA(h){var p=h.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var _=p;switch(p=p.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":eA(_),et(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Vne(h,p,_,w){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==p.toLowerCase()){if(!w&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(w){if(!h[rt])switch(p){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(O=h.getAttribute("rel"),O==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(O!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(O=h.getAttribute("src"),(O!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&O&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(p==="input"&&h.type==="hidden"){var O=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===O)return h}else return h;if(h=ka(h.nextSibling),h===null)break}return null}function Gne(h,p,_){if(p==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=ka(h.nextSibling),h===null))return null;return h}function vU(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=ka(h.nextSibling),h===null))return null;return h}function tA(h){return h.data==="$?"||h.data==="$~"}function nA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Wne(h,p){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=p;else if(h.data!=="$?"||_.readyState!=="loading")p();else{var w=function(){p(),_.removeEventListener("DOMContentLoaded",w)};_.addEventListener("DOMContentLoaded",w),h._reactRetry=w}}function ka(h){for(;h!=null;h=h.nextSibling){var p=h.nodeType;if(p===1||p===3)break;if(p===8){if(p=h.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return h}var rA=null;function yU(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return ka(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function _U(h){h=h.previousSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(p===0)return h;p--}else _!=="/$"&&_!=="/&"||p++}h=h.previousSibling}return null}function wU(h,p,_){switch(p=Gv(_),h){case"html":if(h=p.documentElement,!h)throw Error(r(452));return h;case"head":if(h=p.head,!h)throw Error(r(453));return h;case"body":if(h=p.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Hg(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);et(h)}var Pa=new Map,SU=new Set;function Wv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Bl=V.d;V.d={f:qne,r:Kne,D:Xne,C:Yne,L:Zne,m:Qne,X:ere,S:Jne,M:tre};function qne(){var h=Bl.f(),p=Iv();return h||p}function Kne(h){var p=se(h);p!==null&&p.tag===5&&p.type==="form"?zI(p):Bl.r(h)}var Bf=typeof document>"u"?null:document;function EU(h,p,_){var w=Bf;if(w&&typeof p=="string"&&p){var P=Pn(p);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),SU.has(P)||(SU.add(P),h={rel:h,crossOrigin:_,href:p},w.querySelector(P)===null&&(p=w.createElement("link"),$i(p,"link",h),Oe(p),w.head.appendChild(p)))}}function Xne(h){Bl.D(h),EU("dns-prefetch",h,null)}function Yne(h,p){Bl.C(h,p),EU("preconnect",h,p)}function Zne(h,p,_){Bl.L(h,p,_);var w=Bf;if(w&&h&&p){var P='link[rel="preload"][as="'+Pn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Pn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Pn(_.imageSizes)+'"]')):P+='[href="'+Pn(h)+'"]';var O=P;switch(p){case"style":O=Hf(h);break;case"script":O=$f(h)}Pa.has(O)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),Pa.set(O,h),w.querySelector(P)!==null||p==="style"&&w.querySelector($g(O))||p==="script"&&w.querySelector(Vg(O))||(p=w.createElement("link"),$i(p,"link",h),Oe(p),w.head.appendChild(p)))}}function Qne(h,p){Bl.m(h,p);var _=Bf;if(_&&h){var w=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+Pn(w)+'"][href="'+Pn(h)+'"]',O=P;switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=$f(h)}if(!Pa.has(O)&&(h=f({rel:"modulepreload",href:h},p),Pa.set(O,h),_.querySelector(P)===null)){switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Vg(O)))return}w=_.createElement("link"),$i(w,"link",h),Oe(w),_.head.appendChild(w)}}}function Jne(h,p,_){Bl.S(h,p,_);var w=Bf;if(w&&h){var P=Le(w).hoistableStyles,O=Hf(h);p=p||"default";var X=P.get(O);if(!X){var oe={loading:0,preload:null};if(X=w.querySelector($g(O)))oe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=Pa.get(O))&&iA(h,_);var Me=X=w.createElement("link");Oe(Me),$i(Me,"link",h),Me._p=new Promise(function(Ke,lt){Me.onload=Ke,Me.onerror=lt}),Me.addEventListener("load",function(){oe.loading|=1}),Me.addEventListener("error",function(){oe.loading|=2}),oe.loading|=4,qv(X,p,w)}X={type:"stylesheet",instance:X,count:1,state:oe},P.set(O,X)}}}function ere(h,p){Bl.X(h,p);var _=Bf;if(_&&h){var w=Le(_).hoistableScripts,P=$f(h),O=w.get(P);O||(O=_.querySelector(Vg(P)),O||(h=f({src:h,async:!0},p),(p=Pa.get(P))&&sA(h,p),O=_.createElement("script"),Oe(O),$i(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(P,O))}}function tre(h,p){Bl.M(h,p);var _=Bf;if(_&&h){var w=Le(_).hoistableScripts,P=$f(h),O=w.get(P);O||(O=_.querySelector(Vg(P)),O||(h=f({src:h,async:!0,type:"module"},p),(p=Pa.get(P))&&sA(h,p),O=_.createElement("script"),Oe(O),$i(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(P,O))}}function MU(h,p,_,w){var P=(P=de.current)?Wv(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(p=Hf(_.href),_=Le(P).hoistableStyles,w=_.get(p),w||(w={type:"style",instance:null,count:0,state:null},_.set(p,w)),w):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Hf(_.href);var O=Le(P).hoistableStyles,X=O.get(h);if(X||(P=P.ownerDocument||P,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(h,X),(O=P.querySelector($g(h)))&&!O._p&&(X.instance=O,X.state.loading=5),Pa.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Pa.set(h,_),O||nre(P,h,_,X.state))),p&&w===null)throw Error(r(528,""));return X}if(p&&w!==null)throw Error(r(529,""));return null;case"script":return p=_.async,_=_.src,typeof _=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=$f(_),_=Le(P).hoistableScripts,w=_.get(p),w||(w={type:"script",instance:null,count:0,state:null},_.set(p,w)),w):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Hf(h){return'href="'+Pn(h)+'"'}function $g(h){return'link[rel="stylesheet"]['+h+"]"}function AU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function nre(h,p,_,w){h.querySelector('link[rel="preload"][as="style"]['+p+"]")?w.loading=1:(p=h.createElement("link"),w.preload=p,p.addEventListener("load",function(){return w.loading|=1}),p.addEventListener("error",function(){return w.loading|=2}),$i(p,"link",_),Oe(p),h.head.appendChild(p))}function $f(h){return'[src="'+Pn(h)+'"]'}function Vg(h){return"script[async]"+h}function TU(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var w=h.querySelector('style[data-href~="'+Pn(_.href)+'"]');if(w)return p.instance=w,Oe(w),w;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return w=(h.ownerDocument||h).createElement("style"),Oe(w),$i(w,"style",P),qv(w,_.precedence,h),p.instance=w;case"stylesheet":P=Hf(_.href);var O=h.querySelector($g(P));if(O)return p.state.loading|=4,p.instance=O,Oe(O),O;w=AU(_),(P=Pa.get(P))&&iA(w,P),O=(h.ownerDocument||h).createElement("link"),Oe(O);var X=O;return X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),$i(O,"link",w),p.state.loading|=4,qv(O,_.precedence,h),p.instance=O;case"script":return O=$f(_.src),(P=h.querySelector(Vg(O)))?(p.instance=P,Oe(P),P):(w=_,(P=Pa.get(O))&&(w=f({},_),sA(w,P)),h=h.ownerDocument||h,P=h.createElement("script"),Oe(P),$i(P,"link",w),h.head.appendChild(P),p.instance=P);case"void":return null;default:throw Error(r(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(w=p.instance,p.state.loading|=4,qv(w,_.precedence,h));return p.instance}function qv(h,p,_){for(var w=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=w.length?w[w.length-1]:null,O=P,X=0;X<w.length;X++){var oe=w[X];if(oe.dataset.precedence===p)O=oe;else if(O!==P)break}O?O.parentNode.insertBefore(h,O.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(h,p.firstChild))}function iA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.title==null&&(h.title=p.title)}function sA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.integrity==null&&(h.integrity=p.integrity)}var Kv=null;function CU(h,p,_){if(Kv===null){var w=new Map,P=Kv=new Map;P.set(_,w)}else P=Kv,w=P.get(_),w||(w=new Map,P.set(_,w));if(w.has(h))return w;for(w.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var O=_[P];if(!(O[rt]||O[br]||h==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var X=O.getAttribute(p)||"";X=h+X;var oe=w.get(X);oe?oe.push(O):w.set(X,[O])}}return w}function NU(h,p,_){h=h.ownerDocument||h,h.head.insertBefore(_,p==="title"?h.querySelector("head > title"):null)}function rre(h,p,_){if(_===1||p.itemProp!=null)return!1;switch(h){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 h=p.disabled,typeof p.precedence=="string"&&h==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 kU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function ire(h,p,_,w){if(_.type==="stylesheet"&&(typeof w.media!="string"||matchMedia(w.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Hf(w.href),O=p.querySelector($g(P));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=Xv.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=O,Oe(O);return}O=p.ownerDocument||p,w=AU(w),(P=Pa.get(P))&&iA(w,P),O=O.createElement("link"),Oe(O);var X=O;X._p=new Promise(function(oe,Me){X.onload=oe,X.onerror=Me}),$i(O,"link",w),_.instance=O}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,p),(p=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=Xv.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var aA=0;function sre(h,p){return h.stylesheets&&h.count===0&&Zv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var w=setTimeout(function(){if(h.stylesheets&&Zv(h,h.stylesheets),h.unsuspend){var O=h.unsuspend;h.unsuspend=null,O()}},6e4+p);0<h.imgBytes&&aA===0&&(aA=62500*Fne());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&Zv(h,h.stylesheets),h.unsuspend)){var O=h.unsuspend;h.unsuspend=null,O()}},(h.imgBytes>aA?50:800)+p);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(w),clearTimeout(P)}}:null}function Xv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Yv=null;function Zv(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Yv=new Map,p.forEach(are,h),Yv=null,Xv.call(h))}function are(h,p){if(!(p.state.loading&4)){var _=Yv.get(h);if(_)var w=_.get(null);else{_=new Map,Yv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<P.length;O++){var X=P[O];(X.nodeName==="LINK"||X.getAttribute("media")!=="not all")&&(_.set(X.dataset.precedence,X),w=X)}w&&_.set(null,w)}P=p.instance,X=P.getAttribute("data-precedence"),O=_.get(X)||w,O===w&&_.set(null,P),_.set(X,P),this.count++,w=Xv.bind(this),P.addEventListener("load",w),P.addEventListener("error",w),O?O.parentNode.insertBefore(P,O.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),p.state.loading|=4}}var Gg={$$typeof:S,Provider:null,Consumer:null,_currentValue:te,_currentValue2:te,_threadCount:0};function ore(h,p,_,w,P,O,X,oe,Me){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ot(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.hiddenUpdates=Ot(null),this.identifierPrefix=w,this.onUncaughtError=P,this.onCaughtError=O,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Me,this.incompleteTransitions=new Map}function PU(h,p,_,w,P,O,X,oe,Me,Ke,lt,dt){return h=new ore(h,p,_,X,Me,Ke,lt,dt,oe),p=1,O===!0&&(p|=24),O=ta(3,null,null,p),h.current=O,O.stateNode=h,p=FM(),p.refCount++,h.pooledCache=p,p.refCount++,O.memoizedState={element:w,isDehydrated:_,cache:p},$M(O),h}function RU(h){return h?(h=yf,h):yf}function DU(h,p,_,w,P,O){P=RU(P),w.context===null?w.context=P:w.pendingContext=P,w=qc(p),w.payload={element:_},O=O===void 0?null:O,O!==null&&(w.callback=O),_=Kc(h,w,p),_!==null&&(Us(_,h,p),Sg(_,h,p))}function OU(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function oA(h,p){OU(h,p),(h=h.alternate)&&OU(h,p)}function jU(h){if(h.tag===13||h.tag===31){var p=Td(h,67108864);p!==null&&Us(p,h,67108864),oA(h,67108864)}}function LU(h){if(h.tag===13||h.tag===31){var p=aa();p=si(p);var _=Td(h,p);_!==null&&Us(_,h,p),oA(h,p)}}var Qv=!0;function lre(h,p,_,w){var P=K.T;K.T=null;var O=V.p;try{V.p=2,lA(h,p,_,w)}finally{V.p=O,K.T=P}}function cre(h,p,_,w){var P=K.T;K.T=null;var O=V.p;try{V.p=8,lA(h,p,_,w)}finally{V.p=O,K.T=P}}function lA(h,p,_,w){if(Qv){var P=cA(w);if(P===null)K2(h,p,w,Jv,_),UU(h,w);else if(dre(P,h,p,_,w))w.stopPropagation();else if(UU(h,w),p&4&&-1<ure.indexOf(h)){for(;P!==null;){var O=se(P);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var X=Ce(O.pendingLanes);if(X!==0){var oe=O;for(oe.pendingLanes|=2,oe.entangledLanes|=2;X;){var Me=1<<31-$e(X);oe.entanglements[1]|=Me,X&=~Me}Wo(O),(Nn&6)===0&&(jv=L()+500,Fg(0))}}break;case 31:case 13:oe=Td(O,2),oe!==null&&Us(oe,O,2),Iv(),oA(O,2)}if(O=cA(w),O===null&&K2(h,p,w,Jv,_),O===P)break;P=O}P!==null&&w.stopPropagation()}else K2(h,p,w,null,_)}}function cA(h){return h=dM(h),uA(h)}var Jv=null;function uA(h){if(Jv=null,h=St(h),h!==null){var p=s(h);if(p===null)h=null;else{var _=p.tag;if(_===13){if(h=a(p),h!==null)return h;h=null}else if(_===31){if(h=o(p),h!==null)return h;h=null}else if(_===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;h=null}else p!==h&&(h=null)}}return Jv=h,null}function IU(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ne()){case be:return 2;case we:return 8;case ge:case me:return 32;case Ae:return 268435456;default:return 32}default:return 32}}var dA=!1,su=null,au=null,ou=null,Wg=new Map,qg=new Map,lu=[],ure="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 UU(h,p){switch(h){case"focusin":case"focusout":su=null;break;case"dragenter":case"dragleave":au=null;break;case"mouseover":case"mouseout":ou=null;break;case"pointerover":case"pointerout":Wg.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":qg.delete(p.pointerId)}}function Kg(h,p,_,w,P,O){return h===null||h.nativeEvent!==O?(h={blockedOn:p,domEventName:_,eventSystemFlags:w,nativeEvent:O,targetContainers:[P]},p!==null&&(p=se(p),p!==null&&jU(p)),h):(h.eventSystemFlags|=w,p=h.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),h)}function dre(h,p,_,w,P){switch(p){case"focusin":return su=Kg(su,h,p,_,w,P),!0;case"dragenter":return au=Kg(au,h,p,_,w,P),!0;case"mouseover":return ou=Kg(ou,h,p,_,w,P),!0;case"pointerover":var O=P.pointerId;return Wg.set(O,Kg(Wg.get(O)||null,h,p,_,w,P)),!0;case"gotpointercapture":return O=P.pointerId,qg.set(O,Kg(qg.get(O)||null,h,p,_,w,P)),!0}return!1}function FU(h){var p=St(h.target);if(p!==null){var _=s(p);if(_!==null){if(p=_.tag,p===13){if(p=a(_),p!==null){h.blockedOn=p,ts(h.priority,function(){LU(_)});return}}else if(p===31){if(p=o(_),p!==null){h.blockedOn=p,ts(h.priority,function(){LU(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function ey(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=cA(h.nativeEvent);if(_===null){_=h.nativeEvent;var w=new _.constructor(_.type,_);uM=w,_.target.dispatchEvent(w),uM=null}else return p=se(_),p!==null&&jU(p),h.blockedOn=_,!1;p.shift()}return!0}function zU(h,p,_){ey(h)&&_.delete(p)}function hre(){dA=!1,su!==null&&ey(su)&&(su=null),au!==null&&ey(au)&&(au=null),ou!==null&&ey(ou)&&(ou=null),Wg.forEach(zU),qg.forEach(zU)}function ty(h,p){h.blockedOn===p&&(h.blockedOn=null,dA||(dA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,hre)))}var ny=null;function BU(h){ny!==h&&(ny=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ny===h&&(ny=null);for(var p=0;p<h.length;p+=3){var _=h[p],w=h[p+1],P=h[p+2];if(typeof w!="function"){if(uA(w||_)===null)continue;break}var O=se(_);O!==null&&(h.splice(p,3),p-=3,c2(O,{pending:!0,data:P,method:_.method,action:w},w,P))}}))}function Vf(h){function p(Me){return ty(Me,h)}su!==null&&ty(su,h),au!==null&&ty(au,h),ou!==null&&ty(ou,h),Wg.forEach(p),qg.forEach(p);for(var _=0;_<lu.length;_++){var w=lu[_];w.blockedOn===h&&(w.blockedOn=null)}for(;0<lu.length&&(_=lu[0],_.blockedOn===null);)FU(_),_.blockedOn===null&&lu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(w=0;w<_.length;w+=3){var P=_[w],O=_[w+1],X=P[Dr]||null;if(typeof O=="function")X||BU(_);else if(X){var oe=null;if(O&&O.hasAttribute("formAction")){if(P=O,X=O[Dr]||null)oe=X.formAction;else if(uA(P)!==null)continue}else oe=X.action;typeof oe=="function"?_[w+1]=oe:(_.splice(w,3),w-=3),BU(_)}}}function HU(){function h(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(X){return P=X})},focusReset:"manual",scroll:"manual"})}function p(){P!==null&&(P(),P=null),w||setTimeout(_,20)}function _(){if(!w&&!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 w=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(_,100),function(){w=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),P!==null&&(P(),P=null)}}}function hA(h){this._internalRoot=h}ry.prototype.render=hA.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,w=aa();DU(_,w,h,p,null,null)},ry.prototype.unmount=hA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;DU(h.current,2,null,h,null,null),Iv(),p[uo]=null}};function ry(h){this._internalRoot=h}ry.prototype.unstable_scheduleHydration=function(h){if(h){var p=Ui();h={blockedOn:null,target:h,priority:p};for(var _=0;_<lu.length&&p!==0&&p<lu[_].priority;_++);lu.splice(_,0,h),_===0&&FU(h)}};var $U=e.version;if($U!=="19.2.0")throw Error(r(527,$U,"19.2.0"));V.findDOMNode=function(h){var p=h._reactInternals;if(p===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(p),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var fre={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var iy=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!iy.isDisabled&&iy.supportsFiber)try{Ve=iy.inject(fre),ce=iy}catch{}}return Yg.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,w="",P=YI,O=ZI,X=QI;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(w=p.identifierPrefix),p.onUncaughtError!==void 0&&(P=p.onUncaughtError),p.onCaughtError!==void 0&&(O=p.onCaughtError),p.onRecoverableError!==void 0&&(X=p.onRecoverableError)),p=PU(h,1,!1,null,null,_,w,null,P,O,X,HU),h[uo]=p.current,q2(h),new hA(p)},Yg.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var w=!1,P="",O=YI,X=ZI,oe=QI,Me=null;return _!=null&&(_.unstable_strictMode===!0&&(w=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(X=_.onCaughtError),_.onRecoverableError!==void 0&&(oe=_.onRecoverableError),_.formState!==void 0&&(Me=_.formState)),p=PU(h,1,!0,p,_??null,w,P,Me,O,X,oe,HU),p.context=RU(null),_=p.current,w=aa(),w=si(w),P=qc(w),P.callback=null,Kc(_,P,w),_=w,p.current.lanes=_,cn(p,_),Wo(p),h[uo]=p.current,q2(h),new ry(p)},Yg.version="19.2.0",Yg}var JU;function Ere(){if(JU)return mA.exports;JU=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(),mA.exports=Sre(),mA.exports}var Mre=Ere();const Wt=t=>typeof t=="string",Zg=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},e5=t=>t==null?"":""+t,Are=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Tre=/###/g,t5=t=>t&&t.indexOf("###")>-1?t.replace(Tre,"."):t,n5=t=>!t||Wt(t),Lx=(t,e,n)=>{const r=Wt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(n5(t))return{};const s=t5(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return n5(t)?{}:{obj:t,k:t5(r[i])}},r5=(t,e,n)=>{const{obj:r,k:i}=Lx(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=Lx(t,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=Lx(t,a,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=n},Cre=(t,e,n,r)=>{const{obj:i,k:s}=Lx(t,e,Object);i[s]=i[s]||[],i[s].push(n)},f1=(t,e)=>{const{obj:n,k:r}=Lx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Nre=(t,e,n)=>{const r=f1(t,n);return r!==void 0?r:f1(e,n)},uG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Wt(t[r])||t[r]instanceof String||Wt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):uG(t[r],e[r],n):t[r]=e[r]);return t},Gf=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var kre={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Pre=t=>Wt(t)?t.replace(/[&<>"'\/]/g,e=>kre[e]):t;class Rre{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 Dre=[" ",",","?","!",";"],Ore=new Rre(20),jre=(t,e,n)=>{e=e||"",n=n||"";const r=Dre.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=Ore.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},c3=(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},a0=t=>t?.replace("_","-"),Lre={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 p1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Lre,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:(Wt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new p1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new p1(this.logger,e)}}var rl=new p1;let TS=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 i5 extends TS{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):Wt(r)&&s?o.push(...r.split(s)):o.push(r)));const l=f1(this.data,o);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),l||!a||!Wt(r)?l:c3(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),r5(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)(Wt(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=f1(this.data,o)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?uG(l,r,s):l={...l,...r},r5(this.data,o,l),a.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var dG={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{e=this.processors[s]?.process(e,n,r,i)??e}),e}};const hG=Symbol("i18next/PATH_KEY");function Ire(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===hG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function u3(t,e){const{[hG]:n}=t(Ire());return n.join(e?.keySeparator??".")}const s5={},vA=t=>!Wt(t)&&typeof t!="boolean"&&typeof t!="number";class m1 extends TS{constructor(e,n={}){super(),Are(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=rl.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=vA(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&&!jre(e,r,i);if(a&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:Wt(s)?[s]:s};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(i)}return{key:e,namespaces:Wt(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=u3(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),u=l[l.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?s?{res:`${u}${d}${o}`,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${o}`:s?{res:o,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:o;const m=this.resolve(e,i);let x=m?.res;const y=m?.usedKey||o,v=m?.exactUsedKey||o,b=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,S=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!Wt(i.count),T=m1.hasDefaultValue(i),k=A?this.pluralResolver.getSuffix(f,i.count,i):"",N=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",I=A&&!i.ordinal&&i.count===0,C=I&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${N}`]||i.defaultValue;let D=x;S&&!x&&T&&(D=C);const F=vA(D),j=Object.prototype.toString.apply(D);if(S&&D&&F&&b.indexOf(j)<0&&!(Wt(E)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,D,{...i,ns:l}):`key '${o} (${this.language})' returned an object instead of string.`;return s?(m.res=q,m.usedParams=this.getUsedParamsDetails(i),m):q}if(a){const q=Array.isArray(D),R=q?[]:{},W=q?v:y;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const V=`${W}${a}${K}`;T&&!x?R[K]=this.translate(V,{...i,defaultValue:vA(C)?C[K]:void 0,joinArrays:!1,ns:l}):R[K]=this.translate(V,{...i,joinArrays:!1,ns:l}),R[K]===V&&(R[K]=D[K])}x=R}}else if(S&&Wt(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(x)&&T&&(q=!0,x=C),this.isValidLookup(x)||(R=!0,x=o);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:x,V=T&&C!==x&&this.options.updateMissing;if(R||q||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,o,V?C:x),a){const U=this.resolve(o,{...i,keySeparator:!1});U&&U.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let te=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let U=0;U<Y.length;U++)te.push(Y[U]);else this.options.saveMissingTo==="all"?te=this.languageUtils.toResolveHierarchy(i.lng||this.language):te.push(i.lng||this.language);const Z=(U,z,ee)=>{const ae=T&&ee!==x?ee:K;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,z,ae,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,z,ae,V,i),this.emit("missingKey",U,u,z,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?te.forEach(U=>{const z=this.pluralResolver.getSuffixes(U,i);I&&i[`defaultValue${this.options.pluralSeparator}zero`]&&z.indexOf(`${this.options.pluralSeparator}zero`)<0&&z.push(`${this.options.pluralSeparator}zero`),z.forEach(ee=>{Z([U],o+ee,i[`defaultValue${ee}`]||C)})}):Z(te,o,C))}x=this.extendTranslation(x,e,i,m,r),R&&x===o&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${o}`),(R||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${o}`:o,q?x:void 0,i))}return s?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}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=Wt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(l){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!Wt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),l){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>s?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const a=r.postProcess||this.options.postProcess,o=Wt(a)?[a]:a;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=dG.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,s,a,o;return Wt(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(l,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!Wt(n.count),m=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(Wt(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(o=v,!s5[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(s5[`${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(b=>{if(this.isValidLookup(r))return;a=b;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,b,v,n);else{let A;g&&(A=this.pluralResolver.getSuffix(b,n.count,n));const T=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&A.indexOf(k)===0&&E.push(d+A.replace(k,this.options.pluralSeparator)),E.push(d+A),m&&E.push(d+T)),x){const N=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(N),g&&(n.ordinal&&A.indexOf(k)===0&&E.push(N+A.replace(k,this.options.pluralSeparator)),E.push(N+A),m&&E.push(N+T))}}let S;for(;S=E.pop();)this.isValidLookup(r)||(s=S,r=this.getResource(b,v,S,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&&!Wt(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 a5{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=rl.create("languageUtils")}getScriptPartFromCode(e){if(e=a0(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=a0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Wt(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)),Wt(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 Wt(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))):Wt(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const o5={zero:0,one:1,two:2,few:3,many:4,other:5},l5={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Ure{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=rl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=a0(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!"),l5;if(!e.match(/-|_/))return l5;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)=>o5[i]-o5[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 c5=(t,e,n,r=".",i=!0)=>{let s=Nre(t,e,n);return!s&&i&&Wt(n)&&(s=c3(t,n,r),s===void 0&&(s=c3(e,n,r))),s},yA=t=>t.replace(/\$/g,"$$$$");class Fre{constructor(e={}){this.logger=rl.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:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:b,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:Pre,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Gf(s):a||"{{",this.suffix=o?Gf(o):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?Gf(g):m||Gf("$t("),this.nestingSuffix=x?Gf(x):y||Gf(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=b||1e3,this.alwaysFormat=E!==void 0?E:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let s,a,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const b=c5(n,l,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(b,void 0,r,{...i,...n,interpolationkey:m}):b}const x=m.split(this.formatSeparator),y=x.shift().trim(),v=x.join(this.formatSeparator).trim();return this.format(c5(n,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>yA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?yA(this.escape(m)):yA(m)}].forEach(m=>{for(o=0;s=m.regex.exec(e);){const x=s[1].trim();if(a=u(x),a===void 0)if(typeof d=="function"){const v=d(e,s,i);a=Wt(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))a="";else if(f){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),a="";else!Wt(a)&&!this.useRawValueToEscape&&(a=e5(a));const y=m.safeValue(a);if(e=e.replace(s[0],y),f?(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,u)=>{const d=this.nestingOptionsSeparator;if(l.indexOf(d)<0)return l;const f=l.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;l=f[0],g=this.interpolate(g,a);const m=g.match(/'/g),x=g.match(/"/g);((m?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{a=JSON.parse(g),u&&(a={...u,...a})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${d}${g}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!Wt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(l=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),s=n(o.call(this,i[1].trim(),a),a),s&&i[0]===e&&!Wt(s))return s;Wt(s)||(s=e5(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),l.length&&(s=l.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const zre=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(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),d=o.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},u5=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(a0(r),i),e[a]=o),o(n)}},Bre=t=>(e,n,r)=>t(a0(n),r)(e);class Hre{constructor(e={}){this.logger=rl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?u5:Bre;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()]=u5(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:u,formatOptions:d}=zre(l);if(this.formats[u]){let f=o;try{const g=i?.formatParams?.[i.interpolationkey]||{},m=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[u](o,m,{...d,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${u}`);return o},e)}}const $re=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Vre extends TS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=rl.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(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?a[g]===void 0&&(a[g]=!0):(this.state[g]=1,d=!1,a[g]===void 0&&(a[g]=!0),s[g]===void 0&&(s[g]=!0),l[f]===void 0&&(l[f]=!0)))}),d||(o[u]=!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=>{Cre(l.loaded,[s],a),$re(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{o[u]||(o[u]={});const d=l.loaded[u];d.length&&d.forEach(f=>{o[u][f]===void 0&&(o[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,n,r,i=0,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=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(u,d)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const u=l(e,n);u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}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();Wt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Wt(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},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,l):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>o(null,f)).catch(o):o(null,d)}catch(d){o(d)}else u(e,n,r,i,o,l)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const d5=()=>({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]),Wt(t[1])&&(e.defaultValue=t[1]),Wt(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}),h5=t=>(Wt(t.ns)&&(t.ns=[t.ns]),Wt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Wt(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),ay=()=>{},Gre=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Ix extends TS{constructor(e={},n){if(super(),this.options=h5(e),this.services={},this.logger=rl,this.modules={external:[]},Gre(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&&(Wt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=d5();this.options={...r,...this.options,...h5(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?rl.init(i(this.modules.logger),this.options):rl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Hre;const d=new a5(this.options);this.store=new i5(this.options.resources,this.options);const f=this.services;f.logger=rl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Ure(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Fre(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Vre(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new m1(this.services,this.options),this.translator.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=ay),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const o=Zg(),l=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,n=ay){let r=n;const i=Wt(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(u=>{u!=="cimode"&&s.indexOf(u)<0&&s.push(u)})};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=Zg();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=ay),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&dG.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=Zg();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((...u)=>this.t(...u)),n&&n(o,(...u)=>this.t(...u))},a=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const l=Wt(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(Wt(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{s(d,u)})};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 u=this.options.keySeparator||".";let d;return l.keyPrefix&&Array.isArray(s)?d=s.map(f=>(typeof f=="function"&&(f=u3(f,{...this.options,...a})),`${l.keyPrefix}${u}${f}`)):(typeof s=="function"&&(s=u3(s,{...this.options,...a})),d=l.keyPrefix?`${l.keyPrefix}${u}${s}`:s),this.t(d,l)};return Wt(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 u=this.services.backendConnector.state[`${o}|${l}`];return u===-1||u===0||u===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=Zg();return this.options.ns?(Wt(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=Zg();Wt(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 a5(d5());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 Ix(e,n);return r.createInstance=Ix.createInstance,r}cloneInstance(e={},n=ay){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Ix(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,u)=>(l[u]={...this.store.data[u]},l[u]=Object.keys(l[u]).reduce((d,f)=>(d[f]={...l[u][f]},d),l[u]),l),{});s.store=new i5(o,i),s.services.resourceStore=s.store}return s.translator=new m1(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 Rs=Ix.createInstance();Rs.createInstance;Rs.dir;Rs.init;Rs.loadResources;Rs.reloadResources;Rs.use;Rs.changeLanguage;Rs.getFixedT;Rs.t;Rs.exists;Rs.setDefaultNamespace;Rs.hasLoadedNamespace;Rs.loadNamespaces;Rs.loadLanguages;const Wre=(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);Dh(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},f5={},fG=(t,e,n,r)=>{Dh(n)&&f5[n]||(Dh(n)&&(f5[n]=new Date),Wre(t,e,n,r))},pG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},d3=(t,e,n)=>{t.loadNamespaces(e,pG(t,n))},p5=(t,e,n,r)=>{if(Dh(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return d3(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,pG(t,r))},qre=(t,e,n={})=>!e.languages||!e.languages.length?(fG(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}}),Dh=t=>typeof t=="string",Kre=t=>typeof t=="object"&&t!==null,Xre=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Yre={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Zre=t=>Yre[t],Qre=t=>t.replace(Xre,Zre);let h3={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Qre};const Jre=(t={})=>{h3={...h3,...t}},eie=()=>h3;let mG;const tie=t=>{mG=t},nie=()=>mG,rie={type:"3rdParty",init(t){Jre(t.options.react),tie(t)}},iie=M.createContext();class sie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var _A={exports:{}},wA={};var m5;function aie(){if(m5)return wA;m5=1;var t=Im();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,a=t.useDebugValue;function o(f,g){var m=g(),x=r({inst:{value:m,getSnapshot:g}}),y=x[0].inst,v=x[1];return s(function(){y.value=m,y.getSnapshot=g,l(y)&&v({inst:y})},[f,m,g]),i(function(){return l(y)&&v({inst:y}),f(function(){l(y)&&v({inst:y})})},[f]),a(m),m}function l(f){var g=f.getSnapshot;f=f.value;try{var m=g();return!n(f,m)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:o;return wA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,wA}var g5;function gG(){return g5||(g5=1,_A.exports=aie()),_A.exports}var vR=gG();const oie=(t,e)=>Dh(e)?e:Kre(e)&&Dh(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,lie={t:oie,ready:!1},cie=()=>()=>{},sb=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=M.useContext(iie)||{},s=n||r||nie();s&&!s.reportNamespaces&&(s.reportNamespaces=new sie),s||fG(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const a=M.useMemo(()=>({...eie(),...s?.options?.react,...e}),[s,e]),{useSuspense:o,keyPrefix:l}=a,u=i||s?.options?.defaultNS,d=Dh(u)?[u]:u||["translation"],f=M.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(f);const g=M.useRef(0),m=M.useCallback(C=>{if(!s)return cie;const{bindI18n:D,bindI18nStore:F}=a,j=()=>{g.current+=1,C()};return D&&s.on(D,j),F&&s.store.on(F,j),()=>{D&&D.split(" ").forEach(q=>s.off(q,j)),F&&F.split(" ").forEach(q=>s.store.off(q,j))}},[s,a]),x=M.useRef(),y=M.useCallback(()=>{if(!s)return lie;const C=!!(s.isInitialized||s.initializedStoreOnce)&&f.every(W=>qre(W,s,a)),D=e.lng||s.language,F=g.current,j=x.current;if(j&&j.ready===C&&j.lng===D&&j.keyPrefix===l&&j.revision===F)return j;const R={t:s.getFixedT(D,a.nsMode==="fallback"?f:f[0],l),ready:C,lng:D,keyPrefix:l,revision:F};return x.current=R,R},[s,f,l,a,e.lng]),[v,b]=M.useState(0),{t:E,ready:S}=vR.useSyncExternalStore(m,y,y);M.useEffect(()=>{if(s&&!S&&!o){const C=()=>b(D=>D+1);e.lng?p5(s,e.lng,f,C):d3(s,f,C)}},[s,e.lng,f,S,o,v]);const A=s||{},T=M.useRef(null),k=M.useRef(),N=C=>{const D=Object.getOwnPropertyDescriptors(C);D.__original&&delete D.__original;const F=Object.create(Object.getPrototypeOf(C),D);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},I=M.useMemo(()=>{const C=A,D=C?.language;let F=C;C&&(T.current&&T.current.__original===C?k.current!==D?(F=N(C),T.current=F,k.current=D):F=T.current:(F=N(C),T.current=F,k.current=D));const j=[E,F,S];return j.t=E,j.i18n=F,j.ready=S,j},[E,A,S,A.resolvedLanguage,A.language,A.languages]);if(s&&o&&!S)throw new Promise(C=>{const D=()=>C();e.lng?p5(s,e.lng,f,D):d3(s,f,D)});return I},{slice:uie,forEach:die}=[];function hie(t){return die.call(uie.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function fie(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 x5=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,pie=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(!x5.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!x5.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},b5={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=pie(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 mie={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return b5.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&b5.create(n,t,r,i,s)}},gie={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}},xie={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 Wf=null;const v5=()=>{if(Wf!==null)return Wf;try{if(Wf=typeof window<"u"&&window.localStorage!==null,!Wf)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Wf=!1}return Wf};var bie={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&v5())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&v5()&&window.localStorage.setItem(n,t)}};let qf=null;const y5=()=>{if(qf!==null)return qf;try{if(qf=typeof window<"u"&&window.sessionStorage!==null,!qf)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{qf=!1}return qf};var vie={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&y5())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&y5()&&window.sessionStorage.setItem(n,t)}},yie={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}},_ie={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}},wie={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}},Sie={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 xG=!1;try{document.cookie,xG=!0}catch{}const bG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];xG||bG.splice(1,1);const Eie=()=>({order:bG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class vG{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=hie(n,this.options||{},Eie()),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(mie),this.addDetector(gie),this.addDetector(bie),this.addDetector(vie),this.addDetector(yie),this.addDetector(_ie),this.addDetector(wie),this.addDetector(Sie),this.addDetector(xie)}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&&!fie(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)}))}}vG.type="languageDetector";const Mie={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",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?"}},Aie={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",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?"}},Tie={en:{translation:Mie},de:{translation:Aie}};Rs.use(vG).use(rie).init({resources:Tie,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const _5=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var w5="popstate";function Cie(t={}){function e(r,i){let{pathname:s,search:a,hash:o}=r.location;return f3("",{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:o0(i)}return kie(e,n,null,t)}function yr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Oo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Nie(){return Math.random().toString(36).substring(2,10)}function S5(t,e){return{usr:t.state,key:t.key,idx:e}}function f3(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Um(e):e,state:n,key:e&&e.key||r||Nie()}}function o0({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 Um(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 kie(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,o="POP",l=null,u=d();u==null&&(u=0,a.replaceState({...a.state,idx:u},""));function d(){return(a.state||{idx:null}).idx}function f(){o="POP";let v=d(),b=v==null?null:v-u;u=v,l&&l({action:o,location:y.location,delta:b})}function g(v,b){o="PUSH";let E=f3(y.location,v,b);u=d()+1;let S=S5(E,u),A=y.createHref(E);try{a.pushState(S,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}s&&l&&l({action:o,location:y.location,delta:1})}function m(v,b){o="REPLACE";let E=f3(y.location,v,b);u=d();let S=S5(E,u),A=y.createHref(E);a.replaceState(S,"",A),s&&l&&l({action:o,location:y.location,delta:0})}function x(v){return Pie(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(w5,f),l=v,()=>{i.removeEventListener(w5,f),l=null}},createHref(v){return e(i,v)},createURL:x,encodeLocation(v){let b=x(v);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:g,replace:m,go(v){return a.go(v)}};return y}function Pie(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),yr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:o0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function yG(t,e,n="/"){return Rie(t,e,n,!1)}function Rie(t,e,n,r){let i=typeof e=="string"?Um(e):e,s=Mc(i.pathname||"/",n);if(s==null)return null;let a=_G(t);Die(a);let o=null;for(let l=0;o==null&&l<a.length;++l){let u=Vie(s);o=Hie(a[l],u,r)}return o}function _G(t,e=[],n=[],r="",i=!1){let s=(a,o,l=i,u)=>{let d={relativePath:u===void 0?a.path||"":u,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&l)return;yr(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=xc([r,d.relativePath]),g=n.concat(d);a.children&&a.children.length>0&&(yr(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),_G(a.children,e,g,f,l)),!(a.path==null&&!a.index)&&e.push({path:f,score:zie(f,a.index),routesMeta:g})};return t.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))s(a,o);else for(let l of wG(a.path))s(a,o,!0,l)}),e}function wG(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=wG(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 Die(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Bie(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Oie=/^:[\w-]+$/,jie=3,Lie=2,Iie=1,Uie=10,Fie=-2,E5=t=>t==="*";function zie(t,e){let n=t.split("/"),r=n.length;return n.some(E5)&&(r+=Fie),e&&(r+=Lie),n.filter(i=>!E5(i)).reduce((i,s)=>i+(Oie.test(s)?jie:s===""?Iie:Uie),r)}function Bie(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 Hie(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",a=[];for(let o=0;o<r.length;++o){let l=r[o],u=o===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",f=g1({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},d),g=l.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=g1({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),a.push({params:i,pathname:xc([s,f.pathname]),pathnameBase:Xie(xc([s,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(s=xc([s,f.pathnameBase]))}return a}function g1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=$ie(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((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=o[g]||"";a=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const m=o[g];return f&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:a,pattern:t}}function $ie(t,e=!1,n=!0){Oo(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 Vie(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Oo(!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 Mc(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 Gie=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Wie=t=>Gie.test(t);function qie(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Um(t):t,s;if(n)if(Wie(n))s=n;else{if(n.includes("//")){let a=n;n=n.replace(/\/\/+/g,"/"),Oo(!1,`Pathnames cannot have embedded double slashes - normalizing ${a} -> ${n}`)}n.startsWith("/")?s=M5(n.substring(1),"/"):s=M5(n,e)}else s=e;return{pathname:s,search:Yie(r),hash:Zie(i)}}function M5(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 SA(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 Kie(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function SG(t){let e=Kie(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function EG(t,e,n,r=!1){let i;typeof t=="string"?i=Um(t):(i={...t},yr(!i.pathname||!i.pathname.includes("?"),SA("?","pathname","search",i)),yr(!i.pathname||!i.pathname.includes("#"),SA("#","pathname","hash",i)),yr(!i.search||!i.search.includes("#"),SA("#","search","hash",i)));let s=t===""||i.pathname==="",a=s?"/":i.pathname,o;if(a==null)o=n;else{let f=e.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}o=f>=0?e[f]:"/"}let l=qie(i,o),u=a&&a!=="/"&&a.endsWith("/"),d=(s||a===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(u||d)&&(l.pathname+="/"),l}var xc=t=>t.join("/").replace(/\/\/+/g,"/"),Xie=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Yie=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Zie=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Qie(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 MG=["POST","PUT","PATCH","DELETE"];new Set(MG);var Jie=["GET",...MG];new Set(Jie);var Fm=M.createContext(null);Fm.displayName="DataRouter";var CS=M.createContext(null);CS.displayName="DataRouterState";M.createContext(!1);var AG=M.createContext({isTransitioning:!1});AG.displayName="ViewTransition";var ese=M.createContext(new Map);ese.displayName="Fetchers";var tse=M.createContext(null);tse.displayName="Await";var vl=M.createContext(null);vl.displayName="Navigation";var ab=M.createContext(null);ab.displayName="Location";var Fo=M.createContext({outlet:null,matches:[],isDataRoute:!1});Fo.displayName="Route";var yR=M.createContext(null);yR.displayName="RouteError";function nse(t,{relative:e}={}){yr(ob(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=M.useContext(vl),{hash:i,pathname:s,search:a}=lb(t,{relative:e}),o=s;return n!=="/"&&(o=s==="/"?n:xc([n,s])),r.createHref({pathname:o,search:a,hash:i})}function ob(){return M.useContext(ab)!=null}function pd(){return yr(ob(),"useLocation() may be used only in the context of a <Router> component."),M.useContext(ab).location}var TG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function CG(t){M.useContext(vl).static||M.useLayoutEffect(t)}function _R(){let{isDataRoute:t}=M.useContext(Fo);return t?xse():rse()}function rse(){yr(ob(),"useNavigate() may be used only in the context of a <Router> component.");let t=M.useContext(Fm),{basename:e,navigator:n}=M.useContext(vl),{matches:r}=M.useContext(Fo),{pathname:i}=pd(),s=JSON.stringify(SG(r)),a=M.useRef(!1);return CG(()=>{a.current=!0}),M.useCallback((l,u={})=>{if(Oo(a.current,TG),!a.current)return;if(typeof l=="number"){n.go(l);return}let d=EG(l,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:xc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var ise=M.createContext(null);function sse(t){let e=M.useContext(Fo).outlet;return M.useMemo(()=>e&&M.createElement(ise.Provider,{value:t},e),[e,t])}function NG(){let{matches:t}=M.useContext(Fo),e=t[t.length-1];return e?e.params:{}}function lb(t,{relative:e}={}){let{matches:n}=M.useContext(Fo),{pathname:r}=pd(),i=JSON.stringify(SG(n));return M.useMemo(()=>EG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function ase(t,e){return kG(t,e)}function kG(t,e,n,r,i){yr(ob(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=M.useContext(vl),{matches:a}=M.useContext(Fo),o=a[a.length-1],l=o?o.params:{},u=o?o.pathname:"/",d=o?o.pathnameBase:"/",f=o&&o.route;{let E=f&&f.path||"";PG(u,!f||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let g=pd(),m;if(e){let E=typeof e=="string"?Um(e):e;yr(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),m=E}else m=g;let x=m.pathname||"/",y=x;if(d!=="/"){let E=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let v=yG(t,{pathname:y});Oo(f||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Oo(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 b=dse(v&&v.map(E=>Object.assign({},E,{params:Object.assign({},l,E.params),pathname:xc([d,s.encodeLocation?s.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:xc([d,s.encodeLocation?s.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),a,n,r,i);return e&&b?M.createElement(ab.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},b):b}function ose(){let t=gse(),e=Qie(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=M.createElement(M.Fragment,null,M.createElement("p",null,"💿 Hey developer 👋"),M.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",M.createElement("code",{style:s},"ErrorBoundary")," or"," ",M.createElement("code",{style:s},"errorElement")," prop on your route.")),M.createElement(M.Fragment,null,M.createElement("h2",null,"Unexpected Application Error!"),M.createElement("h3",{style:{fontStyle:"italic"}},e),n?M.createElement("pre",{style:i},n):null,a)}var lse=M.createElement(ose,null),cse=class extends M.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?M.createElement(Fo.Provider,{value:this.props.routeContext},M.createElement(yR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function use({routeContext:t,match:e,children:n}){let r=M.useContext(Fm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),M.createElement(Fo.Provider,{value:t},n)}function dse(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let s=t,a=n?.errors;if(a!=null){let d=s.findIndex(f=>f.route.id&&a?.[f.route.id]!==void 0);yr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),s=s.slice(0,Math.min(s.length,d+1))}let o=!1,l=-1;if(n)for(let d=0;d<s.length;d++){let f=s[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=d),f.route.id){let{loaderData:g,errors:m}=n,x=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||x){o=!0,l>=0?s=s.slice(0,l+1):s=[s[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return s.reduceRight((d,f,g)=>{let m,x=!1,y=null,v=null;n&&(m=a&&f.route.id?a[f.route.id]:void 0,y=f.route.errorElement||lse,o&&(l<0&&g===0?(PG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,v=null):l===g&&(x=!0,v=f.route.hydrateFallbackElement||null)));let b=e.concat(s.slice(0,g+1)),E=()=>{let S;return m?S=y:x?S=v:f.route.Component?S=M.createElement(f.route.Component,null):f.route.element?S=f.route.element:S=d,M.createElement(use,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?M.createElement(cse,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:E(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):E()},null)}function wR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function hse(t){let e=M.useContext(Fm);return yr(e,wR(t)),e}function fse(t){let e=M.useContext(CS);return yr(e,wR(t)),e}function pse(t){let e=M.useContext(Fo);return yr(e,wR(t)),e}function SR(t){let e=pse(t),n=e.matches[e.matches.length-1];return yr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function mse(){return SR("useRouteId")}function gse(){let t=M.useContext(yR),e=fse("useRouteError"),n=SR("useRouteError");return t!==void 0?t:e.errors?.[n]}function xse(){let{router:t}=hse("useNavigate"),e=SR("useNavigate"),n=M.useRef(!1);return CG(()=>{n.current=!0}),M.useCallback(async(i,s={})=>{Oo(n.current,TG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var A5={};function PG(t,e,n){!e&&!A5[t]&&(A5[t]=!0,Oo(!1,n))}M.memo(bse);function bse({routes:t,future:e,state:n,unstable_onError:r}){return kG(t,void 0,n,r,e)}function vse(t){return sse(t.context)}function Ia(t){yr(!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 yse({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1}){yr(!ob(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let a=t.replace(/^\/*/,"/"),o=M.useMemo(()=>({basename:a,navigator:i,static:s,future:{}}),[a,i,s]);typeof n=="string"&&(n=Um(n));let{pathname:l="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,m=M.useMemo(()=>{let x=Mc(l,a);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[a,l,u,d,f,g,r]);return Oo(m!=null,`<Router basename="${a}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:M.createElement(vl.Provider,{value:o},M.createElement(ab.Provider,{children:e,value:m}))}function _se({children:t,location:e}){return ase(p3(t),e)}function p3(t,e=[]){let n=[];return M.Children.forEach(t,(r,i)=>{if(!M.isValidElement(r))return;let s=[...e,i];if(r.type===M.Fragment){n.push.apply(n,p3(r.props.children,s));return}yr(r.type===Ia,`[${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>`),yr(!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=p3(r.props.children,s)),n.push(a)}),n}var $_="get",V_="application/x-www-form-urlencoded";function NS(t){return t!=null&&typeof t.tagName=="string"}function wse(t){return NS(t)&&t.tagName.toLowerCase()==="button"}function Sse(t){return NS(t)&&t.tagName.toLowerCase()==="form"}function Ese(t){return NS(t)&&t.tagName.toLowerCase()==="input"}function Mse(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Ase(t,e){return t.button===0&&(!e||e==="_self")&&!Mse(t)}var oy=null;function Tse(){if(oy===null)try{new FormData(document.createElement("form"),0),oy=!1}catch{oy=!0}return oy}var Cse=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function EA(t){return t!=null&&!Cse.has(t)?(Oo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${V_}"`),null):t}function Nse(t,e){let n,r,i,s,a;if(Sse(t)){let o=t.getAttribute("action");r=o?Mc(o,e):null,n=t.getAttribute("method")||$_,i=EA(t.getAttribute("enctype"))||V_,s=new FormData(t)}else if(wse(t)||Ese(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?Mc(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||$_,i=EA(t.getAttribute("formenctype"))||EA(o.getAttribute("enctype"))||V_,s=new FormData(o,t),!Tse()){let{name:u,type:d,value:f}=t;if(d==="image"){let g=u?`${u}.`:"";s.append(`${g}x`,"0"),s.append(`${g}y`,"0")}else u&&s.append(u,f)}}else{if(NS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=$_,r=null,i=V_,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 ER(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function kse(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&&Mc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Pse(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 Rse(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 Dse(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let a=await Pse(s,n);return a.links?a.links():[]}return[]}));return Ise(r.flat(1).filter(Rse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function T5(t,e,n,r,i,s){let a=(l,u)=>n[u]?l.route.id!==n[u].route.id:!0,o=(l,u)=>n[u].pathname!==l.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==l.params["*"];return s==="assets"?e.filter((l,u)=>a(l,u)||o(l,u)):s==="data"?e.filter((l,u)=>{let d=r.routes[l.route.id];if(!d||!d.hasLoader)return!1;if(a(l,u)||o(l,u))return!0;if(l.route.shouldRevalidate){let f=l.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Ose(t,e,{includeHydrateFallback:n}={}){return jse(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 jse(t){return[...new Set(t)]}function Lse(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Ise(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(Lse(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function RG(){let t=M.useContext(Fm);return ER(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Use(){let t=M.useContext(CS);return ER(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var MR=M.createContext(void 0);MR.displayName="FrameworkContext";function DG(){let t=M.useContext(MR);return ER(t,"You must render this element inside a <HydratedRouter> element"),t}function Fse(t,e){let n=M.useContext(MR),[r,i]=M.useState(!1),[s,a]=M.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=M.useRef(null);M.useEffect(()=>{if(t==="render"&&a(!0),t==="viewport"){let y=b=>{b.forEach(E=>{a(E.isIntersecting)})},v=new IntersectionObserver(y,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.disconnect()}}},[t]),M.useEffect(()=>{if(r){let y=setTimeout(()=>{a(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),a(!1)};return n?t!=="intent"?[s,g,{}]:[s,g,{onFocus:Qg(o,m),onBlur:Qg(l,x),onMouseEnter:Qg(u,m),onMouseLeave:Qg(d,x),onTouchStart:Qg(f,m)}]:[!1,g,{}]}function Qg(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function zse({page:t,...e}){let{router:n}=RG(),r=M.useMemo(()=>yG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?M.createElement(Hse,{page:t,matches:r,...e}):null}function Bse(t){let{manifest:e,routeModules:n}=DG(),[r,i]=M.useState([]);return M.useEffect(()=>{let s=!1;return Dse(t,e,n).then(a=>{s||i(a)}),()=>{s=!0}},[t,e,n]),r}function Hse({page:t,matches:e,...n}){let r=pd(),{manifest:i,routeModules:s}=DG(),{basename:a}=RG(),{loaderData:o,matches:l}=Use(),u=M.useMemo(()=>T5(t,e,l,i,r,"data"),[t,e,l,i,r]),d=M.useMemo(()=>T5(t,e,l,i,r,"assets"),[t,e,l,i,r]),f=M.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,y=!1;if(e.forEach(b=>{let E=i.routes[b.route.id];!E||!E.hasLoader||(!u.some(S=>S.route.id===b.route.id)&&b.route.id in o&&s[b.route.id]?.shouldRevalidate||E.hasClientLoader?y=!0:x.add(b.route.id))}),x.size===0)return[];let v=kse(t,a,"data");return y&&x.size>0&&v.searchParams.set("_routes",e.filter(b=>x.has(b.route.id)).map(b=>b.route.id).join(",")),[v.pathname+v.search]},[a,o,r,i,u,e,t,s]),g=M.useMemo(()=>Ose(d,i),[d,i]),m=Bse(d);return M.createElement(M.Fragment,null,f.map(x=>M.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>M.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),m.map(({key:x,link:y})=>M.createElement("link",{key:x,nonce:n.nonce,...y})))}function $se(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var OG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{OG&&(window.__reactRouterVersion="7.9.6")}catch{}function Vse({basename:t,children:e,window:n}){let r=M.useRef();r.current==null&&(r.current=Cie({window:n,v5Compat:!0}));let i=r.current,[s,a]=M.useState({action:i.action,location:i.location}),o=M.useCallback(l=>{M.startTransition(()=>a(l))},[a]);return M.useLayoutEffect(()=>i.listen(o),[i,o]),M.createElement(yse,{basename:t,children:e,location:s.location,navigationType:s.action,navigator:i})}var jG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kS=M.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:a,state:o,target:l,to:u,preventScrollReset:d,viewTransition:f,...g},m){let{basename:x}=M.useContext(vl),y=typeof u=="string"&&jG.test(u),v,b=!1;if(typeof u=="string"&&y&&(v=u,OG))try{let C=new URL(window.location.href),D=u.startsWith("//")?new URL(C.protocol+u):new URL(u),F=Mc(D.pathname,x);D.origin===C.origin&&F!=null?u=F+D.search+D.hash:b=!0}catch{Oo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=nse(u,{relative:i}),[S,A,T]=Fse(r,g),k=qse(u,{replace:a,state:o,target:l,preventScrollReset:d,relative:i,viewTransition:f});function N(C){e&&e(C),C.defaultPrevented||k(C)}let I=M.createElement("a",{...g,...T,href:v||E,onClick:b||s?e:N,ref:$se(m,A),target:l,"data-discover":!y&&n==="render"?"true":void 0});return S&&!y?M.createElement(M.Fragment,null,I,M.createElement(zse,{page:E})):I});kS.displayName="Link";var m3=M.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:a,viewTransition:o,children:l,...u},d){let f=lb(a,{relative:u.relative}),g=pd(),m=M.useContext(CS),{navigator:x,basename:y}=M.useContext(vl),v=m!=null&&Qse(f)&&o===!0,b=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,S=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(E=E.toLowerCase(),S=S?S.toLowerCase():null,b=b.toLowerCase()),S&&y&&(S=Mc(S,y)||S);const A=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let T=E===b||!i&&E.startsWith(b)&&E.charAt(A)==="/",k=S!=null&&(S===b||!i&&S.startsWith(b)&&S.charAt(b.length)==="/"),N={isActive:T,isPending:k,isTransitioning:v},I=T?e:void 0,C;typeof r=="function"?C=r(N):C=[r,T?"active":null,k?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let D=typeof s=="function"?s(N):s;return M.createElement(kS,{...u,"aria-current":I,className:C,ref:d,style:D,to:a,viewTransition:o},typeof l=="function"?l(N):l)});m3.displayName="NavLink";var Gse=M.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:a=$_,action:o,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:f,...g},m)=>{let x=Yse(),y=Zse(o,{relative:u}),v=a.toLowerCase()==="get"?"get":"post",b=typeof o=="string"&&jG.test(o),E=S=>{if(l&&l(S),S.defaultPrevented)return;S.preventDefault();let A=S.nativeEvent.submitter,T=A?.getAttribute("formmethod")||a;x(A||S.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:f})};return M.createElement("form",{ref:m,method:v,action:y,onSubmit:r?l:E,...g,"data-discover":!b&&t==="render"?"true":void 0})});Gse.displayName="Form";function Wse(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function LG(t){let e=M.useContext(Fm);return yr(e,Wse(t)),e}function qse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:a}={}){let o=_R(),l=pd(),u=lb(t,{relative:s});return M.useCallback(d=>{if(Ase(d,e)){d.preventDefault();let f=n!==void 0?n:o0(l)===o0(u);o(t,{replace:f,state:r,preventScrollReset:i,relative:s,viewTransition:a})}},[l,o,u,n,r,e,t,i,s,a])}var Kse=0,Xse=()=>`__${String(++Kse)}__`;function Yse(){let{router:t}=LG("useSubmit"),{basename:e}=M.useContext(vl),n=mse();return M.useCallback(async(r,i={})=>{let{action:s,method:a,encType:o,formData:l,body:u}=Nse(r,e);if(i.navigate===!1){let d=i.fetcherKey||Xse();await t.fetch(d,n,i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:u,formMethod:i.method||a,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||s,{preventScrollReset:i.preventScrollReset,formData:l,body:u,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 Zse(t,{relative:e}={}){let{basename:n}=M.useContext(vl),r=M.useContext(Fo);yr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...lb(t||".",{relative:e})},a=pd();if(t==null){s.search=a.search;let o=new URLSearchParams(s.search),l=o.getAll("index");if(l.some(d=>d==="")){o.delete("index"),l.filter(f=>f).forEach(f=>o.append("index",f));let d=o.toString();s.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:xc([n,s.pathname])),o0(s)}function Qse(t,{relative:e}={}){let n=M.useContext(AG);yr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=LG("useViewTransitionState"),i=lb(t,{relative:e});if(!n.isTransitioning)return!1;let s=Mc(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=Mc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return g1(i.pathname,a)!=null||g1(i.pathname,s)!=null}var uc=cG();const Jse=lo(uc);var zm=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(){}},eae={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},tae=class{#e=eae;#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)}},lh=new tae;function nae(t){setTimeout(t,0)}var Oh=typeof window>"u"||"Deno"in globalThis;function ws(){}function rae(t,e){return typeof t=="function"?t(e):t}function g3(t){return typeof t=="number"&&t>=0&&t!==1/0}function IG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Vu(t,e){return typeof t=="function"?t(e):t}function Ha(t,e){return typeof t=="function"?t(e):t}function C5(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=t;if(a){if(r){if(e.queryHash!==AR(a,e.options))return!1}else if(!l0(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 N5(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(jh(e.options.mutationKey)!==jh(s))return!1}else if(!l0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function AR(t,e){return(e?.queryKeyHashFn||jh)(t)}function jh(t){return JSON.stringify(t,(e,n)=>x3(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function l0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>l0(t[n],e[n])):!1}var iae=Object.prototype.hasOwnProperty;function UG(t,e){if(t===e)return t;const n=k5(t)&&k5(e);if(!n&&!(x3(t)&&x3(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 u=0;u<a;u++){const d=n?u:s[u],f=t[d],g=e[d];if(f===g){o[d]=f,(n?u<i:iae.call(t,d))&&l++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[d]=g;continue}const m=UG(f,g);o[d]=m,m===f&&l++}return i===a&&l===i?t:o}function x1(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 k5(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function x3(t){if(!P5(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!P5(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function P5(t){return Object.prototype.toString.call(t)==="[object Object]"}function sae(t){return new Promise(e=>{lh.setTimeout(e,t)})}function b3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?UG(t,e):e}function aae(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function oae(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var TR=Symbol();function FG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===TR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function zG(t,e){return typeof t=="function"?t(...e):!!t}var lae=class extends zm{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Oh&&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"}},CR=new lae;function v3(){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 cae=nae;function uae(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=cae;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 di=uae(),dae=class extends zm{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Oh&&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}},b1=new dae;function hae(t){return Math.min(1e3*2**t,3e4)}function BG(t){return(t??"online")==="online"?b1.isOnline():!0}var y3=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function HG(t){let e=!1,n=0,r;const i=v3(),s=()=>i.status!=="pending",a=y=>{if(!s()){const v=new y3(y);g(v),t.onCancel?.(v)}},o=()=>{e=!0},l=()=>{e=!1},u=()=>CR.isFocused()&&(t.networkMode==="always"||b1.isOnline())&&t.canRun(),d=()=>BG(t.networkMode)&&t.canRun(),f=y=>{s()||(r?.(),i.resolve(y))},g=y=>{s()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=v=>{(s()||u())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),x=()=>{if(s())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(f).catch(b=>{if(s())return;const E=t.retry??(Oh?0:3),S=t.retryDelay??hae,A=typeof S=="function"?S(n,b):S,T=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(e||!T){g(b);return}n++,t.onFail?.(n,b),sae(A).then(()=>u()?void 0:m()).then(()=>{e?g(b):x()})})};return{promise:i,status:()=>i.status,cancel:a,continue:()=>(r?.(),i),cancelRetry:o,continueRetry:l,canStart:d,start:()=>(d()?x():m().then(x),i)}}var $G=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),g3(this.gcTime)&&(this.#e=lh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Oh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(lh.clearTimeout(this.#e),this.#e=void 0)}},fae=class extends $G{#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=D5(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=D5(this.options);e.data!==void 0&&(this.setState(R5(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=b3(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(ws).catch(ws):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ha(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===TR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Vu(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:!IG(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=FG(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,u,this):o(u)},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=HG({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof y3&&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 y3){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,...VG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...R5(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),di.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function VG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:BG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function R5(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function D5(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 pae=class extends zm{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#o=v3(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#m;#h;#f;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),O5(this.#t,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return _3(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return _3(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 Ha(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),e._defaulted&&!x1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&j5(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Ha(this.options.enabled,this.#t)!==Ha(e.enabled,this.#t)||Vu(this.options.staleTime,this.#t)!==Vu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Ha(this.options.enabled,this.#t)!==Ha(e.enabled,this.#t)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return gae(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.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(ws)),e}#g(){this.#y();const t=Vu(this.options.staleTime,this.#t);if(Oh||this.#i.isStale||!g3(t))return;const n=IG(this.#i.dataUpdatedAt,t)+1;this.#c=lh.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(Oh||Ha(this.options.enabled,this.#t)===!1||!g3(this.#l)||this.#l===0)&&(this.#u=lh.setInterval(()=>{(this.options.refetchIntervalInBackground||CR.isFocused())&&this.#d()},this.#l))}#v(){this.#g(),this.#b(this.#x())}#y(){this.#c&&(lh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(lh.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:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const I=this.hasListeners(),C=!I&&O5(t,e),D=I&&j5(t,n,e,r);(C||D)&&(d={...d,...VG(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:y}=d;g=d.data;let v=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(I=i.data,v=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,I!==void 0&&(y="success",g=b3(i?.data,I,e),f=!0)}if(e.select&&g!==void 0&&!v)if(i&&g===s?.data&&e.select===this.#m)g=this.#h;else try{this.#m=e.select,g=e.select(g),g=b3(i?.data,g,e),this.#h=g,this.#s=null}catch(I){this.#s=I}this.#s&&(m=this.#s,g=this.#h,x=Date.now(),y="error");const b=d.fetchStatus==="fetching",E=y==="pending",S=y==="error",A=E&&b,T=g!==void 0,N={status:y,fetchStatus:d.fetchStatus,isPending:E,isSuccess:y==="success",isError:S,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:b,isRefetching:b&&!E,isLoadingError:S&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&T,isStale:NR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ha(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=F=>{N.status==="error"?F.reject(N.error):N.data!==void 0&&F.resolve(N.data)},C=()=>{const F=this.#o=N.promise=v3();I(F)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&I(D);break;case"fulfilled":(N.status==="error"||N.data!==D.value)&&C();break;case"rejected":(N.status!=="error"||N.error!==D.reason)&&C();break}}return N}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.#f=this.#t),x1(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.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#S(t){di.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function mae(t,e){return Ha(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function O5(t,e){return mae(t,e)||t.state.data!==void 0&&_3(t,e,e.refetchOnMount)}function _3(t,e,n){if(Ha(e.enabled,t)!==!1&&Vu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&NR(t,e)}return!1}function j5(t,e,n,r){return(t!==e||Ha(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&NR(t,n)}function NR(t,e){return Ha(e.enabled,t)!==!1&&t.isStaleByTime(Vu(e.staleTime,t))}function gae(t,e){return!x1(t.getCurrentResult(),e)}function L5(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 u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=FG(e.options,e.fetchOptions),m=async(x,y,v)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const k={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return f(k),k})(),S=await g(E),{maxPages:A}=e.options,T=v?oae:aae;return{pages:T(x.pages,S,A),pageParams:T(x.pageParams,y,A)}};if(i&&s.length){const x=i==="backward",y=x?xae:I5,v={pages:s,pageParams:a},b=y(r,v);o=await m(v,b,x)}else{const x=t??s.length;do{const y=l===0?a[0]??r.initialPageParam:I5(r,o);if(l>0&&y==null)break;o=await m(o,y),l++}while(l<x)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function I5(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 xae(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var bae=class extends $G{#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||GG(),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=HG({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),di.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function GG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var vae=class extends zm{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 bae({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=ly(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=ly(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=ly(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=ly(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){di.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=>N5(e,n))}findAll(t={}){return this.getAll().filter(e=>N5(t,e))}notify(t){di.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return di.batch(()=>Promise.all(t.map(e=>e.continue().catch(ws))))}};function ly(t){return t.options.scope?.id}var yae=class extends zm{#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),x1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&jh(n.mutationKey)!==jh(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??GG();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){di.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)})})}},_ae=class extends zm{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??AR(r,e);let s=this.get(i);return s||(s=new fae({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(){di.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=>C5(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>C5(t,n)):e}notify(t){di.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){di.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){di.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},wae=class{#e;#t;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#e=t.queryCache||new _ae,this.#t=t.mutationCache||new vae,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=CR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=b1.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(Vu(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=rae(e,s);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(t,e,n){return di.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;di.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return di.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=di.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(ws).catch(ws)}invalidateQueries(t,e={}){return di.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=di.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(ws)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(ws)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Vu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ws).catch(ws)}fetchInfiniteQuery(t){return t.behavior=L5(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ws).catch(ws)}ensureInfiniteQueryData(t){return t.behavior=L5(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return b1.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(jh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{l0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(jh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{l0(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=AR(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===TR&&(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()}},WG=M.createContext(void 0),En=t=>{const e=M.useContext(WG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Sae=({client:t,children:e})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),c.jsx(WG.Provider,{value:t,children:e})),qG=M.createContext(!1),Eae=()=>M.useContext(qG);qG.Provider;function Mae(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Aae=M.createContext(Mae()),Tae=()=>M.useContext(Aae),Cae=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Nae=t=>{M.useEffect(()=>{t.clearReset()},[t])},kae=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||zG(n,[t.error,r])),Pae=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))}},Rae=(t,e)=>t.isLoading&&t.isFetching&&!e,Dae=(t,e)=>t?.suspense&&e.isPending,U5=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Oae(t,e,n){const r=Eae(),i=Tae(),s=En(),a=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=r?"isRestoring":"optimistic",Pae(a),Cae(a,i),Nae(i);const o=!s.getQueryCache().get(a.queryHash),[l]=M.useState(()=>new e(s,a)),u=l.getOptimisticResult(a),d=!r&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(f=>{const g=d?l.subscribe(di.batchCalls(f)):ws;return l.updateResult(),g},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),M.useEffect(()=>{l.setOptions(a)},[a,l]),Dae(a,u))throw U5(a,l,i);if(kae({result:u,errorResetBoundary:i,throwOnError:a.throwOnError,query:s.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(a,u),a.experimental_prefetchInRender&&!Oh&&Rae(u,r)&&(o?U5(a,l,i):s.getQueryCache().get(a.queryHash)?.promise)?.catch(ws).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?u:l.trackResult(u)}function yt(t,e){return Oae(t,pae)}function _t(t,e){const n=En(),[r]=M.useState(()=>new yae(n,t));M.useEffect(()=>{r.setOptions(t)},[r,t]);const i=M.useSyncExternalStore(M.useCallback(a=>r.subscribe(di.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=M.useCallback((a,o)=>{r.mutate(a,o).catch(ws)},[r]);if(i.error&&zG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const jae=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Lae=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),F5=t=>{const e=Lae(t);return e.charAt(0).toUpperCase()+e.slice(1)},KG=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Iae=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Uae={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 Fae=M.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:a,...o},l)=>M.createElement("svg",{ref:l,...Uae,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:KG("lucide",i),...!s&&!Iae(o)&&{"aria-hidden":"true"},...o},[...a.map(([u,d])=>M.createElement(u,d)),...Array.isArray(s)?s:[s]]));const Xe=(t,e)=>{const n=M.forwardRef(({className:r,...i},s)=>M.createElement(Fae,{ref:s,iconNode:e,className:KG(`lucide-${jae(F5(t))}`,`lucide-${t}`,r),...i}));return n.displayName=F5(t),n};const zae=[["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"}]],PS=Xe("archive",zae);const Bae=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],c0=Xe("arrow-down",Bae);const Hae=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],w3=Xe("arrow-right",Hae);const $ae=[["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"}]],Vae=Xe("arrow-up-down",$ae);const Gae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],om=Xe("arrow-up",Gae);const Wae=[["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"}]],xh=Xe("bell",Wae);const qae=[["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"}]],Kae=Xe("bold",qae);const Xae=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],Yae=Xe("book",Xae);const Zae=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Qae=Xe("bookmark",Zae);const Jae=[["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"}]],lm=Xe("box",Jae);const eoe=[["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"}]],toe=Xe("cable",eoe);const noe=[["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"}]],roe=Xe("calendar-days",noe);const ioe=[["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"}]],Xr=Xe("calendar",ioe);const soe=[["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"}]],u0=Xe("camera",soe);const aoe=[["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"}]],ooe=Xe("chart-column",aoe);const loe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Lh=Xe("check",loe);const coe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],af=Xe("chevron-down",coe);const uoe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],of=Xe("chevron-right",uoe);const doe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ih=Xe("chevron-left",doe);const hoe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],RS=Xe("chevron-up",hoe);const foe=[["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"}]],jo=Xe("circle-alert",foe);const poe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],MA=Xe("circle-arrow-up",poe);const moe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],fs=Xe("circle-check-big",moe);const goe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],xoe=Xe("circle-dot",goe);const boe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],voe=Xe("circle-stop",boe);const yoe=[["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"}]],md=Xe("circle-x",yoe);const _oe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ni=Xe("clock",_oe);const woe=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],DS=Xe("cloud",woe);const Soe=[["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"}]],Eoe=Xe("code-xml",Soe);const Moe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],XG=Xe("code",Moe);const Aoe=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],Toe=Xe("coffee",Aoe);const Coe=[["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"}]],Noe=Xe("cog",Coe);const koe=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Poe=Xe("compass",koe);const Roe=[["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"}]],Uh=Xe("copy",Roe);const Doe=[["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"}]],v1=Xe("database",Doe);const Ooe=[["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"}]],S3=Xe("dollar-sign",Ooe);const joe=[["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"}]],_a=Xe("download",joe);const Loe=[["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"}]],kR=Xe("droplet",Loe);const Ioe=[["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"}]],YG=Xe("droplets",Ioe);const Uoe=[["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"}]],ZG=Xe("ellipsis-vertical",Uoe);const Foe=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],AA=Xe("equal",Foe);const zoe=[["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"}]],io=Xe("external-link",zoe);const Boe=[["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"}]],PR=Xe("eye-off",Boe);const Hoe=[["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"}]],d0=Xe("eye",Hoe);const $oe=[["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"}]],Voe=Xe("fan",$oe);const Goe=[["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"}]],Woe=Xe("file-box",Goe);const qoe=[["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"}]],z5=Xe("file-code",qoe);const Koe=[["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"}]],Xoe=Xe("file-exclamation-point",Koe);const Yoe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],y1=Xe("file-spreadsheet",Yoe);const Zoe=[["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"}]],Za=Xe("file-text",Zoe);const Qoe=[["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"}]],QG=Xe("file",Qoe);const Joe=[["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"}]],qp=Xe("film",Joe);const ele=[["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"}]],tle=Xe("flame",ele);const nle=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],bh=Xe("folder-kanban",nle);const rle=[["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"}]],ile=Xe("folder-open",rle);const sle=[["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"}]],JG=Xe("folder",sle);const ale=[["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"}]],RR=Xe("funnel",ale);const ole=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],DR=Xe("gauge",ole);const lle=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],cle=Xe("gift",lle);const ule=[["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"}]],Kp=Xe("git-compare",ule);const dle=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],B5=Xe("github",dle);const hle=[["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"}]],h0=Xe("globe",hle);const fle=[["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"}]],f0=Xe("grip-vertical",fle);const ple=[["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"}]],e7=Xe("hard-drive",ple);const mle=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],gle=Xe("heart",mle);const xle=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],E3=Xe("history",xle);const ble=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],vle=Xe("house",ble);const yle=[["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"}]],cb=Xe("image",yle);const _le=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],t7=Xe("info",_le);const wle=[["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"}]],Sle=Xe("italic",wle);const Ele=[["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"}]],zp=Xe("key",Ele);const Mle=[["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"}]],M3=Xe("keyboard",Mle);const Ale=[["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"}]],Fh=Xe("layers",Ale);const Tle=[["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"}]],n7=Xe("layout-grid",Tle);const Cle=[["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"}]],Nle=Xe("layout-list",Cle);const kle=[["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"}]],Ple=Xe("link-2-off",kle);const Rle=[["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"}]],A3=Xe("link-2",Rle);const Dle=[["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"}]],OS=Xe("link",Dle);const Ole=[["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"}]],r7=Xe("list-ordered",Ole);const jle=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Lle=Xe("list-todo",jle);const Ile=[["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"}]],OR=Xe("list",Ile);const Ule=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],At=Xe("loader-circle",Ule);const Fle=[["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"}]],H5=Xe("log-in",Fle);const zle=[["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"}]],Ble=Xe("log-out",zle);const Hle=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],$le=Xe("mail",Hle);const Vle=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],Gle=Xe("map",Vle);const Wle=[["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"}]],qle=Xe("maximize-2",Wle);const Kle=[["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"}]],Xle=Xe("maximize",Kle);const Yle=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Zle=Xe("menu",Yle);const Qle=[["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"}]],Jle=Xe("minimize-2",Qle);const ece=[["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"}]],tce=Xe("minimize",ece);const nce=[["path",{d:"M5 12h14",key:"1ays0h"}]],T3=Xe("minus",nce);const rce=[["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"}]],_1=Xe("moon",rce);const ice=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],sce=Xe("music",ice);const ace=[["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"}]],p0=Xe("package",ace);const oce=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],lce=Xe("palette",oce);const cce=[["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"}]],uce=Xe("pause",cce);const dce=[["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"}]],m0=Xe("pen-line",dce);const hce=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],jR=Xe("pen",hce);const fce=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],ed=Xe("pencil",fce);const pce=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],mce=Xe("phone",pce);const gce=[["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"}]],jS=Xe("play",gce);const xce=[["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"}]],Ux=Xe("plug",xce);const bce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pr=Xe("plus",bce);const vce=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],LR=Xe("power-off",vce);const yce=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],gd=Xe("power",yce);const _ce=[["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"}]],Lo=Xe("printer",_ce);const wce=[["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"}]],Sce=Xe("qr-code",wce);const Ece=[["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"}]],Xs=Xe("refresh-cw",Ece);const Mce=[["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"}]],Bm=Xe("rotate-ccw",Mce);const Ace=[["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"}]],Tce=Xe("ruler",Ace);const Cce=[["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"}]],Co=Xe("save",Cce);const Nce=[["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"}]],kce=Xe("scan-search",Nce);const Pce=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],td=Xe("search",Pce);const Rce=[["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"}]],IR=Xe("send",Rce);const Dce=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Oce=Xe("server",Dce);const jce=[["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"}]],LS=Xe("settings-2",jce);const Lce=[["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"}]],UR=Xe("settings",Lce);const Ice=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],Uce=Xe("shopping-cart",Ice);const Fce=[["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"}]],zce=Xe("signal",Fce);const Bce=[["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"}]],Hce=Xe("skip-back",Bce);const $ce=[["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"}]],w1=Xe("skip-forward",$ce);const Vce=[["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"}]],$5=Xe("sliders-vertical",Vce);const Gce=[["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"}]],g0=Xe("sparkles",Gce);const Wce=[["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"}]],zh=Xe("square-check-big",Wce);const qce=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],cm=Xe("square",qce);const Kce=[["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"}]],um=Xe("star",Kce);const Xce=[["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"}]],i7=Xe("sticky-note",Xce);const Yce=[["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"}]],V5=Xe("sun",Yce);const Zce=[["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"}]],x0=Xe("tag",Zce);const Qce=[["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"}]],s7=Xe("target",Qce);const Jce=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],a7=Xe("terminal",Jce);const eue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],tue=Xe("text-align-center",eue);const nue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],rue=Xe("text-align-end",nue);const iue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],sue=Xe("text-align-start",iue);const aue=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],vh=Xe("thermometer",aue);const oue=[["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"}]],Iu=Xe("timer",oue);const lue=[["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"}]],kn=Xe("trash-2",lue);const cue=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],o7=Xe("trending-down",cue);const uue=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],l7=Xe("trending-up",uue);const due=[["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"}]],Jr=Xe("triangle-alert",due);const hue=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],fue=Xe("underline",hue);const pue=[["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"}]],c7=Xe("unlink",pue);const mue=[["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"}]],ga=Xe("upload",mue);const gue=[["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"}]],C3=Xe("user",gue);const xue=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],bue=Xe("users",xue);const vue=[["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"}]],u7=Xe("video",vue);const yue=[["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"}]],FR=Xe("wifi-off",yue);const _ue=[["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"}]],d7=Xe("wifi",_ue);const wue=[["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"}]],Sue=Xe("wind",wue);const Eue=[["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"}]],nd=Xe("wrench",Eue);const Mue=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gt=Xe("x",Mue);const Aue=[["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"}]],Tue=Xe("zoom-in",Aue);const Cue=[["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"}]],dm=Xe("zap",Cue);const Nue=[["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"}]],kue=Xe("zoom-out",Nue),h7=M.createContext(void 0);function Pue({children:t}){const[e,n]=M.useState(()=>{const s=localStorage.getItem("theme");return s||"dark"});M.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 c.jsx(h7.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function ub(){const t=M.useContext(h7);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function kt({children:t,className:e="",onClick:n,onContextMenu:r}){return c.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function Ba({children:t,className:e=""}){return c.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Dt({children:t,className:e=""}){return c.jsx("div",{className:`p-6 ${e}`,children:t})}function Rue(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,s)=>({keys:[String(s+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,s)=>({keys:[String(s+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function G5({children:t}){return c.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 Due({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=sb(),i=Rue(n,e,r);return M.useEffect(()=>{const s=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:c.jsx(kt,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(M3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(s=>c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:s.category}),c.jsx("div",{className:"space-y-2",children:s.items.map(a=>c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[a.description,a.isExternal&&c.jsx(io,{className:"w-3 h-3 text-bambu-gray"})]}),c.jsx("div",{className:"flex gap-1",children:a.keys.map(o=>c.jsx(G5,{children:o},o))})]},a.description))})]},s.category))}),c.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:c.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",c.jsx(G5,{children:"Esc"})," or click outside to close"]})})]})})})}const er="/api/v1";async function tt(t,e={}){const n=await fetch(`${er}${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 Pe={getPrinters:()=>tt("/printers/"),getPrinter:t=>tt(`/printers/${t}`),createPrinter:t=>tt("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>tt(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>tt(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>tt(`/printers/${t}/status`),connectPrinter:t=>tt(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>tt(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>tt(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>tt(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>tt(`/printers/${t}/logging`),clearMQTTLogs:t=>tt(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>tt(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${er}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>tt(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>tt(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),tt(`/archives/?${i}`)},getArchive:t=>tt(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),tt(`/archives/search?${n}`)},rebuildSearchIndex:()=>tt("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>tt(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>tt(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>tt(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>tt("/archives/stats"),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),tt(`/archives/analysis/failures?${e}`)},compareArchives:t=>tt(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>tt(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${er}/archives/export?${e}`);if(!n.ok){const a=await n.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const a=r.match(/filename="?([^"]+)"?/);a&&(i=a[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${er}/archives/stats/export?${e}`);if(!n.ok){const a=await n.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const a=r.match(/filename="?([^"]+)"?/);a&&(i=a[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>tt(`/archives/${t}/duplicates`),backfillContentHashes:()=>tt("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${er}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${er}/archives/${t}/download`,getArchiveGcode:t=>`${er}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${er}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>tt(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>tt(`/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(`${er}/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)=>`${er}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${er}/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)=>tt(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${er}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${er}/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(`${er}/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=>tt(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${er}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>tt(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>tt(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>tt(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${er}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${er}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>tt(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${er}/archives/upload?printer_id=${e}`:`${er}/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?`${er}/archives/upload-bulk?printer_id=${e}`:`${er}/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:()=>tt("/settings/"),updateSettings:t=>tt("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>tt("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)));const n=`${er}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n),i=r.headers.get("Content-Disposition");let s="bambuddy-backup.json";if(i){const o=i.match(/filename=([^;]+)/);o&&(s=o[1].trim())}return{blob:await r.blob(),filename:s}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${er}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>tt("/settings/check-ffmpeg"),getCloudStatus:()=>tt("/cloud/status"),cloudLogin:(t,e,n="global")=>tt("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>tt("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>tt("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>tt("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>tt(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>tt(`/cloud/settings/${t}`),createCloudSetting:t=>tt("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>tt(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>tt(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>tt("/cloud/devices"),getCloudFields:t=>tt(`/cloud/fields/${t}`),getAllCloudFields:()=>tt("/cloud/fields"),getSmartPlugs:()=>tt("/smart-plugs/"),getSmartPlug:t=>tt(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>tt(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>tt("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>tt(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>tt(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>tt(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>tt(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>tt("/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),tt(`/queue/?${n}`)},getQueueItem:t=>tt(`/queue/${t}`),addToQueue:t=>tt("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>tt(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>tt(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>tt("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>tt(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>tt(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>tt(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>tt(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>tt(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>tt(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>tt(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>tt(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>tt(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>tt(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>tt(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>tt(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>tt(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>tt("/filaments/"),getFilament:t=>tt(`/filaments/${t}`),getFilamentsByType:t=>tt(`/filaments/by-type/${t}`),getNotificationProviders:()=>tt("/notifications/"),getNotificationProvider:t=>tt(`/notifications/${t}`),createNotificationProvider:t=>tt("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>tt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>tt(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>tt(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>tt("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>tt("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>tt("/notification-templates"),getNotificationTemplate:t=>tt(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>tt(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>tt(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>tt("/notification-templates/variables"),previewTemplate:t=>tt("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),tt(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>tt(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>tt(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>tt("/spoolman/status"),connectSpoolman:()=>tt("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>tt("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>tt(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>tt("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>tt("/spoolman/spools"),getSpoolmanFilaments:()=>tt("/spoolman/filaments"),getVersion:()=>tt("/updates/version"),checkForUpdates:()=>tt("/updates/check"),applyUpdate:()=>tt("/updates/apply",{method:"POST"}),getUpdateStatus:()=>tt("/updates/status"),getMaintenanceTypes:()=>tt("/maintenance/types"),createMaintenanceType:t=>tt("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>tt(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>tt(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>tt("/maintenance/overview"),getPrinterMaintenance:t=>tt(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>tt(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>tt(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>tt(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>tt("/maintenance/summary"),setPrinterHours:(t,e)=>tt(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),getCameraStreamUrl:(t,e=10)=>`${er}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${er}/printers/${t}/camera/snapshot`,testCameraConnection:t=>tt(`/printers/${t}/camera/test`),getExternalLinks:()=>tt("/external-links/"),getExternalLink:t=>tt(`/external-links/${t}`),createExternalLink:t=>tt("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>tt(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>tt(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>tt("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${er}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>tt(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${er}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),tt(`/projects/?${e}`)},getProject:t=>tt(`/projects/${t}`),createProject:t=>tt("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>tt(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>tt(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>tt(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>tt(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>tt(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>tt(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),getAPIKeys:()=>tt("/api-keys/"),createAPIKey:t=>tt("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>tt(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>tt(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>tt(`/ams-history/${t}/${e}?hours=${n}`)},f7=[{name:"globe",icon:h0},{name:"link",icon:OS},{name:"external-link",icon:io},{name:"book",icon:Yae},{name:"file-text",icon:Za},{name:"home",icon:vle},{name:"star",icon:um},{name:"heart",icon:gle},{name:"bookmark",icon:Qae},{name:"shopping-cart",icon:Uce},{name:"music",icon:sce},{name:"video",icon:u7},{name:"image",icon:cb},{name:"camera",icon:u0},{name:"map",icon:Gle},{name:"compass",icon:Poe},{name:"coffee",icon:Toe},{name:"gift",icon:cle},{name:"wrench",icon:nd},{name:"zap",icon:dm},{name:"cloud",icon:DS},{name:"database",icon:v1},{name:"folder",icon:JG},{name:"mail",icon:$le},{name:"phone",icon:mce},{name:"user",icon:C3},{name:"users",icon:bue},{name:"server",icon:Oce},{name:"terminal",icon:a7},{name:"code",icon:XG}];function IS(t){return f7.find(n=>n.name===t)?.icon||OS}function Oue({value:t,onChange:e}){const[n,r]=M.useState(!1),i=IS(t);return c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[c.jsx(i,{className:"w-5 h-5"}),c.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),c.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:c.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:f7.map(({name:s,icon:a})=>c.jsx("button",{type:"button",onClick:()=>{e(s),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===s?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:s,children:c.jsx(a,{className:"w-5 h-5"})},s))})})]})]})}const W5=768;function p7(){const[t,e]=M.useState(()=>typeof window<"u"?window.innerWidth<W5:!1);return M.useEffect(()=>{const n=window.matchMedia(`(max-width: ${W5-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const b0=[{id:"printers",to:"/",icon:Lo,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:PS,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Xr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:ooe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:DS,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:nd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:bh,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:UR,labelKey:"nav.settings"}];function jue(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return b0.map(e=>e.id)}return b0.map(e=>e.id)}function Lue(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function TA(t){return t.startsWith("ext-")}function m7(){return localStorage.getItem("defaultView")||"/"}function Iue(t){localStorage.setItem("defaultView",t)}function Uue(){const t=_R(),e=pd(),{theme:n,toggleTheme:r}=ub(),{t:i}=sb(),s=p7(),[a,o]=M.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[l,u]=M.useState(!1),[d,f]=M.useState(!1),[g,m]=M.useState(jue),[x,y]=M.useState(null),[v,b]=M.useState(null),E=M.useRef(!1),[S,A]=M.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=yt({queryKey:["version"],queryFn:Pe.getVersion,staleTime:1/0}),{data:k}=yt({queryKey:["settings"],queryFn:Pe.getSettings,staleTime:300*1e3}),{data:N}=yt({queryKey:["updateCheck"],queryFn:Pe.checkForUpdates,enabled:k?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:I}=yt({queryKey:["external-links"],queryFn:Pe.getExternalLinks}),C=new Map(b0.map(Z=>[Z.id,Z])),D=new Map((I||[]).map(Z=>[`ext-${Z.id}`,Z])),F=(()=>{const Z=[],U=new Set;for(const z of g)(C.has(z)||D.has(z))&&(Z.push(z),U.add(z));for(const z of b0)U.has(z.id)||(Z.push(z.id),U.add(z.id));for(const z of I||[]){const ee=`ext-${z.id}`;U.has(ee)||(Z.push(ee),U.add(ee))}return Z})(),j=(Z,U)=>{y(U),Z.dataTransfer.effectAllowed="move",Z.dataTransfer.setData("text/plain",U)},q=(Z,U)=>{Z.preventDefault(),Z.dataTransfer.dropEffect="move",b(U)},R=()=>{b(null)},W=(Z,U)=>{if(Z.preventDefault(),x===null||x===U){y(null),b(null);return}const z=[...F],ee=z.indexOf(x),ae=z.indexOf(U);if(ee===-1||ae===-1){y(null),b(null);return}z.splice(ee,1),z.splice(ae,0,x),m(z),Lue(z),y(null),b(null)},K=()=>{y(null),b(null)},V=N?.update_available&&N.latest_version&&N.latest_version!==S,te=()=>{N?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",N.latest_version),A(N.latest_version))};M.useEffect(()=>{if(!E.current&&e.pathname==="/"){const Z=m7();Z!=="/"&&(E.current=!0,t(Z,{replace:!0}))}},[e.pathname,t]),M.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(a))},[a]),M.useEffect(()=>{s&&u(!1)},[e.pathname,s]);const Y=M.useCallback(Z=>{const U=Z.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!Z.metaKey&&!Z.ctrlKey&&!Z.altKey){const z=parseInt(Z.key);if(z>=1&&z<=F.length&&z<=9){const ee=F[z-1];if(Z.preventDefault(),TA(ee)){const ae=ee.replace("ext-","");t(`/external/${ae}`)}else{const ae=C.get(ee);ae&&t(ae.to)}return}switch(Z.key){case"?":Z.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,F,C]);return M.useEffect(()=>(document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)),[Y]),c.jsxs("div",{className:"flex min-h-screen",children:[s&&c.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[c.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:c.jsx(Zle,{className:"w-6 h-6 text-white"})}),c.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),s&&l&&c.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),c.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${s?`fixed inset-y-0 left-0 z-50 w-72 transform ${l?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${a?"w-64":"w-16"}`}`,children:[c.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||a?"p-4":"p-2"}`,children:c.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:s||a?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),c.jsx("nav",{className:"flex-1 p-2",children:c.jsx("ul",{className:"space-y-2",children:F.map(Z=>{if(TA(Z)){const z=D.get(Z);if(!z)return null;const ee=z.custom_icon?null:IS(z.icon);return c.jsx("li",{draggable:!0,onDragStart:ae=>j(ae,Z),onDragOver:ae=>q(ae,Z),onDragLeave:R,onDrop:ae=>W(ae,Z),onDragEnd:K,className:`relative ${x===Z?"opacity-50":""} ${v===Z&&x!==Z?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:c.jsxs(m3,{to:`/external/${z.id}`,className:({isActive:ae})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ae?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!a?z.name:void 0,children:[a&&!s&&c.jsx(f0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),z.custom_icon?c.jsx("img",{src:`/api/v1/external-links/${z.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):ee&&c.jsx(ee,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&c.jsx("span",{children:z.name})]})},Z)}else{const z=C.get(Z);if(!z)return null;const{to:ee,icon:ae,labelKey:fe}=z;return c.jsx("li",{draggable:!0,onDragStart:de=>j(de,Z),onDragOver:de=>q(de,Z),onDragLeave:R,onDrop:de=>W(de,Z),onDragEnd:K,className:`relative ${x===Z?"opacity-50":""} ${v===Z&&x!==Z?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:c.jsxs(m3,{to:ee,className:({isActive:de})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${de?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!a?i(fe):void 0,children:[a&&!s&&c.jsx(f0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),c.jsx(ae,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&c.jsx("span",{children:i(fe)})]})},Z)}})})}),!s&&c.jsx("button",{onClick:()=>o(!a),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(a?"nav.collapseSidebar":"nav.expandSidebar"),children:a?c.jsx(Ih,{className:"w-5 h-5"}):c.jsx(of,{className:"w-5 h-5"})}),c.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||a?c.jsxs("div",{className:"flex items-center justify-between px-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),N?.update_available&&c.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:N.latest_version}),children:[c.jsx(MA,{className:"w-4 h-4"}),c.jsx("span",{children:i("nav.update")})]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:c.jsx(B5,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:c.jsx(M3,{className:"w-5 h-5"})}),c.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"?c.jsx(V5,{className:"w-5 h-5"}):c.jsx(_1,{className:"w-5 h-5"})})]})]}):c.jsxs("div",{className:"flex flex-col items-center gap-1",children:[N?.update_available&&c.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:N.latest_version}),children:c.jsx(MA,{className:"w-5 h-5"})}),c.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:c.jsx(B5,{className:"w-5 h-5"})}),c.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:c.jsx(M3,{className:"w-5 h-5"})}),c.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"?c.jsx(V5,{className:"w-5 h-5"}):c.jsx(_1,{className:"w-5 h-5"})})]})})]}),c.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":a?"ml-64":"ml-16"}`,children:[V&&c.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(MA,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{children:i("nav.updateAvailableBanner",{version:N?.latest_version,defaultValue:`Version ${N?.latest_version} is available!`})}),c.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),c.jsx("button",{onClick:te,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:c.jsx(Gt,{className:"w-4 h-4"})})]}),c.jsx(vse,{})]}),d&&c.jsx(Due,{onClose:()=>f(!1),sidebarItems:F.map(Z=>{if(TA(Z)){const U=D.get(Z);return U?{type:"external",label:U.name}:null}else{const U=C.get(Z);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)})]})}function Ie({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 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return c.jsx("button",{className:`${s} ${a[t]} ${o[e]} ${n}`,...i,children:r})}function Yr({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:s,onCancel:a}){M.useEffect(()=>{const u=d=>{d.key==="Escape"&&a()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[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 c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a,children:c.jsx(kt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-start gap-4",children:[c.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:c.jsx(Jr,{className:"w-6 h-6"})}),c.jsxs("div",{className:"flex-1",children:[c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),c.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),c.jsxs("div",{className:"flex gap-3 mt-6",children:[c.jsx(Ie,{variant:"secondary",onClick:a,className:"flex-1",children:r}),c.jsx(Ie,{onClick:s,className:`flex-1 ${l.button}`,children:n})]})]})})})}const g7=M.createContext(void 0);function ii(){const t=M.useContext(g7);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Fue={success:c.jsx(fs,{className:"w-5 h-5 text-green-400"}),error:c.jsx(md,{className:"w-5 h-5 text-red-400"}),warning:c.jsx(jo,{className:"w-5 h-5 text-yellow-400"}),info:c.jsx(t7,{className:"w-5 h-5 text-blue-400"})},zue={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 Bue({children:t}){const[e,n]=M.useState([]),r=M.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(u=>u.id!==o))},3e3)},[]),i=M.useCallback(s=>{n(a=>a.filter(o=>o.id!==s))},[]);return c.jsxs(g7.Provider,{value:{showToast:r},children:[t,c.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>c.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${zue[s.type]}`,children:[Fue[s.type],c.jsx("span",{className:"text-white text-sm",children:s.message}),c.jsx("button",{onClick:()=>i(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-4 h-4"})})]},s.id))})]})}function Hue(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 q5(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 $ue(t,e){if(e)return JG;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Woe;case"gcode":return Za;case"mp4":case"avi":return qp;case"png":case"jpg":case"jpeg":return cb;default:return QG}}function Vue({printerId:t,printerName:e,onClose:n}){const{showToast:r}=ii(),i=En(),[s,a]=M.useState("/"),[o,l]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(null);M.useEffect(()=>{const N=I=>{I.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const{data:m,isLoading:x,refetch:y}=yt({queryKey:["printerFiles",t,s],queryFn:()=>Pe.getPrinterFiles(t,s)}),{data:v}=yt({queryKey:["printerStorage",t],queryFn:()=>Pe.getPrinterStorage(t),staleTime:3e4}),b=_t({mutationFn:N=>Pe.deletePrinterFile(t,N),onSuccess:(N,I)=>{r(`Deleted: ${I.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:N=>{r(`Delete failed: ${N.message}`,"error")}}),E=N=>{a(N),l(null)},S=()=>{if(s==="/")return;const N=s.split("/").filter(Boolean);N.pop(),a(N.length?"/"+N.join("/"):"/"),l(null)},A=N=>{window.open(Pe.getPrinterFileDownloadUrl(t,N),"_blank")},T=N=>{g(N)},k=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[c.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:N=>N.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(e7,{className:"w-5 h-5 text-bambu-green"}),c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),c.jsxs("div",{className:"flex items-center gap-4",children:[v&&(v.used_bytes!=null||v.free_bytes!=null)&&c.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[v.used_bytes!=null&&c.jsxs("span",{children:["Used: ",q5(v.used_bytes)]}),v.used_bytes!=null&&v.free_bytes!=null&&c.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),v.free_bytes!=null&&c.jsxs("span",{children:["Free: ",q5(v.free_bytes)]})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]})]}),c.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[k.map(N=>c.jsx("button",{onClick:()=>{E(N.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${s===N.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:N.label},N.path)),c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"relative",children:[c.jsx(td,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:N=>d(N.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:x,children:c.jsx(Xs,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),c.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[c.jsx("button",{onClick:S,disabled:s==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:c.jsx(Ih,{className:"w-4 h-4"})}),c.jsx("span",{className:"text-bambu-gray font-mono",children:s})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?c.jsx("div",{className:"space-y-1",children:[...m.files].filter(N=>!u||N.name.toLowerCase().includes(u.toLowerCase())).sort((N,I)=>N.is_directory&&!I.is_directory?-1:!N.is_directory&&I.is_directory?1:N.name.localeCompare(I.name)).map(N=>{const I=$ue(N.name,N.is_directory),C=o===N.path;return c.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${C?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{N.is_directory?E(N.path):l(C?null:N.path)},children:[c.jsx(I,{className:`w-5 h-5 flex-shrink-0 ${N.is_directory?"text-bambu-green":"text-bambu-gray"}`}),c.jsx("span",{className:"flex-1 text-white truncate",children:N.name}),!N.is_directory&&c.jsx("span",{className:"text-sm text-bambu-gray",children:Hue(N.size)}),N.is_directory&&c.jsx(Ih,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[c.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${m?.files?.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[c.jsx(_a,{className:"w-4 h-4"}),"Download"]}),c.jsxs(Ie,{variant:"secondary",disabled:!o||b.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[b.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&c.jsx(Yr,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{b.mutate(f),g(null)},onCancel:()=>g(null)})]})}function Gue({printerId:t,printerName:e,onClose:n}){const r=En(),[i,s]=M.useState(!0),[a,o]=M.useState(new Set),[l,u]=M.useState(""),[d,f]=M.useState("all"),g=M.useRef(null),{data:m,isLoading:x,refetch:y}=yt({queryKey:["mqtt-logs",t],queryFn:()=>Pe.getMQTTLogs(t),refetchInterval:1e3}),v=_t({mutationFn:()=>Pe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=_t({mutationFn:()=>Pe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=_t({mutationFn:()=>Pe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});M.useEffect(()=>{const C=D=>{D.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]),M.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[m?.logs,i]);const S=C=>{o(D=>{const F=new Set(D);return F.has(C)?F.delete(C):F.add(C),F})},A=C=>new Date(C).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(C,D)=>{if(C==null)return"<empty>";const F=typeof C=="string"?JSON.parse(C):C,j=JSON.stringify(F,null,D?2:0);return!D&&j.length>100?j.substring(0,100)+"...":j},k=m?.logging_enabled??!1,N=m?.logs??[],I=M.useMemo(()=>N.filter(C=>{if(d!=="all"&&C.direction!==d)return!1;if(l.trim()){const D=l.toLowerCase(),F=C.topic.toLowerCase().includes(D),q=JSON.stringify(C.payload).toLowerCase().includes(D);return F||q}return!0}),[N,l,d]);return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[k?c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[c.jsx(cm,{className:"w-4 h-4"}),"Stop"]}):c.jsxs(Ie,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[c.jsx(jS,{className:"w-4 h-4"}),"Start Logging"]}),c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||N.length===0,children:[c.jsx(kn,{className:"w-4 h-4"}),"Clear"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:c.jsx(Xs,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),c.jsx("div",{className:"flex-1"}),c.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i,onChange:C=>s(C.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),c.jsxs("span",{className:"text-sm text-bambu-gray",children:[I.length,"/",N.length]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(td,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:l,onChange:C=>u(C.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&&c.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),c.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[c.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),c.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[c.jsx(c0,{className:"w-3 h-3"}),"In"]}),c.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[c.jsx(om,{className:"w-3 h-3"}),"Out"]})]})]})]}),c.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:N.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[c.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!k&&c.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):I.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[c.jsx("p",{className:"mb-2",children:"No messages match your filter"}),c.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):c.jsx("div",{className:"space-y-1",children:I.map((C,D)=>{const F=a.has(D),j=C.direction==="in";return c.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>S(D),children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx("span",{className:"text-bambu-gray shrink-0",children:A(C.timestamp)}),c.jsx("span",{className:`shrink-0 ${j?"text-blue-400":"text-green-400"}`,title:j?"Incoming":"Outgoing",children:j?c.jsx(c0,{className:"w-3 h-3"}):c.jsx(om,{className:"w-3 h-3"})}),c.jsx("span",{className:"text-purple-400 shrink-0",children:C.topic})]}),F?c.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(C.payload,!0)}):c.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(C.payload,!1)})]},D)})})}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[c.jsx("div",{className:"text-sm text-bambu-gray",children:k?c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):c.jsx("span",{children:"Logging stopped"})}),c.jsx(Ie,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const Wue={"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 que(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Jr};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Jr};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:jo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:t7}}}function x7(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(),u=(e&255).toString(16).padStart(2,"0").toUpperCase();return`${n}${r}_${i}${s}_${a}${o}_${l}${u}`}function Kue(t,e,n){const r=x7(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function Xue({printerName:t,errors:e,onClose:n}){return console.log("HMSErrorModal errors:",JSON.stringify(e,null,2)),M.useEffect(()=>{const r=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n]),c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Jr,{className:"w-5 h-5 text-orange-400"}),c.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),c.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?c.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[c.jsx(jo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{children:"No HMS errors"})]}):c.jsx("div",{className:"space-y-3",children:e.map((r,i)=>{const{label:s,color:a,bgColor:o,Icon:l}=que(r.severity),u=parseInt(r.code.replace("0x",""),16)||0,d=x7(r.attr,u),f=Wue[d]||"Unknown error. Click the link below for details.",g=Kue(r.attr,u,t),m=`HMS_${d.replace(/_/g,"-")}`;return c.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(l,{className:`w-5 h-5 ${a} flex-shrink-0 mt-0.5`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("span",{className:`font-mono text-sm ${a}`,children:m}),c.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${a}`,children:s})]}),c.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:f}),c.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[c.jsx(io,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${r.code}-${i}`)})})}),c.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:c.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 Yue(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 Zue({printerId:t}){const{data:e}=yt({queryKey:["queue",t,"pending"],queryFn:()=>Pe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:c.jsx(kS,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[c.jsx(Xr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),c.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[c.jsx(ni,{className:"w-3 h-3"}),Yue(n?.scheduled_time||null)]}),r>1&&c.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),c.jsx(of,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function b7(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=b7(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Sn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=b7(t))&&(r&&(r+=" "),r+=e);return r}var Que=["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 zR(t){if(typeof t!="string")return!1;var e=Que;return e.includes(t)}var Jue=["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"],ede=new Set(Jue);function v7(t){return typeof t!="string"?!1:ede.has(t)}function y7(t){return typeof t=="string"&&t.startsWith("data-")}function Ts(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(v7(n)||y7(n))&&(e[n]=t[n]);return e}function Bh(t){if(t==null)return null;if(M.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ts(e)}return typeof t=="object"&&!Array.isArray(t)?Ts(t):null}function es(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(v7(n)||y7(n)||zR(n))&&(e[n]=t[n]);return e}function tde(t){return t==null?null:M.isValidElement(t)?es(t.props):typeof t=="object"&&!Array.isArray(t)?es(t):null}var nde=["children","width","height","viewBox","className","style","title","desc"];function N3(){return N3=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},N3.apply(null,arguments)}function rde(t,e){if(t==null)return{};var n,r,i=ide(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 ide(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 BR=M.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:a,style:o,title:l,desc:u}=t,d=rde(t,nde),f=s||{width:r,height:i,x:0,y:0},g=Sn("recharts-surface",a);return M.createElement("svg",N3({},es(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),M.createElement("title",null,l),M.createElement("desc",null,u),n)}),sde=["children","className"];function k3(){return k3=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},k3.apply(null,arguments)}function ade(t,e){if(t==null)return{};var n,r,i=ode(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 ode(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var _r=M.forwardRef((t,e)=>{var{children:n,className:r}=t,i=ade(t,sde),s=Sn("recharts-layer",r);return M.createElement("g",k3({className:s},es(i),{ref:e}),n)}),_7=M.createContext(null),lde=()=>M.useContext(_7);function ir(t){return function(){return t}}const w7=Math.cos,S1=Math.sin,zo=Math.sqrt,E1=Math.PI,US=2*E1,P3=Math.PI,R3=2*P3,Qd=1e-6,cde=R3-Qd;function S7(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function ude(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return S7;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 dde{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?S7:ude(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,u=i-n,d=a-e,f=o-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>Qd)if(!(Math.abs(f*l-u*d)>Qd)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-a,x=i-o,y=l*l+u*u,v=m*m+x*x,b=Math.sqrt(y),E=Math.sqrt(g),S=s*Math.tan((P3-Math.acos((y+g-v)/(2*b*E)))/2),A=S/E,T=S/b;Math.abs(A-1)>Qd&&this._append`L${e+A*d},${n+A*f}`,this._append`A${s},${s},0,0,${+(f*m>d*x)},${this._x1=e+T*l},${this._y1=n+T*u}`}}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),u=e+o,d=n+l,f=1^a,g=a?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Qd||Math.abs(this._y1-d)>Qd)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%R3+R3),g>cde?this._append`A${r},${r},0,1,${f},${e-o},${n-l}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>Qd&&this._append`A${r},${r},0,${+(g>=P3)},${f},${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 HR(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 dde(e)}function $R(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function E7(t){this._context=t}E7.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 FS(t){return new E7(t)}function M7(t){return t[0]}function A7(t){return t[1]}function T7(t,e){var n=ir(!0),r=null,i=FS,s=null,a=HR(o);t=typeof t=="function"?t:t===void 0?M7:ir(t),e=typeof e=="function"?e:e===void 0?A7:ir(e);function o(l){var u,d=(l=$R(l)).length,f,g=!1,m;for(r==null&&(s=i(m=a())),u=0;u<=d;++u)!(u<d&&n(f=l[u],u,l))===g&&((g=!g)?s.lineStart():s.lineEnd()),g&&s.point(+t(f,u,l),+e(f,u,l));if(m)return s=null,m+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:ir(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:ir(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:ir(!!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 cy(t,e,n){var r=null,i=ir(!0),s=null,a=FS,o=null,l=HR(u);t=typeof t=="function"?t:t===void 0?M7:ir(+t),e=typeof e=="function"?e:ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?A7:ir(+n);function u(f){var g,m,x,y=(f=$R(f)).length,v,b=!1,E,S=new Array(y),A=new Array(y);for(s==null&&(o=a(E=l())),g=0;g<=y;++g){if(!(g<y&&i(v=f[g],g,f))===b)if(b=!b)m=g,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),x=g-1;x>=m;--x)o.point(S[x],A[x]);o.lineEnd(),o.areaEnd()}b&&(S[g]=+t(v,g,f),A[g]=+e(v,g,f),o.point(r?+r(v,g,f):S[g],n?+n(v,g,f):A[g]))}if(E)return o=null,E+""||null}function d(){return T7().defined(i).curve(a).context(s)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:ir(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:ir(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:ir(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:ir(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:ir(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:ir(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:ir(!!f),u):i},u.curve=function(f){return arguments.length?(a=f,s!=null&&(o=a(s)),u):a},u.context=function(f){return arguments.length?(f==null?s=o=null:o=a(s=f),u):s},u}class C7{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 hde(t){return new C7(t,!0)}function fde(t){return new C7(t,!1)}const VR={draw(t,e){const n=zo(e/E1);t.moveTo(n,0),t.arc(0,0,n,0,US)}},pde={draw(t,e){const n=zo(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()}},N7=zo(1/3),mde=N7*2,gde={draw(t,e){const n=zo(e/mde),r=n*N7;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},xde={draw(t,e){const n=zo(e),r=-n/2;t.rect(r,r,n,n)}},bde=.8908130915292852,k7=S1(E1/10)/S1(7*E1/10),vde=S1(US/10)*k7,yde=-w7(US/10)*k7,_de={draw(t,e){const n=zo(e*bde),r=vde*n,i=yde*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const a=US*s/5,o=w7(a),l=S1(a);t.lineTo(l*n,-o*n),t.lineTo(o*r-l*i,l*r+o*i)}t.closePath()}},CA=zo(3),wde={draw(t,e){const n=-zo(e/(CA*3));t.moveTo(0,n*2),t.lineTo(-CA*n,-n),t.lineTo(CA*n,-n),t.closePath()}},Ra=-.5,Da=zo(3)/2,D3=1/zo(12),Sde=(D3/2+1)*3,Ede={draw(t,e){const n=zo(e/Sde),r=n/2,i=n*D3,s=r,a=n*D3+n,o=-s,l=a;t.moveTo(r,i),t.lineTo(s,a),t.lineTo(o,l),t.lineTo(Ra*r-Da*i,Da*r+Ra*i),t.lineTo(Ra*s-Da*a,Da*s+Ra*a),t.lineTo(Ra*o-Da*l,Da*o+Ra*l),t.lineTo(Ra*r+Da*i,Ra*i-Da*r),t.lineTo(Ra*s+Da*a,Ra*a-Da*s),t.lineTo(Ra*o+Da*l,Ra*l-Da*o),t.closePath()}};function Mde(t,e){let n=null,r=HR(i);t=typeof t=="function"?t:ir(t||VR),e=typeof e=="function"?e:ir(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:ir(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:ir(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function M1(){}function A1(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 P7(t){this._context=t}P7.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:A1(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:A1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Ade(t){return new P7(t)}function R7(t){this._context=t}R7.prototype={areaStart:M1,areaEnd:M1,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:A1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Tde(t){return new R7(t)}function D7(t){this._context=t}D7.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:A1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Cde(t){return new D7(t)}function O7(t){this._context=t}O7.prototype={areaStart:M1,areaEnd:M1,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 Nde(t){return new O7(t)}function K5(t){return t<0?-1:1}function X5(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(K5(s)+K5(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function Y5(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function NA(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 T1(t){this._context=t}T1.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:NA(this,this._t0,Y5(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,NA(this,Y5(this,n=X5(this,t,e)),n);break;default:NA(this,this._t0,n=X5(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function j7(t){this._context=new L7(t)}(j7.prototype=Object.create(T1.prototype)).point=function(t,e){T1.prototype.point.call(this,e,t)};function L7(t){this._context=t}L7.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 kde(t){return new T1(t)}function Pde(t){return new j7(t)}function I7(t){this._context=t}I7.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=Z5(t),i=Z5(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 Z5(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 Rde(t){return new I7(t)}function zS(t,e){this._context=t,this._t=e}zS.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}break}}this._x=t,this._y=e}};function Dde(t){return new zS(t,.5)}function Ode(t){return new zS(t,0)}function jde(t){return new zS(t,1)}function hm(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 O3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Lde(t,e){return t[e]}function Ide(t){const e=[];return e.key=t,e}function Ude(){var t=ir([]),e=O3,n=hm,r=Lde;function i(s){var a=Array.from(t.apply(this,arguments),Ide),o,l=a.length,u=-1,d;for(const f of s)for(o=0,++u;o<l;++o)(a[o][u]=[0,+r(f,a[o].key,u,s)]).data=f;for(o=0,d=$R(e(a));o<l;++o)a[d[o]].index=o;return n(a,d),a}return i.keys=function(s){return arguments.length?(t=typeof s=="function"?s:ir(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:ir(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?O3:typeof s=="function"?s:ir(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??hm,i):n},i}function Fde(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}hm(t,e)}}function zde(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}hm(t,e)}}function Bde(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,u=0;o<a;++o){for(var d=t[e[o]],f=d[r][1]||0,g=d[r-1][1]||0,m=(f-g)/2,x=0;x<o;++x){var y=t[e[x]],v=y[r][1]||0,b=y[r-1][1]||0;m+=v-b}l+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,l&&(n-=u/l)}i[r-1][1]+=i[r-1][0]=n,hm(t,e)}}var kA={},PA={},Q5;function Hde(){return Q5||(Q5=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(PA)),PA}var RA={},J5;function U7(){return J5||(J5=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})(RA)),RA}var DA={},eF;function GR(){return eF||(eF=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})(DA)),DA}var OA={},jA={},tF;function $de(){return tF||(tF=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})(jA)),jA}var nF;function WR(){return nF||(nF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$de(),n=GR();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="",u="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),o++);o<a;){const f=i[o];u?f==="\\"&&o+1<a?(o++,l+=i[o]):f===u?u="":l+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,s.push(l),l=""):l+=f:f==="["?(d=!0,l&&(s.push(l),l="")):f==="."?l&&(s.push(l),l=""):l+=f,o++}return l&&s.push(l),s}t.toPath=r})(OA)),OA}var rF;function qR(){return rF||(rF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hde(),n=U7(),r=GR(),i=WR();function s(o,l,u){if(o==null)return u;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return u;const d=o[l];return d===void 0?n.isDeepKey(l)?s(o,i.toPath(l),u):u:d}case"number":case"symbol":{typeof l=="number"&&(l=r.toKey(l));const d=o[l];return d===void 0?u:d}default:{if(Array.isArray(l))return a(o,l,u);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),e.isUnsafeProperty(l))return u;const d=o[l];return d===void 0?u:d}}}function a(o,l,u){if(l.length===0)return u;let d=o;for(let f=0;f<l.length;f++){if(d==null||e.isUnsafeProperty(l[f]))return u;d=d[l[f]]}return d===void 0?u:d}t.get=s})(kA)),kA}var LA,iF;function Vde(){return iF||(iF=1,LA=qR().get),LA}var Gde=Vde();const Hh=lo(Gde);var Oi=t=>t===0?0:t>0?1:-1,Ys=t=>typeof t=="number"&&t!=+t,Ac=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Nt=t=>(typeof t=="number"||t instanceof Number)&&!Ys(t),so=t=>Nt(t)||typeof t=="string",Wde=0,v0=t=>{var e=++Wde;return"".concat(t||"").concat(e)},ps=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(!Nt(e)&&typeof e!="string")return r;var s;if(Ac(e)){if(n==null)return r;var a=e.indexOf("%");s=n*parseFloat(e.slice(0,a))/100}else s=+e;return Ys(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},F7=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 Rn(t,e,n){return Nt(t)&&Nt(e)?t+n*(e-t):e}function z7(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Hh(r,e))===n)}var dr=t=>t===null||typeof t>"u",db=t=>dr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function qde(t){return t!=null}function hb(){}var Kde=["type","size","sizeType"];function j3(){return j3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},j3.apply(null,arguments)}function sF(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 aF(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sF(Object(n),!0).forEach(function(r){Xde(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sF(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Xde(t,e,n){return(e=Yde(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Yde(t){var e=Zde(t,"string");return typeof e=="symbol"?e:e+""}function Zde(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 Qde(t,e){if(t==null)return{};var n,r,i=Jde(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 Jde(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var B7={symbolCircle:VR,symbolCross:pde,symbolDiamond:gde,symbolSquare:xde,symbolStar:_de,symbolTriangle:wde,symbolWye:Ede},ehe=Math.PI/180,the=t=>{var e="symbol".concat(db(t));return B7[e]||VR},nhe=(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*ehe;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}},rhe=(t,e)=>{B7["symbol".concat(db(t))]=e},KR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Qde(t,Kde),s=aF(aF({},i),{},{type:e,size:n,sizeType:r}),a="circle";typeof e=="string"&&(a=e);var o=()=>{var g=the(a),m=Mde().type(g).size(nhe(n,r,a)),x=m();if(x!==null)return x},{className:l,cx:u,cy:d}=s,f=es(s);return Nt(u)&&Nt(d)&&Nt(n)?M.createElement("path",j3({},f,{className:Sn("recharts-symbols",l),transform:"translate(".concat(u,", ").concat(d,")"),d:o()})):null};KR.registerSymbol=rhe;var H7=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,XR=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(M.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{zR(i)&&(r[i]=(s=>n[i](n,s)))}),r},ihe=(t,e,n)=>r=>(t(e,n,r),null),fb=(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];zR(i)&&typeof s=="function"&&(r||(r={}),r[i]=ihe(s,e,n))}),r};function oF(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 she(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oF(Object(n),!0).forEach(function(r){ahe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oF(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ahe(t,e,n){return(e=ohe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ohe(t){var e=lhe(t,"string");return typeof e=="symbol"?e:e+""}function lhe(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 wr(t,e){var n=she({},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 C1(){return C1=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},C1.apply(null,arguments)}function lF(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 che(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lF(Object(n),!0).forEach(function(r){uhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lF(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uhe(t,e,n){return(e=dhe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dhe(t){var e=hhe(t,"string");return typeof e=="symbol"?e:e+""}function hhe(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 Fa=32,fhe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function phe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Fa/2,s=Fa/6,a=Fa/3,o=e.inactive?r:e.color,l=n??e.type;if(l==="none")return null;if(l==="plainline"){var u;return M.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Fa,y2:i,className:"recharts-legend-icon"})}if(l==="line")return M.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(Fa,"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 M.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Fa/8,"h").concat(Fa,"v").concat(Fa*3/4,"h").concat(-Fa,"z"),className:"recharts-legend-icon"});if(M.isValidElement(e.legendIcon)){var d=che({},e);return delete d.legendIcon,M.cloneElement(e.legendIcon,d)}return M.createElement(KR,{fill:o,cx:i,cy:i,size:Fa,sizeType:"diameter",type:l})}function mhe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:a}=t,o={x:0,y:0,width:Fa,height:Fa},l={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,m=Sn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?s:d.color,y=g?g(d.value,d,f):d.value;return M.createElement("li",C1({className:m,style:l,key:"legend-item-".concat(f)},fb(t,d,f)),M.createElement(BR,{width:n,height:n,viewBox:o,style:u,"aria-label":"".concat(y," legend icon")},M.createElement(phe,{data:d,iconType:a,inactiveColor:s})),M.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var ghe=t=>{var e=wr(t,fhe),{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 M.createElement("ul",{className:"recharts-default-legend",style:s},M.createElement(mhe,C1({},e,{payload:n})))},IA={},UA={},cF;function xhe(){return cF||(cF=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})(UA)),UA}var FA={},uF;function $7(){return uF||(uF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(FA)),FA}var zA={},BA={},HA={},dF;function bhe(){return dF||(dF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(HA)),HA}var hF;function YR(){return hF||(hF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bhe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(BA)),BA}var $A={},fF;function vhe(){return fF||(fF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})($A)),$A}var pF;function yhe(){return pF||(pF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YR(),n=vhe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(zA)),zA}var VA={},GA={},mF;function _he(){return mF||(mF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(GA)),GA}var WA={},qA={},KA={},XA={},gF;function V7(){return gF||(gF=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})(XA)),XA}var YA={},xF;function G7(){return xF||(xF=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})(YA)),YA}var ZA={},bF;function W7(){return bF||(bF=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})(ZA)),ZA}var vF;function whe(){return vF||(vF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=V7(),n=G7(),r=W7();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):s(d,f,function m(x,y,v,b,E,S){const A=g(x,y,v,b,E,S);return A!==void 0?!!A:s(x,y,m,S)},new Map)}function s(d,f,g,m){if(f===d)return!0;switch(typeof f){case"object":return a(d,f,g,m);case"function":return Object.keys(f).length>0?s(d,{...f},g,m):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function a(d,f,g,m){if(f==null)return!0;if(Array.isArray(f))return l(d,f,g,m);if(f instanceof Map)return o(d,f,g,m);if(f instanceof Set)return u(d,f,g,m);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(m?.has(f))return m.get(f)===d;m?.set(f,d);try{for(let y=0;y<x.length;y++){const v=x[y];if(!n.isPrimitive(d)&&!(v in d)||f[v]===void 0&&d[v]!==void 0||f[v]===null&&d[v]!==null||!g(d[v],f[v],v,d,f,m))return!1}return!0}finally{m?.delete(f)}}function o(d,f,g,m){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of f.entries()){const v=d.get(x);if(g(v,y,x,d,f,m)===!1)return!1}return!0}function l(d,f,g,m){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<f.length;y++){const v=f[y];let b=!1;for(let E=0;E<d.length;E++){if(x.has(E))continue;const S=d[E];let A=!1;if(g(S,v,y,d,f,m)&&(A=!0),A){x.add(E),b=!0;break}}if(!b)return!1}return!0}function u(d,f,g,m){return f.size===0?!0:d instanceof Set?l([...d],[...f],g,m):!1}t.isMatchWith=i,t.isSetMatch=u})(KA)),KA}var yF;function q7(){return yF||(yF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=whe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(qA)),qA}var QA={},JA={},eT={},_F;function She(){return _F||(_F=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})(eT)),eT}var tT={},wF;function K7(){return wF||(wF=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})(tT)),tT}var nT={},SF;function X7(){return SF||(SF=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]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",m="[object Object]",x="[object Error]",y="[object DataView]",v="[object Uint8Array]",b="[object Uint8ClampedArray]",E="[object Uint16Array]",S="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",k="[object Int16Array]",N="[object Int32Array]",I="[object BigInt64Array]",C="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=I,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=o,t.errorTag=x,t.float32ArrayTag=C,t.float64ArrayTag=D,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=N,t.int8ArrayTag=T,t.mapTag=l,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=a,t.uint16ArrayTag=E,t.uint32ArrayTag=S,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=b})(nT)),nT}var rT={},EF;function Ehe(){return EF||(EF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(rT)),rT}var MF;function Y7(){return MF||(MF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=She(),n=K7(),r=X7(),i=G7(),s=Ehe();function a(d,f){return o(d,void 0,d,new Map,f)}function o(d,f,g,m=new Map,x=void 0){const y=x?.(d,f,g,m);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const v=new Array(d.length);m.set(d,v);for(let b=0;b<d.length;b++)v[b]=o(d[b],b,g,m,x);return Object.hasOwn(d,"index")&&(v.index=d.index),Object.hasOwn(d,"input")&&(v.input=d.input),v}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const v=new RegExp(d.source,d.flags);return v.lastIndex=d.lastIndex,v}if(d instanceof Map){const v=new Map;m.set(d,v);for(const[b,E]of d)v.set(b,o(E,b,g,m,x));return v}if(d instanceof Set){const v=new Set;m.set(d,v);for(const b of d)v.add(o(b,void 0,g,m,x));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const v=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,v);for(let b=0;b<d.length;b++)v[b]=o(d[b],b,g,m,x);return v}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const v=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,v),l(v,d,g,m,x),v}if(typeof File<"u"&&d instanceof File){const v=new File([d],d.name,{type:d.type});return m.set(d,v),l(v,d,g,m,x),v}if(typeof Blob<"u"&&d instanceof Blob){const v=new Blob([d],{type:d.type});return m.set(d,v),l(v,d,g,m,x),v}if(d instanceof Error){const v=new d.constructor;return m.set(d,v),v.message=d.message,v.name=d.name,v.stack=d.stack,v.cause=d.cause,l(v,d,g,m,x),v}if(d instanceof Boolean){const v=new Boolean(d.valueOf());return m.set(d,v),l(v,d,g,m,x),v}if(d instanceof Number){const v=new Number(d.valueOf());return m.set(d,v),l(v,d,g,m,x),v}if(d instanceof String){const v=new String(d.valueOf());return m.set(d,v),l(v,d,g,m,x),v}if(typeof d=="object"&&u(d)){const v=Object.create(Object.getPrototypeOf(d));return m.set(d,v),l(v,d,g,m,x),v}return d}function l(d,f,g=d,m,x){const y=[...Object.keys(f),...e.getSymbols(f)];for(let v=0;v<y.length;v++){const b=y[v],E=Object.getOwnPropertyDescriptor(d,b);(E==null||E.writable)&&(d[b]=o(f[b],b,g,m,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=a,t.cloneDeepWithImpl=o,t.copyProperties=l})(JA)),JA}var AF;function Mhe(){return AF||(AF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Y7();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(QA)),QA}var TF;function Ahe(){return TF||(TF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=q7(),n=Mhe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(WA)),WA}var iT={},sT={},aT={},CF;function The(){return CF||(CF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Y7(),n=X7();function r(i,s){return e.cloneDeepWith(i,(a,o,l,u)=>{const d=s?.(a,o,l,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(aT)),aT}var NF;function Che(){return NF||(NF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=The();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(sT)),sT}var oT={},lT={},kF;function Z7(){return kF||(kF=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})(lT)),lT}var cT={},PF;function Nhe(){return PF||(PF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=K7();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(cT)),cT}var RF;function khe(){return RF||(RF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=U7(),n=Z7(),r=Nhe(),i=WR();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 u=a;for(let d=0;d<l.length;d++){const f=l[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=s})(oT)),oT}var DF;function Phe(){return DF||(DF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=q7(),n=GR(),r=Che(),i=qR(),s=khe();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(u){const d=i.get(u,o);return d===void 0?s.has(u,o):l===void 0?d===void 0:e.isMatch(d,l)}}t.matchesProperty=a})(iT)),iT}var OF;function Rhe(){return OF||(OF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$7(),n=_he(),r=Ahe(),i=Phe();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})(VA)),VA}var jF;function Dhe(){return jF||(jF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xhe(),n=$7(),r=yhe(),i=Rhe();function s(a,o=n.identity){return r.isArrayLikeObject(a)?e.uniqBy(Array.from(a),i.iteratee(o)):[]}t.uniqBy=s})(IA)),IA}var uT,LF;function Ohe(){return LF||(LF=1,uT=Dhe().uniqBy),uT}var jhe=Ohe();const IF=lo(jhe);function Q7(t,e,n){return e===!0?IF(t,n):typeof e=="function"?IF(t,e):t}var dT={exports:{}},hT={};var UF;function Lhe(){if(UF)return hT;UF=1;var t=Im(),e=gG();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return hT.useSyncExternalStoreWithSelector=function(u,d,f,g,m){var x=s(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=o(function(){function b(k){if(!E){if(E=!0,S=k,k=g(k),m!==void 0&&y.hasValue){var N=y.value;if(m(N,k))return A=N}return A=k}if(N=A,r(S,k))return N;var I=g(k);return m!==void 0&&m(N,I)?(S=k,N):(S=k,A=I)}var E=!1,S,A,T=f===void 0?null:f;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,f,g,m]);var v=i(u,x[0],x[1]);return a(function(){y.hasValue=!0,y.value=v},[v]),l(v),v},hT}var FF;function Ihe(){return FF||(FF=1,dT.exports=Lhe()),dT.exports}var J7=Ihe(),ZR=M.createContext(null),Uhe=t=>t,rr=()=>{var t=M.useContext(ZR);return t?t.store.dispatch:Uhe},G_=()=>{},Fhe=()=>G_,zhe=(t,e)=>t===e;function Tt(t){var e=M.useContext(ZR);return J7.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Fhe,e?e.store.getState:G_,e?e.store.getState:G_,e?t:G_,zhe)}function Bhe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Hhe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function $he(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 zF=t=>Array.isArray(t)?t:[t];function Vhe(t){const e=Array.isArray(t[0])?t[0]:t;return $he(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function Ghe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Whe=class{constructor(t){this.value=t}deref(){return this.value}},qhe=typeof WeakRef<"u"?WeakRef:Whe,Khe=0,BF=1;function uy(){return{s:Khe,v:void 0,o:null,p:null}}function eW(t,e={}){let n=uy();const{resultEqualityCheck:r}=e;let i,s=0;function a(){let o=n;const{length:l}=arguments;for(let f=0,g=l;f<g;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=o.o;x===null&&(o.o=x=new WeakMap);const y=x.get(m);y===void 0?(o=uy(),x.set(m,o)):o=y}else{let x=o.p;x===null&&(o.p=x=new Map);const y=x.get(m);y===void 0?(o=uy(),x.set(m,o)):o=y}}const u=o;let d;if(o.s===BF)d=o.v;else if(d=t.apply(null,arguments),s++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,s!==0&&s--),i=typeof d=="object"&&d!==null||typeof d=="function"?new qhe(d):d}return u.s=BF,u.v=d,d}return a.clearCache=()=>{n=uy(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function Xhe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,a=0,o,l={},u=i.pop();typeof u=="object"&&(l=u,u=i.pop()),Bhe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...l},{memoize:f,memoizeOptions:g=[],argsMemoize:m=eW,argsMemoizeOptions:x=[]}=d,y=zF(g),v=zF(x),b=Vhe(i),E=f(function(){return s++,u.apply(null,arguments)},...y),S=m(function(){a++;const T=Ghe(b,arguments);return o=E.apply(null,T),o},...v);return Object.assign(S,{resultFunc:u,memoizedResultFunc:E,dependencies:b,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>o,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var We=Xhe(eW),Yhe=Object.assign((t,e=We)=>{Hhe(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:()=>Yhe}),fT={},pT={},mT={},HF;function Zhe(){return HF||(HF=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})(mT)),mT}var gT={},xT={},$F;function tW(){return $F||($F=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(xT)),xT}var VF;function Qhe(){return VF||(VF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tW(),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})(gT)),gT}var GF;function Jhe(){return GF||(GF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Zhe(),n=Qhe(),r=WR();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 u=(m,x)=>{let y=m;for(let v=0;v<x.length&&y!=null;++v)y=y[x[v]];return y},d=(m,x)=>x==null||m==null?x:typeof m=="object"&&"key"in m?Object.hasOwn(x,m.key)?x[m.key]:u(x,m.path):typeof m=="function"?m(x):Array.isArray(m)?u(x,m):typeof x=="object"?x[m]:x,f=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:f.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let y=0;y<f.length;y++){const v=e.compareValues(m.criteria[y],x.criteria[y],o[y]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=i})(pT)),pT}var bT={},WF;function efe(){return WF||(WF=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 u=0;u<o.length;u++){const d=o[u];Array.isArray(d)&&l<s?a(d,l+1):i.push(d)}};return a(n,0),i}t.flatten=e})(bT)),bT}var vT={},qF;function nW(){return qF||(qF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Z7(),n=YR(),r=V7(),i=W7();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})(vT)),vT}var KF;function tfe(){return KF||(KF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jhe(),n=efe(),r=nW();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})(fT)),fT}var yT,XF;function nfe(){return XF||(XF=1,yT=tfe().sortBy),yT}var rfe=nfe();const BS=lo(rfe);var rW=t=>t.legend.settings,ife=t=>t.legend.size,sfe=t=>t.legend.payload,afe=We([sfe,rW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?BS(r,n):r});function ofe(){return Tt(afe)}var dy=1;function iW(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=M.useState({height:0,left:0,top:0,width:0}),r=M.useCallback(i=>{if(i!=null){var s=i.getBoundingClientRect(),a={height:s.height,left:s.left,top:s.top,width:s.width};(Math.abs(a.height-e.height)>dy||Math.abs(a.left-e.left)>dy||Math.abs(a.top-e.top)>dy||Math.abs(a.width-e.width)>dy)&&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 qi(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 lfe=typeof Symbol=="function"&&Symbol.observable||"@@observable",YF=lfe,_T=()=>Math.random().toString(36).substring(7).split("").join("."),cfe={INIT:`@@redux/INIT${_T()}`,REPLACE:`@@redux/REPLACE${_T()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${_T()}`},N1=cfe;function QR(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 sW(t,e,n){if(typeof t!="function")throw new Error(qi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(qi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(qi(1));return n(sW)(t,e)}let r=t,i=e,s=new Map,a=s,o=0,l=!1;function u(){a===s&&(a=new Map,s.forEach((v,b)=>{a.set(b,v)}))}function d(){if(l)throw new Error(qi(3));return i}function f(v){if(typeof v!="function")throw new Error(qi(4));if(l)throw new Error(qi(5));let b=!0;u();const E=o++;return a.set(E,v),function(){if(b){if(l)throw new Error(qi(6));b=!1,u(),a.delete(E),s=null}}}function g(v){if(!QR(v))throw new Error(qi(7));if(typeof v.type>"u")throw new Error(qi(8));if(typeof v.type!="string")throw new Error(qi(17));if(l)throw new Error(qi(9));try{l=!0,i=r(i,v)}finally{l=!1}return(s=a).forEach(E=>{E()}),v}function m(v){if(typeof v!="function")throw new Error(qi(10));r=v,g({type:N1.REPLACE})}function x(){const v=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(qi(11));function E(){const A=b;A.next&&A.next(d())}return E(),{unsubscribe:v(E)}},[YF](){return this}}}return g({type:N1.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:m,[YF]:x}}function ufe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:N1.INIT})>"u")throw new Error(qi(12));if(typeof n(void 0,{type:N1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(qi(13))})}function aW(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{ufe(n)}catch(s){i=s}return function(a={},o){if(i)throw i;let l=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],m=a[f],x=g(m,o);if(typeof x>"u")throw o&&o.type,new Error(qi(14));u[f]=x,l=l||x!==m}return l=l||r.length!==Object.keys(a).length,l?u:a}}function k1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function dfe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(qi(15))};const a={getState:i.getState,dispatch:(l,...u)=>s(l,...u)},o=t.map(l=>l(a));return s=k1(...o)(i.dispatch),{...i,dispatch:s}}}function oW(t){return QR(t)&&"type"in t&&typeof t.type=="string"}var lW=Symbol.for("immer-nothing"),ZF=Symbol.for("immer-draftable"),Cs=Symbol.for("immer-state");function So(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var ma=Object,fm=ma.getPrototypeOf,P1="constructor",HS="prototype",L3="configurable",R1="enumerable",W_="writable",y0="value",Tc=t=>!!t&&!!t[Cs];function Io(t){return t?cW(t)||$S(t)||!!t[ZF]||!!t[P1]?.[ZF]||VS(t)||GS(t):!1}var hfe=ma[HS][P1].toString(),QF=new WeakMap;function cW(t){if(!t||!JR(t))return!1;const e=fm(t);if(e===null||e===ma[HS])return!0;const n=ma.hasOwnProperty.call(e,P1)&&e[P1];if(n===Object)return!0;if(!Op(n))return!1;let r=QF.get(n);return r===void 0&&(r=Function.toString.call(n),QF.set(n,r)),r===hfe}function pb(t,e,n=!0){mb(t)===0?(n?Reflect.ownKeys(t):ma.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function mb(t){const e=t[Cs];return e?e.type_:$S(t)?1:VS(t)?2:GS(t)?3:0}var JF=(t,e,n=mb(t))=>n===2?t.has(e):ma[HS].hasOwnProperty.call(t,e),I3=(t,e,n=mb(t))=>n===2?t.get(e):t[e],D1=(t,e,n,r=mb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function ffe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var $S=Array.isArray,VS=t=>t instanceof Map,GS=t=>t instanceof Set,JR=t=>typeof t=="object",Op=t=>typeof t=="function",wT=t=>typeof t=="boolean",ac=t=>t.copy_||t.base_,eD=t=>t.modified_?t.copy_:t.base_;function U3(t,e){if(VS(t))return new Map(t);if(GS(t))return new Set(t);if($S(t))return Array[HS].slice.call(t);const n=cW(t);if(e===!0||e==="class_only"&&!n){const r=ma.getOwnPropertyDescriptors(t);delete r[Cs];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o[W_]===!1&&(o[W_]=!0,o[L3]=!0),(o.get||o.set)&&(r[a]={[L3]:!0,[W_]:!0,[R1]:o[R1],[y0]:t[a]})}return ma.create(fm(t),r)}else{const r=fm(t);if(r!==null&&n)return{...t};const i=ma.create(r);return ma.assign(i,t)}}function tD(t,e=!1){return WS(t)||Tc(t)||!Io(t)||(mb(t)>1&&ma.defineProperties(t,{set:hy,add:hy,clear:hy,delete:hy}),ma.freeze(t),e&&pb(t,(n,r)=>{tD(r,!0)},!1)),t}function pfe(){So(2)}var hy={[y0]:pfe};function WS(t){return t===null||!JR(t)?!0:ma.isFrozen(t)}var O1="MapSet",F3="Patches",uW={};function pm(t){const e=uW[t];return e||So(0,t),e}var mfe=t=>!!uW[t],_0,dW=()=>_0,gfe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:mfe(O1)?pm(O1):void 0});function ez(t,e){e&&(t.patchPlugin_=pm(F3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function z3(t){B3(t),t.drafts_.forEach(xfe),t.drafts_=null}function B3(t){t===_0&&(_0=t.parent_)}var tz=t=>_0=gfe(_0,t);function xfe(t){const e=t[Cs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function nz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Cs].modified_&&(z3(e),So(4)),Io(t)&&(t=rz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Cs].base_,t,e)}else t=rz(e,n);return bfe(e,t,!0),z3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==lW?t:void 0}function rz(t,e){if(WS(e))return e;const n=e[Cs];if(!n)return nD(e,t.handledSet_,t);if(!qS(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);pW(n,t)}return n.copy_}function bfe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&tD(e,n)}function hW(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var qS=(t,e)=>t.scope_===e,vfe=[];function fW(t,e,n,r){const i=ac(t),s=t.type_;if(r!==void 0&&I3(i,r,s)===e){D1(i,r,n,s);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;pb(i,(l,u)=>{if(Tc(u)){const d=o.get(u)||[];d.push(l),o.set(u,d)}})}const a=t.draftLocations_.get(e)??vfe;for(const o of a)D1(i,o,n,s)}function yfe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!qS(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const a=eD(s);fW(t,s.draft_??s,a,n),pW(s,i)})}function pW(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)}hW(t)}}function _fe(t,e,n){const{scope_:r}=t;if(Tc(n)){const i=n[Cs];qS(i,r)&&i.callbacks_.push(function(){q_(t);const a=eD(i);fW(t,n,a,e)})}else Io(n)&&t.callbacks_.push(function(){const s=ac(t);I3(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&nD(I3(t.copy_,e,t.type_),r.handledSet_,r)})}function nD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Tc(t)||e.has(t)||!Io(t)||WS(t)||(e.add(t),pb(t,(r,i)=>{if(Tc(i)){const s=i[Cs];if(qS(s,n)){const a=eD(s);D1(t,r,a,t.type_),hW(s)}}else Io(i)&&nD(i,e,n)})),t}function wfe(t,e){const n=$S(t),r={type_:n?1:0,scope_:e?e.scope_:dW(),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=rD;n&&(i=[r],s=w0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,[o,r]}var rD={get(t,e){if(e===Cs)return t;const n=ac(t);if(!JF(n,e,t.type_))return Sfe(t,n,e);const r=n[e];if(t.finalized_||!Io(r))return r;if(r===ST(t.base_,e)){q_(t);const i=t.type_===1?+e:e,s=$3(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in ac(t)},ownKeys(t){return Reflect.ownKeys(ac(t))},set(t,e,n){const r=mW(ac(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=ST(ac(t),e),s=i?.[Cs];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(ffe(n,i)&&(n!==void 0||JF(t.base_,e,t.type_)))return!0;q_(t),H3(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),_fe(t,e,n)),!0},deleteProperty(t,e){return q_(t),ST(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),H3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=ac(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[W_]:!0,[L3]:t.type_!==1||e!=="length",[R1]:r[R1],[y0]:n[e]}},defineProperty(){So(11)},getPrototypeOf(t){return fm(t.base_)},setPrototypeOf(){So(12)}},w0={};pb(rD,(t,e)=>{w0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});w0.deleteProperty=function(t,e){return w0.set.call(this,t,e,void 0)};w0.set=function(t,e,n){return rD.set.call(this,t[0],e,n,t[0])};function ST(t,e){const n=t[Cs];return(n?ac(n):t)[e]}function Sfe(t,e,n){const r=mW(e,n);return r?y0 in r?r[y0]:r.get?.call(t.draft_):void 0}function mW(t,e){if(!(e in t))return;let n=fm(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=fm(n)}}function H3(t){t.modified_||(t.modified_=!0,t.parent_&&H3(t.parent_))}function q_(t){t.copy_||(t.assigned_=new Map,t.copy_=U3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Efe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Op(n)&&!Op(r)){const a=r;r=n;const o=this;return function(u=a,...d){return o.produce(u,f=>r.call(this,f,...d))}}Op(r)||So(6),i!==void 0&&!Op(i)&&So(7);let s;if(Io(n)){const a=tz(this),o=$3(a,n,void 0);let l=!0;try{s=r(o),l=!1}finally{l?z3(a):B3(a)}return ez(a,i),nz(s,a)}else if(!n||!JR(n)){if(s=r(n),s===void 0&&(s=n),s===lW&&(s=void 0),this.autoFreeze_&&tD(s,!0),i){const a=[],o=[];pm(F3).generateReplacementPatches_(n,s,{patches_:a,inversePatches_:o}),i(a,o)}return s}else So(1,n)},this.produceWithPatches=(n,r)=>{if(Op(n))return(o,...l)=>this.produceWithPatches(o,u=>n(u,...l));let i,s;return[this.produce(n,r,(o,l)=>{i=o,s=l}),i,s]},wT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),wT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),wT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Io(e)||So(8),Tc(e)&&(e=Ro(e));const n=tz(this),r=$3(n,e,void 0);return r[Cs].isManual_=!0,B3(n),r}finishDraft(e,n){const r=e&&e[Cs];(!r||!r.isManual_)&&So(9);const{scope_:i}=r;return ez(i,n),nz(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=pm(F3).applyPatches_;return Tc(e)?i(e,n):this.produce(e,s=>i(s,n))}};function $3(t,e,n,r){const[i,s]=VS(e)?pm(O1).proxyMap_(e,n):GS(e)?pm(O1).proxySet_(e,n):wfe(e,n);return(n?.scope_??dW()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?yfe(n,s,r):s.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:u}=l;s.modified_&&u&&u.generatePatches_(s,[],l)}),i}function Ro(t){return Tc(t)||So(10,t),gW(t)}function gW(t){if(!Io(t)||WS(t))return t;const e=t[Cs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=U3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=U3(t,!0);return pb(n,(i,s)=>{D1(n,i,gW(s))},r),e&&(e.finalized_=!1),n}var Mfe=new Efe,xW=Mfe.produce;function bW(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var Afe=bW(),Tfe=bW,Cfe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?k1:k1.apply(null,arguments)};function ao(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(xa(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=>oW(r)&&r.type===t,n}var vW=class Ex extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Ex.prototype)}static get[Symbol.species](){return Ex}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Ex(...e[0].concat(this)):new Ex(...e.concat(this))}};function iz(t){return Io(t)?xW(t,()=>{}):t}function fy(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Nfe(t){return typeof t=="boolean"}var kfe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let a=new vW;return n&&(Nfe(n)?a.push(Afe):a.push(Tfe(n.extraArgument))),a},yW="RTK_autoBatch",fr=()=>t=>({payload:t,meta:{[yW]:!0}}),sz=t=>e=>{setTimeout(e,t)},_W=(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:sz(10):t.type==="callback"?t.queueNotification:sz(t.timeout),u=()=>{a=!1,s&&(s=!1,o.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return o.add(d),()=>{g(),o.delete(d)}},dispatch(d){try{return i=!d?.meta?.[yW],s=!i,s&&(a||(a=!0,l(u))),r.dispatch(d)}finally{i=!0}}})},Pfe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new vW(t);return r&&i.push(_W(typeof r=="object"?r:void 0)),i};function Rfe(t){const e=kfe(),{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(QR(n))o=aW(n);else throw new Error(xa(1));let l;typeof r=="function"?l=r(e):l=e();let u=k1;i&&(u=Cfe({trace:!1,...typeof i=="object"&&i}));const d=dfe(...l),f=Pfe(d);let g=typeof a=="function"?a(f):f();const m=u(...g);return sW(o,s,m)}function wW(t){const e={},n=[];let r;const i={addCase(s,a){const o=typeof s=="string"?s:s.type;if(!o)throw new Error(xa(28));if(o in e)throw new Error(xa(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 Dfe(t){return typeof t=="function"}function Ofe(t,e){let[n,r,i]=wW(e),s;if(Dfe(t))s=()=>iz(t());else{const o=iz(t);s=()=>o}function a(o=s(),l){let u=[n[l.type],...r.filter(({matcher:d})=>d(l)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Tc(d)){const m=f(d,l);return m===void 0?d:m}else{if(Io(d))return xW(d,g=>f(g,l));{const g=f(d,l);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},o)}return a.getInitialState=s,a}var jfe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Lfe=(t=21)=>{let e="",n=t;for(;n--;)e+=jfe[Math.random()*64|0];return e},Ife=Symbol.for("rtk-slice-createasyncthunk");function Ufe(t,e){return`${t}/${e}`}function Ffe({creators:t}={}){const e=t?.asyncThunk?.[Ife];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(xa(11));const a=(typeof r.reducers=="function"?r.reducers(Bfe()):r.reducers)||{},o=Object.keys(a),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,A){const T=typeof S=="string"?S:S.type;if(!T)throw new Error(xa(12));if(T in l.sliceCaseReducersByType)throw new Error(xa(13));return l.sliceCaseReducersByType[T]=A,u},addMatcher(S,A){return l.sliceMatchers.push({matcher:S,reducer:A}),u},exposeAction(S,A){return l.actionCreators[S]=A,u},exposeCaseReducer(S,A){return l.sliceCaseReducersByName[S]=A,u}};o.forEach(S=>{const A=a[S],T={reducerName:S,type:Ufe(i,S),createNotation:typeof r.reducers=="function"};$fe(A)?Gfe(T,A,u,e):Hfe(T,A,u)});function d(){const[S={},A=[],T=void 0]=typeof r.extraReducers=="function"?wW(r.extraReducers):[r.extraReducers],k={...S,...l.sliceCaseReducersByType};return Ofe(r.initialState,N=>{for(let I in k)N.addCase(I,k[I]);for(let I of l.sliceMatchers)N.addMatcher(I.matcher,I.reducer);for(let I of A)N.addMatcher(I.matcher,I.reducer);T&&N.addDefaultCase(T)})}const f=S=>S,g=new Map,m=new WeakMap;let x;function y(S,A){return x||(x=d()),x(S,A)}function v(){return x||(x=d()),x.getInitialState()}function b(S,A=!1){function T(N){let I=N[S];return typeof I>"u"&&A&&(I=fy(m,T,v)),I}function k(N=f){const I=fy(g,A,()=>new WeakMap);return fy(I,N,()=>{const C={};for(const[D,F]of Object.entries(r.selectors??{}))C[D]=zfe(F,N,()=>fy(m,N,v),A);return C})}return{reducerPath:S,getSelectors:k,get selectors(){return k(T)},selectSlice:T}}const E={name:i,reducer:y,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:v,...b(s),injectInto(S,{reducerPath:A,...T}={}){const k=A??s;return S.inject({reducerPath:k,reducer:y},T),{...E,...b(k,!0)}}};return E}}function zfe(t,e,n,r){function i(s,...a){let o=e(s);return typeof o>"u"&&r&&(o=n()),t(o,...a)}return i.unwrapped=t,i}var Zs=Ffe();function Bfe(){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 Hfe({type:t,reducerName:e,createNotation:n},r,i){let s,a;if("reducer"in r){if(n&&!Vfe(r))throw new Error(xa(17));s=r.reducer,a=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,a?ao(t,a):ao(t))}function $fe(t){return t._reducerDefinitionType==="asyncThunk"}function Vfe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function Gfe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(xa(18));const{payloadCreator:s,fulfilled:a,pending:o,rejected:l,settled:u,options:d}=n,f=i(t,s,d);r.exposeAction(e,f),a&&r.addCase(f.fulfilled,a),o&&r.addCase(f.pending,o),l&&r.addCase(f.rejected,l),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:a||py,pending:o||py,rejected:l||py,settled:u||py})}function py(){}var Wfe="task",SW="listener",EW="completed",iD="cancelled",qfe=`task-${iD}`,Kfe=`task-${EW}`,V3=`${SW}-${iD}`,Xfe=`${SW}-${EW}`,KS=class{constructor(t){this.code=t,this.message=`${Wfe} ${iD} (reason: ${t})`}name="TaskAbortError";message},sD=(t,e)=>{if(typeof t!="function")throw new TypeError(xa(32))},j1=()=>{},MW=(t,e=j1)=>(t.catch(e),t),AW=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),yh=(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))},_h=t=>{if(t.aborted){const{reason:e}=t;throw new KS(e)}};function TW(t,e){let n=j1;return new Promise((r,i)=>{const s=()=>i(new KS(t.reason));if(t.aborted){s();return}n=AW(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=j1})}var Yfe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof KS?"cancelled":"rejected",error:n}}finally{e?.()}},L1=t=>e=>MW(TW(t,e).then(n=>(_h(t),n))),CW=t=>{const e=L1(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Xp}=Object,az={},XS="listenerMiddleware",Zfe=(t,e)=>{const n=r=>AW(t,()=>yh(r,t.reason));return(r,i)=>{sD(r);const s=new AbortController;n(s);const a=Yfe(async()=>{_h(t),_h(s.signal);const o=await r({pause:L1(s.signal),delay:CW(s.signal),signal:s.signal});return _h(s.signal),o},()=>yh(s,Kfe));return i?.autoJoin&&e.push(a.catch(j1)),{result:L1(t)(a),cancel(){yh(s,qfe)}}}},Qfe=(t,e)=>{const n=async(r,i)=>{_h(e);let s=()=>{};const o=[new Promise((l,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),l([f,g.getState(),g.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&o.push(new Promise(l=>setTimeout(l,i,null)));try{const l=await TW(e,Promise.race(o));return _h(e),l}finally{s()}};return(r,i)=>MW(n(r,i))},NW=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=ao(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(xa(21));return sD(s),{predicate:i,type:e,effect:s}},kW=Xp(t=>{const{type:e,predicate:n,effect:r}=NW(t);return{id:Lfe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(xa(22))}}},{withTypes:()=>kW}),oz=(t,e)=>{const{type:n,effect:r,predicate:i}=NW(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},G3=t=>{t.pending.forEach(e=>{yh(e,V3)})},Jfe=(t,e)=>()=>{for(const n of e.keys())G3(n);t.clear()},lz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},PW=Xp(ao(`${XS}/add`),{withTypes:()=>PW}),epe=ao(`${XS}/removeAll`),RW=Xp(ao(`${XS}/remove`),{withTypes:()=>RW}),tpe=(...t)=>{console.error(`${XS}/error`,...t)},gb=(t={})=>{const e=new Map,n=new Map,r=m=>{const x=n.get(m)??0;n.set(m,x+1)},i=m=>{const x=n.get(m)??1;x===1?n.delete(m):n.set(m,x-1)},{extra:s,onError:a=tpe}=t;sD(a);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&G3(m)}),l=m=>{const x=oz(e,m)??kW(m);return o(x)};Xp(l,{withTypes:()=>l});const u=m=>{const x=oz(e,m);return x&&(x.unsubscribe(),m.cancelActive&&G3(x)),!!x};Xp(u,{withTypes:()=>u});const d=async(m,x,y,v)=>{const b=new AbortController,E=Qfe(l,b.signal),S=[];try{m.pending.add(b),r(m),await Promise.resolve(m.effect(x,Xp({},y,{getOriginalState:v,condition:(A,T)=>E(A,T).then(Boolean),take:E,delay:CW(b.signal),pause:L1(b.signal),extra:s,signal:b.signal,fork:Zfe(b.signal,S),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((A,T,k)=>{A!==b&&(yh(A,V3),k.delete(A))})},cancel:()=>{yh(b,V3),m.pending.delete(b)},throwIfCancelled:()=>{_h(b.signal)}})))}catch(A){A instanceof KS||lz(a,A,{raisedBy:"effect"})}finally{await Promise.all(S),yh(b,Xfe),i(m),m.pending.delete(b)}},f=Jfe(e,n);return{middleware:m=>x=>y=>{if(!oW(y))return x(y);if(PW.match(y))return l(y.payload);if(epe.match(y)){f();return}if(RW.match(y))return u(y.payload);let v=m.getState();const b=()=>{if(v===az)throw new Error(xa(23));return v};let E;try{if(E=x(y),e.size>0){const S=m.getState(),A=Array.from(e.values());for(const T of A){let k=!1;try{k=T.predicate(y,S,v)}catch(N){k=!1,lz(a,N,{raisedBy:"predicate"})}k&&d(T,y,m,b)}}}finally{v=az}return E},startListening:l,stopListening:u,clearListeners:f}};function xa(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 npe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},DW=Zs({name:"chartLayout",initialState:npe,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:rpe,setLayout:ipe,setChartSize:spe,setScale:ape}=DW.actions,ope=DW.reducer;function OW(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function cz(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 Bp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cz(Object(n),!0).forEach(function(r){lpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lpe(t,e,n){return(e=cpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cpe(t){var e=upe(t,"string");return typeof e=="symbol"?e:e+""}function upe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function zn(t,e,n){return dr(t)||dr(e)?n:so(e)?Hh(t,e,n):typeof e=="function"?e(t):n}var dpe=(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"&&Nt(t[s]))return Bp(Bp({},t),{},{[s]:t[s]+(r||0)});if((o==="horizontal"||o==="vertical"&&s==="center")&&a!=="middle"&&Nt(t[a]))return Bp(Bp({},t),{},{[a]:t[a]+(i||0)})}return t},yl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",jW=(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},LW=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:a,realScaleType:o,isCategorical:l,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:m}=t;if(!a)return null;var x=o==="scaleBand"&&a.bandwidth?a.bandwidth()/2:2,y=i==="category"&&a.bandwidth?a.bandwidth()/x:0;if(y=m==="angleAxis"&&s&&s.length>=2?Oi(s[0]-s[1])*2*y:y,f||g){var v=(f||g||[]).map((b,E)=>{var S=r?r.indexOf(b):b;return{coordinate:a(S)+y,value:b,offset:y,index:E}});return v.filter(b=>!Ys(b.coordinate))}return l&&u?u.map((b,E)=>({coordinate:a(b)+y,value:b,index:E,offset:y})):a.ticks&&d!=null?a.ticks(d).map((b,E)=>({coordinate:a(b)+y,value:b,offset:y,index:E})):a.domain().map((b,E)=>({coordinate:a(b)+y,value:r?r[b]:b,index:E,offset:y}))},uz=1e-4,hpe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-uz,s=Math.max(r[0],r[1])+uz,a=t(e[0]),o=t(e[n-1]);(a<i||a>s||o<i||o>s)&&t.domain([e[0],e[n-1]])}},fpe=(t,e)=>{if(!e||e.length!==2||!Nt(e[0])||!Nt(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(!Nt(t[0])||t[0]<n)&&(i[0]=n),(!Nt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},ppe=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=Ys(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])}},mpe=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=Ys(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)}},gpe={sign:ppe,expand:Fde,none:hm,silhouette:zde,wiggle:Bde,positive:mpe},xpe=(t,e,n)=>{var r=gpe[n],i=Ude().keys(e).value((s,a)=>Number(zn(s,a,0))).order(O3).offset(r);return i(t)};function IW(t){return t==null?void 0:String(t)}function I1(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:a}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!dr(i[e.dataKey])){var o=z7(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var l=zn(i,dr(a)?e.dataKey:a);return dr(l)?null:e.scale(l)}var dz=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=zn(s,e.dataKey,e.scale.domain()[a]);return dr(o)?null:e.scale(o)-i/2+r},bpe=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]},vpe=t=>{var e=t.flat(2).filter(Nt);return[Math.min(...e),Math.max(...e)]},ype=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],_pe=(t,e,n)=>{if(t!=null)return ype(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:a}=s,o=a.reduce((l,u)=>{var d=OW(u,e,n),f=vpe(d);return[Math.min(l[0],f[0]),Math.max(l[1],f[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},hz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,fz=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,rd=(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=BS(e,d=>d.coordinate),s=1/0,a=1,o=i.length;a<o;a++){var l=i[a],u=i[a-1];s=Math.min((l.coordinate||0)-(u.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function pz(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Bp(Bp({},e),{},{dataKey:n,payload:r,value:i,name:s})}function xd(t,e){if(t)return String(t);if(typeof e=="string")return e}var wpe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Spe=(t,e)=>e==="centric"?t.angle:t.radius,jc=t=>t.layout.width,Lc=t=>t.layout.height,Epe=t=>t.layout.scale,UW=t=>t.layout.margin,YS=We(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),ZS=We(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),FW="data-recharts-item-index",zW="data-recharts-item-data-key",xb=60;function mz(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 my(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mz(Object(n),!0).forEach(function(r){Mpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Mpe(t,e,n){return(e=Ape(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ape(t){var e=Tpe(t,"string");return typeof e=="symbol"?e:e+""}function Tpe(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 Cpe=t=>t.brush.height;function Npe(t){var e=ZS(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:xb;return n+i}return n},0)}function kpe(t){var e=ZS(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:xb;return n+i}return n},0)}function Ppe(t){var e=YS(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Rpe(t){var e=YS(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var gi=We([jc,Lc,UW,Cpe,Npe,kpe,Ppe,Rpe,rW,ife],(t,e,n,r,i,s,a,o,l,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},f={top:(n.top||0)+a,bottom:(n.bottom||0)+o},g=my(my({},f),d),m=g.bottom;g.bottom+=r,g=dpe(g,l,u);var x=t-g.left-g.right,y=e-g.top-g.bottom;return my(my({brushBottom:m},g),{},{width:Math.max(x,0),height:Math.max(y,0)})}),Dpe=We(gi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),aD=We(jc,Lc,(t,e)=>({x:0,y:0,width:t,height:e})),Ope=M.createContext(null),xi=()=>M.useContext(Ope)!=null,QS=t=>t.brush,JS=We([QS,gi,UW],(t,e,n)=>({height:t.height,x:Nt(t.x)?t.x:e.left,y:Nt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Nt(t.width)?t.width:e.width})),ET={},MT={},AT={},gz;function jpe(){return gz||(gz=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"),u=s==null||s.includes("trailing"),d=()=>{o!==null&&(n.apply(a,o),a=void 0,o=null)},f=()=>{u&&d(),y()};let g=null;const m=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{x(),a=void 0,o=null},v=()=>{d()},b=function(...E){if(i?.aborted)return;a=this,o=E;const S=g==null;m(),l&&S&&d()};return b.schedule=m,b.cancel=y,b.flush=v,i?.addEventListener("abort",y,{once:!0}),b}t.debounce=e})(AT)),AT}var xz;function Lpe(){return xz||(xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jpe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:a=!1,trailing:o=!0,maxWait:l}=s,u=Array(2);a&&(u[0]="leading"),o&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),m=function(...y){return l!=null&&(f===null&&(f=Date.now()),Date.now()-f>=l)?(d=r.apply(this,y),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,y),d)},x=()=>(g.flush(),d);return m.cancel=g.cancel,m.flush=x,m}t.debounce=n})(MT)),MT}var bz;function Ipe(){return bz||(bz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Lpe();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})(ET)),ET}var TT,vz;function Upe(){return vz||(vz=1,TT=Ipe().throttle),TT}var Fpe=Upe();const zpe=lo(Fpe);var U1=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++]))}},BW=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:a}=n,o=Ac(r)?t:Number(r),l=Ac(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}},Bpe={width:0,height:0,overflow:"visible"},Hpe={width:0,overflowX:"visible"},$pe={height:0,overflowY:"visible"},Vpe={},Gpe=t=>{var{width:e,height:n}=t,r=Ac(e),i=Ac(n);return r&&i?Bpe:r?Hpe:i?$pe:Vpe};function Wpe(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 Bn(t){return Number.isFinite(t)}function ul(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function W3(){return W3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},W3.apply(null,arguments)}function yz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _z(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yz(Object(n),!0).forEach(function(r){qpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qpe(t,e,n){return(e=Kpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kpe(t){var e=Xpe(t,"string");return typeof e=="symbol"?e:e+""}function Xpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var HW=M.createContext({width:-1,height:-1});function Ype(t){return ul(t.width)&&ul(t.height)}function $W(t){var{children:e,width:n,height:r}=t,i=M.useMemo(()=>({width:n,height:r}),[n,r]);return Ype(i)?M.createElement(HW.Provider,{value:i},e):null}var oD=()=>M.useContext(HW),Zpe=M.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:a=0,minHeight:o,maxHeight:l,children:u,debounce:d=0,id:f,className:g,onResize:m,style:x={}}=t,y=M.useRef(null),v=M.useRef();v.current=m,M.useImperativeHandle(e,()=>y.current);var[b,E]=M.useState({containerWidth:r.width,containerHeight:r.height}),S=M.useCallback((I,C)=>{E(D=>{var F=Math.round(I),j=Math.round(C);return D.containerWidth===F&&D.containerHeight===j?D:{containerWidth:F,containerHeight:j}})},[]);M.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return hb;var I=j=>{var q,{width:R,height:W}=j[0].contentRect;S(R,W),(q=v.current)===null||q===void 0||q.call(v,R,W)};d>0&&(I=zpe(I,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(I),{width:D,height:F}=y.current.getBoundingClientRect();return S(D,F),C.observe(y.current),()=>{C.disconnect()}},[S,d]);var{containerWidth:A,containerHeight:T}=b;U1(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:N}=BW(A,T,{width:i,height:s,aspect:n,maxHeight:l});return U1(k!=null&&k>0||N!=null&&N>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.`,k,N,i,s,a,o,n),M.createElement("div",{id:f?"".concat(f):void 0,className:Sn("recharts-responsive-container",g),style:_z(_z({},x),{},{width:i,height:s,minWidth:a,minHeight:o,maxHeight:l}),ref:y},M.createElement("div",{style:Gpe({width:i,height:s})},M.createElement($W,{width:k,height:N},u)))}),K_=M.forwardRef((t,e)=>{var n=oD();if(ul(n.width)&&ul(n.height))return t.children;var{width:r,height:i}=Wpe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:a}=BW(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Nt(s)&&Nt(a)?M.createElement($W,{width:s,height:a},t.children):M.createElement(Zpe,W3({},t,{width:r,height:i,ref:e}))});function VW(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 bb=()=>{var t,e=xi(),n=Tt(Dpe),r=Tt(JS),i=(t=Tt(QS))===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}},Qpe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},GW=()=>{var t;return(t=Tt(gi))!==null&&t!==void 0?t:Qpe},lD=()=>Tt(jc),cD=()=>Tt(Lc),Jpe=()=>Tt(t=>t.layout.margin),gn=t=>t.layout.layoutType,lf=()=>Tt(gn),eme=()=>{var t=lf();if(t==="horizontal"||t==="vertical")return t},tme=()=>{var t=lf();return t!==void 0},eE=t=>{var e=rr(),n=xi(),{width:r,height:i}=t,s=oD(),a=r,o=i;return s&&(a=s.width>0?s.width:r,o=s.height>0?s.height:i),M.useEffect(()=>{!n&&ul(a)&&ul(o)&&e(spe({width:a,height:o}))},[e,n,a,o]),null},WW=Symbol.for("immer-nothing"),wz=Symbol.for("immer-draftable"),wa=Symbol.for("immer-state");function Eo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var S0=Object.getPrototypeOf;function mm(t){return!!t&&!!t[wa]}function $h(t){return t?qW(t)||Array.isArray(t)||!!t[wz]||!!t.constructor?.[wz]||vb(t)||nE(t):!1}var nme=Object.prototype.constructor.toString(),Sz=new WeakMap;function qW(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=Sz.get(n);return r===void 0&&(r=Function.toString.call(n),Sz.set(n,r)),r===nme}function F1(t,e,n=!0){tE(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 tE(t){const e=t[wa];return e?e.type_:Array.isArray(t)?1:vb(t)?2:nE(t)?3:0}function q3(t,e){return tE(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function KW(t,e,n){const r=tE(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function rme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function vb(t){return t instanceof Map}function nE(t){return t instanceof Set}function Jd(t){return t.copy_||t.base_}function K3(t,e){if(vb(t))return new Map(t);if(nE(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=qW(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[wa];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(S0(t),r)}else{const r=S0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function uD(t,e=!1){return rE(t)||mm(t)||!$h(t)||(tE(t)>1&&Object.defineProperties(t,{set:gy,add:gy,clear:gy,delete:gy}),Object.freeze(t),e&&Object.values(t).forEach(n=>uD(n,!0))),t}function ime(){Eo(2)}var gy={value:ime};function rE(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var sme={};function Vh(t){const e=sme[t];return e||Eo(0,t),e}var E0;function XW(){return E0}function ame(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ez(t,e){e&&(Vh("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function X3(t){Y3(t),t.drafts_.forEach(ome),t.drafts_=null}function Y3(t){t===E0&&(E0=t.parent_)}function Mz(t){return E0=ame(E0,t)}function ome(t){const e=t[wa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Az(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[wa].modified_&&(X3(e),Eo(4)),$h(t)&&(t=z1(e,t),e.parent_||B1(e,t)),e.patches_&&Vh("Patches").generateReplacementPatches_(n[wa].base_,t,e.patches_,e.inversePatches_)):t=z1(e,n,[]),X3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==WW?t:void 0}function z1(t,e,n){if(rE(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[wa];if(!i)return F1(e,(s,a)=>Tz(t,i,e,s,a,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return B1(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),F1(a,(l,u)=>Tz(t,i,s,l,u,n,o),r),B1(t,s,!1),n&&t.patches_&&Vh("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function Tz(t,e,n,r,i,s,a){if(i==null||typeof i!="object"&&!a)return;const o=rE(i);if(!(o&&!a)){if(mm(i)){const l=s&&e&&e.type_!==3&&!q3(e.assigned_,r)?s.concat(r):void 0,u=z1(t,i,l);if(KW(n,r,u),mm(u))t.canAutoFreeze_=!1;else return}else a&&n.add(i);if($h(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;z1(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(vb(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&B1(t,i)}}}function B1(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&uD(e,n)}function lme(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:XW(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=dD;n&&(i=[r],s=M0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}var dD={get(t,e){if(e===wa)return t;const n=Jd(t);if(!q3(n,e))return cme(t,n,e);const r=n[e];return t.finalized_||!$h(r)?r:r===CT(t.base_,e)?(NT(t),t.copy_[e]=Q3(r,t)):r},has(t,e){return e in Jd(t)},ownKeys(t){return Reflect.ownKeys(Jd(t))},set(t,e,n){const r=YW(Jd(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=CT(Jd(t),e),s=i?.[wa];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(rme(n,i)&&(n!==void 0||q3(t.base_,e)))return!0;NT(t),Z3(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 CT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,NT(t),Z3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Jd(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Eo(11)},getPrototypeOf(t){return S0(t.base_)},setPrototypeOf(){Eo(12)}},M0={};F1(dD,(t,e)=>{M0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});M0.deleteProperty=function(t,e){return M0.set.call(this,t,e,void 0)};M0.set=function(t,e,n){return dD.set.call(this,t[0],e,n,t[0])};function CT(t,e){const n=t[wa];return(n?Jd(n):t)[e]}function cme(t,e,n){const r=YW(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function YW(t,e){if(!(e in t))return;let n=S0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=S0(n)}}function Z3(t){t.modified_||(t.modified_=!0,t.parent_&&Z3(t.parent_))}function NT(t){t.copy_||(t.copy_=K3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var ume=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,...u){return a.produce(l,d=>n.call(this,d,...u))}}typeof n!="function"&&Eo(6),r!==void 0&&typeof r!="function"&&Eo(7);let i;if($h(e)){const s=Mz(this),a=Q3(e,void 0);let o=!0;try{i=n(a),o=!1}finally{o?X3(s):Y3(s)}return Ez(s,r),Az(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===WW&&(i=void 0),this.autoFreeze_&&uD(i,!0),r){const s=[],a=[];Vh("Patches").generateReplacementPatches_(e,i,s,a),r(s,a)}return i}else Eo(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){$h(t)||Eo(8),mm(t)&&(t=dme(t));const e=Mz(this),n=Q3(t,void 0);return n[wa].isManual_=!0,Y3(e),n}finishDraft(t,e){const n=t&&t[wa];(!n||!n.isManual_)&&Eo(9);const{scope_:r}=n;return Ez(r,e),Az(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=Vh("Patches").applyPatches_;return mm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function Q3(t,e){const n=vb(t)?Vh("MapSet").proxyMap_(t,e):nE(t)?Vh("MapSet").proxySet_(t,e):lme(t,e);return(e?e.scope_:XW()).drafts_.push(n),n}function dme(t){return mm(t)||Eo(10,t),ZW(t)}function ZW(t){if(!$h(t)||rE(t))return t;const e=t[wa];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=K3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=K3(t,!0);return F1(n,(i,s)=>{KW(n,i,ZW(s))},r),e&&(e.finalized_=!1),n}var hme=new ume;hme.produce;var fme={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},QW=Zs({name:"legend",initialState:fme,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:fr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ro(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:fr()},removeLegendPayload:{reducer(t,e){var n=Ro(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:fr()}}}),{setLegendSize:Cz,setLegendSettings:pme,addLegendPayload:JW,replaceLegendPayload:eq,removeLegendPayload:tq}=QW.actions,mme=QW.reducer,gme=["contextPayload"];function J3(){return J3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},J3.apply(null,arguments)}function Nz(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 gm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Nz(Object(n),!0).forEach(function(r){xme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Nz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xme(t,e,n){return(e=bme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bme(t){var e=vme(t,"string");return typeof e=="symbol"?e:e+""}function vme(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 yme(t,e){if(t==null)return{};var n,r,i=_me(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 _me(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 wme(t){return t.value}function Sme(t){var{contextPayload:e}=t,n=yme(t,gme),r=Q7(e,t.payloadUniqBy,wme),i=gm(gm({},n),{},{payload:r});return M.isValidElement(t.content)?M.cloneElement(t.content,i):typeof t.content=="function"?M.createElement(t.content,i):M.createElement(ghe,i)}function Eme(t,e,n,r,i,s){var{layout:a,align:o,verticalAlign:l}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&a==="vertical"?u={left:((r||0)-s.width)/2}:u=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(l==="middle"?d={top:((i||0)-s.height)/2}:d=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),gm(gm({},u),d)}function Mme(t){var e=rr();return M.useEffect(()=>{e(pme(t))},[e,t]),null}function Ame(t){var e=rr();return M.useEffect(()=>(e(Cz(t)),()=>{e(Cz({width:0,height:0}))}),[e,t]),null}function Tme(t,e,n,r){return t==="vertical"&&Nt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Cme={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function hD(t){var e=wr(t,Cme),n=ofe(),r=lde(),i=Jpe(),{width:s,height:a,wrapperStyle:o,portal:l}=e,[u,d]=iW([n]),f=lD(),g=cD();if(f==null||g==null)return null;var m=f-(i?.left||0)-(i?.right||0),x=Tme(e.layout,a,s,m),y=l?o:gm(gm({position:"absolute",width:x?.width||s||"auto",height:x?.height||a||"auto"},Eme(o,e,i,f,g,u)),o),v=l??r;if(v==null||n==null)return null;var b=M.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},M.createElement(Mme,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&M.createElement(Ame,{width:u.width,height:u.height}),M.createElement(Sme,J3({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return uc.createPortal(b,v)}hD.displayName="Legend";function ek(){return ek=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},ek.apply(null,arguments)}function kz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kz(Object(n),!0).forEach(function(r){Nme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Nme(t,e,n){return(e=kme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kme(t){var e=Pme(t,"string");return typeof e=="symbol"?e:e+""}function Pme(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 Rme(t){return Array.isArray(t)&&so(t[0])&&so(t[1])?t.join(" ~ "):t}var Dme=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:a,itemSorter:o,wrapperClassName:l,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,m=()=>{if(s&&s.length){var T={padding:0,margin:0},k=(o?BS(s,o):s).map((N,I)=>{if(N.type==="none")return null;var C=N.formatter||a||Rme,{value:D,name:F}=N,j=D,q=F;if(C){var R=C(D,F,N,I,s);if(Array.isArray(R))[j,q]=R;else if(R!=null)j=R;else return null}var W=kT({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},r);return M.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(I),style:W},so(q)?M.createElement("span",{className:"recharts-tooltip-item-name"},q):null,so(q)?M.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,M.createElement("span",{className:"recharts-tooltip-item-value"},j),M.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return M.createElement("ul",{className:"recharts-tooltip-item-list",style:T},k)}return null},x=kT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=kT({margin:0},i),v=!dr(d),b=v?d:"",E=Sn("recharts-default-tooltip",l),S=Sn("recharts-tooltip-label",u);v&&f&&s!==void 0&&s!==null&&(b=f(d,s));var A=g?{role:"status","aria-live":"assertive"}:{};return M.createElement("div",ek({className:E,style:x},A),M.createElement("p",{className:S,style:y},M.isValidElement(b)?b:"".concat(b)),m())},Jg="recharts-tooltip-wrapper",Ome={visibility:"hidden"};function jme(t){var{coordinate:e,translateX:n,translateY:r}=t;return Sn(Jg,{["".concat(Jg,"-right")]:Nt(n)&&e&&Nt(e.x)&&n>=e.x,["".concat(Jg,"-left")]:Nt(n)&&e&&Nt(e.x)&&n<e.x,["".concat(Jg,"-bottom")]:Nt(r)&&e&&Nt(e.y)&&r>=e.y,["".concat(Jg,"-top")]:Nt(r)&&e&&Nt(e.y)&&r<e.y})}function Pz(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:a,tooltipDimension:o,viewBox:l,viewBoxDimension:u}=t;if(s&&Nt(s[r]))return s[r];var d=n[r]-o-(i>0?i:0),f=n[r]+i;if(e[r])return a[r]?d:f;var g=l[r];if(g==null)return 0;if(a[r]){var m=d,x=g;return m<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var y=f+o,v=g+u;return y>v?Math.max(d,g):Math.max(f,g)}function Lme(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 Ime(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:a,useTranslate3d:o,viewBox:l}=t,u,d,f;return a.height>0&&a.width>0&&n?(d=Pz({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.width,viewBox:l,viewBoxDimension:l.width}),f=Pz({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.height,viewBox:l,viewBoxDimension:l.height}),u=Lme({translateX:d,translateY:f,useTranslate3d:o})):u=Ome,{cssProperties:u,cssClasses:jme({translateX:d,translateY:f,coordinate:n})}}function Rz(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 xy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Rz(Object(n),!0).forEach(function(r){tk(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Rz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tk(t,e,n){return(e=Ume(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ume(t){var e=Fme(t,"string");return typeof e=="symbol"?e:e+""}function Fme(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 zme extends M.PureComponent{constructor(){super(...arguments),tk(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),tk(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:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:m,wrapperStyle:x,lastBoundingBox:y,innerRef:v,hasPortalFromProps:b}=this.props,{cssClasses:E,cssProperties:S}=Ime({allowEscapeViewBox:n,coordinate:a,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),A=b?{}:xy(xy({transition:l&&e?"transform ".concat(r,"ms ").concat(i):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=xy(xy({},A),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},x);return M.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:T,ref:v},s)}}var nq=()=>{var t;return(t=Tt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function nk(){return nk=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},nk.apply(null,arguments)}function Dz(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 Oz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Dz(Object(n),!0).forEach(function(r){Bme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Dz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Bme(t,e,n){return(e=Hme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hme(t){var e=$me(t,"string");return typeof e=="symbol"?e:e+""}function $me(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var jz={curveBasisClosed:Tde,curveBasisOpen:Cde,curveBasis:Ade,curveBumpX:hde,curveBumpY:fde,curveLinearClosed:Nde,curveLinear:FS,curveMonotoneX:kde,curveMonotoneY:Pde,curveNatural:Rde,curveStep:Dde,curveStepAfter:jde,curveStepBefore:Ode},H1=t=>Bn(t.x)&&Bn(t.y),Lz=t=>t.base!=null&&H1(t.base)&&H1(t),ex=t=>t.x,tx=t=>t.y,Vme=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(db(t));return(n==="curveMonotone"||n==="curveBump")&&e?jz["".concat(n).concat(e==="vertical"?"Y":"X")]:jz[n]||FS},Gme=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,a=Vme(e,i),o=s?n.filter(H1):n,l;if(Array.isArray(r)){var u=n.map((m,x)=>Oz(Oz({},m),{},{base:r[x]}));i==="vertical"?l=cy().y(tx).x1(ex).x0(m=>m.base.x):l=cy().x(ex).y1(tx).y0(m=>m.base.y);var d=l.defined(Lz).curve(a),f=s?u.filter(Lz):u;return d(f)}i==="vertical"&&Nt(r)?l=cy().y(tx).x1(ex).x0(r):Nt(r)?l=cy().x(ex).y1(tx).y0(r):l=T7().x(ex).y(tx);var g=l.defined(H1).curve(a);return g(o)},Yp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?Gme(t):r;return M.createElement("path",nk({},Ts(t),XR(t),{className:Sn("recharts-curve",e),d:s===null?void 0:s,ref:i}))},Wme=["x","y","top","left","width","height","className"];function rk(){return rk=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},rk.apply(null,arguments)}function Iz(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 qme(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Iz(Object(n),!0).forEach(function(r){Kme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Iz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Kme(t,e,n){return(e=Xme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Xme(t){var e=Yme(t,"string");return typeof e=="symbol"?e:e+""}function Yme(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 Zme(t,e){if(t==null)return{};var n,r,i=Qme(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 Qme(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 Jme=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),ege=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:a=0,className:o}=t,l=Zme(t,Wme),u=qme({x:e,y:n,top:r,left:i,width:s,height:a},l);return!Nt(e)||!Nt(n)||!Nt(s)||!Nt(a)||!Nt(r)||!Nt(i)?null:M.createElement("path",rk({},es(u),{className:Sn("recharts-cross",o),d:Jme(e,n,s,a,r,i)}))};function tge(t,e,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-i:n.left+.5,y:t==="horizontal"?n.top+.5:e.y-i,width:t==="horizontal"?r:n.width-1,height:t==="horizontal"?n.height-1:r}}function Uz(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 Fz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Uz(Object(n),!0).forEach(function(r){nge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Uz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nge(t,e,n){return(e=rge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rge(t){var e=ige(t,"string");return typeof e=="symbol"?e:e+""}function ige(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 sge=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),rq=(t,e,n)=>t.map(r=>"".concat(sge(r)," ").concat(e,"ms ").concat(n)).join(","),age=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),A0=(t,e)=>Object.keys(e).reduce((n,r)=>Fz(Fz({},n),{},{[r]:t(r,e[r])}),{});function zz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ci(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zz(Object(n),!0).forEach(function(r){oge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oge(t,e,n){return(e=lge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lge(t){var e=cge(t,"string");return typeof e=="symbol"?e:e+""}function cge(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 $1=(t,e,n)=>t+(e-t)*n,ik=t=>{var{from:e,to:n}=t;return e!==n},iq=(t,e,n)=>{var r=A0((i,s)=>{if(ik(s)){var[a,o]=t(s.from,s.to,s.velocity);return ci(ci({},s),{},{from:a,velocity:o})}return s},e);return n<1?A0((i,s)=>ik(s)?ci(ci({},s),{},{velocity:$1(s.velocity,r[i].velocity,n),from:$1(s.from,r[i].from,n)}):s,e):iq(t,r,n-1)};function uge(t,e,n,r,i,s){var a,o=r.reduce((g,m)=>ci(ci({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),l=()=>A0((g,m)=>m.from,o),u=()=>!Object.values(o).filter(ik).length,d=null,f=g=>{a||(a=g);var m=g-a,x=m/n.dt;o=iq(n,o,x),i(ci(ci(ci({},t),e),l())),a=g,u()||(d=s.setTimeout(f))};return()=>(d=s.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function dge(t,e,n,r,i,s,a){var o=null,l=i.reduce((f,g)=>ci(ci({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,m=A0((y,v)=>$1(...v,n(g)),l);if(s(ci(ci(ci({},t),e),m)),g<1)o=a.setTimeout(d);else{var x=A0((y,v)=>$1(...v,n(1)),l);s(ci(ci(ci({},t),e),x))}};return()=>(o=a.setTimeout(d),()=>{var f;(f=o)===null||f===void 0||f()})}const hge=(t,e,n,r,i,s)=>{var a=age(t,e);return n==null?()=>(i(ci(ci({},t),e)),()=>{}):n.isStepper===!0?uge(t,e,n,a,i,s):dge(t,e,n,r,a,i,s)};var V1=1e-4,sq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],aq=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),Bz=(t,e)=>n=>{var r=sq(t,e);return aq(r,n)},fge=(t,e)=>n=>{var r=sq(t,e),i=[...r.map((s,a)=>s*a).slice(1),0];return aq(i,n)},pge=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]},mge=(t,e,n,r)=>{var i=Bz(t,n),s=Bz(e,r),a=fge(t,n),o=u=>u>1?1:u<0?0:u,l=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var m=i(f)-d,x=a(f);if(Math.abs(m-d)<V1||x<V1)return s(f);f=o(f-m/x)}return s(f)};return l.isStepper=!1,l},Hz=function(){return mge(...pge(...arguments))},gge=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 u=-(a-o)*n,d=l*r,f=l+(u-d)*i/1e3,g=l*i/1e3+a;return Math.abs(g-o)<V1&&Math.abs(f)<V1?[o,0]:[g,f]};return s.isStepper=!0,s.dt=i,s},xge=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return Hz(t);case"spring":return gge();default:if(t.split("(")[0]==="cubic-bezier")return Hz(t)}return typeof t=="function"?t:null};function bge(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,...u]=o;if(typeof l=="number"){i=t.setTimeout(s.bind(null,u),l);return}s(l),i=t.setTimeout(s.bind(null,u));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 vge{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 yge(){return bge(new vge)}var _ge=M.createContext(yge);function wge(t,e){var n=M.useContext(_ge);return M.useMemo(()=>e??n(t),[t,e,n])}var Sge=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Hm={devToolsEnabled:!1,isSsr:Sge()},Ege={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},$z={t:0},PT={t:1};function $m(t){var e=wr(t,Ege),{isActive:n,canBegin:r,duration:i,easing:s,begin:a,onAnimationEnd:o,onAnimationStart:l,children:u}=e,d=n==="auto"?!Hm.isSsr:n,f=wge(e.animationId,e.animationManager),[g,m]=M.useState(d?$z:PT),x=M.useRef(null);return M.useEffect(()=>{d||m(PT)},[d]),M.useEffect(()=>{if(!d||!r)return hb;var y=hge($z,PT,xge(s),i,m,f.getTimeoutController()),v=()=>{x.current=y()};return f.start([l,a,v,i,o]),()=>{f.stop(),x.current&&x.current(),o()}},[d,r,i,s,a,l,o,f]),u(g.t)}function Vm(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=M.useRef(v0(e)),r=M.useRef(t);return r.current!==t&&(n.current=v0(e),r.current=t),n.current}var Mge=["radius"],Age=["radius"];function Vz(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 Gz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Vz(Object(n),!0).forEach(function(r){Tge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Vz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Tge(t,e,n){return(e=Cge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cge(t){var e=Nge(t,"string");return typeof e=="symbol"?e:e+""}function Nge(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 G1(){return G1=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},G1.apply(null,arguments)}function Wz(t,e){if(t==null)return{};var n,r,i=kge(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 kge(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 qz=(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,u;if(s>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>s?s:i[f];u="M".concat(t,",").concat(e+a*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(l,",").concat(t+o*d[0],",").concat(e)),u+="L ".concat(t+n-o*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(l,`,
- `).concat(t+n,",").concat(e+a*d[1])),u+="L ".concat(t+n,",").concat(e+r-a*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(l,`,
- `).concat(t+n-o*d[2],",").concat(e+r)),u+="L ".concat(t+o*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(l,`,
- `).concat(t,",").concat(e+r-a*d[3])),u+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);u="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 u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},Kz={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},oq=t=>{var e=wr(t,Kz),n=M.useRef(null),[r,i]=M.useState(-1);M.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:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:y}=e,v=M.useRef(o),b=M.useRef(l),E=M.useRef(s),S=M.useRef(a),A=M.useMemo(()=>({x:s,y:a,width:o,height:l,radius:u}),[s,a,o,l,u]),T=Vm(A,"rectangle-");if(s!==+s||a!==+a||o!==+o||l!==+l||o===0||l===0)return null;var k=Sn("recharts-rectangle",d);if(!y){var N=es(e),{radius:I}=N,C=Wz(N,Mge);return M.createElement("path",G1({},C,{radius:typeof u=="number"?u:void 0,className:k,d:qz(s,a,o,l,u)}))}var D=v.current,F=b.current,j=E.current,q=S.current,R="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=rq(["strokeDasharray"],g,typeof f=="string"?f:Kz.animationEasing);return M.createElement($m,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:y,begin:m},V=>{var te=Rn(D,o,V),Y=Rn(F,l,V),Z=Rn(j,s,V),U=Rn(q,a,V);n.current&&(v.current=te,b.current=Y,E.current=Z,S.current=U);var z;x?V>0?z={transition:K,strokeDasharray:W}:z={strokeDasharray:R}:z={strokeDasharray:W};var ee=es(e),{radius:ae}=ee,fe=Wz(ee,Age);return M.createElement("path",G1({},fe,{radius:typeof u=="number"?u:void 0,className:k,d:qz(Z,U,te,Y,u),ref:n,style:Gz(Gz({},z),e.style)}))})};function Xz(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 Yz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Xz(Object(n),!0).forEach(function(r){Pge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Xz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pge(t,e,n){return(e=Rge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rge(t){var e=Dge(t,"string");return typeof e=="symbol"?e:e+""}function Dge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var W1=Math.PI/180,Oge=t=>t*180/Math.PI,Zr=(t,e,n,r)=>({x:t+Math.cos(-W1*r)*n,y:e+Math.sin(-W1*r)*n}),lq=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},jge=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},Lge=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,a=jge({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:Oge(l),angleInRadian:l}},Ige=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}},Uge=(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},Fge=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=Lge({x:n,y:r},e),{innerRadius:a,outerRadius:o}=e;if(i<a||i>o||i===0)return null;var{startAngle:l,endAngle:u}=Ige(e),d=s,f;if(l<=u){for(;d>u;)d-=360;for(;d<l;)d+=360;f=d>=l&&d<=u}else{for(;d>l;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=l}return f?Yz(Yz({},e),{},{radius:i,angle:Uge(d,e)}):null};function cq(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,a=Zr(e,n,r,i),o=Zr(e,n,r,s);return{points:[a,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function sk(){return sk=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},sk.apply(null,arguments)}var zge=(t,e)=>{var n=Oi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},by=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:a,cornerRadius:o,cornerIsExternal:l}=t,u=o*(a?1:-1)+r,d=Math.asin(o/u)/W1,f=l?i:i+s*d,g=Zr(e,n,u,f),m=Zr(e,n,r,f),x=l?i-s*d:i,y=Zr(e,n,u*Math.cos(d*W1),x);return{center:g,circleTangency:m,lineTangency:y,theta:d}},uq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:a}=t,o=zge(s,a),l=s+o,u=Zr(e,n,i,s),d=Zr(e,n,i,l),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(s>l),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var g=Zr(e,n,r,s),m=Zr(e,n,r,l);f+="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 f+="L ".concat(e,",").concat(n," Z");return f},Bge=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:a,cornerIsExternal:o,startAngle:l,endAngle:u}=t,d=Oi(u-l),{circleTangency:f,lineTangency:g,theta:m}=by({cx:e,cy:n,radius:i,angle:l,sign:d,cornerRadius:s,cornerIsExternal:o}),{circleTangency:x,lineTangency:y,theta:v}=by({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:o}),b=o?Math.abs(l-u):Math.abs(l-u)-m-v;if(b<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
- `):uq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:l,endAngle:u});var E="M ".concat(g.x,",").concat(g.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(b>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
- `);if(r>0){var{circleTangency:S,lineTangency:A,theta:T}=by({cx:e,cy:n,radius:r,angle:l,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),{circleTangency:k,lineTangency:N,theta:I}=by({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),C=o?Math.abs(l-u):Math.abs(l-u)-T-I;if(C<0&&s===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(N.x,",").concat(N.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(k.x,",").concat(k.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(C>180),",").concat(+(d>0),",").concat(S.x,",").concat(S.y,`
- A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},Hge={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},dq=t=>{var e=wr(t,Hge),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:u,endAngle:d,className:f}=e;if(s<i||u===d)return null;var g=Sn("recharts-sector",f),m=s-i,x=ps(a,m,0,!0),y;return x>0&&Math.abs(u-d)<360?y=Bge({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:u,endAngle:d}):y=uq({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),M.createElement("path",sk({},es(e),{className:g,d:y}))};function $ge(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(H7(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:a,angle:o}=e,l=Zr(r,i,s,o),u=Zr(r,i,a,o);return[{x:l.x,y:l.y},{x:u.x,y:u.y}]}return cq(e)}}var RT={},DT={},OT={},Zz;function Vge(){return Zz||(Zz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(OT)),OT}var Qz;function Gge(){return Qz||(Qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Vge();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})(DT)),DT}var Jz;function Wge(){return Jz||(Jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nW(),n=Gge();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 u=0;u<o;u++)l[u]=i,i+=a;return l}t.range=r})(RT)),RT}var jT,eB;function qge(){return eB||(eB=1,jT=Wge().range),jT}var Kge=qge();const hq=lo(Kge);function Gu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Xge(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function fD(t){let e,n,r;t.length!==2?(e=Gu,n=(o,l)=>Gu(t(o),l),r=(o,l)=>t(o)-l):(e=t===Gu||t===Xge?t:Yge,n=t,r=t);function i(o,l,u=0,d=o.length){if(u<d){if(e(l,l)!==0)return d;do{const f=u+d>>>1;n(o[f],l)<0?u=f+1:d=f}while(u<d)}return u}function s(o,l,u=0,d=o.length){if(u<d){if(e(l,l)!==0)return d;do{const f=u+d>>>1;n(o[f],l)<=0?u=f+1:d=f}while(u<d)}return u}function a(o,l,u=0,d=o.length){const f=i(o,l,u,d-1);return f>u&&r(o[f-1],l)>-r(o[f],l)?f-1:f}return{left:i,center:a,right:s}}function Yge(){return 0}function fq(t){return t===null?NaN:+t}function*Zge(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const Qge=fD(Gu),yb=Qge.right;fD(fq).center;class tB extends Map{constructor(e,n=txe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(nB(this,e))}has(e){return super.has(nB(this,e))}set(e,n){return super.set(Jge(this,e),n)}delete(e){return super.delete(exe(this,e))}}function nB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Jge({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function exe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function txe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function nxe(t=Gu){if(t===Gu)return pq;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 pq(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const rxe=Math.sqrt(50),ixe=Math.sqrt(10),sxe=Math.sqrt(2);function q1(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>=rxe?10:s>=ixe?5:s>=sxe?2:1;let o,l,u;return i<0?(u=Math.pow(10,-i)/a,o=Math.round(t*u),l=Math.round(e*u),o/u<t&&++o,l/u>e&&--l,u=-u):(u=Math.pow(10,i)*a,o=Math.round(t/u),l=Math.round(e/u),o*u<t&&++o,l*u>e&&--l),l<o&&.5<=n&&n<2?q1(t,e,n*2):[o,l,u]}function ak(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?q1(e,t,n):q1(t,e,n);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let u=0;u<o;++u)l[u]=(s-u)/-a;else for(let u=0;u<o;++u)l[u]=(s-u)*a;else if(a<0)for(let u=0;u<o;++u)l[u]=(i+u)/-a;else for(let u=0;u<o;++u)l[u]=(i+u)*a;return l}function ok(t,e,n){return e=+e,t=+t,n=+n,q1(t,e,n)[2]}function lk(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?ok(e,t,n):ok(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function rB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function iB(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function mq(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?pq:nxe(i);r>n;){if(r-n>600){const l=r-n+1,u=e-n+1,d=Math.log(l),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(l-f)/l)*(u-l/2<0?-1:1),m=Math.max(n,Math.floor(e-u*f/l+g)),x=Math.min(r,Math.floor(e+(l-u)*f/l+g));mq(t,e,m,x,i)}const s=t[e];let a=n,o=r;for(nx(t,n,e),i(t[r],s)>0&&nx(t,n,r);a<o;){for(nx(t,a,o),++a,--o;i(t[a],s)<0;)++a;for(;i(t[o],s)>0;)--o}i(t[n],s)===0?nx(t,n,o):(++o,nx(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function nx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function axe(t,e,n){if(t=Float64Array.from(Zge(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return iB(t);if(e>=1)return rB(t);var r,i=(r-1)*e,s=Math.floor(i),a=rB(mq(t,s).subarray(0,s+1)),o=iB(t.subarray(s+1));return a+(o-a)*(i-s)}}function oxe(t,e,n=fq){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 lxe(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 co(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Ic(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 ck=Symbol("implicit");function pD(){var t=new tB,e=[],n=[],r=ck;function i(s){let a=t.get(s);if(a===void 0){if(r!==ck)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 tB;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 pD(e,n).unknown(r)},co.apply(i,arguments),i}function mD(){var t=pD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,a,o=!1,l=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,m=i<r,x=m?i:r,y=m?r:i;s=(y-x)/Math.max(1,g-l+u*2),o&&(s=Math.floor(s)),x+=(y-x-s*(g-l))*d,a=s*(1-l),o&&(x=Math.round(x),a=Math.round(a));var v=lxe(g).map(function(b){return x+s*b});return n(m?v.reverse():v)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,o=!0,f()},t.bandwidth=function(){return a},t.step=function(){return s},t.round=function(g){return arguments.length?(o=!!g,f()):o},t.padding=function(g){return arguments.length?(l=Math.min(1,u=+g),f()):l},t.paddingInner=function(g){return arguments.length?(l=Math.min(1,g),f()):l},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return mD(e(),[r,i]).round(o).paddingInner(l).paddingOuter(u).align(d)},co.apply(f(),arguments)}function gq(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return gq(e())},t}function cxe(){return gq(mD.apply(null,arguments).paddingInner(1))}function gD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function xq(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function _b(){}var T0=.7,K1=1/T0,Zp="\\s*([+-]?\\d+)\\s*",C0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ol="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",uxe=/^#([0-9a-f]{3,8})$/,dxe=new RegExp(`^rgb\\(${Zp},${Zp},${Zp}\\)$`),hxe=new RegExp(`^rgb\\(${ol},${ol},${ol}\\)$`),fxe=new RegExp(`^rgba\\(${Zp},${Zp},${Zp},${C0}\\)$`),pxe=new RegExp(`^rgba\\(${ol},${ol},${ol},${C0}\\)$`),mxe=new RegExp(`^hsl\\(${C0},${ol},${ol}\\)$`),gxe=new RegExp(`^hsla\\(${C0},${ol},${ol},${C0}\\)$`),sB={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};gD(_b,N0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:aB,formatHex:aB,formatHex8:xxe,formatHsl:bxe,formatRgb:oB,toString:oB});function aB(){return this.rgb().formatHex()}function xxe(){return this.rgb().formatHex8()}function bxe(){return bq(this).formatHsl()}function oB(){return this.rgb().formatRgb()}function N0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=uxe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?lB(e):n===3?new Vs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?vy(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?vy(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=dxe.exec(t))?new Vs(e[1],e[2],e[3],1):(e=hxe.exec(t))?new Vs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=fxe.exec(t))?vy(e[1],e[2],e[3],e[4]):(e=pxe.exec(t))?vy(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=mxe.exec(t))?dB(e[1],e[2]/100,e[3]/100,1):(e=gxe.exec(t))?dB(e[1],e[2]/100,e[3]/100,e[4]):sB.hasOwnProperty(t)?lB(sB[t]):t==="transparent"?new Vs(NaN,NaN,NaN,0):null}function lB(t){return new Vs(t>>16&255,t>>8&255,t&255,1)}function vy(t,e,n,r){return r<=0&&(t=e=n=NaN),new Vs(t,e,n,r)}function vxe(t){return t instanceof _b||(t=N0(t)),t?(t=t.rgb(),new Vs(t.r,t.g,t.b,t.opacity)):new Vs}function uk(t,e,n,r){return arguments.length===1?vxe(t):new Vs(t,e,n,r??1)}function Vs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}gD(Vs,uk,xq(_b,{brighter(t){return t=t==null?K1:Math.pow(K1,t),new Vs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?T0:Math.pow(T0,t),new Vs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Vs(wh(this.r),wh(this.g),wh(this.b),X1(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:cB,formatHex:cB,formatHex8:yxe,formatRgb:uB,toString:uB}));function cB(){return`#${ch(this.r)}${ch(this.g)}${ch(this.b)}`}function yxe(){return`#${ch(this.r)}${ch(this.g)}${ch(this.b)}${ch((isNaN(this.opacity)?1:this.opacity)*255)}`}function uB(){const t=X1(this.opacity);return`${t===1?"rgb(":"rgba("}${wh(this.r)}, ${wh(this.g)}, ${wh(this.b)}${t===1?")":`, ${t})`}`}function X1(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function wh(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ch(t){return t=wh(t),(t<16?"0":"")+t.toString(16)}function dB(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Mo(t,e,n,r)}function bq(t){if(t instanceof Mo)return new Mo(t.h,t.s,t.l,t.opacity);if(t instanceof _b||(t=N0(t)),!t)return new Mo;if(t instanceof Mo)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 Mo(a,o,l,t.opacity)}function _xe(t,e,n,r){return arguments.length===1?bq(t):new Mo(t,e,n,r??1)}function Mo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}gD(Mo,_xe,xq(_b,{brighter(t){return t=t==null?K1:Math.pow(K1,t),new Mo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?T0:Math.pow(T0,t),new Mo(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 Vs(LT(t>=240?t-240:t+120,i,r),LT(t,i,r),LT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Mo(hB(this.h),yy(this.s),yy(this.l),X1(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=X1(this.opacity);return`${t===1?"hsl(":"hsla("}${hB(this.h)}, ${yy(this.s)*100}%, ${yy(this.l)*100}%${t===1?")":`, ${t})`}`}}));function hB(t){return t=(t||0)%360,t<0?t+360:t}function yy(t){return Math.max(0,Math.min(1,t||0))}function LT(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 xD=t=>()=>t;function wxe(t,e){return function(n){return t+n*e}}function Sxe(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 Exe(t){return(t=+t)==1?vq:function(e,n){return n-e?Sxe(e,n,t):xD(isNaN(e)?n:e)}}function vq(t,e){var n=e-t;return n?wxe(t,n):xD(isNaN(t)?e:t)}const fB=(function t(e){var n=Exe(e);function r(i,s){var a=n((i=uk(i)).r,(s=uk(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=vq(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function Mxe(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 Axe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Txe(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]=Gm(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 Cxe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Y1(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Nxe(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]=Gm(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var dk=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,IT=new RegExp(dk.source,"g");function kxe(t){return function(){return t}}function Pxe(t){return function(e){return t(e)+""}}function Rxe(t,e){var n=dk.lastIndex=IT.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(t=t+"",e=e+"";(r=dk.exec(t))&&(i=IT.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:Y1(r,i)})),n=IT.lastIndex;return n<e.length&&(s=e.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?Pxe(l[0].x):kxe(e):(e=l.length,function(u){for(var d=0,f;d<e;++d)o[(f=l[d]).i]=f.x(u);return o.join("")})}function Gm(t,e){var n=typeof e,r;return e==null||n==="boolean"?xD(e):(n==="number"?Y1:n==="string"?(r=N0(e))?(e=r,fB):Rxe:e instanceof N0?fB:e instanceof Date?Cxe:Axe(e)?Mxe:Array.isArray(e)?Txe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Nxe:Y1)(t,e)}function bD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Dxe(t,e){e===void 0&&(e=t,t=Gm);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 Oxe(t){return function(){return t}}function Z1(t){return+t}var pB=[0,1];function Es(t){return t}function hk(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Oxe(isNaN(e)?NaN:.5)}function jxe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Lxe(t,e,n){var r=t[0],i=t[1],s=e[0],a=e[1];return i<r?(r=hk(i,r),s=n(a,s)):(r=hk(r,i),s=n(s,a)),function(o){return s(r(o))}}function Ixe(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]=hk(t[a],t[a+1]),s[a]=n(e[a],e[a+1]);return function(o){var l=yb(t,o,1,r)-1;return s[l](i[l](o))}}function wb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function iE(){var t=pB,e=pB,n=Gm,r,i,s,a=Es,o,l,u;function d(){var g=Math.min(t.length,e.length);return a!==Es&&(a=jxe(t[0],t[g-1])),o=g>2?Ixe:Lxe,l=u=null,f}function f(g){return g==null||isNaN(g=+g)?s:(l||(l=o(t.map(r),e,n)))(r(a(g)))}return f.invert=function(g){return a(i((u||(u=o(e,t.map(r),Y1)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,Z1),d()):t.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),n=bD,d()},f.clamp=function(g){return arguments.length?(a=g?!0:Es,d()):a!==Es},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(s=g,f):s},function(g,m){return r=g,i=m,d()}}function vD(){return iE()(Es,Es)}function Uxe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Q1(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 xm(t){return t=Q1(Math.abs(t)),t?t[1]:NaN}function Fxe(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 zxe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Bxe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function k0(t){if(!(e=Bxe.exec(t)))throw new Error("invalid format: "+t);var e;return new yD({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]})}k0.prototype=yD.prototype;function yD(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+""}yD.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 Hxe(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 yq;function $xe(t,e){var n=Q1(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(yq=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")+Q1(t,Math.max(0,e+s-1))[0]}function mB(t,e){var n=Q1(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 gB={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Uxe,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)=>mB(t*100,e),r:mB,s:$xe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function xB(t){return t}var bB=Array.prototype.map,vB=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Vxe(t){var e=t.grouping===void 0||t.thousands===void 0?xB:Fxe(bB.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?xB:zxe(bB.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 u(f){f=k0(f);var g=f.fill,m=f.align,x=f.sign,y=f.symbol,v=f.zero,b=f.width,E=f.comma,S=f.precision,A=f.trim,T=f.type;T==="n"?(E=!0,T="g"):gB[T]||(S===void 0&&(S=12),A=!0,T="g"),(v||g==="0"&&m==="=")&&(v=!0,g="0",m="=");var k=y==="$"?n:y==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",N=y==="$"?r:/[%p]/.test(T)?a:"",I=gB[T],C=/[defgprs%]/.test(T);S=S===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,S)):Math.max(0,Math.min(20,S));function D(F){var j=k,q=N,R,W,K;if(T==="c")q=I(F)+q,F="";else{F=+F;var V=F<0||1/F<0;if(F=isNaN(F)?l:I(Math.abs(F),S),A&&(F=Hxe(F)),V&&+F==0&&x!=="+"&&(V=!1),j=(V?x==="("?x:o:x==="-"||x==="("?"":x)+j,q=(T==="s"?vB[8+yq/3]:"")+q+(V&&x==="("?")":""),C){for(R=-1,W=F.length;++R<W;)if(K=F.charCodeAt(R),48>K||K>57){q=(K===46?i+F.slice(R+1):F.slice(R))+q,F=F.slice(0,R);break}}}E&&!v&&(F=e(F,1/0));var te=j.length+F.length+q.length,Y=te<b?new Array(b-te+1).join(g):"";switch(E&&v&&(F=e(Y+F,Y.length?b-q.length:1/0),Y=""),m){case"<":F=j+F+q+Y;break;case"=":F=j+Y+F+q;break;case"^":F=Y.slice(0,te=Y.length>>1)+j+F+q+Y.slice(te);break;default:F=Y+j+F+q;break}return s(F)}return D.toString=function(){return f+""},D}function d(f,g){var m=u((f=k0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(xm(g)/3)))*3,y=Math.pow(10,-x),v=vB[8+x/3];return function(b){return m(y*b)+v}}return{format:u,formatPrefix:d}}var _y,_D,_q;Gxe({thousands:",",grouping:[3],currency:["$",""]});function Gxe(t){return _y=Vxe(t),_D=_y.format,_q=_y.formatPrefix,_y}function Wxe(t){return Math.max(0,-xm(Math.abs(t)))}function qxe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(xm(e)/3)))*3-xm(Math.abs(t)))}function Kxe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,xm(e)-xm(t))+1}function wq(t,e,n,r){var i=lk(t,e,n),s;switch(r=k0(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=qxe(i,a))&&(r.precision=s),_q(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=Kxe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=Wxe(i))&&(r.precision=s-(r.type==="%")*2);break}}return _D(r)}function bd(t){var e=t.domain;return t.ticks=function(n){var r=e();return ak(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return wq(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,u,d=10;for(o<a&&(u=a,a=o,o=u,u=i,i=s,s=u);d-- >0;){if(u=ok(a,o,n),u===l)return r[i]=a,r[s]=o,e(r);if(u>0)a=Math.floor(a/u)*u,o=Math.ceil(o/u)*u;else if(u<0)a=Math.ceil(a*u)/u,o=Math.floor(o*u)/u;else break;l=u}return t},t}function Sq(){var t=vD();return t.copy=function(){return wb(t,Sq())},co.apply(t,arguments),bd(t)}function Eq(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,Z1),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return Eq(t).unknown(e)},t=arguments.length?Array.from(t,Z1):[0,1],bd(n)}function Mq(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 yB(t){return Math.log(t)}function _B(t){return Math.exp(t)}function Xxe(t){return-Math.log(-t)}function Yxe(t){return-Math.exp(-t)}function Zxe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Qxe(t){return t===10?Zxe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Jxe(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 wB(t){return(e,n)=>-t(-e,n)}function wD(t){const e=t(yB,_B),n=e.domain;let r=10,i,s;function a(){return i=Jxe(r),s=Qxe(r),n()[0]<0?(i=wB(i),s=wB(s),t(Xxe,Yxe)):t(yB,_B),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 u=l[0],d=l[l.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),m=i(d),x,y;const v=o==null?10:+o;let b=[];if(!(r%1)&&m-g<v){if(g=Math.floor(g),m=Math.ceil(m),u>0){for(;g<=m;++g)for(x=1;x<r;++x)if(y=g<0?x/s(-g):x*s(g),!(y<u)){if(y>d)break;b.push(y)}}else for(;g<=m;++g)for(x=r-1;x>=1;--x)if(y=g>0?x/s(-g):x*s(g),!(y<u)){if(y>d)break;b.push(y)}b.length*2<v&&(b=ak(u,d,v))}else b=ak(g,m,Math.min(m-g,v)).map(s);return f?b.reverse():b},e.tickFormat=(o,l)=>{if(o==null&&(o=10),l==null&&(l=r===10?"s":","),typeof l!="function"&&(!(r%1)&&(l=k0(l)).precision==null&&(l.trim=!0),l=_D(l)),o===1/0)return l;const u=Math.max(1,r*o/e.ticks().length);return d=>{let f=d/s(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?l(d):""}},e.nice=()=>n(Mq(n(),{floor:o=>s(Math.floor(i(o))),ceil:o=>s(Math.ceil(i(o)))})),e}function Aq(){const t=wD(iE()).domain([1,10]);return t.copy=()=>wb(t,Aq()).base(t.base()),co.apply(t,arguments),t}function SB(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function EB(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function SD(t){var e=1,n=t(SB(e),EB(e));return n.constant=function(r){return arguments.length?t(SB(e=+r),EB(e)):e},bd(n)}function Tq(){var t=SD(iE());return t.copy=function(){return wb(t,Tq()).constant(t.constant())},co.apply(t,arguments)}function MB(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function e0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function t0e(t){return t<0?-t*t:t*t}function ED(t){var e=t(Es,Es),n=1;function r(){return n===1?t(Es,Es):n===.5?t(e0e,t0e):t(MB(n),MB(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},bd(e)}function MD(){var t=ED(iE());return t.copy=function(){return wb(t,MD()).exponent(t.exponent())},co.apply(t,arguments),t}function n0e(){return MD.apply(null,arguments).exponent(.5)}function AB(t){return Math.sign(t)*t*t}function r0e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Cq(){var t=vD(),e=[0,1],n=!1,r;function i(s){var a=r0e(t(s));return isNaN(a)?r:n?Math.round(a):a}return i.invert=function(s){return t.invert(AB(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,Z1)).map(AB)),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 Cq(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},co.apply(i,arguments),bd(i)}function Nq(){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]=oxe(t,a/o);return s}function s(a){return a==null||isNaN(a=+a)?r:e[yb(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(Gu),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 Nq().domain(t).range(e).unknown(r)},co.apply(s,arguments)}function kq(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function a(l){return l!=null&&l<=l?i[yb(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 u=i.indexOf(l);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},a.unknown=function(l){return arguments.length&&(s=l),a},a.thresholds=function(){return r.slice()},a.copy=function(){return kq().domain([t,e]).range(i).unknown(s)},co.apply(bd(a),arguments)}function Pq(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[yb(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 Pq().domain(t).range(e).unknown(n)},co.apply(i,arguments)}const UT=new Date,FT=new Date;function bi(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 u;do l.push(u=new Date(+s)),e(s,o),t(s);while(u<s&&s<a);return l},i.filter=s=>bi(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)=>(UT.setTime(+s),FT.setTime(+a),t(UT),t(FT),Math.floor(n(UT,FT))),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 J1=bi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);J1.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?bi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):J1);J1.range;const dc=1e3,Qa=dc*60,hc=Qa*60,Cc=hc*24,AD=Cc*7,TB=Cc*30,zT=Cc*365,uh=bi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*dc)},(t,e)=>(e-t)/dc,t=>t.getUTCSeconds());uh.range;const TD=bi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*dc)},(t,e)=>{t.setTime(+t+e*Qa)},(t,e)=>(e-t)/Qa,t=>t.getMinutes());TD.range;const CD=bi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Qa)},(t,e)=>(e-t)/Qa,t=>t.getUTCMinutes());CD.range;const ND=bi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*dc-t.getMinutes()*Qa)},(t,e)=>{t.setTime(+t+e*hc)},(t,e)=>(e-t)/hc,t=>t.getHours());ND.range;const kD=bi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*hc)},(t,e)=>(e-t)/hc,t=>t.getUTCHours());kD.range;const Sb=bi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Qa)/Cc,t=>t.getDate()-1);Sb.range;const sE=bi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Cc,t=>t.getUTCDate()-1);sE.range;const Rq=bi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Cc,t=>Math.floor(t/Cc));Rq.range;function cf(t){return bi(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())*Qa)/AD)}const aE=cf(0),ew=cf(1),i0e=cf(2),s0e=cf(3),bm=cf(4),a0e=cf(5),o0e=cf(6);aE.range;ew.range;i0e.range;s0e.range;bm.range;a0e.range;o0e.range;function uf(t){return bi(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)/AD)}const oE=uf(0),tw=uf(1),l0e=uf(2),c0e=uf(3),vm=uf(4),u0e=uf(5),d0e=uf(6);oE.range;tw.range;l0e.range;c0e.range;vm.range;u0e.range;d0e.range;const PD=bi(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());PD.range;const RD=bi(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());RD.range;const Nc=bi(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());Nc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:bi(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)});Nc.range;const kc=bi(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());kc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:bi(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)});kc.range;function Dq(t,e,n,r,i,s){const a=[[uh,1,dc],[uh,5,5*dc],[uh,15,15*dc],[uh,30,30*dc],[s,1,Qa],[s,5,5*Qa],[s,15,15*Qa],[s,30,30*Qa],[i,1,hc],[i,3,3*hc],[i,6,6*hc],[i,12,12*hc],[r,1,Cc],[r,2,2*Cc],[n,1,AD],[e,1,TB],[e,3,3*TB],[t,1,zT]];function o(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const m=f&&typeof f.range=="function"?f:l(u,d,f),x=m?m.range(u,+d+1):[];return g?x.reverse():x}function l(u,d,f){const g=Math.abs(d-u)/f,m=fD(([,,v])=>v).right(a,g);if(m===a.length)return t.every(lk(u/zT,d/zT,f));if(m===0)return J1.every(Math.max(lk(u,d,f),1));const[x,y]=a[g/a[m-1][2]<a[m][2]/g?m-1:m];return x.every(y)}return[o,l]}const[h0e,f0e]=Dq(kc,RD,oE,Rq,kD,CD),[p0e,m0e]=Dq(Nc,PD,aE,Sb,ND,TD);function BT(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 HT(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 rx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function g0e(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,u=ix(i),d=sx(i),f=ix(s),g=sx(s),m=ix(a),x=sx(a),y=ix(o),v=sx(o),b=ix(l),E=sx(l),S={a:V,A:te,b:Y,B:Z,c:null,d:DB,e:DB,f:F0e,g:X0e,G:Z0e,H:L0e,I:I0e,j:U0e,L:Oq,m:z0e,M:B0e,p:U,q:z,Q:LB,s:IB,S:H0e,u:$0e,U:V0e,V:G0e,w:W0e,W:q0e,x:null,X:null,y:K0e,Y:Y0e,Z:Q0e,"%":jB},A={a:ee,A:ae,b:fe,B:de,c:null,d:OB,e:OB,f:nbe,g:hbe,G:pbe,H:J0e,I:ebe,j:tbe,L:Lq,m:rbe,M:ibe,p:xe,q:ye,Q:LB,s:IB,S:sbe,u:abe,U:obe,V:lbe,w:cbe,W:ube,x:null,X:null,y:dbe,Y:fbe,Z:mbe,"%":jB},T={a:D,A:F,b:j,B:q,c:R,d:PB,e:PB,f:R0e,g:kB,G:NB,H:RB,I:RB,j:C0e,L:P0e,m:T0e,M:N0e,p:C,q:A0e,Q:O0e,s:j0e,S:k0e,u:_0e,U:w0e,V:S0e,w:y0e,W:E0e,x:W,X:K,y:kB,Y:NB,Z:M0e,"%":D0e};S.x=k(n,S),S.X=k(r,S),S.c=k(e,S),A.x=k(n,A),A.X=k(r,A),A.c=k(e,A);function k(re,ve){return function(je){var ue=[],ut=-1,$=0,H=re.length,ie,G,J;for(je instanceof Date||(je=new Date(+je));++ut<H;)re.charCodeAt(ut)===37&&(ue.push(re.slice($,ut)),(G=CB[ie=re.charAt(++ut)])!=null?ie=re.charAt(++ut):G=ie==="e"?" ":"0",(J=ve[ie])&&(ie=J(je,G)),ue.push(ie),$=ut+1);return ue.push(re.slice($,ut)),ue.join("")}}function N(re,ve){return function(je){var ue=rx(1900,void 0,1),ut=I(ue,re,je+="",0),$,H;if(ut!=je.length)return null;if("Q"in ue)return new Date(ue.Q);if("s"in ue)return new Date(ue.s*1e3+("L"in ue?ue.L:0));if(ve&&!("Z"in ue)&&(ue.Z=0),"p"in ue&&(ue.H=ue.H%12+ue.p*12),ue.m===void 0&&(ue.m="q"in ue?ue.q:0),"V"in ue){if(ue.V<1||ue.V>53)return null;"w"in ue||(ue.w=1),"Z"in ue?($=HT(rx(ue.y,0,1)),H=$.getUTCDay(),$=H>4||H===0?tw.ceil($):tw($),$=sE.offset($,(ue.V-1)*7),ue.y=$.getUTCFullYear(),ue.m=$.getUTCMonth(),ue.d=$.getUTCDate()+(ue.w+6)%7):($=BT(rx(ue.y,0,1)),H=$.getDay(),$=H>4||H===0?ew.ceil($):ew($),$=Sb.offset($,(ue.V-1)*7),ue.y=$.getFullYear(),ue.m=$.getMonth(),ue.d=$.getDate()+(ue.w+6)%7)}else("W"in ue||"U"in ue)&&("w"in ue||(ue.w="u"in ue?ue.u%7:"W"in ue?1:0),H="Z"in ue?HT(rx(ue.y,0,1)).getUTCDay():BT(rx(ue.y,0,1)).getDay(),ue.m=0,ue.d="W"in ue?(ue.w+6)%7+ue.W*7-(H+5)%7:ue.w+ue.U*7-(H+6)%7);return"Z"in ue?(ue.H+=ue.Z/100|0,ue.M+=ue.Z%100,HT(ue)):BT(ue)}}function I(re,ve,je,ue){for(var ut=0,$=ve.length,H=je.length,ie,G;ut<$;){if(ue>=H)return-1;if(ie=ve.charCodeAt(ut++),ie===37){if(ie=ve.charAt(ut++),G=T[ie in CB?ve.charAt(ut++):ie],!G||(ue=G(re,je,ue))<0)return-1}else if(ie!=je.charCodeAt(ue++))return-1}return ue}function C(re,ve,je){var ue=u.exec(ve.slice(je));return ue?(re.p=d.get(ue[0].toLowerCase()),je+ue[0].length):-1}function D(re,ve,je){var ue=m.exec(ve.slice(je));return ue?(re.w=x.get(ue[0].toLowerCase()),je+ue[0].length):-1}function F(re,ve,je){var ue=f.exec(ve.slice(je));return ue?(re.w=g.get(ue[0].toLowerCase()),je+ue[0].length):-1}function j(re,ve,je){var ue=b.exec(ve.slice(je));return ue?(re.m=E.get(ue[0].toLowerCase()),je+ue[0].length):-1}function q(re,ve,je){var ue=y.exec(ve.slice(je));return ue?(re.m=v.get(ue[0].toLowerCase()),je+ue[0].length):-1}function R(re,ve,je){return I(re,e,ve,je)}function W(re,ve,je){return I(re,n,ve,je)}function K(re,ve,je){return I(re,r,ve,je)}function V(re){return a[re.getDay()]}function te(re){return s[re.getDay()]}function Y(re){return l[re.getMonth()]}function Z(re){return o[re.getMonth()]}function U(re){return i[+(re.getHours()>=12)]}function z(re){return 1+~~(re.getMonth()/3)}function ee(re){return a[re.getUTCDay()]}function ae(re){return s[re.getUTCDay()]}function fe(re){return l[re.getUTCMonth()]}function de(re){return o[re.getUTCMonth()]}function xe(re){return i[+(re.getUTCHours()>=12)]}function ye(re){return 1+~~(re.getUTCMonth()/3)}return{format:function(re){var ve=k(re+="",S);return ve.toString=function(){return re},ve},parse:function(re){var ve=N(re+="",!1);return ve.toString=function(){return re},ve},utcFormat:function(re){var ve=k(re+="",A);return ve.toString=function(){return re},ve},utcParse:function(re){var ve=N(re+="",!0);return ve.toString=function(){return re},ve}}}var CB={"-":"",_:" ",0:"0"},Ii=/^\s*\d+/,x0e=/^%/,b0e=/[\\^$*+?|[\]().{}]/g;function Cn(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 v0e(t){return t.replace(b0e,"\\$&")}function ix(t){return new RegExp("^(?:"+t.map(v0e).join("|")+")","i")}function sx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function y0e(t,e,n){var r=Ii.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function _0e(t,e,n){var r=Ii.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function w0e(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function S0e(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function E0e(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function NB(t,e,n){var r=Ii.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function kB(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function M0e(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 A0e(t,e,n){var r=Ii.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function T0e(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function PB(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function C0e(t,e,n){var r=Ii.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function RB(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function N0e(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function k0e(t,e,n){var r=Ii.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function P0e(t,e,n){var r=Ii.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function R0e(t,e,n){var r=Ii.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function D0e(t,e,n){var r=x0e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function O0e(t,e,n){var r=Ii.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function j0e(t,e,n){var r=Ii.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function DB(t,e){return Cn(t.getDate(),e,2)}function L0e(t,e){return Cn(t.getHours(),e,2)}function I0e(t,e){return Cn(t.getHours()%12||12,e,2)}function U0e(t,e){return Cn(1+Sb.count(Nc(t),t),e,3)}function Oq(t,e){return Cn(t.getMilliseconds(),e,3)}function F0e(t,e){return Oq(t,e)+"000"}function z0e(t,e){return Cn(t.getMonth()+1,e,2)}function B0e(t,e){return Cn(t.getMinutes(),e,2)}function H0e(t,e){return Cn(t.getSeconds(),e,2)}function $0e(t){var e=t.getDay();return e===0?7:e}function V0e(t,e){return Cn(aE.count(Nc(t)-1,t),e,2)}function jq(t){var e=t.getDay();return e>=4||e===0?bm(t):bm.ceil(t)}function G0e(t,e){return t=jq(t),Cn(bm.count(Nc(t),t)+(Nc(t).getDay()===4),e,2)}function W0e(t){return t.getDay()}function q0e(t,e){return Cn(ew.count(Nc(t)-1,t),e,2)}function K0e(t,e){return Cn(t.getFullYear()%100,e,2)}function X0e(t,e){return t=jq(t),Cn(t.getFullYear()%100,e,2)}function Y0e(t,e){return Cn(t.getFullYear()%1e4,e,4)}function Z0e(t,e){var n=t.getDay();return t=n>=4||n===0?bm(t):bm.ceil(t),Cn(t.getFullYear()%1e4,e,4)}function Q0e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Cn(e/60|0,"0",2)+Cn(e%60,"0",2)}function OB(t,e){return Cn(t.getUTCDate(),e,2)}function J0e(t,e){return Cn(t.getUTCHours(),e,2)}function ebe(t,e){return Cn(t.getUTCHours()%12||12,e,2)}function tbe(t,e){return Cn(1+sE.count(kc(t),t),e,3)}function Lq(t,e){return Cn(t.getUTCMilliseconds(),e,3)}function nbe(t,e){return Lq(t,e)+"000"}function rbe(t,e){return Cn(t.getUTCMonth()+1,e,2)}function ibe(t,e){return Cn(t.getUTCMinutes(),e,2)}function sbe(t,e){return Cn(t.getUTCSeconds(),e,2)}function abe(t){var e=t.getUTCDay();return e===0?7:e}function obe(t,e){return Cn(oE.count(kc(t)-1,t),e,2)}function Iq(t){var e=t.getUTCDay();return e>=4||e===0?vm(t):vm.ceil(t)}function lbe(t,e){return t=Iq(t),Cn(vm.count(kc(t),t)+(kc(t).getUTCDay()===4),e,2)}function cbe(t){return t.getUTCDay()}function ube(t,e){return Cn(tw.count(kc(t)-1,t),e,2)}function dbe(t,e){return Cn(t.getUTCFullYear()%100,e,2)}function hbe(t,e){return t=Iq(t),Cn(t.getUTCFullYear()%100,e,2)}function fbe(t,e){return Cn(t.getUTCFullYear()%1e4,e,4)}function pbe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?vm(t):vm.ceil(t),Cn(t.getUTCFullYear()%1e4,e,4)}function mbe(){return"+0000"}function jB(){return"%"}function LB(t){return+t}function IB(t){return Math.floor(+t/1e3)}var Kf,Uq,Fq;gbe({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 gbe(t){return Kf=g0e(t),Uq=Kf.format,Kf.parse,Fq=Kf.utcFormat,Kf.utcParse,Kf}function xbe(t){return new Date(t)}function bbe(t){return t instanceof Date?+t:+new Date(+t)}function DD(t,e,n,r,i,s,a,o,l,u){var d=vD(),f=d.invert,g=d.domain,m=u(".%L"),x=u(":%S"),y=u("%I:%M"),v=u("%I %p"),b=u("%a %d"),E=u("%b %d"),S=u("%B"),A=u("%Y");function T(k){return(l(k)<k?m:o(k)<k?x:a(k)<k?y:s(k)<k?v:r(k)<k?i(k)<k?b:E:n(k)<k?S:A)(k)}return d.invert=function(k){return new Date(f(k))},d.domain=function(k){return arguments.length?g(Array.from(k,bbe)):g().map(xbe)},d.ticks=function(k){var N=g();return t(N[0],N[N.length-1],k??10)},d.tickFormat=function(k,N){return N==null?T:u(N)},d.nice=function(k){var N=g();return(!k||typeof k.range!="function")&&(k=e(N[0],N[N.length-1],k??10)),k?g(Mq(N,k)):d},d.copy=function(){return wb(d,DD(t,e,n,r,i,s,a,o,l,u))},d}function vbe(){return co.apply(DD(p0e,m0e,Nc,PD,aE,Sb,ND,TD,uh,Uq).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function ybe(){return co.apply(DD(h0e,f0e,kc,RD,oE,sE,kD,CD,uh,Fq).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function lE(){var t=0,e=1,n,r,i,s,a=Es,o=!1,l;function u(f){return f==null||isNaN(f=+f)?l:a(i===0?.5:(f=(s(f)-n)*i,o?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(o=!!f,u):o},u.interpolator=function(f){return arguments.length?(a=f,u):a};function d(f){return function(g){var m,x;return arguments.length?([m,x]=g,a=f(m,x),u):[a(0),a(1)]}}return u.range=d(Gm),u.rangeRound=d(bD),u.unknown=function(f){return arguments.length?(l=f,u):l},function(f){return s=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function vd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function zq(){var t=bd(lE()(Es));return t.copy=function(){return vd(t,zq())},Ic.apply(t,arguments)}function Bq(){var t=wD(lE()).domain([1,10]);return t.copy=function(){return vd(t,Bq()).base(t.base())},Ic.apply(t,arguments)}function Hq(){var t=SD(lE());return t.copy=function(){return vd(t,Hq()).constant(t.constant())},Ic.apply(t,arguments)}function OD(){var t=ED(lE());return t.copy=function(){return vd(t,OD()).exponent(t.exponent())},Ic.apply(t,arguments)}function _be(){return OD.apply(null,arguments).exponent(.5)}function $q(){var t=[],e=Es;function n(r){if(r!=null&&!isNaN(r=+r))return e((yb(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(Gu),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)=>axe(t,s/r))},n.copy=function(){return $q(e).domain(t)},Ic.apply(n,arguments)}function cE(){var t=0,e=.5,n=1,r=1,i,s,a,o,l,u=Es,d,f=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-s)*(r*y<r*s?o:l),u(f?Math.max(0,Math.min(1,y)):y))}m.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),s=d(e=+e),a=d(n=+n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m):[t,e,n]},m.clamp=function(y){return arguments.length?(f=!!y,m):f},m.interpolator=function(y){return arguments.length?(u=y,m):u};function x(y){return function(v){var b,E,S;return arguments.length?([b,E,S]=v,u=Dxe(y,[b,E,S]),m):[u(0),u(.5),u(1)]}}return m.range=x(Gm),m.rangeRound=x(bD),m.unknown=function(y){return arguments.length?(g=y,m):g},function(y){return d=y,i=y(t),s=y(e),a=y(n),o=i===s?0:.5/(s-i),l=s===a?0:.5/(a-s),r=s<i?-1:1,m}}function Vq(){var t=bd(cE()(Es));return t.copy=function(){return vd(t,Vq())},Ic.apply(t,arguments)}function Gq(){var t=wD(cE()).domain([.1,1,10]);return t.copy=function(){return vd(t,Gq()).base(t.base())},Ic.apply(t,arguments)}function Wq(){var t=SD(cE());return t.copy=function(){return vd(t,Wq()).constant(t.constant())},Ic.apply(t,arguments)}function jD(){var t=ED(cE());return t.copy=function(){return vd(t,jD()).exponent(t.exponent())},Ic.apply(t,arguments)}function wbe(){return jD.apply(null,arguments).exponent(.5)}const Mx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:mD,scaleDiverging:Vq,scaleDivergingLog:Gq,scaleDivergingPow:jD,scaleDivergingSqrt:wbe,scaleDivergingSymlog:Wq,scaleIdentity:Eq,scaleImplicit:ck,scaleLinear:Sq,scaleLog:Aq,scaleOrdinal:pD,scalePoint:cxe,scalePow:MD,scaleQuantile:Nq,scaleQuantize:kq,scaleRadial:Cq,scaleSequential:zq,scaleSequentialLog:Bq,scaleSequentialPow:OD,scaleSequentialQuantile:$q,scaleSequentialSqrt:_be,scaleSequentialSymlog:Hq,scaleSqrt:n0e,scaleSymlog:Tq,scaleThreshold:Pq,scaleTime:vbe,scaleUtc:ybe,tickFormat:wq},Symbol.toStringTag,{value:"Module"}));var yd=t=>t.chartData,LD=We([yd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Eb=(t,e,n,r)=>r?LD(t):yd(t);function id(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Bn(e)&&Bn(n))return!0}return!1}function UB(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function qq(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(Bn(n))i=n;else if(typeof n=="function")return;if(Bn(r))s=r;else if(typeof r=="function")return;var a=[i,s];if(id(a))return a}}function Sbe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(id(r))return UB(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(Nt(i))a=i;else if(typeof i=="function")try{e!=null&&(a=i(e?.[0]))}catch{}else if(typeof i=="string"&&hz.test(i)){var l=hz.exec(i);if(l==null||e==null)a=void 0;else{var u=+l[1];a=e[0]-u}}else a=e?.[0];if(s==="auto")e!=null&&(o=Math.max(...e));else if(Nt(s))o=s;else if(typeof s=="function")try{e!=null&&(o=s(e?.[1]))}catch{}else if(typeof s=="string"&&fz.test(s)){var d=fz.exec(s);if(d==null||e==null)o=void 0;else{var f=+d[1];o=e[1]+f}}else o=e?.[1];var g=[a,o];if(id(g))return e==null?g:UB(g,e,n)}}}var Wm=1e9,Ebe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},UD,gr=!0,oo="[DecimalError] ",Sh=oo+"Invalid argument: ",ID=oo+"Exponent out of range: ",qm=Math.floor,eh=Math.pow,Mbe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,fa,Pi=1e7,ur=7,Kq=9007199254740991,nw=qm(Kq/ur),Pt={};Pt.absoluteValue=Pt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Pt.comparedTo=Pt.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};Pt.decimalPlaces=Pt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ur;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Pt.dividedBy=Pt.div=function(t){return bc(this,new this.constructor(t))};Pt.dividedToIntegerBy=Pt.idiv=function(t){var e=this,n=e.constructor;return nr(bc(e,new n(t),0,1),n.precision)};Pt.equals=Pt.eq=function(t){return!this.cmp(t)};Pt.exponent=function(){return ei(this)};Pt.greaterThan=Pt.gt=function(t){return this.cmp(t)>0};Pt.greaterThanOrEqualTo=Pt.gte=function(t){return this.cmp(t)>=0};Pt.isInteger=Pt.isint=function(){return this.e>this.d.length-2};Pt.isNegative=Pt.isneg=function(){return this.s<0};Pt.isPositive=Pt.ispos=function(){return this.s>0};Pt.isZero=function(){return this.s===0};Pt.lessThan=Pt.lt=function(t){return this.cmp(t)<0};Pt.lessThanOrEqualTo=Pt.lte=function(t){return this.cmp(t)<1};Pt.logarithm=Pt.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(fa))throw Error(oo+"NaN");if(n.s<1)throw Error(oo+(n.s?"NaN":"-Infinity"));return n.eq(fa)?new r(0):(gr=!1,e=bc(P0(n,s),P0(t,s),s),gr=!0,nr(e,i))};Pt.minus=Pt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?Zq(e,t):Xq(e,(t.s=-t.s,t))};Pt.modulo=Pt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(oo+"NaN");return n.s?(gr=!1,e=bc(n,t,0,1).times(t),gr=!0,n.minus(e)):nr(new r(n),i)};Pt.naturalExponential=Pt.exp=function(){return Yq(this)};Pt.naturalLogarithm=Pt.ln=function(){return P0(this)};Pt.negated=Pt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Pt.plus=Pt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?Xq(e,t):Zq(e,(t.s=-t.s,t))};Pt.precision=Pt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Sh+t);if(e=ei(i)+1,r=i.d.length-1,n=r*ur+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};Pt.squareRoot=Pt.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(oo+"NaN")}for(t=ei(o),gr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=il(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=qm((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(bc(o,s,a+2)).times(.5),il(s.d).slice(0,a)===(e=il(r.d)).slice(0,a)){if(e=e.slice(a-3,a+1),i==a&&e=="4999"){if(nr(s,n+1,0),s.times(s).eq(o)){r=s;break}}else if(e!="9999")break;a+=4}return gr=!0,nr(r,n)};Pt.times=Pt.mul=function(t){var e,n,r,i,s,a,o,l,u,d=this,f=d.constructor,g=d.d,m=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,l=g.length,u=m.length,l<u&&(s=g,g=m,m=s,a=l,l=u,u=a),s=[],a=l+u,r=a;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=l+r;i>r;)o=s[i]+m[r]*g[i-r-1]+e,s[i--]=o%Pi|0,e=o/Pi|0;s[i]=(s[i]+e)%Pi|0}for(;!s[--a];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,gr?nr(t,f.precision):t};Pt.toDecimalPlaces=Pt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(dl(t,0,Wm),e===void 0?e=r.rounding:dl(e,0,8),nr(n,t+ei(n)+1,e))};Pt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Gh(r,!0):(dl(t,0,Wm),e===void 0?e=i.rounding:dl(e,0,8),r=nr(new i(r),t+1,e),n=Gh(r,!0,t+1)),n};Pt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Gh(i):(dl(t,0,Wm),e===void 0?e=s.rounding:dl(e,0,8),r=nr(new s(i),t+ei(i)+1,e),n=Gh(r.abs(),!1,t+ei(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Pt.toInteger=Pt.toint=function(){var t=this,e=t.constructor;return nr(new e(t),ei(t)+1,e.rounding)};Pt.toNumber=function(){return+this};Pt.toPower=Pt.pow=function(t){var e,n,r,i,s,a,o=this,l=o.constructor,u=12,d=+(t=new l(t));if(!t.s)return new l(fa);if(o=new l(o),!o.s){if(t.s<1)throw Error(oo+"Infinity");return o}if(o.eq(fa))return o;if(r=l.precision,t.eq(fa))return nr(o,r);if(e=t.e,n=t.d.length-1,a=e>=n,s=o.s,a){if((n=d<0?-d:d)<=Kq){for(i=new l(fa),e=Math.ceil(r/ur+4),gr=!1;n%2&&(i=i.times(o),zB(i.d,e)),n=qm(n/2),n!==0;)o=o.times(o),zB(o.d,e);return gr=!0,t.s<0?new l(fa).div(i):nr(i,r)}}else if(s<0)throw Error(oo+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,gr=!1,i=t.times(P0(o,r+u)),gr=!0,i=Yq(i),i.s=s,i};Pt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=ei(i),r=Gh(i,n<=s.toExpNeg||n>=s.toExpPos)):(dl(t,1,Wm),e===void 0?e=s.rounding:dl(e,0,8),i=nr(new s(i),t,e),n=ei(i),r=Gh(i,t<=n||n<=s.toExpNeg,t)),r};Pt.toSignificantDigits=Pt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(dl(t,1,Wm),e===void 0?e=r.rounding:dl(e,0,8)),nr(new r(n),t,e)};Pt.toString=Pt.valueOf=Pt.val=Pt.toJSON=Pt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=ei(t),n=t.constructor;return Gh(t,e<=n.toExpNeg||e>=n.toExpPos)};function Xq(t,e){var n,r,i,s,a,o,l,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),gr?nr(e,f):e;if(l=t.d,u=e.d,a=t.e,i=e.e,l=l.slice(),s=a-i,s){for(s<0?(r=l,s=-s,o=u.length):(r=u,i=a,o=l.length),a=Math.ceil(f/ur),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=u.length,o-s<0&&(s=o,r=u,u=l,l=r),n=0;s;)n=(l[--s]=l[s]+u[s]+n)/Pi|0,l[s]%=Pi;for(n&&(l.unshift(n),++i),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=i,gr?nr(e,f):e}function dl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Sh+t)}function il(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=ur-r.length,n&&(s+=Mu(n)),s+=r;a=t[e],r=a+"",n=ur-r.length,n&&(s+=Mu(n))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}var bc=(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%Pi|0,a=s/Pi|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*Pi+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,a){var o,l,u,d,f,g,m,x,y,v,b,E,S,A,T,k,N,I,C=r.constructor,D=r.s==i.s?1:-1,F=r.d,j=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(oo+"Division by zero");for(l=r.e-i.e,N=j.length,T=F.length,m=new C(D),x=m.d=[],u=0;j[u]==(F[u]||0);)++u;if(j[u]>(F[u]||0)&&--l,s==null?E=s=C.precision:a?E=s+(ei(r)-ei(i))+1:E=s,E<0)return new C(0);if(E=E/ur+2|0,u=0,N==1)for(d=0,j=j[0],E++;(u<T||d)&&E--;u++)S=d*Pi+(F[u]||0),x[u]=S/j|0,d=S%j|0;else{for(d=Pi/(j[0]+1)|0,d>1&&(j=t(j,d),F=t(F,d),N=j.length,T=F.length),A=N,y=F.slice(0,N),v=y.length;v<N;)y[v++]=0;I=j.slice(),I.unshift(0),k=j[0],j[1]>=Pi/2&&++k;do d=0,o=e(j,y,N,v),o<0?(b=y[0],N!=v&&(b=b*Pi+(y[1]||0)),d=b/k|0,d>1?(d>=Pi&&(d=Pi-1),f=t(j,d),g=f.length,v=y.length,o=e(f,y,g,v),o==1&&(d--,n(f,N<g?I:j,g))):(d==0&&(o=d=1),f=j.slice()),g=f.length,g<v&&f.unshift(0),n(y,f,v),o==-1&&(v=y.length,o=e(j,y,N,v),o<1&&(d++,n(y,N<v?I:j,v))),v=y.length):o===0&&(d++,y=[0]),x[u++]=d,o&&y[0]?y[v++]=F[A]||0:(y=[F[A]],v=1);while((A++<T||y[0]!==void 0)&&E--)}return x[0]||x.shift(),m.e=l,nr(m,a?s+ei(m)+1:s)}})();function Yq(t,e){var n,r,i,s,a,o,l=0,u=0,d=t.constructor,f=d.precision;if(ei(t)>16)throw Error(ID+ei(t));if(!t.s)return new d(fa);for(gr=!1,o=f,a=new d(.03125);t.abs().gte(.1);)t=t.times(a),u+=5;for(r=Math.log(eh(2,u))/Math.LN10*2+5|0,o+=r,n=i=s=new d(fa),d.precision=o;;){if(i=nr(i.times(t),o),n=n.times(++l),a=s.plus(bc(i,n,o)),il(a.d).slice(0,o)===il(s.d).slice(0,o)){for(;u--;)s=nr(s.times(s),o);return d.precision=f,e==null?(gr=!0,nr(s,f)):s}s=a}}function ei(t){for(var e=t.e*ur,n=t.d[0];n>=10;n/=10)e++;return e}function $T(t,e,n){if(e>t.LN10.sd())throw gr=!0,n&&(t.precision=n),Error(oo+"LN10 precision limit exceeded");return nr(new t(t.LN10),e)}function Mu(t){for(var e="";t--;)e+="0";return e}function P0(t,e){var n,r,i,s,a,o,l,u,d,f=1,g=10,m=t,x=m.d,y=m.constructor,v=y.precision;if(m.s<1)throw Error(oo+(m.s?"NaN":"-Infinity"));if(m.eq(fa))return new y(0);if(e==null?(gr=!1,u=v):u=e,m.eq(10))return e==null&&(gr=!0),$T(y,u);if(u+=g,y.precision=u,n=il(x),r=n.charAt(0),s=ei(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=il(m.d),r=n.charAt(0),f++;s=ei(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return l=$T(y,u+2,v).times(s+""),m=P0(new y(r+"."+n.slice(1)),u-g).plus(l),y.precision=v,e==null?(gr=!0,nr(m,v)):m;for(o=a=m=bc(m.minus(fa),m.plus(fa),u),d=nr(m.times(m),u),i=3;;){if(a=nr(a.times(d),u),l=o.plus(bc(a,new y(i),u)),il(l.d).slice(0,u)===il(o.d).slice(0,u))return o=o.times(2),s!==0&&(o=o.plus($T(y,u+2,v).times(s+""))),o=bc(o,new y(f),u),y.precision=v,e==null?(gr=!0,nr(o,v)):o;o=l,i+=2}}function FB(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=qm(n/ur),t.d=[],r=(n+1)%ur,n<0&&(r+=ur),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=ur;r<i;)t.d.push(+e.slice(r,r+=ur));e=e.slice(r),r=ur-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),gr&&(t.e>nw||t.e<-nw))throw Error(ID+n)}else t.s=0,t.e=0,t.d=[0];return t}function nr(t,e,n){var r,i,s,a,o,l,u,d,f=t.d;for(a=1,s=f[0];s>=10;s/=10)a++;if(r=e-a,r<0)r+=ur,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/ur),s=f.length,d>=s)return t;for(u=s=f[d],a=1;s>=10;s/=10)a++;r%=ur,i=r-ur+a}if(n!==void 0&&(s=eh(10,a-i-1),o=u/s%10|0,l=e<0||f[d+1]!==void 0||u%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?u/eh(10,a-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return l?(s=ei(t),f.length=1,e=e-s-1,f[0]=eh(10,(ur-e%ur)%ur),t.e=qm(-e/ur)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,s=1,d--):(f.length=d+1,s=eh(10,ur-r),f[d]=i>0?(u/eh(10,a-i)%eh(10,i)|0)*s:0),l)for(;;)if(d==0){(f[0]+=s)==Pi&&(f[0]=1,++t.e);break}else{if(f[d]+=s,f[d]!=Pi)break;f[d--]=0,s=1}for(r=f.length;f[--r]===0;)f.pop();if(gr&&(t.e>nw||t.e<-nw))throw Error(ID+ei(t));return t}function Zq(t,e){var n,r,i,s,a,o,l,u,d,f,g=t.constructor,m=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),gr?nr(e,m):e;if(l=t.d,f=e.d,r=e.e,u=t.e,l=l.slice(),a=u-r,a){for(d=a<0,d?(n=l,a=-a,o=f.length):(n=f,r=u,o=l.length),i=Math.max(Math.ceil(m/ur),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=f.length,d=i<o,d&&(o=i),i=0;i<o;i++)if(l[i]!=f[i]){d=l[i]<f[i];break}a=0}for(d&&(n=l,l=f,f=n,e.s=-e.s),o=l.length,i=f.length-o;i>0;--i)l[o++]=0;for(i=f.length;i>a;){if(l[--i]<f[i]){for(s=i;s&&l[--s]===0;)l[s]=Pi-1;--l[s],l[i]+=Pi}l[i]-=f[i]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(e.d=l,e.e=r,gr?nr(e,m):e):new g(0)}function Gh(t,e,n){var r,i=ei(t),s=il(t.d),a=s.length;return e?(n&&(r=n-a)>0?s=s.charAt(0)+"."+s.slice(1)+Mu(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Mu(-i-1)+s,n&&(r=n-a)>0&&(s+=Mu(r))):i>=a?(s+=Mu(i+1-a),n&&(r=n-i-1)>0&&(s=s+"."+Mu(r))):((r=i+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-a)>0&&(i+1===a&&(s+="."),s+=Mu(r))),t.s<0?"-"+s:s}function zB(t,e){if(t.length>e)return t.length=e,!0}function Qq(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(Sh+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 FB(a,s.toString())}else if(typeof s!="string")throw Error(Sh+s);if(s.charCodeAt(0)===45?(s=s.slice(1),a.s=-1):a.s=1,Mbe.test(s))FB(a,s);else throw Error(Sh+s)}if(i.prototype=Pt,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=Qq,i.config=i.set=Abe,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 Abe(t){if(!t||typeof t!="object")throw Error(oo+"Object expected");var e,n,r,i=["precision",1,Wm,"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(qm(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Sh+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Sh+n+": "+r);return this}var UD=Qq(Ebe);fa=new UD(1);const Fn=UD;var Tbe=t=>t,Jq={},eK=t=>t===Jq,BB=t=>function e(){return arguments.length===0||arguments.length===1&&eK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},tK=(t,e)=>t===1?e:BB(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!==Jq).length;return s>=t?e(...r):tK(t-s,BB(function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];var u=r.map(d=>eK(d)?o.shift():d);return e(...u,...o)}))}),Cbe=t=>tK(t.length,t),fk=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Nbe=Cbe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),kbe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Tbe;var i=n.reverse(),s=i[0],a=i.slice(1);return function(){return a.reduce((o,l)=>l(o),s(...arguments))}},pk=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function nK(t){var e;return t===0?e=1:e=Math.floor(new Fn(t).abs().log(10).toNumber())+1,e}function rK(t,e,n){for(var r=new Fn(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var iK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},sK=(t,e,n)=>{if(t.lte(0))return new Fn(0);var r=nK(t.toNumber()),i=new Fn(10).pow(r),s=t.div(i),a=r!==1?.05:.1,o=new Fn(Math.ceil(s.div(a).toNumber())).add(n).mul(a),l=o.mul(i);return e?new Fn(l.toNumber()):new Fn(Math.ceil(l.toNumber()))},Pbe=(t,e,n)=>{var r=new Fn(1),i=new Fn(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new Fn(10).pow(nK(t)-1),i=new Fn(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new Fn(Math.floor(t)))}else t===0?i=new Fn(Math.floor((e-1)/2)):n||(i=new Fn(Math.floor(t)));var a=Math.floor((e-1)/2),o=kbe(Nbe(l=>i.add(new Fn(l-a).mul(r)).toNumber()),fk);return o(0,e)},aK=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 Fn(0),tickMin:new Fn(0),tickMax:new Fn(0)};var a=sK(new Fn(n).sub(e).div(r-1),i,s),o;e<=0&&n>=0?o=new Fn(0):(o=new Fn(e).add(n).div(2),o=o.sub(new Fn(o).mod(a)));var l=Math.ceil(o.sub(e).div(a).toNumber()),u=Math.ceil(new Fn(n).sub(o).div(a).toNumber()),d=l+u+1;return d>r?aK(e,n,r,i,s+1):(d<r&&(u=n>0?u+(r-d):u,l=n>0?l:l+(r-d)),{step:a,tickMin:o.sub(new Fn(l).mul(a)),tickMax:o.add(new Fn(u).mul(a))})},Rbe=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]=iK([n,r]);if(o===-1/0||l===1/0){var u=l===1/0?[o,...fk(0,i-1).map(()=>1/0)]:[...fk(0,i-1).map(()=>-1/0),l];return n>r?pk(u):u}if(o===l)return Pbe(o,i,s);var{step:d,tickMin:f,tickMax:g}=aK(o,l,a,s,0),m=rK(f,g.add(new Fn(.1).mul(d)),d);return n>r?pk(m):m},Dbe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=iK([r,i]);if(a===-1/0||o===1/0)return[r,i];if(a===o)return[a];var l=Math.max(n,2),u=sK(new Fn(o).sub(a).div(l-1),s,0),d=[...rK(new Fn(a),new Fn(o),u),o];return s===!1&&(d=d.map(f=>Math.round(f))),r>i?pk(d):d},oK=t=>t.rootProps.maxBarSize,Obe=t=>t.rootProps.barGap,lK=t=>t.rootProps.barCategoryGap,jbe=t=>t.rootProps.barSize,Mb=t=>t.rootProps.stackOffset,cK=t=>t.rootProps.reverseStackOrder,FD=t=>t.options.chartName,zD=t=>t.rootProps.syncId,uK=t=>t.rootProps.syncMethod,BD=t=>t.options.eventEmitter,Lbe=t=>t.rootProps.baseValue,Pr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},oc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},da={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},uE=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Ibe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:oc.angleAxisId,includeHidden:!1,name:void 0,reversed:oc.reversed,scale:oc.scale,tick:oc.tick,tickCount:void 0,ticks:void 0,type:oc.type,unit:void 0},Ube={allowDataOverflow:da.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:da.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:da.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:da.scale,tick:da.tick,tickCount:da.tickCount,ticks:void 0,type:da.type,unit:void 0},Fbe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:oc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:oc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:oc.scale,tick:oc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},zbe={allowDataOverflow:da.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:da.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:da.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:da.scale,tick:da.tick,tickCount:da.tickCount,ticks:void 0,type:"category",unit:void 0},HD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Fbe:Ibe,$D=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?zbe:Ube,dE=t=>t.polarOptions,VD=We([jc,Lc,gi],lq),dK=We([dE,VD],(t,e)=>{if(t!=null)return ps(t.innerRadius,e,0)}),hK=We([dE,VD],(t,e)=>{if(t!=null)return ps(t.outerRadius,e,e*.8)}),Bbe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},fK=We([dE],Bbe);We([HD,fK],uE);var pK=We([VD,dK,hK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});We([$D,pK],uE);var mK=We([gn,dE,dK,hK,jc,Lc],(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:u}=e;return{cx:ps(a,i,i/2),cy:ps(o,s,s/2),innerRadius:n,outerRadius:r,startAngle:l,endAngle:u,clockWise:!1}}}),xr=(t,e)=>e,Ab=(t,e,n)=>n;function hE(t){return t?.id}function gK(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,a=new Map;return t.forEach(o=>{var l,u=(l=o.data)!==null&&l!==void 0?l:r;if(!(u==null||u.length===0)){var d=hE(o);u.forEach((f,g)=>{var m=s==null||i?g:String(zn(f,s,null)),x=zn(f,o.dataKey,0),y;a.has(m)?y=a.get(m):y={},Object.assign(y,{[d]:x}),a.set(m,y)})}}),Array.from(a.values())}function fE(t){return t.stackId!=null&&t.dataKey!=null}var pE=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function mE(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Hbe(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 vi=t=>{var e=gn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Km=t=>t.tooltip.settings.axisId;function HB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function rw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HB(Object(n),!0).forEach(function(r){$be(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $be(t,e,n){return(e=Vbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vbe(t){var e=Gbe(t,"string");return typeof e=="symbol"?e:e+""}function Gbe(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 mk=[0,"auto"],Ni={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},xK=(t,e)=>t.cartesianAxis.xAxis[e],_l=(t,e)=>{var n=xK(t,e);return n??Ni},ki={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:mk,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:xb},bK=(t,e)=>t.cartesianAxis.yAxis[e],wl=(t,e)=>{var n=bK(t,e);return n??ki},Wbe={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:""},GD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Wbe},Sr=(t,e,n)=>{switch(e){case"xAxis":return _l(t,n);case"yAxis":return wl(t,n);case"zAxis":return GD(t,n);case"angleAxis":return HD(t,n);case"radiusAxis":return $D(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},qbe=(t,e,n)=>{switch(e){case"xAxis":return _l(t,n);case"yAxis":return wl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Tb=(t,e,n)=>{switch(e){case"xAxis":return _l(t,n);case"yAxis":return wl(t,n);case"angleAxis":return HD(t,n);case"radiusAxis":return $D(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},vK=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function WD(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 Cb=t=>t.graphicalItems.cartesianItems,Kbe=We([xr,Ab],WD),qD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Nb=We([Cb,Sr,Kbe],qD,{memoizeOptions:{resultEqualityCheck:mE}}),yK=We([Nb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(fE)),_K=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Xbe=We([Nb],_K),KD=t=>t.map(e=>e.data).filter(Boolean).flat(1),Ybe=We([Nb],KD,{memoizeOptions:{resultEqualityCheck:mE}}),XD=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},YD=We([Ybe,Eb],XD),ZD=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:zn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:zn(i,r)}))):t.map(r=>({value:r})),gE=We([YD,Sr,Nb],ZD);function wK(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function X_(t){if(so(t)||t instanceof Date){var e=Number(t);if(Bn(e))return e}}function $B(t){if(Array.isArray(t)){var e=[X_(t[0]),X_(t[1])];return id(e)?e:void 0}var n=X_(t);if(n!=null)return[n,n]}function Pc(t){return t.map(X_).filter(qde)}function Zbe(t,e,n){return!n||typeof e!="number"||Ys(e)?[]:n.length?Pc(n.flatMap(r=>{var i=zn(t,r.dataKey),s,a;if(Array.isArray(i)?[s,a]=i:s=a=i,!(!Bn(s)||!Bn(a)))return[e-s,e+a]})):[]}var yi=t=>{var e=vi(t),n=Km(t);return Tb(t,e,n)},kb=We([yi],t=>t?.dataKey),Qbe=We([yK,Eb,yi],gK),SK=(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,u=r?[...l].reverse():l,d=u.map(hE);return[o,{stackedData:xpe(t,d,n),graphicalItems:u}]}))},R0=We([Qbe,yK,Mb,cK],SK),EK=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var a=_pe(t,i,s);if(!(a!=null&&a[0]===0&&a[1]===0))return a}},Jbe=We([Sr],t=>t.allowDataOverflow),QD=t=>{var e;if(t==null||!("domain"in t))return mk;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Pc(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:mk},JD=We([Sr],QD),eO=We([JD,Jbe],qq),eve=We([R0,yd,xr,eO],EK,{memoizeOptions:{resultEqualityCheck:pE}}),xE=t=>t.errorBars,tve=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>wK(n,r)),iw=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]}},tO=(t,e,n,r,i)=>{var s,a;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var u,d,f=(u=r[l.id])===null||u===void 0?void 0:u.filter(b=>wK(i,b)),g=zn(o,(d=e.dataKey)!==null&&d!==void 0?d:l.dataKey),m=Zbe(o,g,f);if(m.length>=2){var x=Math.min(...m),y=Math.max(...m);(s==null||x<s)&&(s=x),(a==null||y>a)&&(a=y)}var v=$B(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=$B(zn(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]))}),Bn(s)&&Bn(a))return[s,a]},nve=We([YD,Sr,Xbe,xE,xr],tO,{memoizeOptions:{resultEqualityCheck:pE}});function rve(t){var{value:e}=t;if(so(e)||e instanceof Date)return e}var ive=(t,e,n)=>{var r=t.map(rve).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&F7(r))?hq(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},MK=t=>t.referenceElements.dots,Xm=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),sve=We([MK,xr,Ab],Xm),AK=t=>t.referenceElements.areas,ave=We([AK,xr,Ab],Xm),TK=t=>t.referenceElements.lines,ove=We([TK,xr,Ab],Xm),CK=(t,e)=>{var n=Pc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},lve=We(sve,xr,CK),NK=(t,e)=>{var n=Pc(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)]},cve=We([ave,xr],NK);function uve(t){var e;if(t.x!=null)return Pc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Pc(n)}function dve(t){var e;if(t.y!=null)return Pc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Pc(n)}var kK=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?uve(r):dve(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},hve=We([ove,xr],kK),fve=We(lve,hve,cve,(t,e,n)=>iw(t,n,e)),nO=(t,e,n,r,i,s,a,o)=>{if(n!=null)return n;var l=a==="vertical"&&o==="xAxis"||a==="horizontal"&&o==="yAxis",u=l?iw(r,s,i):iw(s,i);return Sbe(e,u,t.allowDataOverflow)},pve=We([Sr,JD,eO,eve,nve,fve,gn,xr],nO,{memoizeOptions:{resultEqualityCheck:pE}}),mve=[0,1],rO=(t,e,n,r,i,s,a)=>{if(!((t==null||n==null||n.length===0)&&a===void 0)){var{dataKey:o,type:l}=t,u=yl(e,s);if(u&&o==null){var d;return hq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return l==="category"?ive(r,t,u):i==="expand"?mve:a}},iO=We([Sr,gn,YD,gE,Mb,xr,pve],rO),PK=(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(db(s));return o in Mx?o:"point"}}},Ym=We([Sr,gn,vK,FD,xr],PK);function gve(t){if(t!=null){if(t in Mx)return Mx[t]();var e="scale".concat(db(t));if(e in Mx)return Mx[e]()}}function sO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=gve(e);if(i!=null){var s=i.domain(n).range(r);return hpe(s),s}}}var aO=(t,e,n)=>{var r=QD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&id(t))return Rbe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&id(t))return Dbe(t,e.tickCount,e.allowDecimals)}},oO=We([iO,Tb,Ym],aO),lO=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&id(e)&&Array.isArray(n)&&n.length>0){var i=e[0],s=n[0],a=e[1],o=n[n.length-1];return[Math.min(i,s),Math.max(a,o)]}return e},xve=We([Sr,iO,oO,xr],lO),bve=We(gE,Sr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Pc(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}}),RK=We(bve,gn,lK,gi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!Bn(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var a=ps(n,t*s),o=t*s/2;return o-a-(o-a)/s*a}return 0}),vve=(t,e)=>{var n=_l(t,e);return n==null||typeof n.padding!="string"?0:RK(t,"xAxis",e,n.padding)},yve=(t,e)=>{var n=wl(t,e);return n==null||typeof n.padding!="string"?0:RK(t,"yAxis",e,n.padding)},_ve=We(_l,vve,(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}}),wve=We(wl,yve,(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}}),Sve=We([gi,_ve,JS,QS,(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]}),Eve=We([gi,gn,wve,JS,QS,(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]}),Pb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Sve(t,n,r);case"yAxis":return Eve(t,n,r);case"zAxis":return(i=GD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return fK(t);case"radiusAxis":return pK(t,n);default:return}},DK=We([Sr,Pb],uE),sd=We([Sr,Ym,xve,DK],sO);We([Nb,xE,xr],tve);function OK(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var bE=(t,e)=>e,vE=(t,e,n)=>n,Mve=We(YS,bE,vE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(OK)),Ave=We(ZS,bE,vE,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(OK)),jK=(t,e)=>({width:t.width,height:e.height}),Tve=(t,e)=>{var n=typeof e.width=="number"?e.width:xb;return{width:n,height:t.height}},LK=We(gi,_l,jK),Cve=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Nve=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},kve=We(Lc,gi,Mve,bE,vE,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=jK(e,o);a==null&&(a=Cve(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;s[o.id]=a-Number(u)*l.height,a+=(u?-1:1)*l.height}),s}),Pve=We(jc,gi,Ave,bE,vE,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var l=Tve(e,o);a==null&&(a=Nve(e,r,t));var u=r==="left"&&!i||r==="right"&&i;s[o.id]=a-Number(u)*l.width,a+=(u?-1:1)*l.width}),s}),Rve=(t,e)=>{var n=_l(t,e);if(n!=null)return kve(t,n.orientation,n.mirror)},Dve=We([gi,_l,Rve,(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}}}),Ove=(t,e)=>{var n=wl(t,e);if(n!=null)return Pve(t,n.orientation,n.mirror)},jve=We([gi,wl,Ove,(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}}}),IK=We(gi,wl,(t,e)=>{var n=typeof e.width=="number"?e.width:xb;return{width:n,height:t.height}}),VB=(t,e,n)=>{switch(e){case"xAxis":return LK(t,n).width;case"yAxis":return IK(t,n).height;default:return}},UK=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:a}=n,o=yl(t,r),l=e.map(u=>u.value);if(a&&o&&s==="category"&&i&&F7(l))return l}},cO=We([gn,gE,Sr,xr],UK),FK=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,a=yl(t,r);if(a&&(i==="number"||s!=="auto"))return e.map(o=>o.value)}},uO=We([gn,gE,Tb,xr],FK),GB=We([gn,qbe,Ym,sd,cO,uO,Pb,oO,xr],(t,e,n,r,i,s,a,o,l)=>{if(e!=null){var u=yl(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:u,niceTicks:o,range:a,realScaleType:n,scale:r}}}),Lve=(t,e,n,r,i,s,a,o,l)=>{if(!(e==null||r==null)){var u=yl(t,l),{type:d,ticks:f,tickCount:g}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/m:0;x=l==="angleAxis"&&s!=null&&s.length>=2?Oi(s[0]-s[1])*2*x:x;var y=f||i;if(y){var v=y.map((b,E)=>{var S=a?a.indexOf(b):b;return{index:E,coordinate:r(S)+x,value:b,offset:x}});return v.filter(b=>Bn(b.coordinate))}return u&&o?o.map((b,E)=>({coordinate:r(b)+x,value:b,index:E,offset:x})).filter(b=>Bn(b.coordinate)):r.ticks?r.ticks(g).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,E)=>({coordinate:r(b)+x,value:a?a[b]:b,index:E,offset:x}))}},zK=We([gn,Tb,Ym,sd,oO,Pb,cO,uO,xr],Lve),Ive=(t,e,n,r,i,s,a)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=yl(t,a),{tickCount:l}=e,u=0;return u=a==="angleAxis"&&r?.length>=2?Oi(r[0]-r[1])*2*u:u,o&&s?s.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(l).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},hl=We([gn,Tb,sd,Pb,cO,uO,xr],Ive),fl=We(Sr,sd,(t,e)=>{if(!(t==null||e==null))return rw(rw({},t),{},{scale:e})}),Uve=We([Sr,Ym,iO,DK],sO);We((t,e,n)=>GD(t,n),Uve,(t,e)=>{if(!(t==null||e==null))return rw(rw({},t),{},{scale:e})});var Fve=We([gn,YS,ZS],(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}}),BK=t=>t.options.defaultTooltipEventType,HK=t=>t.options.validateTooltipEventTypes;function $K(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function dO(t,e){var n=BK(t),r=HK(t);return $K(e,n,r)}function zve(t){return Tt(e=>dO(e,t))}var VK=(t,e)=>{var n,r=Number(e);if(!(Ys(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},Bve=t=>t.tooltip.settings,Du={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},Hve={itemInteraction:{click:Du,hover:Du},axisInteraction:{click:Du,hover:Du},keyboardInteraction:Du,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},GK=Zs({name:"tooltip",initialState:Hve,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ro(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:fr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ro(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:fr()},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:$ve,replaceTooltipEntrySettings:Vve,removeTooltipEntrySettings:Gve,setTooltipSettingsState:Wve,setActiveMouseOverItemIndex:WK,mouseLeaveItem:qve,mouseLeaveChart:qK,setActiveClickItemIndex:Kve,setMouseOverAxisIndex:KK,setMouseClickAxisIndex:Xve,setSyncInteraction:gk,setKeyboardInteraction:xk}=GK.actions,Yve=GK.reducer;function WB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function wy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WB(Object(n),!0).forEach(function(r){Zve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zve(t,e,n){return(e=Qve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qve(t){var e=Jve(t,"string");return typeof e=="symbol"?e:e+""}function Jve(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eye(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function tye(t){return t.index!=null}var XK=(t,e,n,r)=>{if(e==null)return Du;var i=eye(t,e,n);if(i==null)return Du;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var s=t.settings.active===!0;if(tye(i)){if(s)return wy(wy({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return wy(wy({},Du),{},{coordinate:i.coordinate})};function nye(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 rye(t,e){var n=nye(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 iye(t,e,n){if(n==null||e==null)return!0;var r=zn(t,e);return r==null||!id(n)?!0:rye(r,n)}var hO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!Bn(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)),u=e[l];return u==null||iye(u,n,r)?String(l):null},YK=(t,e,n,r,i,s,a,o)=>{if(!(s==null||o==null)){var l=a[0],u=l==null?void 0:o(l.positions,s);if(u!=null)return u;var d=i?.[Number(s)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},ZK=(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})},Rb=t=>t.options.tooltipPayloadSearcher,Zm=t=>t.tooltip;function qB(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 KB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qB(Object(n),!0).forEach(function(r){sye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sye(t,e,n){return(e=aye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aye(t){var e=oye(t,"string");return typeof e=="symbol"?e:e+""}function oye(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 lye(t,e){return t??e}var QK=(t,e,n,r,i,s,a)=>{if(!(e==null||s==null)){var{chartData:o,computedData:l,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,m)=>{var x,{dataDefinedOnItem:y,settings:v}=m,b=lye(y,o),E=Array.isArray(b)?OW(b,u,d):b,S=(x=v?.dataKey)!==null&&x!==void 0?x:r,A=v?.nameKey,T;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&a==="axis"?T=z7(E,r,i):T=s(E,e,l,A),Array.isArray(T))T.forEach(N=>{var I=KB(KB({},v),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(pz({tooltipEntrySettings:I,dataKey:N.dataKey,payload:N.payload,value:zn(N.payload,N.dataKey),name:N.name}))});else{var k;g.push(pz({tooltipEntrySettings:v,dataKey:S,payload:T,value:zn(T,S),name:(k=zn(T,A))!==null&&k!==void 0?k:v?.name}))}return g},f)}},fO=We([yi,gn,vK,FD,vi],PK),cye=We([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),uye=We([vi,Km],WD),Db=We([cye,yi,uye],qD,{memoizeOptions:{resultEqualityCheck:mE}}),dye=We([Db],t=>t.filter(fE)),hye=We([Db],KD,{memoizeOptions:{resultEqualityCheck:mE}}),Qm=We([hye,yd],XD),fye=We([dye,yd,yi],gK),pO=We([Qm,yi,Db],ZD),JK=We([yi],QD),pye=We([yi],t=>t.allowDataOverflow),eX=We([JK,pye],qq),mye=We([Db],t=>t.filter(fE)),gye=We([fye,mye,Mb,cK],SK),xye=We([gye,yd,vi,eX],EK),bye=We([Db],_K),vye=We([Qm,yi,bye,xE,vi],tO,{memoizeOptions:{resultEqualityCheck:pE}}),yye=We([MK,vi,Km],Xm),_ye=We([yye,vi],CK),wye=We([AK,vi,Km],Xm),Sye=We([wye,vi],NK),Eye=We([TK,vi,Km],Xm),Mye=We([Eye,vi],kK),Aye=We([_ye,Mye,Sye],iw),Tye=We([yi,JK,eX,xye,vye,Aye,gn,vi],nO),Ob=We([yi,gn,Qm,pO,Mb,vi,Tye],rO),Cye=We([Ob,yi,fO],aO),Nye=We([yi,Ob,Cye,vi],lO),tX=t=>{var e=vi(t),n=Km(t),r=!1;return Pb(t,e,n,r)},nX=We([yi,tX],uE),rX=We([yi,fO,Nye,nX],sO),kye=We([gn,pO,yi,vi],UK),Pye=We([gn,pO,yi,vi],FK),Rye=(t,e,n,r,i,s,a,o)=>{if(e){var{type:l}=e,u=yl(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=l==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=o==="angleAxis"&&i!=null&&i?.length>=2?Oi(i[0]-i[1])*2*f:f,u&&a?a.map((g,m)=>({coordinate:r(g)+f,value:g,index:m,offset:f})):r.domain().map((g,m)=>({coordinate:r(g)+f,value:s?s[g]:g,index:m,offset:f}))}}},Uc=We([gn,yi,fO,rX,tX,kye,Pye,vi],Rye),mO=We([BK,HK,Bve],(t,e,n)=>$K(n.shared,t,e)),iX=t=>t.tooltip.settings.trigger,gO=t=>t.tooltip.settings.defaultIndex,jb=We([Zm,mO,iX,gO],XK),ad=We([jb,Qm,kb,Ob],hO),sX=We([Uc,ad],VK),xO=We([jb],t=>{if(t)return t.dataKey}),Dye=We([jb],t=>{if(t)return t.graphicalItemId}),aX=We([Zm,mO,iX,gO],ZK),Oye=We([jc,Lc,gn,gi,Uc,gO,aX,Rb],YK),jye=We([jb,Oye],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),Lye=We([jb],t=>t.active),Iye=We([aX,ad,yd,kb,sX,Rb,mO],QK),Uye=We([Iye],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function XB(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 YB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XB(Object(n),!0).forEach(function(r){Fye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Fye(t,e,n){return(e=zye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zye(t){var e=Bye(t,"string");return typeof e=="symbol"?e:e+""}function Bye(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Hye=()=>Tt(yi),$ye=()=>{var t=Hye(),e=Tt(Uc),n=Tt(rX);return rd(!t||!n?void 0:YB(YB({},t),{},{scale:n}),e)};function ZB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZB(Object(n),!0).forEach(function(r){Vye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Vye(t,e,n){return(e=Gye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gye(t){var e=Wye(t,"string");return typeof e=="symbol"?e:e+""}function Wye(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 qye=(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}},Kye=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var s=i.coordinate,{radius:a}=r;return Xf(Xf(Xf({},r),Zr(r.cx,r.cy,a,s)),{},{angle:s,radius:a})}var o=i.coordinate,{angle:l}=r;return Xf(Xf(Xf({},r),Zr(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 Xye(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 oX=(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 u=l>0?n[l-1].coordinate:n[o-1].coordinate,d=n[l].coordinate,f=l>=o-1?n[0].coordinate:n[l+1].coordinate,g=void 0;if(Oi(d-u)!==Oi(f-d)){var m=[];if(Oi(f-d)===Oi(i[1]-i[0])){g=f;var x=d+i[1]-i[0];m[0]=Math.min(x,(x+u)/2),m[1]=Math.max(x,(x+u)/2)}else{g=u;var y=f+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var v=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>v[0]&&t<=v[1]||t>=m[0]&&t<=m[1]){({index:a}=n[l]);break}}else{var b=Math.min(u,f),E=Math.max(u,f);if(t>(b+d)/2&&t<=(E+d)/2){({index:a}=n[l]);break}}}else if(e){for(var S=0;S<o;S++)if(S===0&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S>0&&S<o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2&&t<=(e[S].coordinate+e[S+1].coordinate)/2||S===o-1&&t>(e[S].coordinate+e[S-1].coordinate)/2){({index:a}=e[S]);break}}return a},lX=()=>Tt(FD),bO=(t,e)=>e,cX=(t,e,n)=>n,vO=(t,e,n,r)=>r,Yye=We(Uc,t=>BS(t,e=>e.coordinate)),yO=We([Zm,bO,cX,vO],XK),_O=We([yO,Qm,kb,Ob],hO),Zye=(t,e,n)=>{if(e!=null){var r=Zm(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},uX=We([Zm,bO,cX,vO],ZK),sw=We([jc,Lc,gn,gi,Uc,vO,uX,Rb],YK),Qye=We([yO,sw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),dX=We([Uc,_O],VK),Jye=We([uX,_O,yd,kb,dX,Rb,bO],QK),e_e=We([yO,_O],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),t_e=(t,e,n,r,i,s,a)=>{if(!(!t||!n||!r||!i)&&Xye(t,a)){var o=wpe(t,e),l=oX(o,s,i,n,r),u=qye(e,i,l,t);return{activeIndex:String(l),activeCoordinate:u}}},n_e=(t,e,n,r,i,s,a)=>{if(!(!t||!r||!i||!s||!n)){var o=Fge(t,n);if(o){var l=Spe(o,e),u=oX(l,a,s,r,i),d=Kye(e,s,u,o);return{activeIndex:String(u),activeCoordinate:d}}}},r_e=(t,e,n,r,i,s,a,o)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?t_e(t,e,r,i,s,a,o):n_e(t,e,n,r,i,s,a)},i_e=We(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),s_e=We(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Pr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Hbe}});function QB(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 JB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QB(Object(n),!0).forEach(function(r){a_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function a_e(t,e,n){return(e=o_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o_e(t){var e=l_e(t,"string");return typeof e=="symbol"?e:e+""}function l_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var c_e={},u_e={zIndexMap:Object.values(Pr).reduce((t,e)=>JB(JB({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),c_e)},d_e=new Set(Object.values(Pr));function h_e(t){return d_e.has(t)}var hX=Zs({name:"zIndex",initialState:u_e,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:fr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!h_e(n)&&delete t.zIndexMap[n])},prepare:fr()},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:fr()},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:fr()}}}),{registerZIndexPortal:f_e,unregisterZIndexPortal:p_e,registerZIndexPortalId:m_e,unregisterZIndexPortalId:g_e}=hX.actions,x_e=hX.reducer;function ms(t){var{zIndex:e,children:n}=t,r=tme(),i=r&&e!==void 0&&e!==0,s=xi(),a=rr();M.useLayoutEffect(()=>i?(a(f_e({zIndex:e})),()=>{a(p_e({zIndex:e}))}):hb,[a,e,i]);var o=Tt(u=>i_e(u,e,s));if(!i)return n;if(!o)return null;var l=document.getElementById(o);return l?uc.createPortal(n,l):null}function bk(){return bk=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},bk.apply(null,arguments)}function e6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e6(Object(n),!0).forEach(function(r){b_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function b_e(t,e,n){return(e=v_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function v_e(t){var e=y_e(t,"string");return typeof e=="symbol"?e:e+""}function y_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 __e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return M.isValidElement(e)?M.cloneElement(e,r):M.createElement(n,r)}function w_e(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:a,layout:o,cursor:l,tooltipEventType:u,chartName:d}=t,f=n,g=r,m=i;if(!l||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,v;if(d==="ScatterChart")x=f,y=ege,v=Pr.cursorLine;else if(d==="BarChart")x=tge(o,f,s,a),y=oq,v=Pr.cursorRectangle;else if(o==="radial"&&H7(f)){var{cx:b,cy:E,radius:S,startAngle:A,endAngle:T}=cq(f);x={cx:b,cy:E,startAngle:A,endAngle:T,innerRadius:S,outerRadius:S},y=dq,v=Pr.cursorLine}else x={points:$ge(o,f,s)},y=Yp,v=Pr.cursorLine;var k=typeof l=="object"&&"className"in l?l.className:void 0,N=Sy(Sy(Sy(Sy({stroke:"#ccc",pointerEvents:"none"},s),x),Bh(l)),{},{payload:g,payloadIndex:m,className:Sn("recharts-tooltip-cursor",k)});return M.createElement(ms,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},M.createElement(__e,{cursor:l,cursorComp:y,cursorProps:N}))}function S_e(t){var e=$ye(),n=GW(),r=lf(),i=lX();return e==null||n==null||r==null||i==null?null:M.createElement(w_e,bk({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var fX=M.createContext(null),E_e=()=>M.useContext(fX),VT={exports:{}},t6;function M_e(){return t6||(t6=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,u,d){this.fn=l,this.context=u,this.once=d||!1}function s(l,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,f||l,g),x=n?n+u:u;return l._events[x]?l._events[x].fn?l._events[x]=[l._events[x],m]:l._events[x].push(m):(l._events[x]=m,l._eventsCount++),l}function a(l,u){--l._eventsCount===0?l._events=new r:delete l._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,m=f.length,x=new Array(m);g<m;g++)x[g]=f[g].fn;return x},o.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(u,d,f,g,m,x){var y=n?n+u:u;if(!this._events[y])return!1;var v=this._events[y],b=arguments.length,E,S;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),b){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,f),!0;case 4:return v.fn.call(v.context,d,f,g),!0;case 5:return v.fn.call(v.context,d,f,g,m),!0;case 6:return v.fn.call(v.context,d,f,g,m,x),!0}for(S=1,E=new Array(b-1);S<b;S++)E[S-1]=arguments[S];v.fn.apply(v.context,E)}else{var A=v.length,T;for(S=0;S<A;S++)switch(v[S].once&&this.removeListener(u,v[S].fn,void 0,!0),b){case 1:v[S].fn.call(v[S].context);break;case 2:v[S].fn.call(v[S].context,d);break;case 3:v[S].fn.call(v[S].context,d,f);break;case 4:v[S].fn.call(v[S].context,d,f,g);break;default:if(!E)for(T=1,E=new Array(b-1);T<b;T++)E[T-1]=arguments[T];v[S].fn.apply(v[S].context,E)}}return!0},o.prototype.on=function(u,d,f){return s(this,u,d,f,!1)},o.prototype.once=function(u,d,f){return s(this,u,d,f,!0)},o.prototype.removeListener=function(u,d,f,g){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return a(this,m),this;var x=this._events[m];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&a(this,m);else{for(var y=0,v=[],b=x.length;y<b;y++)(x[y].fn!==d||g&&!x[y].once||f&&x[y].context!==f)&&v.push(x[y]);v.length?this._events[m]=v.length===1?v[0]:v:a(this,m)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&a(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(VT)),VT.exports}var A_e=M_e();const T_e=lo(A_e);var D0=new T_e,vk="recharts.syncEvent.tooltip",n6="recharts.syncEvent.brush";function yE(t,e){if(e){var n=Number.parseInt(e,10);if(!Ys(n))return t?.[n]}}var C_e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},pX=Zs({name:"options",initialState:C_e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),N_e=pX.reducer,{createEventEmitter:k_e}=pX.actions;function P_e(t){return t.tooltip.syncInteraction}var R_e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},mX=Zs({name:"chartData",initialState:R_e,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:r6,setDataStartEndIndexes:D_e,setComputedData:T7e}=mX.actions,O_e=mX.reducer,j_e=["x","y"];function i6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Yf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i6(Object(n),!0).forEach(function(r){L_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function L_e(t,e,n){return(e=I_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I_e(t){var e=U_e(t,"string");return typeof e=="symbol"?e:e+""}function U_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 F_e(t,e){if(t==null)return{};var n,r,i=z_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 z_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 B_e(){var t=Tt(zD),e=Tt(BD),n=rr(),r=Tt(uK),i=Tt(Uc),s=lf(),a=bb(),o=Tt(l=>l.rootProps.className);M.useEffect(()=>{if(t==null)return hb;var l=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(a&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x,y}=m,v=F_e(m,j_e),{x:b,y:E,width:S,height:A}=d.payload.sourceViewBox,T=Yf(Yf({},v),{},{x:a.x+(S?(x-b)/S:0)*a.width,y:a.y+(A?(y-E)/A:0)*a.height});n(Yf(Yf({},d),{},{payload:Yf(Yf({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var k;if(typeof r=="function"){var N={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},I=r(i,N);k=i[I]}else r==="value"&&(k=i.find(K=>String(K.value)===d.payload.label));var{coordinate:C}=d.payload;if(k==null||d.payload.active===!1||C==null||a==null){n(gk({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:F}=C,j=Math.min(D,a.x+a.width),q=Math.min(F,a.y+a.height),R={x:s==="horizontal"?k.coordinate:j,y:s==="horizontal"?q:k.coordinate},W=gk({active:d.payload.active,coordinate:R,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return D0.on(vk,l),()=>{D0.off(vk,l)}},[o,n,e,t,r,i,s,a])}function H_e(){var t=Tt(zD),e=Tt(BD),n=rr();M.useEffect(()=>{if(t==null)return hb;var r=(i,s,a)=>{e!==a&&t===i&&n(D_e(s))};return D0.on(n6,r),()=>{D0.off(n6,r)}},[n,e,t])}function $_e(){var t=rr();M.useEffect(()=>{t(k_e())},[t]),B_e(),H_e()}function V_e(t,e,n,r,i,s){var a=Tt(m=>Zye(m,t,e)),o=Tt(BD),l=Tt(zD),u=Tt(uK),d=Tt(P_e),f=d?.active,g=bb();M.useEffect(()=>{if(!f&&l!=null&&o!=null){var m=gk({active:s,coordinate:n,dataKey:a,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});D0.emit(vk,l,m,o)}},[f,n,a,i,r,o,l,u,s,g])}function s6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function a6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s6(Object(n),!0).forEach(function(r){G_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function G_e(t,e,n){return(e=W_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W_e(t){var e=q_e(t,"string");return typeof e=="symbol"?e:e+""}function q_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 K_e(t){return t.dataKey}function X_e(t,e){return M.isValidElement(t)?M.cloneElement(t,e):typeof t=="function"?M.createElement(t,e):M.createElement(Dme,e)}var o6=[],Y_e={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 Y_(t){var e,n,r=wr(t,Y_e),{active:i,allowEscapeViewBox:s,animationDuration:a,animationEasing:o,content:l,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:m,reverseDirection:x,useTranslate3d:y,wrapperStyle:v,cursor:b,shared:E,trigger:S,defaultIndex:A,portal:T,axisId:k}=r,N=rr(),I=typeof A=="number"?String(A):A;M.useEffect(()=>{N(Wve({shared:E,trigger:S,axisId:k,active:i,defaultIndex:I}))},[N,E,S,k,i,I]);var C=bb(),D=nq(),F=zve(E),{activeIndex:j,isActive:q}=(e=Tt(xe=>e_e(xe,F,S,I)))!==null&&e!==void 0?e:{},R=Tt(xe=>Jye(xe,F,S,I)),W=Tt(xe=>dX(xe,F,S,I)),K=Tt(xe=>Qye(xe,F,S,I)),V=R,te=E_e(),Y=(n=i??q)!==null&&n!==void 0?n:!1,[Z,U]=iW([V,Y]),z=F==="axis"?W:void 0;V_e(F,S,K,z,j,Y);var ee=T??te;if(ee==null||C==null||F==null)return null;var ae=V??o6;Y||(ae=o6),u&&ae.length&&(ae=Q7(ae.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),g,K_e));var fe=ae.length>0,de=M.createElement(zme,{allowEscapeViewBox:s,animationDuration:a,animationEasing:o,isAnimationActive:d,active:Y,coordinate:K,hasPayload:fe,offset:f,position:m,reverseDirection:x,useTranslate3d:y,viewBox:C,wrapperStyle:v,lastBoundingBox:Z,innerRef:U,hasPortalFromProps:!!T},X_e(l,a6(a6({},r),{},{payload:ae,label:z,active:Y,activeIndex:j,coordinate:K,accessibilityLayer:D})));return M.createElement(M.Fragment,null,uc.createPortal(de,ee),Y&&M.createElement(S_e,{cursor:b,tooltipEventType:F,coordinate:K,payload:ae,index:j}))}var Lb=t=>null;Lb.displayName="Cell";function Z_e(t,e,n){return(e=Q_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q_e(t){var e=J_e(t,"string");return typeof e=="symbol"?e:e+""}function J_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)}class e1e{constructor(e){Z_e(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 l6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function t1e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l6(Object(n),!0).forEach(function(r){n1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function n1e(t,e,n){return(e=r1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r1e(t){var e=i1e(t,"string");return typeof e=="symbol"?e:e+""}function i1e(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 s1e={cacheSize:2e3,enableCache:!0},gX=t1e({},s1e),c6=new e1e(gX.cacheSize),a1e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},u6="recharts_measurement_span";function o1e(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 d6=(t,e)=>{try{var n=document.getElementById(u6);n||(n=document.createElement("span"),n.setAttribute("id",u6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,a1e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},Fx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Hm.isSsr)return{width:0,height:0};if(!gX.enableCache)return d6(e,n);var r=o1e(e,n),i=c6.get(r);if(i)return i;var s=d6(e,n);return c6.set(r,s),s},h6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,f6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,l1e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,c1e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,xX={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},u1e=Object.keys(xX),Hp="NaN";function d1e(t,e){return t*xX[e]}class Bs{static parse(e){var n,[,r,i]=(n=c1e.exec(e))!==null&&n!==void 0?n:[];return new Bs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Ys(e)&&(this.unit=""),n!==""&&!l1e.test(n)&&(this.num=NaN,this.unit=""),u1e.includes(n)&&(this.num=d1e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Bs(NaN,""):new Bs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Bs(NaN,""):new Bs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Bs(NaN,""):new Bs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Bs(NaN,""):new Bs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Ys(this.num)}}function bX(t){if(t.includes(Hp))return Hp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=h6.exec(e))!==null&&n!==void 0?n:[],a=Bs.parse(r??""),o=Bs.parse(s??""),l=i==="*"?a.multiply(o):a.divide(o);if(l.isNaN())return Hp;e=e.replace(h6,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=f6.exec(e))!==null&&u!==void 0?u:[],m=Bs.parse(d??""),x=Bs.parse(g??""),y=f==="+"?m.add(x):m.subtract(x);if(y.isNaN())return Hp;e=e.replace(f6,y.toString())}return e}var p6=/\(([^()]*)\)/;function h1e(t){for(var e=t,n;(n=p6.exec(e))!=null;){var[,r]=n;e=e.replace(p6,bX(r))}return e}function f1e(t){var e=t.replace(/\s+/g,"");return e=h1e(e),e=bX(e),e}function p1e(t){try{return f1e(t)}catch{return Hp}}function GT(t){var e=p1e(t.slice(5,-1));return e===Hp?"":e}var m1e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],g1e=["dx","dy","angle","className","breakAll"];function yk(){return yk=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},yk.apply(null,arguments)}function m6(t,e){if(t==null)return{};var n,r,i=x1e(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 x1e(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 vX=/[ \f\n\r\t\v\u2028\u2029]+/,yX=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];dr(e)||(n?i=e.toString().split(""):i=e.toString().split(vX));var s=i.map(o=>({word:o,width:Fx(o,r).width})),a=n?0:Fx(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:a}}catch{return null}};function b1e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var _X=(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 u={words:[a],width:o};i.push(u)}return i},[]),wX=t=>t.reduce((e,n)=>e.width>n.width?e:n),v1e="…",g6=(t,e,n,r,i,s,a,o)=>{var l=t.slice(0,e),u=yX({breakAll:n,style:r,children:l+v1e});if(!u)return[!1,[]];var d=_X(u.wordsWithComputedWidth,s,a,o),f=d.length>i||wX(d).width>Number(s);return[f,d]},y1e=(t,e,n,r,i)=>{var{maxLines:s,children:a,style:o,breakAll:l}=t,u=Nt(s),d=String(a),f=_X(e,r,n,i);if(!u||i)return f;var g=f.length>s||wX(f).width>Number(r);if(!g)return f;for(var m=0,x=d.length-1,y=0,v;m<=x&&y<=d.length-1;){var b=Math.floor((m+x)/2),E=b-1,[S,A]=g6(d,E,l,o,s,r,n,i),[T]=g6(d,b,l,o,s,r,n,i);if(!S&&!T&&(m=b+1),S&&T&&(x=b-1),!S&&T){v=A;break}y++}return v||f},x6=t=>{var e=dr(t)?[]:t.toString().split(vX);return[{words:e,width:void 0}]},_1e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:a}=t;if((e||n)&&!Hm.isSsr){var o,l,u=yX({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;o=d,l=f}else return x6(r);return y1e({breakAll:s,children:r,maxLines:a,style:i},o,l,e,!!n)}return x6(r)},SX="#808080",w1e={angle:0,breakAll:!1,capHeight:"0.71em",fill:SX,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},_E=M.forwardRef((t,e)=>{var n=wr(t,w1e),{x:r,y:i,lineHeight:s,capHeight:a,fill:o,scaleToFit:l,textAnchor:u,verticalAnchor:d}=n,f=m6(n,m1e),g=M.useMemo(()=>_1e({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:l,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,l,f.style,f.width]),{dx:m,dy:x,angle:y,className:v,breakAll:b}=f,E=m6(f,g1e);if(!so(r)||!so(i)||g.length===0)return null;var S=Number(r)+(Nt(m)?m:0),A=Number(i)+(Nt(x)?x:0);if(!Bn(S)||!Bn(A))return null;var T;switch(d){case"start":T=GT("calc(".concat(a,")"));break;case"middle":T=GT("calc(".concat((g.length-1)/2," * -").concat(s," + (").concat(a," / 2))"));break;default:T=GT("calc(".concat(g.length-1," * -").concat(s,")"));break}var k=[];if(l){var N=g[0].width,{width:I}=f;k.push("scale(".concat(Nt(I)&&Nt(N)?I/N:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(S,", ").concat(A,")")),k.length&&(E.transform=k.join(" ")),M.createElement("text",yk({},es(E),{ref:e,x:S,y:A,className:Sn("recharts-text",v),textAnchor:u,fill:o.includes("url")?SX:o}),g.map((C,D)=>{var F=C.words.join(b?"":" ");return M.createElement("tspan",{x:S,dy:D===0?T:s,key:"".concat(F,"-").concat(D)},F)}))});_E.displayName="Text";var S1e=["labelRef"];function E1e(t,e){if(t==null)return{};var n,r,i=M1e(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 M1e(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 b6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ir(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b6(Object(n),!0).forEach(function(r){A1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function A1e(t,e,n){return(e=T1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function T1e(t){var e=C1e(t,"string");return typeof e=="symbol"?e:e+""}function C1e(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 lc(){return lc=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},lc.apply(null,arguments)}var EX=M.createContext(null),MX=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a,children:o}=t,l=M.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a}),[e,n,r,i,s,a]);return M.createElement(EX.Provider,{value:l},o)},AX=()=>{var t=M.useContext(EX),e=bb();return t||VW(e)},N1e=M.createContext(null),k1e=()=>{var t=M.useContext(N1e),e=Tt(mK);return t||e},P1e=t=>{var{value:e,formatter:n}=t,r=dr(t.children)?e:t.children;return typeof n=="function"?n(r):r},wO=t=>t!=null&&typeof t=="function",R1e=(t,e)=>{var n=Oi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},D1e=(t,e,n,r,i)=>{var{offset:s,className:a}=t,{cx:o,cy:l,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:m}=i,x=(u+d)/2,y=R1e(f,g),v=y>=0?1:-1,b,E;switch(e){case"insideStart":b=f+v*s,E=m;break;case"insideEnd":b=g-v*s,E=!m;break;case"end":b=g+v*s,E=m;break;default:throw new Error("Unsupported position ".concat(e))}E=y<=0?E:!E;var S=Zr(o,l,x,b),A=Zr(o,l,x,b+(E?1:-1)*359),T="M".concat(S.x,",").concat(S.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
- `).concat(A.x,",").concat(A.y),k=dr(t.id)?v0("recharts-radial-line-"):t.id;return M.createElement("text",lc({},r,{dominantBaseline:"central",className:Sn("recharts-radial-bar-label",a)}),M.createElement("defs",null,M.createElement("path",{id:k,d:T})),M.createElement("textPath",{xlinkHref:"#".concat(k)},n))},O1e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:a,startAngle:o,endAngle:l}=t,u=(o+l)/2;if(n==="outside"){var{x:d,y:f}=Zr(r,i,a+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(s+a)/2,{x:m,y:x}=Zr(r,i,g,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},_k=t=>"cx"in t&&Nt(t.cx),j1e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!_k(n)&&(s=n);var{x:a,y:o,upperWidth:l,lowerWidth:u,height:d}=e,f=a,g=a+(l-u)/2,m=(f+g)/2,x=(l+u)/2,y=f+l/2,v=d>=0?1:-1,b=v*r,E=v>0?"end":"start",S=v>0?"start":"end",A=l>=0?1:-1,T=A*r,k=A>0?"end":"start",N=A>0?"start":"end";if(i==="top"){var I={x:f+l/2,y:o-b,textAnchor:"middle",verticalAnchor:E};return Ir(Ir({},I),s?{height:Math.max(o-s.y,0),width:l}:{})}if(i==="bottom"){var C={x:g+u/2,y:o+d+b,textAnchor:"middle",verticalAnchor:S};return Ir(Ir({},C),s?{height:Math.max(s.y+s.height-(o+d),0),width:u}:{})}if(i==="left"){var D={x:m-T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"};return Ir(Ir({},D),s?{width:Math.max(D.x-s.x,0),height:d}:{})}if(i==="right"){var F={x:m+x+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"};return Ir(Ir({},F),s?{width:Math.max(s.x+s.width-F.x,0),height:d}:{})}var j=s?{width:x,height:d}:{};return i==="insideLeft"?Ir({x:m+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"},j):i==="insideRight"?Ir({x:m+x-T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"},j):i==="insideTop"?Ir({x:f+l/2,y:o+b,textAnchor:"middle",verticalAnchor:S},j):i==="insideBottom"?Ir({x:g+u/2,y:o+d-b,textAnchor:"middle",verticalAnchor:E},j):i==="insideTopLeft"?Ir({x:f+T,y:o+b,textAnchor:N,verticalAnchor:S},j):i==="insideTopRight"?Ir({x:f+l-T,y:o+b,textAnchor:k,verticalAnchor:S},j):i==="insideBottomLeft"?Ir({x:g+T,y:o+d-b,textAnchor:N,verticalAnchor:E},j):i==="insideBottomRight"?Ir({x:g+u-T,y:o+d-b,textAnchor:k,verticalAnchor:E},j):i&&typeof i=="object"&&(Nt(i.x)||Ac(i.x))&&(Nt(i.y)||Ac(i.y))?Ir({x:a+ps(i.x,x),y:o+ps(i.y,d),textAnchor:"end",verticalAnchor:"end"},j):Ir({x:y,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},j)},L1e={angle:0,offset:5,zIndex:Pr.label,position:"middle",textBreakAll:!1};function Au(t){var e=wr(t,L1e),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:l,labelRef:u}=e,d=k1e(),f=AX(),g=r==="center"?f:d??f,m,x,y;if(n==null?m=g:_k(n)?m=n:m=VW(n),!m||dr(i)&&dr(s)&&!M.isValidElement(a)&&typeof a!="function")return null;var v=Ir(Ir({},e),{},{viewBox:m});if(M.isValidElement(a)){var{labelRef:b}=v,E=E1e(v,S1e);return M.cloneElement(a,E)}if(typeof a=="function"){if(x=M.createElement(a,v),M.isValidElement(x))return x}else x=P1e(e);var S=es(e);if(_k(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return D1e(e,r,x,S,m);y=O1e(m,e.offset,e.position)}else y=j1e(e,m);return M.createElement(ms,{zIndex:e.zIndex},M.createElement(_E,lc({ref:u,className:Sn("recharts-label",o)},S,y,{textAnchor:b1e(S.textAnchor)?S.textAnchor:y.textAnchor,breakAll:l}),x))}Au.displayName="Label";var I1e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?M.createElement(Au,lc({key:"label-implicit"},r)):so(t)?M.createElement(Au,lc({key:"label-implicit",value:t},r)):M.isValidElement(t)?t.type===Au?M.cloneElement(t,Ir({key:"label-implicit"},r)):M.createElement(Au,lc({key:"label-implicit",content:t},r)):wO(t)?M.createElement(Au,lc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?M.createElement(Au,lc({},t,{key:"label-implicit"},r)):null};function TX(t){var{label:e,labelRef:n}=t,r=AX();return I1e(e,r,n)||null}var WT={},qT={},v6;function U1e(){return v6||(v6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(qT)),qT}var KT={},y6;function F1e(){return y6||(y6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(KT)),KT}var _6;function z1e(){return _6||(_6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=U1e(),n=F1e(),r=YR();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(WT)),WT}var XT,w6;function B1e(){return w6||(w6=1,XT=z1e().last),XT}var H1e=B1e();const $1e=lo(H1e);var V1e=["valueAccessor"],G1e=["dataKey","clockWise","id","textBreakAll","zIndex"];function aw(){return aw=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},aw.apply(null,arguments)}function S6(t,e){if(t==null)return{};var n,r,i=W1e(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 W1e(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 q1e=t=>Array.isArray(t.value)?$1e(t.value):t.value,CX=M.createContext(void 0),SO=CX.Provider,NX=M.createContext(void 0),K1e=NX.Provider;function X1e(){return M.useContext(CX)}function Y1e(){return M.useContext(NX)}function Z_(t){var{valueAccessor:e=q1e}=t,n=S6(t,V1e),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,l=S6(n,G1e),u=X1e(),d=Y1e(),f=u||d;return!f||!f.length?null:M.createElement(ms,{zIndex:o??Pr.label},M.createElement(_r,{className:"recharts-label-list"},f.map((g,m)=>{var x,y=dr(r)?e(g,m):zn(g&&g.payload,r),v=dr(s)?{}:{id:"".concat(s,"-").concat(m)};return M.createElement(Au,aw({key:"label-".concat(m)},es(g),l,v,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:a,viewBox:g.viewBox,index:m,zIndex:0}))})))}Z_.displayName="LabelList";function wE(t){var{label:e}=t;return e?e===!0?M.createElement(Z_,{key:"labelList-implicit"}):M.isValidElement(e)||wO(e)?M.createElement(Z_,{key:"labelList-implicit",content:e}):typeof e=="object"?M.createElement(Z_,aw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function wk(){return wk=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},wk.apply(null,arguments)}var kX=t=>{var{cx:e,cy:n,r,className:i}=t,s=Sn("recharts-dot",i);return Nt(e)&&Nt(n)&&Nt(r)?M.createElement("circle",wk({},Ts(t),XR(t),{className:s,cx:e,cy:n,r})):null},PX=t=>t.graphicalItems.polarItems,Z1e=We([xr,Ab],WD),SE=We([PX,Sr,Z1e],qD),Q1e=We([SE],KD),EE=We([Q1e,LD],XD),J1e=We([EE,Sr,SE],ZD);We([EE,Sr,SE],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=zn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:zn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var E6=()=>{},ewe=We([EE,Sr,SE,xE,xr],tO),twe=We([Sr,JD,eO,E6,ewe,E6,gn,xr],nO),RX=We([Sr,gn,EE,J1e,Mb,xr,twe],rO),nwe=We([RX,Sr,Ym],aO);We([Sr,RX,nwe,xr],lO);var rwe={radiusAxis:{},angleAxis:{}},DX=Zs({name:"polarAxis",initialState:rwe,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:C7e,removeRadiusAxis:N7e,addAngleAxis:k7e,removeAngleAxis:P7e}=DX.actions,iwe=DX.reducer;function M6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function A6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M6(Object(n),!0).forEach(function(r){swe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function swe(t,e,n){return(e=awe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function awe(t){var e=owe(t,"string");return typeof e=="symbol"?e:e+""}function owe(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 lwe=(t,e)=>e,EO=We([PX,lwe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),cwe=[],MO=(t,e,n)=>n?.length===0?cwe:n,OX=We([LD,EO,MO],(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=>A6(A6({},e.presentationProps),s.props))),i!=null)return i}}),uwe=We([OX,EO,MO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=zn(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:xd(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),dwe=We([OX,EO,MO,gi],(t,e,n,r)=>{if(!(e==null||t==null))return hSe({offset:r,pieSettings:e,displayedData:t,cells:n})}),YT={exports:{}},Gn={};var T6;function hwe(){if(T6)return Gn;T6=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"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function x(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 u:case g:return y;default:switch(y=y&&y.$$typeof,y){case a:case o:case f:case d:return y;case s:return y;default:return v}}case e:return v}}}return Gn.ContextConsumer=s,Gn.ContextProvider=a,Gn.Element=t,Gn.ForwardRef=o,Gn.Fragment=n,Gn.Lazy=f,Gn.Memo=d,Gn.Portal=e,Gn.Profiler=i,Gn.StrictMode=r,Gn.Suspense=l,Gn.SuspenseList=u,Gn.isContextConsumer=function(y){return x(y)===s},Gn.isContextProvider=function(y){return x(y)===a},Gn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Gn.isForwardRef=function(y){return x(y)===o},Gn.isFragment=function(y){return x(y)===n},Gn.isLazy=function(y){return x(y)===f},Gn.isMemo=function(y){return x(y)===d},Gn.isPortal=function(y){return x(y)===e},Gn.isProfiler=function(y){return x(y)===i},Gn.isStrictMode=function(y){return x(y)===r},Gn.isSuspense=function(y){return x(y)===l},Gn.isSuspenseList=function(y){return x(y)===u},Gn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===l||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===a||y.$$typeof===s||y.$$typeof===o||y.$$typeof===m||y.getModuleId!==void 0)},Gn.typeOf=x,Gn}var C6;function fwe(){return C6||(C6=1,YT.exports=hwe()),YT.exports}var pwe=fwe(),N6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",k6=null,ZT=null,jX=t=>{if(t===k6&&Array.isArray(ZT))return ZT;var e=[];return M.Children.forEach(t,n=>{dr(n)||(pwe.isFragment(n)?e=e.concat(jX(n.props.children)):e.push(n))}),ZT=e,k6=t,e};function AO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>N6(i)):r=[N6(e)],jX(t).forEach(i=>{var s=Hh(i,"type.displayName")||Hh(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var TO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,QT={},P6;function mwe(){return P6||(P6=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})(QT)),QT}var JT,R6;function gwe(){return R6||(R6=1,JT=mwe().isPlainObject),JT}var xwe=gwe();const bwe=lo(xwe);function D6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D6(Object(n),!0).forEach(function(r){vwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vwe(t,e,n){return(e=ywe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ywe(t){var e=_we(t,"string");return typeof e=="symbol"?e:e+""}function _we(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 ow(){return ow=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},ow.apply(null,arguments)}var j6=(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},wwe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Swe=t=>{var e=wr(t,wwe),{x:n,y:r,upperWidth:i,lowerWidth:s,height:a,className:o}=e,{animationEasing:l,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=M.useRef(null),[m,x]=M.useState(-1),y=M.useRef(i),v=M.useRef(s),b=M.useRef(a),E=M.useRef(n),S=M.useRef(r),A=Vm(t,"trapezoid-");if(M.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&x(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||s!==+s||a!==+a||i===0&&s===0||a===0)return null;var T=Sn("recharts-trapezoid",o);if(!f)return M.createElement("g",null,M.createElement("path",ow({},es(e),{className:T,d:j6(n,r,i,s,a)})));var k=y.current,N=v.current,I=b.current,C=E.current,D=S.current,F="0px ".concat(m===-1?1:m,"px"),j="".concat(m,"px 0px"),q=rq(["strokeDasharray"],u,l);return M.createElement($m,{animationId:A,key:A,canBegin:m>0,duration:u,easing:l,isActive:f,begin:d},R=>{var W=Rn(k,i,R),K=Rn(N,s,R),V=Rn(I,a,R),te=Rn(C,n,R),Y=Rn(D,r,R);g.current&&(y.current=W,v.current=K,b.current=V,E.current=te,S.current=Y);var Z=R>0?{transition:q,strokeDasharray:j}:{strokeDasharray:F};return M.createElement("path",ow({},es(e),{className:T,d:j6(te,Y,W,K,V),ref:g,style:O6(O6({},Z),e.style)}))})},Ewe=["option","shapeType","propTransformer","activeClassName"];function Mwe(t,e){if(t==null)return{};var n,r,i=Awe(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 Awe(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 L6(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 lw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L6(Object(n),!0).forEach(function(r){Twe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Twe(t,e,n){return(e=Cwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cwe(t){var e=Nwe(t,"string");return typeof e=="symbol"?e:e+""}function Nwe(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 kwe(t,e){return lw(lw({},e),t)}function Pwe(t,e){return t==="symbols"}function I6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return M.createElement(oq,n);case"trapezoid":return M.createElement(Swe,n);case"sector":return M.createElement(dq,n);case"symbols":if(Pwe(e))return M.createElement(KR,n);break;case"curve":return M.createElement(Yp,n);default:return null}}function Rwe(t){return M.isValidElement(t)?t.props:t}function CO(t){var{option:e,shapeType:n,propTransformer:r=kwe,activeClassName:i="recharts-active-shape"}=t,s=Mwe(t,Ewe),a;if(M.isValidElement(e))a=M.cloneElement(e,lw(lw({},s),Rwe(e)));else if(typeof e=="function")a=e(s,s.index);else if(bwe(e)&&typeof e!="boolean"){var o=r(e,s);a=M.createElement(I6,{shapeType:n,elementProps:o})}else{var l=s;a=M.createElement(I6,{shapeType:n,elementProps:l})}return s.isActive?M.createElement(_r,{className:i},a):a}var NO=(t,e,n)=>{var r=rr();return(i,s)=>a=>{t?.(i,s,a),r(WK({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},kO=t=>{var e=rr();return(n,r)=>i=>{t?.(n,r,i),e(qve())}},PO=(t,e,n)=>{var r=rr();return(i,s)=>a=>{t?.(i,s,a),r(Kve({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function ME(t){var{tooltipEntrySettings:e}=t,n=rr(),r=xi(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n($ve(e)):i.current!==e&&n(Vve({prev:i.current,next:e})),i.current=e)},[e,n,r]),M.useLayoutEffect(()=>()=>{i.current&&(n(Gve(i.current)),i.current=null)},[n]),null}function RO(t){var{legendPayload:e}=t,n=rr(),r=xi(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(JW(e)):i.current!==e&&n(eq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(tq(i.current)),i.current=null)},[n]),null}function Dwe(t){var{legendPayload:e}=t,n=rr(),r=Tt(gn),i=M.useRef(null);return M.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(JW(e)):i.current!==e&&n(eq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(tq(i.current)),i.current=null)},[n]),null}var eC,Owe=()=>{var[t]=M.useState(()=>v0("uid-"));return t},jwe=(eC=vre.useId)!==null&&eC!==void 0?eC:Owe;function LX(t,e){var n=jwe();return e||(t?"".concat(t,"-").concat(n):n)}var Lwe=M.createContext(void 0),AE=t=>{var{id:e,type:n,children:r}=t,i=LX("recharts-".concat(n),e);return M.createElement(Lwe.Provider,{value:i},r(i))},Iwe={cartesianItems:[],polarItems:[]},IX=Zs({name:"graphicalItems",initialState:Iwe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ro(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ro(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:fr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:fr()},removePolarGraphicalItem:{reducer(t,e){var n=Ro(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:fr()}}}),{addCartesianGraphicalItem:Uwe,replaceCartesianGraphicalItem:Fwe,removeCartesianGraphicalItem:zwe,addPolarGraphicalItem:Bwe,removePolarGraphicalItem:Hwe}=IX.actions,$we=IX.reducer,Vwe=t=>{var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(Uwe(t)):n.current!==t&&e(Fwe({prev:n.current,next:t})),n.current=t},[e,t]),M.useLayoutEffect(()=>()=>{n.current&&(e(zwe(n.current)),n.current=null)},[e]),null},DO=M.memo(Vwe);function Gwe(t){var e=rr();return M.useLayoutEffect(()=>(e(Bwe(t)),()=>{e(Hwe(t))}),[e,t]),null}var Wwe=["key"],qwe=["onMouseEnter","onClick","onMouseLeave"],Kwe=["id"],Xwe=["id"];function U6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Nr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U6(Object(n),!0).forEach(function(r){Ywe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ywe(t,e,n){return(e=Zwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Zwe(t){var e=Qwe(t,"string");return typeof e=="symbol"?e:e+""}function Qwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function 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 TE(t,e){if(t==null)return{};var n,r,i=Jwe(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 Jwe(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 eSe(t){var e=M.useMemo(()=>AO(t.children,Lb),[t.children]),n=Tt(r=>uwe(r,t.id,e));return n==null?null:M.createElement(Dwe,{legendPayload:n})}var tSe=M.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:a,name:o,hide:l,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:a,dataKey:e,nameKey:n,name:xd(o,e),hide:l,type:u,color:a,unit:""}};return M.createElement(ME,{tooltipEntrySettings:d})}),nSe=(t,e)=>t>e?"start":t<e?"end":"middle",rSe=(t,e,n)=>ps(typeof e=="function"?e(t):e,n,n*.8),iSe=(t,e,n)=>{var{top:r,left:i,width:s,height:a}=e,o=lq(s,a),l=i+ps(t.cx,s,s/2),u=r+ps(t.cy,a,a/2),d=ps(t.innerRadius,o,0),f=rSe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(s*s+a*a)/2;return{cx:l,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},sSe=(t,e)=>{var n=Oi(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function aSe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var oSe=(t,e)=>{if(M.isValidElement(t))return M.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Sn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=TE(e,Wwe);return M.createElement(Yp,od({},i,{type:"linear",className:n}))},lSe=(t,e,n)=>{if(M.isValidElement(t))return M.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),M.isValidElement(r)))return r;var i=Sn("recharts-pie-label-text",aSe(t));return M.createElement(_E,od({},e,{alignmentBaseline:"middle",className:i}),r)};function cSe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:a}=n;if(!r||!i||!e)return null;var o=Ts(n),l=Bh(i),u=Bh(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,m)=>{var x=(g.startAngle+g.endAngle)/2,y=Zr(g.cx,g.cy,g.outerRadius+d,x),v=Nr(Nr(Nr(Nr({},o),g),{},{stroke:"none"},l),{},{index:m,textAnchor:nSe(y.x,g.cx)},y),b=Nr(Nr(Nr(Nr({},o),g),{},{fill:"none",stroke:g.fill},u),{},{index:m,points:[Zr(g.cx,g.cy,g.outerRadius,x),y],key:"line"});return M.createElement(ms,{zIndex:Pr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},M.createElement(_r,null,s&&oSe(s,b),lSe(i,v,zn(g,a))))});return M.createElement(_r,{className:"recharts-pie-labels"},f)}function uSe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?M.createElement(wE,{label:i}):M.createElement(cSe,{sectors:e,props:n,showLabels:r})}function dSe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=Tt(ad),l=Tt(xO),u=Tt(Dye),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,m=TE(i,qwe),x=NO(d,i.dataKey,a),y=kO(g),v=PO(f,i.dataKey,a);return e==null||e.length===0?null:M.createElement(M.Fragment,null,e.map((b,E)=>{if(b?.startAngle===0&&b?.endAngle===0&&e.length!==1)return null;var S=u==null||u===a,A=String(E)===o&&(l==null||i.dataKey===l)&&S,T=o?r:null,k=n&&A?n:T,N=Nr(Nr({},b),{},{stroke:b.stroke,tabIndex:-1,[FW]:E,[zW]:i.dataKey});return M.createElement(_r,od({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},fb(m,b,E),{onMouseEnter:x(b,E),onMouseLeave:y(b,E),onClick:v(b,E)}),M.createElement(CO,od({option:s??k,index:E,shapeType:"sector",isActive:A},N)))}))}function hSe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:a,startAngle:o,endAngle:l,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),m=sSe(o,l),x=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(k=>zn(k,u,0)!==0).length,b=(x>=360?v:v-1)*y,E=x-v*g-b,S=r.reduce((k,N)=>{var I=zn(N,u,0);return k+(Nt(I)?I:0)},0),A;if(S>0){var T;A=r.map((k,N)=>{var I=zn(k,u,0),C=zn(k,d,N),D=iSe(n,s,k),F=(Nt(I)?I:0)/S,j,q=Nr(Nr({},k),i&&i[N]&&i[N].props);N?j=T.endAngle+Oi(m)*y*(I!==0?1:0):j=o;var R=j+Oi(m)*((I!==0?g:0)+F*E),W=(j+R)/2,K=(D.innerRadius+D.outerRadius)/2,V=[{name:C,value:I,payload:q,dataKey:u,type:f}],te=Zr(D.cx,D.cy,K,W);return T=Nr(Nr(Nr(Nr({},n.presentationProps),{},{percent:F,cornerRadius:typeof a=="string"?parseFloat(a):a,name:C,tooltipPayload:V,midAngle:W,middleRadius:K,tooltipPosition:te},q),D),{},{value:I,dataKey:u,startAngle:j,endAngle:R,payload:q,paddingAngle:Oi(m)*y}),T})}return A}function fSe(t){var{showLabels:e,sectors:n,children:r}=t,i=M.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 M.createElement(K1e,{value:e?i:void 0},r)}function pSe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,m=Vm(e,"recharts-pie-"),x=n.current,[y,v]=M.useState(!1),b=M.useCallback(()=>{typeof g=="function"&&g(),v(!1)},[g]),E=M.useCallback(()=>{typeof f=="function"&&f(),v(!0)},[f]);return M.createElement(fSe,{showLabels:!y,sectors:i},M.createElement($m,{animationId:m,begin:a,duration:o,isActive:s,easing:l,onAnimationStart:E,onAnimationEnd:b,key:m},S=>{var A=[],T=i&&i[0],k=T?.startAngle;return i?.forEach((N,I)=>{var C=x&&x[I],D=I>0?Hh(N,"paddingAngle",0):0;if(C){var F=Rn(C.endAngle-C.startAngle,N.endAngle-N.startAngle,S),j=Nr(Nr({},N),{},{startAngle:k+D,endAngle:k+F+D});A.push(j),k=j.endAngle}else{var{endAngle:q,startAngle:R}=N,W=Rn(0,q-R,S),K=Nr(Nr({},N),{},{startAngle:k+D,endAngle:k+W+D});A.push(K),k=K.endAngle}}),n.current=A,M.createElement(_r,null,M.createElement(dSe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),M.createElement(uSe,{showLabels:!y,sectors:i,props:e}),e.children)}var mSe={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:Pr.area};function gSe(t){var{id:e}=t,n=TE(t,Kwe),{hide:r,className:i,rootTabIndex:s}=t,a=M.useMemo(()=>AO(t.children,Lb),[t.children]),o=Tt(d=>dwe(d,e,a)),l=M.useRef(null),u=Sn("recharts-pie",i);return r||o==null?(l.current=null,M.createElement(_r,{tabIndex:s,className:u})):M.createElement(ms,{zIndex:t.zIndex},M.createElement(tSe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),M.createElement(_r,{tabIndex:s,className:u},M.createElement(pSe,{props:Nr(Nr({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function UX(t){var e=wr(t,mSe),{id:n}=e,r=TE(e,Xwe),i=Ts(r);return M.createElement(AE,{id:n,type:"pie"},s=>M.createElement(M.Fragment,null,M.createElement(Gwe,{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}),M.createElement(eSe,od({},r,{id:s})),M.createElement(gSe,od({},r,{id:s}))))}UX.displayName="Pie";var xSe=["points"];function F6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F6(Object(n),!0).forEach(function(r){bSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bSe(t,e,n){return(e=vSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vSe(t){var e=ySe(t,"string");return typeof e=="symbol"?e:e+""}function ySe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function cw(){return cw=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},cw.apply(null,arguments)}function _Se(t,e){if(t==null)return{};var n,r,i=wSe(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 wSe(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 SSe(t){var{option:e,dotProps:n,className:r}=t;if(M.isValidElement(e))return M.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Sn(r,typeof e!="boolean"?e.className:""),s=n??{},{points:a}=s,o=_Se(s,xSe);return M.createElement(kX,cw({},o,{className:i}))}function ESe(t,e){return t==null?!1:e?!0:t.length===1}function FX(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:a,needClip:o,clipPathId:l,zIndex:u=Pr.scatter}=t;if(!ESe(e,n))return null;var d=TO(n),f=tde(n),g=e.map((x,y)=>{var v,b,E=tC(tC(tC({r:3},a),f),{},{index:y,cx:(v=x.x)!==null&&v!==void 0?v:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:s,value:x.value,payload:x.payload,points:e});return M.createElement(SSe,{key:"dot-".concat(y),option:n,dotProps:E,className:i})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(l,")")),M.createElement(ms,{zIndex:u},M.createElement(_r,cw({className:r},m),g))}function z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function B6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z6(Object(n),!0).forEach(function(r){MSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MSe(t,e,n){return(e=ASe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ASe(t){var e=TSe(t,"string");return typeof e=="symbol"?e:e+""}function TSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var CSe={xAxis:{},yAxis:{},zAxis:{}},zX=Zs({name:"cartesianAxis",initialState:CSe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:fr()},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:fr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:fr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:fr()},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:fr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:fr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:fr()},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:fr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:fr()},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]=B6(B6({},t.yAxis[n]),{},{width:r,widthHistory:a})}}}}),{addXAxis:NSe,replaceXAxis:kSe,removeXAxis:PSe,addYAxis:RSe,replaceYAxis:DSe,removeYAxis:OSe,addZAxis:R7e,replaceZAxis:D7e,removeZAxis:O7e,updateYAxisWidth:jSe}=zX.actions,LSe=zX.reducer,ISe=We([gi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),USe=We([ISe,jc,Lc],(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)}}),CE=()=>Tt(USe),FSe=()=>Tt(Uye);function H6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H6(Object(n),!0).forEach(function(r){zSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zSe(t,e,n){return(e=BSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BSe(t){var e=HSe(t,"string");return typeof e=="symbol"?e:e+""}function HSe(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 $Se=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=nC(nC(nC({},o),Bh(i)),XR(i)),u;return M.isValidElement(i)?u=M.cloneElement(i,l):typeof i=="function"?u=i(l):u=M.createElement(kX,l),M.createElement(_r,{className:"recharts-active-dot",clipPath:a},u)};function Sk(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:a=Pr.activeDot}=t,o=Tt(ad),l=FSe();if(e==null||l==null)return null;var u=e.find(d=>l.includes(d.payload));return dr(u)?null:M.createElement(ms,{zIndex:a},M.createElement($Se,{point:u,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var VSe="Invariant failed";function GSe(t,e){throw new Error(VSe)}var WSe=["x","y"];function Ek(){return Ek=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},Ek.apply(null,arguments)}function $6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ax(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$6(Object(n),!0).forEach(function(r){qSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qSe(t,e,n){return(e=KSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KSe(t){var e=XSe(t,"string");return typeof e=="symbol"?e:e+""}function XSe(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 YSe(t,e){if(t==null)return{};var n,r,i=ZSe(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 ZSe(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 QSe(t,e){var{x:n,y:r}=t,i=YSe(t,WSe),s="".concat(n),a=parseInt(s,10),o="".concat(r),l=parseInt(o,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return ax(ax(ax(ax(ax({},e),i),a?{x:a}:{}),l?{y:l}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function uw(t){return M.createElement(CO,Ek({shapeType:"rectangle",propTransformer:QSe,activeClassName:"recharts-active-bar"},t))}var JSe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Nt(e))return e;var s=Nt(r)||dr(r);return s?e(r,i):(s||GSe(),n)}},eEe={},BX=Zs({name:"errorBars",initialState:eEe,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:j7e,replaceErrorBar:L7e,removeErrorBar:I7e}=BX.actions,tEe=BX.reducer,nEe=["children"];function rEe(t,e){if(t==null)return{};var n,r,i=iEe(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 iEe(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 sEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},aEe=M.createContext(sEe);function HX(t){var{children:e}=t,n=rEe(t,nEe);return M.createElement(aEe.Provider,{value:n},e)}function NE(t,e){var n,r,i=Tt(u=>_l(u,t)),s=Tt(u=>wl(u,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ni.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:ki.allowDataOverflow,l=a||o;return{needClip:l,needClipX:a,needClipY:o}}function OO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=CE(),{needClipX:s,needClipY:a,needClip:o}=NE(e,n);if(!o||!i)return null;var{x:l,y:u,width:d,height:f}=i;return M.createElement("clipPath",{id:"clipPath-".concat(r)},M.createElement("rect",{x:s?l:l-d/2,y:a?u:u-f/2,width:s?d:d*2,height:a?f:f*2}))}function oEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Bn(t.zIndex)?t.zIndex:e}var rC={exports:{}},iC={};var V6;function lEe(){if(V6)return iC;V6=1;var t=Im();function e(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}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 iC.useSyncExternalStoreWithSelector=function(l,u,d,f,g){var m=i(null);if(m.current===null){var x={hasValue:!1,value:null};m.current=x}else x=m.current;m=a(function(){function v(T){if(!b){if(b=!0,E=T,T=f(T),g!==void 0&&x.hasValue){var k=x.value;if(g(k,T))return S=k}return S=T}if(k=S,n(E,T))return k;var N=f(T);return g!==void 0&&g(k,N)?(E=T,k):(E=T,S=N)}var b=!1,E,S,A=d===void 0?null:d;return[function(){return v(u())},A===null?void 0:function(){return v(A())}]},[u,d,f,g]);var y=r(l,m[0],m[1]);return s(function(){x.hasValue=!0,x.value=y},[y]),o(y),y},iC}var G6;function cEe(){return G6||(G6=1,rC.exports=lEe()),rC.exports}cEe();function uEe(t){t()}function dEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){uEe(()=>{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 W6={notify(){},get:()=>[]};function hEe(t,e){let n,r=W6,i=0,s=!1;function a(y){d();const v=r.subscribe(y);let b=!1;return()=>{b||(b=!0,v(),f())}}function o(){r.notify()}function l(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(l),r=dEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=W6)}function g(){s||(s=!0,d())}function m(){s&&(s=!1,f())}const x={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:u,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return x}var fEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",pEe=fEe(),mEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",gEe=mEe(),xEe=()=>pEe||gEe?M.useLayoutEffect:M.useEffect,bEe=xEe();function q6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function vEe(t,e){if(q6(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])||!q6(t[n[i]],e[n[i]]))return!1;return!0}var yEe=Symbol.for("react-redux-context"),_Ee=typeof globalThis<"u"?globalThis:{};function wEe(){if(!M.createContext)return{};const t=_Ee[yEe]??=new Map;let e=t.get(M.createContext);return e||(e=M.createContext(null),t.set(M.createContext,e)),e}var SEe=wEe();function EEe(t){const{children:e,context:n,serverState:r,store:i}=t,s=M.useMemo(()=>{const l=hEe(i);return{store:i,subscription:l,getServerState:r?()=>r:void 0}},[i,r]),a=M.useMemo(()=>i.getState(),[i]);bEe(()=>{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||SEe;return M.createElement(o.Provider,{value:s},e)}var MEe=EEe,AEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function TEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Ib(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(AEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!vEe(t[r],e[r]))return!1}else if(!TEe(t[r],e[r]))return!1;return!0}var CEe=["onMouseEnter","onMouseLeave","onClick"],NEe=["value","background","tooltipPosition"],kEe=["id"],PEe=["onMouseEnter","onClick","onMouseLeave"];function Rc(){return Rc=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},Rc.apply(null,arguments)}function K6(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?K6(Object(n),!0).forEach(function(r){REe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function REe(t,e,n){return(e=DEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DEe(t){var e=OEe(t,"string");return typeof e=="symbol"?e:e+""}function OEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dw(t,e){if(t==null)return{};var n,r,i=jEe(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 jEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var LEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:xd(n,e),payload:t}]},IEe=M.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:a,unit:o,tooltipType:l}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:xd(s,e),hide:a,type:l,color:i,unit:o}};return M.createElement(ME,{tooltipEntrySettings:u})});function UEe(t){var e=Tt(ad),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:l}=s,u=dw(s,CEe),d=NO(a,r),f=kO(o),g=PO(l,r);if(!i||n==null)return null;var m=Bh(i);return M.createElement(ms,{zIndex:oEe(i,Pr.barBackground)},n.map((x,y)=>{var{value:v,background:b,tooltipPosition:E}=x,S=dw(x,NEe);if(!b)return null;var A=d(x,y),T=f(x,y),k=g(x,y),N=Ss(Ss(Ss(Ss(Ss({option:i,isActive:String(y)===e},S),{},{fill:"#eee"},b),m),fb(u,x,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return M.createElement(uw,Rc({key:"background-bar-".concat(y)},N))}))}function FEe(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 Ss(Ss({},a),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:a,fill:s.fill})});return M.createElement(SO,{value:e?i:void 0},n)}function zEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=Tt(ad),l=Tt(xO),u=n&&String(s)===o&&(l==null||a===l),d=u?n:e;return u?M.createElement(ms,{zIndex:Pr.activeBar},M.createElement(uw,Rc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))):M.createElement(uw,Rc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))}function BEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return M.createElement(uw,Rc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function HEe(t){var e,{data:n,props:r}=t,i=(e=Ts(r))!==null&&e!==void 0?e:{},{id:s}=i,a=dw(i,kEe),{shape:o,dataKey:l,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,m=dw(r,PEe),x=NO(d,l),y=kO(g),v=PO(f,l);return n?M.createElement(M.Fragment,null,n.map((b,E)=>M.createElement(_r,Rc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(E),className:"recharts-bar-rectangle"},fb(m,b,E),{onMouseEnter:x(b,E),onMouseLeave:y(b,E),onClick:v(b,E)}),u?M.createElement(zEe,{shape:o,activeBar:u,baseProps:a,entry:b,index:E,dataKey:l}):M.createElement(BEe,{shape:o,baseProps:a,entry:b,index:E,dataKey:l})))):null}function $Ee(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:l,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=Vm(e,"recharts-bar-"),[m,x]=M.useState(!1),y=!m,v=M.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),b=M.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return M.createElement(FEe,{showLabels:y,rects:r},M.createElement($m,{animationId:g,begin:a,duration:o,isActive:s,easing:l,onAnimationEnd:v,onAnimationStart:b,key:g},E=>{var S=E===1?r:r?.map((A,T)=>{var k=f&&f[T];if(k)return Ss(Ss({},A),{},{x:Rn(k.x,A.x,E),y:Rn(k.y,A.y,E),width:Rn(k.width,A.width,E),height:Rn(k.height,A.height,E)});if(i==="horizontal"){var N=Rn(0,A.height,E),I=Rn(A.stackedBarStart,A.y,E);return Ss(Ss({},A),{},{y:I,height:N})}var C=Rn(0,A.width,E),D=Rn(A.stackedBarStart,A.x,E);return Ss(Ss({},A),{},{width:C,x:D})});return E>0&&(n.current=S??null),S==null?null:M.createElement(_r,null,M.createElement(HEe,{props:e,data:S}))}),M.createElement(wE,{label:e.label}),e.children)}function VEe(t){var e=M.useRef(null);return M.createElement($Ee,{previousRectanglesRef:e,props:t})}var $X=0,GEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:zn(t,e)}};class WEe extends M.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:a,needClip:o,background:l,id:u}=this.props;if(e||n==null)return null;var d=Sn("recharts-bar",i),f=u;return M.createElement(_r,{className:d,id:u},o&&M.createElement("defs",null,M.createElement(OO,{clipPathId:f,xAxisId:s,yAxisId:a})),M.createElement(_r,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},M.createElement(UEe,{data:n,dataKey:r,background:l,allOtherBarProps:this.props}),M.createElement(VEe,this.props)))}}var qEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:$X,xAxisId:0,yAxisId:0,zIndex:Pr.bar};function KEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=NE(e,n),g=lf(),m=xi(),x=AO(t.children,Lb),y=Tt(E=>wMe(E,e,n,m,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var v,b=y?.[0];return b==null||b.height==null||b.width==null?v=0:v=g==="vertical"?b.height/2:b.width/2,M.createElement(HX,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:GEe,errorBarOffset:v},M.createElement(WEe,Rc({},t,{layout:g,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:l,animationEasing:u,isAnimationActive:d})))}function XEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:a,yAxis:o,xAxisTicks:l,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:m,parentViewBox:x,dataStartIndex:y}=t,v=e==="horizontal"?o:a,b=d?v.scale.domain():null,E=bpe({numericAxis:v}),S=v.scale(E);return f.map((A,T)=>{var k,N,I,C,D,F;d?k=fpe(d[T+y],b):(k=zn(A,n),Array.isArray(k)||(k=[E,k]));var j=JSe(r,$X)(k[1],T);if(e==="horizontal"){var q,[R,W]=[o.scale(k[0]),o.scale(k[1])];N=dz({axis:a,ticks:l,bandSize:s,offset:i.offset,entry:A,index:T}),I=(q=W??R)!==null&&q!==void 0?q:void 0,C=i.size;var K=R-W;if(D=Ys(K)?0:K,F={x:N,y:g.top,width:C,height:g.height},Math.abs(j)>0&&Math.abs(D)<Math.abs(j)){var V=Oi(D||j)*(Math.abs(j)-Math.abs(D));I-=V,D+=V}}else{var[te,Y]=[a.scale(k[0]),a.scale(k[1])];if(N=te,I=dz({axis:o,ticks:u,bandSize:s,offset:i.offset,entry:A,index:T}),C=Y-te,D=i.size,F={x:g.left,y:I,width:g.width,height:D},Math.abs(j)>0&&Math.abs(C)<Math.abs(j)){var Z=Oi(C||j)*(Math.abs(j)-Math.abs(C));C+=Z}}if(N==null||I==null||C==null||D==null)return null;var U=Ss(Ss({},A),{},{stackedBarStart:S,x:N,y:I,width:C,height:D,value:d?k:k[1],payload:A,background:F,tooltipPosition:{x:N+C/2,y:I+D/2},parentViewBox:x},m&&m[T]&&m[T].props);return U}).filter(Boolean)}function YEe(t){var e=wr(t,qEe),n=xi();return M.createElement(AE,{id:e.id,type:"bar"},r=>M.createElement(M.Fragment,null,M.createElement(RO,{legendPayload:LEe(e)}),M.createElement(IEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),M.createElement(DO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:IW(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),M.createElement(ms,{zIndex:e.zIndex},M.createElement(KEe,Rc({},e,{id:r})))))}var VX=M.memo(YEe,Ib);VX.displayName="Bar";function X6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ey(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X6(Object(n),!0).forEach(function(r){ZEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZEe(t,e,n){return(e=QEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QEe(t){var e=JEe(t,"string");return typeof e=="symbol"?e:e+""}function JEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var eMe=(t,e)=>e,tMe=(t,e,n)=>n,nMe=(t,e,n,r)=>r,rMe=(t,e,n,r,i)=>i,Ub=We([Cb,rMe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),iMe=We([Ub],t=>t?.maxBarSize),sMe=(t,e,n,r,i,s)=>s,Y6=(t,e,n)=>{var r=n??t;if(!dr(r))return ps(r,e,0)},aMe=We([gn,Cb,eMe,tMe,nMe],(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")),oMe=(t,e,n,r)=>{var i=gn(t);return i==="horizontal"?R0(t,"yAxis",n,r):R0(t,"xAxis",e,r)},lMe=(t,e,n)=>{var r=gn(t);return r==="horizontal"?VB(t,"xAxis",e):VB(t,"yAxis",n)},cMe=(t,e,n)=>{var r={},i=t.filter(fE),s=t.filter(u=>u.stackId==null),a=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),o=Object.entries(a).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),m=Y6(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),l=s.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=Y6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...o,...l]},uMe=We([aMe,jbe,lMe],cMe),dMe=(t,e,n,r,i)=>{var s,a,o=Ub(t,e,n,r,i);if(o!=null){var l=gn(t),u=oK(t),{maxBarSize:d}=o,f=dr(d)?u:d,g,m;return l==="horizontal"?(g=fl(t,"xAxis",e,r),m=hl(t,"xAxis",e,r)):(g=fl(t,"yAxis",n,r),m=hl(t,"yAxis",n,r)),(s=(a=rd(g,m,!0))!==null&&a!==void 0?a:f)!==null&&s!==void 0?s:0}},GX=(t,e,n,r)=>{var i=gn(t),s,a;return i==="horizontal"?(s=fl(t,"xAxis",e,r),a=hl(t,"xAxis",e,r)):(s=fl(t,"yAxis",n,r),a=hl(t,"yAxis",n,r)),rd(s,a)};function hMe(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=ps(t,n,0,!0),o,l=[];if(Bn(r[0].barSize)){var u=!1,d=n/s,f=r.reduce((b,E)=>b+(E.barSize||0),0);f+=(s-1)*a,f>=n&&(f-=(s-1)*a,a=0),f>=n&&d>0&&(u=!0,d*=.9,f=s*d);var g=(n-f)/2>>0,m={offset:g-a,size:0};o=r.reduce((b,E)=>{var S,A={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:m.offset+m.size+a,size:u?d:(S=E.barSize)!==null&&S!==void 0?S:0}},T=[...b,A];return m=T[T.length-1].position,T},l)}else{var x=ps(e,n,0,!0);n-2*x-(s-1)*a<=0&&(a=0);var y=(n-2*x-(s-1)*a)/s;y>1&&(y>>=0);var v=Bn(i)?Math.min(y,i):y;o=r.reduce((b,E,S)=>[...b,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(y+a)*S+(y-v)/2,size:v}}],l)}return o}}var fMe=(t,e,n,r,i,s,a)=>{var o=dr(a)?e:a,l=hMe(n,r,i!==s?i:s,t,o);return i!==s&&l!=null&&(l=l.map(u=>Ey(Ey({},u),{},{position:Ey(Ey({},u.position),{},{offset:u.position.offset-i/2})}))),l},pMe=We([uMe,oK,Obe,lK,dMe,GX,iMe],fMe),mMe=(t,e,n,r)=>fl(t,"xAxis",e,r),gMe=(t,e,n,r)=>fl(t,"yAxis",n,r),xMe=(t,e,n,r)=>hl(t,"xAxis",e,r),bMe=(t,e,n,r)=>hl(t,"yAxis",n,r),vMe=We([pMe,Ub],(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}}),yMe=(t,e)=>{var n=hE(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:s}=i;if(s)return s.find(a=>a.key===n)}}}},_Me=We([oMe,Ub],yMe),wMe=We([gi,aD,mMe,gMe,xMe,bMe,vMe,gn,Eb,GX,_Me,Ub,sMe],(t,e,n,r,i,s,a,o,l,u,d,f,g)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:y}=l;if(!(f==null||a==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:v}=f,b;if(v!=null&&v.length>0?b=v:b=m?.slice(x,y+1),b!=null)return XEe({layout:o,barSettings:f,pos:a,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:b,offset:t,cells:g,dataStartIndex:x})}}),WX=t=>{var{chartData:e}=t,n=rr(),r=xi();return M.useEffect(()=>r?()=>{}:(n(r6(e)),()=>{n(r6(void 0))}),[e,n,r]),null},Z6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},qX=Zs({name:"brush",initialState:Z6,reducers:{setBrushSettings(t,e){return e.payload==null?Z6:e.payload}}}),{setBrushSettings:U7e}=qX.actions,SMe=qX.reducer;function Q6(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 My(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q6(Object(n),!0).forEach(function(r){KX(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KX(t,e,n){return(e=EMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EMe(t){var e=MMe(t,"string");return typeof e=="symbol"?e:e+""}function MMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var AMe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return{x:Math.min(n,i),y:Math.min(r,s),width:Math.abs(i-n),height:Math.abs(s-r)}},TMe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return AMe({x:e,y:n},{x:r,y:i})};class kE{static create(e){return new kE(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}}KX(kE,"EPS",1e-4);var CMe=t=>{var e=Object.keys(t).reduce((n,r)=>My(My({},n),{},{[r]:kE.create(t[r])}),{});return My(My({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(s=>{var[a,o]=s;return[a,e[a].apply(o,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function NMe(t){return(t%180+180)%180}var kMe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=NMe(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)},PMe={dots:[],areas:[],lines:[]},XX=Zs({name:"referenceElements",initialState:PMe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Ro(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=Ro(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=Ro(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:F7e,removeDot:z7e,addArea:B7e,removeArea:H7e,addLine:RMe,removeLine:DMe}=XX.actions,OMe=XX.reducer,YX=M.createContext(void 0),jMe=t=>{var{children:e}=t,[n]=M.useState("".concat(v0("recharts"),"-clip")),r=CE();if(r==null)return null;var{x:i,y:s,width:a,height:o}=r;return M.createElement(YX.Provider,{value:n},M.createElement("defs",null,M.createElement("clipPath",{id:n},M.createElement("rect",{x:i,y:s,height:o,width:a}))),e)},LMe=()=>M.useContext(YX);function J6(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 e8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J6(Object(n),!0).forEach(function(r){IMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IMe(t,e,n){return(e=UMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UMe(t){var e=FMe(t,"string");return typeof e=="symbol"?e:e+""}function FMe(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 hw(){return hw=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},hw.apply(null,arguments)}var zMe=(t,e)=>{var n;if(M.isValidElement(t))n=M.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Bn(e.x1)||!Bn(e.y1)||!Bn(e.x2)||!Bn(e.y2))return null;n=M.createElement("line",hw({},e,{className:"recharts-reference-line-line"}))}return n},BMe=(t,e,n,r,i,s)=>{var{x:a,width:o}=s,l=i.y.apply(t,{position:n});if(Ys(l)||e==="discard"&&!i.y.isInRange(l))return null;var u=[{x:a+o,y:l},{x:a,y:l}];return r==="left"?u.reverse():u},HMe=(t,e,n,r,i,s)=>{var{y:a,height:o}=s,l=i.x.apply(t,{position:n});if(Ys(l)||e==="discard"&&!i.x.isInRange(l))return null;var u=[{x:l,y:a+o},{x:l,y:a}];return r==="top"?u.reverse():u},$Me=(t,e,n,r)=>{var i=t.map(s=>r.apply(s,{position:n}));return e==="discard"&&i.some(s=>!r.isInRange(s))?null:i},VMe=(t,e,n,r,i,s)=>{var{x:a,y:o,segment:l,ifOverflow:u}=s,d=so(a),f=so(o);return f?BMe(o,u,n,i,t,e):d?HMe(a,u,n,r,t,e):l!=null&&l.length===2?$Me(l,u,n,t):null};function GMe(t){var e=rr();return M.useEffect(()=>(e(RMe(t)),()=>{e(DMe(t))})),null}function WMe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,a=xi(),o=LMe(),l=Tt(k=>_l(k,e)),u=Tt(k=>wl(k,n)),d=Tt(k=>sd(k,"xAxis",e,a)),f=Tt(k=>sd(k,"yAxis",n,a)),g=bb();if(!o||!g||l==null||u==null||d==null||f==null)return null;var m=CMe({x:d,y:f}),x=VMe(m,g,t.position,l.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:v},{x:b,y:E}]=x,S=s==="hidden"?"url(#".concat(o,")"):void 0,A=e8(e8({clipPath:S},es(t)),{},{x1:y,y1:v,x2:b,y2:E}),T=TMe({x1:y,y1:v,x2:b,y2:E});return M.createElement(ms,{zIndex:t.zIndex},M.createElement(_r,{className:Sn("recharts-reference-line",i)},zMe(r,A),M.createElement(MX,hw({},T,{lowerWidth:T.width,upperWidth:T.width}),M.createElement(TX,{label:t.label}),t.children)))}var qMe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Pr.line};function Ax(t){var e=wr(t,qMe);return M.createElement(M.Fragment,null,M.createElement(GMe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),M.createElement(WMe,e))}Ax.displayName="ReferenceLine";function ZX(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 KMe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return kMe(r,n)}function XMe(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 fw(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 YMe(t,e){return ZX(t,e+1)}function ZMe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:a,end:o}=e,l=0,u=1,d=a,f=function(){var x=r?.[l];if(x===void 0)return{v:ZX(r,u)};var y=l,v,b=()=>(v===void 0&&(v=n(x,y)),v),E=x.coordinate,S=l===0||fw(t,E,b,d,o);S||(l=0,d=a,u+=1),S&&(d=E+t*(b()/2+i),l+=u)},g;u<=s.length;)if(g=f(),g)return g.v;return[]}function t8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function cs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t8(Object(n),!0).forEach(function(r){QMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QMe(t,e,n){return(e=JMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JMe(t){var e=e2e(t,"string");return typeof e=="symbol"?e:e+""}function e2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function t2e(t,e,n,r,i){for(var s=(r||[]).slice(),a=s.length,{start:o}=e,{end:l}=e,u=function(g){var m=s[g],x,y=()=>(x===void 0&&(x=n(m,g)),x);if(g===a-1){var v=t*(m.coordinate+t*y()/2-l);s[g]=m=cs(cs({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else s[g]=m=cs(cs({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var b=fw(t,m.tickCoord,y,o,l);b&&(l=m.tickCoord-t*(y()/2+i),s[g]=cs(cs({},m),{},{isShow:!0}))}},d=a-1;d>=0;d--)u(d);return s}function n2e(t,e,n,r,i,s){var a=(r||[]).slice(),o=a.length,{start:l,end:u}=e;if(s){var d=r[o-1],f=n(d,o-1),g=t*(d.coordinate+t*f/2-u);if(a[o-1]=d=cs(cs({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=fw(t,d.tickCoord,()=>f,l,u);m&&(u=d.tickCoord-t*(f/2+i),a[o-1]=cs(cs({},d),{},{isShow:!0}))}}for(var x=s?o-1:o,y=function(E){var S=a[E],A,T=()=>(A===void 0&&(A=n(S,E)),A);if(E===0){var k=t*(S.coordinate-t*T()/2-l);a[E]=S=cs(cs({},S),{},{tickCoord:k<0?S.coordinate-k*t:S.coordinate})}else a[E]=S=cs(cs({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var N=fw(t,S.tickCoord,T,l,u);N&&(l=S.tickCoord+t*(T()/2+i),a[E]=cs(cs({},S),{},{isShow:!0}))}},v=0;v<x;v++)y(v);return a}function jO(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:a,orientation:o,interval:l,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Nt(l)||Hm.isSsr){var g;return(g=YMe(i,Nt(l)?l:0))!==null&&g!==void 0?g:[]}var m=[],x=o==="top"||o==="bottom"?"width":"height",y=d&&x==="width"?Fx(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(S,A)=>{var T=typeof u=="function"?u(S.value,A):S.value;return x==="width"?KMe(Fx(T,{fontSize:e,letterSpacing:n}),y,f):Fx(T,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?Oi(i[1].coordinate-i[0].coordinate):1,E=XMe(s,b,x);return l==="equidistantPreserveStart"?ZMe(b,E,v,i,a):(l==="preserveStart"||l==="preserveStartEnd"?m=n2e(b,E,v,i,a,l==="preserveStartEnd"):m=t2e(b,E,v,i,a),m.filter(S=>S.isShow))}var r2e=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:s=0}=t,a=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>a&&(a=f.width)}});var o=n?n.getBoundingClientRect().width:0,l=i+s,u=a+l+o+(n?r:0);return Math.round(u)}return 0},i2e=["axisLine","width","height","className","hide","ticks","axisType"];function s2e(t,e){if(t==null)return{};var n,r,i=a2e(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 a2e(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 Wh(){return Wh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Wh.apply(null,arguments)}function n8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function qr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n8(Object(n),!0).forEach(function(r){o2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function o2e(t,e,n){return(e=l2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l2e(t){var e=c2e(t,"string");return typeof e=="symbol"?e:e+""}function c2e(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 vc={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:Pr.axis};function u2e(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:a,axisLine:o,otherSvgProps:l}=t;if(!o)return null;var u=qr(qr(qr({},l),Ts(o)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!a||s==="bottom"&&a);u=qr(qr({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(s==="left"&&!a||s==="right"&&a);u=qr(qr({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return M.createElement("line",Wh({},u,{className:Sn("recharts-cartesian-axis-line",Hh(o,"className"))}))}function d2e(t,e,n,r,i,s,a,o,l){var u,d,f,g,m,x,y=o?-1:1,v=t.tickSize||a,b=Nt(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,g=n+ +!o*i,f=g-y*v,x=f-y*l,m=b;break;case"left":f=g=t.coordinate,d=e+ +!o*r,u=d-y*v,m=u-y*l,x=b;break;case"right":f=g=t.coordinate,d=e+ +o*r,u=d+y*v,m=u+y*l,x=b;break;default:u=d=t.coordinate,g=n+ +o*i,f=g+y*v,x=f+y*l,m=b;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:m,y:x}}}function h2e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function f2e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function p2e(t){var{option:e,tickProps:n,value:r}=t,i,s=Sn(n.className,"recharts-cartesian-axis-tick-value");if(M.isValidElement(e))i=M.cloneElement(e,qr(qr({},n),{},{className:s}));else if(typeof e=="function")i=e(qr(qr({},n),{},{className:s}));else{var a="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(a=Sn(a,e?.className)),i=M.createElement(_E,Wh({},n,{className:a}),r)}return i}var m2e=M.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:a,unit:o,padding:l,tickTextProps:u,orientation:d,mirror:f,x:g,y:m,width:x,height:y,tickSize:v,tickMargin:b,fontSize:E,letterSpacing:S,getTicksConfig:A,events:T,axisType:k}=t,N=jO(qr(qr({},A),{},{ticks:n}),E,S),I=h2e(d,f),C=f2e(d,f),D=Ts(A),F=Bh(r),j={};typeof i=="object"&&(j=i);var q=qr(qr({},D),{},{fill:"none"},j),R=N.map(V=>qr({entry:V},d2e(V,g,m,x,y,d,v,f,b))),W=R.map(V=>{var{entry:te,line:Y}=V;return M.createElement(_r,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(te.value,"-").concat(te.coordinate,"-").concat(te.tickCoord)},i&&M.createElement("line",Wh({},q,Y,{className:Sn("recharts-cartesian-axis-tick-line",Hh(i,"className"))})))}),K=R.map((V,te)=>{var{entry:Y,tick:Z}=V,U=qr(qr(qr(qr({textAnchor:I,verticalAnchor:C},D),{},{stroke:"none",fill:s},F),Z),{},{index:te,payload:Y,visibleTicksCount:N.length,tickFormatter:a,padding:l},u);return M.createElement(_r,Wh({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},fb(T,Y,te)),r&&M.createElement(p2e,{option:r,tickProps:U,value:"".concat(typeof a=="function"?a(Y.value,te):Y.value).concat(o||"")}))});return M.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&M.createElement(ms,{zIndex:Pr.label},M.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(k,"-tick-labels"),ref:e},K)),W.length>0&&M.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(k,"-tick-lines")},W))}),g2e=M.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:l}=t,u=s2e(t,i2e),[d,f]=M.useState(""),[g,m]=M.useState(""),x=M.useRef(null);M.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return r2e({ticks:x.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=M.useCallback(v=>{if(v){var b=v.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var E=b[0];if(E){var S=window.getComputedStyle(E),A=S.fontSize,T=S.letterSpacing;(A!==d||T!==g)&&(f(A),m(T))}}},[d,g]);return a||r!=null&&r<=0||i!=null&&i<=0?null:M.createElement(ms,{zIndex:t.zIndex},M.createElement(_r,{className:Sn("recharts-cartesian-axis",s)},M.createElement(u2e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ts(t)}),M.createElement(m2e,{ref:y,axisType:l,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),M.createElement(MX,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},M.createElement(TX,{label:t.label,labelRef:t.labelRef}),t.children)))}),LO=M.forwardRef((t,e)=>{var n=wr(t,vc);return M.createElement(g2e,Wh({},n,{ref:e}))});LO.displayName="CartesianAxis";var x2e=["x1","y1","x2","y2","key"],b2e=["offset"],v2e=["xAxisId","yAxisId"],y2e=["xAxisId","yAxisId"];function r8(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 ds(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r8(Object(n),!0).forEach(function(r){_2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _2e(t,e,n){return(e=w2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function w2e(t){var e=S2e(t,"string");return typeof e=="symbol"?e:e+""}function S2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dh(){return dh=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},dh.apply(null,arguments)}function pw(t,e){if(t==null)return{};var n,r,i=E2e(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 E2e(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 M2e=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 M.createElement("rect",{x:r,y:i,ry:o,width:s,height:a,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function QX(t){var{option:e,lineItemProps:n}=t,r;if(M.isValidElement(e))r=M.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:s,y1:a,x2:o,y2:l,key:u}=n,d=pw(n,x2e),f=(i=Ts(d))!==null&&i!==void 0?i:{},{offset:g}=f,m=pw(f,b2e);r=M.createElement("line",dh({},m,{x1:s,y1:a,x2:o,y2:l,fill:"none",key:u}))}return r}function A2e(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=pw(t,v2e),l=i.map((u,d)=>{var f=ds(ds({},o),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return M.createElement(QX,{key:"line-".concat(d),option:r,lineItemProps:f})});return M.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function T2e(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=pw(t,y2e),l=i.map((u,d)=>{var f=ds(ds({},o),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return M.createElement(QX,{option:r,lineItemProps:f,key:"line-".concat(d)})});return M.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function C2e(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 u=o.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],x=m?i+a-f:u[g+1]-f;if(x<=0)return null;var y=g%e.length;return M.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function N2e(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 u=l.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var m=!u[g+1],x=m?i+a-f:u[g+1]-f;if(x<=0)return null;var y=g%n.length;return M.createElement("rect",{key:"react-".concat(g),x:f,y:s,width:x,height:o,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return M.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var k2e=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return jW(jO(ds(ds(ds({},vc),n),{},{ticks:LW(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},P2e=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return jW(jO(ds(ds(ds({},vc),n),{},{ticks:LW(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},R2e={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Pr.grid};function mw(t){var e=lD(),n=cD(),r=GW(),i=ds(ds({},wr(t,R2e)),{},{x:Nt(t.x)?t.x:r.left,y:Nt(t.y)?t.y:r.top,width:Nt(t.width)?t.width:r.width,height:Nt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:l,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:m}=i,x=xi(),y=Tt(C=>GB(C,"xAxis",s,x)),v=Tt(C=>GB(C,"yAxis",a,x));if(!ul(u)||!ul(d)||!Nt(o)||!Nt(l))return null;var b=i.verticalCoordinatesGenerator||k2e,E=i.horizontalCoordinatesGenerator||P2e,{horizontalPoints:S,verticalPoints:A}=i;if((!S||!S.length)&&typeof E=="function"){var T=g&&g.length,k=E({yAxis:v?ds(ds({},v),{},{ticks:T?g:v.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);U1(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(S=k)}if((!A||!A.length)&&typeof b=="function"){var N=m&&m.length,I=b({xAxis:y?ds(ds({},y),{},{ticks:N?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);U1(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(A=I)}return M.createElement(ms,{zIndex:i.zIndex},M.createElement("g",{className:"recharts-cartesian-grid"},M.createElement(M2e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),M.createElement(C2e,dh({},i,{horizontalPoints:S})),M.createElement(N2e,dh({},i,{verticalPoints:A})),M.createElement(A2e,dh({},i,{offset:r,horizontalPoints:S,xAxis:y,yAxis:v})),M.createElement(T2e,dh({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:v}))))}mw.displayName="CartesianGrid";var JX=(t,e,n,r)=>fl(t,"xAxis",e,r),eY=(t,e,n,r)=>hl(t,"xAxis",e,r),tY=(t,e,n,r)=>fl(t,"yAxis",n,r),nY=(t,e,n,r)=>hl(t,"yAxis",n,r),D2e=We([gn,JX,tY,eY,nY],(t,e,n,r,i)=>yl(t,"xAxis")?rd(e,r,!1):rd(n,i,!1)),O2e=(t,e,n,r,i)=>i;function j2e(t){return t.type==="line"}var L2e=We([Cb,O2e],(t,e)=>t.filter(j2e).find(n=>n.id===e)),I2e=We([gn,JX,tY,eY,nY,L2e,D2e,Eb],(t,e,n,r,i,s,a,o)=>{var{chartData:l,dataStartIndex:u,dataEndIndex:d}=o;if(!(s==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||a==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:g}=s,m;if(g!=null&&g.length>0?m=g:m=l?.slice(u,d+1),m!=null)return rAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:a,displayedData:m})}});function rY(t){var e=Bh(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 U2e=["id"],F2e=["type","layout","connectNulls","needClip","shape"],z2e=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function O0(){return O0=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},O0.apply(null,arguments)}function i8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jo(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i8(Object(n),!0).forEach(function(r){B2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function B2e(t,e,n){return(e=H2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H2e(t){var e=$2e(t,"string");return typeof e=="symbol"?e:e+""}function $2e(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 IO(t,e){if(t==null)return{};var n,r,i=V2e(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 V2e(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 G2e=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:xd(n,e),payload:t}]},W2e=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:l,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:xd(a,e),hide:o,type:u,color:r,unit:l}};return M.createElement(ME,{tooltipEntrySettings:d})}),iY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function q2e(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var K2e=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return iY(e,t);for(var i=Math.floor(t/r),s=t%r,a=e-t,o=[],l=0,u=0;l<n.length;u+=n[l],++l)if(u+n[l]>s){o=[...n.slice(0,l),s-u];break}var d=o.length%2===0?[0,a]:[a];return[...q2e(n,i),...o,...d].map(f=>"".concat(f,"px")).join(", ")};function X2e(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:a}=r,{id:o}=r,l=IO(r,U2e),u=Ts(l);return M.createElement(FX,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:a,clipPathId:e})}function Y2e(t){var{showLabels:e,children:n,points:r}=t,i=M.useMemo(()=>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 Jo(Jo({},l),{},{value:s.value,payload:s.payload,viewBox:l,parentViewBox:void 0,fill:void 0})}),[r]);return M.createElement(SO,{value:e?i:void 0},n)}function s8(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:a,layout:o,connectNulls:l,needClip:u,shape:d}=s,f=IO(s,F2e),g=Jo(Jo({},es(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:a,layout:o,connectNulls:l,strokeDasharray:i??s.strokeDasharray});return M.createElement(M.Fragment,null,r?.length>1&&M.createElement(CO,O0({shapeType:"curve",option:d},g,{pathRef:n})),M.createElement(X2e,{points:r,clipPathId:e,props:s}))}function Z2e(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function Q2e(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:a,strokeDasharray:o,isAnimationActive:l,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:m,height:x,onAnimationEnd:y,onAnimationStart:v}=n,b=i.current,E=Vm(a,"recharts-line-"),S=M.useRef(E),[A,T]=M.useState(!1),k=!A,N=M.useCallback(()=>{typeof y=="function"&&y(),T(!1)},[y]),I=M.useCallback(()=>{typeof v=="function"&&v(),T(!0)},[v]),C=Z2e(r.current),D=M.useRef(0);S.current!==E&&(D.current=s.current,S.current=E);var F=D.current;return M.createElement(Y2e,{points:a,showLabels:k},n.children,M.createElement($m,{animationId:E,begin:u,duration:d,isActive:l,easing:f,onAnimationEnd:N,onAnimationStart:I,key:E},j=>{var q=Rn(F,C+F,j),R=Math.min(q,C),W;if(l)if(o){var K="".concat(o).split(/[,\s]+/gim).map(Y=>parseFloat(Y));W=K2e(R,C,K)}else W=iY(C,R);else W=o==null?void 0:String(o);if(j>0&&C>0&&(i.current=a,s.current=Math.max(s.current,R)),b){var V=b.length/a.length,te=j===1?a:a.map((Y,Z)=>{var U=Math.floor(Z*V);if(b[U]){var z=b[U];return Jo(Jo({},Y),{},{x:Rn(z.x,Y.x,j),y:Rn(z.y,Y.y,j)})}return g?Jo(Jo({},Y),{},{x:Rn(m*2,Y.x,j),y:Rn(x/2,Y.y,j)}):Jo(Jo({},Y),{},{x:Y.x,y:Y.y})});return i.current=te,M.createElement(s8,{props:n,points:te,clipPathId:e,pathRef:r,strokeDasharray:W})}return M.createElement(s8,{props:n,points:a,clipPathId:e,pathRef:r,strokeDasharray:W})}),M.createElement(wE,{label:n.label}))}function J2e(t){var{clipPathId:e,props:n}=t,r=M.useRef(null),i=M.useRef(0),s=M.useRef(null);return M.createElement(Q2e,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var eAe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:zn(t.payload,e)}};class tAe extends M.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:a,top:o,left:l,width:u,height:d,id:f,needClip:g,zIndex:m}=this.props;if(e)return null;var x=Sn("recharts-line",i),y=f,{r:v,strokeWidth:b}=rY(n),E=TO(n),S=v*2+b,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(y,")"):void 0;return M.createElement(ms,{zIndex:m},M.createElement(_r,{className:x},g&&M.createElement("defs",null,M.createElement(OO,{clipPathId:y,xAxisId:s,yAxisId:a}),!E&&M.createElement("clipPath",{id:"clipPath-dots-".concat(y)},M.createElement("rect",{x:l-S/2,y:o-S/2,width:u+S,height:d+S}))),M.createElement(HX,{xAxisId:s,yAxisId:a,data:r,dataPointFormatter:eAe,errorBarOffset:0},M.createElement(J2e,{props:this.props,clipPathId:y}))),M.createElement(Sk,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var sY={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Pr.line,type:"linear"};function nAe(t){var e=wr(t,sY),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:l,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:m,yAxisId:x,id:y}=e,v=IO(e,z2e),{needClip:b}=NE(m,x),E=CE(),S=lf(),A=xi(),T=Tt(D=>I2e(D,m,x,A,y));if(S!=="horizontal"&&S!=="vertical"||T==null||E==null)return null;var{height:k,width:N,x:I,y:C}=E;return M.createElement(tAe,O0({},v,{id:y,connectNulls:o,dot:l,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:a,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:m,yAxisId:x,points:T,layout:S,height:k,width:N,left:I,top:C,needClip:b}))}function rAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,dataKey:a,bandSize:o,displayedData:l}=t;return l.map((u,d)=>{var f=zn(u,a);if(e==="horizontal"){var g=I1({axis:n,ticks:i,bandSize:o,entry:u,index:d}),m=dr(f)?null:r.scale(f);return{x:g,y:m,value:f,payload:u}}var x=dr(f)?null:n.scale(f),y=I1({axis:r,ticks:s,bandSize:o,entry:u,index:d});return x==null||y==null?null:{x,y,value:f,payload:u}}).filter(Boolean)}function iAe(t){var e=wr(t,sY),n=xi();return M.createElement(AE,{id:e.id,type:"line"},r=>M.createElement(M.Fragment,null,M.createElement(RO,{legendPayload:G2e(e)}),M.createElement(W2e,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),M.createElement(DO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),M.createElement(nAe,O0({},e,{id:r}))))}var aY=M.memo(iAe,Ib);aY.displayName="Line";var oY=(t,e,n,r)=>fl(t,"xAxis",e,r),lY=(t,e,n,r)=>hl(t,"xAxis",e,r),cY=(t,e,n,r)=>fl(t,"yAxis",n,r),uY=(t,e,n,r)=>hl(t,"yAxis",n,r),sAe=We([gn,oY,cY,lY,uY],(t,e,n,r,i)=>yl(t,"xAxis")?rd(e,r,!1):rd(n,i,!1)),aAe=(t,e,n,r,i)=>i,dY=We([Cb,aAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),oAe=(t,e,n,r,i)=>{var s,a=dY(t,e,n,r,i);if(a!=null){var o=gn(t),l=yl(o,"xAxis"),u;if(l?u=R0(t,"yAxis",n,r):u=R0(t,"xAxis",e,r),u!=null){var{stackId:d}=a,f=hE(a);if(!(d==null||f==null)){var g=(s=u[d])===null||s===void 0?void 0:s.stackedData;return g?.find(m=>m.key===f)}}}},lAe=We([gn,oY,cY,lY,uY,oAe,Eb,sAe,dY,Lbe],(t,e,n,r,i,s,a,o,l,u)=>{var{chartData:d,dataStartIndex:f,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,x;if(m&&m.length>0?x=m:x=d?.slice(f,g+1),x!=null)return TAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:l,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:o})}}),cAe=["id"],uAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Eh(){return Eh=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},Eh.apply(null,arguments)}function hY(t,e){if(t==null)return{};var n,r,i=dAe(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 dAe(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 a8(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?a8(Object(n),!0).forEach(function(r){hAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hAe(t,e,n){return(e=fAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fAe(t){var e=pAe(t,"string");return typeof e=="symbol"?e:e+""}function pAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gw(t,e){return t&&t!=="none"?t:e}var mAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:a}=t;return[{inactive:a,dataKey:e,type:s,color:gw(r,i),value:xd(n,e),payload:t}]},gAe=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:l,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:xd(a,e),hide:o,type:u,color:gw(r,s),unit:l}};return M.createElement(ME,{tooltipEntrySettings:d})});function xAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:a}=r,o=Ts(r);return M.createElement(FX,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:a,baseProps:o,needClip:i,clipPathId:e})}function bAe(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 $p($p({},l),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return M.createElement(SO,{value:e?i:void 0},n)}function o8(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:a,type:o,stroke:l,connectNulls:u,isRange:d}=s,{id:f}=s,g=hY(s,cAe),m=Ts(g),x=es(g);return M.createElement(M.Fragment,null,e?.length>1&&M.createElement(_r,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},M.createElement(Yp,Eh({},x,{id:f,points:e,connectNulls:u,type:o,baseLine:n,layout:a,stroke:"none",className:"recharts-area-area"})),l!=="none"&&M.createElement(Yp,Eh({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:u,fill:"none",points:e})),l!=="none"&&d&&M.createElement(Yp,Eh({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:u,fill:"none",points:n}))),M.createElement(xAe,{points:e,props:g,clipPathId:i}))}function vAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!Bn(s)||!Bn(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(u=>u.x||0));return Nt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(u=>u.x||0),l)),Nt(l)?M.createElement("rect",{x:0,y:s<a?s:s-o,width:l+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function yAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,a=r[r.length-1].x;if(!Bn(s)||!Bn(a))return null;var o=e*Math.abs(s-a),l=Math.max(...r.map(u=>u.y||0));return Nt(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(u=>u.y||0),l)),Nt(l)?M.createElement("rect",{x:s<a?s:s-o,y:0,width:o,height:Math.floor(l+(i?parseInt("".concat(i),10):1))}):null}function _Ae(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?M.createElement(vAe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):M.createElement(yAe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function wAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:a,baseLine:o,isAnimationActive:l,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:m}=r,x=M.useMemo(()=>({points:a,baseLine:o}),[a,o]),y=Vm(x,"recharts-area-"),v=eme(),[b,E]=M.useState(!1),S=!b,A=M.useCallback(()=>{typeof m=="function"&&m(),E(!1)},[m]),T=M.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(v==null)return null;var k=i.current,N=s.current;return M.createElement(bAe,{showLabels:S,points:a},r.children,M.createElement($m,{animationId:y,begin:u,duration:d,isActive:l,easing:f,onAnimationEnd:A,onAnimationStart:T,key:y},I=>{if(k){var C=k.length/a.length,D=I===1?a:a.map((j,q)=>{var R=Math.floor(q*C);if(k[R]){var W=k[R];return $p($p({},j),{},{x:Rn(W.x,j.x,I),y:Rn(W.y,j.y,I)})}return j}),F;return Nt(o)?F=Rn(N,o,I):dr(o)||Ys(o)?F=Rn(N,0,I):F=o.map((j,q)=>{var R=Math.floor(q*C);if(Array.isArray(N)&&N[R]){var W=N[R];return $p($p({},j),{},{x:Rn(W.x,j.x,I),y:Rn(W.y,j.y,I)})}return j}),I>0&&(i.current=D,s.current=F),M.createElement(o8,{points:D,baseLine:F,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=a,s.current=o),M.createElement(_r,null,l&&M.createElement("defs",null,M.createElement("clipPath",{id:"animationClipPath-".concat(n)},M.createElement(_Ae,{alpha:I,points:a,baseLine:o,layout:v,strokeWidth:r.strokeWidth}))),M.createElement(_r,{clipPath:"url(#animationClipPath-".concat(n,")")},M.createElement(o8,{points:a,baseLine:o,needClip:e,clipPathId:n,props:r})))}),M.createElement(wE,{label:r.label}))}function SAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=M.useRef(null),s=M.useRef();return M.createElement(wAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class EAe extends M.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:a,needClip:o,xAxisId:l,yAxisId:u,width:d,height:f,id:g,baseLine:m,zIndex:x}=this.props;if(e)return null;var y=Sn("recharts-area",i),v=g,{r:b,strokeWidth:E}=rY(n),S=TO(n),A=b*2+E,T=o?"url(#clipPath-".concat(S?"":"dots-").concat(v,")"):void 0;return M.createElement(ms,{zIndex:x},M.createElement(_r,{className:y},o&&M.createElement("defs",null,M.createElement(OO,{clipPathId:v,xAxisId:l,yAxisId:u}),!S&&M.createElement("clipPath",{id:"clipPath-dots-".concat(v)},M.createElement("rect",{x:a-A/2,y:s-A/2,width:d+A,height:f+A}))),M.createElement(SAe,{needClip:o,clipPathId:v,props:this.props})),M.createElement(Sk,{points:r,mainColor:gw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&M.createElement(Sk,{points:m,mainColor:gw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var fY={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:Pr.area};function MAe(t){var e,n=wr(t,fY),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:l,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:m,stroke:x,xAxisId:y,yAxisId:v}=n,b=hY(n,uAe),E=lf(),S=lX(),{needClip:A}=NE(y,v),T=xi(),{points:k,isRange:N,baseLine:I}=(e=Tt(R=>lAe(R,y,v,T,t.id)))!==null&&e!==void 0?e:{},C=CE();if(E!=="horizontal"&&E!=="vertical"||C==null||S!=="AreaChart"&&S!=="ComposedChart")return null;var{height:D,width:F,x:j,y:q}=C;return!k||!k.length?null:M.createElement(EAe,Eh({},b,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,baseLine:I,connectNulls:o,dot:l,fill:u,fillOpacity:d,height:D,hide:f,layout:E,isAnimationActive:g==="auto"?!Hm.isSsr:g,isRange:N,legendType:m,needClip:A,points:k,stroke:x,width:F,left:j,top:q,xAxisId:y,yAxisId:v}))}var AAe=(t,e,n,r,i)=>{var s=n??e;if(Nt(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]),u=Math.min(o[0],o[1]);return s==="dataMin"?u: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 TAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:a,xAxis:o,yAxis:l,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:m}=t,x=i&&i.length,y=AAe(s,a,n,o,l),v=s==="horizontal",b=!1,E=u.map((A,T)=>{var k;x?k=i[d+T]:(k=zn(A,r),Array.isArray(k)?b=!0:k=[y,k]);var N=k[1]==null||x&&!e&&zn(A,r)==null;return v?{x:I1({axis:o,ticks:f,bandSize:m,entry:A,index:T}),y:N?null:l.scale(k[1]),value:k,payload:A}:{x:N?null:o.scale(k[1]),y:I1({axis:l,ticks:g,bandSize:m,entry:A,index:T}),value:k,payload:A}}),S;return x||b?S=E.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return v?{x:A.x,y:T!=null&&A.y!=null?l.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):S=v?l.scale(y):o.scale(y),{points:E,baseLine:S,isRange:b}}function CAe(t){var e=wr(t,fY),n=xi();return M.createElement(AE,{id:e.id,type:"area"},r=>M.createElement(M.Fragment,null,M.createElement(RO,{legendPayload:mAe(e)}),M.createElement(gAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),M.createElement(DO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:IW(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),M.createElement(MAe,Eh({},e,{id:r}))))}var pY=M.memo(CAe,Ib);pY.displayName="Area";var NAe=["domain","range"],kAe=["domain","range"];function l8(t,e){if(t==null)return{};var n,r,i=PAe(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 PAe(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 c8(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 mY(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=l8(t,NAe),{domain:s,range:a}=e,o=l8(e,kAe);return!c8(n,s)||!c8(r,a)?!1:Ib(i,o)}var RAe=["dangerouslySetInnerHTML","ticks"],DAe=["id"];function Mk(){return Mk=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},Mk.apply(null,arguments)}function u8(t,e){if(t==null)return{};var n,r,i=OAe(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 OAe(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 jAe(t){var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(NSe(t)):n.current!==t&&e(kSe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(PSe(n.current)),n.current=null)},[e]),null}var LAe=t=>{var{xAxisId:e,className:n}=t,r=Tt(aD),i=xi(),s="xAxis",a=Tt(v=>sd(v,s,e,i)),o=Tt(v=>zK(v,s,e,i)),l=Tt(v=>LK(v,e)),u=Tt(v=>Dve(v,e)),d=Tt(v=>xK(v,e));if(l==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,m=u8(t,RAe),{id:x}=d,y=u8(d,DAe);return M.createElement(LO,Mk({},m,y,{scale:a,x:u.x,y:u.y,width:l.width,height:l.height,className:Sn("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},IAe={allowDataOverflow:Ni.allowDataOverflow,allowDecimals:Ni.allowDecimals,allowDuplicatedCategory:Ni.allowDuplicatedCategory,angle:Ni.angle,axisLine:vc.axisLine,height:Ni.height,hide:!1,includeHidden:Ni.includeHidden,interval:Ni.interval,minTickGap:Ni.minTickGap,mirror:Ni.mirror,orientation:Ni.orientation,padding:Ni.padding,reversed:Ni.reversed,scale:Ni.scale,tick:Ni.tick,tickCount:Ni.tickCount,tickLine:vc.tickLine,tickSize:vc.tickSize,type:Ni.type,xAxisId:0},UAe=t=>{var e=wr(t,IAe);return M.createElement(M.Fragment,null,M.createElement(jAe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),M.createElement(LAe,e))},xw=M.memo(UAe,mY);xw.displayName="XAxis";var FAe=["dangerouslySetInnerHTML","ticks"],zAe=["id"];function Ak(){return Ak=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},Ak.apply(null,arguments)}function d8(t,e){if(t==null)return{};var n,r,i=BAe(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 BAe(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 HAe(t){var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(RSe(t)):n.current!==t&&e(DSe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(OSe(n.current)),n.current=null)},[e]),null}var $Ae=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=M.useRef(null),a=M.useRef(null),o=Tt(aD),l=xi(),u=rr(),d="yAxis",f=Tt(T=>sd(T,d,e,l)),g=Tt(T=>IK(T,e)),m=Tt(T=>jve(T,e)),x=Tt(T=>zK(T,d,e,l)),y=Tt(T=>bK(T,e));if(M.useLayoutEffect(()=>{if(!(r!=="auto"||!g||wO(i)||M.isValidElement(i)||y==null)){var T=s.current;if(T){var k=T.getCalculatedWidth();Math.round(g.width)!==Math.round(k)&&u(jSe({id:e,width:k}))}}},[x,g,u,i,e,r,y]),g==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:v,ticks:b}=t,E=d8(t,FAe),{id:S}=y,A=d8(y,zAe);return M.createElement(LO,Ak({},E,A,{ref:s,labelRef:a,scale:f,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:Sn("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:x,axisType:d}))},VAe={allowDataOverflow:ki.allowDataOverflow,allowDecimals:ki.allowDecimals,allowDuplicatedCategory:ki.allowDuplicatedCategory,angle:ki.angle,axisLine:vc.axisLine,hide:!1,includeHidden:ki.includeHidden,interval:ki.interval,minTickGap:ki.minTickGap,mirror:ki.mirror,orientation:ki.orientation,padding:ki.padding,reversed:ki.reversed,scale:ki.scale,tick:ki.tick,tickCount:ki.tickCount,tickLine:vc.tickLine,tickSize:vc.tickSize,type:ki.type,width:ki.width,yAxisId:0},GAe=t=>{var e=wr(t,VAe);return M.createElement(M.Fragment,null,M.createElement(HAe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),M.createElement($Ae,e))},bw=M.memo(GAe,mY);bw.displayName="YAxis";var WAe=(t,e)=>e,UO=We([WAe,gn,mK,vi,nX,Uc,Yye,gi],r_e),FO=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)}},gY=ao("mouseClick"),xY=gb();xY.startListening({actionCreator:gY,effect:(t,e)=>{var n=t.payload,r=UO(e.getState(),FO(n));r?.activeIndex!=null&&e.dispatch(Xve({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var Tk=ao("mouseMove"),bY=gb(),Ay=null;bY.startListening({actionCreator:Tk,effect:(t,e)=>{var n=t.payload;Ay!==null&&cancelAnimationFrame(Ay);var r=FO(n);Ay=requestAnimationFrame(()=>{var i=e.getState(),s=dO(i,i.tooltip.settings.shared);if(s==="axis"){var a=UO(i,r);a?.activeIndex!=null?e.dispatch(KK({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):e.dispatch(qK())}Ay=null})}});var h8={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},vY=Zs({name:"rootProps",initialState:h8,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:h8.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}}}),qAe=vY.reducer,{updateOptions:KAe}=vY.actions,yY=Zs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:XAe}=yY.actions,YAe=yY.reducer,_Y=ao("keyDown"),wY=ao("focus"),zO=gb();zO.startListening({actionCreator:_Y,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=hO(i,Qm(n),kb(n),Ob(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var l=Uc(n);if(s==="Enter"){var u=sw(n,"axis","hover",String(i.index));e.dispatch(xk({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=Fve(n),f=d==="left-to-right"?1:-1,g=s==="ArrowRight"?1:-1,m=o+g*f;if(!(l==null||m>=l.length||m<0)){var x=sw(n,"axis","hover",String(m));e.dispatch(xk({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});zO.startListening({actionCreator:wY,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=sw(n,"axis","hover",String(s));e.dispatch(xk({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:a}))}}}});var Ua=ao("externalEvent"),SY=gb(),sC=new Map;SY.startListening({actionCreator:Ua,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=sC.get(i);s!==void 0&&cancelAnimationFrame(s);var a=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:jye(o),activeDataKey:xO(o),activeIndex:ad(o),activeLabel:sX(o),activeTooltipIndex:ad(o),isTooltipActive:Lye(o)};n(l,r)}finally{sC.delete(i)}});sC.set(i,a)}}});var ZAe=We([Zm],t=>t.tooltipItemPayloads),QAe=We([ZAe,Rb,(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}}}),EY=ao("touchMove"),MY=gb();MY.startListening({actionCreator:EY,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=dO(r,r.tooltip.settings.shared);if(i==="axis"){var s=UO(r,FO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(KK({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 u=l.getAttribute(FW),d=(a=l.getAttribute(zW))!==null&&a!==void 0?a:void 0,f=QAe(e.getState(),u,d);e.dispatch(WK({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var JAe=aW({brush:SMe,cartesianAxis:LSe,chartData:O_e,errorBars:tEe,graphicalItems:$we,layout:ope,legend:mme,options:N_e,polarAxis:iwe,polarOptions:YAe,referenceElements:OMe,rootProps:qAe,tooltip:Yve,zIndex:x_e}),eTe=function(e){return Rfe({reducer:JAe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([xY.middleware,bY.middleware,zO.middleware,SY.middleware,MY.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(_W({type:"raf"}))},devTools:Hm.devToolsEnabled})};function AY(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=xi(),s=M.useRef(null);if(i)return n;s.current==null&&(s.current=eTe(e));var a=ZR;return M.createElement(MEe,{context:a,store:s.current},n)}function tTe(t){var{layout:e,margin:n}=t,r=rr(),i=xi();return M.useEffect(()=>{i||(r(ipe(e)),r(rpe(n)))},[r,i,e,n]),null}var TY=M.memo(tTe,Ib);function CY(t){var e=rr();return M.useEffect(()=>{e(KAe(t))},[e,t]),null}function f8(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=LX("".concat(r).concat(e)),s=rr();return M.useLayoutEffect(()=>(s(m_e({zIndex:e,elementId:i,isPanorama:n})),()=>{s(g_e({zIndex:e,isPanorama:n}))}),[s,e,i,n]),M.createElement("g",{tabIndex:-1,id:i})}function p8(t){var{children:e,isPanorama:n}=t,r=Tt(s_e);if(!r||r.length===0)return e;var i=r.filter(a=>a<0),s=r.filter(a=>a>0);return M.createElement(M.Fragment,null,i.map(a=>M.createElement(f8,{key:a,zIndex:a,isPanorama:n})),e,s.map(a=>M.createElement(f8,{key:a,zIndex:a,isPanorama:n})))}var nTe=["children"];function rTe(t,e){if(t==null)return{};var n,r,i=iTe(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 iTe(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 vw(){return vw=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},vw.apply(null,arguments)}var sTe={width:"100%",height:"100%",display:"block"},aTe=M.forwardRef((t,e)=>{var n=lD(),r=cD(),i=nq();if(!ul(n)||!ul(r))return null;var{children:s,otherAttributes:a,title:o,desc:l}=t,u,d;return a!=null&&(typeof a.tabIndex=="number"?u=a.tabIndex:u=i?0:void 0,typeof a.role=="string"?d=a.role:d=i?"application":void 0),M.createElement(BR,vw({},a,{title:o,desc:l,role:d,tabIndex:u,width:n,height:r,style:sTe,ref:e}),s)}),oTe=t=>{var{children:e}=t,n=Tt(JS);if(!n)return null;var{width:r,height:i,y:s,x:a}=n;return M.createElement(BR,{width:r,height:i,x:a,y:s},e)},m8=M.forwardRef((t,e)=>{var{children:n}=t,r=rTe(t,nTe),i=xi();return i?M.createElement(oTe,null,M.createElement(p8,{isPanorama:!0},n)):M.createElement(aTe,vw({ref:e},r),M.createElement(p8,{isPanorama:!1},n))});function lTe(){var t=rr(),[e,n]=M.useState(null),r=Tt(Epe);return M.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;Bn(s)&&s!==r&&t(ape(s))}},[e,t,r]),n}function g8(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 cTe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g8(Object(n),!0).forEach(function(r){uTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function uTe(t,e,n){return(e=dTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dTe(t){var e=hTe(t,"string");return typeof e=="symbol"?e:e+""}function hTe(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 qh(){return qh=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},qh.apply(null,arguments)}var fTe=()=>($_e(),null);function yw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var pTe=M.forwardRef((t,e)=>{var n,r,i=M.useRef(null),[s,a]=M.useState({containerWidth:yw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:yw((r=t.style)===null||r===void 0?void 0:r.height)}),o=M.useCallback((u,d)=>{a(f=>{var g=Math.round(u),m=Math.round(d);return f.containerWidth===g&&f.containerHeight===m?f:{containerWidth:g,containerHeight:m}})},[]),l=M.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();o(d,f);var g=x=>{var{width:y,height:v}=x[0].contentRect;o(y,v)},m=new ResizeObserver(g);m.observe(u),i.current=m}},[e,o]);return M.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[o]),M.createElement(M.Fragment,null,M.createElement(eE,{width:s.containerWidth,height:s.containerHeight}),M.createElement("div",qh({ref:l},t)))}),mTe=M.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=M.useState({containerWidth:yw(n),containerHeight:yw(r)}),a=M.useCallback((l,u)=>{s(d=>{var f=Math.round(l),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),o=M.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:u,height:d}=l.getBoundingClientRect();a(u,d)}},[e,a]);return M.createElement(M.Fragment,null,M.createElement(eE,{width:i.containerWidth,height:i.containerHeight}),M.createElement("div",qh({ref:o},t)))}),gTe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return M.createElement(M.Fragment,null,M.createElement(eE,{width:n,height:r}),M.createElement("div",qh({ref:e},t)))}),xTe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return Ac(n)||Ac(r)?M.createElement(mTe,qh({},t,{ref:e})):M.createElement(gTe,qh({},t,{ref:e}))});function bTe(t){return t===!0?pTe:xTe}var vTe=M.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:a,onDoubleClick:o,onMouseDown:l,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:m,onTouchMove:x,onTouchStart:y,style:v,width:b,responsive:E,dispatchTouchEvents:S=!0}=t,A=M.useRef(null),T=rr(),[k,N]=M.useState(null),[I,C]=M.useState(null),D=lTe(),F=oD(),j=F?.width>0?F.width:b,q=F?.height>0?F.height:i,R=M.useCallback(re=>{D(re),typeof e=="function"&&e(re),N(re),C(re),re!=null&&(A.current=re)},[D,e,N,C]),W=M.useCallback(re=>{T(gY(re)),T(Ua({handler:s,reactEvent:re}))},[T,s]),K=M.useCallback(re=>{T(Tk(re)),T(Ua({handler:u,reactEvent:re}))},[T,u]),V=M.useCallback(re=>{T(qK()),T(Ua({handler:d,reactEvent:re}))},[T,d]),te=M.useCallback(re=>{T(Tk(re)),T(Ua({handler:f,reactEvent:re}))},[T,f]),Y=M.useCallback(()=>{T(wY())},[T]),Z=M.useCallback(re=>{T(_Y(re.key))},[T]),U=M.useCallback(re=>{T(Ua({handler:a,reactEvent:re}))},[T,a]),z=M.useCallback(re=>{T(Ua({handler:o,reactEvent:re}))},[T,o]),ee=M.useCallback(re=>{T(Ua({handler:l,reactEvent:re}))},[T,l]),ae=M.useCallback(re=>{T(Ua({handler:g,reactEvent:re}))},[T,g]),fe=M.useCallback(re=>{T(Ua({handler:y,reactEvent:re}))},[T,y]),de=M.useCallback(re=>{S&&T(EY(re)),T(Ua({handler:x,reactEvent:re}))},[T,S,x]),xe=M.useCallback(re=>{T(Ua({handler:m,reactEvent:re}))},[T,m]),ye=bTe(E);return M.createElement(fX.Provider,{value:k},M.createElement(_7.Provider,{value:I},M.createElement(ye,{width:j??v?.width,height:q??v?.height,className:Sn("recharts-wrapper",r),style:cTe({position:"relative",cursor:"default",width:j,height:q},v),onClick:W,onContextMenu:U,onDoubleClick:z,onFocus:Y,onKeyDown:Z,onMouseDown:ee,onMouseEnter:K,onMouseLeave:V,onMouseMove:te,onMouseUp:ae,onTouchEnd:xe,onTouchMove:de,onTouchStart:fe,ref:R},M.createElement(fTe,null),n)))}),yTe=["width","height","responsive","children","className","style","compact","title","desc"];function _Te(t,e){if(t==null)return{};var n,r,i=wTe(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 wTe(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 NY=M.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:a,style:o,compact:l,title:u,desc:d}=t,f=_Te(t,yTe),g=Ts(f);return l?M.createElement(M.Fragment,null,M.createElement(eE,{width:n,height:r}),M.createElement(m8,{otherAttributes:g,title:u,desc:d},s)):M.createElement(vTe,{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},M.createElement(m8,{otherAttributes:g,title:u,desc:d,ref:e},M.createElement(jMe,null,s)))});function Ck(){return Ck=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},Ck.apply(null,arguments)}var STe={top:5,right:5,bottom:5,left:5},ETe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:STe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},BO=M.forwardRef(function(e,n){var r,i=wr(e.categoricalChartProps,ETe),{chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return M.createElement(AY,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},M.createElement(WX,{chartData:u.data}),M.createElement(TY,{layout:i.layout,margin:i.margin}),M.createElement(CY,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),M.createElement(NY,Ck({},i,{ref:n})))}),MTe=["axis"],ATe=M.forwardRef((t,e)=>M.createElement(BO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:MTe,tooltipPayloadSearcher:yE,categoricalChartProps:t,ref:e})),TTe=["axis","item"],CTe=M.forwardRef((t,e)=>M.createElement(BO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:TTe,tooltipPayloadSearcher:yE,categoricalChartProps:t,ref:e}));function NTe(t){var e=rr();return M.useEffect(()=>{e(XAe(t))},[e,t]),null}var kTe=["layout"];function Nk(){return Nk=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},Nk.apply(null,arguments)}function PTe(t,e){if(t==null)return{};var n,r,i=RTe(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 RTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var DTe={top:5,right:5,bottom:5,left:5},kY={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:DTe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},OTe=M.forwardRef(function(e,n){var r,i=wr(e.categoricalChartProps,kY),{layout:s}=i,a=PTe(i,kTe),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return M.createElement(AY,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},M.createElement(WX,{chartData:i.data}),M.createElement(TY,{layout:s,margin:i.margin}),M.createElement(CY,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),M.createElement(NTe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),M.createElement(NY,Nk({},a,{ref:n})))});function x8(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 b8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x8(Object(n),!0).forEach(function(r){jTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jTe(t,e,n){return(e=LTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LTe(t){var e=ITe(t,"string");return typeof e=="symbol"?e:e+""}function ITe(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 UTe=["item"],FTe=b8(b8({},kY),{},{layout:"centric",startAngle:0,endAngle:360}),zTe=M.forwardRef((t,e)=>{var n=wr(t,FTe);return M.createElement(OTe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:UTe,tooltipPayloadSearcher:yE,categoricalChartProps:n,ref:e})}),BTe=["axis"],HTe=M.forwardRef((t,e)=>M.createElement(BO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:BTe,tooltipPayloadSearcher:yE,categoricalChartProps:t,ref:e}));const v8=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function $Te({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:a="humidity",thresholds:o}){const{t:l}=sb(),{theme:u}=ub(),[d,f]=M.useState("24h"),[g,m]=M.useState(a),x=u==="dark";M.useEffect(()=>{if(!t)return;const z=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t,e]);const y=v8.find(z=>z.value===d)?.hours||24,{data:v,isLoading:b,error:E}=yt({queryKey:["ams-history",n,i,y],queryFn:()=>Pe.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const S=v?.data.map(z=>({time:new Date(z.recorded_at).getTime(),humidity:z.humidity,temperature:z.temperature,timeLabel:new Date(z.recorded_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",...y>24?{day:"numeric",month:"short"}:{}})}))||[],A=o?.humidityGood||40,T=o?.humidityFair||60,k=o?.tempGood||30,N=o?.tempFair||35,I=S[S.length-1],C=I?.humidity,D=I?.temperature,F=z=>{const ee=z.filter(re=>re!=null);if(ee.length<4)return"stable";const ae=ee.slice(0,Math.floor(ee.length/4)),fe=ee.slice(-Math.floor(ee.length/4)),de=ae.reduce((re,ve)=>re+ve,0)/ae.length,ye=fe.reduce((re,ve)=>re+ve,0)/fe.length-de;return Math.abs(ye)<2?"stable":ye>0?"up":"down"},j=F(S.map(z=>z.humidity)),q=F(S.map(z=>z.temperature)),R=({trend:z})=>z==="up"?c.jsx(l7,{className:"w-4 h-4 text-red-400"}):z==="down"?c.jsx(o7,{className:"w-4 h-4 text-green-400"}):c.jsx(T3,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),W=z=>z==null?"#9ca3af":z<=A?"#22a352":z<=T?"#d4a017":"#c62828",K=z=>z==null?"#9ca3af":z<=k?"#22a352":z<=N?"#d4a017":"#c62828",V=x?"#2d2d2d":"#ffffff",te=x?"#1d1d1d":"#f3f4f6",Y=x?"#3d3d3d":"#e5e7eb",Z=x?"#ffffff":"#111827",U=x?"#9ca3af":"#4b5563";return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:c.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:V},onClick:z=>z.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:Y},children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold",style:{color:Z},children:[s," ",l("common.history","History")]}),c.jsx("p",{className:"text-sm",style:{color:U},children:r})]}),c.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:U},children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:te},children:[c.jsxs("button",{onClick:()=>m("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="humidity"?"bg-blue-600 text-white":""}`,style:g!=="humidity"?{color:U}:void 0,children:[c.jsx(YG,{className:"w-4 h-4"}),l("common.humidity","Humidity")]}),c.jsxs("button",{onClick:()=>m("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="temperature"?"bg-orange-600 text-white":""}`,style:g!=="temperature"?{color:U}:void 0,children:[c.jsx(vh,{className:"w-4 h-4"}),l("common.temperature","Temperature")]})]}),c.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:te},children:v8.map(z=>c.jsx("button",{onClick:()=>f(z.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===z.value?"bg-bambu-green text-white":""}`,style:d!==z.value?{color:U}:void 0,children:z.label},z.value))})]}),c.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.current","Current")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-2xl font-bold",style:{color:W(C)},children:C!=null?`${C}%`:"—"}),c.jsx(R,{trend:j})]})]}),c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.average","Average")}),c.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:v?.avg_humidity!=null?`${v.avg_humidity}%`:"—"})]}),c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.min","Min")}),c.jsx("p",{className:"text-2xl font-bold text-green-500",children:v?.min_humidity!=null?`${v.min_humidity}%`:"—"})]}),c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.max","Max")}),c.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_humidity!=null?`${v.max_humidity}%`:"—"})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.current","Current")}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-2xl font-bold",style:{color:K(D)},children:D!=null?`${D}°C`:"—"}),c.jsx(R,{trend:q})]})]}),c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.average","Average")}),c.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:v?.avg_temperature!=null?`${v.avg_temperature}°C`:"—"})]}),c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.min","Min")}),c.jsx("p",{className:"text-2xl font-bold text-blue-500",children:v?.min_temperature!=null?`${v.min_temperature}°C`:"—"})]}),c.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[c.jsx("p",{className:"text-xs",style:{color:U},children:l("common.max","Max")}),c.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_temperature!=null?`${v.max_temperature}°C`:"—"})]})]})}),c.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:b?c.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:l("common.loading","Loading...")}):E?c.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:l("common.error","Error loading data")}):S.length===0?c.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:l("common.noData","No data available for this time range")}):c.jsx(K_,{width:"100%",height:300,children:c.jsxs(ATe,{data:S,children:[c.jsx(mw,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),c.jsx(xw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:z=>{const ee=new Date(z);return y>24?ee.toLocaleDateString([],{day:"numeric",month:"short"}):ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),c.jsx(bw,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:z=>g==="humidity"?`${z}%`:`${z}°C`}),c.jsx(Y_,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:z=>new Date(z).toLocaleString(),formatter:z=>[g==="humidity"?`${z}%`:`${z}°C`,g==="humidity"?"Humidity":"Temperature"]}),c.jsx(hD,{}),g==="humidity"?c.jsxs(c.Fragment,{children:[c.jsx(Ax,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),c.jsx(Ax,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ax,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),c.jsx(Ax,{y:N,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),c.jsx(aY,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),c.jsx("div",{className:"text-xs text-center",style:{color:U},children:l("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function VTe({side:t}){const{theme:e}=ub(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return c.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 GTe({colors:t,className:e}){const n=[{x:9.5,cx:12.5},{x:18.5,cx:21.5},{x:27.5,cx:30.5},{x:36.5,cx:39.5}];return c.jsxs("svg",{className:e,width:"56",height:"34",viewBox:"0 0 52 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0C1.79086 0 0 1.79086 0 4V28C0 30.2091 1.79086 32 4 32H48C50.2091 32 52 30.2091 52 28V4C52 1.79086 50.2091 0 48 0H4ZM44 8H8V24H44V8Z",fill:"#2F2E33"}),n.map((r,i)=>t[i]?c.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:t[i]},i):c.jsxs("g",{children:[c.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:"#ffffff"}),c.jsx("line",{x1:r.x,y1:"8",x2:r.x+6,y2:"24",stroke:"#555555",strokeWidth:"1.5"})]},i)),c.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M36.5 16H33.5V18.2617C33.5 19.9186 32.1569 21.2617 30.5 21.2617C28.8431 21.2617 27.5 19.9186 27.5 18.2617V16H24.5V18.2617C24.5 19.9186 23.1569 21.2617 21.5 21.2617C19.8431 21.2617 18.5 19.9186 18.5 18.2617V16H15.5V18.2617C15.5 19.9186 14.1569 21.2617 12.5 21.2617C10.8432 21.2617 9.5 19.9186 9.5 18.2617V16H4V28H48V16H42.5V18.2617C42.5 19.9186 41.1569 21.2617 39.5 21.2617C37.8431 21.2617 36.5 19.9186 36.5 18.2617V16Z",fill:"#767676"}),c.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 9.18382C6 6.32088 8.32088 4 11.1838 4H40.8162C43.6791 4 46 6.32088 46 9.18382V16H42.5V12.2617C42.5 10.6049 41.1569 9.26172 39.5 9.26172C37.8431 9.26172 36.5 10.6049 36.5 12.2617V16H33.5V12.2617C33.5 10.6049 32.1569 9.26172 30.5 9.26172C28.8431 9.26172 27.5 10.6049 27.5 12.2617V16H24.5V12.2617C24.5 10.6049 23.1569 9.26172 21.5 9.26172C19.8431 9.26172 18.5 10.6049 18.5 12.2617V16H15.5V12.2617C15.5 10.6049 14.1569 9.26172 12.5 9.26172C10.8432 9.26172 9.5 10.6049 9.5 12.2617V16H6V9.18382Z",fill:"#BFBFBF"})]})}function WTe({color:t,className:e}){return c.jsxs("svg",{className:e,width:"56",height:"56",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t?c.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:t,rx:"0.3"}):c.jsxs("g",{children:[c.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:"#ffffff",rx:"0.3"}),c.jsx("line",{x1:"8.3",y1:"5.2",x2:"12.1",y2:"10.3",stroke:"#555555",strokeWidth:"0.8"})]}),c.jsx("path",{d:"M5.88312 4.68555C5.88312 4.13326 6.33083 3.68555 6.88312 3.68555H13.5059C14.0582 3.68555 14.5059 4.13326 14.5059 4.68555V10.3887H5.88312V4.68555Z",stroke:"#6B6B6B"}),c.jsx("rect",{x:"3.8725",y:"10.3887",width:"12.7037",height:"7.55371",rx:"1.2",stroke:"#6B6B6B"}),c.jsx("path",{d:"M8.21991 5.65234C8.21991 5.3762 8.44377 5.15234 8.71991 5.15234H11.7288C12.005 5.15234 12.2288 5.3762 12.2288 5.65234V10.3887H8.21991V5.65234Z",stroke:"#6B6B6B"})]})}function y8({className:t}){return c.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:c.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 qTe({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.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"}),c.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 KTe({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.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"}),c.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 XTe({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.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"}),c.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function YTe({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),c.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),c.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 ZTe({className:t}){return c.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),c.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),c.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 QTe({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r}){const i=typeof t=="string"?parseInt(t,10):t,s=typeof e=="number"?e:40,a=typeof n=="number"?n:60;let o,l;isNaN(i)?(o="#C3C2C1",l="Unknown"):i<=s?(o="#22a352",l="Good"):i<=a?(o="#d4a017",l="Fair"):(o="#c62828",l="Bad");let u;return isNaN(i)||i<=s?u=y8:i<=a?u=qTe:u=KTe,c.jsxs("button",{type:"button",onClick:r,className:`flex items-center justify-end gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${i}% - ${l}${r?" (click for history)":""}`,children:[c.jsx(u,{className:"w-3 h-4"}),c.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:o},children:[i,"%"]})]})}function JTe({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r}){const i=typeof e=="number"?e:28,s=typeof n=="number"?n:35;let a,o,l;return t<=i?(a="#22a352",o="Good",l=XTe):t<=s?(a="#d4a017",o="Fair",l=YTe):(a="#c62828",o="Bad",l=ZTe),c.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${o}${r?" (click for history)":""}`,children:[c.jsx(l,{className:"w-3 h-4"}),c.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:a},children:[t,"°C"]})]})}function aC(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 eCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function tCe(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),r=new Date;r.setHours(0,0,0,0);const i=new Date(n);i.setHours(0,0,0,0);const 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 nCe(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 rCe(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 iCe({url:t,printName:e}){const[n,r]=M.useState(!1),[i,s]=M.useState(!1),[a,o]=M.useState(!1);return c.jsxs(c.Fragment,{children:[c.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?c.jsxs(c.Fragment,{children:[c.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>s(!0)}),!n&&c.jsx(lm,{className:"w-8 h-8 text-bambu-gray"})]}):c.jsx(lm,{className:"w-8 h-8 text-bambu-gray"})}),a&&t&&c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:c.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[c.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&c.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function sCe({printers:t}){const e=En(),n=M.useMemo(()=>{let i=0,s=0,a=0,o=0;return t?.forEach(l=>{const u=e.getQueryData(["printerStatus",l.id]);u===void 0?o++:u.connected?u.state==="RUNNING"?i++:s++:a++}),{printing:i,idle:s,offline:a,loading:o,total:t?.length||0}},[t,e]),[,r]=M.useState(0);return M.useEffect(()=>{const i=e.getQueryCache().subscribe(()=>{r(s=>s+1)});return()=>i()},[e]),t?.length?c.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),c.jsxs("span",{className:"text-bambu-gray",children:[c.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),c.jsxs("span",{className:"text-bambu-gray",children:[c.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),c.jsxs("span",{className:"text-bambu-gray",children:[c.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function _8({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const s=En(),a=_R(),[o,l]=M.useState(!1),[u,d]=M.useState(!1),[f,g]=M.useState(!1),[m,x]=M.useState(!1),[y,v]=M.useState(!1),[b,E]=M.useState(!1),[S,A]=M.useState(!1),[T,k]=M.useState(!1),[N,I]=M.useState(null),{data:C}=yt({queryKey:["printerStatus",t.id],queryFn:()=>Pe.getPrinterStatus(t.id),refetchInterval:3e4}),[D,F]=M.useState(null);M.useEffect(()=>{C?.wifi_signal!=null&&F(C.wifi_signal)},[C?.wifi_signal]);const j=C?.wifi_signal??D,q=M.useRef({});M.useEffect(()=>{C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0&&(q.current=C.ams_extruder_map)},[C?.ams_extruder_map]);const R=C?.ams_extruder_map&&Object.keys(C.ams_extruder_map).length>0?C.ams_extruder_map:q.current,W=M.useRef([]);M.useEffect(()=>{C?.ams&&C.ams.length>0&&(W.current=C.ams)},[C?.ams]);const K=C?.ams&&C.ams.length>0?C.ams:W.current,{data:V}=yt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Pe.getSmartPlugByPrinter(t.id)}),{data:te}=yt({queryKey:["smartPlugStatus",V?.id],queryFn:()=>V?Pe.getSmartPlugStatus(V.id):null,enabled:!!V,refetchInterval:1e4}),{data:Y}=yt({queryKey:["queue",t.id,"pending"],queryFn:()=>Pe.getQueue(t.id,"pending")}),Z=Y?.length||0,{data:U}=yt({queryKey:["archives",t.id,"last"],queryFn:()=>Pe.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),z=U?.[0],ee=e&&C&&!C.connected,ae=_t({mutationFn:()=>Pe.deletePrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printers"]})}}),fe=_t({mutationFn:()=>Pe.connectPrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printerStatus",t.id]})}}),de=_t({mutationFn:ye=>V?Pe.controlSmartPlug(V.id,ye):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugStatus",V?.id]})}}),xe=_t({mutationFn:ye=>V?Pe.updateSmartPlug(V.id,{auto_off:ye}):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),s.invalidateQueries({queryKey:["smart-plugs"]})}});return ee?null:c.jsxs(kt,{className:"relative",children:[c.jsxs(Dt,{children:[c.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[c.jsx("img",{src:nCe(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"}`}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&c.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"})]}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&C?.nozzles&&C.nozzles[0]?.nozzle_diameter&&c.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&&c.jsxs("span",{className:"ml-2 text-bambu-gray",children:[c.jsx(ni,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),c.jsxs("div",{className:"relative flex-shrink-0",children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>l(!o),children:c.jsx(ZG,{className:"w-4 h-4"})}),o&&c.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:[c.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:[c.jsx(ed,{className:"w-4 h-4"}),"Edit"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{fe.mutate(),l(!1)},children:[c.jsx(Xs,{className:"w-4 h-4"}),"Reconnect"]}),c.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:[c.jsx(a7,{className:"w-4 h-4"}),"MQTT Debug"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{d(!0),l(!1)},children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&c.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[c.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?c.jsx(OS,{className:"w-3 h-3"}):c.jsx(c7,{className:"w-3 h-3"}),C?.connected?"Connected":"Offline"]}),C?.connected&&j!=null&&c.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${j>=-50||j>=-60?"bg-bambu-green/20 text-bambu-green":j>=-70?"bg-amber-500/20 text-amber-600":j>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${j} dBm - ${rCe(j).label}`,children:[c.jsx(zce,{className:"w-3 h-3"}),j,"dBm"]}),C?.connected&&c.jsxs("button",{onClick:()=>k(!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(ye=>ye.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:[c.jsx(Jr,{className:"w-3 h-3"}),C.hms_errors&&C.hms_errors.length>0?C.hms_errors.length:"OK"]}),n&&c.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:[c.jsx(nd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Z>0&&c.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:[c.jsx(Fh,{className:"w-3 h-3"}),Z]})]})]}),u&&c.jsx(Yr,{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:()=>{ae.mutate(),d(!1)},onCancel:()=>d(!1)}),C?.connected&&c.jsxs(c.Fragment,{children:[r==="compact"?c.jsx("div",{className:"mt-2",children:C.state==="RUNNING"?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:c.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),c.jsxs("span",{className:"text-xs text-white",children:[Math.round(C.progress||0),"%"]})]}):c.jsx("p",{className:"text-xs text-bambu-gray capitalize",children:C.state?.toLowerCase()||"Idle"})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:c.jsxs("div",{className:"flex gap-3",children:[c.jsx(iCe,{url:C.state==="RUNNING"?C.cover_url:null,printName:C.state==="RUNNING"&&(C.subtask_name||C.current_print)||void 0}),c.jsx("div",{className:"flex-1 min-w-0",children:C.current_print&&C.state==="RUNNING"?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),c.jsx("p",{className:"text-white text-sm mb-2 truncate",children:C.subtask_name||C.current_print}),c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:c.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),c.jsxs("span",{className:"text-white",children:[Math.round(C.progress||0),"%"]})]}),c.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[C.remaining_time!=null&&C.remaining_time>0&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(ni,{className:"w-3 h-3"}),eCe(C.remaining_time*60)]}),c.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",tCe(C.remaining_time)]})]}),C.layer_num!=null&&C.total_layers!=null&&C.total_layers>0&&c.jsxs("span",{className:"flex items-center gap-1",children:[c.jsx(Fh,{className:"w-3 h-3"}),C.layer_num,"/",C.total_layers]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),c.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:C.state?.toLowerCase()||"Idle"}),c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:c.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),c.jsx("span",{className:"text-bambu-gray",children:"—"})]}),z?c.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:z.print_name||z.filename,children:["Last: ",z.print_name||z.filename,z.completed_at&&c.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(z.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):c.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),C.state!=="RUNNING"&&c.jsx(Zue,{printerId:t.id})]}),C.temperatures&&r==="expanded"&&c.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[c.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[c.jsx(vh,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),C.temperatures.nozzle_2!==void 0?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C / ",Math.round(C.temperatures.nozzle_2||0),"°C"]})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C"]})]})]}),c.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[c.jsx(vh,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.bed||0),"°C"]})]}),C.temperatures.chamber!==void 0&&c.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[c.jsx(vh,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),c.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.chamber||0),"°C"]})]})]}),K&&K.length>0&&r==="expanded"&&c.jsxs("div",{className:"mt-3 space-y-2",children:[K.map(ye=>{const re=R[String(ye.id)],ve=ye.id>=128?ye.id-128:ye.id,je=re!==void 0?re:ve,ue=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,ut=je===1,$=je===0,H=ye.tray.map(G=>G.tray_color?`#${G.tray_color}`:G.tray_type?"#333":null),ie=ye.tray.length===1;return c.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[ue&&(ut||$)&&c.jsx(VTe,{side:ut?"L":"R"}),ie?c.jsx(WTe,{color:H[0],className:"flex-shrink-0"}):c.jsx(GTe,{colors:H,className:"flex-shrink-0"})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:aC(ye.id,ye.tray.length)}),c.jsx("div",{className:"mt-0.5 text-[10px] flex items-start",children:ye.tray.map((G,J)=>c.jsxs("div",{className:"flex items-start",children:[c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{className:"text-bambu-gray/70 truncate",children:G.tray_type?G.tray_sub_brands||G.tray_type:"—"}),c.jsx("span",{className:"text-bambu-gray/50 truncate",children:G.tray_type&&G.remain>=0?`${G.remain}%`:"—"})]}),J<ye.tray.length-1&&c.jsxs("span",{className:"text-bambu-gray/50 mx-1 flex flex-col",children:[c.jsx("span",{children:"·"}),c.jsx("span",{children:"·"})]})]},J))})]}),(ye.humidity!=null||ye.temp!=null)&&c.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[ye.humidity!=null&&c.jsx(QTe,{humidity:ye.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>I({amsId:ye.id,amsLabel:aC(ye.id,ye.tray.length),mode:"humidity"})}),ye.temp!=null&&c.jsx(JTe,{temp:ye.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>I({amsId:ye.id,amsLabel:aC(ye.id,ye.tray.length),mode:"temperature"})})]})]})},ye.id)}),C.vt_tray&&C.vt_tray.tray_type&&c.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-white/20 flex-shrink-0",style:{backgroundColor:C.vt_tray.tray_color?`#${C.vt_tray.tray_color}`:"#333"}}),c.jsxs("div",{children:[c.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:"External"}),c.jsx("p",{className:"text-[10px] text-bambu-gray/70",children:C.vt_tray.tray_sub_brands||C.vt_tray.tray_type||"Spool"})]})]})})]})]}),V&&r==="expanded"&&c.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx(dm,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),c.jsx("span",{className:"text-sm text-white truncate",children:V.name}),te&&c.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${te.state==="ON"?"bg-bambu-green/20 text-bambu-green":te.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:te.state||"?"}),te?.energy?.power!=null&&te.state==="ON"&&c.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[te.energy.power,"W"]})]}),c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs("button",{onClick:()=>E(!0),disabled:de.isPending||te?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${te?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[c.jsx(gd,{className:"w-3 h-3"}),"On"]}),c.jsxs("button",{onClick:()=>A(!0),disabled:de.isPending||te?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${te?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[c.jsx(LR,{className:"w-3 h-3"}),"Off"]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx("span",{className:`text-xs hidden sm:inline ${V.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:V.auto_off_executed?"Auto-off done":"Auto-off"}),c.jsx("button",{onClick:()=>xe.mutate(!V.auto_off),disabled:xe.isPending||V.auto_off_executed,title:V.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 ${V.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":V.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:c.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${V.auto_off||V.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&c.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[c.jsxs("div",{className:"text-xs text-bambu-gray",children:[c.jsx("p",{children:t.ip_address}),c.jsx("p",{className:"truncate",children:t.serial_number})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ie,{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:c.jsx(u7,{className:"w-4 h-4"})}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>x(!0),title:"Browse printer files",children:[c.jsx(e7,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&c.jsx(Vue,{printerId:t.id,printerName:t.name,onClose:()=>x(!1)}),y&&c.jsx(Gue,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),b&&V&&c.jsx(Yr,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{de.mutate("on"),E(!1)},onCancel:()=>E(!1)}),S&&V&&c.jsx(Yr,{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:()=>{de.mutate("off"),A(!1)},onCancel:()=>A(!1)}),T&&c.jsx(Xue,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>k(!1)}),N&&c.jsx($Te,{isOpen:!!N,onClose:()=>I(null),printerId:t.id,printerName:t.name,amsId:N.amsId,amsLabel:N.amsLabel,initialMode:N.mode,thresholds:i}),f&&c.jsx(oCe,{printer:t,onClose:()=>g(!1)})]})}function aCe({onClose:t,onAdd:e}){const[n,r]=M.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return M.useEffect(()=>{const i=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:c.jsx(kt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:c.jsxs(Dt,{children:[c.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),c.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),c.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:[c.jsx("option",{value:"",children:"Select model..."}),c.jsxs("optgroup",{label:"H2 Series",children:[c.jsx("option",{value:"H2C",children:"H2C"}),c.jsx("option",{value:"H2D",children:"H2D"}),c.jsx("option",{value:"H2S",children:"H2S"})]}),c.jsxs("optgroup",{label:"X1 Series",children:[c.jsx("option",{value:"X1E",children:"X1E"}),c.jsx("option",{value:"X1C",children:"X1 Carbon"}),c.jsx("option",{value:"X1",children:"X1"})]}),c.jsxs("optgroup",{label:"P Series",children:[c.jsx("option",{value:"P2S",children:"P2S"}),c.jsx("option",{value:"P1S",children:"P1S"}),c.jsx("option",{value:"P1P",children:"P1P"})]}),c.jsxs("optgroup",{label:"A1 Series",children:[c.jsx("option",{value:"A1",children:"A1"}),c.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.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"}),c.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),c.jsxs("div",{className:"flex gap-3 pt-4",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function oCe({printer:t,onClose:e}){const n=En(),[r,i]=M.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),s=_t({mutationFn:o=>Pe.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});M.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 c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:c.jsx(kt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:c.jsxs(Dt,{children:[c.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),c.jsxs("form",{onSubmit:a,className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),c.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}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),c.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:[c.jsx("option",{value:"",children:"Select model..."}),c.jsxs("optgroup",{label:"H2 Series",children:[c.jsx("option",{value:"H2C",children:"H2C"}),c.jsx("option",{value:"H2D",children:"H2D"}),c.jsx("option",{value:"H2S",children:"H2S"})]}),c.jsxs("optgroup",{label:"X1 Series",children:[c.jsx("option",{value:"X1E",children:"X1E"}),c.jsx("option",{value:"X1C",children:"X1 Carbon"}),c.jsx("option",{value:"X1",children:"X1"})]}),c.jsxs("optgroup",{label:"P Series",children:[c.jsx("option",{value:"P2S",children:"P2S"}),c.jsx("option",{value:"P1S",children:"P1S"}),c.jsx("option",{value:"P1P",children:"P1P"})]}),c.jsxs("optgroup",{label:"A1 Series",children:[c.jsx("option",{value:"A1",children:"A1"}),c.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),c.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"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.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"}),c.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),c.jsxs("div",{className:"flex gap-3 pt-4",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Saving...":"Save Changes"})]})]})]})})})}function lCe(t){const{data:e}=yt({queryKey:["printerStatus",t],queryFn:()=>Pe.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function cCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=lCe(t.id),{data:s}=yt({queryKey:["smartPlugStatus",e.id],queryFn:()=>Pe.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?c.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&c.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||"?"})]}),c.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:[c.jsx(gd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function uCe(){const[t,e]=M.useState(!1),[n,r]=M.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,s]=M.useState(!1),[a,o]=M.useState(null),[l,u]=M.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=M.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=M.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),x=En(),{data:y,isLoading:v}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:b}=yt({queryKey:["settings"],queryFn:Pe.getSettings}),{data:E}=yt({queryKey:["smart-plugs"],queryFn:Pe.getSmartPlugs}),{data:S}=yt({queryKey:["maintenanceOverview"],queryFn:Pe.getMaintenanceOverview,staleTime:60*1e3}),A=S?.reduce((R,W)=>(R[W.printer_id]={due_count:W.due_count,warning_count:W.warning_count,total_print_hours:W.total_print_hours},R),{})||{},T=E?.reduce((R,W)=>(W.printer_id&&(R[W.printer_id]=W),R),{})||{},k=_t({mutationFn:Pe.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),N=_t({mutationFn:R=>Pe.controlSmartPlug(R,"on"),onSuccess:()=>{x.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),I=()=>{const R=!n;r(R),localStorage.setItem("hideDisconnectedPrinters",String(R))},C=R=>{u(R),localStorage.setItem("printerSortBy",R)},D=()=>{const R=!d;f(R),localStorage.setItem("printerSortAsc",String(R))},F=()=>{const R=g==="expanded"?"compact":"expanded";m(R),localStorage.setItem("printerViewMode",R)},j=M.useMemo(()=>{if(!y)return[];const R=[...y];switch(l){case"name":R.sort((W,K)=>W.name.localeCompare(K.name));break;case"model":R.sort((W,K)=>(W.model||"").localeCompare(K.model||""));break;case"location":R.sort((W,K)=>{const V=W.location||"",te=K.location||"";return!V&&te?1:V&&!te?-1:V.localeCompare(te)||W.name.localeCompare(K.name)});break;case"status":R.sort((W,K)=>{const V=x.getQueryData(["printerStatus",W.id]),te=x.getQueryData(["printerStatus",K.id]),Y=Z=>Z?.connected?Z.state==="RUNNING"?0:1:2;return Y(V)-Y(te)});break}return d||R.reverse(),R},[y,l,d,x]),q=M.useMemo(()=>{if(l!=="location")return null;const R={};return j.forEach(W=>{const K=W.location||"Ungrouped";R[K]||(R[K]=[]),R[K].push(W)}),R},[l,j]);return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"flex items-center justify-between mb-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),c.jsx(sCe,{printers:y})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsxs("select",{value:l,onChange:R=>C(R.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"name",children:"Name"}),c.jsx("option",{value:"status",children:"Status"}),c.jsx("option",{value:"model",children:"Model"}),c.jsx("option",{value:"location",children:"Location"})]}),c.jsx("button",{onClick:D,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?c.jsx(om,{className:"w-4 h-4 text-bambu-gray"}):c.jsx(c0,{className:"w-4 h-4 text-bambu-gray"})})]}),c.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"?c.jsx(Nle,{className:"w-5 h-5 text-bambu-gray"}):c.jsx(n7,{className:"w-5 h-5 text-bambu-gray"})}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:n,onChange:I,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(T).length>0&&c.jsxs("div",{className:"relative",children:[c.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:[c.jsx(gd,{className:"w-4 h-4"}),"Power On",c.jsx(af,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),c.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:[c.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(R=>T[R.id]).map(R=>c.jsx(cCe,{printer:R,plug:T[R.id],onPowerOn:W=>{o(W),N.mutate(W)},isPowering:a===T[R.id]?.id},R.id)),y?.filter(R=>T[R.id]).length===0&&c.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),c.jsxs(Ie,{onClick:()=>e(!0),children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):y?.length===0?c.jsx(kt,{children:c.jsxs(Dt,{className:"text-center py-12",children:[c.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),c.jsxs(Ie,{onClick:()=>e(!0),children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?c.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([R,W])=>c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[c.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),R,c.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.length,")"]})]}),c.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:W.map(K=>c.jsx(_8,{printer:K,hideIfDisconnected:n,maintenanceInfo:A[K.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},K.id))})]},R))}):c.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:j.map(R=>c.jsx(_8,{printer:R,hideIfDisconnected:n,maintenanceInfo:A[R.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},R.id))}),t&&c.jsx(aCe,{onClose:()=>e(!1),onAdd:R=>k.mutate(R)})]})}const HO="181",Qp={ROTATE:0,DOLLY:1,PAN:2},Vp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dCe=0,w8=1,hCe=2,PY=1,fCe=2,nc=3,ld=0,Gs=1,tl=2,yc=0,Jp=1,S8=2,E8=3,M8=4,pCe=5,nh=100,mCe=101,gCe=102,xCe=103,bCe=104,vCe=200,yCe=201,_Ce=202,wCe=203,kk=204,Pk=205,SCe=206,ECe=207,MCe=208,ACe=209,TCe=210,CCe=211,NCe=212,kCe=213,PCe=214,Rk=0,Dk=1,Ok=2,ym=3,jk=4,Lk=5,Ik=6,Uk=7,$O=0,RCe=1,DCe=2,Wu=0,OCe=1,jCe=2,LCe=3,ICe=4,UCe=5,FCe=6,zCe=7,RY=300,_m=301,wm=302,Fk=303,zk=304,PE=306,Bk=1e3,fc=1001,Hk=1002,ba=1003,BCe=1004,Ty=1005,Ja=1006,oC=1007,hh=1008,pl=1009,DY=1010,OY=1011,j0=1012,VO=1013,Kh=1014,pc=1015,Jm=1016,GO=1017,WO=1018,L0=1020,jY=35902,LY=35899,IY=1021,UY=1022,No=1023,I0=1026,U0=1027,FY=1028,qO=1029,KO=1030,XO=1031,YO=1033,Q_=33776,J_=33777,e1=33778,t1=33779,$k=35840,Vk=35841,Gk=35842,Wk=35843,qk=36196,Kk=37492,Xk=37496,Yk=37808,Zk=37809,Qk=37810,Jk=37811,eP=37812,tP=37813,nP=37814,rP=37815,iP=37816,sP=37817,aP=37818,oP=37819,lP=37820,cP=37821,uP=36492,dP=36494,hP=36495,fP=36283,pP=36284,mP=36285,gP=36286,HCe=3200,$Ce=3201,zY=0,VCe=1,Ou="",$a="srgb",Sm="srgb-linear",_w="linear",Wn="srgb",Zf=7680,A8=519,GCe=512,WCe=513,qCe=514,BY=515,KCe=516,XCe=517,YCe=518,ZCe=519,T8=35044,C8="300 es",sl=2e3,ww=2001;function HY(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Sw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function QCe(){const t=Sw("canvas");return t.style.display="block",t}const N8={};function k8(...t){const e="THREE."+t.shift();console.log(e,...t)}function Xt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Ur(...t){const e="THREE."+t.shift();console.error(e,...t)}function F0(...t){const e=t.join(" ");e in N8||(N8[e]=!0,Xt(...t))}function JCe(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 df=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 rs=["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"],n1=Math.PI/180,xP=180/Math.PI;function Fb(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(rs[t&255]+rs[t>>8&255]+rs[t>>16&255]+rs[t>>24&255]+"-"+rs[e&255]+rs[e>>8&255]+"-"+rs[e>>16&15|64]+rs[e>>24&255]+"-"+rs[n&63|128]+rs[n>>8&255]+"-"+rs[n>>16&255]+rs[n>>24&255]+rs[r&255]+rs[r>>8&255]+rs[r>>16&255]+rs[r>>24&255]).toLowerCase()}function mn(t,e,n){return Math.max(e,Math.min(n,t))}function eNe(t,e){return(t%e+e)%e}function lC(t,e,n){return(1-n)*t+n*e}function ox(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 Fs(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const tNe={DEG2RAD:n1};let on=class $Y{constructor(e=0,n=0){$Y.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}},Xh=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],u=r[i+1],d=r[i+2],f=r[i+3],g=s[a+0],m=s[a+1],x=s[a+2],y=s[a+3];if(o<=0){e[n+0]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o>=1){e[n+0]=g,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(f!==y||l!==g||u!==m||d!==x){let v=l*g+u*m+d*x+f*y;v<0&&(g=-g,m=-m,x=-x,y=-y,v=-v);let b=1-o;if(v<.9995){const E=Math.acos(v),S=Math.sin(E);b=Math.sin(b*E)/S,o=Math.sin(o*E)/S,l=l*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+y*o}else{l=l*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+y*o;const E=1/Math.sqrt(l*l+u*u+d*d+f*f);l*=E,u*=E,d*=E,f*=E}}e[n]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],u=r[i+2],d=r[i+3],f=s[a],g=s[a+1],m=s[a+2],x=s[a+3];return e[n]=o*x+d*f+l*m-u*g,e[n+1]=l*x+d*g+u*f-o*m,e[n+2]=u*x+d*m+o*g-l*f,e[n+3]=d*x-o*f-l*g-u*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,u=o(r/2),d=o(i/2),f=o(s/2),g=l(r/2),m=l(i/2),x=l(s/2);switch(a){case"XYZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"YXZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"ZXY":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"ZYX":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"YZX":this._x=g*d*f+u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f-g*m*x;break;case"XZY":this._x=g*d*f-u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f+g*m*x;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],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-l)*m,this._y=(s-u)*m,this._z=(a-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(d-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(s-u)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(a-i)/m,this._x=(s+u)/m,this._y=(l+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(mn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,l=n._y,u=n._z,d=n._w;return this._x=r*d+a*o+i*u-s*l,this._y=i*d+a*l+s*o-r*u,this._z=s*d+a*u+r*l-i*o,this._w=a*d-r*o-i*l-s*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,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 u=Math.acos(o),d=Math.sin(u);l=Math.sin(l*u)/d,n=Math.sin(n*u)/d,this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*n,this._onChangeCallback()}else this._x=this._x*l+r*n,this._y=this._y*l+i*n,this._z=this._z*l+s*n,this._w=this._w*l+a*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(n),s*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Je=class VY{constructor(e=0,n=0,r=0){VY.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(P8.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(P8.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,u=2*(a*i-o*r),d=2*(o*n-s*i),f=2*(s*r-a*n);return this.x=n+l*u+a*f-o*d,this.y=r+l*d+o*u-s*f,this.z=i+l*f+s*d-a*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,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 cC.copy(this).projectOnVector(e),this.sub(cC)}reflect(e){return this.sub(cC.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 cC=new Je,P8=new Xh;let un=class GY{constructor(e,n,r,i,s,a,o,l,u){GY.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,u)}set(e,n,r,i,s,a,o,l,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],l=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],x=r[8],y=i[0],v=i[3],b=i[6],E=i[1],S=i[4],A=i[7],T=i[2],k=i[5],N=i[8];return s[0]=a*y+o*E+l*T,s[3]=a*v+o*S+l*k,s[6]=a*b+o*A+l*N,s[1]=u*y+d*E+f*T,s[4]=u*v+d*S+f*k,s[7]=u*b+d*A+f*N,s[2]=g*y+m*E+x*T,s[5]=g*v+m*S+x*k,s[8]=g*b+m*A+x*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8];return n*a*d-n*o*u-r*s*d+r*o*l+i*s*u-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],u=e[7],d=e[8],f=d*a-o*u,g=o*l-d*s,m=u*s-a*l,x=n*f+r*g+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(d*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-u*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),u=Math.sin(s);return this.set(r*l,r*u,-r*(l*a+u*o)+a+e,-i*u,i*l,-i*(-u*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(uC.makeScale(e,n)),this}rotate(e){return this.premultiply(uC.makeRotation(-e)),this}translate(e,n){return this.premultiply(uC.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 uC=new un,R8=new un().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),D8=new un().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function nNe(){const t={enabled:!0,workingColorSpace:Sm,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Wn&&(i.r=_c(i.r),i.g=_c(i.g),i.b=_c(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===Wn&&(i.r=em(i.r),i.g=em(i.g),i.b=em(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===Ou?_w: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 F0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return F0("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({[Sm]:{primaries:e,whitePoint:r,transfer:_w,toXYZ:R8,fromXYZ:D8,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:$a},outputColorSpaceConfig:{drawingBufferColorSpace:$a}},[$a]:{primaries:e,whitePoint:r,transfer:Wn,toXYZ:R8,fromXYZ:D8,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:$a}}}),t}const Tn=nNe();function _c(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function em(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Qf,rNe=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{Qf===void 0&&(Qf=Sw("canvas")),Qf.width=e.width,Qf.height=e.height;const i=Qf.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Qf}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=Sw("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]=_c(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(_c(n[r]/255)*255):n[r]=_c(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}},iNe=0,ZO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:iNe++}),this.uuid=Fb(),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(dC(i[a].image)):s.push(dC(i[a]))}else s=dC(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function dC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?rNe.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 sNe=0;const hC=new Je;let Bo=class r1 extends df{constructor(e=r1.DEFAULT_IMAGE,n=r1.DEFAULT_MAPPING,r=fc,i=fc,s=Ja,a=hh,o=No,l=pl,u=r1.DEFAULT_ANISOTROPY,d=Ou){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:sNe++}),this.uuid=Fb(),this.name="",this.source=new ZO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=l,this.offset=new on(0,0),this.repeat=new on(1,1),this.center=new on(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new un,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(hC).x}get height(){return this.source.getSize(hC).y}get depth(){return this.source.getSize(hC).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!==RY)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Bk:e.x=e.x-Math.floor(e.x);break;case fc:e.x=e.x<0?0:1;break;case Hk: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 Bk:e.y=e.y-Math.floor(e.y);break;case fc:e.y=e.y<0?0:1;break;case Hk: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++}};Bo.DEFAULT_IMAGE=null;Bo.DEFAULT_MAPPING=RY;Bo.DEFAULT_ANISOTROPY=1;let Kr=class WY{constructor(e=0,n=0,r=0,i=1){WY.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,u=l[0],d=l[4],f=l[8],g=l[1],m=l[5],x=l[9],y=l[2],v=l[6],b=l[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(b+1)/2,k=(d+g)/4,N=(f+y)/4,I=(x+v)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(S),i=k/r,s=N/r):A>T?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=k/i,s=I/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=N/s,i=I/s),this.set(r,i,s,n),this}let E=Math.sqrt((v-x)*(v-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(v-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+m+b-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=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}},aNe=class extends df{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ja,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 Kr(0,0,e,n),this.scissorTest=!1,this.viewport=new Kr(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new Bo(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:Ja,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 ZO(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"})}},Yh=class extends aNe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},qY=class extends Bo{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=ba,this.minFilter=ba,this.wrapR=fc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},oNe=class extends Bo{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=ba,this.minFilter=ba,this.wrapR=fc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Zh=class{constructor(e=new Je(1/0,1/0,1/0),n=new Je(-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(go.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(go.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=go.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,go):go.fromBufferAttribute(s,a),go.applyMatrix4(e.matrixWorld),this.expandByPoint(go);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Cy.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Cy.copy(r.boundingBox)),Cy.applyMatrix4(e.matrixWorld),this.union(Cy)}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,go),go.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(lx),Ny.subVectors(this.max,lx),Jf.subVectors(e.a,lx),ep.subVectors(e.b,lx),tp.subVectors(e.c,lx),uu.subVectors(ep,Jf),du.subVectors(tp,ep),zd.subVectors(Jf,tp);let n=[0,-uu.z,uu.y,0,-du.z,du.y,0,-zd.z,zd.y,uu.z,0,-uu.x,du.z,0,-du.x,zd.z,0,-zd.x,-uu.y,uu.x,0,-du.y,du.x,0,-zd.y,zd.x,0];return!fC(n,Jf,ep,tp,Ny)||(n=[1,0,0,0,1,0,0,0,1],!fC(n,Jf,ep,tp,Ny))?!1:(ky.crossVectors(uu,du),n=[ky.x,ky.y,ky.z],fC(n,Jf,ep,tp,Ny))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,go).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(go).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:(Hl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hl),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 Hl=[new Je,new Je,new Je,new Je,new Je,new Je,new Je,new Je],go=new Je,Cy=new Zh,Jf=new Je,ep=new Je,tp=new Je,uu=new Je,du=new Je,zd=new Je,lx=new Je,Ny=new Je,ky=new Je,Bd=new Je;function fC(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){Bd.fromArray(t,s);const o=i.x*Math.abs(Bd.x)+i.y*Math.abs(Bd.y)+i.z*Math.abs(Bd.z),l=e.dot(Bd),u=n.dot(Bd),d=r.dot(Bd);if(Math.max(-Math.max(l,u,d),Math.min(l,u,d))>o)return!1}return!0}const lNe=new Zh,cx=new Je,pC=new Je;let RE=class{constructor(e=new Je,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):lNe.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;cx.subVectors(e,this.center);const n=cx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(cx,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(pC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cx.copy(e.center).add(pC)),this.expandByPoint(cx.copy(e.center).sub(pC))),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 $l=new Je,mC=new Je,Py=new Je,hu=new Je,gC=new Je,Ry=new Je,xC=new Je;let QO=class{constructor(e=new Je,n=new Je(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,$l)),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=$l.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):($l.copy(this.origin).addScaledVector(this.direction,n),$l.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){mC.copy(e).add(n).multiplyScalar(.5),Py.copy(n).sub(e).normalize(),hu.copy(this.origin).sub(mC);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Py),o=hu.dot(this.direction),l=-hu.dot(Py),u=hu.lengthSq(),d=Math.abs(1-a*a);let f,g,m,x;if(d>0)if(f=a*l-o,g=a*o-l,x=s*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,m=f*(f+a*g+2*o)+g*(a*f+g+2*l)+u}else g=s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g=-s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g<=-x?(f=Math.max(0,-(-a*s+o)),g=f>0?-s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u):g<=x?(f=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+u):(f=Math.max(0,-(a*s+o)),g=f>0?s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u);else g=a>0?-s:s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(mC).addScaledVector(Py,g),m}intersectSphere(e,n){$l.subVectors(e.center,this.origin);const r=$l.dot(this.direction),i=$l.dot($l)-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 u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(s=(e.min.y-g.y)*d,a=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,a=(e.min.y-g.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),f>=0?(o=(e.min.z-g.z)*f,l=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,l=(e.min.z-g.z)*f),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,$l)!==null}intersectTriangle(e,n,r,i,s){gC.subVectors(n,e),Ry.subVectors(r,e),xC.crossVectors(gC,Ry);let a=this.direction.dot(xC),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;hu.subVectors(this.origin,e);const l=o*this.direction.dot(Ry.crossVectors(hu,Ry));if(l<0)return null;const u=o*this.direction.dot(gC.cross(hu));if(u<0||l+u>a)return null;const d=-o*hu.dot(xC);return d<0?null:this.at(d/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ti=class bP{constructor(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){bP.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,u,d,f,g,m,x,y,v)}set(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=s,b[5]=a,b[9]=o,b[13]=l,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=m,b[7]=x,b[11]=y,b[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 bP().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/np.setFromMatrixColumn(e,0).length(),s=1/np.setFromMatrixColumn(e,1).length(),a=1/np.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),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=-l*f,n[8]=u,n[1]=m+x*u,n[5]=g-y*u,n[9]=-o*l,n[2]=y-g*u,n[6]=x+m*u,n[10]=a*l}else if(e.order==="YXZ"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g+y*o,n[4]=x*o-m,n[8]=a*u,n[1]=a*f,n[5]=a*d,n[9]=-o,n[2]=m*o-x,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g-y*o,n[4]=-a*f,n[8]=x+m*o,n[1]=m+x*o,n[5]=a*d,n[9]=y-g*o,n[2]=-a*u,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=x*u-m,n[8]=g*u+y,n[1]=l*f,n[5]=y*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=y-g*f,n[8]=x*f+m,n[1]=f,n[5]=a*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=a*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=o*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(cNe,e,uNe)}lookAt(e,n,r){const i=this.elements;return oa.subVectors(e,n),oa.lengthSq()===0&&(oa.z=1),oa.normalize(),fu.crossVectors(r,oa),fu.lengthSq()===0&&(Math.abs(r.z)===1?oa.x+=1e-4:oa.z+=1e-4,oa.normalize(),fu.crossVectors(r,oa)),fu.normalize(),Dy.crossVectors(oa,fu),i[0]=fu.x,i[4]=Dy.x,i[8]=oa.x,i[1]=fu.y,i[5]=Dy.y,i[9]=oa.y,i[2]=fu.z,i[6]=Dy.z,i[10]=oa.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],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],x=r[2],y=r[6],v=r[10],b=r[14],E=r[3],S=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],j=i[9],q=i[13],R=i[2],W=i[6],K=i[10],V=i[14],te=i[3],Y=i[7],Z=i[11],U=i[15];return s[0]=a*k+o*D+l*R+u*te,s[4]=a*N+o*F+l*W+u*Y,s[8]=a*I+o*j+l*K+u*Z,s[12]=a*C+o*q+l*V+u*U,s[1]=d*k+f*D+g*R+m*te,s[5]=d*N+f*F+g*W+m*Y,s[9]=d*I+f*j+g*K+m*Z,s[13]=d*C+f*q+g*V+m*U,s[2]=x*k+y*D+v*R+b*te,s[6]=x*N+y*F+v*W+b*Y,s[10]=x*I+y*j+v*K+b*Z,s[14]=x*C+y*q+v*V+b*U,s[3]=E*k+S*D+A*R+T*te,s[7]=E*N+S*F+A*W+T*Y,s[11]=E*I+S*j+A*K+T*Z,s[15]=E*C+S*q+A*V+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],x=e[3],y=e[7],v=e[11],b=e[15];return x*(+s*l*f-i*u*f-s*o*g+r*u*g+i*o*m-r*l*m)+y*(+n*l*m-n*u*g+s*a*g-i*a*m+i*u*d-s*l*d)+v*(+n*u*f-n*o*m-s*a*f+r*a*m+s*o*d-r*u*d)+b*(-i*o*d-n*l*f+n*o*g+i*a*f-r*a*g+r*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],x=e[12],y=e[13],v=e[14],b=e[15],E=f*v*u-y*g*u+y*l*m-o*v*m-f*l*b+o*g*b,S=x*g*u-d*v*u-x*l*m+a*v*m+d*l*b-a*g*b,A=d*y*u-x*f*u+x*o*m-a*y*m-d*o*b+a*f*b,T=x*f*l-d*y*l-x*o*g+a*y*g+d*o*v-a*f*v,k=n*E+r*S+i*A+s*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/k;return e[0]=E*N,e[1]=(y*g*s-f*v*s-y*i*m+r*v*m+f*i*b-r*g*b)*N,e[2]=(o*v*s-y*l*s+y*i*u-r*v*u-o*i*b+r*l*b)*N,e[3]=(f*l*s-o*g*s-f*i*u+r*g*u+o*i*m-r*l*m)*N,e[4]=S*N,e[5]=(d*v*s-x*g*s+x*i*m-n*v*m-d*i*b+n*g*b)*N,e[6]=(x*l*s-a*v*s-x*i*u+n*v*u+a*i*b-n*l*b)*N,e[7]=(a*g*s-d*l*s+d*i*u-n*g*u-a*i*m+n*l*m)*N,e[8]=A*N,e[9]=(x*f*s-d*y*s-x*r*m+n*y*m+d*r*b-n*f*b)*N,e[10]=(a*y*s-x*o*s+x*r*u-n*y*u-a*r*b+n*o*b)*N,e[11]=(d*o*s-a*f*s-d*r*u+n*f*u+a*r*m-n*o*m)*N,e[12]=T*N,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*v+n*f*v)*N,e[14]=(x*o*i-a*y*i-x*r*l+n*y*l+a*r*v-n*o*v)*N,e[15]=(a*f*i-d*o*i+d*r*l-n*f*l-a*r*g+n*o*g)*N,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,u=s*a,d=s*o;return this.set(u*a+r,u*o-i*l,u*l+i*o,0,u*o+i*l,d*o+r,d*l-i*a,0,u*l-i*o,d*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,u=s+s,d=a+a,f=o+o,g=s*u,m=s*d,x=s*f,y=a*d,v=a*f,b=o*f,E=l*u,S=l*d,A=l*f,T=r.x,k=r.y,N=r.z;return i[0]=(1-(y+b))*T,i[1]=(m+A)*T,i[2]=(x-S)*T,i[3]=0,i[4]=(m-A)*k,i[5]=(1-(g+b))*k,i[6]=(v+E)*k,i[7]=0,i[8]=(x+S)*N,i[9]=(v-E)*N,i[10]=(1-(g+y))*N,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=np.set(i[0],i[1],i[2]).length();const a=np.set(i[4],i[5],i[6]).length(),o=np.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],xo.copy(this);const u=1/s,d=1/a,f=1/o;return xo.elements[0]*=u,xo.elements[1]*=u,xo.elements[2]*=u,xo.elements[4]*=d,xo.elements[5]*=d,xo.elements[6]*=d,xo.elements[8]*=f,xo.elements[9]*=f,xo.elements[10]*=f,n.setFromRotationMatrix(xo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=sl,l=!1){const u=this.elements,d=2*s/(n-e),f=2*s/(r-i),g=(n+e)/(n-e),m=(r+i)/(r-i);let x,y;if(l)x=s/(a-s),y=a*s/(a-s);else if(o===sl)x=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===ww)x=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=sl,l=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,y;if(l)x=1/(a-s),y=a/(a-s);else if(o===sl)x=-2/(a-s),y=-(a+s)/(a-s);else if(o===ww)x=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const np=new Je,xo=new ti,cNe=new Je(0,0,0),uNe=new Je(1,1,1),fu=new Je,Dy=new Je,oa=new Je,O8=new ti,j8=new Xh;let cd=class KY{constructor(e=0,n=0,r=0,i=KY.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],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(mn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-mn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(mn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-mn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(mn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,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,u),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:Xt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return O8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(O8,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return j8.setFromEuler(this),this.setFromQuaternion(j8,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}};cd.DEFAULT_ORDER="XYZ";let XY=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}},dNe=0;const L8=new Je,rp=new Xh,Vl=new ti,Oy=new Je,ux=new Je,hNe=new Je,fNe=new Xh,I8=new Je(1,0,0),U8=new Je(0,1,0),F8=new Je(0,0,1),z8={type:"added"},pNe={type:"removed"},ip={type:"childadded",child:null},bC={type:"childremoved",child:null};let Sa=class i1 extends df{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:dNe++}),this.uuid=Fb(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i1.DEFAULT_UP.clone();const e=new Je,n=new cd,r=new Xh,i=new Je(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 ti},normalMatrix:{value:new un}}),this.matrix=new ti,this.matrixWorld=new ti,this.matrixAutoUpdate=i1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new XY,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 rp.setFromAxisAngle(e,n),this.quaternion.multiply(rp),this}rotateOnWorldAxis(e,n){return rp.setFromAxisAngle(e,n),this.quaternion.premultiply(rp),this}rotateX(e){return this.rotateOnAxis(I8,e)}rotateY(e){return this.rotateOnAxis(U8,e)}rotateZ(e){return this.rotateOnAxis(F8,e)}translateOnAxis(e,n){return L8.copy(e).applyQuaternion(this.quaternion),this.position.add(L8.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(I8,e)}translateY(e){return this.translateOnAxis(U8,e)}translateZ(e){return this.translateOnAxis(F8,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Vl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Oy.copy(e):Oy.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),ux.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Vl.lookAt(ux,Oy,this.up):Vl.lookAt(Oy,ux,this.up),this.quaternion.setFromRotationMatrix(Vl),i&&(Vl.extractRotation(i.matrixWorld),rp.setFromRotationMatrix(Vl),this.quaternion.premultiply(rp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Ur("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(z8),ip.child=e,this.dispatchEvent(ip),ip.child=null):Ur("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(pNe),bC.child=e,this.dispatchEvent(bC),bC.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),Vl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Vl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Vl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(z8),ip.child=e,this.dispatchEvent(ip),ip.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(ux,e,hNe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ux,fNe,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 u=0,d=l.length;u<d;u++){const f=l[u];s(e.shapes,f)}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,u=this.material.length;l<u;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),u=a(e.textures),d=a(e.images),f=a(e.shapes),g=a(e.skeletons),m=a(e.animations),x=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function a(o){const l=[];for(const u in o){const d=o[u];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Sa.DEFAULT_UP=new Je(0,1,0);Sa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Sa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const bo=new Je,Gl=new Je,vC=new Je,Wl=new Je,sp=new Je,ap=new Je,B8=new Je,yC=new Je,_C=new Je,wC=new Je,SC=new Kr,EC=new Kr,MC=new Kr;let dx=class jp{constructor(e=new Je,n=new Je,r=new Je){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),bo.subVectors(e,n),i.cross(bo);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){bo.subVectors(i,n),Gl.subVectors(r,n),vC.subVectors(e,n);const a=bo.dot(bo),o=bo.dot(Gl),l=bo.dot(vC),u=Gl.dot(Gl),d=Gl.dot(vC),f=a*u-o*o;if(f===0)return s.set(0,0,0),null;const g=1/f,m=(u*l-o*d)*g,x=(a*d-o*l)*g;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Wl)===null?!1:Wl.x>=0&&Wl.y>=0&&Wl.x+Wl.y<=1}static getInterpolation(e,n,r,i,s,a,o,l){return this.getBarycoord(e,n,r,i,Wl)===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,Wl.x),l.addScaledVector(a,Wl.y),l.addScaledVector(o,Wl.z),l)}static getInterpolatedAttribute(e,n,r,i,s,a){return SC.setScalar(0),EC.setScalar(0),MC.setScalar(0),SC.fromBufferAttribute(e,n),EC.fromBufferAttribute(e,r),MC.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(SC,s.x),a.addScaledVector(EC,s.y),a.addScaledVector(MC,s.z),a}static isFrontFacing(e,n,r,i){return bo.subVectors(r,n),Gl.subVectors(e,n),bo.cross(Gl).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 bo.subVectors(this.c,this.b),Gl.subVectors(this.a,this.b),bo.cross(Gl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return jp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return jp.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return jp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jp.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;sp.subVectors(i,r),ap.subVectors(s,r),yC.subVectors(e,r);const l=sp.dot(yC),u=ap.dot(yC);if(l<=0&&u<=0)return n.copy(r);_C.subVectors(e,i);const d=sp.dot(_C),f=ap.dot(_C);if(d>=0&&f<=d)return n.copy(i);const g=l*f-d*u;if(g<=0&&l>=0&&d<=0)return a=l/(l-d),n.copy(r).addScaledVector(sp,a);wC.subVectors(e,s);const m=sp.dot(wC),x=ap.dot(wC);if(x>=0&&m<=x)return n.copy(s);const y=m*u-l*x;if(y<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(ap,o);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return B8.subVectors(s,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(B8,o);const b=1/(v+y+g);return a=y*b,o=g*b,n.copy(r).addScaledVector(sp,a).addScaledVector(ap,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const YY={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},jy={h:0,s:0,l:0};function AC(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 yn=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=$a){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Tn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Tn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Tn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Tn.workingColorSpace){if(e=eNe(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=AC(a,s,e+1/3),this.g=AC(a,s,e),this.b=AC(a,s,e-1/3)}return Tn.colorSpaceToWorking(this,i),this}setStyle(e,n=$a){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=$a){const r=YY[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=_c(e.r),this.g=_c(e.g),this.b=_c(e.b),this}copyLinearToSRGB(e){return this.r=em(e.r),this.g=em(e.g),this.b=em(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=$a){return Tn.workingToColorSpace(is.copy(this),e),Math.round(mn(is.r*255,0,255))*65536+Math.round(mn(is.g*255,0,255))*256+Math.round(mn(is.b*255,0,255))}getHexString(e=$a){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Tn.workingColorSpace){Tn.workingToColorSpace(is.copy(this),n);const r=is.r,i=is.g,s=is.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,u;const d=(o+a)/2;if(o===a)l=0,u=0;else{const f=a-o;switch(u=d<=.5?f/(a+o):f/(2-a-o),a){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=u,e.l=d,e}getRGB(e,n=Tn.workingColorSpace){return Tn.workingToColorSpace(is.copy(this),n),e.r=is.r,e.g=is.g,e.b=is.b,e}getStyle(e=$a){Tn.workingToColorSpace(is.copy(this),e);const n=is.r,r=is.g,i=is.b;return e!==$a?`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(jy);const r=lC(pu.h,jy.h,n),i=lC(pu.s,jy.s,n),s=lC(pu.l,jy.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 is=new yn;yn.NAMES=YY;let mNe=0,eg=class extends df{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:mNe++}),this.uuid=Fb(),this.name="",this.type="Material",this.blending=Jp,this.side=ld,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=kk,this.blendDst=Pk,this.blendEquation=nh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new yn(0,0,0),this.blendAlpha=0,this.depthFunc=ym,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=A8,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Zf,this.stencilZFail=Zf,this.stencilZPass=Zf,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!==Jp&&(r.blending=this.blending),this.side!==ld&&(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!==kk&&(r.blendSrc=this.blendSrc),this.blendDst!==Pk&&(r.blendDst=this.blendDst),this.blendEquation!==nh&&(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!==ym&&(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!==A8&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Zf&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Zf&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Zf&&(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++}},JO=class extends eg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yn(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 cd,this.combine=$O,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 Gr=new Je,Ly=new on;let gNe=0,eo=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:gNe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=T8,this.updateRanges=[],this.gpuType=pc,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++)Ly.fromBufferAttribute(this,n),Ly.applyMatrix3(e),this.setXY(n,Ly.x,Ly.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Gr.fromBufferAttribute(this,n),Gr.applyMatrix3(e),this.setXYZ(n,Gr.x,Gr.y,Gr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Gr.fromBufferAttribute(this,n),Gr.applyMatrix4(e),this.setXYZ(n,Gr.x,Gr.y,Gr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Gr.fromBufferAttribute(this,n),Gr.applyNormalMatrix(e),this.setXYZ(n,Gr.x,Gr.y,Gr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Gr.fromBufferAttribute(this,n),Gr.transformDirection(e),this.setXYZ(n,Gr.x,Gr.y,Gr.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=ox(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Fs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=ox(n,this.array)),n}setX(e,n){return this.normalized&&(n=Fs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=ox(n,this.array)),n}setY(e,n){return this.normalized&&(n=Fs(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=ox(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Fs(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=ox(n,this.array)),n}setW(e,n){return this.normalized&&(n=Fs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Fs(n,this.array),r=Fs(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=Fs(n,this.array),r=Fs(r,this.array),i=Fs(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=Fs(n,this.array),r=Fs(r,this.array),i=Fs(i,this.array),s=Fs(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!==T8&&(e.usage=this.usage),e}},ZY=class extends eo{constructor(e,n,r){super(new Uint16Array(e),n,r)}},QY=class extends eo{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Do=class extends eo{constructor(e,n,r){super(new Float32Array(e),n,r)}},xNe=0;const Oa=new ti,TC=new Sa,op=new Je,la=new Zh,hx=new Zh,Ti=new Je;let Sl=class JY extends df{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:xNe++}),this.uuid=Fb(),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(HY(e)?QY:ZY)(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 Oa.makeRotationFromQuaternion(e),this.applyMatrix4(Oa),this}rotateX(e){return Oa.makeRotationX(e),this.applyMatrix4(Oa),this}rotateY(e){return Oa.makeRotationY(e),this.applyMatrix4(Oa),this}rotateZ(e){return Oa.makeRotationZ(e),this.applyMatrix4(Oa),this}translate(e,n,r){return Oa.makeTranslation(e,n,r),this.applyMatrix4(Oa),this}scale(e,n,r){return Oa.makeScale(e,n,r),this.applyMatrix4(Oa),this}lookAt(e){return TC.lookAt(e),TC.updateMatrix(),this.applyMatrix4(TC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(op).negate(),this.translate(op.x,op.y,op.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 Do(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 Zh);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ur("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Je(-1/0,-1/0,-1/0),new Je(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];la.setFromBufferAttribute(s),this.morphTargetsRelative?(Ti.addVectors(this.boundingBox.min,la.min),this.boundingBox.expandByPoint(Ti),Ti.addVectors(this.boundingBox.max,la.max),this.boundingBox.expandByPoint(Ti)):(this.boundingBox.expandByPoint(la.min),this.boundingBox.expandByPoint(la.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ur('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 RE);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ur("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Je,1/0);return}if(e){const r=this.boundingSphere.center;if(la.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];hx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ti.addVectors(la.min,hx.min),la.expandByPoint(Ti),Ti.addVectors(la.max,hx.max),la.expandByPoint(Ti)):(la.expandByPoint(hx.min),la.expandByPoint(hx.max))}la.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Ti.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ti));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ti.fromBufferAttribute(o,u),l&&(op.fromBufferAttribute(e,u),Ti.add(op)),i=Math.max(i,r.distanceToSquared(Ti))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ur('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){Ur("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 eo(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<r.count;I++)o[I]=new Je,l[I]=new Je;const u=new Je,d=new Je,f=new Je,g=new on,m=new on,x=new on,y=new Je,v=new Je;function b(I,C,D){u.fromBufferAttribute(r,I),d.fromBufferAttribute(r,C),f.fromBufferAttribute(r,D),g.fromBufferAttribute(s,I),m.fromBufferAttribute(s,C),x.fromBufferAttribute(s,D),d.sub(u),f.sub(u),m.sub(g),x.sub(g);const F=1/(m.x*x.y-x.x*m.y);isFinite(F)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(F),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(F),o[I].add(y),o[C].add(y),o[D].add(y),l[I].add(v),l[C].add(v),l[D].add(v))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let I=0,C=E.length;I<C;++I){const D=E[I],F=D.start,j=D.count;for(let q=F,R=F+j;q<R;q+=3)b(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const S=new Je,A=new Je,T=new Je,k=new Je;function N(I){T.fromBufferAttribute(i,I),k.copy(T);const C=o[I];S.copy(C),S.sub(T.multiplyScalar(T.dot(C))).normalize(),A.crossVectors(k,C);const F=A.dot(l[I])<0?-1:1;a.setXYZW(I,S.x,S.y,S.z,F)}for(let I=0,C=E.length;I<C;++I){const D=E[I],F=D.start,j=D.count;for(let q=F,R=F+j;q<R;q+=3)N(e.getX(q+0)),N(e.getX(q+1)),N(e.getX(q+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new eo(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 Je,s=new Je,a=new Je,o=new Je,l=new Je,u=new Je,d=new Je,f=new Je;if(e)for(let g=0,m=e.count;g<m;g+=3){const x=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),o.fromBufferAttribute(r,x),l.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),l.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ti.fromBufferAttribute(e,n),Ti.normalize(),e.setXYZ(n,Ti.x,Ti.y,Ti.z)}toNonIndexed(){function e(o,l){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(l.length*d);let m=0,x=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new eo(g,d,f)}if(this.index===null)return Xt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new JY,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],u=e(l,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const l=[],u=s[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const u=a[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const u in l)l[u]!==void 0&&(e[u]=l[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const u=r[l];e.data.attributes[l]=u.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const u=this.morphAttributes[l],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],f=s[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let u=0,d=a.length;u<d;u++){const f=a[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const H8=new ti,Hd=new QO,Iy=new RE,$8=new Je,Uy=new Je,Fy=new Je,zy=new Je,CC=new Je,By=new Je,V8=new Je,Hy=new Je;let ml=class extends Sa{constructor(e=new Sl,n=new JO){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){By.set(0,0,0);for(let l=0,u=s.length;l<u;l++){const d=o[l],f=s[l];d!==0&&(CC.fromBufferAttribute(f,e),a?By.addScaledVector(CC,d):By.addScaledVector(CC.sub(n),d))}n.add(By)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Iy.copy(r.boundingSphere),Iy.applyMatrix4(s),Hd.copy(e.ray).recast(e.near),!(Iy.containsPoint(Hd.origin)===!1&&(Hd.intersectSphere(Iy,$8)===null||Hd.origin.distanceToSquared($8)>(e.far-e.near)**2))&&(H8.copy(s).invert(),Hd.copy(e.ray).applyMatrix4(H8),!(r.boundingBox!==null&&Hd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Hd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=$y(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=o.getX(v),S=o.getX(v+1),A=o.getX(v+2);i=$y(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const k=A,N=A+1,I=A+2;i=$y(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=v,S=v+1,A=v+2;i=$y(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function bNe(t,e,n,r,i,s,a,o){let l;if(e.side===Gs?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===ld,o),l===null)return null;Hy.copy(o),Hy.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Hy);return u<n.near||u>n.far?null:{distance:u,point:Hy.clone(),object:t}}function $y(t,e,n,r,i,s,a,o,l,u){t.getVertexPosition(o,Uy),t.getVertexPosition(l,Fy),t.getVertexPosition(u,zy);const d=bNe(t,e,n,r,Uy,Fy,zy,V8);if(d){const f=new Je;dx.getBarycoord(V8,Uy,Fy,zy,f),i&&(d.uv=dx.getInterpolatedAttribute(i,o,l,u,f,new on)),s&&(d.uv1=dx.getInterpolatedAttribute(s,o,l,u,f,new on)),a&&(d.normal=dx.getInterpolatedAttribute(a,o,l,u,f,new Je),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:l,c:u,normal:new Je,materialIndex:0};dx.getNormal(Uy,Fy,zy,g.normal),d.face=g,d.barycoord=f}return d}let ej=class eZ extends Sl{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=[],u=[],d=[],f=[];let g=0,m=0;x("z","y","x",-1,-1,r,n,e,a,s,0),x("z","y","x",1,-1,r,n,-e,a,s,1),x("x","z","y",1,1,e,r,n,i,a,2),x("x","z","y",1,-1,e,r,-n,i,a,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Do(u,3)),this.setAttribute("normal",new Do(d,3)),this.setAttribute("uv",new Do(f,2));function x(y,v,b,E,S,A,T,k,N,I,C){const D=A/N,F=T/I,j=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let V=0,te=0;const Y=new Je;for(let Z=0;Z<K;Z++){const U=Z*F-q;for(let z=0;z<W;z++){const ee=z*D-j;Y[y]=ee*E,Y[v]=U*S,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=k>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push(z/N),f.push(1-Z/I),V+=1}}for(let Z=0;Z<I;Z++)for(let U=0;U<N;U++){const z=g+U+W*Z,ee=g+U+W*(Z+1),ae=g+(U+1)+W*(Z+1),fe=g+(U+1)+W*Z;l.push(z,ee,fe),l.push(ee,ae,fe),te+=6}o.addGroup(m,te,C),m+=te,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new eZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Em(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(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 ys(t){const e={};for(let n=0;n<t.length;n++){const r=Em(t[n]);for(const i in r)e[i]=r[i]}return e}function vNe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function tZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Tn.workingColorSpace}const yNe={clone:Em,merge:ys};var _Ne=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,wNe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let Dc=class extends eg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_Ne,this.fragmentShader=wNe,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=Em(e.uniforms),this.uniformsGroups=vNe(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}},nZ=class extends Sa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ti,this.projectionMatrix=new ti,this.projectionMatrixInverse=new ti,this.coordinateSystem=sl,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const mu=new Je,G8=new on,W8=new on;let Wa=class extends nZ{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=xP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(n1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return xP*2*Math.atan(Math.tan(n1*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,r){mu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(mu.x,mu.y).multiplyScalar(-e/mu.z),mu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(mu.x,mu.y).multiplyScalar(-e/mu.z)}getViewSize(e,n){return this.getViewBounds(e,G8,W8),n.subVectors(W8,G8)}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(n1*.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,u=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/u,i*=a.width/l,r*=a.height/u}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 lp=-90,cp=1;let SNe=class extends Sa{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Wa(lp,cp,e,n);i.layers=this.layers,this.add(i);const s=new Wa(lp,cp,e,n);s.layers=this.layers,this.add(s);const a=new Wa(lp,cp,e,n);a.layers=this.layers,this.add(a);const o=new Wa(lp,cp,e,n);o.layers=this.layers,this.add(o);const l=new Wa(lp,cp,e,n);l.layers=this.layers,this.add(l);const u=new Wa(lp,cp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const u of n)this.remove(u);if(e===sl)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===ww)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 u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=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,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},rZ=class extends Bo{constructor(e=[],n=_m,r,i,s,a,o,l,u,d){super(e,n,r,i,s,a,o,l,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},ENe=class extends Yh{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 rZ(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 ej(5,5,5),s=new Dc({name:"CubemapFromEquirect",uniforms:Em(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Gs,blending:yc});s.uniforms.tEquirect.value=n;const a=new ml(i,s),o=n.minFilter;return n.minFilter===hh&&(n.minFilter=Ja),new SNe(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)}},Tx=class extends Sa{constructor(){super(),this.isGroup=!0,this.type="Group"}};const MNe={type:"move"};let NC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Tx,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 Tx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Je,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Je),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Tx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Je,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Je),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,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){a=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),b=this._getHandJoint(u,y);v!==null&&(b.matrix.fromArray(v.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=v.radius),b.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&g>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=m-x&&(u.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(MNe)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Tx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},ANe=class extends Sa{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 cd,this.environmentIntensity=1,this.environmentRotation=new cd,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}},TNe=class extends Bo{constructor(e=null,n=1,r=1,i,s,a,o,l,u=ba,d=ba,f,g){super(null,a,o,l,u,d,i,s,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const kC=new Je,CNe=new Je,NNe=new un;let Tu=class{constructor(e=new Je(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=kC.subVectors(r,n).cross(CNe.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(kC),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||NNe.getNormalMatrix(e),i=this.coplanarPoint(kC).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const $d=new RE,kNe=new on(.5,.5),Vy=new Je;let tj=class{constructor(e=new Tu,n=new Tu,r=new Tu,i=new Tu,s=new Tu,a=new Tu){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=sl,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],u=s[3],d=s[4],f=s[5],g=s[6],m=s[7],x=s[8],y=s[9],v=s[10],b=s[11],E=s[12],S=s[13],A=s[14],T=s[15];if(i[0].setComponents(u-a,m-d,b-x,T-E).normalize(),i[1].setComponents(u+a,m+d,b+x,T+E).normalize(),i[2].setComponents(u+o,m+f,b+y,T+S).normalize(),i[3].setComponents(u-o,m-f,b-y,T-S).normalize(),r)i[4].setComponents(l,g,v,A).normalize(),i[5].setComponents(u-l,m-g,b-v,T-A).normalize();else if(i[4].setComponents(u-l,m-g,b-v,T-A).normalize(),n===sl)i[5].setComponents(u+l,m+g,b+v,T+A).normalize();else if(n===ww)i[5].setComponents(l,g,v,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),$d.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),$d.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($d)}intersectsSprite(e){$d.center.set(0,0,0);const n=kNe.distanceTo(e.center);return $d.radius=.7071067811865476+n,$d.applyMatrix4(e.matrixWorld),this.intersectsSphere($d)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Vy.x=i.normal.x>0?e.max.x:e.min.x,Vy.y=i.normal.y>0?e.max.y:e.min.y,Vy.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Vy)<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)}},iZ=class extends eg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yn(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 Ew=new Je,Mw=new Je,q8=new ti,fx=new QO,Gy=new RE,PC=new Je,K8=new Je;let PNe=class extends Sa{constructor(e=new Sl,n=new iZ){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++)Ew.fromBufferAttribute(n,i-1),Mw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Ew.distanceTo(Mw);e.setAttribute("lineDistance",new Do(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(),Gy.copy(r.boundingSphere),Gy.applyMatrix4(i),Gy.radius+=s,e.ray.intersectsSphere(Gy)===!1)return;q8.copy(i).invert(),fx.copy(e.ray).applyMatrix4(q8);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const m=Math.max(0,a.start),x=Math.min(d.count,a.start+a.count);for(let y=m,v=x-1;y<v;y+=u){const b=d.getX(y),E=d.getX(y+1),S=Wy(this,e,fx,l,b,E,y);S&&n.push(S)}if(this.isLineLoop){const y=d.getX(x-1),v=d.getX(m),b=Wy(this,e,fx,l,y,v,x-1);b&&n.push(b)}}else{const m=Math.max(0,a.start),x=Math.min(g.count,a.start+a.count);for(let y=m,v=x-1;y<v;y+=u){const b=Wy(this,e,fx,l,y,y+1,y);b&&n.push(b)}if(this.isLineLoop){const y=Wy(this,e,fx,l,x-1,m,x-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 Wy(t,e,n,r,i,s,a){const o=t.geometry.attributes.position;if(Ew.fromBufferAttribute(o,i),Mw.fromBufferAttribute(o,s),n.distanceSqToSegment(Ew,Mw,PC,K8)>r)return;PC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(PC);if(!(u<e.near||u>e.far))return{distance:u,point:K8.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const X8=new Je,Y8=new Je;let RNe=class extends PNe{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)X8.fromBufferAttribute(n,i),Y8.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+X8.distanceTo(Y8);e.setAttribute("lineDistance",new Do(r,1))}else Xt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},sZ=class extends Bo{constructor(e,n,r=Kh,i,s,a,o=ba,l=ba,u,d=I0,f=1){if(d!==I0&&d!==U0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,s,a,o,l,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ZO(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 aZ extends Bo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let nj=class oZ extends Sl{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),u=o+1,d=l+1,f=e/o,g=n/l,m=[],x=[],y=[],v=[];for(let b=0;b<d;b++){const E=b*g-a;for(let S=0;S<u;S++){const A=S*f-s;x.push(A,-E,0),y.push(0,0,1),v.push(S/o),v.push(1-b/l)}}for(let b=0;b<l;b++)for(let E=0;E<o;E++){const S=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),k=E+1+u*b;m.push(S,A,k),m.push(A,T,k)}this.setIndex(m),this.setAttribute("position",new Do(x,3)),this.setAttribute("normal",new Do(y,3)),this.setAttribute("uv",new Do(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class DNe extends eg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yn(16777215),this.specular=new yn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=zY,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 cd,this.combine=$O,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 ONe=class extends eg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=HCe,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}},jNe=class extends eg{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}},lZ=class extends Sa{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new yn(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 RC=new ti,Z8=new Je,Q8=new Je;let LNe=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=pl,this.map=null,this.mapPass=null,this.matrix=new ti,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new tj,this._frameExtents=new on(1,1),this._viewportCount=1,this._viewports=[new Kr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;Z8.setFromMatrixPosition(e.matrixWorld),n.position.copy(Z8),Q8.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(Q8),n.updateMatrixWorld(),RC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(RC,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(RC)}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}},cZ=class extends nZ{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 u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,a=s+u*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class INe extends LNe{constructor(){super(new cZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class J8 extends lZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Sa.DEFAULT_UP),this.updateMatrix(),this.target=new Sa,this.shadow=new INe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let UNe=class extends lZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},FNe=class extends Wa{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},eH=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 zNe extends RNe{constructor(e=10,n=10,r=4473924,i=8947848){r=new yn(r),i=new yn(i);const s=n/2,a=e/n,o=e/2,l=[],u=[];for(let g=0,m=0,x=-o;g<=n;g++,x+=a){l.push(-o,0,x,o,0,x),l.push(x,0,-o,x,0,o);const y=g===s?r:i;y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3}const d=new Sl;d.setAttribute("position",new Do(l,3)),d.setAttribute("color",new Do(u,3));const f=new iZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class BNe extends df{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 tH(t,e,n,r){const i=HNe(r);switch(n){case IY:return t*e;case FY:return t*e/i.components*i.byteLength;case qO:return t*e/i.components*i.byteLength;case KO:return t*e*2/i.components*i.byteLength;case XO:return t*e*2/i.components*i.byteLength;case UY:return t*e*3/i.components*i.byteLength;case No:return t*e*4/i.components*i.byteLength;case YO:return t*e*4/i.components*i.byteLength;case Q_:case J_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case e1:case t1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Vk:case Wk:return Math.max(t,16)*Math.max(e,8)/4;case $k:case Gk:return Math.max(t,8)*Math.max(e,8)/2;case qk:case Kk:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Xk:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Yk:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Zk:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case Qk:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case Jk:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case eP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case tP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case nP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case rP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case iP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case sP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case aP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case oP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case lP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case cP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case uP:case dP:case hP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case fP:case pP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case mP:case gP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function HNe(t){switch(t){case pl:case DY:return{byteLength:1,components:1};case j0:case OY:case Jm:return{byteLength:2,components:1};case GO:case WO:return{byteLength:2,components:4};case Kh:case VO:case pc:return{byteLength:4,components:1};case jY:case LY:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:HO}}));typeof window<"u"&&(window.__THREE__?Xt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=HO);function uZ(){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 $Ne(t){const e=new WeakMap;function n(o,l){const u=o.array,d=o.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(l,g),t.bufferData(l,u,d),o.onUploadCallback();let m;if(u instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)m=t.HALF_FLOAT;else if(u instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=t.SHORT;else if(u instanceof Uint32Array)m=t.UNSIGNED_INT;else if(u instanceof Int32Array)m=t.INT;else if(u instanceof Int8Array)m=t.BYTE;else if(u instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:o.version,size:f}}function r(o,l,u){const d=l.array,f=l.updateRanges;if(t.bindBuffer(u,o),f.length===0)t.bufferSubData(u,0,d);else{f.sort((m,x)=>m.start-x.start);let g=0;for(let m=1;m<f.length;m++){const x=f[g],y=f[m];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++g,f[g]=y)}f.length=g+1;for(let m=0,x=f.length;m<x;m++){const y=f[m];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(t.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const u=e.get(o);if(u===void 0)e.set(o,n(o,l));else if(u.version<o.version){if(u.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,o,l),u.version=o.version}}return{get:i,remove:s,update:a}}var VNe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,GNe=`#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`,WNe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,qNe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,KNe=`#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`,XNe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,YNe=`#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`,ZNe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,QNe=`#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`,JNe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,e3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,t3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,n3e=`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`,r3e=`#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`,i3e=`#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`,s3e=`#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`,a3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,o3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,l3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,c3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,u3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,d3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,h3e=`#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`,f3e=`#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`,p3e=`#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`,m3e=`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`,g3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,x3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,b3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,v3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,y3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",_3e=`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 );
- }`,w3e=`#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`,S3e=`#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`,E3e=`#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`,M3e=`#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`,A3e=`#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`,T3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,C3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,N3e=`#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`,k3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,P3e=`#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
- }`,R3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,D3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,O3e=`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`,j3e=`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`,L3e=`#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`,I3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,U3e=`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`,F3e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,z3e=`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`,B3e=`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`,H3e=`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 );
- }`,$3e=`
- 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`,V3e=`#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`,G3e=`#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`,W3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,q3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,K3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,X3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,Y3e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Z3e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,Q3e=`#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`,J3e=`#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`,eke=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,tke=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,nke=`#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`,rke=`#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`,ike=`#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`,ske=`#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`,ake=`#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`,oke=`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;`,lke=`#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`,cke=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,uke=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,dke=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,hke=`#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`,fke=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,pke=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,mke=`#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`,gke=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,xke=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,bke=`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 );
- }`,vke=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,yke=`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;`,_ke=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,wke=`#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`,Ske=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Eke=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Mke=`#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`,Ake=`#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`,Tke=`#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`,Cke=`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;
- }`,Nke=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,kke=`#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`,Pke=`#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`,Rke=`#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`,Dke=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,Oke=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,jke=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,Lke=`#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; }`,Ike=`#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`,Uke=`#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`,Fke=`#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`,zke=`#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`,Bke=`#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`,Hke=`#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 $ke=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Vke=`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>
- }`,Gke=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Wke=`#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>
- }`,qke=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Kke=`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>
- }`,Xke=`#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;
- }`,Yke=`#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
- }`,Zke=`#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;
- }`,Qke=`#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 );
- }`,Jke=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,ePe=`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>
- }`,tPe=`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>
- }`,nPe=`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>
- }`,rPe=`#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>
- }`,iPe=`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>
- }`,sPe=`#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>
- }`,aPe=`#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>
- }`,oPe=`#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;
- }`,lPe=`#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>
- }`,cPe=`#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
- }`,uPe=`#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
- }`,dPe=`#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>
- }`,hPe=`#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>
- }`,fPe=`#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
- }`,pPe=`#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>
- }`,mPe=`#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>
- }`,gPe=`#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>
- }`,xPe=`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>
- }`,bPe=`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>
- }`,vPe=`#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>
- }`,yPe=`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>
- }`,_Pe=`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>
- }`,wPe=`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:VNe,alphahash_pars_fragment:GNe,alphamap_fragment:WNe,alphamap_pars_fragment:qNe,alphatest_fragment:KNe,alphatest_pars_fragment:XNe,aomap_fragment:YNe,aomap_pars_fragment:ZNe,batching_pars_vertex:QNe,batching_vertex:JNe,begin_vertex:e3e,beginnormal_vertex:t3e,bsdfs:n3e,iridescence_fragment:r3e,bumpmap_pars_fragment:i3e,clipping_planes_fragment:s3e,clipping_planes_pars_fragment:a3e,clipping_planes_pars_vertex:o3e,clipping_planes_vertex:l3e,color_fragment:c3e,color_pars_fragment:u3e,color_pars_vertex:d3e,color_vertex:h3e,common:f3e,cube_uv_reflection_fragment:p3e,defaultnormal_vertex:m3e,displacementmap_pars_vertex:g3e,displacementmap_vertex:x3e,emissivemap_fragment:b3e,emissivemap_pars_fragment:v3e,colorspace_fragment:y3e,colorspace_pars_fragment:_3e,envmap_fragment:w3e,envmap_common_pars_fragment:S3e,envmap_pars_fragment:E3e,envmap_pars_vertex:M3e,envmap_physical_pars_fragment:L3e,envmap_vertex:A3e,fog_vertex:T3e,fog_pars_vertex:C3e,fog_fragment:N3e,fog_pars_fragment:k3e,gradientmap_pars_fragment:P3e,lightmap_pars_fragment:R3e,lights_lambert_fragment:D3e,lights_lambert_pars_fragment:O3e,lights_pars_begin:j3e,lights_toon_fragment:I3e,lights_toon_pars_fragment:U3e,lights_phong_fragment:F3e,lights_phong_pars_fragment:z3e,lights_physical_fragment:B3e,lights_physical_pars_fragment:H3e,lights_fragment_begin:$3e,lights_fragment_maps:V3e,lights_fragment_end:G3e,logdepthbuf_fragment:W3e,logdepthbuf_pars_fragment:q3e,logdepthbuf_pars_vertex:K3e,logdepthbuf_vertex:X3e,map_fragment:Y3e,map_pars_fragment:Z3e,map_particle_fragment:Q3e,map_particle_pars_fragment:J3e,metalnessmap_fragment:eke,metalnessmap_pars_fragment:tke,morphinstance_vertex:nke,morphcolor_vertex:rke,morphnormal_vertex:ike,morphtarget_pars_vertex:ske,morphtarget_vertex:ake,normal_fragment_begin:oke,normal_fragment_maps:lke,normal_pars_fragment:cke,normal_pars_vertex:uke,normal_vertex:dke,normalmap_pars_fragment:hke,clearcoat_normal_fragment_begin:fke,clearcoat_normal_fragment_maps:pke,clearcoat_pars_fragment:mke,iridescence_pars_fragment:gke,opaque_fragment:xke,packing:bke,premultiplied_alpha_fragment:vke,project_vertex:yke,dithering_fragment:_ke,dithering_pars_fragment:wke,roughnessmap_fragment:Ske,roughnessmap_pars_fragment:Eke,shadowmap_pars_fragment:Mke,shadowmap_pars_vertex:Ake,shadowmap_vertex:Tke,shadowmask_pars_fragment:Cke,skinbase_vertex:Nke,skinning_pars_vertex:kke,skinning_vertex:Pke,skinnormal_vertex:Rke,specularmap_fragment:Dke,specularmap_pars_fragment:Oke,tonemapping_fragment:jke,tonemapping_pars_fragment:Lke,transmission_fragment:Ike,transmission_pars_fragment:Uke,uv_pars_fragment:Fke,uv_pars_vertex:zke,uv_vertex:Bke,worldpos_vertex:Hke,background_vert:$ke,background_frag:Vke,backgroundCube_vert:Gke,backgroundCube_frag:Wke,cube_vert:qke,cube_frag:Kke,depth_vert:Xke,depth_frag:Yke,distanceRGBA_vert:Zke,distanceRGBA_frag:Qke,equirect_vert:Jke,equirect_frag:ePe,linedashed_vert:tPe,linedashed_frag:nPe,meshbasic_vert:rPe,meshbasic_frag:iPe,meshlambert_vert:sPe,meshlambert_frag:aPe,meshmatcap_vert:oPe,meshmatcap_frag:lPe,meshnormal_vert:cPe,meshnormal_frag:uPe,meshphong_vert:dPe,meshphong_frag:hPe,meshphysical_vert:fPe,meshphysical_frag:pPe,meshtoon_vert:mPe,meshtoon_frag:gPe,points_vert:xPe,points_frag:bPe,shadow_vert:vPe,shadow_frag:yPe,sprite_vert:_Pe,sprite_frag:wPe},Et={common:{diffuse:{value:new yn(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 yn(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 yn(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 yn(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}}},el={basic:{uniforms:ys([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.fog]),vertexShader:sn.meshbasic_vert,fragmentShader:sn.meshbasic_frag},lambert:{uniforms:ys([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,Et.lights,{emissive:{value:new yn(0)}}]),vertexShader:sn.meshlambert_vert,fragmentShader:sn.meshlambert_frag},phong:{uniforms:ys([Et.common,Et.specularmap,Et.envmap,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,Et.lights,{emissive:{value:new yn(0)},specular:{value:new yn(1118481)},shininess:{value:30}}]),vertexShader:sn.meshphong_vert,fragmentShader:sn.meshphong_frag},standard:{uniforms:ys([Et.common,Et.envmap,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.roughnessmap,Et.metalnessmap,Et.fog,Et.lights,{emissive:{value:new yn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:sn.meshphysical_vert,fragmentShader:sn.meshphysical_frag},toon:{uniforms:ys([Et.common,Et.aomap,Et.lightmap,Et.emissivemap,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.gradientmap,Et.fog,Et.lights,{emissive:{value:new yn(0)}}]),vertexShader:sn.meshtoon_vert,fragmentShader:sn.meshtoon_frag},matcap:{uniforms:ys([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,Et.fog,{matcap:{value:null}}]),vertexShader:sn.meshmatcap_vert,fragmentShader:sn.meshmatcap_frag},points:{uniforms:ys([Et.points,Et.fog]),vertexShader:sn.points_vert,fragmentShader:sn.points_frag},dashed:{uniforms:ys([Et.common,Et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:sn.linedashed_vert,fragmentShader:sn.linedashed_frag},depth:{uniforms:ys([Et.common,Et.displacementmap]),vertexShader:sn.depth_vert,fragmentShader:sn.depth_frag},normal:{uniforms:ys([Et.common,Et.bumpmap,Et.normalmap,Et.displacementmap,{opacity:{value:1}}]),vertexShader:sn.meshnormal_vert,fragmentShader:sn.meshnormal_frag},sprite:{uniforms:ys([Et.sprite,Et.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:ys([Et.common,Et.displacementmap,{referencePosition:{value:new Je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:sn.distanceRGBA_vert,fragmentShader:sn.distanceRGBA_frag},shadow:{uniforms:ys([Et.lights,Et.fog,{color:{value:new yn(0)},opacity:{value:1}}]),vertexShader:sn.shadow_vert,fragmentShader:sn.shadow_frag}};el.physical={uniforms:ys([el.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 yn(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 yn(0)},specularColor:{value:new yn(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 qy={r:0,b:0,g:0},Vd=new cd,SPe=new ti;function EPe(t,e,n,r,i,s,a){const o=new yn(0);let l=s===!0?0:1,u,d,f=null,g=0,m=null;function x(S){let A=S.isScene===!0?S.background:null;return A&&A.isTexture&&(A=(S.backgroundBlurriness>0?n:e).get(A)),A}function y(S){let A=!1;const T=x(S);T===null?b(o,l):T&&T.isColor&&(b(T,1),A=!0);const k=t.xr.getEnvironmentBlendMode();k==="additive"?r.buffers.color.setClear(0,0,0,1,a):k==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function v(S,A){const T=x(A);T&&(T.isCubeTexture||T.mapping===PE)?(d===void 0&&(d=new ml(new ej(1,1,1),new Dc({name:"BackgroundCubeMaterial",uniforms:Em(el.backgroundCube.uniforms),vertexShader:el.backgroundCube.vertexShader,fragmentShader:el.backgroundCube.fragmentShader,side:Gs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,N,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Vd.copy(A.backgroundRotation),Vd.x*=-1,Vd.y*=-1,Vd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Vd.y*=-1,Vd.z*=-1),d.material.uniforms.envMap.value=T,d.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(SPe.makeRotationFromEuler(Vd)),d.material.toneMapped=Tn.getTransfer(T.colorSpace)!==Wn,(f!==T||g!==T.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),d.layers.enableAll(),S.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new ml(new nj(2,2),new Dc({name:"BackgroundMaterial",uniforms:Em(el.background.uniforms),vertexShader:el.background.vertexShader,fragmentShader:el.background.fragmentShader,side:ld,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=T,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Tn.getTransfer(T.colorSpace)!==Wn,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||g!==T.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,g=T.version,m=t.toneMapping),u.layers.enableAll(),S.unshift(u,u.geometry,u.material,0,0,null))}function b(S,A){S.getRGB(qy,tZ(t)),r.buffers.color.setClear(qy.r,qy.g,qy.b,A,a)}function E(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return o},setClearColor:function(S,A=1){o.set(S),l=A,b(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(S){l=S,b(o,l)},render:y,addToRenderList:v,dispose:E}}function MPe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let s=i,a=!1;function o(D,F,j,q,R){let W=!1;const K=f(q,j,F);s!==K&&(s=K,u(s.object)),W=m(D,q,j,R),W&&x(D,q,j,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,A(D,F,j,q),R!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(R).buffer))}function l(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function f(D,F,j){const q=j.wireframe===!0;let R=r[D.id];R===void 0&&(R={},r[D.id]=R);let W=R[F.id];W===void 0&&(W={},R[F.id]=W);let K=W[q];return K===void 0&&(K=g(l()),W[q]=K),K}function g(D){const F=[],j=[],q=[];for(let R=0;R<n;R++)F[R]=0,j[R]=0,q[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:j,attributeDivisors:q,object:D,attributes:{},index:null}}function m(D,F,j,q){const R=s.attributes,W=F.attributes;let K=0;const V=j.getAttributes();for(const te in V)if(V[te].location>=0){const Z=R[te];let U=W[te];if(U===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(U=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(U=D.instanceColor)),Z===void 0||Z.attribute!==U||U&&Z.data!==U.data)return!0;K++}return s.attributesNum!==K||s.index!==q}function x(D,F,j,q){const R={},W=F.attributes;let K=0;const V=j.getAttributes();for(const te in V)if(V[te].location>=0){let Z=W[te];Z===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor));const U={};U.attribute=Z,Z&&Z.data&&(U.data=Z.data),R[te]=U,K++}s.attributes=R,s.attributesNum=K,s.index=q}function y(){const D=s.newAttributes;for(let F=0,j=D.length;F<j;F++)D[F]=0}function v(D){b(D,0)}function b(D,F){const j=s.newAttributes,q=s.enabledAttributes,R=s.attributeDivisors;j[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),R[D]!==F&&(t.vertexAttribDivisor(D,F),R[D]=F)}function E(){const D=s.newAttributes,F=s.enabledAttributes;for(let j=0,q=F.length;j<q;j++)F[j]!==D[j]&&(t.disableVertexAttribArray(j),F[j]=0)}function S(D,F,j,q,R,W,K){K===!0?t.vertexAttribIPointer(D,F,j,R,W):t.vertexAttribPointer(D,F,j,q,R,W)}function A(D,F,j,q){y();const R=q.attributes,W=j.getAttributes(),K=F.defaultAttributeValues;for(const V in W){const te=W[V];if(te.location>=0){let Y=R[V];if(Y===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(Y=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(Y=D.instanceColor)),Y!==void 0){const Z=Y.normalized,U=Y.itemSize,z=e.get(Y);if(z===void 0)continue;const ee=z.buffer,ae=z.type,fe=z.bytesPerElement,de=ae===t.INT||ae===t.UNSIGNED_INT||Y.gpuType===VO;if(Y.isInterleavedBufferAttribute){const xe=Y.data,ye=xe.stride,re=Y.offset;if(xe.isInstancedInterleavedBuffer){for(let ve=0;ve<te.locationSize;ve++)b(te.location+ve,xe.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let ve=0;ve<te.locationSize;ve++)v(te.location+ve);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let ve=0;ve<te.locationSize;ve++)S(te.location+ve,U/te.locationSize,ae,Z,ye*fe,(re+U/te.locationSize*ve)*fe,de)}else{if(Y.isInstancedBufferAttribute){for(let xe=0;xe<te.locationSize;xe++)b(te.location+xe,Y.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let xe=0;xe<te.locationSize;xe++)v(te.location+xe);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let xe=0;xe<te.locationSize;xe++)S(te.location+xe,U/te.locationSize,ae,Z,U*fe,U/te.locationSize*xe*fe,de)}}else if(K!==void 0){const Z=K[V];if(Z!==void 0)switch(Z.length){case 2:t.vertexAttrib2fv(te.location,Z);break;case 3:t.vertexAttrib3fv(te.location,Z);break;case 4:t.vertexAttrib4fv(te.location,Z);break;default:t.vertexAttrib1fv(te.location,Z)}}}}E()}function T(){I();for(const D in r){const F=r[D];for(const j in F){const q=F[j];for(const R in q)d(q[R].object),delete q[R];delete F[j]}delete r[D]}}function k(D){if(r[D.id]===void 0)return;const F=r[D.id];for(const j in F){const q=F[j];for(const R in q)d(q[R].object),delete q[R];delete F[j]}delete r[D.id]}function N(D){for(const F in r){const j=r[F];if(j[D.id]===void 0)continue;const q=j[D.id];for(const R in q)d(q[R].object),delete q[R];delete j[D.id]}}function I(){C(),a=!0,s!==i&&(s=i,u(s.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:I,resetDefaultState:C,dispose:T,releaseStatesOfGeometry:k,releaseStatesOfProgram:N,initAttributes:y,enableAttribute:v,disableUnusedAttributes:E}}function APe(t,e,n){let r;function i(u){r=u}function s(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function a(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function o(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let m=0;for(let x=0;x<f;x++)m+=d[x];n.update(m,r,1)}function l(u,d,f,g){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<u.length;x++)a(u[x],d[x],g[x]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let y=0;y<f;y++)x+=d[y]*g[y];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function TPe(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(N){return!(N!==No&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(N){const I=N===Jm&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==pl&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==pc&&!I)}function l(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=l(u);d!==u&&(Xt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),S=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=x>0,k=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:m,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:v,maxAttributes:b,maxVertexUniforms:E,maxVaryings:S,maxFragmentUniforms:A,vertexTextures:T,maxSamples:k}}function CPe(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new Tu,o=new un,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const x=f.clippingPlanes,y=f.clipIntersection,v=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||s&&!v)s?d(null):u();else{const E=s?0:r,S=E*4;let A=b.clippingState||null;l.value=A,A=d(x,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,m,x){const y=f!==null?f.length:0;let v=null;if(y!==0){if(v=l.value,x!==!0||v===null){const b=m+y*4,E=g.matrixWorldInverse;o.getNormalMatrix(E),(v===null||v.length<b)&&(v=new Float32Array(b));for(let S=0,A=m;S!==y;++S,A+=4)a.copy(f[S]).applyMatrix4(E,o),a.normal.toArray(v,A),v[A+3]=a.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function NPe(t){let e=new WeakMap;function n(a,o){return o===Fk?a.mapping=_m:o===zk&&(a.mapping=wm),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===Fk||o===zk)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 u=new ENe(l.height);return u.fromEquirectangularTexture(t,a),e.set(a,u),a.addEventListener("dispose",i),n(u.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 Uu=4,nH=[.125,.215,.35,.446,.526,.582],rh=20,kPe=256,px=new cZ,rH=new yn;let DC=null,OC=0,jC=0,LC=!1;const PPe=new Je;let iH=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=PPe}=s;DC=this._renderer.getRenderTarget(),OC=this._renderer.getActiveCubeFace(),jC=this._renderer.getActiveMipmapLevel(),LC=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=oH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=aH(),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(DC,OC,jC),this._renderer.xr.enabled=LC,e.scissorTest=!1,up(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===_m||e.mapping===wm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),DC=this._renderer.getRenderTarget(),OC=this._renderer.getActiveCubeFace(),jC=this._renderer.getActiveMipmapLevel(),LC=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:Ja,minFilter:Ja,generateMipmaps:!1,type:Jm,format:No,colorSpace:Sm,depthBuffer:!1},i=sH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=sH(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=RPe(s)),this._blurMaterial=OPe(s,e,n),this._ggxMaterial=DPe(s,e,n)}return i}_compileMaterial(e){const n=new ml(new Sl,e);this._renderer.compile(n,px)}_sceneToCubeUV(e,n,r,i,s){const l=new Wa(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,g=f.autoClear,m=f.toneMapping;f.getClearColor(rH),f.toneMapping=Wu,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new ml(new ej,new JO({name:"PMREM.Background",side:Gs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,v=y.material;let b=!1;const E=e.background;E?E.isColor&&(v.color.copy(E),e.background=null,b=!0):(v.color.copy(rH),b=!0);for(let S=0;S<6;S++){const A=S%3;A===0?(l.up.set(0,u[S],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+d[S],s.y,s.z)):A===1?(l.up.set(0,0,u[S]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+d[S],s.z)):(l.up.set(0,u[S],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+d[S]));const T=this._cubeSize;up(i,A*T,S>2?T:0,T,T),f.setRenderTarget(i),b&&f.render(y,l),f.render(e,l)}f.toneMapping=m,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===_m||e.mapping===wm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=oH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=aH());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;up(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,px)}_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,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,m=f*g,{_lodMax:x}=this,y=this._sizeLods[r],v=3*y*(r>x-Uu?r-x+Uu:0),b=4*(this._cubeSize-y);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=x-n,up(s,v,b,3*y,2*y),i.setRenderTarget(s),i.render(o,px),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=x-r,up(e,v,b,3*y,2*y),i.setRenderTarget(e),i.render(o,px)}_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,u=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Ur("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const g=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*rh-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):rh;v>rh&&Xt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${rh}`);const b=[];let E=0;for(let N=0;N<rh;++N){const I=N/y,C=Math.exp(-I*I/2);b.push(C),N===0?E+=C:N<v&&(E+=2*C)}for(let N=0;N<b.length;N++)b[N]=b[N]/E;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=b,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=x,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-Uu?i-S+Uu:0),k=4*(this._cubeSize-A);up(n,T,k,3*A,2*A),l.setRenderTarget(n),l.render(f,px)}};function RPe(t){const e=[],n=[],r=[];let i=t;const s=t-Uu+1+nH.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>t-Uu?l=nH[a-t+Uu-1]:a===0&&(l=0),n.push(l);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,y=3,v=2,b=1,E=new Float32Array(y*x*m),S=new Float32Array(v*x*m),A=new Float32Array(b*x*m);for(let k=0;k<m;k++){const N=k%3*2/3-1,I=k>2?0:-1,C=[N,I,0,N+2/3,I,0,N+2/3,I+1,0,N,I,0,N+2/3,I+1,0,N,I+1,0];E.set(C,y*x*k),S.set(g,v*x*k);const D=[k,k,k,k,k,k];A.set(D,b*x*k)}const T=new Sl;T.setAttribute("position",new eo(E,y)),T.setAttribute("uv",new eo(S,v)),T.setAttribute("faceIndex",new eo(A,b)),r.push(new ml(T,null)),i>Uu&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function sH(t,e,n){const r=new Yh(t,e,n);return r.texture.mapping=PE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function up(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function DPe(t,e,n){return new Dc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:kPe,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:DE(),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:yc,depthTest:!1,depthWrite:!1})}function OPe(t,e,n){const r=new Float32Array(rh),i=new Je(0,1,0);return new Dc({name:"SphericalGaussianBlur",defines:{n:rh,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:DE(),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:yc,depthTest:!1,depthWrite:!1})}function aH(){return new Dc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:DE(),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:yc,depthTest:!1,depthWrite:!1})}function oH(){return new Dc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:DE(),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:yc,depthTest:!1,depthWrite:!1})}function DE(){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 jPe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,u=l===Fk||l===zk,d=l===_m||l===wm;if(u||d){let f=e.get(o);const g=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==g)return n===null&&(n=new iH(t)),f=u?n.fromEquirectangular(o,f):n.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const m=o.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new iH(t)),f=u?n.fromEquirectangular(o):n.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",s),f.texture):null}}}return o}function i(o){let l=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&l++;return l===u}function s(o){const l=o.target;l.removeEventListener("dispose",s);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function LPe(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&&F0("WebGLRenderer: "+r+" extension not supported."),i}}}function IPe(t,e,n,r){const i={},s=new WeakMap;function a(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",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(f,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(f){const g=f.attributes;for(const m in g)e.update(g[m],t.ARRAY_BUFFER)}function u(f){const g=[],m=f.index,x=f.attributes.position;let y=0;if(m!==null){const E=m.array;y=m.version;for(let S=0,A=E.length;S<A;S+=3){const T=E[S+0],k=E[S+1],N=E[S+2];g.push(T,k,k,N,N,T)}}else if(x!==void 0){const E=x.array;y=x.version;for(let S=0,A=E.length/3-1;S<A;S+=3){const T=S+0,k=S+1,N=S+2;g.push(T,k,k,N,N,T)}}else return;const v=new(HY(g)?QY:ZY)(g,1);v.version=y;const b=s.get(f);b&&e.remove(b),s.set(f,v)}function d(f){const g=s.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return s.get(f)}return{get:o,update:l,getWireframeAttribute:d}}function UPe(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 u(g,m,x){x!==0&&(t.drawElementsInstanced(r,m,s,g*a,x),n.update(m,r,x))}function d(g,m,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,s,g,0,x);let v=0;for(let b=0;b<x;b++)v+=m[b];n.update(v,r,1)}function f(g,m,x,y){if(x===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let b=0;b<g.length;b++)u(g[b]/a,m[b],y[b]);else{v.multiDrawElementsInstancedWEBGL(r,m,0,s,g,0,y,0,x);let b=0;for(let E=0;E<x;E++)b+=m[E]*y[E];n.update(b,r,1)}}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function FPe(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:Ur("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 zPe(t,e,n){const r=new WeakMap,i=new Kr;function s(a,o,l){const u=a.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(o);if(g===void 0||g.count!==f){let D=function(){I.dispose(),r.delete(o),o.removeEventListener("dispose",D)};var m=D;g!==void 0&&g.texture.dispose();const x=o.morphAttributes.position!==void 0,y=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,b=o.morphAttributes.position||[],E=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let A=0;x===!0&&(A=1),y===!0&&(A=2),v===!0&&(A=3);let T=o.attributes.position.count*A,k=1;T>e.maxTextureSize&&(k=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const N=new Float32Array(T*k*4*f),I=new qY(N,T,k,f);I.type=pc,I.needsUpdate=!0;const C=A*4;for(let F=0;F<f;F++){const j=b[F],q=E[F],R=S[F],W=T*k*4*F;for(let K=0;K<j.count;K++){const V=K*C;x===!0&&(i.fromBufferAttribute(j,K),N[W+V+0]=i.x,N[W+V+1]=i.y,N[W+V+2]=i.z,N[W+V+3]=0),y===!0&&(i.fromBufferAttribute(q,K),N[W+V+4]=i.x,N[W+V+5]=i.y,N[W+V+6]=i.z,N[W+V+7]=0),v===!0&&(i.fromBufferAttribute(R,K),N[W+V+8]=i.x,N[W+V+9]=i.y,N[W+V+10]=i.z,N[W+V+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:I,size:new on(T,k)},r.set(o,g),o.addEventListener("dispose",D)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",a.morphTexture,n);else{let x=0;for(let v=0;v<u.length;v++)x+=u[v];const y=o.morphTargetsRelative?1:1-x;l.getUniforms().setValue(t,"morphTargetBaseInfluence",y),l.getUniforms().setValue(t,"morphTargetInfluences",u)}l.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:s}}function BPe(t,e,n,r){let i=new WeakMap;function s(l){const u=r.render.frame,d=l.geometry,f=e.get(l,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==u&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,u))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function a(){i=new WeakMap}function o(l){const u=l.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:a}}const dZ=new Bo,lH=new sZ(1,1),hZ=new qY,fZ=new oNe,pZ=new rZ,cH=[],uH=[],dH=new Float32Array(16),hH=new Float32Array(9),fH=new Float32Array(4);function tg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=cH[i];if(s===void 0&&(s=new Float32Array(i),cH[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 hi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function fi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function OE(t,e){let n=uH[e];n===void 0&&(n=new Int32Array(e),uH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function HPe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $Pe(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(hi(n,e))return;t.uniform2fv(this.addr,e),fi(n,e)}}function VPe(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(hi(n,e))return;t.uniform3fv(this.addr,e),fi(n,e)}}function GPe(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(hi(n,e))return;t.uniform4fv(this.addr,e),fi(n,e)}}function WPe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(hi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),fi(n,e)}else{if(hi(n,r))return;fH.set(r),t.uniformMatrix2fv(this.addr,!1,fH),fi(n,r)}}function qPe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(hi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),fi(n,e)}else{if(hi(n,r))return;hH.set(r),t.uniformMatrix3fv(this.addr,!1,hH),fi(n,r)}}function KPe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(hi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),fi(n,e)}else{if(hi(n,r))return;dH.set(r),t.uniformMatrix4fv(this.addr,!1,dH),fi(n,r)}}function XPe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function YPe(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(hi(n,e))return;t.uniform2iv(this.addr,e),fi(n,e)}}function ZPe(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(hi(n,e))return;t.uniform3iv(this.addr,e),fi(n,e)}}function QPe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.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(hi(n,e))return;t.uniform4iv(this.addr,e),fi(n,e)}}function JPe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function eRe(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(hi(n,e))return;t.uniform2uiv(this.addr,e),fi(n,e)}}function tRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(hi(n,e))return;t.uniform3uiv(this.addr,e),fi(n,e)}}function nRe(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(hi(n,e))return;t.uniform4uiv(this.addr,e),fi(n,e)}}function rRe(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?(lH.compareFunction=BY,s=lH):s=dZ,n.setTexture2D(e||s,i)}function iRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||fZ,i)}function sRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||pZ,i)}function aRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||hZ,i)}function oRe(t){switch(t){case 5126:return HPe;case 35664:return $Pe;case 35665:return VPe;case 35666:return GPe;case 35674:return WPe;case 35675:return qPe;case 35676:return KPe;case 5124:case 35670:return XPe;case 35667:case 35671:return YPe;case 35668:case 35672:return ZPe;case 35669:case 35673:return QPe;case 5125:return JPe;case 36294:return eRe;case 36295:return tRe;case 36296:return nRe;case 35678:case 36198:case 36298:case 36306:case 35682:return rRe;case 35679:case 36299:case 36307:return iRe;case 35680:case 36300:case 36308:case 36293:return sRe;case 36289:case 36303:case 36311:case 36292:return aRe}}function lRe(t,e){t.uniform1fv(this.addr,e)}function cRe(t,e){const n=tg(e,this.size,2);t.uniform2fv(this.addr,n)}function uRe(t,e){const n=tg(e,this.size,3);t.uniform3fv(this.addr,n)}function dRe(t,e){const n=tg(e,this.size,4);t.uniform4fv(this.addr,n)}function hRe(t,e){const n=tg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function fRe(t,e){const n=tg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function pRe(t,e){const n=tg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function mRe(t,e){t.uniform1iv(this.addr,e)}function gRe(t,e){t.uniform2iv(this.addr,e)}function xRe(t,e){t.uniform3iv(this.addr,e)}function bRe(t,e){t.uniform4iv(this.addr,e)}function vRe(t,e){t.uniform1uiv(this.addr,e)}function yRe(t,e){t.uniform2uiv(this.addr,e)}function _Re(t,e){t.uniform3uiv(this.addr,e)}function wRe(t,e){t.uniform4uiv(this.addr,e)}function SRe(t,e,n){const r=this.cache,i=e.length,s=OE(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||dZ,s[a])}function ERe(t,e,n){const r=this.cache,i=e.length,s=OE(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||fZ,s[a])}function MRe(t,e,n){const r=this.cache,i=e.length,s=OE(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||pZ,s[a])}function ARe(t,e,n){const r=this.cache,i=e.length,s=OE(n,i);hi(r,s)||(t.uniform1iv(this.addr,s),fi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||hZ,s[a])}function TRe(t){switch(t){case 5126:return lRe;case 35664:return cRe;case 35665:return uRe;case 35666:return dRe;case 35674:return hRe;case 35675:return fRe;case 35676:return pRe;case 5124:case 35670:return mRe;case 35667:case 35671:return gRe;case 35668:case 35672:return xRe;case 35669:case 35673:return bRe;case 5125:return vRe;case 36294:return yRe;case 36295:return _Re;case 36296:return wRe;case 35678:case 36198:case 36298:case 36306:case 35682:return SRe;case 35679:case 36299:case 36307:return ERe;case 35680:case 36300:case 36308:case 36293:return MRe;case 36289:case 36303:case 36311:case 36292:return ARe}}let CRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=oRe(n.type)}},NRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=TRe(n.type)}},kRe=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 IC=/(\w+)(\])?(\[|\.)?/g;function pH(t,e){t.seq.push(e),t.map[e.id]=e}function PRe(t,e,n){const r=t.name,i=r.length;for(IC.lastIndex=0;;){const s=IC.exec(r),a=IC.lastIndex;let o=s[1];const l=s[2]==="]",u=s[3];if(l&&(o=o|0),u===void 0||u==="["&&a+2===i){pH(n,u===void 0?new CRe(o,t,e):new NRe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new kRe(o),pH(n,f)),n=f}}}let s1=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);PRe(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 mH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const RRe=37297;let DRe=0;function ORe(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 gH=new un;function jRe(t){Tn._getMatrix(gH,Tn.workingColorSpace,t);const e=`mat3( ${gH.elements.map(n=>n.toFixed(4))} )`;switch(Tn.getTransfer(t)){case _w:return[e,"LinearTransferOETF"];case Wn:return[e,"sRGBTransferOETF"];default:return Xt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function xH(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+`
- `+ORe(t.getShaderSource(e),o)}else return s}function LRe(t,e){const n=jRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function IRe(t,e){let n;switch(e){case OCe:n="Linear";break;case jCe:n="Reinhard";break;case LCe:n="Cineon";break;case ICe:n="ACESFilmic";break;case FCe:n="AgX";break;case zCe:n="Neutral";break;case UCe:n="Custom";break;default:Xt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Ky=new Je;function URe(){Tn.getLuminanceCoefficients(Ky);const t=Ky.x.toFixed(4),e=Ky.y.toFixed(4),n=Ky.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function FRe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cx).join(`
- `)}function zRe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function BRe(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 Cx(t){return t!==""}function bH(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 vH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const HRe=/^[ \t]*#include +<([\w\d./]+)>/gm;function vP(t){return t.replace(HRe,VRe)}const $Re=new Map;function VRe(t,e){let n=sn[e];if(n===void 0){const r=$Re.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 vP(n)}const GRe=/#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 yH(t){return t.replace(GRe,WRe)}function WRe(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 _H(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 qRe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===PY?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===fCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===nc&&(e="SHADOWMAP_TYPE_VSM"),e}function KRe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case _m:case wm:e="ENVMAP_TYPE_CUBE";break;case PE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function XRe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case wm:e="ENVMAP_MODE_REFRACTION";break}return e}function YRe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case $O:e="ENVMAP_BLENDING_MULTIPLY";break;case RCe:e="ENVMAP_BLENDING_MIX";break;case DCe:e="ENVMAP_BLENDING_ADD";break}return e}function ZRe(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 QRe(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=qRe(n),u=KRe(n),d=XRe(n),f=YRe(n),g=ZRe(n),m=FRe(n),x=zRe(s),y=i.createProgram();let v,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Cx).join(`
- `),v.length>0&&(v+=`
- `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Cx).join(`
- `),b.length>0&&(b+=`
- `)):(v=[_H(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+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(Cx).join(`
- `),b=[_H(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+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!==Wu?"#define TONE_MAPPING":"",n.toneMapping!==Wu?sn.tonemapping_pars_fragment:"",n.toneMapping!==Wu?IRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",sn.colorspace_pars_fragment,LRe("linearToOutputTexel",n.outputColorSpace),URe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Cx).join(`
- `)),a=vP(a),a=bH(a,n),a=vH(a,n),o=vP(o),o=bH(o,n),o=vH(o,n),a=yH(a),o=yH(o),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,b=["#define varying in",n.glslVersion===C8?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===C8?"":"#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(`
- `)+`
- `+b);const S=E+v+a,A=E+b+o,T=mH(i,i.VERTEX_SHADER,S),k=mH(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function N(F){if(t.debug.checkShaderErrors){const j=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(k)||"",W=j.trim(),K=q.trim(),V=R.trim();let te=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(te=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const Z=xH(i,T,"vertex"),U=xH(i,k,"fragment");Ur("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: `+W+`
- `+Z+`
- `+U)}else W!==""?Xt("WebGLProgram: Program Info Log:",W):(K===""||V==="")&&(Y=!1);Y&&(F.diagnostics={runnable:te,programLog:W,vertexShader:{log:K,prefix:v},fragmentShader:{log:V,prefix:b}})}i.deleteShader(T),i.deleteShader(k),I=new s1(i,y),C=BRe(i,y)}let I;this.getUniforms=function(){return I===void 0&&N(this),I};let C;this.getAttributes=function(){return C===void 0&&N(this),C};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,RRe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=DRe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let JRe=0,eDe=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 tDe(e),n.set(e,r)),r}},tDe=class{constructor(e){this.id=JRe++,this.code=e,this.usedTimes=0}};function nDe(t,e,n,r,i,s,a){const o=new XY,l=new eDe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return u.add(C),C===0?"uv":`uv${C}`}function v(C,D,F,j,q){const R=j.fog,W=q.geometry,K=C.isMeshStandardMaterial?j.environment:null,V=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),te=V&&V.mapping===PE?V.image.height:null,Y=x[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&Xt("WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Z=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Z!==void 0?Z.length:0;let z=0;W.morphAttributes.position!==void 0&&(z=1),W.morphAttributes.normal!==void 0&&(z=2),W.morphAttributes.color!==void 0&&(z=3);let ee,ae,fe,de;if(Y){const Ot=el[Y];ee=Ot.vertexShader,ae=Ot.fragmentShader}else ee=C.vertexShader,ae=C.fragmentShader,l.update(C),fe=l.getVertexShaderID(C),de=l.getFragmentShaderID(C);const xe=t.getRenderTarget(),ye=t.state.buffers.depth.getReversed(),re=q.isInstancedMesh===!0,ve=q.isBatchedMesh===!0,je=!!C.map,ue=!!C.matcap,ut=!!V,$=!!C.aoMap,H=!!C.lightMap,ie=!!C.bumpMap,G=!!C.normalMap,J=!!C.displacementMap,le=!!C.emissiveMap,ke=!!C.metalnessMap,Ne=!!C.roughnessMap,Se=C.anisotropy>0,B=C.clearcoat>0,L=C.dispersion>0,ne=C.iridescence>0,be=C.sheen>0,we=C.transmission>0,ge=Se&&!!C.anisotropyMap,me=B&&!!C.clearcoatMap,Ae=B&&!!C.clearcoatNormalMap,ze=B&&!!C.clearcoatRoughnessMap,st=ne&&!!C.iridescenceMap,Ve=ne&&!!C.iridescenceThicknessMap,ce=be&&!!C.sheenColorMap,Ye=be&&!!C.sheenRoughnessMap,$e=!!C.specularMap,Ze=!!C.specularColorMap,at=!!C.specularIntensityMap,Q=we&&!!C.transmissionMap,Fe=we&&!!C.thicknessMap,pe=!!C.gradientMap,Ue=!!C.alphaMap,Ce=C.alphaTest>0,_e=!!C.alphaHash,He=!!C.extensions;let ht=Wu;C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(ht=t.toneMapping);const wt={shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:ee,fragmentShader:ae,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:de,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:ve,batchingColor:ve&&q._colorsTexture!==null,instancing:re,instancingColor:re&&q.instanceColor!==null,instancingMorph:re&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Sm,alphaToCoverage:!!C.alphaToCoverage,map:je,matcap:ue,envMap:ut,envMapMode:ut&&V.mapping,envMapCubeUVHeight:te,aoMap:$,lightMap:H,bumpMap:ie,normalMap:G,displacementMap:g&&J,emissiveMap:le,normalMapObjectSpace:G&&C.normalMapType===VCe,normalMapTangentSpace:G&&C.normalMapType===zY,metalnessMap:ke,roughnessMap:Ne,anisotropy:Se,anisotropyMap:ge,clearcoat:B,clearcoatMap:me,clearcoatNormalMap:Ae,clearcoatRoughnessMap:ze,dispersion:L,iridescence:ne,iridescenceMap:st,iridescenceThicknessMap:Ve,sheen:be,sheenColorMap:ce,sheenRoughnessMap:Ye,specularMap:$e,specularColorMap:Ze,specularIntensityMap:at,transmission:we,transmissionMap:Q,thicknessMap:Fe,gradientMap:pe,opaque:C.transparent===!1&&C.blending===Jp&&C.alphaToCoverage===!1,alphaMap:Ue,alphaTest:Ce,alphaHash:_e,combine:C.combine,mapUv:je&&y(C.map.channel),aoMapUv:$&&y(C.aoMap.channel),lightMapUv:H&&y(C.lightMap.channel),bumpMapUv:ie&&y(C.bumpMap.channel),normalMapUv:G&&y(C.normalMap.channel),displacementMapUv:J&&y(C.displacementMap.channel),emissiveMapUv:le&&y(C.emissiveMap.channel),metalnessMapUv:ke&&y(C.metalnessMap.channel),roughnessMapUv:Ne&&y(C.roughnessMap.channel),anisotropyMapUv:ge&&y(C.anisotropyMap.channel),clearcoatMapUv:me&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:Ae&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ze&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ve&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Ye&&y(C.sheenRoughnessMap.channel),specularMapUv:$e&&y(C.specularMap.channel),specularColorMapUv:Ze&&y(C.specularColorMap.channel),specularIntensityMapUv:at&&y(C.specularIntensityMap.channel),transmissionMapUv:Q&&y(C.transmissionMap.channel),thicknessMapUv:Fe&&y(C.thicknessMap.channel),alphaMapUv:Ue&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(G||Se),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(je||Ue),fog:!!R,useFog:C.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:ye,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:z,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:ht,decodeVideoTexture:je&&C.map.isVideoTexture===!0&&Tn.getTransfer(C.map.colorSpace)===Wn,decodeVideoTextureEmissive:le&&C.emissiveMap.isVideoTexture===!0&&Tn.getTransfer(C.emissiveMap.colorSpace)===Wn,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===tl,flipSided:C.side===Gs,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:He&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(He&&C.extensions.multiDraw===!0||ve)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return wt.vertexUv1s=u.has(1),wt.vertexUv2s=u.has(2),wt.vertexUv3s=u.has(3),u.clear(),wt}function b(C){const D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)D.push(F),D.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(E(D,C),S(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function E(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function S(C,D){o.disableAll(),D.supportsVertexTextures&&o.enable(0),D.instancing&&o.enable(1),D.instancingColor&&o.enable(2),D.instancingMorph&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),D.dispersion&&o.enable(20),D.batchingColor&&o.enable(21),D.gradientMap&&o.enable(22),C.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.reversedDepthBuffer&&o.enable(4),D.skinning&&o.enable(5),D.morphTargets&&o.enable(6),D.morphNormals&&o.enable(7),D.morphColors&&o.enable(8),D.premultipliedAlpha&&o.enable(9),D.shadowMapEnabled&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),D.decodeVideoTextureEmissive&&o.enable(20),D.alphaToCoverage&&o.enable(21),C.push(o.mask)}function A(C){const D=x[C.type];let F;if(D){const j=el[D];F=yNe.clone(j.uniforms)}else F=C.uniforms;return F}function T(C,D){let F;for(let j=0,q=d.length;j<q;j++){const R=d[j];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new QRe(t,D,C,s),d.push(F)),F}function k(C){if(--C.usedTimes===0){const D=d.indexOf(C);d[D]=d[d.length-1],d.pop(),C.destroy()}}function N(C){l.remove(C)}function I(){l.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:d,dispose:I}}function rDe(){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 iDe(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 wH(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 SH(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(f,g,m,x,y,v){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:m,groupOrder:x,renderOrder:f.renderOrder,z:y,group:v},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=m,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=y,b.group=v),e++,b}function o(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function l(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.unshift(b):m.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||iDe),r.length>1&&r.sort(g||wH),i.length>1&&i.sort(g||wH)}function d(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:d,sort:u}}function sDe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new SH,t.set(r,[a])):i>=s.length?(a=new SH,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function aDe(){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 Je,color:new yn};break;case"SpotLight":n={position:new Je,direction:new Je,color:new yn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Je,color:new yn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Je,skyColor:new yn,groundColor:new yn};break;case"RectAreaLight":n={color:new yn,position:new Je,halfWidth:new Je,halfHeight:new Je};break}return t[e.id]=n,n}}}function oDe(){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 lDe=0;function cDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function uDe(t){const e=new aDe,n=oDe(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new Je);const i=new Je,s=new ti,a=new ti;function o(u){let d=0,f=0,g=0;for(let C=0;C<9;C++)r.probe[C].set(0,0,0);let m=0,x=0,y=0,v=0,b=0,E=0,S=0,A=0,T=0,k=0,N=0;u.sort(cDe);for(let C=0,D=u.length;C<D;C++){const F=u[C],j=F.color,q=F.intensity,R=F.distance,W=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)d+=j.r*q,f+=j.g*q,g+=j.b*q;else if(F.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(F.sh.coefficients[K],q);N++}else if(F.isDirectionalLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const V=F.shadow,te=n.get(F);te.shadowIntensity=V.intensity,te.shadowBias=V.bias,te.shadowNormalBias=V.normalBias,te.shadowRadius=V.radius,te.shadowMapSize=V.mapSize,r.directionalShadow[m]=te,r.directionalShadowMap[m]=W,r.directionalShadowMatrix[m]=F.shadow.matrix,E++}r.directional[m]=K,m++}else if(F.isSpotLight){const K=e.get(F);K.position.setFromMatrixPosition(F.matrixWorld),K.color.copy(j).multiplyScalar(q),K.distance=R,K.coneCos=Math.cos(F.angle),K.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),K.decay=F.decay,r.spot[y]=K;const V=F.shadow;if(F.map&&(r.spotLightMap[T]=F.map,T++,V.updateMatrices(F),F.castShadow&&k++),r.spotLightMatrix[y]=V.matrix,F.castShadow){const te=n.get(F);te.shadowIntensity=V.intensity,te.shadowBias=V.bias,te.shadowNormalBias=V.normalBias,te.shadowRadius=V.radius,te.shadowMapSize=V.mapSize,r.spotShadow[y]=te,r.spotShadowMap[y]=W,A++}y++}else if(F.isRectAreaLight){const K=e.get(F);K.color.copy(j).multiplyScalar(q),K.halfWidth.set(F.width*.5,0,0),K.halfHeight.set(0,F.height*.5,0),r.rectArea[v]=K,v++}else if(F.isPointLight){const K=e.get(F);if(K.color.copy(F.color).multiplyScalar(F.intensity),K.distance=F.distance,K.decay=F.decay,F.castShadow){const V=F.shadow,te=n.get(F);te.shadowIntensity=V.intensity,te.shadowBias=V.bias,te.shadowNormalBias=V.normalBias,te.shadowRadius=V.radius,te.shadowMapSize=V.mapSize,te.shadowCameraNear=V.camera.near,te.shadowCameraFar=V.camera.far,r.pointShadow[x]=te,r.pointShadowMap[x]=W,r.pointShadowMatrix[x]=F.shadow.matrix,S++}r.point[x]=K,x++}else if(F.isHemisphereLight){const K=e.get(F);K.skyColor.copy(F.color).multiplyScalar(q),K.groundColor.copy(F.groundColor).multiplyScalar(q),r.hemi[b]=K,b++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Et.LTC_FLOAT_1,r.rectAreaLTC2=Et.LTC_FLOAT_2):(r.rectAreaLTC1=Et.LTC_HALF_1,r.rectAreaLTC2=Et.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const I=r.hash;(I.directionalLength!==m||I.pointLength!==x||I.spotLength!==y||I.rectAreaLength!==v||I.hemiLength!==b||I.numDirectionalShadows!==E||I.numPointShadows!==S||I.numSpotShadows!==A||I.numSpotMaps!==T||I.numLightProbes!==N)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=v,r.point.length=x,r.hemi.length=b,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=S,r.pointShadowMap.length=S,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=S,r.spotLightMatrix.length=A+T-k,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=k,r.numLightProbes=N,I.directionalLength=m,I.pointLength=x,I.spotLength=y,I.rectAreaLength=v,I.hemiLength=b,I.numDirectionalShadows=E,I.numPointShadows=S,I.numSpotShadows=A,I.numSpotMaps=T,I.numLightProbes=N,r.version=lDe++)}function l(u,d){let f=0,g=0,m=0,x=0,y=0;const v=d.matrixWorldInverse;for(let b=0,E=u.length;b<E;b++){const S=u[b];if(S.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(v),f++}else if(S.isSpotLight){const A=r.spot[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(S.matrixWorld),i.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(v),m++}else if(S.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),a.identity(),s.copy(S.matrixWorld),s.premultiply(v),a.extractRotation(s),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(a),A.halfHeight.applyMatrix4(a),x++}else if(S.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),g++}else if(S.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(v),y++}}}return{setup:o,setupView:l,state:r}}function EH(t){const e=new uDe(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function s(d){n.push(d)}function a(d){r.push(d)}function o(){e.setup(n)}function l(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function dDe(t){let e=new WeakMap;function n(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new EH(t),e.set(i,[o])):s>=a.length?(o=new EH(t),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const hDe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,fDe=`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 pDe(t,e,n){let r=new tj;const i=new on,s=new on,a=new Kr,o=new ONe({depthPacking:$Ce}),l=new jNe,u={},d=n.maxTextureSize,f={[ld]:Gs,[Gs]:ld,[tl]:tl},g=new Dc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new on},radius:{value:4}},vertexShader:hDe,fragmentShader:fDe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new Sl;x.setAttribute("position",new eo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new ml(x,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=PY;let b=this.type;this.render=function(k,N,I){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||k.length===0)return;const C=t.getRenderTarget(),D=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),j=t.state;j.setBlending(yc),j.buffers.depth.getReversed()===!0?j.buffers.color.setClear(0,0,0,0):j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);const q=b!==nc&&this.type===nc,R=b===nc&&this.type!==nc;for(let W=0,K=k.length;W<K;W++){const V=k[W],te=V.shadow;if(te===void 0){Xt("WebGLShadowMap:",V,"has no shadow.");continue}if(te.autoUpdate===!1&&te.needsUpdate===!1)continue;i.copy(te.mapSize);const Y=te.getFrameExtents();if(i.multiply(Y),s.copy(te.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Y.x),i.x=s.x*Y.x,te.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Y.y),i.y=s.y*Y.y,te.mapSize.y=s.y)),te.map===null||q===!0||R===!0){const U=this.type!==nc?{minFilter:ba,magFilter:ba}:{};te.map!==null&&te.map.dispose(),te.map=new Yh(i.x,i.y,U),te.map.texture.name=V.name+".shadowMap",te.camera.updateProjectionMatrix()}t.setRenderTarget(te.map),t.clear();const Z=te.getViewportCount();for(let U=0;U<Z;U++){const z=te.getViewport(U);a.set(s.x*z.x,s.y*z.y,s.x*z.z,s.y*z.w),j.viewport(a),te.updateMatrices(V,U),r=te.getFrustum(),A(N,I,te.camera,V,this.type)}te.isPointLightShadow!==!0&&this.type===nc&&E(te,I),te.needsUpdate=!1}b=this.type,v.needsUpdate=!1,t.setRenderTarget(C,D,F)};function E(k,N){const I=e.update(y);g.defines.VSM_SAMPLES!==k.blurSamples&&(g.defines.VSM_SAMPLES=k.blurSamples,m.defines.VSM_SAMPLES=k.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new Yh(i.x,i.y)),g.uniforms.shadow_pass.value=k.map.texture,g.uniforms.resolution.value=k.mapSize,g.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(N,null,I,g,y,null),m.uniforms.shadow_pass.value=k.mapPass.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(N,null,I,m,y,null)}function S(k,N,I,C){let D=null;const F=I.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(F!==void 0)D=F;else if(D=I.isPointLight===!0?l:o,t.localClippingEnabled&&N.clipShadows===!0&&Array.isArray(N.clippingPlanes)&&N.clippingPlanes.length!==0||N.displacementMap&&N.displacementScale!==0||N.alphaMap&&N.alphaTest>0||N.map&&N.alphaTest>0||N.alphaToCoverage===!0){const j=D.uuid,q=N.uuid;let R=u[j];R===void 0&&(R={},u[j]=R);let W=R[q];W===void 0&&(W=D.clone(),R[q]=W,N.addEventListener("dispose",T)),D=W}if(D.visible=N.visible,D.wireframe=N.wireframe,C===nc?D.side=N.shadowSide!==null?N.shadowSide:N.side:D.side=N.shadowSide!==null?N.shadowSide:f[N.side],D.alphaMap=N.alphaMap,D.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,D.map=N.map,D.clipShadows=N.clipShadows,D.clippingPlanes=N.clippingPlanes,D.clipIntersection=N.clipIntersection,D.displacementMap=N.displacementMap,D.displacementScale=N.displacementScale,D.displacementBias=N.displacementBias,D.wireframeLinewidth=N.wireframeLinewidth,D.linewidth=N.linewidth,I.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const j=t.properties.get(D);j.light=I}return D}function A(k,N,I,C,D){if(k.visible===!1)return;if(k.layers.test(N.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&D===nc)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,k.matrixWorld);const q=e.update(k),R=k.material;if(Array.isArray(R)){const W=q.groups;for(let K=0,V=W.length;K<V;K++){const te=W[K],Y=R[te.materialIndex];if(Y&&Y.visible){const Z=S(k,Y,C,D);k.onBeforeShadow(t,k,N,I,q,Z,te),t.renderBufferDirect(I,null,q,Z,k,te),k.onAfterShadow(t,k,N,I,q,Z,te)}}}else if(R.visible){const W=S(k,R,C,D);k.onBeforeShadow(t,k,N,I,q,W,null),t.renderBufferDirect(I,null,q,W,k,null),k.onAfterShadow(t,k,N,I,q,W,null)}}const j=k.children;for(let q=0,R=j.length;q<R;q++)A(j[q],N,I,C,D)}function T(k){k.target.removeEventListener("dispose",T);for(const I in u){const C=u[I],D=k.target.uuid;D in C&&(C[D].dispose(),delete C[D])}}}const mDe={[Rk]:Dk,[Ok]:Ik,[jk]:Uk,[ym]:Lk,[Dk]:Rk,[Ik]:Ok,[Uk]:jk,[Lk]:ym};function gDe(t,e){function n(){let Q=!1;const Fe=new Kr;let pe=null;const Ue=new Kr(0,0,0,0);return{setMask:function(Ce){pe!==Ce&&!Q&&(t.colorMask(Ce,Ce,Ce,Ce),pe=Ce)},setLocked:function(Ce){Q=Ce},setClear:function(Ce,_e,He,ht,wt){wt===!0&&(Ce*=ht,_e*=ht,He*=ht),Fe.set(Ce,_e,He,ht),Ue.equals(Fe)===!1&&(t.clearColor(Ce,_e,He,ht),Ue.copy(Fe))},reset:function(){Q=!1,pe=null,Ue.set(-1,0,0,0)}}}function r(){let Q=!1,Fe=!1,pe=null,Ue=null,Ce=null;return{setReversed:function(_e){if(Fe!==_e){const He=e.get("EXT_clip_control");_e?He.clipControlEXT(He.LOWER_LEFT_EXT,He.ZERO_TO_ONE_EXT):He.clipControlEXT(He.LOWER_LEFT_EXT,He.NEGATIVE_ONE_TO_ONE_EXT),Fe=_e;const ht=Ce;Ce=null,this.setClear(ht)}},getReversed:function(){return Fe},setTest:function(_e){_e?xe(t.DEPTH_TEST):ye(t.DEPTH_TEST)},setMask:function(_e){pe!==_e&&!Q&&(t.depthMask(_e),pe=_e)},setFunc:function(_e){if(Fe&&(_e=mDe[_e]),Ue!==_e){switch(_e){case Rk:t.depthFunc(t.NEVER);break;case Dk:t.depthFunc(t.ALWAYS);break;case Ok:t.depthFunc(t.LESS);break;case ym:t.depthFunc(t.LEQUAL);break;case jk:t.depthFunc(t.EQUAL);break;case Lk:t.depthFunc(t.GEQUAL);break;case Ik:t.depthFunc(t.GREATER);break;case Uk:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=_e}},setLocked:function(_e){Q=_e},setClear:function(_e){Ce!==_e&&(Fe&&(_e=1-_e),t.clearDepth(_e),Ce=_e)},reset:function(){Q=!1,pe=null,Ue=null,Ce=null,Fe=!1}}}function i(){let Q=!1,Fe=null,pe=null,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null;return{setTest:function(Ot){Q||(Ot?xe(t.STENCIL_TEST):ye(t.STENCIL_TEST))},setMask:function(Ot){Fe!==Ot&&!Q&&(t.stencilMask(Ot),Fe=Ot)},setFunc:function(Ot,cn,It){(pe!==Ot||Ue!==cn||Ce!==It)&&(t.stencilFunc(Ot,cn,It),pe=Ot,Ue=cn,Ce=It)},setOp:function(Ot,cn,It){(_e!==Ot||He!==cn||ht!==It)&&(t.stencilOp(Ot,cn,It),_e=Ot,He=cn,ht=It)},setLocked:function(Ot){Q=Ot},setClear:function(Ot){wt!==Ot&&(t.clearStencil(Ot),wt=Ot)},reset:function(){Q=!1,Fe=null,pe=null,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null}}}const s=new n,a=new r,o=new i,l=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,m=[],x=null,y=!1,v=null,b=null,E=null,S=null,A=null,T=null,k=null,N=new yn(0,0,0),I=0,C=!1,D=null,F=null,j=null,q=null,R=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,V=0;const te=t.getParameter(t.VERSION);te.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(te)[1]),K=V>=1):te.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),K=V>=2);let Y=null,Z={};const U=t.getParameter(t.SCISSOR_BOX),z=t.getParameter(t.VIEWPORT),ee=new Kr().fromArray(U),ae=new Kr().fromArray(z);function fe(Q,Fe,pe,Ue){const Ce=new Uint8Array(4),_e=t.createTexture();t.bindTexture(Q,_e),t.texParameteri(Q,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Q,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let He=0;He<pe;He++)Q===t.TEXTURE_3D||Q===t.TEXTURE_2D_ARRAY?t.texImage3D(Fe,0,t.RGBA,1,1,Ue,0,t.RGBA,t.UNSIGNED_BYTE,Ce):t.texImage2D(Fe+He,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ce);return _e}const de={};de[t.TEXTURE_2D]=fe(t.TEXTURE_2D,t.TEXTURE_2D,1),de[t.TEXTURE_CUBE_MAP]=fe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),de[t.TEXTURE_2D_ARRAY]=fe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),de[t.TEXTURE_3D]=fe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),xe(t.DEPTH_TEST),a.setFunc(ym),ie(!1),G(w8),xe(t.CULL_FACE),$(yc);function xe(Q){d[Q]!==!0&&(t.enable(Q),d[Q]=!0)}function ye(Q){d[Q]!==!1&&(t.disable(Q),d[Q]=!1)}function re(Q,Fe){return f[Q]!==Fe?(t.bindFramebuffer(Q,Fe),f[Q]=Fe,Q===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Fe),Q===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Fe),!0):!1}function ve(Q,Fe){let pe=m,Ue=!1;if(Q){pe=g.get(Fe),pe===void 0&&(pe=[],g.set(Fe,pe));const Ce=Q.textures;if(pe.length!==Ce.length||pe[0]!==t.COLOR_ATTACHMENT0){for(let _e=0,He=Ce.length;_e<He;_e++)pe[_e]=t.COLOR_ATTACHMENT0+_e;pe.length=Ce.length,Ue=!0}}else pe[0]!==t.BACK&&(pe[0]=t.BACK,Ue=!0);Ue&&t.drawBuffers(pe)}function je(Q){return x!==Q?(t.useProgram(Q),x=Q,!0):!1}const ue={[nh]:t.FUNC_ADD,[mCe]:t.FUNC_SUBTRACT,[gCe]:t.FUNC_REVERSE_SUBTRACT};ue[xCe]=t.MIN,ue[bCe]=t.MAX;const ut={[vCe]:t.ZERO,[yCe]:t.ONE,[_Ce]:t.SRC_COLOR,[kk]:t.SRC_ALPHA,[TCe]:t.SRC_ALPHA_SATURATE,[MCe]:t.DST_COLOR,[SCe]:t.DST_ALPHA,[wCe]:t.ONE_MINUS_SRC_COLOR,[Pk]:t.ONE_MINUS_SRC_ALPHA,[ACe]:t.ONE_MINUS_DST_COLOR,[ECe]:t.ONE_MINUS_DST_ALPHA,[CCe]:t.CONSTANT_COLOR,[NCe]:t.ONE_MINUS_CONSTANT_COLOR,[kCe]:t.CONSTANT_ALPHA,[PCe]:t.ONE_MINUS_CONSTANT_ALPHA};function $(Q,Fe,pe,Ue,Ce,_e,He,ht,wt,Ot){if(Q===yc){y===!0&&(ye(t.BLEND),y=!1);return}if(y===!1&&(xe(t.BLEND),y=!0),Q!==pCe){if(Q!==v||Ot!==C){if((b!==nh||A!==nh)&&(t.blendEquation(t.FUNC_ADD),b=nh,A=nh),Ot)switch(Q){case Jp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case S8:t.blendFunc(t.ONE,t.ONE);break;case E8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case M8:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ur("WebGLState: Invalid blending: ",Q);break}else switch(Q){case Jp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case S8:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case E8:Ur("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case M8:Ur("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ur("WebGLState: Invalid blending: ",Q);break}E=null,S=null,T=null,k=null,N.set(0,0,0),I=0,v=Q,C=Ot}return}Ce=Ce||Fe,_e=_e||pe,He=He||Ue,(Fe!==b||Ce!==A)&&(t.blendEquationSeparate(ue[Fe],ue[Ce]),b=Fe,A=Ce),(pe!==E||Ue!==S||_e!==T||He!==k)&&(t.blendFuncSeparate(ut[pe],ut[Ue],ut[_e],ut[He]),E=pe,S=Ue,T=_e,k=He),(ht.equals(N)===!1||wt!==I)&&(t.blendColor(ht.r,ht.g,ht.b,wt),N.copy(ht),I=wt),v=Q,C=!1}function H(Q,Fe){Q.side===tl?ye(t.CULL_FACE):xe(t.CULL_FACE);let pe=Q.side===Gs;Fe&&(pe=!pe),ie(pe),Q.blending===Jp&&Q.transparent===!1?$(yc):$(Q.blending,Q.blendEquation,Q.blendSrc,Q.blendDst,Q.blendEquationAlpha,Q.blendSrcAlpha,Q.blendDstAlpha,Q.blendColor,Q.blendAlpha,Q.premultipliedAlpha),a.setFunc(Q.depthFunc),a.setTest(Q.depthTest),a.setMask(Q.depthWrite),s.setMask(Q.colorWrite);const Ue=Q.stencilWrite;o.setTest(Ue),Ue&&(o.setMask(Q.stencilWriteMask),o.setFunc(Q.stencilFunc,Q.stencilRef,Q.stencilFuncMask),o.setOp(Q.stencilFail,Q.stencilZFail,Q.stencilZPass)),le(Q.polygonOffset,Q.polygonOffsetFactor,Q.polygonOffsetUnits),Q.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):ye(t.SAMPLE_ALPHA_TO_COVERAGE)}function ie(Q){D!==Q&&(Q?t.frontFace(t.CW):t.frontFace(t.CCW),D=Q)}function G(Q){Q!==dCe?(xe(t.CULL_FACE),Q!==F&&(Q===w8?t.cullFace(t.BACK):Q===hCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ye(t.CULL_FACE),F=Q}function J(Q){Q!==j&&(K&&t.lineWidth(Q),j=Q)}function le(Q,Fe,pe){Q?(xe(t.POLYGON_OFFSET_FILL),(q!==Fe||R!==pe)&&(t.polygonOffset(Fe,pe),q=Fe,R=pe)):ye(t.POLYGON_OFFSET_FILL)}function ke(Q){Q?xe(t.SCISSOR_TEST):ye(t.SCISSOR_TEST)}function Ne(Q){Q===void 0&&(Q=t.TEXTURE0+W-1),Y!==Q&&(t.activeTexture(Q),Y=Q)}function Se(Q,Fe,pe){pe===void 0&&(Y===null?pe=t.TEXTURE0+W-1:pe=Y);let Ue=Z[pe];Ue===void 0&&(Ue={type:void 0,texture:void 0},Z[pe]=Ue),(Ue.type!==Q||Ue.texture!==Fe)&&(Y!==pe&&(t.activeTexture(pe),Y=pe),t.bindTexture(Q,Fe||de[Q]),Ue.type=Q,Ue.texture=Fe)}function B(){const Q=Z[Y];Q!==void 0&&Q.type!==void 0&&(t.bindTexture(Q.type,null),Q.type=void 0,Q.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function be(){try{t.texSubImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function we(){try{t.texSubImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ge(){try{t.compressedTexSubImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function me(){try{t.compressedTexSubImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function Ae(){try{t.texStorage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ze(){try{t.texStorage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function st(){try{t.texImage2D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function Ve(){try{t.texImage3D(...arguments)}catch(Q){Q("WebGLState:",Q)}}function ce(Q){ee.equals(Q)===!1&&(t.scissor(Q.x,Q.y,Q.z,Q.w),ee.copy(Q))}function Ye(Q){ae.equals(Q)===!1&&(t.viewport(Q.x,Q.y,Q.z,Q.w),ae.copy(Q))}function $e(Q,Fe){let pe=u.get(Fe);pe===void 0&&(pe=new WeakMap,u.set(Fe,pe));let Ue=pe.get(Q);Ue===void 0&&(Ue=t.getUniformBlockIndex(Fe,Q.name),pe.set(Q,Ue))}function Ze(Q,Fe){const Ue=u.get(Fe).get(Q);l.get(Fe)!==Ue&&(t.uniformBlockBinding(Fe,Ue,Q.__bindingPointIndex),l.set(Fe,Ue))}function at(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Y=null,Z={},f={},g=new WeakMap,m=[],x=null,y=!1,v=null,b=null,E=null,S=null,A=null,T=null,k=null,N=new yn(0,0,0),I=0,C=!1,D=null,F=null,j=null,q=null,R=null,ee.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:xe,disable:ye,bindFramebuffer:re,drawBuffers:ve,useProgram:je,setBlending:$,setMaterial:H,setFlipSided:ie,setCullFace:G,setLineWidth:J,setPolygonOffset:le,setScissorTest:ke,activeTexture:Ne,bindTexture:Se,unbindTexture:B,compressedTexImage2D:L,compressedTexImage3D:ne,texImage2D:st,texImage3D:Ve,updateUBOMapping:$e,uniformBlockBinding:Ze,texStorage2D:Ae,texStorage3D:ze,texSubImage2D:be,texSubImage3D:we,compressedTexSubImage2D:ge,compressedTexSubImage3D:me,scissor:ce,viewport:Ye,reset:at}}function xDe(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),u=new on,d=new WeakMap;let f;const g=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(B,L){return m?new OffscreenCanvas(B,L):Sw("canvas")}function y(B,L,ne){let be=1;const we=Se(B);if((we.width>ne||we.height>ne)&&(be=ne/Math.max(we.width,we.height)),be<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const ge=Math.floor(be*we.width),me=Math.floor(be*we.height);f===void 0&&(f=x(ge,me));const Ae=L?x(ge,me):f;return Ae.width=ge,Ae.height=me,Ae.getContext("2d").drawImage(B,0,0,ge,me),Xt("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ge+"x"+me+")."),Ae}else return"data"in B&&Xt("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),B;return B}function v(B){return B.generateMipmaps}function b(B){t.generateMipmap(B)}function E(B){return B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?t.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function S(B,L,ne,be,we=!1){if(B!==null){if(t[B]!==void 0)return t[B];Xt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ge=L;if(L===t.RED&&(ne===t.FLOAT&&(ge=t.R32F),ne===t.HALF_FLOAT&&(ge=t.R16F),ne===t.UNSIGNED_BYTE&&(ge=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.R8UI),ne===t.UNSIGNED_SHORT&&(ge=t.R16UI),ne===t.UNSIGNED_INT&&(ge=t.R32UI),ne===t.BYTE&&(ge=t.R8I),ne===t.SHORT&&(ge=t.R16I),ne===t.INT&&(ge=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ge=t.RG32F),ne===t.HALF_FLOAT&&(ge=t.RG16F),ne===t.UNSIGNED_BYTE&&(ge=t.RG8)),L===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.RG8UI),ne===t.UNSIGNED_SHORT&&(ge=t.RG16UI),ne===t.UNSIGNED_INT&&(ge=t.RG32UI),ne===t.BYTE&&(ge=t.RG8I),ne===t.SHORT&&(ge=t.RG16I),ne===t.INT&&(ge=t.RG32I)),L===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(ge=t.RGB16UI),ne===t.UNSIGNED_INT&&(ge=t.RGB32UI),ne===t.BYTE&&(ge=t.RGB8I),ne===t.SHORT&&(ge=t.RGB16I),ne===t.INT&&(ge=t.RGB32I)),L===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(ge=t.RGBA16UI),ne===t.UNSIGNED_INT&&(ge=t.RGBA32UI),ne===t.BYTE&&(ge=t.RGBA8I),ne===t.SHORT&&(ge=t.RGBA16I),ne===t.INT&&(ge=t.RGBA32I)),L===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(ge=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(ge=t.R11F_G11F_B10F)),L===t.RGBA){const me=we?_w:Tn.getTransfer(be);ne===t.FLOAT&&(ge=t.RGBA32F),ne===t.HALF_FLOAT&&(ge=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ge=me===Wn?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function A(B,L){let ne;return B?L===null||L===Kh||L===L0?ne=t.DEPTH24_STENCIL8:L===pc?ne=t.DEPTH32F_STENCIL8:L===j0&&(ne=t.DEPTH24_STENCIL8,Xt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Kh||L===L0?ne=t.DEPTH_COMPONENT24:L===pc?ne=t.DEPTH_COMPONENT32F:L===j0&&(ne=t.DEPTH_COMPONENT16),ne}function T(B,L){return v(B)===!0||B.isFramebufferTexture&&B.minFilter!==ba&&B.minFilter!==Ja?Math.log2(Math.max(L.width,L.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?L.mipmaps.length:1}function k(B){const L=B.target;L.removeEventListener("dispose",k),I(L),L.isVideoTexture&&d.delete(L)}function N(B){const L=B.target;L.removeEventListener("dispose",N),D(L)}function I(B){const L=r.get(B);if(L.__webglInit===void 0)return;const ne=B.source,be=g.get(ne);if(be){const we=be[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&C(B),Object.keys(be).length===0&&g.delete(ne)}r.remove(B)}function C(B){const L=r.get(B);t.deleteTexture(L.__webglTexture);const ne=B.source,be=g.get(ne);delete be[L.__cacheKey],a.memory.textures--}function D(B){const L=r.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),r.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(L.__webglFramebuffer[be]))for(let we=0;we<L.__webglFramebuffer[be].length;we++)t.deleteFramebuffer(L.__webglFramebuffer[be][we]);else t.deleteFramebuffer(L.__webglFramebuffer[be]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[be])}else{if(Array.isArray(L.__webglFramebuffer))for(let be=0;be<L.__webglFramebuffer.length;be++)t.deleteFramebuffer(L.__webglFramebuffer[be]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let be=0;be<L.__webglColorRenderbuffer.length;be++)L.__webglColorRenderbuffer[be]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[be]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const ne=B.textures;for(let be=0,we=ne.length;be<we;be++){const ge=r.get(ne[be]);ge.__webglTexture&&(t.deleteTexture(ge.__webglTexture),a.memory.textures--),r.remove(ne[be])}r.remove(B)}let F=0;function j(){F=0}function q(){const B=F;return B>=i.maxTextures&&Xt("WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+i.maxTextures),F+=1,B}function R(B){const L=[];return L.push(B.wrapS),L.push(B.wrapT),L.push(B.wrapR||0),L.push(B.magFilter),L.push(B.minFilter),L.push(B.anisotropy),L.push(B.internalFormat),L.push(B.format),L.push(B.type),L.push(B.generateMipmaps),L.push(B.premultiplyAlpha),L.push(B.flipY),L.push(B.unpackAlignment),L.push(B.colorSpace),L.join()}function W(B,L){const ne=r.get(B);if(B.isVideoTexture&&ke(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&ne.__version!==B.version){const be=B.image;if(be===null)Xt("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)Xt("WebGLRenderer: Texture marked for update but image is incomplete");else{de(ne,B,L);return}}else B.isExternalTexture&&(ne.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function K(B,L){const ne=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ne.__version!==B.version){de(ne,B,L);return}else B.isExternalTexture&&(ne.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function V(B,L){const ne=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ne.__version!==B.version){de(ne,B,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function te(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){xe(ne,B,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const Y={[Bk]:t.REPEAT,[fc]:t.CLAMP_TO_EDGE,[Hk]:t.MIRRORED_REPEAT},Z={[ba]:t.NEAREST,[BCe]:t.NEAREST_MIPMAP_NEAREST,[Ty]:t.NEAREST_MIPMAP_LINEAR,[Ja]:t.LINEAR,[oC]:t.LINEAR_MIPMAP_NEAREST,[hh]:t.LINEAR_MIPMAP_LINEAR},U={[GCe]:t.NEVER,[ZCe]:t.ALWAYS,[WCe]:t.LESS,[BY]:t.LEQUAL,[qCe]:t.EQUAL,[YCe]:t.GEQUAL,[KCe]:t.GREATER,[XCe]:t.NOTEQUAL};function z(B,L){if(L.type===pc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Ja||L.magFilter===oC||L.magFilter===Ty||L.magFilter===hh||L.minFilter===Ja||L.minFilter===oC||L.minFilter===Ty||L.minFilter===hh)&&Xt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(B,t.TEXTURE_WRAP_S,Y[L.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,Y[L.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,Y[L.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,Z[L.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,Z[L.minFilter]),L.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,U[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ba||L.minFilter!==Ty&&L.minFilter!==hh||L.type===pc&&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(B,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ee(B,L){let ne=!1;B.__webglInit===void 0&&(B.__webglInit=!0,L.addEventListener("dispose",k));const be=L.source;let we=g.get(be);we===void 0&&(we={},g.set(be,we));const ge=R(L);if(ge!==B.__cacheKey){we[ge]===void 0&&(we[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,ne=!0),we[ge].usedTimes++;const me=we[B.__cacheKey];me!==void 0&&(we[B.__cacheKey].usedTimes--,me.usedTimes===0&&C(L)),B.__cacheKey=ge,B.__webglTexture=we[ge].texture}return ne}function ae(B,L,ne){return Math.floor(Math.floor(B/ne)/L)}function fe(B,L,ne,be){const ge=B.updateRanges;if(ge.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,ne,be,L.data);else{ge.sort((Ve,ce)=>Ve.start-ce.start);let me=0;for(let Ve=1;Ve<ge.length;Ve++){const ce=ge[me],Ye=ge[Ve],$e=ce.start+ce.count,Ze=ae(Ye.start,L.width,4),at=ae(ce.start,L.width,4);Ye.start<=$e+1&&Ze===at&&ae(Ye.start+Ye.count-1,L.width,4)===Ze?ce.count=Math.max(ce.count,Ye.start+Ye.count-ce.start):(++me,ge[me]=Ye)}ge.length=me+1;const Ae=t.getParameter(t.UNPACK_ROW_LENGTH),ze=t.getParameter(t.UNPACK_SKIP_PIXELS),st=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Ve=0,ce=ge.length;Ve<ce;Ve++){const Ye=ge[Ve],$e=Math.floor(Ye.start/4),Ze=Math.ceil(Ye.count/4),at=$e%L.width,Q=Math.floor($e/L.width),Fe=Ze,pe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,at),t.pixelStorei(t.UNPACK_SKIP_ROWS,Q),n.texSubImage2D(t.TEXTURE_2D,0,at,Q,Fe,pe,ne,be,L.data)}B.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ae),t.pixelStorei(t.UNPACK_SKIP_PIXELS,ze),t.pixelStorei(t.UNPACK_SKIP_ROWS,st)}}function de(B,L,ne){let be=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(be=t.TEXTURE_3D);const we=ee(B,L),ge=L.source;n.bindTexture(be,B.__webglTexture,t.TEXTURE0+ne);const me=r.get(ge);if(ge.version!==me.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Ae=Tn.getPrimaries(Tn.workingColorSpace),ze=L.colorSpace===Ou?null:Tn.getPrimaries(L.colorSpace),st=L.colorSpace===Ou||Ae===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);let Ve=y(L.image,!1,i.maxTextureSize);Ve=Ne(L,Ve);const ce=s.convert(L.format,L.colorSpace),Ye=s.convert(L.type);let $e=S(L.internalFormat,ce,Ye,L.colorSpace,L.isVideoTexture);z(be,L);let Ze;const at=L.mipmaps,Q=L.isVideoTexture!==!0,Fe=me.__version===void 0||we===!0,pe=ge.dataReady,Ue=T(L,Ve);if(L.isDepthTexture)$e=A(L.format===U0,L.type),Fe&&(Q?n.texStorage2D(t.TEXTURE_2D,1,$e,Ve.width,Ve.height):n.texImage2D(t.TEXTURE_2D,0,$e,Ve.width,Ve.height,0,ce,Ye,null));else if(L.isDataTexture)if(at.length>0){Q&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,at[0].width,at[0].height);for(let Ce=0,_e=at.length;Ce<_e;Ce++)Ze=at[Ce],Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ye,Ze.data):n.texImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,ce,Ye,Ze.data);L.generateMipmaps=!1}else Q?(Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ve.width,Ve.height),pe&&fe(L,Ve,ce,Ye)):n.texImage2D(t.TEXTURE_2D,0,$e,Ve.width,Ve.height,0,ce,Ye,Ve.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){Q&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,$e,at[0].width,at[0].height,Ve.depth);for(let Ce=0,_e=at.length;Ce<_e;Ce++)if(Ze=at[Ce],L.format!==No)if(ce!==null)if(Q){if(pe)if(L.layerUpdates.size>0){const He=tH(Ze.width,Ze.height,L.format,L.type);for(const ht of L.layerUpdates){const wt=Ze.data.subarray(ht*He/Ze.data.BYTES_PER_ELEMENT,(ht+1)*He/Ze.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,ht,Ze.width,Ze.height,1,ce,wt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ze.width,Ze.height,Ve.depth,ce,Ze.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,$e,Ze.width,Ze.height,Ve.depth,0,Ze.data,0,0);else Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Q?pe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ze.width,Ze.height,Ve.depth,ce,Ye,Ze.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,$e,Ze.width,Ze.height,Ve.depth,0,ce,Ye,Ze.data)}else{Q&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,$e,at[0].width,at[0].height);for(let Ce=0,_e=at.length;Ce<_e;Ce++)Ze=at[Ce],L.format!==No?ce!==null?Q?pe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ze.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,Ze.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ze.width,Ze.height,ce,Ye,Ze.data):n.texImage2D(t.TEXTURE_2D,Ce,$e,Ze.width,Ze.height,0,ce,Ye,Ze.data)}else if(L.isDataArrayTexture)if(Q){if(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,$e,Ve.width,Ve.height,Ve.depth),pe)if(L.layerUpdates.size>0){const Ce=tH(Ve.width,Ve.height,L.format,L.type);for(const _e of L.layerUpdates){const He=Ve.data.subarray(_e*Ce/Ve.data.BYTES_PER_ELEMENT,(_e+1)*Ce/Ve.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,_e,Ve.width,Ve.height,1,ce,Ye,He)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ve.width,Ve.height,Ve.depth,ce,Ye,Ve.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,$e,Ve.width,Ve.height,Ve.depth,0,ce,Ye,Ve.data);else if(L.isData3DTexture)Q?(Fe&&n.texStorage3D(t.TEXTURE_3D,Ue,$e,Ve.width,Ve.height,Ve.depth),pe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ve.width,Ve.height,Ve.depth,ce,Ye,Ve.data)):n.texImage3D(t.TEXTURE_3D,0,$e,Ve.width,Ve.height,Ve.depth,0,ce,Ye,Ve.data);else if(L.isFramebufferTexture){if(Fe)if(Q)n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ve.width,Ve.height);else{let Ce=Ve.width,_e=Ve.height;for(let He=0;He<Ue;He++)n.texImage2D(t.TEXTURE_2D,He,$e,Ce,_e,0,ce,Ye,null),Ce>>=1,_e>>=1}}else if(at.length>0){if(Q&&Fe){const Ce=Se(at[0]);n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ce.width,Ce.height)}for(let Ce=0,_e=at.length;Ce<_e;Ce++)Ze=at[Ce],Q?pe&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,ce,Ye,Ze):n.texImage2D(t.TEXTURE_2D,Ce,$e,ce,Ye,Ze);L.generateMipmaps=!1}else if(Q){if(Fe){const Ce=Se(Ve);n.texStorage2D(t.TEXTURE_2D,Ue,$e,Ce.width,Ce.height)}pe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce,Ye,Ve)}else n.texImage2D(t.TEXTURE_2D,0,$e,ce,Ye,Ve);v(L)&&b(be),me.__version=ge.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function xe(B,L,ne){if(L.image.length!==6)return;const be=ee(B,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+ne);const ge=r.get(we);if(we.version!==ge.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const me=Tn.getPrimaries(Tn.workingColorSpace),Ae=L.colorSpace===Ou?null:Tn.getPrimaries(L.colorSpace),ze=L.colorSpace===Ou||me===Ae?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ze);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,Ve=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let _e=0;_e<6;_e++)!st&&!Ve?ce[_e]=y(L.image[_e],!0,i.maxCubemapSize):ce[_e]=Ve?L.image[_e].image:L.image[_e],ce[_e]=Ne(L,ce[_e]);const Ye=ce[0],$e=s.convert(L.format,L.colorSpace),Ze=s.convert(L.type),at=S(L.internalFormat,$e,Ze,L.colorSpace),Q=L.isVideoTexture!==!0,Fe=ge.__version===void 0||be===!0,pe=we.dataReady;let Ue=T(L,Ye);z(t.TEXTURE_CUBE_MAP,L);let Ce;if(st){Q&&Fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,at,Ye.width,Ye.height);for(let _e=0;_e<6;_e++){Ce=ce[_e].mipmaps;for(let He=0;He<Ce.length;He++){const ht=Ce[He];L.format!==No?$e!==null?Q?pe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,$e,ht.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,at,ht.width,ht.height,0,ht.data):Xt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,$e,Ze,ht.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,at,ht.width,ht.height,0,$e,Ze,ht.data)}}}else{if(Ce=L.mipmaps,Q&&Fe){Ce.length>0&&Ue++;const _e=Se(ce[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,at,_e.width,_e.height)}for(let _e=0;_e<6;_e++)if(Ve){Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,ce[_e].width,ce[_e].height,$e,Ze,ce[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,at,ce[_e].width,ce[_e].height,0,$e,Ze,ce[_e].data);for(let He=0;He<Ce.length;He++){const wt=Ce[He].image[_e].image;Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,wt.width,wt.height,$e,Ze,wt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,at,wt.width,wt.height,0,$e,Ze,wt.data)}}else{Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,$e,Ze,ce[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,at,$e,Ze,ce[_e]);for(let He=0;He<Ce.length;He++){const ht=Ce[He];Q?pe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,$e,Ze,ht.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,at,$e,Ze,ht.image[_e])}}}v(L)&&b(t.TEXTURE_CUBE_MAP),ge.__version=we.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function ye(B,L,ne,be,we,ge){const me=s.convert(ne.format,ne.colorSpace),Ae=s.convert(ne.type),ze=S(ne.internalFormat,me,Ae,ne.colorSpace),st=r.get(L),Ve=r.get(ne);if(Ve.__renderTarget=L,!st.__hasExternalTextures){const ce=Math.max(1,L.width>>ge),Ye=Math.max(1,L.height>>ge);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ge,ze,ce,Ye,L.depth,0,me,Ae,null):n.texImage2D(we,ge,ze,ce,Ye,0,me,Ae,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,we,Ve.__webglTexture,0,J(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,we,Ve.__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function re(B,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,B),L.depthBuffer){const be=L.depthTexture,we=be&&be.isDepthTexture?be.type:null,ge=A(L.stencilBuffer,we),me=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ae=J(L);le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ae,ge,L.width,L.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ae,ge,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ge,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,me,t.RENDERBUFFER,B)}else{const be=L.textures;for(let we=0;we<be.length;we++){const ge=be[we],me=s.convert(ge.format,ge.colorSpace),Ae=s.convert(ge.type),ze=S(ge.internalFormat,me,Ae,ge.colorSpace),st=J(L);ne&&le(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,ze,L.width,L.height):le(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,ze,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ze,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ve(B,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const be=r.get(L.depthTexture);be.__renderTarget=L,(!be.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),W(L.depthTexture,0);const we=be.__webglTexture,ge=J(L);if(L.depthTexture.format===I0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0);else if(L.depthTexture.format===U0)le(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0,ge):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function je(B){const L=r.get(B),ne=B.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==B.depthTexture){const be=B.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),be){const we=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,be.removeEventListener("dispose",we)};be.addEventListener("dispose",we),L.__depthDisposeCallback=we}L.__boundDepthTexture=be}if(B.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const be=B.texture.mipmaps;be&&be.length>0?ve(L.__webglFramebuffer[0],B):ve(L.__webglFramebuffer,B)}else if(ne){L.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[be]),L.__webglDepthbuffer[be]===void 0)L.__webglDepthbuffer[be]=t.createRenderbuffer(),re(L.__webglDepthbuffer[be],B,!1);else{const we=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=L.__webglDepthbuffer[be];t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ge)}}else{const be=B.texture.mipmaps;if(be&&be.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),re(L.__webglDepthbuffer,B,!1);else{const we=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ge=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ge),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ge)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(B,L,ne){const be=r.get(B);L!==void 0&&ye(be.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&je(B)}function ut(B){const L=B.texture,ne=r.get(B),be=r.get(L);B.addEventListener("dispose",N);const we=B.textures,ge=B.isWebGLCubeRenderTarget===!0,me=we.length>1;if(me||(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=L.version,a.memory.textures++),ge){ne.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Ae]=[];for(let ze=0;ze<L.mipmaps.length;ze++)ne.__webglFramebuffer[Ae][ze]=t.createFramebuffer()}else ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ae=0;Ae<L.mipmaps.length;Ae++)ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(me)for(let Ae=0,ze=we.length;Ae<ze;Ae++){const st=r.get(we[Ae]);st.__webglTexture===void 0&&(st.__webglTexture=t.createTexture(),a.memory.textures++)}if(B.samples>0&&le(B)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Ae=0;Ae<we.length;Ae++){const ze=we[Ae];ne.__webglColorRenderbuffer[Ae]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ae]);const st=s.convert(ze.format,ze.colorSpace),Ve=s.convert(ze.type),ce=S(ze.internalFormat,st,Ve,ze.colorSpace,B.isXRRenderTarget===!0),Ye=J(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ye,ce,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ae,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ae])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),re(ne.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ge){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),z(t.TEXTURE_CUBE_MAP,L);for(let Ae=0;Ae<6;Ae++)if(L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)ye(ne.__webglFramebuffer[Ae][ze],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,ze);else ye(ne.__webglFramebuffer[Ae],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);v(L)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(me){for(let Ae=0,ze=we.length;Ae<ze;Ae++){const st=we[Ae],Ve=r.get(st);let ce=t.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(ce=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ce,Ve.__webglTexture),z(ce,st),ye(ne.__webglFramebuffer,B,st,t.COLOR_ATTACHMENT0+Ae,ce,0),v(st)&&b(ce)}n.unbindTexture()}else{let Ae=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(Ae=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ae,be.__webglTexture),z(Ae,L),L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)ye(ne.__webglFramebuffer[ze],B,L,t.COLOR_ATTACHMENT0,Ae,ze);else ye(ne.__webglFramebuffer,B,L,t.COLOR_ATTACHMENT0,Ae,0);v(L)&&b(Ae),n.unbindTexture()}B.depthBuffer&&je(B)}function $(B){const L=B.textures;for(let ne=0,be=L.length;ne<be;ne++){const we=L[ne];if(v(we)){const ge=E(B),me=r.get(we).__webglTexture;n.bindTexture(ge,me),b(ge),n.unbindTexture()}}}const H=[],ie=[];function G(B){if(B.samples>0){if(le(B)===!1){const L=B.textures,ne=B.width,be=B.height;let we=t.COLOR_BUFFER_BIT;const ge=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,me=r.get(B),Ae=L.length>1;if(Ae)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,me.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,me.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,me.__webglMultisampledFramebuffer);const ze=B.texture.mipmaps;ze&&ze.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglFramebuffer);for(let st=0;st<L.length;st++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Ae){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,me.__webglColorRenderbuffer[st]);const Ve=r.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ve,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,we,t.NEAREST),l===!0&&(H.length=0,ie.length=0,H.push(t.COLOR_ATTACHMENT0+st),B.depthBuffer&&B.resolveDepthBuffer===!1&&(H.push(ge),ie.push(ge),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ie)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ae)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,me.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,me.__webglColorRenderbuffer[st]);const Ve=r.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,me.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ve,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,me.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&l){const L=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function J(B){return Math.min(i.maxSamples,B.samples)}function le(B){const L=r.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function ke(B){const L=a.render.frame;d.get(B)!==L&&(d.set(B,L),B.update())}function Ne(B,L){const ne=B.colorSpace,be=B.format,we=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||ne!==Sm&&ne!==Ou&&(Tn.getTransfer(ne)===Wn?(be!==No||we!==pl)&&Xt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ur("WebGLTextures: Unsupported texture color space:",ne)),L}function Se(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(u.width=B.naturalWidth||B.width,u.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(u.width=B.displayWidth,u.height=B.displayHeight):(u.width=B.width,u.height=B.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=j,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=V,this.setTextureCube=te,this.rebindTextures=ue,this.setupRenderTarget=ut,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=G,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=ye,this.useMultisampledRTT=le}function bDe(t,e){function n(r,i=Ou){let s;const a=Tn.getTransfer(i);if(r===pl)return t.UNSIGNED_BYTE;if(r===GO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===WO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===jY)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===LY)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===DY)return t.BYTE;if(r===OY)return t.SHORT;if(r===j0)return t.UNSIGNED_SHORT;if(r===VO)return t.INT;if(r===Kh)return t.UNSIGNED_INT;if(r===pc)return t.FLOAT;if(r===Jm)return t.HALF_FLOAT;if(r===IY)return t.ALPHA;if(r===UY)return t.RGB;if(r===No)return t.RGBA;if(r===I0)return t.DEPTH_COMPONENT;if(r===U0)return t.DEPTH_STENCIL;if(r===FY)return t.RED;if(r===qO)return t.RED_INTEGER;if(r===KO)return t.RG;if(r===XO)return t.RG_INTEGER;if(r===YO)return t.RGBA_INTEGER;if(r===Q_||r===J_||r===e1||r===t1)if(a===Wn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===Q_)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===J_)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===e1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===t1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===Q_)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===J_)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===e1)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===t1)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===$k||r===Vk||r===Gk||r===Wk)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===$k)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Vk)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Gk)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Wk)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===qk||r===Kk||r===Xk)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===qk||r===Kk)return a===Wn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===Xk)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Yk||r===Zk||r===Qk||r===Jk||r===eP||r===tP||r===nP||r===rP||r===iP||r===sP||r===aP||r===oP||r===lP||r===cP)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===Yk)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Zk)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Qk)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Jk)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===eP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===tP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===nP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===rP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===iP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===sP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===aP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===oP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===lP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===cP)return a===Wn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===uP||r===dP||r===hP)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===uP)return a===Wn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===dP)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===hP)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===fP||r===pP||r===mP||r===gP)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===fP)return s.COMPRESSED_RED_RGTC1_EXT;if(r===pP)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===mP)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===gP)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===L0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const vDe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,yDe=`
- 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 _De{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new aZ(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 Dc({vertexShader:vDe,fragmentShader:yDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new ml(new nj(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let wDe=class extends df{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,u=null,d=null,f=null,g=null,m=null,x=null;const y=typeof XRWebGLBinding<"u",v=new _De,b={},E=n.getContextAttributes();let S=null,A=null;const T=[],k=[],N=new on;let I=null;const C=new Wa;C.viewport=new Kr;const D=new Wa;D.viewport=new Kr;const F=[C,D],j=new FNe;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(de){let xe=T[de];return xe===void 0&&(xe=new NC,T[de]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(de){let xe=T[de];return xe===void 0&&(xe=new NC,T[de]=xe),xe.getGripSpace()},this.getHand=function(de){let xe=T[de];return xe===void 0&&(xe=new NC,T[de]=xe),xe.getHandSpace()};function W(de){const xe=k.indexOf(de.inputSource);if(xe===-1)return;const ye=T[xe];ye!==void 0&&(ye.update(de.inputSource,de.frame,u||a),ye.dispatchEvent({type:de.type,data:de.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",V);for(let de=0;de<T.length;de++){const xe=k[de];xe!==null&&(k[de]=null,T[de].disconnect(xe))}q=null,R=null,v.reset();for(const de in b)delete b[de];e.setRenderTarget(S),m=null,g=null,f=null,i=null,A=null,fe.stop(),r.isPresenting=!1,e.setPixelRatio(I),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(de){s=de,r.isPresenting===!0&&Xt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(de){o=de,r.isPresenting===!0&&Xt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(de){u=de},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(de){if(i=de,i!==null){if(S=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",V),E.xrCompatible!==!0&&await n.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(N),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ye=null,re=null,ve=null;E.depth&&(ve=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ye=E.stencil?U0:I0,re=E.stencil?L0:Kh);const je={colorFormat:n.RGBA8,depthFormat:ve,scaleFactor:s};f=this.getBinding(),g=f.createProjectionLayer(je),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new Yh(g.textureWidth,g.textureHeight,{format:No,type:pl,depthTexture:new sZ(g.textureWidth,g.textureHeight,re,void 0,void 0,void 0,void 0,void 0,void 0,ye),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const ye={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ye),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new Yh(m.framebufferWidth,m.framebufferHeight,{format:No,type:pl,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(l),u=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(de){for(let xe=0;xe<de.removed.length;xe++){const ye=de.removed[xe],re=k.indexOf(ye);re>=0&&(k[re]=null,T[re].disconnect(ye))}for(let xe=0;xe<de.added.length;xe++){const ye=de.added[xe];let re=k.indexOf(ye);if(re===-1){for(let je=0;je<T.length;je++)if(je>=k.length){k.push(ye),re=je;break}else if(k[je]===null){k[je]=ye,re=je;break}if(re===-1)break}const ve=T[re];ve&&ve.connect(ye)}}const te=new Je,Y=new Je;function Z(de,xe,ye){te.setFromMatrixPosition(xe.matrixWorld),Y.setFromMatrixPosition(ye.matrixWorld);const re=te.distanceTo(Y),ve=xe.projectionMatrix.elements,je=ye.projectionMatrix.elements,ue=ve[14]/(ve[10]-1),ut=ve[14]/(ve[10]+1),$=(ve[9]+1)/ve[5],H=(ve[9]-1)/ve[5],ie=(ve[8]-1)/ve[0],G=(je[8]+1)/je[0],J=ue*ie,le=ue*G,ke=re/(-ie+G),Ne=ke*-ie;if(xe.matrixWorld.decompose(de.position,de.quaternion,de.scale),de.translateX(Ne),de.translateZ(ke),de.matrixWorld.compose(de.position,de.quaternion,de.scale),de.matrixWorldInverse.copy(de.matrixWorld).invert(),ve[10]===-1)de.projectionMatrix.copy(xe.projectionMatrix),de.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const Se=ue+ke,B=ut+ke,L=J-Ne,ne=le+(re-Ne),be=$*ut/B*Se,we=H*ut/B*Se;de.projectionMatrix.makePerspective(L,ne,be,we,Se,B),de.projectionMatrixInverse.copy(de.projectionMatrix).invert()}}function U(de,xe){xe===null?de.matrixWorld.copy(de.matrix):de.matrixWorld.multiplyMatrices(xe.matrixWorld,de.matrix),de.matrixWorldInverse.copy(de.matrixWorld).invert()}this.updateCamera=function(de){if(i===null)return;let xe=de.near,ye=de.far;v.texture!==null&&(v.depthNear>0&&(xe=v.depthNear),v.depthFar>0&&(ye=v.depthFar)),j.near=D.near=C.near=xe,j.far=D.far=C.far=ye,(q!==j.near||R!==j.far)&&(i.updateRenderState({depthNear:j.near,depthFar:j.far}),q=j.near,R=j.far),j.layers.mask=de.layers.mask|6,C.layers.mask=j.layers.mask&3,D.layers.mask=j.layers.mask&5;const re=de.parent,ve=j.cameras;U(j,re);for(let je=0;je<ve.length;je++)U(ve[je],re);ve.length===2?Z(j,C,D):j.projectionMatrix.copy(C.projectionMatrix),z(de,j,re)};function z(de,xe,ye){ye===null?de.matrix.copy(xe.matrixWorld):(de.matrix.copy(ye.matrixWorld),de.matrix.invert(),de.matrix.multiply(xe.matrixWorld)),de.matrix.decompose(de.position,de.quaternion,de.scale),de.updateMatrixWorld(!0),de.projectionMatrix.copy(xe.projectionMatrix),de.projectionMatrixInverse.copy(xe.projectionMatrixInverse),de.isPerspectiveCamera&&(de.fov=xP*2*Math.atan(1/de.projectionMatrix.elements[5]),de.zoom=1)}this.getCamera=function(){return j},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(de){l=de,g!==null&&(g.fixedFoveation=de),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=de)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(j)},this.getCameraTexture=function(de){return b[de]};let ee=null;function ae(de,xe){if(d=xe.getViewerPose(u||a),x=xe,d!==null){const ye=d.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let re=!1;ye.length!==j.cameras.length&&(j.cameras.length=0,re=!0);for(let ut=0;ut<ye.length;ut++){const $=ye[ut];let H=null;if(m!==null)H=m.getViewport($);else{const G=f.getViewSubImage(g,$);H=G.viewport,ut===0&&(e.setRenderTargetTextures(A,G.colorTexture,G.depthStencilTexture),e.setRenderTarget(A))}let ie=F[ut];ie===void 0&&(ie=new Wa,ie.layers.enable(ut),ie.viewport=new Kr,F[ut]=ie),ie.matrix.fromArray($.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray($.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set(H.x,H.y,H.width,H.height),ut===0&&(j.matrix.copy(ie.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale)),re===!0&&j.cameras.push(ie)}const ve=i.enabledFeatures;if(ve&&ve.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const ut=f.getDepthInformation(ye[0]);ut&&ut.isValid&&ut.texture&&v.init(ut,i.renderState)}if(ve&&ve.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let ut=0;ut<ye.length;ut++){const $=ye[ut].camera;if($){let H=b[$];H||(H=new aZ,b[$]=H);const ie=f.getCameraImage($);H.sourceTexture=ie}}}}for(let ye=0;ye<T.length;ye++){const re=k[ye],ve=T[ye];re!==null&&ve!==void 0&&ve.update(re,xe,u||a)}ee&&ee(de,xe),xe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:xe}),x=null}const fe=new uZ;fe.setAnimationLoop(ae),this.setAnimationLoop=function(de){ee=de},this.dispose=function(){}}};const Gd=new cd,SDe=new ti;function EDe(t,e){function n(v,b){v.matrixAutoUpdate===!0&&v.updateMatrix(),b.value.copy(v.matrix)}function r(v,b){b.color.getRGB(v.fogColor.value,tZ(t)),b.isFog?(v.fogNear.value=b.near,v.fogFar.value=b.far):b.isFogExp2&&(v.fogDensity.value=b.density)}function i(v,b,E,S,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?s(v,b):b.isMeshToonMaterial?(s(v,b),f(v,b)):b.isMeshPhongMaterial?(s(v,b),d(v,b)):b.isMeshStandardMaterial?(s(v,b),g(v,b),b.isMeshPhysicalMaterial&&m(v,b,A)):b.isMeshMatcapMaterial?(s(v,b),x(v,b)):b.isMeshDepthMaterial?s(v,b):b.isMeshDistanceMaterial?(s(v,b),y(v,b)):b.isMeshNormalMaterial?s(v,b):b.isLineBasicMaterial?(a(v,b),b.isLineDashedMaterial&&o(v,b)):b.isPointsMaterial?l(v,b,E,S):b.isSpriteMaterial?u(v,b):b.isShadowMaterial?(v.color.value.copy(b.color),v.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function s(v,b){v.opacity.value=b.opacity,b.color&&v.diffuse.value.copy(b.color),b.emissive&&v.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.bumpMap&&(v.bumpMap.value=b.bumpMap,n(b.bumpMap,v.bumpMapTransform),v.bumpScale.value=b.bumpScale,b.side===Gs&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===Gs&&v.normalScale.value.negate()),b.displacementMap&&(v.displacementMap.value=b.displacementMap,n(b.displacementMap,v.displacementMapTransform),v.displacementScale.value=b.displacementScale,v.displacementBias.value=b.displacementBias),b.emissiveMap&&(v.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,v.emissiveMapTransform)),b.specularMap&&(v.specularMap.value=b.specularMap,n(b.specularMap,v.specularMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest);const E=e.get(b),S=E.envMap,A=E.envMapRotation;S&&(v.envMap.value=S,Gd.copy(A),Gd.x*=-1,Gd.y*=-1,Gd.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Gd.y*=-1,Gd.z*=-1),v.envMapRotation.value.setFromMatrix4(SDe.makeRotationFromEuler(Gd)),v.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=b.reflectivity,v.ior.value=b.ior,v.refractionRatio.value=b.refractionRatio),b.lightMap&&(v.lightMap.value=b.lightMap,v.lightMapIntensity.value=b.lightMapIntensity,n(b.lightMap,v.lightMapTransform)),b.aoMap&&(v.aoMap.value=b.aoMap,v.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,v.aoMapTransform))}function a(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform))}function o(v,b){v.dashSize.value=b.dashSize,v.totalSize.value=b.dashSize+b.gapSize,v.scale.value=b.scale}function l(v,b,E,S){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*E,v.scale.value=S*.5,b.map&&(v.map.value=b.map,n(b.map,v.uvTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function u(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.rotation.value=b.rotation,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function d(v,b){v.specular.value.copy(b.specular),v.shininess.value=Math.max(b.shininess,1e-4)}function f(v,b){b.gradientMap&&(v.gradientMap.value=b.gradientMap)}function g(v,b){v.metalness.value=b.metalness,b.metalnessMap&&(v.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,v.metalnessMapTransform)),v.roughness.value=b.roughness,b.roughnessMap&&(v.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,v.roughnessMapTransform)),b.envMap&&(v.envMapIntensity.value=b.envMapIntensity)}function m(v,b,E){v.ior.value=b.ior,b.sheen>0&&(v.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),v.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(v.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,v.sheenColorMapTransform)),b.sheenRoughnessMap&&(v.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,v.sheenRoughnessMapTransform))),b.clearcoat>0&&(v.clearcoat.value=b.clearcoat,v.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(v.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,v.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(v.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Gs&&v.clearcoatNormalScale.value.negate())),b.dispersion>0&&(v.dispersion.value=b.dispersion),b.iridescence>0&&(v.iridescence.value=b.iridescence,v.iridescenceIOR.value=b.iridescenceIOR,v.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(v.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,v.iridescenceMapTransform)),b.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),b.transmission>0&&(v.transmission.value=b.transmission,v.transmissionSamplerMap.value=E.texture,v.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(v.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,v.transmissionMapTransform)),v.thickness.value=b.thickness,b.thicknessMap&&(v.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=b.attenuationDistance,v.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(v.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(v.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=b.specularIntensity,v.specularColor.value.copy(b.specularColor),b.specularColorMap&&(v.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,v.specularColorMapTransform)),b.specularIntensityMap&&(v.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,b){b.matcap&&(v.matcap.value=b.matcap)}function y(v,b){const E=e.get(b).light;v.referencePosition.value.setFromMatrixPosition(E.matrixWorld),v.nearDistance.value=E.shadow.camera.near,v.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function MDe(t,e,n,r){let i={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(E,S){const A=S.program;r.uniformBlockBinding(E,A)}function u(E,S){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",v));const T=S.program;r.updateUBOMapping(E,T);const k=e.render.frame;s[E.id]!==k&&(g(E),s[E.id]=k)}function d(E){const S=f();E.__bindingPointIndex=S;const A=t.createBuffer(),T=E.__size,k=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let E=0;E<o;E++)if(a.indexOf(E)===-1)return a.push(E),E;return Ur("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const S=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,N=A.length;k<N;k++){const I=Array.isArray(A[k])?A[k]:[A[k]];for(let C=0,D=I.length;C<D;C++){const F=I[C];if(m(F,k,C,T)===!0){const j=F.__offset,q=Array.isArray(F.value)?F.value:[F.value];let R=0;for(let W=0;W<q.length;W++){const K=q[W],V=y(K);typeof K=="number"||typeof K=="boolean"?(F.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,j+R,F.__data)):K.isMatrix3?(F.__data[0]=K.elements[0],F.__data[1]=K.elements[1],F.__data[2]=K.elements[2],F.__data[3]=0,F.__data[4]=K.elements[3],F.__data[5]=K.elements[4],F.__data[6]=K.elements[5],F.__data[7]=0,F.__data[8]=K.elements[6],F.__data[9]=K.elements[7],F.__data[10]=K.elements[8],F.__data[11]=0):(K.toArray(F.__data,R),R+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,j,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(E,S,A,T){const k=E.value,N=S+"_"+A;if(T[N]===void 0)return typeof k=="number"||typeof k=="boolean"?T[N]=k:T[N]=k.clone(),!0;{const I=T[N];if(typeof k=="number"||typeof k=="boolean"){if(I!==k)return T[N]=k,!0}else if(I.equals(k)===!1)return I.copy(k),!0}return!1}function x(E){const S=E.uniforms;let A=0;const T=16;for(let N=0,I=S.length;N<I;N++){const C=Array.isArray(S[N])?S[N]:[S[N]];for(let D=0,F=C.length;D<F;D++){const j=C[D],q=Array.isArray(j.value)?j.value:[j.value];for(let R=0,W=q.length;R<W;R++){const K=q[R],V=y(K),te=A%T,Y=te%V.boundary,Z=te+Y;A+=Y,Z!==0&&T-Z<V.storage&&(A+=T-Z),j.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=A,A+=V.storage}}}const k=A%T;return k>0&&(A+=T-k),E.__size=A,E.__cache={},this}function y(E){const S={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(S.boundary=4,S.storage=4):E.isVector2?(S.boundary=8,S.storage=8):E.isVector3||E.isColor?(S.boundary=16,S.storage=12):E.isVector4?(S.boundary=16,S.storage=16):E.isMatrix3?(S.boundary=48,S.storage=48):E.isMatrix4?(S.boundary=64,S.storage=64):E.isTexture?Xt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Xt("WebGLRenderer: Unsupported uniform value type.",E),S}function v(E){const S=E.target;S.removeEventListener("dispose",v);const A=a.indexOf(S.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete s[S.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);a=[],i={},s={}}return{bind:l,update:u,dispose:b}}const ADe=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 ql=null;function TDe(){return ql===null&&(ql=new TNe(ADe,32,32,KO,Jm),ql.minFilter=Ja,ql.magFilter=Ja,ql.wrapS=fc,ql.wrapT=fc,ql.generateMipmaps=!1,ql.needsUpdate=!0),ql}let CDe=class{constructor(e={}){const{canvas:n=QCe(),context:r=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=a;const x=new Set([YO,XO,qO]),y=new Set([pl,Kh,j0,L0,GO,WO]),v=new Uint32Array(4),b=new Int32Array(4);let E=null,S=null;const A=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Wu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let N=!1;this._outputColorSpace=$a;let I=0,C=0,D=null,F=-1,j=null;const q=new Kr,R=new Kr;let W=null;const K=new yn(0);let V=0,te=n.width,Y=n.height,Z=1,U=null,z=null;const ee=new Kr(0,0,te,Y),ae=new Kr(0,0,te,Y);let fe=!1;const de=new tj;let xe=!1,ye=!1;const re=new ti,ve=new Je,je=new Kr,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ut=!1;function $(){return D===null?Z:1}let H=r;function ie(se,Ee){return n.getContext(se,Ee)}try{const se={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${HO}`),n.addEventListener("webglcontextlost",Ce,!1),n.addEventListener("webglcontextrestored",_e,!1),n.addEventListener("webglcontextcreationerror",He,!1),H===null){const Ee="webgl2";if(H=ie(Ee,se),H===null)throw ie(Ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(se){throw se("WebGLRenderer: "+se.message),se}let G,J,le,ke,Ne,Se,B,L,ne,be,we,ge,me,Ae,ze,st,Ve,ce,Ye,$e,Ze,at,Q,Fe;function pe(){G=new LPe(H),G.init(),at=new bDe(H,G),J=new TPe(H,G,e,at),le=new gDe(H,G),J.reversedDepthBuffer&&g&&le.buffers.depth.setReversed(!0),ke=new FPe(H),Ne=new rDe,Se=new xDe(H,G,le,Ne,J,at,ke),B=new NPe(k),L=new jPe(k),ne=new $Ne(H),Q=new MPe(H,ne),be=new IPe(H,ne,ke,Q),we=new BPe(H,be,ne,ke),Ye=new zPe(H,J,Se),st=new CPe(Ne),ge=new nDe(k,B,L,G,J,Q,st),me=new EDe(k,Ne),Ae=new sDe,ze=new dDe(G),ce=new EPe(k,B,L,le,we,m,l),Ve=new pDe(k,we,J),Fe=new MDe(H,ke,J,le),$e=new APe(H,G,ke),Ze=new UPe(H,G,ke),ke.programs=ge.programs,k.capabilities=J,k.extensions=G,k.properties=Ne,k.renderLists=Ae,k.shadowMap=Ve,k.state=le,k.info=ke}pe();const Ue=new wDe(k,H);this.xr=Ue,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const se=G.get("WEBGL_lose_context");se&&se.loseContext()},this.forceContextRestore=function(){const se=G.get("WEBGL_lose_context");se&&se.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(se){se!==void 0&&(Z=se,this.setSize(te,Y,!1))},this.getSize=function(se){return se.set(te,Y)},this.setSize=function(se,Ee,Le=!0){if(Ue.isPresenting){Xt("WebGLRenderer: Can't change size while VR device is presenting.");return}te=se,Y=Ee,n.width=Math.floor(se*Z),n.height=Math.floor(Ee*Z),Le===!0&&(n.style.width=se+"px",n.style.height=Ee+"px"),this.setViewport(0,0,se,Ee)},this.getDrawingBufferSize=function(se){return se.set(te*Z,Y*Z).floor()},this.setDrawingBufferSize=function(se,Ee,Le){te=se,Y=Ee,Z=Le,n.width=Math.floor(se*Le),n.height=Math.floor(Ee*Le),this.setViewport(0,0,se,Ee)},this.getCurrentViewport=function(se){return se.copy(q)},this.getViewport=function(se){return se.copy(ee)},this.setViewport=function(se,Ee,Le,Oe){se.isVector4?ee.set(se.x,se.y,se.z,se.w):ee.set(se,Ee,Le,Oe),le.viewport(q.copy(ee).multiplyScalar(Z).round())},this.getScissor=function(se){return se.copy(ae)},this.setScissor=function(se,Ee,Le,Oe){se.isVector4?ae.set(se.x,se.y,se.z,se.w):ae.set(se,Ee,Le,Oe),le.scissor(R.copy(ae).multiplyScalar(Z).round())},this.getScissorTest=function(){return fe},this.setScissorTest=function(se){le.setScissorTest(fe=se)},this.setOpaqueSort=function(se){U=se},this.setTransparentSort=function(se){z=se},this.getClearColor=function(se){return se.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor(...arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha(...arguments)},this.clear=function(se=!0,Ee=!0,Le=!0){let Oe=0;if(se){let Te=!1;if(D!==null){const ot=D.texture.format;Te=x.has(ot)}if(Te){const ot=D.texture.type,ft=y.has(ot),bt=ce.getClearColor(),xt=ce.getClearAlpha(),jt=bt.r,Mt=bt.g,mt=bt.b;ft?(v[0]=jt,v[1]=Mt,v[2]=mt,v[3]=xt,H.clearBufferuiv(H.COLOR,0,v)):(b[0]=jt,b[1]=Mt,b[2]=mt,b[3]=xt,H.clearBufferiv(H.COLOR,0,b))}else Oe|=H.COLOR_BUFFER_BIT}Ee&&(Oe|=H.DEPTH_BUFFER_BIT),Le&&(Oe|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(Oe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Ce,!1),n.removeEventListener("webglcontextrestored",_e,!1),n.removeEventListener("webglcontextcreationerror",He,!1),ce.dispose(),Ae.dispose(),ze.dispose(),Ne.dispose(),B.dispose(),L.dispose(),we.dispose(),Q.dispose(),Fe.dispose(),ge.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",Qn),Ue.removeEventListener("sessionend",wi),si.stop()};function Ce(se){se.preventDefault(),k8("WebGLRenderer: Context Lost."),N=!0}function _e(){k8("WebGLRenderer: Context Restored."),N=!1;const se=ke.autoReset,Ee=Ve.enabled,Le=Ve.autoUpdate,Oe=Ve.needsUpdate,Te=Ve.type;pe(),ke.autoReset=se,Ve.enabled=Ee,Ve.autoUpdate=Le,Ve.needsUpdate=Oe,Ve.type=Te}function He(se){Ur("WebGLRenderer: A WebGL context could not be created. Reason: ",se.statusMessage)}function ht(se){const Ee=se.target;Ee.removeEventListener("dispose",ht),wt(Ee)}function wt(se){Ot(se),Ne.remove(se)}function Ot(se){const Ee=Ne.get(se).programs;Ee!==void 0&&(Ee.forEach(function(Le){ge.releaseProgram(Le)}),se.isShaderMaterial&&ge.releaseShaderCache(se))}this.renderBufferDirect=function(se,Ee,Le,Oe,Te,ot){Ee===null&&(Ee=ue);const ft=Te.isMesh&&Te.matrixWorld.determinant()<0,bt=he(se,Ee,Le,Oe,Te);le.setMaterial(Oe,ft);let xt=Le.index,jt=1;if(Oe.wireframe===!0){if(xt=be.getWireframeAttribute(Le),xt===void 0)return;jt=2}const Mt=Le.drawRange,mt=Le.attributes.position;let Kt=Mt.start*jt,Ft=(Mt.start+Mt.count)*jt;ot!==null&&(Kt=Math.max(Kt,ot.start*jt),Ft=Math.min(Ft,(ot.start+ot.count)*jt)),xt!==null?(Kt=Math.max(Kt,0),Ft=Math.min(Ft,xt.count)):mt!=null&&(Kt=Math.max(Kt,0),Ft=Math.min(Ft,mt.count));const nn=Ft-Kt;if(nn<0||nn===1/0)return;Q.setup(Te,Oe,bt,Le,xt);let dn,xn=$e;if(xt!==null&&(dn=ne.get(xt),xn=Ze,xn.setIndex(dn)),Te.isMesh)Oe.wireframe===!0?(le.setLineWidth(Oe.wireframeLinewidth*$()),xn.setMode(H.LINES)):xn.setMode(H.TRIANGLES);else if(Te.isLine){let Ut=Oe.linewidth;Ut===void 0&&(Ut=1),le.setLineWidth(Ut*$()),Te.isLineSegments?xn.setMode(H.LINES):Te.isLineLoop?xn.setMode(H.LINE_LOOP):xn.setMode(H.LINE_STRIP)}else Te.isPoints?xn.setMode(H.POINTS):Te.isSprite&&xn.setMode(H.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)F0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),xn.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(G.get("WEBGL_multi_draw"))xn.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const Ut=Te._multiDrawStarts,Zt=Te._multiDrawCounts,Jt=Te._multiDrawCount,Mr=xt?ne.get(xt).bytesPerElement:1,Or=Ne.get(Oe).currentProgram.getUniforms();for(let Pn=0;Pn<Jt;Pn++)Or.setValue(H,"_gl_DrawID",Pn),xn.render(Ut[Pn]/Mr,Zt[Pn])}else if(Te.isInstancedMesh)xn.renderInstances(Kt,nn,Te.count);else if(Le.isInstancedBufferGeometry){const Ut=Le._maxInstanceCount!==void 0?Le._maxInstanceCount:1/0,Zt=Math.min(Le.instanceCount,Ut);xn.renderInstances(Kt,nn,Zt)}else xn.render(Kt,nn)};function cn(se,Ee,Le){se.transparent===!0&&se.side===tl&&se.forceSinglePass===!1?(se.side=Gs,se.needsUpdate=!0,Dr(se,Ee,Le),se.side=ld,se.needsUpdate=!0,Dr(se,Ee,Le),se.side=tl):Dr(se,Ee,Le)}this.compile=function(se,Ee,Le=null){Le===null&&(Le=se),S=ze.get(Le),S.init(Ee),T.push(S),Le.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Ee.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),se!==Le&&se.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Ee.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),S.setupLights();const Oe=new Set;return se.traverse(function(Te){if(!(Te.isMesh||Te.isPoints||Te.isLine||Te.isSprite))return;const ot=Te.material;if(ot)if(Array.isArray(ot))for(let ft=0;ft<ot.length;ft++){const bt=ot[ft];cn(bt,Le,Te),Oe.add(bt)}else cn(ot,Le,Te),Oe.add(ot)}),S=T.pop(),Oe},this.compileAsync=function(se,Ee,Le=null){const Oe=this.compile(se,Ee,Le);return new Promise(Te=>{function ot(){if(Oe.forEach(function(ft){Ne.get(ft).currentProgram.isReady()&&Oe.delete(ft)}),Oe.size===0){Te(se);return}setTimeout(ot,10)}G.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let It=null;function Dn(se){It&&It(se)}function Qn(){si.stop()}function wi(){si.start()}const si=new uZ;si.setAnimationLoop(Dn),typeof self<"u"&&si.setContext(self),this.setAnimationLoop=function(se){It=se,Ue.setAnimationLoop(se),se===null?si.stop():si.start()},Ue.addEventListener("sessionstart",Qn),Ue.addEventListener("sessionend",wi),this.render=function(se,Ee){if(Ee!==void 0&&Ee.isCamera!==!0){Ur("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(se.matrixWorldAutoUpdate===!0&&se.updateMatrixWorld(),Ee.parent===null&&Ee.matrixWorldAutoUpdate===!0&&Ee.updateMatrixWorld(),Ue.enabled===!0&&Ue.isPresenting===!0&&(Ue.cameraAutoUpdate===!0&&Ue.updateCamera(Ee),Ee=Ue.getCamera()),se.isScene===!0&&se.onBeforeRender(k,se,Ee,D),S=ze.get(se,T.length),S.init(Ee),T.push(S),re.multiplyMatrices(Ee.projectionMatrix,Ee.matrixWorldInverse),de.setFromProjectionMatrix(re,sl,Ee.reversedDepth),ye=this.localClippingEnabled,xe=st.init(this.clippingPlanes,ye),E=Ae.get(se,A.length),E.init(),A.push(E),Ue.enabled===!0&&Ue.isPresenting===!0){const ot=k.xr.getDepthSensingMesh();ot!==null&&Si(ot,Ee,-1/0,k.sortObjects)}Si(se,Ee,0,k.sortObjects),E.finish(),k.sortObjects===!0&&E.sort(U,z),ut=Ue.enabled===!1||Ue.isPresenting===!1||Ue.hasDepthSensing()===!1,ut&&ce.addToRenderList(E,se),this.info.render.frame++,xe===!0&&st.beginShadows();const Le=S.state.shadowsArray;Ve.render(Le,se,Ee),xe===!0&&st.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=E.opaque,Te=E.transmissive;if(S.setupLights(),Ee.isArrayCamera){const ot=Ee.cameras;if(Te.length>0)for(let ft=0,bt=ot.length;ft<bt;ft++){const xt=ot[ft];ts(Oe,Te,se,xt)}ut&&ce.render(se);for(let ft=0,bt=ot.length;ft<bt;ft++){const xt=ot[ft];Ui(E,se,xt,xt.viewport)}}else Te.length>0&&ts(Oe,Te,se,Ee),ut&&ce.render(se),Ui(E,se,Ee);D!==null&&C===0&&(Se.updateMultisampleRenderTarget(D),Se.updateRenderTargetMipmap(D)),se.isScene===!0&&se.onAfterRender(k,se,Ee),Q.resetDefaultState(),F=-1,j=null,T.pop(),T.length>0?(S=T[T.length-1],xe===!0&&st.setGlobalState(k.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Si(se,Ee,Le,Oe){if(se.visible===!1)return;if(se.layers.test(Ee.layers)){if(se.isGroup)Le=se.renderOrder;else if(se.isLOD)se.autoUpdate===!0&&se.update(Ee);else if(se.isLight)S.pushLight(se),se.castShadow&&S.pushShadow(se);else if(se.isSprite){if(!se.frustumCulled||de.intersectsSprite(se)){Oe&&je.setFromMatrixPosition(se.matrixWorld).applyMatrix4(re);const ft=we.update(se),bt=se.material;bt.visible&&E.push(se,ft,bt,Le,je.z,null)}}else if((se.isMesh||se.isLine||se.isPoints)&&(!se.frustumCulled||de.intersectsObject(se))){const ft=we.update(se),bt=se.material;if(Oe&&(se.boundingSphere!==void 0?(se.boundingSphere===null&&se.computeBoundingSphere(),je.copy(se.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),je.copy(ft.boundingSphere.center)),je.applyMatrix4(se.matrixWorld).applyMatrix4(re)),Array.isArray(bt)){const xt=ft.groups;for(let jt=0,Mt=xt.length;jt<Mt;jt++){const mt=xt[jt],Kt=bt[mt.materialIndex];Kt&&Kt.visible&&E.push(se,ft,Kt,Le,je.z,mt)}}else bt.visible&&E.push(se,ft,bt,Le,je.z,null)}}const ot=se.children;for(let ft=0,bt=ot.length;ft<bt;ft++)Si(ot[ft],Ee,Le,Oe)}function Ui(se,Ee,Le,Oe){const{opaque:Te,transmissive:ot,transparent:ft}=se;S.setupLightsView(Le),xe===!0&&st.setGlobalState(k.clippingPlanes,Le),Oe&&le.viewport(q.copy(Oe)),Te.length>0&&zr(Te,Ee,Le),ot.length>0&&zr(ot,Ee,Le),ft.length>0&&zr(ft,Ee,Le),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function ts(se,Ee,Le,Oe){if((Le.isScene===!0?Le.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[Oe.id]===void 0&&(S.state.transmissionRenderTarget[Oe.id]=new Yh(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")||G.has("EXT_color_buffer_float")?Jm:pl,minFilter:hh,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Tn.workingColorSpace}));const ot=S.state.transmissionRenderTarget[Oe.id],ft=Oe.viewport||q;ot.setSize(ft.z*k.transmissionResolutionScale,ft.w*k.transmissionResolutionScale);const bt=k.getRenderTarget(),xt=k.getActiveCubeFace(),jt=k.getActiveMipmapLevel();k.setRenderTarget(ot),k.getClearColor(K),V=k.getClearAlpha(),V<1&&k.setClearColor(16777215,.5),k.clear(),ut&&ce.render(Le);const Mt=k.toneMapping;k.toneMapping=Wu;const mt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),S.setupLightsView(Oe),xe===!0&&st.setGlobalState(k.clippingPlanes,Oe),zr(se,Le,Oe),Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot),G.has("WEBGL_multisampled_render_to_texture")===!1){let Kt=!1;for(let Ft=0,nn=Ee.length;Ft<nn;Ft++){const dn=Ee[Ft],{object:xn,geometry:Ut,material:Zt,group:Jt}=dn;if(Zt.side===tl&&xn.layers.test(Oe.layers)){const Mr=Zt.side;Zt.side=Gs,Zt.needsUpdate=!0,br(xn,Le,Oe,Ut,Zt,Jt),Zt.side=Mr,Zt.needsUpdate=!0,Kt=!0}}Kt===!0&&(Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot))}k.setRenderTarget(bt,xt,jt),k.setClearColor(K,V),mt!==void 0&&(Oe.viewport=mt),k.toneMapping=Mt}function zr(se,Ee,Le){const Oe=Ee.isScene===!0?Ee.overrideMaterial:null;for(let Te=0,ot=se.length;Te<ot;Te++){const ft=se[Te],{object:bt,geometry:xt,group:jt}=ft;let Mt=ft.material;Mt.allowOverride===!0&&Oe!==null&&(Mt=Oe),bt.layers.test(Le.layers)&&br(bt,Ee,Le,xt,Mt,jt)}}function br(se,Ee,Le,Oe,Te,ot){se.onBeforeRender(k,Ee,Le,Oe,Te,ot),se.modelViewMatrix.multiplyMatrices(Le.matrixWorldInverse,se.matrixWorld),se.normalMatrix.getNormalMatrix(se.modelViewMatrix),Te.onBeforeRender(k,Ee,Le,Oe,se,ot),Te.transparent===!0&&Te.side===tl&&Te.forceSinglePass===!1?(Te.side=Gs,Te.needsUpdate=!0,k.renderBufferDirect(Le,Ee,Oe,Te,se,ot),Te.side=ld,Te.needsUpdate=!0,k.renderBufferDirect(Le,Ee,Oe,Te,se,ot),Te.side=tl):k.renderBufferDirect(Le,Ee,Oe,Te,se,ot),se.onAfterRender(k,Ee,Le,Oe,Te,ot)}function Dr(se,Ee,Le){Ee.isScene!==!0&&(Ee=ue);const Oe=Ne.get(se),Te=S.state.lights,ot=S.state.shadowsArray,ft=Te.state.version,bt=ge.getParameters(se,Te.state,ot,Ee,Le),xt=ge.getProgramCacheKey(bt);let jt=Oe.programs;Oe.environment=se.isMeshStandardMaterial?Ee.environment:null,Oe.fog=Ee.fog,Oe.envMap=(se.isMeshStandardMaterial?L:B).get(se.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&se.envMap===null?Ee.environmentRotation:se.envMapRotation,jt===void 0&&(se.addEventListener("dispose",ht),jt=new Map,Oe.programs=jt);let Mt=jt.get(xt);if(Mt!==void 0){if(Oe.currentProgram===Mt&&Oe.lightsStateVersion===ft)return zc(se,bt),Mt}else bt.uniforms=ge.getUniforms(se),se.onBeforeCompile(bt,k),Mt=ge.acquireProgram(bt,xt),jt.set(xt,Mt),Oe.uniforms=bt.uniforms;const mt=Oe.uniforms;return(!se.isShaderMaterial&&!se.isRawShaderMaterial||se.clipping===!0)&&(mt.clippingPlanes=st.uniform),zc(se,bt),Oe.needsLights=nt(se),Oe.lightsStateVersion=ft,Oe.needsLights&&(mt.ambientLightColor.value=Te.state.ambient,mt.lightProbe.value=Te.state.probe,mt.directionalLights.value=Te.state.directional,mt.directionalLightShadows.value=Te.state.directionalShadow,mt.spotLights.value=Te.state.spot,mt.spotLightShadows.value=Te.state.spotShadow,mt.rectAreaLights.value=Te.state.rectArea,mt.ltc_1.value=Te.state.rectAreaLTC1,mt.ltc_2.value=Te.state.rectAreaLTC2,mt.pointLights.value=Te.state.point,mt.pointLightShadows.value=Te.state.pointShadow,mt.hemisphereLights.value=Te.state.hemi,mt.directionalShadowMap.value=Te.state.directionalShadowMap,mt.directionalShadowMatrix.value=Te.state.directionalShadowMatrix,mt.spotShadowMap.value=Te.state.spotShadowMap,mt.spotLightMatrix.value=Te.state.spotLightMatrix,mt.spotLightMap.value=Te.state.spotLightMap,mt.pointShadowMap.value=Te.state.pointShadowMap,mt.pointShadowMatrix.value=Te.state.pointShadowMatrix),Oe.currentProgram=Mt,Oe.uniformsList=null,Mt}function uo(se){if(se.uniformsList===null){const Ee=se.currentProgram.getUniforms();se.uniformsList=s1.seqWithValue(Ee.seq,se.uniforms)}return se.uniformsList}function zc(se,Ee){const Le=Ne.get(se);Le.outputColorSpace=Ee.outputColorSpace,Le.batching=Ee.batching,Le.batchingColor=Ee.batchingColor,Le.instancing=Ee.instancing,Le.instancingColor=Ee.instancingColor,Le.instancingMorph=Ee.instancingMorph,Le.skinning=Ee.skinning,Le.morphTargets=Ee.morphTargets,Le.morphNormals=Ee.morphNormals,Le.morphColors=Ee.morphColors,Le.morphTargetsCount=Ee.morphTargetsCount,Le.numClippingPlanes=Ee.numClippingPlanes,Le.numIntersection=Ee.numClipIntersection,Le.vertexAlphas=Ee.vertexAlphas,Le.vertexTangents=Ee.vertexTangents,Le.toneMapping=Ee.toneMapping}function he(se,Ee,Le,Oe,Te){Ee.isScene!==!0&&(Ee=ue),Se.resetTextureUnits();const ot=Ee.fog,ft=Oe.isMeshStandardMaterial?Ee.environment:null,bt=D===null?k.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Sm,xt=(Oe.isMeshStandardMaterial?L:B).get(Oe.envMap||ft),jt=Oe.vertexColors===!0&&!!Le.attributes.color&&Le.attributes.color.itemSize===4,Mt=!!Le.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),mt=!!Le.morphAttributes.position,Kt=!!Le.morphAttributes.normal,Ft=!!Le.morphAttributes.color;let nn=Wu;Oe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(nn=k.toneMapping);const dn=Le.morphAttributes.position||Le.morphAttributes.normal||Le.morphAttributes.color,xn=dn!==void 0?dn.length:0,Ut=Ne.get(Oe),Zt=S.state.lights;if(xe===!0&&(ye===!0||se!==j)){const Mi=se===j&&Oe.id===F;st.setState(Oe,se,Mi)}let Jt=!1;Oe.version===Ut.__version?(Ut.needsLights&&Ut.lightsStateVersion!==Zt.state.version||Ut.outputColorSpace!==bt||Te.isBatchedMesh&&Ut.batching===!1||!Te.isBatchedMesh&&Ut.batching===!0||Te.isBatchedMesh&&Ut.batchingColor===!0&&Te.colorTexture===null||Te.isBatchedMesh&&Ut.batchingColor===!1&&Te.colorTexture!==null||Te.isInstancedMesh&&Ut.instancing===!1||!Te.isInstancedMesh&&Ut.instancing===!0||Te.isSkinnedMesh&&Ut.skinning===!1||!Te.isSkinnedMesh&&Ut.skinning===!0||Te.isInstancedMesh&&Ut.instancingColor===!0&&Te.instanceColor===null||Te.isInstancedMesh&&Ut.instancingColor===!1&&Te.instanceColor!==null||Te.isInstancedMesh&&Ut.instancingMorph===!0&&Te.morphTexture===null||Te.isInstancedMesh&&Ut.instancingMorph===!1&&Te.morphTexture!==null||Ut.envMap!==xt||Oe.fog===!0&&Ut.fog!==ot||Ut.numClippingPlanes!==void 0&&(Ut.numClippingPlanes!==st.numPlanes||Ut.numIntersection!==st.numIntersection)||Ut.vertexAlphas!==jt||Ut.vertexTangents!==Mt||Ut.morphTargets!==mt||Ut.morphNormals!==Kt||Ut.morphColors!==Ft||Ut.toneMapping!==nn||Ut.morphTargetsCount!==xn)&&(Jt=!0):(Jt=!0,Ut.__version=Oe.version);let Mr=Ut.currentProgram;Jt===!0&&(Mr=Dr(Oe,Ee,Te));let Or=!1,Pn=!1,ho=!1;const On=Mr.getUniforms(),Ei=Ut.uniforms;if(le.useProgram(Mr.program)&&(Or=!0,Pn=!0,ho=!0),Oe.id!==F&&(F=Oe.id,Pn=!0),Or||j!==se){le.buffers.depth.getReversed()&&se.reversedDepth!==!0&&(se._reversedDepth=!0,se.updateProjectionMatrix()),On.setValue(H,"projectionMatrix",se.projectionMatrix),On.setValue(H,"viewMatrix",se.matrixWorldInverse);const Fi=On.map.cameraPosition;Fi!==void 0&&Fi.setValue(H,ve.setFromMatrixPosition(se.matrixWorld)),J.logarithmicDepthBuffer&&On.setValue(H,"logDepthBufFC",2/(Math.log(se.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&On.setValue(H,"isOrthographic",se.isOrthographicCamera===!0),j!==se&&(j=se,Pn=!0,ho=!0)}if(Te.isSkinnedMesh){On.setOptional(H,Te,"bindMatrix"),On.setOptional(H,Te,"bindMatrixInverse");const Mi=Te.skeleton;Mi&&(Mi.boneTexture===null&&Mi.computeBoneTexture(),On.setValue(H,"boneTexture",Mi.boneTexture,Se))}Te.isBatchedMesh&&(On.setOptional(H,Te,"batchingTexture"),On.setValue(H,"batchingTexture",Te._matricesTexture,Se),On.setOptional(H,Te,"batchingIdTexture"),On.setValue(H,"batchingIdTexture",Te._indirectTexture,Se),On.setOptional(H,Te,"batchingColorTexture"),Te._colorsTexture!==null&&On.setValue(H,"batchingColorTexture",Te._colorsTexture,Se));const ai=Le.morphAttributes;if((ai.position!==void 0||ai.normal!==void 0||ai.color!==void 0)&&Ye.update(Te,Le,Mr),(Pn||Ut.receiveShadow!==Te.receiveShadow)&&(Ut.receiveShadow=Te.receiveShadow,On.setValue(H,"receiveShadow",Te.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Ei.envMap.value=xt,Ei.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Ee.environment!==null&&(Ei.envMapIntensity.value=Ee.environmentIntensity),Ei.dfgLUT!==void 0&&(Ei.dfgLUT.value=TDe()),Pn&&(On.setValue(H,"toneMappingExposure",k.toneMappingExposure),Ut.needsLights&&Ge(Ei,ho),ot&&Oe.fog===!0&&me.refreshFogUniforms(Ei,ot),me.refreshMaterialUniforms(Ei,Oe,Z,Y,S.state.transmissionRenderTarget[se.id]),s1.upload(H,uo(Ut),Ei,Se)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(s1.upload(H,uo(Ut),Ei,Se),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&On.setValue(H,"center",Te.center),On.setValue(H,"modelViewMatrix",Te.modelViewMatrix),On.setValue(H,"normalMatrix",Te.normalMatrix),On.setValue(H,"modelMatrix",Te.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Mi=Oe.uniformsGroups;for(let Fi=0,Ho=Mi.length;Fi<Ho;Fi++){const El=Mi[Fi];Fe.update(El,Mr),Fe.bind(El,Mr)}}return Mr}function Ge(se,Ee){se.ambientLightColor.needsUpdate=Ee,se.lightProbe.needsUpdate=Ee,se.directionalLights.needsUpdate=Ee,se.directionalLightShadows.needsUpdate=Ee,se.pointLights.needsUpdate=Ee,se.pointLightShadows.needsUpdate=Ee,se.spotLights.needsUpdate=Ee,se.spotLightShadows.needsUpdate=Ee,se.rectAreaLights.needsUpdate=Ee,se.hemisphereLights.needsUpdate=Ee}function nt(se){return se.isMeshLambertMaterial||se.isMeshToonMaterial||se.isMeshPhongMaterial||se.isMeshStandardMaterial||se.isShadowMaterial||se.isShaderMaterial&&se.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(se,Ee,Le){const Oe=Ne.get(se);Oe.__autoAllocateDepthBuffer=se.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),Ne.get(se.texture).__webglTexture=Ee,Ne.get(se.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:Le,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(se,Ee){const Le=Ne.get(se);Le.__webglFramebuffer=Ee,Le.__useDefaultFramebuffer=Ee===void 0};const rt=H.createFramebuffer();this.setRenderTarget=function(se,Ee=0,Le=0){D=se,I=Ee,C=Le;let Oe=!0,Te=null,ot=!1,ft=!1;if(se){const xt=Ne.get(se);if(xt.__useDefaultFramebuffer!==void 0)le.bindFramebuffer(H.FRAMEBUFFER,null),Oe=!1;else if(xt.__webglFramebuffer===void 0)Se.setupRenderTarget(se);else if(xt.__hasExternalTextures)Se.rebindTextures(se,Ne.get(se.texture).__webglTexture,Ne.get(se.depthTexture).__webglTexture);else if(se.depthBuffer){const mt=se.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Ne.has(mt)&&(se.width!==mt.image.width||se.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(se)}}const jt=se.texture;(jt.isData3DTexture||jt.isDataArrayTexture||jt.isCompressedArrayTexture)&&(ft=!0);const Mt=Ne.get(se).__webglFramebuffer;se.isWebGLCubeRenderTarget?(Array.isArray(Mt[Ee])?Te=Mt[Ee][Le]:Te=Mt[Ee],ot=!0):se.samples>0&&Se.useMultisampledRTT(se)===!1?Te=Ne.get(se).__webglMultisampledFramebuffer:Array.isArray(Mt)?Te=Mt[Le]:Te=Mt,q.copy(se.viewport),R.copy(se.scissor),W=se.scissorTest}else q.copy(ee).multiplyScalar(Z).floor(),R.copy(ae).multiplyScalar(Z).floor(),W=fe;if(Le!==0&&(Te=rt),le.bindFramebuffer(H.FRAMEBUFFER,Te)&&Oe&&le.drawBuffers(se,Te),le.viewport(q),le.scissor(R),le.setScissorTest(W),ot){const xt=Ne.get(se.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,xt.__webglTexture,Le)}else if(ft){const xt=Ee;for(let jt=0;jt<se.textures.length;jt++){const Mt=Ne.get(se.textures[jt]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+jt,Mt.__webglTexture,Le,xt)}}else if(se!==null&&Le!==0){const xt=Ne.get(se.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,xt.__webglTexture,Le)}F=-1},this.readRenderTargetPixels=function(se,Ee,Le,Oe,Te,ot,ft,bt=0){if(!(se&&se.isWebGLRenderTarget)){Ur("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ne.get(se).__webglFramebuffer;if(se.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt){le.bindFramebuffer(H.FRAMEBUFFER,xt);try{const jt=se.textures[bt],Mt=jt.format,mt=jt.type;if(!J.textureFormatReadable(Mt)){Ur("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!J.textureTypeReadable(mt)){Ur("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ee>=0&&Ee<=se.width-Oe&&Le>=0&&Le<=se.height-Te&&(se.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+bt),H.readPixels(Ee,Le,Oe,Te,at.convert(Mt),at.convert(mt),ot))}finally{const jt=D!==null?Ne.get(D).__webglFramebuffer:null;le.bindFramebuffer(H.FRAMEBUFFER,jt)}}},this.readRenderTargetPixelsAsync=async function(se,Ee,Le,Oe,Te,ot,ft,bt=0){if(!(se&&se.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ne.get(se).__webglFramebuffer;if(se.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt)if(Ee>=0&&Ee<=se.width-Oe&&Le>=0&&Le<=se.height-Te){le.bindFramebuffer(H.FRAMEBUFFER,xt);const jt=se.textures[bt],Mt=jt.format,mt=jt.type;if(!J.textureFormatReadable(Mt))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 Kt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,Kt),H.bufferData(H.PIXEL_PACK_BUFFER,ot.byteLength,H.STREAM_READ),se.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+bt),H.readPixels(Ee,Le,Oe,Te,at.convert(Mt),at.convert(mt),0);const Ft=D!==null?Ne.get(D).__webglFramebuffer:null;le.bindFramebuffer(H.FRAMEBUFFER,Ft);const nn=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await JCe(H,nn,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,Kt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,ot),H.deleteBuffer(Kt),H.deleteSync(nn),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(se,Ee=null,Le=0){const Oe=Math.pow(2,-Le),Te=Math.floor(se.image.width*Oe),ot=Math.floor(se.image.height*Oe),ft=Ee!==null?Ee.x:0,bt=Ee!==null?Ee.y:0;Se.setTexture2D(se,0),H.copyTexSubImage2D(H.TEXTURE_2D,Le,0,0,ft,bt,Te,ot),le.unbindTexture()};const et=H.createFramebuffer(),St=H.createFramebuffer();this.copyTextureToTexture=function(se,Ee,Le=null,Oe=null,Te=0,ot=null){ot===null&&(Te!==0?(F0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ot=Te,Te=0):ot=0);let ft,bt,xt,jt,Mt,mt,Kt,Ft,nn;const dn=se.isCompressedTexture?se.mipmaps[ot]:se.image;if(Le!==null)ft=Le.max.x-Le.min.x,bt=Le.max.y-Le.min.y,xt=Le.isBox3?Le.max.z-Le.min.z:1,jt=Le.min.x,Mt=Le.min.y,mt=Le.isBox3?Le.min.z:0;else{const ai=Math.pow(2,-Te);ft=Math.floor(dn.width*ai),bt=Math.floor(dn.height*ai),se.isDataArrayTexture?xt=dn.depth:se.isData3DTexture?xt=Math.floor(dn.depth*ai):xt=1,jt=0,Mt=0,mt=0}Oe!==null?(Kt=Oe.x,Ft=Oe.y,nn=Oe.z):(Kt=0,Ft=0,nn=0);const xn=at.convert(Ee.format),Ut=at.convert(Ee.type);let Zt;Ee.isData3DTexture?(Se.setTexture3D(Ee,0),Zt=H.TEXTURE_3D):Ee.isDataArrayTexture||Ee.isCompressedArrayTexture?(Se.setTexture2DArray(Ee,0),Zt=H.TEXTURE_2D_ARRAY):(Se.setTexture2D(Ee,0),Zt=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Ee.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ee.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Ee.unpackAlignment);const Jt=H.getParameter(H.UNPACK_ROW_LENGTH),Mr=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Or=H.getParameter(H.UNPACK_SKIP_PIXELS),Pn=H.getParameter(H.UNPACK_SKIP_ROWS),ho=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,dn.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,dn.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,jt),H.pixelStorei(H.UNPACK_SKIP_ROWS,Mt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,mt);const On=se.isDataArrayTexture||se.isData3DTexture,Ei=Ee.isDataArrayTexture||Ee.isData3DTexture;if(se.isDepthTexture){const ai=Ne.get(se),Mi=Ne.get(Ee),Fi=Ne.get(ai.__renderTarget),Ho=Ne.get(Mi.__renderTarget);le.bindFramebuffer(H.READ_FRAMEBUFFER,Fi.__webglFramebuffer),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,Ho.__webglFramebuffer);for(let El=0;El<xt;El++)On&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ne.get(se).__webglTexture,Te,mt+El),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ne.get(Ee).__webglTexture,ot,nn+El)),H.blitFramebuffer(jt,Mt,ft,bt,Kt,Ft,ft,bt,H.DEPTH_BUFFER_BIT,H.NEAREST);le.bindFramebuffer(H.READ_FRAMEBUFFER,null),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(Te!==0||se.isRenderTargetTexture||Ne.has(se)){const ai=Ne.get(se),Mi=Ne.get(Ee);le.bindFramebuffer(H.READ_FRAMEBUFFER,et),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,St);for(let Fi=0;Fi<xt;Fi++)On?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,ai.__webglTexture,Te,mt+Fi):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,ai.__webglTexture,Te),Ei?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Mi.__webglTexture,ot,nn+Fi):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Mi.__webglTexture,ot),Te!==0?H.blitFramebuffer(jt,Mt,ft,bt,Kt,Ft,ft,bt,H.COLOR_BUFFER_BIT,H.NEAREST):Ei?H.copyTexSubImage3D(Zt,ot,Kt,Ft,nn+Fi,jt,Mt,ft,bt):H.copyTexSubImage2D(Zt,ot,Kt,Ft,jt,Mt,ft,bt);le.bindFramebuffer(H.READ_FRAMEBUFFER,null),le.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Ei?se.isDataTexture||se.isData3DTexture?H.texSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,xn,Ut,dn.data):Ee.isCompressedArrayTexture?H.compressedTexSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,xn,dn.data):H.texSubImage3D(Zt,ot,Kt,Ft,nn,ft,bt,xt,xn,Ut,dn):se.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,ot,Kt,Ft,ft,bt,xn,Ut,dn.data):se.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,ot,Kt,Ft,dn.width,dn.height,xn,dn.data):H.texSubImage2D(H.TEXTURE_2D,ot,Kt,Ft,ft,bt,xn,Ut,dn);H.pixelStorei(H.UNPACK_ROW_LENGTH,Jt),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Mr),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Or),H.pixelStorei(H.UNPACK_SKIP_ROWS,Pn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,ho),ot===0&&Ee.generateMipmaps&&H.generateMipmap(Zt),le.unbindTexture()},this.initRenderTarget=function(se){Ne.get(se).__webglFramebuffer===void 0&&Se.setupRenderTarget(se)},this.initTexture=function(se){se.isCubeTexture?Se.setTextureCube(se,0):se.isData3DTexture?Se.setTexture3D(se,0):se.isDataArrayTexture||se.isCompressedArrayTexture?Se.setTexture2DArray(se,0):Se.setTexture2D(se,0),le.unbindTexture()},this.resetState=function(){I=0,C=0,D=null,le.reset(),Q.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return sl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Tn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Tn._getUnpackColorSpace()}};const MH={type:"change"},rj={type:"start"},mZ={type:"end"},Xy=new QO,AH=new Tu,NDe=Math.cos(70*tNe.DEG2RAD),li=new Je,zs=2*Math.PI,Xn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},UC=1e-6;class kDe extends BNe{constructor(e,n=null){super(e,n),this.state=Xn.NONE,this.target=new Je,this.cursor=new Je,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:Qp.ROTATE,MIDDLE:Qp.DOLLY,RIGHT:Qp.PAN},this.touches={ONE:Vp.ROTATE,TWO:Vp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Je,this._lastQuaternion=new Xh,this._lastTargetPosition=new Je,this._quat=new Xh().setFromUnitVectors(e.up,new Je(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new eH,this._sphericalDelta=new eH,this._scale=1,this._panOffset=new Je,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 Je,this._mouse=new on,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=RDe.bind(this),this._onPointerDown=PDe.bind(this),this._onPointerUp=DDe.bind(this),this._onContextMenu=zDe.bind(this),this._onMouseWheel=LDe.bind(this),this._onKeyDown=IDe.bind(this),this._onTouchStart=UDe.bind(this),this._onTouchMove=FDe.bind(this),this._onMouseDown=ODe.bind(this),this._onMouseMove=jDe.bind(this),this._interceptControlDown=BDe.bind(this),this._interceptControlUp=HDe.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(MH),this.update(),this.state=Xn.NONE}update(e=null){const n=this.object.position;li.copy(n).sub(this.target),li.applyQuaternion(this._quat),this._spherical.setFromVector3(li),this.autoRotate&&this.state===Xn.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+=zs:r>Math.PI&&(r-=zs),i<-Math.PI?i+=zs:i>Math.PI&&(i-=zs),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(li.setFromSpherical(this._spherical),li.applyQuaternion(this._quatInverse),n.copy(this.target).add(li),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=li.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 Je(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 u=new Je(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(o),this.object.updateMatrixWorld(),a=li.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):(Xy.origin.copy(this.object.position),Xy.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Xy.direction))<NDe?this.object.lookAt(this.target):(AH.setFromNormalAndCoplanarPoint(this.object.up,this.target),Xy.intersectPlane(AH,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)>UC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>UC||this._lastTargetPosition.distanceToSquared(this.target)>UC?(this.dispatchEvent(MH),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?zs/60*this.autoRotateSpeed*e:zs/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){li.setFromMatrixColumn(n,0),li.multiplyScalar(-e),this._panOffset.add(li)}_panUp(e,n){this.screenSpacePanning===!0?li.setFromMatrixColumn(n,1):(li.setFromMatrixColumn(n,0),li.crossVectors(this.object.up,li)),li.multiplyScalar(e),this._panOffset.add(li)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;li.copy(i).sub(this.target);let s=li.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(zs*this._rotateDelta.x/n.clientHeight),this._rotateUp(zs*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(zs*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(-zs*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(zs*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(-zs*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(zs*this._rotateDelta.x/n.clientHeight),this._rotateUp(zs*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 PDe(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 RDe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function DDe(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(mZ),this.state=Xn.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 ODe(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 Qp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Xn.DOLLY;break;case Qp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Xn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Xn.ROTATE}break;case Qp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Xn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Xn.PAN}break;default:this.state=Xn.NONE}this.state!==Xn.NONE&&this.dispatchEvent(rj)}function jDe(t){switch(this.state){case Xn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Xn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Xn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function LDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Xn.NONE||(t.preventDefault(),this.dispatchEvent(rj),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(mZ))}function IDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function UDe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Vp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Xn.TOUCH_ROTATE;break;case Vp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Xn.TOUCH_PAN;break;default:this.state=Xn.NONE}break;case 2:switch(this.touches.TWO){case Vp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Xn.TOUCH_DOLLY_PAN;break;case Vp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Xn.TOUCH_DOLLY_ROTATE;break;default:this.state=Xn.NONE}break;default:this.state=Xn.NONE}this.state!==Xn.NONE&&this.dispatchEvent(rj)}function FDe(t){switch(this._trackPointer(t),this.state){case Xn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Xn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Xn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Xn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Xn.NONE}}function zDe(t){this.enabled!==!1&&t.preventDefault()}function BDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function HDe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function $De(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 Sl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(f.attributes[m]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in f.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,m,d),u+=m}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const m=t[g].index;for(let x=0;x<m.count;++x)f.push(m.getX(x)+d);d+=t[g].attributes.position.count}l.setIndex(f)}for(const d in s){const f=TH(s[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,f)}for(const d in a){const f=a[d][0].length;if(f===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let g=0;g<f;++g){const m=[];for(let y=0;y<a[d].length;++y)m.push(a[d][y][g]);const x=TH(m);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(x)}}return l}function TH(t){let e,n,r,i=-1,s=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=d.count*n}const a=new e(s),o=new eo(a,n,r);let l=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=l/n;for(let g=0,m=d.count;g<m;g++)for(let x=0;x<n;x++){const y=d.getComponent(g,x);o.setComponent(g+f,x,y)}}else a.set(d.array,l);l+=d.count*n}return i!==void 0&&(o.gpuType=i),o}function Yy(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 FC={exports:{}};var CH;function VDe(){return CH||(CH=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,s){function a(u,d){if(!i[u]){if(!r[u]){var f=typeof Yy=="function"&&Yy;if(!d&&f)return f(u,!0);if(o)return o(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(x){var y=r[u][1][x];return a(y||x)},m,m.exports,n,r,i,s)}return i[u].exports}for(var o=typeof Yy=="function"&&Yy,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 u,d,f,g,m,x,y,v=[],b=0,E=l.length,S=E,A=s.getTypeOf(l)!=="string";b<l.length;)S=E-b,f=A?(u=l[b++],d=b<E?l[b++]:0,b<E?l[b++]:0):(u=l.charCodeAt(b++),d=b<E?l.charCodeAt(b++):0,b<E?l.charCodeAt(b++):0),g=u>>2,m=(3&u)<<4|d>>4,x=1<S?(15&d)<<2|f>>6:64,y=2<S?63&f:64,v.push(o.charAt(g)+o.charAt(m)+o.charAt(x)+o.charAt(y));return v.join("")},i.decode=function(l){var u,d,f,g,m,x,y=0,v=0,b="data:";if(l.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var E,S=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&S--,l.charAt(l.length-2)===o.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=a.uint8array?new Uint8Array(0|S):new Array(0|S);y<l.length;)u=o.indexOf(l.charAt(y++))<<2|(g=o.indexOf(l.charAt(y++)))>>4,d=(15&g)<<4|(m=o.indexOf(l.charAt(y++)))>>2,f=(3&m)<<6|(x=o.indexOf(l.charAt(y++))),E[v++]=u,m!==64&&(E[v++]=d),x!==64&&(E[v++]=f);return E}},{"./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 u(d,f,g,m,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=m,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,g){return d.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./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=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;l[u]=o}return l})();r.exports=function(o,l){return o!==void 0&&o.length?s.getTypeOf(o)!=="string"?(function(u,d,f,g){var m=a,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^m[255&(u^d[y])];return-1^u})(0|l,o,o.length,0):(function(u,d,f,g){var m=a,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^m[255&(u^d.charCodeAt(y))];return-1^u})(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"),u=s?"uint8array":"array";function d(f,g){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(d,l),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(u,f.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,x){var y,v="";for(y=0;y<x;y++)v+=String.fromCharCode(255&m),m>>>=8;return v}function a(m,x,y,v,b,E){var S,A,T=m.file,k=m.compression,N=E!==u.utf8encode,I=o.transformTo("string",E(T.name)),C=o.transformTo("string",u.utf8encode(T.name)),D=T.comment,F=o.transformTo("string",E(D)),j=o.transformTo("string",u.utf8encode(D)),q=C.length!==T.name.length,R=j.length!==D.length,W="",K="",V="",te=T.dir,Y=T.date,Z={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(Z.crc32=m.crc32,Z.compressedSize=m.compressedSize,Z.uncompressedSize=m.uncompressedSize);var U=0;x&&(U|=8),N||!q&&!R||(U|=2048);var z=0,ee=0;te&&(z|=16),b==="UNIX"?(ee=798,z|=(function(fe,de){var xe=fe;return fe||(xe=de?16893:33204),(65535&xe)<<16})(T.unixPermissions,te)):(ee=20,z|=(function(fe){return 63&(fe||0)})(T.dosPermissions)),S=Y.getUTCHours(),S<<=6,S|=Y.getUTCMinutes(),S<<=5,S|=Y.getUTCSeconds()/2,A=Y.getUTCFullYear()-1980,A<<=4,A|=Y.getUTCMonth()+1,A<<=5,A|=Y.getUTCDate(),q&&(K=s(1,1)+s(d(I),4)+C,W+="up"+s(K.length,2)+K),R&&(V=s(1,1)+s(d(F),4)+j,W+="uc"+s(V.length,2)+V);var ae="";return ae+=`
- \0`,ae+=s(U,2),ae+=k.magic,ae+=s(S,2),ae+=s(A,2),ae+=s(Z.crc32,4),ae+=s(Z.compressedSize,4),ae+=s(Z.uncompressedSize,4),ae+=s(I.length,2),ae+=s(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ae+I+W,dirRecord:f.CENTRAL_FILE_HEADER+s(ee,2)+ae+s(F.length,2)+"\0\0\0\0"+s(z,4)+s(v,4)+I+W+F}}var o=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(m,x,y,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,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 x=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?(x+100*(y-v-1))/y:100}}))},g.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var y=a(m,x,!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 x=this.streamFiles&&!m.file.dir,y=a(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(v){return f.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,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-m,v=(function(b,E,S,A,T){var k=o.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(b,2)+s(b,2)+s(E,4)+s(S,4)+s(k.length,2)+k})(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 x=this;return m.on("data",function(y){x.processChunk(y)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(y){x.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 x=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var y=0;y<x.length;y++)try{x[y].error(m)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,x=0;x<m.length;x++)m[x].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,u){var d=new a(l.streamFiles,u,l.platform,l.encodeFileName),f=0;try{o.forEach(function(g,m){f++;var x=(function(E,S){var A=E||S,T=s[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(m.options.compression,l.compression),y=m.options.compressionOptions||l.compressionOptions||{},v=m.dir,b=m.date;m._compressWorker(x,y).withStreamInfo("file",{name:g,dir:v,date:b,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(s.prototype=n("./object")).loadAsync=n("./load"),s.support=n("./support"),s.defaults=n("./defaults"),s.version="3.10.1",s.loadAsync=function(a,o){return new s().loadAsync(a,o)},s.external=n("./external"),r.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var s=n("./utils"),a=n("./external"),o=n("./utf8"),l=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new a.Promise(function(m,x){var y=g.decompressed.getContentWorker().pipe(new u);y.on("error",function(v){x(v)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(g,m){var x=this;return m=s.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(g)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",g,!0,m.optimizedBinaryString,m.base64).then(function(y){var v=new l(m);return v.load(y),v}).then(function(y){var v=[a.Promise.resolve(y)],b=y.files;if(m.checkCRC32)for(var E=0;E<b.length;E++)v.push(f(b[E]));return a.Promise.all(v)}).then(function(y){for(var v=y.shift(),b=v.files,E=0;E<b.length;E++){var S=b[E],A=S.fileNameStr,T=s.resolve(S.fileNameStr);x.file(T,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:m.createFolders}),S.dir||(x.file(T).unsafeOriginalName=A)}return v.zipComment.length&&(x.comment=v.zipComment),x})}},{"./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,u){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(o,a),o.prototype._bindStream=function(l){var u=this;(this._stream=l).pause(),l.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},o.prototype.pause=function(){return!!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,u){s.call(this,l),this._helper=o;var d=this;o.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},r.exports=a},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(n,r,i){function s(T,k,N){var I,C=o.getTypeOf(k),D=o.extend(N||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(T=b(T)),D.createFolders&&(I=v(T))&&E.call(this,I,!0);var F=C==="string"&&D.binary===!1&&D.base64===!1;N&&N.binary!==void 0||(D.binary=!F),(k instanceof f&&k.uncompressedSize===0||D.dir||!k||k.length===0)&&(D.base64=!1,D.binary=!0,k="",D.compression="STORE",C="string");var j=null;j=k instanceof f||k instanceof l?k:x.isNode&&x.isStream(k)?new y(T,k):o.prepareContent(T,k,D.binary,D.optimizedBinaryString,D.base64);var q=new g(T,j,D);this.files[T]=q}var a=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),v=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var k=T.lastIndexOf("/");return 0<k?T.substring(0,k):""},b=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},E=function(T,k){return k=k!==void 0?k:d.createFolders,T=b(T),this.files[T]||s.call(this,T,null,{dir:!0,createFolders:k}),this.files[T]};function S(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var k,N,I;for(k in this.files)I=this.files[k],(N=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&T(N,I)},filter:function(T){var k=[];return this.forEach(function(N,I){T(N,I)&&k.push(I)}),k},file:function(T,k,N){if(arguments.length!==1)return T=this.root+T,s.call(this,T,k,N),this;if(S(T)){var I=T;return this.filter(function(D,F){return!F.dir&&I.test(D)})}var C=this.files[this.root+T];return C&&!C.dir?C:null},folder:function(T){if(!T)return this;if(S(T))return this.filter(function(C,D){return D.dir&&T.test(C)});var k=this.root+T,N=E.call(this,k),I=this.clone();return I.root=N.name,I},remove:function(T){T=this.root+T;var k=this.files[T];if(k||(T.slice(-1)!=="/"&&(T+="/"),k=this.files[T]),k&&!k.dir)delete this.files[T];else for(var N=this.filter(function(C,D){return D.name.slice(0,T.length)===T}),I=0;I<N.length;I++)delete this.files[N[I].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var k,N={};try{if((N=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");o.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var I=N.comment||this.comment||"";k=m.generateWorker(this,N,I)}catch(C){(k=new l("error")).error(C)}return new u(k,N.type||"string",N.mimeType)},generateAsync:function(T,k){return this.generateInternalStream(T).accumulate(k)},generateNodeStream:function(T,k){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(k)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var s=n("./DataReader");function a(o){s.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.readData(4);return l===g[0]&&u===g[1]&&d===g[2]&&f===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,u=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=o,u},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"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=s.getTypeOf(f);return s.checkSupport(g),g!=="string"||a.uint8array?g==="nodebuffer"?new u(f):a.uint8array?new d(s.transformTo("uint8array",f)):new o(s.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var 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 u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+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 u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=s.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=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,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,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"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,y){return new d.Promise(function(v,b){var E=[],S=x._internalType,A=x._outputType,T=x._mimeType;x.on("data",function(k,N){E.push(k),y&&y(N)}).on("error",function(k){E=[],b(k)}).on("end",function(){try{var k=(function(N,I,C){switch(N){case"blob":return s.newBlob(s.transformTo("arraybuffer",I),C);case"base64":return l.encode(I);default:return s.transformTo(N,I)}})(A,(function(N,I){var C,D=0,F=null,j=0;for(C=0;C<I.length;C++)j+=I[C].length;switch(N){case"string":return I.join("");case"array":return Array.prototype.concat.apply([],I);case"uint8array":for(F=new Uint8Array(j),C=0;C<I.length;C++)F.set(I[C],D),D+=I[C].length;return F;case"nodebuffer":return Buffer.concat(I);default:throw new Error("concat : unsupported type '"+N+"'")}})(S,E),T);v(k)}catch(N){b(N)}E=[]}).resume()})}function m(x,y,v){var b=y;switch(y){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=y,this._mimeType=v,s.checkSupport(b),this._worker=x.pipe(new a(b)),x.lock()}catch(E){this._worker=new o("error"),this._worker.error(E)}}m.prototype={accumulate:function(x){return g(this,x)},on:function(x,y){var v=this;return x==="data"?this._worker.on(x,function(b){y.call(v,b.data,b.meta)}):this._worker.on(x,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(x){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=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"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){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(x){var y,v,b,E,S,A=x.length,T=0;for(E=0;E<A;E++)(64512&(v=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),E++),T+=v<128?1:v<2048?2:v<65536?3:4;for(y=a.uint8array?new Uint8Array(T):new Array(T),E=S=0;S<T;E++)(64512&(v=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),E++),v<128?y[S++]=v:(v<2048?y[S++]=192|v>>>6:(v<65536?y[S++]=224|v>>>12:(y[S++]=240|v>>>18,y[S++]=128|v>>>12&63),y[S++]=128|v>>>6&63),y[S++]=128|63&v);return y})(m)},i.utf8decode=function(m){return a.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var y,v,b,E,S=x.length,A=new Array(2*S);for(y=v=0;y<S;)if((b=x[y++])<128)A[v++]=b;else if(4<(E=u[b]))A[v++]=65533,y+=E-1;else{for(b&=E===2?31:E===3?15:7;1<E&&y<S;)b=b<<6|63&x[y++],E--;1<E?A[v++]=65533:b<65536?A[v++]=b:(b-=65536,A[v++]=55296|b>>10&1023,A[v++]=56320|1023&b)}return A.length!==v&&(A.subarray?A=A.subarray(0,v):A.length=v),s.applyFromCharCode(A)})(m=s.transformTo(a.uint8array?"uint8array":"array",m))},s.inherits(f,l),f.prototype.processChunk=function(m){var x=s.transformTo(a.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var y=x;(x=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),x.set(y,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var v=(function(E,S){var A;for((S=S||E.length)>E.length&&(S=E.length),A=S-1;0<=A&&(192&E[A])==128;)A--;return A<0||A===0?S:A+u[E[A]]>S?A:S})(x),b=x;v!==x.length&&(a.uint8array?(b=x.subarray(0,v),this.leftOver=x.subarray(v,x.length)):(b=x.slice(0,v),this.leftOver=x.slice(v,x.length))),this.push({data:i.utf8decode(b),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,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 u(y){return y}function d(y,v){for(var b=0;b<y.length;++b)v[b]=255&y.charCodeAt(b);return v}n("setimmediate"),i.newBlob=function(y,v){i.checkSupport("blob");try{return new Blob([y],{type:v})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(y),b.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,v,b){var E=[],S=0,A=y.length;if(A<=b)return String.fromCharCode.apply(null,y);for(;S<A;)v==="array"||v==="nodebuffer"?E.push(String.fromCharCode.apply(null,y.slice(S,Math.min(S+b,A)))):E.push(String.fromCharCode.apply(null,y.subarray(S,Math.min(S+b,A)))),S+=b;return E.join("")},stringifyByChar:function(y){for(var v="",b=0;b<y.length;b++)v+=String.fromCharCode(y[b]);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,b=i.getTypeOf(y),E=!0;if(b==="uint8array"?E=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<v;)try{return f.stringifyByChunk(y,b,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(y)}function m(y,v){for(var b=0;b<y.length;b++)v[b]=y[b];return v}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return x.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,o.allocBuffer(y.length))}},x.array={string:g,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(y)}},x.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return o.newBufferFrom(new Uint8Array(y))}},x.uint8array={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return o.newBufferFrom(y)}},x.nodebuffer={string:g,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,v){if(v=v||"",!y)return v;i.checkSupport(y);var b=i.getTypeOf(v);return x[b][y](v)},i.resolve=function(y){for(var v=y.split("/"),b=[],E=0;E<v.length;E++){var S=v[E];S==="."||S===""&&E!==0&&E!==v.length-1||(S===".."?b.pop():b.push(S))}return b.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,b,E="";for(b=0;b<(y||"").length;b++)E+="\\x"+((v=y.charCodeAt(b))<16?"0":"")+v.toString(16).toUpperCase();return E},i.delay=function(y,v,b){setImmediate(function(){y.apply(b||null,v||[])})},i.inherits=function(y,v){function b(){}b.prototype=v.prototype,y.prototype=new b},i.extend=function(){var y,v,b={};for(y=0;y<arguments.length;y++)for(v in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],v)&&b[v]===void 0&&(b[v]=arguments[y][v]);return b},i.prepareContent=function(y,v,b,E,S){return l.Promise.resolve(v).then(function(A){return s.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new l.Promise(function(T,k){var N=new FileReader;N.onload=function(I){T(I.target.result)},N.onerror=function(I){k(I.target.error)},N.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(S?A=a.decode(A):b&&E!==!0&&(A=(function(k){return d(k,s.uint8array?new Uint8Array(k.length):new Array(k.length))})(A))),A):l.Promise.reject(new Error("Can't read the data of '"+y+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./signature"),l=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(g)+", expected "+a.pretty(f)+")")}},isSignature:function(f,g){var m=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===g;return this.reader.setIndex(m),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",m=a.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,m,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),g=this.reader.readInt(4),m=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===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,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var x=g-m;if(0<x)this.isSignature(g,o.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=s(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var s=n("./reader/readerFor"),a=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(m,x){this.options=m,this.loadOptions=x}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var x,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((x=(function(v){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===v)return d[b];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,x,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 x=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(x),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 x,y,v,b=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<b;)x=m.readInt(2),y=m.readInt(2),v=m.readData(y),this.extraFields[x]={id:x,length:y,value:v};m.setIndex(b)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var y=a.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var b=a.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=s(m.value);return x.readInt(1)!==1||l(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var x=s(m.value);return x.readInt(1)!==1||l(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.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(x,y,v){this.name=x,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"),u=n("./compressedObject"),d=n("./stream/GenericWorker");s.prototype={internalStream:function(x){var y=null,v="string";try{if(!x)throw new Error("No output type specified.");var b=(v=x.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),y=this._decompressWorker();var E=!this._dataBinary;E&&!b&&(y=y.pipe(new l.Utf8EncodeWorker)),!E&&b&&(y=y.pipe(new l.Utf8DecodeWorker))}catch(S){(y=new d("error")).error(S)}return new a(y,v,"")},async:function(x,y){return this.internalStream(x).accumulate(y)},nodeStream:function(x,y){return this.internalStream(x||"nodebuffer").toNodejsStream(y)},_compressWorker:function(x,y){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),u.createWorkerFrom(v,x,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)s.prototype[f[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 u=0,d=new l(x),f=s.document.createTextNode("");d.observe(f,{characterData:!0}),a=function(){f.data=u=++u%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(){x(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},s.document.documentElement.appendChild(y)}:function(){setTimeout(x,0)};else{var g=new s.MessageChannel;g.port1.onmessage=x,a=function(){g.port2.postMessage(0)}}var m=[];function x(){var y,v;o=!0;for(var b=m.length;b;){for(v=m,m=[],y=-1;++y<b;)v[y]();b=m.length}o=!1}r.exports=function(y){m.push(y)!==1||o||a()}}).call(this,typeof sy<"u"?sy:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function a(){}var o={},l=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==a&&y(this,b)}function g(b,E,S){this.promise=b,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function m(b,E,S){s(function(){var A;try{A=E(S)}catch(T){return o.reject(b,T)}A===b?o.reject(b,new TypeError("Cannot resolve promise with itself")):o.resolve(b,A)})}function x(b){var E=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof E=="function")return function(){E.apply(b,arguments)}}function y(b,E){var S=!1;function A(N){S||(S=!0,o.reject(b,N))}function T(N){S||(S=!0,o.resolve(b,N))}var k=v(function(){E(T,A)});k.status==="error"&&A(k.value)}function v(b,E){var S={};try{S.value=b(E),S.status="success"}catch(A){S.status="error",S.value=A}return S}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var E=this.constructor;return this.then(function(S){return E.resolve(b()).then(function(){return S})},function(S){return E.resolve(b()).then(function(){throw S})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,E){if(typeof b!="function"&&this.state===u||typeof E!="function"&&this.state===l)return this;var S=new this.constructor(a);return this.state!==d?m(S,this.state===u?b:E,this.outcome):this.queue.push(new g(S,b,E)),S},g.prototype.callFulfilled=function(b){o.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){m(this.promise,this.onFulfilled,b)},g.prototype.callRejected=function(b){o.reject(this.promise,b)},g.prototype.otherCallRejected=function(b){m(this.promise,this.onRejected,b)},o.resolve=function(b,E){var S=v(x,E);if(S.status==="error")return o.reject(b,S.value);var A=S.value;if(A)y(b,A);else{b.state=u,b.outcome=E;for(var T=-1,k=b.queue.length;++T<k;)b.queue[T].callFulfilled(E)}return b},o.reject=function(b,E){b.state=l,b.outcome=E;for(var S=-1,A=b.queue.length;++S<A;)b.queue[S].callRejected(E);return b},f.resolve=function(b){return b instanceof this?b:o.resolve(new this(a),b)},f.reject=function(b){var E=new this(a);return o.reject(E,b)},f.all=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,A=!1;if(!S)return this.resolve([]);for(var T=new Array(S),k=0,N=-1,I=new this(a);++N<S;)C(b[N],N);return I;function C(D,F){E.resolve(D).then(function(j){T[F]=j,++k!==S||A||(A=!0,o.resolve(I,T))},function(j){A||(A=!0,o.reject(I,j))})}},f.race=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=b.length,A=!1;if(!S)return this.resolve([]);for(var T=-1,k=new this(a);++T<S;)N=b[T],E.resolve(N).then(function(I){A||(A=!0,o.resolve(k,I))},function(I){A||(A=!0,o.reject(k,I))});var N;return k}},{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"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,m=0,x=8;function y(b){if(!(this instanceof y))return new y(b);this.options=a.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},b||{});var E=this.options;E.raw&&0<E.windowBits?E.windowBits=-E.windowBits:E.gzip&&0<E.windowBits&&E.windowBits<16&&(E.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var S=s.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(S!==f)throw new Error(l[S]);if(E.header&&s.deflateSetHeader(this.strm,E.header),E.dictionary){var A;if(A=typeof E.dictionary=="string"?o.string2buf(E.dictionary):d.call(E.dictionary)==="[object ArrayBuffer]"?new Uint8Array(E.dictionary):E.dictionary,(S=s.deflateSetDictionary(this.strm,A))!==f)throw new Error(l[S]);this._dict_set=!0}}function v(b,E){var S=new y(E);if(S.push(b,!0),S.err)throw S.msg||l[S.err];return S.result}y.prototype.push=function(b,E){var S,A,T=this.strm,k=this.options.chunkSize;if(this.ended)return!1;A=E===~~E?E:E===!0?4:0,typeof b=="string"?T.input=o.string2buf(b):d.call(b)==="[object ArrayBuffer]"?T.input=new Uint8Array(b):T.input=b,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new a.Buf8(k),T.next_out=0,T.avail_out=k),(S=s.deflate(T,A))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(T.output,T.next_out))):this.onData(a.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&S!==1);return A===4?(S=s.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):A!==2||(this.onEnd(f),!(T.avail_out=0))},y.prototype.onData=function(b){this.chunks.push(b)},y.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Deflate=y,i.deflate=v,i.deflateRaw=function(b,E){return(E=E||{}).raw=!0,v(b,E)},i.gzip=function(b,E){return(E=E||{}).gzip=!0,v(b,E)}},{"./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"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=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 d,this.strm.avail_out=0;var b=s.inflateInit2(this.strm,v.windowBits);if(b!==l.Z_OK)throw new Error(u[b]);this.header=new f,s.inflateGetHeader(this.strm,this.header)}function x(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||u[b.err];return b.result}m.prototype.push=function(y,v){var b,E,S,A,T,k,N=this.strm,I=this.options.chunkSize,C=this.options.dictionary,D=!1;if(this.ended)return!1;E=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof y=="string"?N.input=o.binstring2buf(y):g.call(y)==="[object ArrayBuffer]"?N.input=new Uint8Array(y):N.input=y,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new a.Buf8(I),N.next_out=0,N.avail_out=I),(b=s.inflate(N,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(k=typeof C=="string"?o.string2buf(C):g.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,b=s.inflateSetDictionary(this.strm,k)),b===l.Z_BUF_ERROR&&D===!0&&(b=l.Z_OK,D=!1),b!==l.Z_STREAM_END&&b!==l.Z_OK)return this.onEnd(b),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&b!==l.Z_STREAM_END&&(N.avail_in!==0||E!==l.Z_FINISH&&E!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=o.utf8border(N.output,N.next_out),A=N.next_out-S,T=o.buf2string(N.output,S),N.next_out=A,N.avail_out=I-A,A&&a.arraySet(N.output,N.output,S,A,0),this.onData(T)):this.onData(a.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(D=!0)}while((0<N.avail_in||N.avail_out===0)&&b!==l.Z_STREAM_END);return b===l.Z_STREAM_END&&(E=l.Z_FINISH),E===l.Z_FINISH?(b=s.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===l.Z_OK):E!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(N.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=x,i.inflateRaw=function(y,v){return(v=v||{}).raw=!0,x(y,v)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(l[f]=d[f])}}return l},i.shrinkBuf=function(l,u){return l.length===u?l:l.subarray?l.subarray(0,u):(l.length=u,l)};var a={arraySet:function(l,u,d,f,g){if(u.subarray&&l.subarray)l.set(u.subarray(d,d+f),g);else for(var m=0;m<f;m++)l[g+m]=u[d+m]},flattenChunks:function(l){var u,d,f,g,m,x;for(u=f=0,d=l.length;u<d;u++)f+=l[u].length;for(x=new Uint8Array(f),u=g=0,d=l.length;u<d;u++)m=l[u],x.set(m,g),g+=m.length;return x}},o={arraySet:function(l,u,d,f,g){for(var m=0;m<f;m++)l[g+m]=u[d+m]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,a)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,o))},i.setTyped(s)},{}],42:[function(n,r,i){var s=n("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new s.Buf8(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&o||!f.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(f,g));for(var m="",x=0;x<g;x++)m+=String.fromCharCode(f[x]);return m}l[254]=l[254]=1,i.string2buf=function(f){var g,m,x,y,v,b=f.length,E=0;for(y=0;y<b;y++)(64512&(m=f.charCodeAt(y)))==55296&&y+1<b&&(64512&(x=f.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),y++),E+=m<128?1:m<2048?2:m<65536?3:4;for(g=new s.Buf8(E),y=v=0;v<E;y++)(64512&(m=f.charCodeAt(y)))==55296&&y+1<b&&(64512&(x=f.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-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(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new s.Buf8(f.length),m=0,x=g.length;m<x;m++)g[m]=f.charCodeAt(m);return g},i.buf2string=function(f,g){var m,x,y,v,b=g||f.length,E=new Array(2*b);for(m=x=0;m<b;)if((y=f[m++])<128)E[x++]=y;else if(4<(v=l[y]))E[x++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&f[m++],v--;1<v?E[x++]=65533:y<65536?E[x++]=y:(y-=65536,E[x++]=55296|y>>10&1023,E[x++]=56320|1023&y)}return d(E,x)},i.utf8border=function(f,g){var m;for((g=g||f.length)>f.length&&(g=f.length),m=g-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?g:m+l[f[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,a,o,l){for(var u=65535&s|0,d=s>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;d=d+(u=u+a[l++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();r.exports=function(a,o,l,u){var d=s,f=u+l;a^=-1;for(var g=u;g<f;g++)a=a>>>8^d[255&(a^o[g])];return-1^a}},{}],46:[function(n,r,i){var s,a=n("../utils/common"),o=n("./trees"),l=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,m=0,x=-2,y=-1,v=4,b=2,E=8,S=9,A=286,T=30,k=19,N=2*A+1,I=15,C=3,D=258,F=D+C+1,j=42,q=113,R=1,W=2,K=3,V=4;function te($,H){return $.msg=d[H],H}function Y($){return($<<1)-(4<$?9:0)}function Z($){for(var H=$.length;0<=--H;)$[H]=0}function U($){var H=$.state,ie=H.pending;ie>$.avail_out&&(ie=$.avail_out),ie!==0&&(a.arraySet($.output,H.pending_buf,H.pending_out,ie,$.next_out),$.next_out+=ie,H.pending_out+=ie,$.total_out+=ie,$.avail_out-=ie,H.pending-=ie,H.pending===0&&(H.pending_out=0))}function z($,H){o._tr_flush_block($,0<=$.block_start?$.block_start:-1,$.strstart-$.block_start,H),$.block_start=$.strstart,U($.strm)}function ee($,H){$.pending_buf[$.pending++]=H}function ae($,H){$.pending_buf[$.pending++]=H>>>8&255,$.pending_buf[$.pending++]=255&H}function fe($,H){var ie,G,J=$.max_chain_length,le=$.strstart,ke=$.prev_length,Ne=$.nice_match,Se=$.strstart>$.w_size-F?$.strstart-($.w_size-F):0,B=$.window,L=$.w_mask,ne=$.prev,be=$.strstart+D,we=B[le+ke-1],ge=B[le+ke];$.prev_length>=$.good_match&&(J>>=2),Ne>$.lookahead&&(Ne=$.lookahead);do if(B[(ie=H)+ke]===ge&&B[ie+ke-1]===we&&B[ie]===B[le]&&B[++ie]===B[le+1]){le+=2,ie++;do;while(B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&B[++le]===B[++ie]&&le<be);if(G=D-(be-le),le=be-D,ke<G){if($.match_start=H,Ne<=(ke=G))break;we=B[le+ke-1],ge=B[le+ke]}}while((H=ne[H&L])>Se&&--J!=0);return ke<=$.lookahead?ke:$.lookahead}function de($){var H,ie,G,J,le,ke,Ne,Se,B,L,ne=$.w_size;do{if(J=$.window_size-$.lookahead-$.strstart,$.strstart>=ne+(ne-F)){for(a.arraySet($.window,$.window,ne,ne,0),$.match_start-=ne,$.strstart-=ne,$.block_start-=ne,H=ie=$.hash_size;G=$.head[--H],$.head[H]=ne<=G?G-ne:0,--ie;);for(H=ie=ne;G=$.prev[--H],$.prev[H]=ne<=G?G-ne:0,--ie;);J+=ne}if($.strm.avail_in===0)break;if(ke=$.strm,Ne=$.window,Se=$.strstart+$.lookahead,B=J,L=void 0,L=ke.avail_in,B<L&&(L=B),ie=L===0?0:(ke.avail_in-=L,a.arraySet(Ne,ke.input,ke.next_in,L,Se),ke.state.wrap===1?ke.adler=l(ke.adler,Ne,L,Se):ke.state.wrap===2&&(ke.adler=u(ke.adler,Ne,L,Se)),ke.next_in+=L,ke.total_in+=L,L),$.lookahead+=ie,$.lookahead+$.insert>=C)for(le=$.strstart-$.insert,$.ins_h=$.window[le],$.ins_h=($.ins_h<<$.hash_shift^$.window[le+1])&$.hash_mask;$.insert&&($.ins_h=($.ins_h<<$.hash_shift^$.window[le+C-1])&$.hash_mask,$.prev[le&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=le,le++,$.insert--,!($.lookahead+$.insert<C)););}while($.lookahead<F&&$.strm.avail_in!==0)}function xe($,H){for(var ie,G;;){if($.lookahead<F){if(de($),$.lookahead<F&&H===f)return R;if($.lookahead===0)break}if(ie=0,$.lookahead>=C&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),ie!==0&&$.strstart-ie<=$.w_size-F&&($.match_length=fe($,ie)),$.match_length>=C)if(G=o._tr_tally($,$.strstart-$.match_start,$.match_length-C),$.lookahead-=$.match_length,$.match_length<=$.max_lazy_match&&$.lookahead>=C){for($.match_length--;$.strstart++,$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart,--$.match_length!=0;);$.strstart++}else $.strstart+=$.match_length,$.match_length=0,$.ins_h=$.window[$.strstart],$.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+1])&$.hash_mask;else G=o._tr_tally($,0,$.window[$.strstart]),$.lookahead--,$.strstart++;if(G&&(z($,!1),$.strm.avail_out===0))return R}return $.insert=$.strstart<C-1?$.strstart:C-1,H===g?(z($,!0),$.strm.avail_out===0?K:V):$.last_lit&&(z($,!1),$.strm.avail_out===0)?R:W}function ye($,H){for(var ie,G,J;;){if($.lookahead<F){if(de($),$.lookahead<F&&H===f)return R;if($.lookahead===0)break}if(ie=0,$.lookahead>=C&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),$.prev_length=$.match_length,$.prev_match=$.match_start,$.match_length=C-1,ie!==0&&$.prev_length<$.max_lazy_match&&$.strstart-ie<=$.w_size-F&&($.match_length=fe($,ie),$.match_length<=5&&($.strategy===1||$.match_length===C&&4096<$.strstart-$.match_start)&&($.match_length=C-1)),$.prev_length>=C&&$.match_length<=$.prev_length){for(J=$.strstart+$.lookahead-C,G=o._tr_tally($,$.strstart-1-$.prev_match,$.prev_length-C),$.lookahead-=$.prev_length-1,$.prev_length-=2;++$.strstart<=J&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ie=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),--$.prev_length!=0;);if($.match_available=0,$.match_length=C-1,$.strstart++,G&&(z($,!1),$.strm.avail_out===0))return R}else if($.match_available){if((G=o._tr_tally($,0,$.window[$.strstart-1]))&&z($,!1),$.strstart++,$.lookahead--,$.strm.avail_out===0)return R}else $.match_available=1,$.strstart++,$.lookahead--}return $.match_available&&(G=o._tr_tally($,0,$.window[$.strstart-1]),$.match_available=0),$.insert=$.strstart<C-1?$.strstart:C-1,H===g?(z($,!0),$.strm.avail_out===0?K:V):$.last_lit&&(z($,!1),$.strm.avail_out===0)?R:W}function re($,H,ie,G,J){this.good_length=$,this.max_lazy=H,this.nice_length=ie,this.max_chain=G,this.func=J}function ve(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=E,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*N),this.dyn_dtree=new a.Buf16(2*(2*T+1)),this.bl_tree=new a.Buf16(2*(2*k+1)),Z(this.dyn_ltree),Z(this.dyn_dtree),Z(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(I+1),this.heap=new a.Buf16(2*A+1),Z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*A+1),Z(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 je($){var H;return $&&$.state?($.total_in=$.total_out=0,$.data_type=b,(H=$.state).pending=0,H.pending_out=0,H.wrap<0&&(H.wrap=-H.wrap),H.status=H.wrap?j:q,$.adler=H.wrap===2?0:1,H.last_flush=f,o._tr_init(H),m):te($,x)}function ue($){var H=je($);return H===m&&(function(ie){ie.window_size=2*ie.w_size,Z(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=C-1,ie.match_available=0,ie.ins_h=0})($.state),H}function ut($,H,ie,G,J,le){if(!$)return x;var ke=1;if(H===y&&(H=6),G<0?(ke=0,G=-G):15<G&&(ke=2,G-=16),J<1||S<J||ie!==E||G<8||15<G||H<0||9<H||le<0||v<le)return te($,x);G===8&&(G=9);var Ne=new ve;return($.state=Ne).strm=$,Ne.wrap=ke,Ne.gzhead=null,Ne.w_bits=G,Ne.w_size=1<<Ne.w_bits,Ne.w_mask=Ne.w_size-1,Ne.hash_bits=J+7,Ne.hash_size=1<<Ne.hash_bits,Ne.hash_mask=Ne.hash_size-1,Ne.hash_shift=~~((Ne.hash_bits+C-1)/C),Ne.window=new a.Buf8(2*Ne.w_size),Ne.head=new a.Buf16(Ne.hash_size),Ne.prev=new a.Buf16(Ne.w_size),Ne.lit_bufsize=1<<J+6,Ne.pending_buf_size=4*Ne.lit_bufsize,Ne.pending_buf=new a.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=H,Ne.strategy=le,Ne.method=ie,ue($)}s=[new re(0,0,0,0,function($,H){var ie=65535;for(ie>$.pending_buf_size-5&&(ie=$.pending_buf_size-5);;){if($.lookahead<=1){if(de($),$.lookahead===0&&H===f)return R;if($.lookahead===0)break}$.strstart+=$.lookahead,$.lookahead=0;var G=$.block_start+ie;if(($.strstart===0||$.strstart>=G)&&($.lookahead=$.strstart-G,$.strstart=G,z($,!1),$.strm.avail_out===0)||$.strstart-$.block_start>=$.w_size-F&&(z($,!1),$.strm.avail_out===0))return R}return $.insert=0,H===g?(z($,!0),$.strm.avail_out===0?K:V):($.strstart>$.block_start&&(z($,!1),$.strm.avail_out),R)}),new re(4,4,8,4,xe),new re(4,5,16,8,xe),new re(4,6,32,32,xe),new re(4,4,16,16,ye),new re(8,16,32,32,ye),new re(8,16,128,128,ye),new re(8,32,128,256,ye),new re(32,128,258,1024,ye),new re(32,258,258,4096,ye)],i.deflateInit=function($,H){return ut($,H,E,15,8,0)},i.deflateInit2=ut,i.deflateReset=ue,i.deflateResetKeep=je,i.deflateSetHeader=function($,H){return $&&$.state?$.state.wrap!==2?x:($.state.gzhead=H,m):x},i.deflate=function($,H){var ie,G,J,le;if(!$||!$.state||5<H||H<0)return $?te($,x):x;if(G=$.state,!$.output||!$.input&&$.avail_in!==0||G.status===666&&H!==g)return te($,$.avail_out===0?-5:x);if(G.strm=$,ie=G.last_flush,G.last_flush=H,G.status===j)if(G.wrap===2)$.adler=0,ee(G,31),ee(G,139),ee(G,8),G.gzhead?(ee(G,(G.gzhead.text?1:0)+(G.gzhead.hcrc?2:0)+(G.gzhead.extra?4:0)+(G.gzhead.name?8:0)+(G.gzhead.comment?16:0)),ee(G,255&G.gzhead.time),ee(G,G.gzhead.time>>8&255),ee(G,G.gzhead.time>>16&255),ee(G,G.gzhead.time>>24&255),ee(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),ee(G,255&G.gzhead.os),G.gzhead.extra&&G.gzhead.extra.length&&(ee(G,255&G.gzhead.extra.length),ee(G,G.gzhead.extra.length>>8&255)),G.gzhead.hcrc&&($.adler=u($.adler,G.pending_buf,G.pending,0)),G.gzindex=0,G.status=69):(ee(G,0),ee(G,0),ee(G,0),ee(G,0),ee(G,0),ee(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),ee(G,3),G.status=q);else{var ke=E+(G.w_bits-8<<4)<<8;ke|=(2<=G.strategy||G.level<2?0:G.level<6?1:G.level===6?2:3)<<6,G.strstart!==0&&(ke|=32),ke+=31-ke%31,G.status=q,ae(G,ke),G.strstart!==0&&(ae(G,$.adler>>>16),ae(G,65535&$.adler)),$.adler=1}if(G.status===69)if(G.gzhead.extra){for(J=G.pending;G.gzindex<(65535&G.gzhead.extra.length)&&(G.pending!==G.pending_buf_size||(G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),U($),J=G.pending,G.pending!==G.pending_buf_size));)ee(G,255&G.gzhead.extra[G.gzindex]),G.gzindex++;G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),G.gzindex===G.gzhead.extra.length&&(G.gzindex=0,G.status=73)}else G.status=73;if(G.status===73)if(G.gzhead.name){J=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),U($),J=G.pending,G.pending===G.pending_buf_size)){le=1;break}le=G.gzindex<G.gzhead.name.length?255&G.gzhead.name.charCodeAt(G.gzindex++):0,ee(G,le)}while(le!==0);G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),le===0&&(G.gzindex=0,G.status=91)}else G.status=91;if(G.status===91)if(G.gzhead.comment){J=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),U($),J=G.pending,G.pending===G.pending_buf_size)){le=1;break}le=G.gzindex<G.gzhead.comment.length?255&G.gzhead.comment.charCodeAt(G.gzindex++):0,ee(G,le)}while(le!==0);G.gzhead.hcrc&&G.pending>J&&($.adler=u($.adler,G.pending_buf,G.pending-J,J)),le===0&&(G.status=103)}else G.status=103;if(G.status===103&&(G.gzhead.hcrc?(G.pending+2>G.pending_buf_size&&U($),G.pending+2<=G.pending_buf_size&&(ee(G,255&$.adler),ee(G,$.adler>>8&255),$.adler=0,G.status=q)):G.status=q),G.pending!==0){if(U($),$.avail_out===0)return G.last_flush=-1,m}else if($.avail_in===0&&Y(H)<=Y(ie)&&H!==g)return te($,-5);if(G.status===666&&$.avail_in!==0)return te($,-5);if($.avail_in!==0||G.lookahead!==0||H!==f&&G.status!==666){var Ne=G.strategy===2?(function(Se,B){for(var L;;){if(Se.lookahead===0&&(de(Se),Se.lookahead===0)){if(B===f)return R;break}if(Se.match_length=0,L=o._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++,L&&(z(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,B===g?(z(Se,!0),Se.strm.avail_out===0?K:V):Se.last_lit&&(z(Se,!1),Se.strm.avail_out===0)?R:W})(G,H):G.strategy===3?(function(Se,B){for(var L,ne,be,we,ge=Se.window;;){if(Se.lookahead<=D){if(de(Se),Se.lookahead<=D&&B===f)return R;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=C&&0<Se.strstart&&(ne=ge[be=Se.strstart-1])===ge[++be]&&ne===ge[++be]&&ne===ge[++be]){we=Se.strstart+D;do;while(ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&ne===ge[++be]&&be<we);Se.match_length=D-(we-be),Se.match_length>Se.lookahead&&(Se.match_length=Se.lookahead)}if(Se.match_length>=C?(L=o._tr_tally(Se,1,Se.match_length-C),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&&(z(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,B===g?(z(Se,!0),Se.strm.avail_out===0?K:V):Se.last_lit&&(z(Se,!1),Se.strm.avail_out===0)?R:W})(G,H):s[G.level].func(G,H);if(Ne!==K&&Ne!==V||(G.status=666),Ne===R||Ne===K)return $.avail_out===0&&(G.last_flush=-1),m;if(Ne===W&&(H===1?o._tr_align(G):H!==5&&(o._tr_stored_block(G,0,0,!1),H===3&&(Z(G.head),G.lookahead===0&&(G.strstart=0,G.block_start=0,G.insert=0))),U($),$.avail_out===0))return G.last_flush=-1,m}return H!==g?m:G.wrap<=0?1:(G.wrap===2?(ee(G,255&$.adler),ee(G,$.adler>>8&255),ee(G,$.adler>>16&255),ee(G,$.adler>>24&255),ee(G,255&$.total_in),ee(G,$.total_in>>8&255),ee(G,$.total_in>>16&255),ee(G,$.total_in>>24&255)):(ae(G,$.adler>>>16),ae(G,65535&$.adler)),U($),0<G.wrap&&(G.wrap=-G.wrap),G.pending!==0?m:1)},i.deflateEnd=function($){var H;return $&&$.state?(H=$.state.status)!==j&&H!==69&&H!==73&&H!==91&&H!==103&&H!==q&&H!==666?te($,x):($.state=null,H===q?te($,-3):m):x},i.deflateSetDictionary=function($,H){var ie,G,J,le,ke,Ne,Se,B,L=H.length;if(!$||!$.state||(le=(ie=$.state).wrap)===2||le===1&&ie.status!==j||ie.lookahead)return x;for(le===1&&($.adler=l($.adler,H,L,0)),ie.wrap=0,L>=ie.w_size&&(le===0&&(Z(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),B=new a.Buf8(ie.w_size),a.arraySet(B,H,L-ie.w_size,ie.w_size,0),H=B,L=ie.w_size),ke=$.avail_in,Ne=$.next_in,Se=$.input,$.avail_in=L,$.next_in=0,$.input=H,de(ie);ie.lookahead>=C;){for(G=ie.strstart,J=ie.lookahead-(C-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[G+C-1])&ie.hash_mask,ie.prev[G&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=G,G++,--J;);ie.strstart=G,ie.lookahead=C-1,de(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=C-1,ie.match_available=0,$.next_in=Ne,$.input=Se,$.avail_in=ke,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,u,d,f,g,m,x,y,v,b,E,S,A,T,k,N,I,C,D,F,j,q,R,W;o=s.state,l=s.next_in,R=s.input,u=l+(s.avail_in-5),d=s.next_out,W=s.output,f=d-(a-s.avail_out),g=d+(s.avail_out-257),m=o.dmax,x=o.wsize,y=o.whave,v=o.wnext,b=o.window,E=o.hold,S=o.bits,A=o.lencode,T=o.distcode,k=(1<<o.lenbits)-1,N=(1<<o.distbits)-1;e:do{S<15&&(E+=R[l++]<<S,S+=8,E+=R[l++]<<S,S+=8),I=A[E&k];t:for(;;){if(E>>>=C=I>>>24,S-=C,(C=I>>>16&255)===0)W[d++]=65535&I;else{if(!(16&C)){if((64&C)==0){I=A[(65535&I)+(E&(1<<C)-1)];continue t}if(32&C){o.mode=12;break e}s.msg="invalid literal/length code",o.mode=30;break e}D=65535&I,(C&=15)&&(S<C&&(E+=R[l++]<<S,S+=8),D+=E&(1<<C)-1,E>>>=C,S-=C),S<15&&(E+=R[l++]<<S,S+=8,E+=R[l++]<<S,S+=8),I=T[E&N];n:for(;;){if(E>>>=C=I>>>24,S-=C,!(16&(C=I>>>16&255))){if((64&C)==0){I=T[(65535&I)+(E&(1<<C)-1)];continue n}s.msg="invalid distance code",o.mode=30;break e}if(F=65535&I,S<(C&=15)&&(E+=R[l++]<<S,(S+=8)<C&&(E+=R[l++]<<S,S+=8)),m<(F+=E&(1<<C)-1)){s.msg="invalid distance too far back",o.mode=30;break e}if(E>>>=C,S-=C,(C=d-f)<F){if(y<(C=F-C)&&o.sane){s.msg="invalid distance too far back",o.mode=30;break e}if(q=b,(j=0)===v){if(j+=x-C,C<D){for(D-=C;W[d++]=b[j++],--C;);j=d-F,q=W}}else if(v<C){if(j+=x+v-C,(C-=v)<D){for(D-=C;W[d++]=b[j++],--C;);if(j=0,v<D){for(D-=C=v;W[d++]=b[j++],--C;);j=d-F,q=W}}}else if(j+=v-C,C<D){for(D-=C;W[d++]=b[j++],--C;);j=d-F,q=W}for(;2<D;)W[d++]=q[j++],W[d++]=q[j++],W[d++]=q[j++],D-=3;D&&(W[d++]=q[j++],1<D&&(W[d++]=q[j++]))}else{for(j=d-F;W[d++]=W[j++],W[d++]=W[j++],W[d++]=W[j++],2<(D-=3););D&&(W[d++]=W[j++],1<D&&(W[d++]=W[j++]))}break}}break}}while(l<u&&d<g);l-=D=S>>3,E&=(1<<(S-=D<<3))-1,s.next_in=l,s.next_out=d,s.avail_in=l<u?u-l+5:5-(l-u),s.avail_out=d<g?g-d+257:257-(d-g),o.hold=E,o.bits=S}},{}],49:[function(n,r,i){var s=n("../utils/common"),a=n("./adler32"),o=n("./crc32"),l=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,m=-2,x=1,y=852,v=592;function b(j){return(j>>>24&255)+(j>>>8&65280)+((65280&j)<<8)+((255&j)<<24)}function E(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new 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 S(j){var q;return j&&j.state?(q=j.state,j.total_in=j.total_out=q.total=0,j.msg="",q.wrap&&(j.adler=1&q.wrap),q.mode=x,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new s.Buf32(y),q.distcode=q.distdyn=new s.Buf32(v),q.sane=1,q.back=-1,g):m}function A(j){var q;return j&&j.state?((q=j.state).wsize=0,q.whave=0,q.wnext=0,S(j)):m}function T(j,q){var R,W;return j&&j.state?(W=j.state,q<0?(R=0,q=-q):(R=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?m:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=R,W.wbits=q,A(j))):m}function k(j,q){var R,W;return j?(W=new E,(j.state=W).window=null,(R=T(j,q))!==g&&(j.state=null),R):m}var N,I,C=!0;function D(j){if(C){var q;for(N=new s.Buf32(512),I=new s.Buf32(32),q=0;q<144;)j.lens[q++]=8;for(;q<256;)j.lens[q++]=9;for(;q<280;)j.lens[q++]=7;for(;q<288;)j.lens[q++]=8;for(u(d,j.lens,0,288,N,0,j.work,{bits:9}),q=0;q<32;)j.lens[q++]=5;u(f,j.lens,0,32,I,0,j.work,{bits:5}),C=!1}j.lencode=N,j.lenbits=9,j.distcode=I,j.distbits=5}function F(j,q,R,W){var K,V=j.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new s.Buf8(V.wsize)),W>=V.wsize?(s.arraySet(V.window,q,R-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):(W<(K=V.wsize-V.wnext)&&(K=W),s.arraySet(V.window,q,R-W,K,V.wnext),(W-=K)?(s.arraySet(V.window,q,R-W,W,0),V.wnext=W,V.whave=V.wsize):(V.wnext+=K,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=S,i.inflateInit=function(j){return k(j,15)},i.inflateInit2=k,i.inflate=function(j,q){var R,W,K,V,te,Y,Z,U,z,ee,ae,fe,de,xe,ye,re,ve,je,ue,ut,$,H,ie,G,J=0,le=new s.Buf8(4),ke=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!j||!j.state||!j.output||!j.input&&j.avail_in!==0)return m;(R=j.state).mode===12&&(R.mode=13),te=j.next_out,K=j.output,Z=j.avail_out,V=j.next_in,W=j.input,Y=j.avail_in,U=R.hold,z=R.bits,ee=Y,ae=Z,H=g;e:for(;;)switch(R.mode){case x:if(R.wrap===0){R.mode=13;break}for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(2&R.wrap&&U===35615){le[R.check=0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0),z=U=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&U)<<8)+(U>>8))%31){j.msg="incorrect header check",R.mode=30;break}if((15&U)!=8){j.msg="unknown compression method",R.mode=30;break}if(z-=4,$=8+(15&(U>>>=4)),R.wbits===0)R.wbits=$;else if($>R.wbits){j.msg="invalid window size",R.mode=30;break}R.dmax=1<<$,j.adler=R.check=1,R.mode=512&U?10:12,z=U=0;break;case 2:for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(R.flags=U,(255&R.flags)!=8){j.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){j.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=U>>8&1),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),z=U=0,R.mode=3;case 3:for(;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.head&&(R.head.time=U),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,le[2]=U>>>16&255,le[3]=U>>>24&255,R.check=o(R.check,le,4,0)),z=U=0,R.mode=4;case 4:for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.head&&(R.head.xflags=255&U,R.head.os=U>>8),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),z=U=0,R.mode=5;case 5:if(1024&R.flags){for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.length=U,R.head&&(R.head.extra_len=U),512&R.flags&&(le[0]=255&U,le[1]=U>>>8&255,R.check=o(R.check,le,2,0)),z=U=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Y<(fe=R.length)&&(fe=Y),fe&&(R.head&&($=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),s.arraySet(R.head.extra,W,V,fe,$)),512&R.flags&&(R.check=o(R.check,W,fe,V)),Y-=fe,V+=fe,R.length-=fe),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Y===0)break e;for(fe=0;$=W[V+fe++],R.head&&$&&R.length<65536&&(R.head.name+=String.fromCharCode($)),$&&fe<Y;);if(512&R.flags&&(R.check=o(R.check,W,fe,V)),Y-=fe,V+=fe,$)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Y===0)break e;for(fe=0;$=W[V+fe++],R.head&&$&&R.length<65536&&(R.head.comment+=String.fromCharCode($)),$&&fe<Y;);if(512&R.flags&&(R.check=o(R.check,W,fe,V)),Y-=fe,V+=fe,$)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;z<16;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(U!==(65535&R.check)){j.msg="header crc mismatch",R.mode=30;break}z=U=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),j.adler=R.check=0,R.mode=12;break;case 10:for(;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}j.adler=R.check=b(U),z=U=0,R.mode=11;case 11:if(R.havedict===0)return j.next_out=te,j.avail_out=Z,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,2;j.adler=R.check=1,R.mode=12;case 12:if(q===5||q===6)break e;case 13:if(R.last){U>>>=7&z,z-=7&z,R.mode=27;break}for(;z<3;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}switch(R.last=1&U,z-=1,3&(U>>>=1)){case 0:R.mode=14;break;case 1:if(D(R),R.mode=20,q!==6)break;U>>>=2,z-=2;break e;case 2:R.mode=17;break;case 3:j.msg="invalid block type",R.mode=30}U>>>=2,z-=2;break;case 14:for(U>>>=7&z,z-=7&z;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if((65535&U)!=(U>>>16^65535)){j.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&U,z=U=0,R.mode=15,q===6)break e;case 15:R.mode=16;case 16:if(fe=R.length){if(Y<fe&&(fe=Y),Z<fe&&(fe=Z),fe===0)break e;s.arraySet(K,W,V,fe,te),Y-=fe,V+=fe,Z-=fe,te+=fe,R.length-=fe;break}R.mode=12;break;case 17:for(;z<14;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(R.nlen=257+(31&U),U>>>=5,z-=5,R.ndist=1+(31&U),U>>>=5,z-=5,R.ncode=4+(15&U),U>>>=4,z-=4,286<R.nlen||30<R.ndist){j.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;z<3;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.lens[ke[R.have++]]=7&U,U>>>=3,z-=3}for(;R.have<19;)R.lens[ke[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ie={bits:R.lenbits},H=u(0,R.lens,0,19,R.lencode,0,R.work,ie),R.lenbits=ie.bits,H){j.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;re=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,ve=65535&J,!((ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(ve<16)U>>>=ye,z-=ye,R.lens[R.have++]=ve;else{if(ve===16){for(G=ye+2;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(U>>>=ye,z-=ye,R.have===0){j.msg="invalid bit length repeat",R.mode=30;break}$=R.lens[R.have-1],fe=3+(3&U),U>>>=2,z-=2}else if(ve===17){for(G=ye+3;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}z-=ye,$=0,fe=3+(7&(U>>>=ye)),U>>>=3,z-=3}else{for(G=ye+7;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}z-=ye,$=0,fe=11+(127&(U>>>=ye)),U>>>=7,z-=7}if(R.have+fe>R.nlen+R.ndist){j.msg="invalid bit length repeat",R.mode=30;break}for(;fe--;)R.lens[R.have++]=$}}if(R.mode===30)break;if(R.lens[256]===0){j.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,ie={bits:R.lenbits},H=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,ie),R.lenbits=ie.bits,H){j.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ie={bits:R.distbits},H=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ie),R.distbits=ie.bits,H){j.msg="invalid distances set",R.mode=30;break}if(R.mode=20,q===6)break e;case 20:R.mode=21;case 21:if(6<=Y&&258<=Z){j.next_out=te,j.avail_out=Z,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,l(j,ae),te=j.next_out,K=j.output,Z=j.avail_out,V=j.next_in,W=j.input,Y=j.avail_in,U=R.hold,z=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;re=(J=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,ve=65535&J,!((ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(re&&(240&re)==0){for(je=ye,ue=re,ut=ve;re=(J=R.lencode[ut+((U&(1<<je+ue)-1)>>je)])>>>16&255,ve=65535&J,!(je+(ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}U>>>=je,z-=je,R.back+=je}if(U>>>=ye,z-=ye,R.back+=ye,R.length=ve,re===0){R.mode=26;break}if(32&re){R.back=-1,R.mode=12;break}if(64&re){j.msg="invalid literal/length code",R.mode=30;break}R.extra=15&re,R.mode=22;case 22:if(R.extra){for(G=R.extra;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.length+=U&(1<<R.extra)-1,U>>>=R.extra,z-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;re=(J=R.distcode[U&(1<<R.distbits)-1])>>>16&255,ve=65535&J,!((ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if((240&re)==0){for(je=ye,ue=re,ut=ve;re=(J=R.distcode[ut+((U&(1<<je+ue)-1)>>je)])>>>16&255,ve=65535&J,!(je+(ye=J>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}U>>>=je,z-=je,R.back+=je}if(U>>>=ye,z-=ye,R.back+=ye,64&re){j.msg="invalid distance code",R.mode=30;break}R.offset=ve,R.extra=15&re,R.mode=24;case 24:if(R.extra){for(G=R.extra;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}R.offset+=U&(1<<R.extra)-1,U>>>=R.extra,z-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){j.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Z===0)break e;if(fe=ae-Z,R.offset>fe){if((fe=R.offset-fe)>R.whave&&R.sane){j.msg="invalid distance too far back",R.mode=30;break}de=fe>R.wnext?(fe-=R.wnext,R.wsize-fe):R.wnext-fe,fe>R.length&&(fe=R.length),xe=R.window}else xe=K,de=te-R.offset,fe=R.length;for(Z<fe&&(fe=Z),Z-=fe,R.length-=fe;K[te++]=xe[de++],--fe;);R.length===0&&(R.mode=21);break;case 26:if(Z===0)break e;K[te++]=R.length,Z--,R.mode=21;break;case 27:if(R.wrap){for(;z<32;){if(Y===0)break e;Y--,U|=W[V++]<<z,z+=8}if(ae-=Z,j.total_out+=ae,R.total+=ae,ae&&(j.adler=R.check=R.flags?o(R.check,K,ae,te-ae):a(R.check,K,ae,te-ae)),ae=Z,(R.flags?U:b(U))!==R.check){j.msg="incorrect data check",R.mode=30;break}z=U=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;z<32;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(U!==(4294967295&R.total)){j.msg="incorrect length check",R.mode=30;break}z=U=0}R.mode=29;case 29:H=1;break e;case 30:H=-3;break e;case 31:return-4;case 32:default:return m}return j.next_out=te,j.avail_out=Z,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,(R.wsize||ae!==j.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&F(j,j.output,j.next_out,ae-j.avail_out)?(R.mode=31,-4):(ee-=j.avail_in,ae-=j.avail_out,j.total_in+=ee,j.total_out+=ae,R.total+=ae,R.wrap&&ae&&(j.adler=R.check=R.flags?o(R.check,K,ae,j.next_out-ae):a(R.check,K,ae,j.next_out-ae)),j.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ee==0&&ae===0||q===4)&&H===g&&(H=-5),H)},i.inflateEnd=function(j){if(!j||!j.state)return m;var q=j.state;return q.window&&(q.window=null),j.state=null,g},i.inflateGetHeader=function(j,q){var R;return j&&j.state?(2&(R=j.state).wrap)==0?m:((R.head=q).done=!1,g):m},i.inflateSetDictionary=function(j,q){var R,W=q.length;return j&&j.state?(R=j.state).wrap!==0&&R.mode!==11?m:R.mode===11&&a(1,q,W,0)!==R.check?-3:F(j,q,W,W)?(R.mode=31,-4):(R.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],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,m,x,y,v,b){var E,S,A,T,k,N,I,C,D,F=b.bits,j=0,q=0,R=0,W=0,K=0,V=0,te=0,Y=0,Z=0,U=0,z=null,ee=0,ae=new s.Buf16(16),fe=new s.Buf16(16),de=null,xe=0;for(j=0;j<=15;j++)ae[j]=0;for(q=0;q<m;q++)ae[f[g+q]]++;for(K=F,W=15;1<=W&&ae[W]===0;W--);if(W<K&&(K=W),W===0)return x[y++]=20971520,x[y++]=20971520,b.bits=1,0;for(R=1;R<W&&ae[R]===0;R++);for(K<R&&(K=R),j=Y=1;j<=15;j++)if(Y<<=1,(Y-=ae[j])<0)return-1;if(0<Y&&(d===0||W!==1))return-1;for(fe[1]=0,j=1;j<15;j++)fe[j+1]=fe[j]+ae[j];for(q=0;q<m;q++)f[g+q]!==0&&(v[fe[f[g+q]]++]=q);if(N=d===0?(z=de=v,19):d===1?(z=a,ee-=257,de=o,xe-=257,256):(z=l,de=u,-1),j=R,k=y,te=q=U=0,A=-1,T=(Z=1<<(V=K))-1,d===1&&852<Z||d===2&&592<Z)return 1;for(;;){for(I=j-te,D=v[q]<N?(C=0,v[q]):v[q]>N?(C=de[xe+v[q]],z[ee+v[q]]):(C=96,0),E=1<<j-te,R=S=1<<V;x[k+(U>>te)+(S-=E)]=I<<24|C<<16|D|0,S!==0;);for(E=1<<j-1;U&E;)E>>=1;if(E!==0?(U&=E-1,U+=E):U=0,q++,--ae[j]==0){if(j===W)break;j=f[g+v[q]]}if(K<j&&(U&T)!==A){for(te===0&&(te=K),k+=R,Y=1<<(V=j-te);V+te<W&&!((Y-=ae[V+te])<=0);)V++,Y<<=1;if(Z+=1<<V,d===1&&852<Z||d===2&&592<Z)return 1;x[A=U&T]=K<<24|V<<16|k-y|0}}return U!==0&&(x[k+U]=j-te<<24|64<<16|0),b.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),a=0,o=1;function l(J){for(var le=J.length;0<=--le;)J[le]=0}var u=0,d=29,f=256,g=f+1+d,m=30,x=19,y=2*g+1,v=15,b=16,E=7,S=256,A=16,T=17,k=18,N=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],I=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(g+2));l(F);var j=new Array(2*m);l(j);var q=new Array(512);l(q);var R=new Array(256);l(R);var W=new Array(d);l(W);var K,V,te,Y=new Array(m);function Z(J,le,ke,Ne,Se){this.static_tree=J,this.extra_bits=le,this.extra_base=ke,this.elems=Ne,this.max_length=Se,this.has_stree=J&&J.length}function U(J,le){this.dyn_tree=J,this.max_code=0,this.stat_desc=le}function z(J){return J<256?q[J]:q[256+(J>>>7)]}function ee(J,le){J.pending_buf[J.pending++]=255&le,J.pending_buf[J.pending++]=le>>>8&255}function ae(J,le,ke){J.bi_valid>b-ke?(J.bi_buf|=le<<J.bi_valid&65535,ee(J,J.bi_buf),J.bi_buf=le>>b-J.bi_valid,J.bi_valid+=ke-b):(J.bi_buf|=le<<J.bi_valid&65535,J.bi_valid+=ke)}function fe(J,le,ke){ae(J,ke[2*le],ke[2*le+1])}function de(J,le){for(var ke=0;ke|=1&J,J>>>=1,ke<<=1,0<--le;);return ke>>>1}function xe(J,le,ke){var Ne,Se,B=new Array(v+1),L=0;for(Ne=1;Ne<=v;Ne++)B[Ne]=L=L+ke[Ne-1]<<1;for(Se=0;Se<=le;Se++){var ne=J[2*Se+1];ne!==0&&(J[2*Se]=de(B[ne]++,ne))}}function ye(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<x;le++)J.bl_tree[2*le]=0;J.dyn_ltree[2*S]=1,J.opt_len=J.static_len=0,J.last_lit=J.matches=0}function re(J){8<J.bi_valid?ee(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 ve(J,le,ke,Ne){var Se=2*le,B=2*ke;return J[Se]<J[B]||J[Se]===J[B]&&Ne[le]<=Ne[ke]}function je(J,le,ke){for(var Ne=J.heap[ke],Se=ke<<1;Se<=J.heap_len&&(Se<J.heap_len&&ve(le,J.heap[Se+1],J.heap[Se],J.depth)&&Se++,!ve(le,Ne,J.heap[Se],J.depth));)J.heap[ke]=J.heap[Se],ke=Se,Se<<=1;J.heap[ke]=Ne}function ue(J,le,ke){var Ne,Se,B,L,ne=0;if(J.last_lit!==0)for(;Ne=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++,Ne===0?fe(J,Se,le):(fe(J,(B=R[Se])+f+1,le),(L=N[B])!==0&&ae(J,Se-=W[B],L),fe(J,B=z(--Ne),ke),(L=I[B])!==0&&ae(J,Ne-=Y[B],L)),ne<J.last_lit;);fe(J,S,le)}function ut(J,le){var ke,Ne,Se,B=le.dyn_tree,L=le.stat_desc.static_tree,ne=le.stat_desc.has_stree,be=le.stat_desc.elems,we=-1;for(J.heap_len=0,J.heap_max=y,ke=0;ke<be;ke++)B[2*ke]!==0?(J.heap[++J.heap_len]=we=ke,J.depth[ke]=0):B[2*ke+1]=0;for(;J.heap_len<2;)B[2*(Se=J.heap[++J.heap_len]=we<2?++we:0)]=1,J.depth[Se]=0,J.opt_len--,ne&&(J.static_len-=L[2*Se+1]);for(le.max_code=we,ke=J.heap_len>>1;1<=ke;ke--)je(J,B,ke);for(Se=be;ke=J.heap[1],J.heap[1]=J.heap[J.heap_len--],je(J,B,1),Ne=J.heap[1],J.heap[--J.heap_max]=ke,J.heap[--J.heap_max]=Ne,B[2*Se]=B[2*ke]+B[2*Ne],J.depth[Se]=(J.depth[ke]>=J.depth[Ne]?J.depth[ke]:J.depth[Ne])+1,B[2*ke+1]=B[2*Ne+1]=Se,J.heap[1]=Se++,je(J,B,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],(function(ge,me){var Ae,ze,st,Ve,ce,Ye,$e=me.dyn_tree,Ze=me.max_code,at=me.stat_desc.static_tree,Q=me.stat_desc.has_stree,Fe=me.stat_desc.extra_bits,pe=me.stat_desc.extra_base,Ue=me.stat_desc.max_length,Ce=0;for(Ve=0;Ve<=v;Ve++)ge.bl_count[Ve]=0;for($e[2*ge.heap[ge.heap_max]+1]=0,Ae=ge.heap_max+1;Ae<y;Ae++)Ue<(Ve=$e[2*$e[2*(ze=ge.heap[Ae])+1]+1]+1)&&(Ve=Ue,Ce++),$e[2*ze+1]=Ve,Ze<ze||(ge.bl_count[Ve]++,ce=0,pe<=ze&&(ce=Fe[ze-pe]),Ye=$e[2*ze],ge.opt_len+=Ye*(Ve+ce),Q&&(ge.static_len+=Ye*(at[2*ze+1]+ce)));if(Ce!==0){do{for(Ve=Ue-1;ge.bl_count[Ve]===0;)Ve--;ge.bl_count[Ve]--,ge.bl_count[Ve+1]+=2,ge.bl_count[Ue]--,Ce-=2}while(0<Ce);for(Ve=Ue;Ve!==0;Ve--)for(ze=ge.bl_count[Ve];ze!==0;)Ze<(st=ge.heap[--Ae])||($e[2*st+1]!==Ve&&(ge.opt_len+=(Ve-$e[2*st+1])*$e[2*st],$e[2*st+1]=Ve),ze--)}})(J,le),xe(B,we,J.bl_count)}function $(J,le,ke){var Ne,Se,B=-1,L=le[1],ne=0,be=7,we=4;for(L===0&&(be=138,we=3),le[2*(ke+1)+1]=65535,Ne=0;Ne<=ke;Ne++)Se=L,L=le[2*(Ne+1)+1],++ne<be&&Se===L||(ne<we?J.bl_tree[2*Se]+=ne:Se!==0?(Se!==B&&J.bl_tree[2*Se]++,J.bl_tree[2*A]++):ne<=10?J.bl_tree[2*T]++:J.bl_tree[2*k]++,B=Se,we=(ne=0)===L?(be=138,3):Se===L?(be=6,3):(be=7,4))}function H(J,le,ke){var Ne,Se,B=-1,L=le[1],ne=0,be=7,we=4;for(L===0&&(be=138,we=3),Ne=0;Ne<=ke;Ne++)if(Se=L,L=le[2*(Ne+1)+1],!(++ne<be&&Se===L)){if(ne<we)for(;fe(J,Se,J.bl_tree),--ne!=0;);else Se!==0?(Se!==B&&(fe(J,Se,J.bl_tree),ne--),fe(J,A,J.bl_tree),ae(J,ne-3,2)):ne<=10?(fe(J,T,J.bl_tree),ae(J,ne-3,3)):(fe(J,k,J.bl_tree),ae(J,ne-11,7));B=Se,we=(ne=0)===L?(be=138,3):Se===L?(be=6,3):(be=7,4)}}l(Y);var ie=!1;function G(J,le,ke,Ne){ae(J,(u<<1)+(Ne?1:0),3),(function(Se,B,L,ne){re(Se),ee(Se,L),ee(Se,~L),s.arraySet(Se.pending_buf,Se.window,B,L,Se.pending),Se.pending+=L})(J,le,ke)}i._tr_init=function(J){ie||((function(){var le,ke,Ne,Se,B,L=new Array(v+1);for(Se=Ne=0;Se<d-1;Se++)for(W[Se]=Ne,le=0;le<1<<N[Se];le++)R[Ne++]=Se;for(R[Ne-1]=Se,Se=B=0;Se<16;Se++)for(Y[Se]=B,le=0;le<1<<I[Se];le++)q[B++]=Se;for(B>>=7;Se<m;Se++)for(Y[Se]=B<<7,le=0;le<1<<I[Se]-7;le++)q[256+B++]=Se;for(ke=0;ke<=v;ke++)L[ke]=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(xe(F,g+1,L),le=0;le<m;le++)j[2*le+1]=5,j[2*le]=de(le,5);K=new Z(F,N,f+1,g,v),V=new Z(j,I,0,m,v),te=new Z(new Array(0),C,0,x,E)})(),ie=!0),J.l_desc=new U(J.dyn_ltree,K),J.d_desc=new U(J.dyn_dtree,V),J.bl_desc=new U(J.bl_tree,te),J.bi_buf=0,J.bi_valid=0,ye(J)},i._tr_stored_block=G,i._tr_flush_block=function(J,le,ke,Ne){var Se,B,L=0;0<J.level?(J.strm.data_type===2&&(J.strm.data_type=(function(ne){var be,we=4093624447;for(be=0;be<=31;be++,we>>>=1)if(1&we&&ne.dyn_ltree[2*be]!==0)return a;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return o;for(be=32;be<f;be++)if(ne.dyn_ltree[2*be]!==0)return o;return a})(J)),ut(J,J.l_desc),ut(J,J.d_desc),L=(function(ne){var be;for($(ne,ne.dyn_ltree,ne.l_desc.max_code),$(ne,ne.dyn_dtree,ne.d_desc.max_code),ut(ne,ne.bl_desc),be=x-1;3<=be&&ne.bl_tree[2*D[be]+1]===0;be--);return ne.opt_len+=3*(be+1)+5+5+4,be})(J),Se=J.opt_len+3+7>>>3,(B=J.static_len+3+7>>>3)<=Se&&(Se=B)):Se=B=ke+5,ke+4<=Se&&le!==-1?G(J,le,ke,Ne):J.strategy===4||B===Se?(ae(J,2+(Ne?1:0),3),ue(J,F,j)):(ae(J,4+(Ne?1:0),3),(function(ne,be,we,ge){var me;for(ae(ne,be-257,5),ae(ne,we-1,5),ae(ne,ge-4,4),me=0;me<ge;me++)ae(ne,ne.bl_tree[2*D[me]+1],3);H(ne,ne.dyn_ltree,be-1),H(ne,ne.dyn_dtree,we-1)})(J,J.l_desc.max_code+1,J.d_desc.max_code+1,L+1),ue(J,J.dyn_ltree,J.dyn_dtree)),ye(J),Ne&&re(J)},i._tr_tally=function(J,le,ke){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&ke,J.last_lit++,le===0?J.dyn_ltree[2*ke]++:(J.matches++,le--,J.dyn_ltree[2*(R[ke]+f+1)]++,J.dyn_dtree[2*z(le)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){ae(J,2,3),fe(J,S,F),(function(le){le.bi_valid===16?(ee(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,u,d,f,g=1,m={},x=!1,y=a.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(a);v=v&&v.setTimeout?v:a,l={}.toString.call(a.process)==="[object process]"?function(A){process.nextTick(function(){E(A)})}:(function(){if(a.postMessage&&!a.importScripts){var A=!0,T=a.onmessage;return a.onmessage=function(){A=!1},a.postMessage("","*"),a.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",S,!1):a.attachEvent("onmessage",S),function(A){a.postMessage(f+A,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){E(A.data)},function(A){d.port2.postMessage(A)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(A){var T=y.createElement("script");T.onreadystatechange=function(){E(A),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(A){setTimeout(E,0,A)},v.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),k=0;k<T.length;k++)T[k]=arguments[k+1];var N={callback:A,args:T};return m[g]=N,l(g),g++},v.clearImmediate=b}function b(A){delete m[A]}function E(A){if(x)setTimeout(E,0,A);else{var T=m[A];if(T){x=!0;try{(function(k){var N=k.callback,I=k.args;switch(I.length){case 0:N();break;case 1:N(I[0]);break;case 2:N(I[0],I[1]);break;case 3:N(I[0],I[1],I[2]);break;default:N.apply(o,I)}})(T)}finally{b(A),x=!1}}}}function S(A){A.source===a&&typeof A.data=="string"&&A.data.indexOf(f)===0&&E(+A.data.slice(f.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof sy<"u"?sy:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(FC)),FC.exports}var GDe=VDe();const WDe=lo(GDe);function qDe(t){const e=new ti;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 NH=qDe;async function kH(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 u=0;u<o.length;u++){const d=o[u];s.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const l=i.getElementsByTagName("triangle");for(let u=0;u<l.length;u++){const d=l[u];a.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}s.length>0&&a.length>0&&e.push({vertices:s,triangles:a})}return e}async function KDe(t){const e=await WDe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function s(d){const f=d.startsWith("/")?d.slice(1):d,g=e.files[f];if(!g)return null;const m=await g.async("string");return i.parseFromString(m,"application/xml")}const a=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!a){const d=Object.keys(e.files).find(f=>f.endsWith(".model"));if(d){const f=await s(d);if(f){const g=await kH(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const o=await s(a);if(!o)return{objects:n,buildItems:r};const l=o.getElementsByTagName("object");for(let d=0;d<l.length;d++){const f=l[d],g=f.getAttribute("id");if(!g)continue;const m=[],x=f.getElementsByTagName("mesh");for(let v=0;v<x.length;v++){const b=x[v],E=[],S=[],A=b.getElementsByTagName("vertex");for(let k=0;k<A.length;k++){const N=A[k];E.push(parseFloat(N.getAttribute("x")||"0"),parseFloat(N.getAttribute("y")||"0"),parseFloat(N.getAttribute("z")||"0"))}const T=b.getElementsByTagName("triangle");for(let k=0;k<T.length;k++){const N=T[k];S.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}E.length>0&&S.length>0&&m.push({vertices:E,triangles:S})}const y=f.getElementsByTagName("component");for(let v=0;v<y.length;v++){const b=y[v],E=b.getAttribute("p:path")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(E){const S=await s(E);if(S){const A=await kH(S),T=b.getAttribute("transform"),k=NH(T);for(const N of A)if(T){const I=[];for(let C=0;C<N.vertices.length;C+=3){const D=new Je(N.vertices[C],N.vertices[C+1],N.vertices[C+2]);D.applyMatrix4(k),I.push(D.x,D.y,D.z)}m.push({vertices:I,triangles:N.triangles})}else m.push(N)}}}m.length>0&&n.set(g,{id:g,meshes:m})}const u=o.getElementsByTagName("build");if(u.length>0){const d=u[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const g=d[f],m=g.getAttribute("objectid");if(!m)continue;const x=NH(g.getAttribute("transform"));r.push({objectId:m,transform:x})}}return{objects:n,buildItems:r}}function PH(t){const e=new Sl,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 eo(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function XDe({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=M.useRef(null),i=M.useRef(null),s=M.useRef(null),a=M.useRef(null),o=M.useRef(null),[l,u]=M.useState(!0),[d,f]=M.useState(null);M.useEffect(()=>{if(!r.current)return;const x=r.current,y=x.clientWidth,v=x.clientHeight,b=new ANe;b.background=new yn(1710618),s.current=b;const E=new Wa(45,y/v,.1,1e4);E.position.set(150,150,150),a.current=E;const S=new CDe({antialias:!0});S.setSize(y,v),S.setPixelRatio(window.devicePixelRatio),x.appendChild(S.domElement),i.current=S;const A=new kDe(E,S.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new UNe(16777215,.6);b.add(T);const k=new J8(16777215,.8);k.position.set(100,100,100),b.add(k);const N=new J8(16777215,.4);N.position.set(-100,50,-100),b.add(N);const I=Math.max(e.x,e.y),C=Math.ceil(I/16),D=new zNe(I,C,4473924,3355443);b.add(D);const F=new nj(e.x,e.y),j=new JO({color:44610,transparent:!0,opacity:.15,side:tl}),q=new ml(F,j);q.rotation.x=-Math.PI/2,q.position.y=-.5,b.add(q);let R;const W=()=>{R=requestAnimationFrame(W),A.update(),S.render(b,E)};W(),fetch(t).then(V=>{if(!V.ok)throw new Error("Failed to load file");return V.arrayBuffer()}).then(KDe).then(({objects:V,buildItems:te})=>{if(V.size===0)throw new Error("No meshes found in 3MF file");const Y=new DNe({color:44610,shininess:30,flatShading:!1}),Z=new Tx,U=[];if(te.length>0)for(const re of te){const ve=V.get(re.objectId);if(ve)for(const je of ve.meshes){const ue=[];for(let $=0;$<je.vertices.length;$+=3){const H=new Je(je.vertices[$],je.vertices[$+1],je.vertices[$+2]);H.applyMatrix4(re.transform),ue.push(H.x,H.y,H.z)}const ut=PH({vertices:ue,triangles:je.triangles});U.push(ut)}}else for(const re of V.values())for(const ve of re.meshes){const je=PH(ve);U.push(je)}if(U.length>0){const re=U.length===1?U[0]:$De(U,!1);if(re){const ve=new ml(re,Y);Z.add(ve)}if(U.length>1)for(const ve of U)ve.dispose()}const z=new Zh().setFromObject(Z),ee=z.getCenter(new Je);Z.position.y=-z.min.y,te.length===0&&(Z.position.x=-ee.x,Z.position.z=-ee.z),b.add(Z);const ae=new Zh().setFromObject(Z),fe=ae.getCenter(new Je),de=ae.getSize(new Je),ye=Math.max(de.x,de.y,de.z)*1.8;E.position.set(fe.x+ye*.7,fe.y+ye*.5,fe.z+ye*.7),A.target.copy(fe),A.update(),u(!1)}).catch(V=>{f(V.message),u(!1)});const K=()=>{if(!x)return;const V=x.clientWidth,te=x.clientHeight;E.aspect=V/te,E.updateProjectionMatrix(),S.setSize(V,te)};return window.addEventListener("resize",K),()=>{window.removeEventListener("resize",K),cancelAnimationFrame(R),A.dispose(),S.dispose(),x.removeChild(S.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=x=>{a.current&&a.current.position.multiplyScalar(x)};return c.jsxs("div",{className:`relative ${n}`,children:[c.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),l&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsx("p",{className:"text-red-400",children:d})}),!l&&!d&&c.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:c.jsx(Tue,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:c.jsx(kue,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:g,children:c.jsx(Bm,{className:"w-4 h-4"})})]})]})}const jE="159",dp={ROTATE:0,DOLLY:1,PAN:2},hp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},YDe=0,RH=1,ZDe=2,gZ=1,QDe=2,rc=3,ud=0,Ws=1,cc=2,qu=0,tm=1,DH=2,OH=3,jH=4,JDe=5,ih=100,eOe=101,tOe=102,LH=103,IH=104,nOe=200,rOe=201,iOe=202,sOe=203,yP=204,_P=205,aOe=206,oOe=207,lOe=208,cOe=209,uOe=210,dOe=211,hOe=212,fOe=213,pOe=214,mOe=0,gOe=1,xOe=2,Aw=3,bOe=4,vOe=5,yOe=6,_Oe=7,ij=0,wOe=1,SOe=2,Ku=0,EOe=1,MOe=2,AOe=3,TOe=4,COe=5,xZ=300,Mm=301,Am=302,wP=303,SP=304,LE=306,EP=1e3,Ao=1001,MP=1002,Xi=1003,UH=1004,zC=1005,qa=1006,NOe=1007,z0=1008,Xu=1009,kOe=1010,POe=1011,sj=1012,bZ=1013,Fu=1014,mc=1015,B0=1016,vZ=1017,yZ=1018,Mh=1020,ROe=1021,Ka=1023,DOe=1024,OOe=1025,Ah=1026,Tm=1027,jOe=1028,_Z=1029,LOe=1030,wZ=1031,SZ=1033,BC=33776,HC=33777,$C=33778,VC=33779,FH=35840,zH=35841,BH=35842,HH=35843,EZ=36196,$H=37492,VH=37496,GH=37808,WH=37809,qH=37810,KH=37811,XH=37812,YH=37813,ZH=37814,QH=37815,JH=37816,e$=37817,t$=37818,n$=37819,r$=37820,i$=37821,GC=36492,s$=36494,a$=36495,IOe=36283,o$=36284,l$=36285,c$=36286,MZ=3e3,Th=3001,UOe=3200,FOe=3201,AZ=0,zOe=1,Xa="",Yi="srgb",Oc="srgb-linear",aj="display-p3",IE="display-p3-linear",Tw="linear",lr="srgb",Cw="rec709",Nw="p3",fp=7680,u$=519,BOe=512,HOe=513,$Oe=514,TZ=515,VOe=516,GOe=517,WOe=518,qOe=519,AP=35044,d$="300 es",TP=1035,al=2e3,H0=2001;class hf{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 ss=["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 h$=1234567;const zx=Math.PI/180,$0=180/Math.PI;function wc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ss[t&255]+ss[t>>8&255]+ss[t>>16&255]+ss[t>>24&255]+"-"+ss[e&255]+ss[e>>8&255]+"-"+ss[e>>16&15|64]+ss[e>>24&255]+"-"+ss[n&63|128]+ss[n>>8&255]+"-"+ss[n>>16&255]+ss[n>>24&255]+ss[r&255]+ss[r>>8&255]+ss[r>>16&255]+ss[r>>24&255]).toLowerCase()}function Zi(t,e,n){return Math.max(e,Math.min(n,t))}function oj(t,e){return(t%e+e)%e}function KOe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function XOe(t,e,n){return t!==e?(n-t)/(e-t):0}function Bx(t,e,n){return(1-n)*t+n*e}function YOe(t,e,n,r){return Bx(t,e,1-Math.exp(-n*r))}function ZOe(t,e=1){return e-Math.abs(oj(t,e*2)-e)}function QOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function JOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function eje(t,e){return t+Math.floor(Math.random()*(e-t+1))}function tje(t,e){return t+Math.random()*(e-t)}function nje(t){return t*(.5-Math.random())}function rje(t){t!==void 0&&(h$=t);let e=h$+=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 ije(t){return t*zx}function sje(t){return t*$0}function CP(t){return(t&t-1)===0&&t!==0}function aje(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function kw(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function oje(t,e,n,r,i){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),u=s((e+r)/2),d=a((e+r)/2),f=s((e-r)/2),g=a((e-r)/2),m=s((r-e)/2),x=a((r-e)/2);switch(i){case"XYX":t.set(o*d,l*f,l*g,o*u);break;case"YZY":t.set(l*g,o*d,l*f,o*u);break;case"ZXZ":t.set(l*f,l*g,o*d,o*u);break;case"XZX":t.set(o*d,l*x,l*m,o*u);break;case"YXY":t.set(l*m,o*d,l*x,o*u);break;case"ZYZ":t.set(l*x,l*m,o*d,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function nl(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 qn(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 CZ={DEG2RAD:zx,RAD2DEG:$0,generateUUID:wc,clamp:Zi,euclideanModulo:oj,mapLinear:KOe,inverseLerp:XOe,lerp:Bx,damp:YOe,pingpong:ZOe,smoothstep:QOe,smootherstep:JOe,randInt:eje,randFloat:tje,randFloatSpread:nje,seededRandom:rje,degToRad:ije,radToDeg:sje,isPowerOfTwo:CP,ceilPowerOfTwo:aje,floorPowerOfTwo:kw,setQuaternionFromProperEuler:oje,normalize:qn,denormalize:nl};class Yt{constructor(e=0,n=0){Yt.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(Zi(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 hn{constructor(e,n,r,i,s,a,o,l,u){hn.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,u)}set(e,n,r,i,s,a,o,l,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=l,d[6]=r,d[7]=a,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,s=this.elements,a=r[0],o=r[3],l=r[6],u=r[1],d=r[4],f=r[7],g=r[2],m=r[5],x=r[8],y=i[0],v=i[3],b=i[6],E=i[1],S=i[4],A=i[7],T=i[2],k=i[5],N=i[8];return s[0]=a*y+o*E+l*T,s[3]=a*v+o*S+l*k,s[6]=a*b+o*A+l*N,s[1]=u*y+d*E+f*T,s[4]=u*v+d*S+f*k,s[7]=u*b+d*A+f*N,s[2]=g*y+m*E+x*T,s[5]=g*v+m*S+x*k,s[8]=g*b+m*A+x*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8];return n*a*d-n*o*u-r*s*d+r*o*l+i*s*u-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],u=e[7],d=e[8],f=d*a-o*u,g=o*l-d*s,m=u*s-a*l,x=n*f+r*g+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(o*r-i*a)*y,e[3]=g*y,e[4]=(d*n-i*l)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*l-u*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),u=Math.sin(s);return this.set(r*l,r*u,-r*(l*a+u*o)+a+e,-i*u,i*l,-i*(-u*a+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(WC.makeScale(e,n)),this}rotate(e){return this.premultiply(WC.makeRotation(-e)),this}translate(e,n){return this.premultiply(WC.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const WC=new hn;function NZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Pw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function lje(){const t=Pw("canvas");return t.style.display="block",t}const f$={};function Hx(t){t in f$||(f$[t]=!0,console.warn(t))}const p$=new hn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),m$=new hn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Zy={[Oc]:{transfer:Tw,primaries:Cw,toReference:t=>t,fromReference:t=>t},[Yi]:{transfer:lr,primaries:Cw,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[IE]:{transfer:Tw,primaries:Nw,toReference:t=>t.applyMatrix3(m$),fromReference:t=>t.applyMatrix3(p$)},[aj]:{transfer:lr,primaries:Nw,toReference:t=>t.convertSRGBToLinear().applyMatrix3(m$),fromReference:t=>t.applyMatrix3(p$).convertLinearToSRGB()}},cje=new Set([Oc,IE]),Kn={enabled:!0,_workingColorSpace:Oc,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(!cje.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=Zy[e].toReference,i=Zy[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 Zy[t].primaries},getTransfer:function(t){return t===Xa?Tw:Zy[t].transfer}};function nm(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function qC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let pp;class kZ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{pp===void 0&&(pp=Pw("canvas")),pp.width=e.width,pp.height=e.height;const r=pp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=pp}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=Pw("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]=nm(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(nm(n[r]/255)*255):n[r]=nm(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 uje=0;class PZ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:uje++}),this.uuid=wc(),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(KC(i[a].image)):s.push(KC(i[a]))}else s=KC(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function KC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?kZ.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 dje=0;class qs extends hf{constructor(e=qs.DEFAULT_IMAGE,n=qs.DEFAULT_MAPPING,r=Ao,i=Ao,s=qa,a=z0,o=Ka,l=Xu,u=qs.DEFAULT_ANISOTROPY,d=Xa){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dje++}),this.uuid=wc(),this.name="",this.source=new PZ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=a,this.anisotropy=u,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Yt(0,0),this.repeat=new Yt(1,1),this.center=new Yt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new hn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Hx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Th?Yi:Xa),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!==xZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case EP:e.x=e.x-Math.floor(e.x);break;case Ao:e.x=e.x<0?0:1;break;case MP:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case EP:e.y=e.y-Math.floor(e.y);break;case Ao:e.y=e.y<0?0:1;break;case MP: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 Hx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Yi?Th:MZ}set encoding(e){Hx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Th?Yi:Xa}}qs.DEFAULT_IMAGE=null;qs.DEFAULT_MAPPING=xZ;qs.DEFAULT_ANISOTROPY=1;class Yn{constructor(e=0,n=0,r=0,i=1){Yn.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,u=l[0],d=l[4],f=l[8],g=l[1],m=l[5],x=l[9],y=l[2],v=l[6],b=l[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const S=(u+1)/2,A=(m+1)/2,T=(b+1)/2,k=(d+g)/4,N=(f+y)/4,I=(x+v)/4;return S>A&&S>T?S<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(S),i=k/r,s=N/r):A>T?A<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(A),r=k/i,s=I/i):T<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(T),r=N/s,i=I/s),this.set(r,i,s,n),this}let E=Math.sqrt((v-x)*(v-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(v-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+m+b-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class hje extends hf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Yn(0,0,e,n),this.scissorTest=!1,this.viewport=new Yn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Hx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Th?Yi:Xa),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qa,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new qs(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 PZ(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 Qh extends hje{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class RZ extends qs{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=Xi,this.minFilter=Xi,this.wrapR=Ao,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class fje extends qs{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=Xi,this.minFilter=Xi,this.wrapR=Ao,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Jh{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],u=r[i+1],d=r[i+2],f=r[i+3];const g=s[a+0],m=s[a+1],x=s[a+2],y=s[a+3];if(o===0){e[n+0]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(o===1){e[n+0]=g,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(f!==y||l!==g||u!==m||d!==x){let v=1-o;const b=l*g+u*m+d*x+f*y,E=b>=0?1:-1,S=1-b*b;if(S>Number.EPSILON){const T=Math.sqrt(S),k=Math.atan2(T,b*E);v=Math.sin(v*k)/T,o=Math.sin(o*k)/T}const A=o*E;if(l=l*v+g*A,u=u*v+m*A,d=d*v+x*A,f=f*v+y*A,v===1-o){const T=1/Math.sqrt(l*l+u*u+d*d+f*f);l*=T,u*=T,d*=T,f*=T}}e[n]=l,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],l=r[i+1],u=r[i+2],d=r[i+3],f=s[a],g=s[a+1],m=s[a+2],x=s[a+3];return e[n]=o*x+d*f+l*m-u*g,e[n+1]=l*x+d*g+u*f-o*m,e[n+2]=u*x+d*m+o*g-l*f,e[n+3]=d*x-o*f-l*g-u*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,u=o(r/2),d=o(i/2),f=o(s/2),g=l(r/2),m=l(i/2),x=l(s/2);switch(a){case"XYZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"YXZ":this._x=g*d*f+u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"ZXY":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f-g*m*x;break;case"ZYX":this._x=g*d*f-u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f+g*m*x;break;case"YZX":this._x=g*d*f+u*m*x,this._y=u*m*f+g*d*x,this._z=u*d*x-g*m*f,this._w=u*d*f-g*m*x;break;case"XZY":this._x=g*d*f-u*m*x,this._y=u*m*f-g*d*x,this._z=u*d*x+g*m*f,this._w=u*d*f+g*m*x;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],u=n[2],d=n[6],f=n[10],g=r+o+f;if(g>0){const m=.5/Math.sqrt(g+1);this._w=.25/m,this._x=(d-l)*m,this._y=(s-u)*m,this._z=(a-i)*m}else if(r>o&&r>f){const m=2*Math.sqrt(1+r-o-f);this._w=(d-l)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+u)/m}else if(o>f){const m=2*Math.sqrt(1+o-r-f);this._w=(s-u)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(a-i)/m,this._x=(s+u)/m,this._y=(l+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Zi(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,u=n._z,d=n._w;return this._x=r*d+a*o+i*u-s*l,this._y=i*d+a*l+s*o-r*u,this._z=s*d+a*u+r*l-i*o,this._w=a*d-r*o-i*l-s*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,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 u=Math.sqrt(l),d=Math.atan2(u,o),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=a*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=s*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),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 De{constructor(e=0,n=0,r=0){De.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(g$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(g$.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,u=2*(a*i-o*r),d=2*(o*n-s*i),f=2*(s*r-a*n);return this.x=n+l*u+a*f-o*d,this.y=r+l*d+o*u-s*f,this.z=i+l*f+s*d-a*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,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 XC.copy(this).projectOnVector(e),this.sub(XC)}reflect(e){return this.sub(XC.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(Zi(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 XC=new De,g$=new Jh;class to{constructor(e=new De(1/0,1/0,1/0),n=new De(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(vo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(vo.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=vo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const 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,vo):vo.fromBufferAttribute(s,a),vo.applyMatrix4(e.matrixWorld),this.expandByPoint(vo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Qy.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Qy.copy(r.boundingBox)),Qy.applyMatrix4(e.matrixWorld),this.union(Qy)}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,vo),vo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mx),Jy.subVectors(this.max,mx),mp.subVectors(e.a,mx),gp.subVectors(e.b,mx),xp.subVectors(e.c,mx),gu.subVectors(gp,mp),xu.subVectors(xp,gp),Wd.subVectors(mp,xp);let n=[0,-gu.z,gu.y,0,-xu.z,xu.y,0,-Wd.z,Wd.y,gu.z,0,-gu.x,xu.z,0,-xu.x,Wd.z,0,-Wd.x,-gu.y,gu.x,0,-xu.y,xu.x,0,-Wd.y,Wd.x,0];return!YC(n,mp,gp,xp,Jy)||(n=[1,0,0,0,1,0,0,0,1],!YC(n,mp,gp,xp,Jy))?!1:(e_.crossVectors(gu,xu),n=[e_.x,e_.y,e_.z],YC(n,mp,gp,xp,Jy))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Kl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Kl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Kl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Kl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Kl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Kl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Kl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Kl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Kl),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 Kl=[new De,new De,new De,new De,new De,new De,new De,new De],vo=new De,Qy=new to,mp=new De,gp=new De,xp=new De,gu=new De,xu=new De,Wd=new De,mx=new De,Jy=new De,e_=new De,qd=new De;function YC(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){qd.fromArray(t,s);const o=i.x*Math.abs(qd.x)+i.y*Math.abs(qd.y)+i.z*Math.abs(qd.z),l=e.dot(qd),u=n.dot(qd),d=r.dot(qd);if(Math.max(-Math.max(l,u,d),Math.min(l,u,d))>o)return!1}return!0}const pje=new to,gx=new De,ZC=new De;class ll{constructor(e=new De,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):pje.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;gx.subVectors(e,this.center);const n=gx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(gx,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):(ZC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gx.copy(e.center).add(ZC)),this.expandByPoint(gx.copy(e.center).sub(ZC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Xl=new De,QC=new De,t_=new De,bu=new De,JC=new De,n_=new De,eN=new De;class lj{constructor(e=new De,n=new De(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Xl)),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=Xl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Xl.copy(this.origin).addScaledVector(this.direction,n),Xl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){QC.copy(e).add(n).multiplyScalar(.5),t_.copy(n).sub(e).normalize(),bu.copy(this.origin).sub(QC);const s=e.distanceTo(n)*.5,a=-this.direction.dot(t_),o=bu.dot(this.direction),l=-bu.dot(t_),u=bu.lengthSq(),d=Math.abs(1-a*a);let f,g,m,x;if(d>0)if(f=a*l-o,g=a*o-l,x=s*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,m=f*(f+a*g+2*o)+g*(a*f+g+2*l)+u}else g=s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g=-s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;else g<=-x?(f=Math.max(0,-(-a*s+o)),g=f>0?-s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u):g<=x?(f=0,g=Math.min(Math.max(-s,-l),s),m=g*(g+2*l)+u):(f=Math.max(0,-(a*s+o)),g=f>0?s:Math.min(Math.max(-s,-l),s),m=-f*f+g*(g+2*l)+u);else g=a>0?-s:s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*l)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(QC).addScaledVector(t_,g),m}intersectSphere(e,n){Xl.subVectors(e.center,this.origin);const r=Xl.dot(this.direction),i=Xl.dot(Xl)-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 u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(s=(e.min.y-g.y)*d,a=(e.max.y-g.y)*d):(s=(e.max.y-g.y)*d,a=(e.min.y-g.y)*d),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),f>=0?(o=(e.min.z-g.z)*f,l=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,l=(e.min.z-g.z)*f),r>l||o>i)||((o>r||r!==r)&&(r=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Xl)!==null}intersectTriangle(e,n,r,i,s){JC.subVectors(n,e),n_.subVectors(r,e),eN.crossVectors(JC,n_);let a=this.direction.dot(eN),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;bu.subVectors(this.origin,e);const l=o*this.direction.dot(n_.crossVectors(bu,n_));if(l<0)return null;const u=o*this.direction.dot(JC.cross(bu));if(u<0||l+u>a)return null;const d=-o*bu.dot(eN);return d<0?null:this.at(d/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class sr{constructor(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){sr.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,u,d,f,g,m,x,y,v)}set(e,n,r,i,s,a,o,l,u,d,f,g,m,x,y,v){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=s,b[5]=a,b[9]=o,b[13]=l,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=m,b[7]=x,b[11]=y,b[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 sr().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/bp.setFromMatrixColumn(e,0).length(),s=1/bp.setFromMatrixColumn(e,1).length(),a=1/bp.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),u=Math.sin(i),d=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=-l*f,n[8]=u,n[1]=m+x*u,n[5]=g-y*u,n[9]=-o*l,n[2]=y-g*u,n[6]=x+m*u,n[10]=a*l}else if(e.order==="YXZ"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g+y*o,n[4]=x*o-m,n[8]=a*u,n[1]=a*f,n[5]=a*d,n[9]=-o,n[2]=m*o-x,n[6]=y+g*o,n[10]=a*l}else if(e.order==="ZXY"){const g=l*d,m=l*f,x=u*d,y=u*f;n[0]=g-y*o,n[4]=-a*f,n[8]=x+m*o,n[1]=m+x*o,n[5]=a*d,n[9]=y-g*o,n[2]=-a*u,n[6]=o,n[10]=a*l}else if(e.order==="ZYX"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=l*d,n[4]=x*u-m,n[8]=g*u+y,n[1]=l*f,n[5]=y*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*l,n[10]=a*l}else if(e.order==="YZX"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=y-g*f,n[8]=x*f+m,n[1]=f,n[5]=a*d,n[9]=-o*d,n[2]=-u*d,n[6]=m*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=a*l,m=a*u,x=o*l,y=o*u;n[0]=l*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=a*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=o*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(mje,e,gje)}lookAt(e,n,r){const i=this.elements;return ca.subVectors(e,n),ca.lengthSq()===0&&(ca.z=1),ca.normalize(),vu.crossVectors(r,ca),vu.lengthSq()===0&&(Math.abs(r.z)===1?ca.x+=1e-4:ca.z+=1e-4,ca.normalize(),vu.crossVectors(r,ca)),vu.normalize(),r_.crossVectors(ca,vu),i[0]=vu.x,i[4]=r_.x,i[8]=ca.x,i[1]=vu.y,i[5]=r_.y,i[9]=ca.y,i[2]=vu.z,i[6]=r_.z,i[10]=ca.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],u=r[12],d=r[1],f=r[5],g=r[9],m=r[13],x=r[2],y=r[6],v=r[10],b=r[14],E=r[3],S=r[7],A=r[11],T=r[15],k=i[0],N=i[4],I=i[8],C=i[12],D=i[1],F=i[5],j=i[9],q=i[13],R=i[2],W=i[6],K=i[10],V=i[14],te=i[3],Y=i[7],Z=i[11],U=i[15];return s[0]=a*k+o*D+l*R+u*te,s[4]=a*N+o*F+l*W+u*Y,s[8]=a*I+o*j+l*K+u*Z,s[12]=a*C+o*q+l*V+u*U,s[1]=d*k+f*D+g*R+m*te,s[5]=d*N+f*F+g*W+m*Y,s[9]=d*I+f*j+g*K+m*Z,s[13]=d*C+f*q+g*V+m*U,s[2]=x*k+y*D+v*R+b*te,s[6]=x*N+y*F+v*W+b*Y,s[10]=x*I+y*j+v*K+b*Z,s[14]=x*C+y*q+v*V+b*U,s[3]=E*k+S*D+A*R+T*te,s[7]=E*N+S*F+A*W+T*Y,s[11]=E*I+S*j+A*K+T*Z,s[15]=E*C+S*q+A*V+T*U,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],s=e[12],a=e[1],o=e[5],l=e[9],u=e[13],d=e[2],f=e[6],g=e[10],m=e[14],x=e[3],y=e[7],v=e[11],b=e[15];return x*(+s*l*f-i*u*f-s*o*g+r*u*g+i*o*m-r*l*m)+y*(+n*l*m-n*u*g+s*a*g-i*a*m+i*u*d-s*l*d)+v*(+n*u*f-n*o*m-s*a*f+r*a*m+s*o*d-r*u*d)+b*(-i*o*d-n*l*f+n*o*g+i*a*f-r*a*g+r*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],x=e[12],y=e[13],v=e[14],b=e[15],E=f*v*u-y*g*u+y*l*m-o*v*m-f*l*b+o*g*b,S=x*g*u-d*v*u-x*l*m+a*v*m+d*l*b-a*g*b,A=d*y*u-x*f*u+x*o*m-a*y*m-d*o*b+a*f*b,T=x*f*l-d*y*l-x*o*g+a*y*g+d*o*v-a*f*v,k=n*E+r*S+i*A+s*T;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/k;return e[0]=E*N,e[1]=(y*g*s-f*v*s-y*i*m+r*v*m+f*i*b-r*g*b)*N,e[2]=(o*v*s-y*l*s+y*i*u-r*v*u-o*i*b+r*l*b)*N,e[3]=(f*l*s-o*g*s-f*i*u+r*g*u+o*i*m-r*l*m)*N,e[4]=S*N,e[5]=(d*v*s-x*g*s+x*i*m-n*v*m-d*i*b+n*g*b)*N,e[6]=(x*l*s-a*v*s-x*i*u+n*v*u+a*i*b-n*l*b)*N,e[7]=(a*g*s-d*l*s+d*i*u-n*g*u-a*i*m+n*l*m)*N,e[8]=A*N,e[9]=(x*f*s-d*y*s-x*r*m+n*y*m+d*r*b-n*f*b)*N,e[10]=(a*y*s-x*o*s+x*r*u-n*y*u-a*r*b+n*o*b)*N,e[11]=(d*o*s-a*f*s-d*r*u+n*f*u+a*r*m-n*o*m)*N,e[12]=T*N,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*v+n*f*v)*N,e[14]=(x*o*i-a*y*i-x*r*l+n*y*l+a*r*v-n*o*v)*N,e[15]=(a*f*i-d*o*i+d*r*l-n*f*l-a*r*g+n*o*g)*N,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,u=s*a,d=s*o;return this.set(u*a+r,u*o-i*l,u*l+i*o,0,u*o+i*l,d*o+r,d*l-i*a,0,u*l-i*o,d*l+i*a,s*l*l+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,s=n._x,a=n._y,o=n._z,l=n._w,u=s+s,d=a+a,f=o+o,g=s*u,m=s*d,x=s*f,y=a*d,v=a*f,b=o*f,E=l*u,S=l*d,A=l*f,T=r.x,k=r.y,N=r.z;return i[0]=(1-(y+b))*T,i[1]=(m+A)*T,i[2]=(x-S)*T,i[3]=0,i[4]=(m-A)*k,i[5]=(1-(g+b))*k,i[6]=(v+E)*k,i[7]=0,i[8]=(x+S)*N,i[9]=(v-E)*N,i[10]=(1-(g+y))*N,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let s=bp.set(i[0],i[1],i[2]).length();const a=bp.set(i[4],i[5],i[6]).length(),o=bp.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],yo.copy(this);const u=1/s,d=1/a,f=1/o;return yo.elements[0]*=u,yo.elements[1]*=u,yo.elements[2]*=u,yo.elements[4]*=d,yo.elements[5]*=d,yo.elements[6]*=d,yo.elements[8]*=f,yo.elements[9]*=f,yo.elements[10]*=f,n.setFromRotationMatrix(yo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=al){const l=this.elements,u=2*s/(n-e),d=2*s/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let m,x;if(o===al)m=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===H0)m=-a/(a-s),x=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=d,l[9]=g,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=al){const l=this.elements,u=1/(n-e),d=1/(r-i),f=1/(a-s),g=(n+e)*u,m=(r+i)*d;let x,y;if(o===al)x=(a+s)*f,y=-2*f;else if(o===H0)x=s*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*u,l[4]=0,l[8]=0,l[12]=-g,l[1]=0,l[5]=2*d,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=y,l[14]=-x,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 bp=new De,yo=new sr,mje=new De(0,0,0),gje=new De(1,1,1),vu=new De,r_=new De,ca=new De,x$=new sr,b$=new Jh;class zb{constructor(e=0,n=0,r=0,i=zb.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],u=i[5],d=i[9],f=i[2],g=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Zi(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Zi(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Zi(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Zi(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(Zi(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Zi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return x$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(x$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return b$.setFromEuler(this),this.setFromQuaternion(b$,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}}zb.DEFAULT_ORDER="XYZ";class DZ{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 xje=0;const v$=new De,vp=new Jh,Yl=new sr,i_=new De,xx=new De,bje=new De,vje=new Jh,y$=new De(1,0,0),_$=new De(0,1,0),w$=new De(0,0,1),yje={type:"added"},_je={type:"removed"};class As extends hf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:xje++}),this.uuid=wc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=As.DEFAULT_UP.clone();const e=new De,n=new zb,r=new Jh,i=new De(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 sr},normalMatrix:{value:new hn}}),this.matrix=new sr,this.matrixWorld=new sr,this.matrixAutoUpdate=As.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=As.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new DZ,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 vp.setFromAxisAngle(e,n),this.quaternion.multiply(vp),this}rotateOnWorldAxis(e,n){return vp.setFromAxisAngle(e,n),this.quaternion.premultiply(vp),this}rotateX(e){return this.rotateOnAxis(y$,e)}rotateY(e){return this.rotateOnAxis(_$,e)}rotateZ(e){return this.rotateOnAxis(w$,e)}translateOnAxis(e,n){return v$.copy(e).applyQuaternion(this.quaternion),this.position.add(v$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(y$,e)}translateY(e){return this.translateOnAxis(_$,e)}translateZ(e){return this.translateOnAxis(w$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Yl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?i_.copy(e):i_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),xx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Yl.lookAt(xx,i_,this.up):Yl.lookAt(i_,xx,this.up),this.quaternion.setFromRotationMatrix(Yl),i&&(Yl.extractRotation(i.matrixWorld),vp.setFromRotationMatrix(Yl),this.quaternion.premultiply(vp.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(yje)):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(_je)),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),Yl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Yl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Yl),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(xx,e,bje),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xx,vje,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 u=0,d=l.length;u<d;u++){const f=l[u];s(e.shapes,f)}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,u=this.material.length;l<u;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),u=a(e.textures),d=a(e.images),f=a(e.shapes),g=a(e.skeletons),m=a(e.animations),x=a(e.nodes);o.length>0&&(r.geometries=o),l.length>0&&(r.materials=l),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function a(o){const l=[];for(const u in o){const d=o[u];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}As.DEFAULT_UP=new De(0,1,0);As.DEFAULT_MATRIX_AUTO_UPDATE=!0;As.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const _o=new De,Zl=new De,tN=new De,Ql=new De,yp=new De,_p=new De,S$=new De,nN=new De,rN=new De,iN=new De;let s_=!1;class wo{constructor(e=new De,n=new De,r=new De){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),_o.subVectors(e,n),i.cross(_o);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){_o.subVectors(i,n),Zl.subVectors(r,n),tN.subVectors(e,n);const a=_o.dot(_o),o=_o.dot(Zl),l=_o.dot(tN),u=Zl.dot(Zl),d=Zl.dot(tN),f=a*u-o*o;if(f===0)return s.set(-2,-1,-1);const g=1/f,m=(u*l-o*d)*g,x=(a*d-o*l)*g;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Ql),Ql.x>=0&&Ql.y>=0&&Ql.x+Ql.y<=1}static getUV(e,n,r,i,s,a,o,l){return s_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),s_=!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,Ql),l.setScalar(0),l.addScaledVector(s,Ql.x),l.addScaledVector(a,Ql.y),l.addScaledVector(o,Ql.z),l}static isFrontFacing(e,n,r,i){return _o.subVectors(r,n),Zl.subVectors(e,n),_o.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 _o.subVectors(this.c,this.b),Zl.subVectors(this.a,this.b),_o.cross(Zl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return wo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return wo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return s_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),s_=!0),wo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return wo.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return wo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return wo.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;yp.subVectors(i,r),_p.subVectors(s,r),nN.subVectors(e,r);const l=yp.dot(nN),u=_p.dot(nN);if(l<=0&&u<=0)return n.copy(r);rN.subVectors(e,i);const d=yp.dot(rN),f=_p.dot(rN);if(d>=0&&f<=d)return n.copy(i);const g=l*f-d*u;if(g<=0&&l>=0&&d<=0)return a=l/(l-d),n.copy(r).addScaledVector(yp,a);iN.subVectors(e,s);const m=yp.dot(iN),x=_p.dot(iN);if(x>=0&&m<=x)return n.copy(s);const y=m*u-l*x;if(y<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(_p,o);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return S$.subVectors(s,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(S$,o);const b=1/(v+y+g);return a=y*b,o=g*b,n.copy(r).addScaledVector(yp,a).addScaledVector(_p,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const OZ={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},yu={h:0,s:0,l:0},a_={h:0,s:0,l:0};function sN(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let $t=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Yi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Kn.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Kn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Kn.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Kn.workingColorSpace){if(e=oj(e,1),n=Zi(n,0,1),r=Zi(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=sN(a,s,e+1/3),this.g=sN(a,s,e),this.b=sN(a,s,e-1/3)}return Kn.toWorkingColorSpace(this,i),this}setStyle(e,n=Yi){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=Yi){const r=OZ[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=nm(e.r),this.g=nm(e.g),this.b=nm(e.b),this}copyLinearToSRGB(e){return this.r=qC(e.r),this.g=qC(e.g),this.b=qC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Yi){return Kn.fromWorkingColorSpace(as.copy(this),e),Math.round(Zi(as.r*255,0,255))*65536+Math.round(Zi(as.g*255,0,255))*256+Math.round(Zi(as.b*255,0,255))}getHexString(e=Yi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Kn.workingColorSpace){Kn.fromWorkingColorSpace(as.copy(this),n);const r=as.r,i=as.g,s=as.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,u;const d=(o+a)/2;if(o===a)l=0,u=0;else{const f=a-o;switch(u=d<=.5?f/(a+o):f/(2-a-o),a){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return e.h=l,e.s=u,e.l=d,e}getRGB(e,n=Kn.workingColorSpace){return Kn.fromWorkingColorSpace(as.copy(this),n),e.r=as.r,e.g=as.g,e.b=as.b,e}getStyle(e=Yi){Kn.fromWorkingColorSpace(as.copy(this),e);const n=as.r,r=as.g,i=as.b;return e!==Yi?`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(yu),this.setHSL(yu.h+e,yu.s+n,yu.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(yu),e.getHSL(a_);const r=Bx(yu.h,a_.h,n),i=Bx(yu.s,a_.s,n),s=Bx(yu.l,a_.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 as=new $t;$t.NAMES=OZ;let wje=0;class ng extends hf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wje++}),this.uuid=wc(),this.name="",this.type="Material",this.blending=tm,this.side=ud,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=yP,this.blendDst=_P,this.blendEquation=ih,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new $t(0,0,0),this.blendAlpha=0,this.depthFunc=Aw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=u$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fp,this.stencilZFail=fp,this.stencilZPass=fp,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!==tm&&(r.blending=this.blending),this.side!==ud&&(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!==yP&&(r.blendSrc=this.blendSrc),this.blendDst!==_P&&(r.blendDst=this.blendDst),this.blendEquation!==ih&&(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!==Aw&&(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!==u$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==fp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==fp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==fp&&(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 jZ extends ng{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new $t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ij,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 Wr=new De,o_=new Yt;class va{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=AP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=mc,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++)o_.fromBufferAttribute(this,n),o_.applyMatrix3(e),this.setXY(n,o_.x,o_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Wr.fromBufferAttribute(this,n),Wr.applyMatrix3(e),this.setXYZ(n,Wr.x,Wr.y,Wr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Wr.fromBufferAttribute(this,n),Wr.applyMatrix4(e),this.setXYZ(n,Wr.x,Wr.y,Wr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Wr.fromBufferAttribute(this,n),Wr.applyNormalMatrix(e),this.setXYZ(n,Wr.x,Wr.y,Wr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Wr.fromBufferAttribute(this,n),Wr.transformDirection(e),this.setXYZ(n,Wr.x,Wr.y,Wr.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=nl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=qn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=nl(n,this.array)),n}setX(e,n){return this.normalized&&(n=qn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=nl(n,this.array)),n}setY(e,n){return this.normalized&&(n=qn(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=nl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=qn(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=nl(n,this.array)),n}setW(e,n){return this.normalized&&(n=qn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=qn(n,this.array),r=qn(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=qn(n,this.array),r=qn(r,this.array),i=qn(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=qn(n,this.array),r=qn(r,this.array),i=qn(i,this.array),s=qn(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!==AP&&(e.usage=this.usage),e}}class LZ extends va{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class IZ extends va{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Fr extends va{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Sje=0;const ja=new sr,aN=new As,wp=new De,ua=new to,bx=new to,Ci=new De;class gs extends hf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Sje++}),this.uuid=wc(),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(NZ(e)?IZ:LZ)(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 hn().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 ja.makeRotationFromQuaternion(e),this.applyMatrix4(ja),this}rotateX(e){return ja.makeRotationX(e),this.applyMatrix4(ja),this}rotateY(e){return ja.makeRotationY(e),this.applyMatrix4(ja),this}rotateZ(e){return ja.makeRotationZ(e),this.applyMatrix4(ja),this}translate(e,n,r){return ja.makeTranslation(e,n,r),this.applyMatrix4(ja),this}scale(e,n,r){return ja.makeScale(e,n,r),this.applyMatrix4(ja),this}lookAt(e){return aN.lookAt(e),aN.updateMatrix(),this.applyMatrix4(aN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wp).negate(),this.translate(wp.x,wp.y,wp.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 Fr(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new to);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new De(-1/0,-1/0,-1/0),new De(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];ua.setFromBufferAttribute(s),this.morphTargetsRelative?(Ci.addVectors(this.boundingBox.min,ua.min),this.boundingBox.expandByPoint(Ci),Ci.addVectors(this.boundingBox.max,ua.max),this.boundingBox.expandByPoint(Ci)):(this.boundingBox.expandByPoint(ua.min),this.boundingBox.expandByPoint(ua.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 ll);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new De,1/0);return}if(e){const r=this.boundingSphere.center;if(ua.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];bx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ci.addVectors(ua.min,bx.min),ua.expandByPoint(Ci),Ci.addVectors(ua.max,bx.max),ua.expandByPoint(Ci)):(ua.expandByPoint(bx.min),ua.expandByPoint(bx.max))}ua.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Ci.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ci));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],l=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ci.fromBufferAttribute(o,u),l&&(wp.fromBufferAttribute(e,u),Ci.add(wp)),i=Math.max(i,r.distanceToSquared(Ci))}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 va(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<o;D++)u[D]=new De,d[D]=new De;const f=new De,g=new De,m=new De,x=new Yt,y=new Yt,v=new Yt,b=new De,E=new De;function S(D,F,j){f.fromArray(i,D*3),g.fromArray(i,F*3),m.fromArray(i,j*3),x.fromArray(a,D*2),y.fromArray(a,F*2),v.fromArray(a,j*2),g.sub(f),m.sub(f),y.sub(x),v.sub(x);const q=1/(y.x*v.y-v.x*y.y);isFinite(q)&&(b.copy(g).multiplyScalar(v.y).addScaledVector(m,-y.y).multiplyScalar(q),E.copy(m).multiplyScalar(y.x).addScaledVector(g,-v.x).multiplyScalar(q),u[D].add(b),u[F].add(b),u[j].add(b),d[D].add(E),d[F].add(E),d[j].add(E))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let D=0,F=A.length;D<F;++D){const j=A[D],q=j.start,R=j.count;for(let W=q,K=q+R;W<K;W+=3)S(r[W+0],r[W+1],r[W+2])}const T=new De,k=new De,N=new De,I=new De;function C(D){N.fromArray(s,D*3),I.copy(N);const F=u[D];T.copy(F),T.sub(N.multiplyScalar(N.dot(F))).normalize(),k.crossVectors(I,F);const q=k.dot(d[D])<0?-1:1;l[D*4]=T.x,l[D*4+1]=T.y,l[D*4+2]=T.z,l[D*4+3]=q}for(let D=0,F=A.length;D<F;++D){const j=A[D],q=j.start,R=j.count;for(let W=q,K=q+R;W<K;W+=3)C(r[W+0]),C(r[W+1]),C(r[W+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new va(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 De,s=new De,a=new De,o=new De,l=new De,u=new De,d=new De,f=new De;if(e)for(let g=0,m=e.count;g<m;g+=3){const x=e.getX(g+0),y=e.getX(g+1),v=e.getX(g+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),a.fromBufferAttribute(n,v),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),o.fromBufferAttribute(r,x),l.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),l.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(y,l.x,l.y,l.z),r.setXYZ(v,u.x,u.y,u.z)}else for(let g=0,m=n.count;g<m;g+=3)i.fromBufferAttribute(n,g+0),s.fromBufferAttribute(n,g+1),a.fromBufferAttribute(n,g+2),d.subVectors(a,s),f.subVectors(i,s),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ci.fromBufferAttribute(e,n),Ci.normalize(),e.setXYZ(n,Ci.x,Ci.y,Ci.z)}toNonIndexed(){function e(o,l){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(l.length*d);let m=0,x=0;for(let y=0,v=l.length;y<v;y++){o.isInterleavedBufferAttribute?m=l[y]*o.data.stride+o.offset:m=l[y]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new va(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new gs,r=this.index.array,i=this.attributes;for(const o in i){const l=i[o],u=e(l,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const l=[],u=s[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const u=a[o];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const u in l)l[u]!==void 0&&(e[u]=l[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const l in r){const u=r[l];e.data.attributes[l]=u.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const u=this.morphAttributes[l],d=[];for(let f=0,g=u.length;f<g;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[l]=d,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const s=e.morphAttributes;for(const u in s){const d=[],f=s[u];for(let g=0,m=f.length;g<m;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let u=0,d=a.length;u<d;u++){const f=a[u];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const E$=new sr,Kd=new lj,l_=new ll,M$=new De,Sp=new De,Ep=new De,Mp=new De,oN=new De,c_=new De,u_=new Yt,d_=new Yt,h_=new Yt,A$=new De,T$=new De,C$=new De,f_=new De,p_=new De;class ko extends As{constructor(e=new gs,n=new jZ){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){c_.set(0,0,0);for(let l=0,u=s.length;l<u;l++){const d=o[l],f=s[l];d!==0&&(oN.fromBufferAttribute(f,e),a?c_.addScaledVector(oN,d):c_.addScaledVector(oN.sub(n),d))}n.add(c_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),l_.copy(r.boundingSphere),l_.applyMatrix4(s),Kd.copy(e.ray).recast(e.near),!(l_.containsPoint(Kd.origin)===!1&&(Kd.intersectSphere(l_,M$)===null||Kd.origin.distanceToSquared(M$)>(e.far-e.near)**2))&&(E$.copy(s).invert(),Kd.copy(e.ray).applyMatrix4(E$),!(r.boundingBox!==null&&Kd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Kd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,u=s.attributes.uv,d=s.attributes.uv1,f=s.attributes.normal,g=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const k=o.getX(A),N=o.getX(A+1),I=o.getX(A+2);i=m_(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=o.getX(v),S=o.getX(v+1),A=o.getX(v+2);i=m_(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let x=0,y=g.length;x<y;x++){const v=g[x],b=a[v.materialIndex],E=Math.max(v.start,m.start),S=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let A=E,T=S;A<T;A+=3){const k=A,N=A+1,I=A+2;i=m_(this,b,e,r,u,d,f,k,N,I),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const E=v,S=v+1,A=v+2;i=m_(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function Eje(t,e,n,r,i,s,a,o){let l;if(e.side===Ws?l=r.intersectTriangle(a,s,i,!0,o):l=r.intersectTriangle(i,s,a,e.side===ud,o),l===null)return null;p_.copy(o),p_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(p_);return u<n.near||u>n.far?null:{distance:u,point:p_.clone(),object:t}}function m_(t,e,n,r,i,s,a,o,l,u){t.getVertexPosition(o,Sp),t.getVertexPosition(l,Ep),t.getVertexPosition(u,Mp);const d=Eje(t,e,n,r,Sp,Ep,Mp,f_);if(d){i&&(u_.fromBufferAttribute(i,o),d_.fromBufferAttribute(i,l),h_.fromBufferAttribute(i,u),d.uv=wo.getInterpolation(f_,Sp,Ep,Mp,u_,d_,h_,new Yt)),s&&(u_.fromBufferAttribute(s,o),d_.fromBufferAttribute(s,l),h_.fromBufferAttribute(s,u),d.uv1=wo.getInterpolation(f_,Sp,Ep,Mp,u_,d_,h_,new Yt),d.uv2=d.uv1),a&&(A$.fromBufferAttribute(a,o),T$.fromBufferAttribute(a,l),C$.fromBufferAttribute(a,u),d.normal=wo.getInterpolation(f_,Sp,Ep,Mp,A$,T$,C$,new De),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:o,b:l,c:u,normal:new De,materialIndex:0};wo.getNormal(Sp,Ep,Mp,f.normal),d.face=f}return d}class Bb extends gs{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=[],u=[],d=[],f=[];let g=0,m=0;x("z","y","x",-1,-1,r,n,e,a,s,0),x("z","y","x",1,-1,r,n,-e,a,s,1),x("x","z","y",1,1,e,r,n,i,a,2),x("x","z","y",1,-1,e,r,-n,i,a,3),x("x","y","z",1,-1,e,n,r,i,s,4),x("x","y","z",-1,-1,e,n,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new Fr(u,3)),this.setAttribute("normal",new Fr(d,3)),this.setAttribute("uv",new Fr(f,2));function x(y,v,b,E,S,A,T,k,N,I,C){const D=A/N,F=T/I,j=A/2,q=T/2,R=k/2,W=N+1,K=I+1;let V=0,te=0;const Y=new De;for(let Z=0;Z<K;Z++){const U=Z*F-q;for(let z=0;z<W;z++){const ee=z*D-j;Y[y]=ee*E,Y[v]=U*S,Y[b]=R,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=k>0?1:-1,d.push(Y.x,Y.y,Y.z),f.push(z/N),f.push(1-Z/I),V+=1}}for(let Z=0;Z<I;Z++)for(let U=0;U<N;U++){const z=g+U+W*Z,ee=g+U+W*(Z+1),ae=g+(U+1)+W*(Z+1),fe=g+(U+1)+W*Z;l.push(z,ee,fe),l.push(ee,ae,fe),te+=6}o.addGroup(m,te,C),m+=te,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bb(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Cm(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function _s(t){const e={};for(let n=0;n<t.length;n++){const r=Cm(t[n]);for(const i in r)e[i]=r[i]}return e}function Mje(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function UZ(t){return t.getRenderTarget()===null?t.outputColorSpace:Kn.workingColorSpace}const cj={clone:Cm,merge:_s};var Aje=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Tje=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class dd extends ng{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Aje,this.fragmentShader=Tje,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Cm(e.uniforms),this.uniformsGroups=Mje(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 FZ extends As{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new sr,this.projectionMatrix=new sr,this.projectionMatrixInverse=new sr,this.coordinateSystem=al}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 ha extends FZ{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=$0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(zx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $0*2*Math.atan(Math.tan(zx*.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(zx*.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,u=a.fullHeight;s+=a.offsetX*i/l,n-=a.offsetY*r/u,i*=a.width/l,r*=a.height/u}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 Ap=-90,Tp=1;class Cje extends As{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ha(Ap,Tp,e,n);i.layers=this.layers,this.add(i);const s=new ha(Ap,Tp,e,n);s.layers=this.layers,this.add(s);const a=new ha(Ap,Tp,e,n);a.layers=this.layers,this.add(a);const o=new ha(Ap,Tp,e,n);o.layers=this.layers,this.add(o);const l=new ha(Ap,Tp,e,n);l.layers=this.layers,this.add(l);const u=new ha(Ap,Tp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,l]=n;for(const u of n)this.remove(u);if(e===al)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===H0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=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,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class zZ extends qs{constructor(e,n,r,i,s,a,o,l,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Mm,super(e,n,r,i,s,a,o,l,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Nje extends Qh{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&&(Hx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Th?Yi:Xa),this.texture=new zZ(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:qa}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 Bb(5,5,5),s=new dd({name:"CubemapFromEquirect",uniforms:Cm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ws,blending:qu});s.uniforms.tEquirect.value=n;const a=new ko(i,s),o=n.minFilter;return n.minFilter===z0&&(n.minFilter=qa),new Cje(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 lN=new De,kje=new De,Pje=new hn;class Cu{constructor(e=new De(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=lN.subVectors(r,n).cross(kje.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(lN),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||Pje.getNormalMatrix(e),i=this.coplanarPoint(lN).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 Xd=new ll,g_=new De;class UE{constructor(e=new Cu,n=new Cu,r=new Cu,i=new Cu,s=new Cu,a=new Cu){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=al){const r=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],l=i[3],u=i[4],d=i[5],f=i[6],g=i[7],m=i[8],x=i[9],y=i[10],v=i[11],b=i[12],E=i[13],S=i[14],A=i[15];if(r[0].setComponents(l-s,g-u,v-m,A-b).normalize(),r[1].setComponents(l+s,g+u,v+m,A+b).normalize(),r[2].setComponents(l+a,g+d,v+x,A+E).normalize(),r[3].setComponents(l-a,g-d,v-x,A-E).normalize(),r[4].setComponents(l-o,g-f,v-y,A-S).normalize(),n===al)r[5].setComponents(l+o,g+f,v+y,A+S).normalize();else if(n===H0)r[5].setComponents(o,f,y,S).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(),Xd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Xd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Xd)}intersectsSprite(e){return Xd.center.set(0,0,0),Xd.radius=.7071067811865476,Xd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Xd)}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(g_.x=i.normal.x>0?e.max.x:e.min.x,g_.y=i.normal.y>0?e.max.y:e.min.y,g_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(g_)<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 BZ(){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 Rje(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,m=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,g),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:m}}function s(u,d,f){const g=d.array,m=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),m.count===-1&&x.length===0&&t.bufferSubData(f,0,g),x.length!==0){for(let y=0,v=x.length;y<v;y++){const b=x[y];n?t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g,b.start,b.count):t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g.subarray(b.start,b.start+b.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g,m.offset,m.count):t.bufferSubData(f,m.offset*g.BYTES_PER_ELEMENT,g.subarray(m.offset,m.offset+m.count)),m.count=-1),d.onUploadCallback()}function a(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function o(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function l(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(f.buffer,u,d),f.version=u.version}}return{get:a,remove:o,update:l}}class uj extends gs{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),u=o+1,d=l+1,f=e/o,g=n/l,m=[],x=[],y=[],v=[];for(let b=0;b<d;b++){const E=b*g-a;for(let S=0;S<u;S++){const A=S*f-s;x.push(A,-E,0),y.push(0,0,1),v.push(S/o),v.push(1-b/l)}}for(let b=0;b<l;b++)for(let E=0;E<o;E++){const S=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),k=E+1+u*b;m.push(S,A,k),m.push(A,T,k)}this.setIndex(m),this.setAttribute("position",new Fr(x,3)),this.setAttribute("normal",new Fr(y,3)),this.setAttribute("uv",new Fr(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uj(e.width,e.height,e.widthSegments,e.heightSegments)}}var Dje=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Oje=`#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`,jje=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Lje=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Ije=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,Uje=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Fje=`#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`,zje=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Bje=`#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`,Hje=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,$je=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,Vje=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,Gje=`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`,Wje=`#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`,qje=`#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`,Kje=`#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`,Xje=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,Yje=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,Zje=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,Qje=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,Jje=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,eLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,tLe=`#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`,nLe=`#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`,rLe=`#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`,iLe=`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`,sLe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,aLe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,oLe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,lLe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,cLe="gl_FragColor = linearToOutputTexel( gl_FragColor );",uLe=`
- 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 );
- }`,dLe=`#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`,hLe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,fLe=`#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`,pLe=`#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`,mLe=`#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`,gLe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,xLe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,bLe=`#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`,vLe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,yLe=`#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
- }`,_Le=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,wLe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,SLe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,ELe=`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`,MLe=`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`,ALe=`#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`,TLe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,CLe=`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`,NLe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,kLe=`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`,PLe=`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`,RLe=`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 );
- }`,DLe=`
- 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`,OLe=`#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`,jLe=`#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`,LLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,ILe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,ULe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,FLe=`#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`,zLe=`#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`,BLe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,HLe=`#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`,$Le=`#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`,VLe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,GLe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,WLe=`#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`,qLe=`#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`,KLe=`#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`,XLe=`#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`,YLe=`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;`,ZLe=`#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`,QLe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,JLe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,eIe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,tIe=`#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`,nIe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,rIe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,iIe=`#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`,sIe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,aIe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,oIe=`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 );
- }`,lIe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,cIe=`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;`,uIe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,dIe=`#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`,hIe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,fIe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,pIe=`#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`,mIe=`#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`,gIe=`#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`,xIe=`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;
- }`,bIe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,vIe=`#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`,yIe=`#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`,_Ie=`#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`,wIe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,SIe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,EIe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,MIe=`#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; }`,AIe=`#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`,TIe=`#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`,CIe=`#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`,NIe=`#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`,kIe=`#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`,PIe=`#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 RIe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,DIe=`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>
- }`,OIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,jIe=`#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>
- }`,LIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,IIe=`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>
- }`,UIe=`#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;
- }`,FIe=`#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
- }`,zIe=`#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;
- }`,BIe=`#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 );
- }`,HIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,$Ie=`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>
- }`,VIe=`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>
- }`,GIe=`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>
- }`,WIe=`#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>
- }`,qIe=`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>
- }`,KIe=`#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>
- }`,XIe=`#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>
- }`,YIe=`#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;
- }`,ZIe=`#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>
- }`,QIe=`#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
- }`,JIe=`#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
- }`,e4e=`#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>
- }`,t4e=`#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>
- }`,n4e=`#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
- }`,r4e=`#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>
- }`,i4e=`#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>
- }`,s4e=`#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>
- }`,a4e=`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>
- }`,o4e=`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>
- }`,l4e=`#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>
- }`,c4e=`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>
- }`,u4e=`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>
- }`,d4e=`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:Dje,alphahash_pars_fragment:Oje,alphamap_fragment:jje,alphamap_pars_fragment:Lje,alphatest_fragment:Ije,alphatest_pars_fragment:Uje,aomap_fragment:Fje,aomap_pars_fragment:zje,batching_pars_vertex:Bje,batching_vertex:Hje,begin_vertex:$je,beginnormal_vertex:Vje,bsdfs:Gje,iridescence_fragment:Wje,bumpmap_pars_fragment:qje,clipping_planes_fragment:Kje,clipping_planes_pars_fragment:Xje,clipping_planes_pars_vertex:Yje,clipping_planes_vertex:Zje,color_fragment:Qje,color_pars_fragment:Jje,color_pars_vertex:eLe,color_vertex:tLe,common:nLe,cube_uv_reflection_fragment:rLe,defaultnormal_vertex:iLe,displacementmap_pars_vertex:sLe,displacementmap_vertex:aLe,emissivemap_fragment:oLe,emissivemap_pars_fragment:lLe,colorspace_fragment:cLe,colorspace_pars_fragment:uLe,envmap_fragment:dLe,envmap_common_pars_fragment:hLe,envmap_pars_fragment:fLe,envmap_pars_vertex:pLe,envmap_physical_pars_fragment:ALe,envmap_vertex:mLe,fog_vertex:gLe,fog_pars_vertex:xLe,fog_fragment:bLe,fog_pars_fragment:vLe,gradientmap_pars_fragment:yLe,lightmap_fragment:_Le,lightmap_pars_fragment:wLe,lights_lambert_fragment:SLe,lights_lambert_pars_fragment:ELe,lights_pars_begin:MLe,lights_toon_fragment:TLe,lights_toon_pars_fragment:CLe,lights_phong_fragment:NLe,lights_phong_pars_fragment:kLe,lights_physical_fragment:PLe,lights_physical_pars_fragment:RLe,lights_fragment_begin:DLe,lights_fragment_maps:OLe,lights_fragment_end:jLe,logdepthbuf_fragment:LLe,logdepthbuf_pars_fragment:ILe,logdepthbuf_pars_vertex:ULe,logdepthbuf_vertex:FLe,map_fragment:zLe,map_pars_fragment:BLe,map_particle_fragment:HLe,map_particle_pars_fragment:$Le,metalnessmap_fragment:VLe,metalnessmap_pars_fragment:GLe,morphcolor_vertex:WLe,morphnormal_vertex:qLe,morphtarget_pars_vertex:KLe,morphtarget_vertex:XLe,normal_fragment_begin:YLe,normal_fragment_maps:ZLe,normal_pars_fragment:QLe,normal_pars_vertex:JLe,normal_vertex:eIe,normalmap_pars_fragment:tIe,clearcoat_normal_fragment_begin:nIe,clearcoat_normal_fragment_maps:rIe,clearcoat_pars_fragment:iIe,iridescence_pars_fragment:sIe,opaque_fragment:aIe,packing:oIe,premultiplied_alpha_fragment:lIe,project_vertex:cIe,dithering_fragment:uIe,dithering_pars_fragment:dIe,roughnessmap_fragment:hIe,roughnessmap_pars_fragment:fIe,shadowmap_pars_fragment:pIe,shadowmap_pars_vertex:mIe,shadowmap_vertex:gIe,shadowmask_pars_fragment:xIe,skinbase_vertex:bIe,skinning_pars_vertex:vIe,skinning_vertex:yIe,skinnormal_vertex:_Ie,specularmap_fragment:wIe,specularmap_pars_fragment:SIe,tonemapping_fragment:EIe,tonemapping_pars_fragment:MIe,transmission_fragment:AIe,transmission_pars_fragment:TIe,uv_pars_fragment:CIe,uv_pars_vertex:NIe,uv_vertex:kIe,worldpos_vertex:PIe,background_vert:RIe,background_frag:DIe,backgroundCube_vert:OIe,backgroundCube_frag:jIe,cube_vert:LIe,cube_frag:IIe,depth_vert:UIe,depth_frag:FIe,distanceRGBA_vert:zIe,distanceRGBA_frag:BIe,equirect_vert:HIe,equirect_frag:$Ie,linedashed_vert:VIe,linedashed_frag:GIe,meshbasic_vert:WIe,meshbasic_frag:qIe,meshlambert_vert:KIe,meshlambert_frag:XIe,meshmatcap_vert:YIe,meshmatcap_frag:ZIe,meshnormal_vert:QIe,meshnormal_frag:JIe,meshphong_vert:e4e,meshphong_frag:t4e,meshphysical_vert:n4e,meshphysical_frag:r4e,meshtoon_vert:i4e,meshtoon_frag:s4e,points_vert:a4e,points_frag:o4e,shadow_vert:l4e,shadow_frag:c4e,sprite_vert:u4e,sprite_frag:d4e},vt={common:{diffuse:{value:new $t(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new hn}},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 hn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new hn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new hn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new hn},normalScale:{value:new Yt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new hn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new hn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new hn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new hn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $t(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new $t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0},uvTransform:{value:new hn}},sprite:{diffuse:{value:new $t(16777215)},opacity:{value:1},center:{value:new Yt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new hn},alphaMap:{value:null},alphaMapTransform:{value:new hn},alphaTest:{value:0}}},Hs={basic:{uniforms:_s([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:_s([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:_s([vt.common,vt.specularmap,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,vt.lights,{emissive:{value:new $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:_s([vt.common,vt.envmap,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.roughnessmap,vt.metalnessmap,vt.fog,vt.lights,{emissive:{value:new $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:_s([vt.common,vt.aomap,vt.lightmap,vt.emissivemap,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.gradientmap,vt.fog,vt.lights,{emissive:{value:new $t(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:_s([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,vt.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:_s([vt.points,vt.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:_s([vt.common,vt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:_s([vt.common,vt.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:_s([vt.common,vt.bumpmap,vt.normalmap,vt.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:_s([vt.sprite,vt.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new hn},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:_s([vt.common,vt.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distanceRGBA_vert,fragmentShader:an.distanceRGBA_frag},shadow:{uniforms:_s([vt.lights,vt.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};Hs.physical={uniforms:_s([Hs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new hn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new hn},clearcoatNormalScale:{value:new Yt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new hn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new hn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new hn},sheen:{value:0},sheenColor:{value:new $t(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new hn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new hn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new hn},transmissionSamplerSize:{value:new Yt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new hn},attenuationDistance:{value:0},attenuationColor:{value:new $t(0)},specularColor:{value:new $t(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new hn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new hn},anisotropyVector:{value:new Yt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new hn}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const x_={r:0,b:0,g:0};function h4e(t,e,n,r,i,s,a){const o=new $t(0);let l=s===!0?0:1,u,d,f=null,g=0,m=null;function x(v,b){let E=!1,S=b.isScene===!0?b.background:null;S&&S.isTexture&&(S=(b.backgroundBlurriness>0?n:e).get(S)),S===null?y(o,l):S&&S.isColor&&(y(S,1),E=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,a):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,a),(t.autoClear||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),S&&(S.isCubeTexture||S.mapping===LE)?(d===void 0&&(d=new ko(new Bb(1,1,1),new dd({name:"BackgroundCubeMaterial",uniforms:Cm(Hs.backgroundCube.uniforms),vertexShader:Hs.backgroundCube.vertexShader,fragmentShader:Hs.backgroundCube.fragmentShader,side:Ws,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,k,N){this.matrixWorld.copyPosition(N.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=S,d.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,d.material.toneMapped=Kn.getTransfer(S.colorSpace)!==lr,(f!==S||g!==S.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),d.layers.enableAll(),v.unshift(d,d.geometry,d.material,0,0,null)):S&&S.isTexture&&(u===void 0&&(u=new ko(new uj(2,2),new dd({name:"BackgroundMaterial",uniforms:Cm(Hs.background.uniforms),vertexShader:Hs.background.vertexShader,fragmentShader:Hs.background.fragmentShader,side:ud,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=S,u.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,u.material.toneMapped=Kn.getTransfer(S.colorSpace)!==lr,S.matrixAutoUpdate===!0&&S.updateMatrix(),u.material.uniforms.uvTransform.value.copy(S.matrix),(f!==S||g!==S.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=S,g=S.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null))}function y(v,b){v.getRGB(x_,UZ(t)),r.buffers.color.setClear(x_.r,x_.g,x_.b,b,a)}return{getClearColor:function(){return o},setClearColor:function(v,b=1){o.set(v),l=b,y(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,y(o,l)},render:x}}function f4e(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 u=l,d=!1;function f(R,W,K,V,te){let Y=!1;if(a){const Z=y(V,K,W);u!==Z&&(u=Z,m(u.object)),Y=b(R,V,K,te),Y&&E(R,V,K,te)}else{const Z=W.wireframe===!0;(u.geometry!==V.id||u.program!==K.id||u.wireframe!==Z)&&(u.geometry=V.id,u.program=K.id,u.wireframe=Z,Y=!0)}te!==null&&n.update(te,t.ELEMENT_ARRAY_BUFFER),(Y||d)&&(d=!1,I(R,W,K,V),te!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(te).buffer))}function g(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(R){return r.isWebGL2?t.bindVertexArray(R):s.bindVertexArrayOES(R)}function x(R){return r.isWebGL2?t.deleteVertexArray(R):s.deleteVertexArrayOES(R)}function y(R,W,K){const V=K.wireframe===!0;let te=o[R.id];te===void 0&&(te={},o[R.id]=te);let Y=te[W.id];Y===void 0&&(Y={},te[W.id]=Y);let Z=Y[V];return Z===void 0&&(Z=v(g()),Y[V]=Z),Z}function v(R){const W=[],K=[],V=[];for(let te=0;te<i;te++)W[te]=0,K[te]=0,V[te]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:V,object:R,attributes:{},index:null}}function b(R,W,K,V){const te=u.attributes,Y=W.attributes;let Z=0;const U=K.getAttributes();for(const z in U)if(U[z].location>=0){const ae=te[z];let fe=Y[z];if(fe===void 0&&(z==="instanceMatrix"&&R.instanceMatrix&&(fe=R.instanceMatrix),z==="instanceColor"&&R.instanceColor&&(fe=R.instanceColor)),ae===void 0||ae.attribute!==fe||fe&&ae.data!==fe.data)return!0;Z++}return u.attributesNum!==Z||u.index!==V}function E(R,W,K,V){const te={},Y=W.attributes;let Z=0;const U=K.getAttributes();for(const z in U)if(U[z].location>=0){let ae=Y[z];ae===void 0&&(z==="instanceMatrix"&&R.instanceMatrix&&(ae=R.instanceMatrix),z==="instanceColor"&&R.instanceColor&&(ae=R.instanceColor));const fe={};fe.attribute=ae,ae&&ae.data&&(fe.data=ae.data),te[z]=fe,Z++}u.attributes=te,u.attributesNum=Z,u.index=V}function S(){const R=u.newAttributes;for(let W=0,K=R.length;W<K;W++)R[W]=0}function A(R){T(R,0)}function T(R,W){const K=u.newAttributes,V=u.enabledAttributes,te=u.attributeDivisors;K[R]=1,V[R]===0&&(t.enableVertexAttribArray(R),V[R]=1),te[R]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,W),te[R]=W)}function k(){const R=u.newAttributes,W=u.enabledAttributes;for(let K=0,V=W.length;K<V;K++)W[K]!==R[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function N(R,W,K,V,te,Y,Z){Z===!0?t.vertexAttribIPointer(R,W,K,te,Y):t.vertexAttribPointer(R,W,K,V,te,Y)}function I(R,W,K,V){if(r.isWebGL2===!1&&(R.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const te=V.attributes,Y=K.getAttributes(),Z=W.defaultAttributeValues;for(const U in Y){const z=Y[U];if(z.location>=0){let ee=te[U];if(ee===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor)),ee!==void 0){const ae=ee.normalized,fe=ee.itemSize,de=n.get(ee);if(de===void 0)continue;const xe=de.buffer,ye=de.type,re=de.bytesPerElement,ve=r.isWebGL2===!0&&(ye===t.INT||ye===t.UNSIGNED_INT||ee.gpuType===bZ);if(ee.isInterleavedBufferAttribute){const je=ee.data,ue=je.stride,ut=ee.offset;if(je.isInstancedInterleavedBuffer){for(let $=0;$<z.locationSize;$++)T(z.location+$,je.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=je.meshPerAttribute*je.count)}else for(let $=0;$<z.locationSize;$++)A(z.location+$);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let $=0;$<z.locationSize;$++)N(z.location+$,fe/z.locationSize,ye,ae,ue*re,(ut+fe/z.locationSize*$)*re,ve)}else{if(ee.isInstancedBufferAttribute){for(let je=0;je<z.locationSize;je++)T(z.location+je,ee.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let je=0;je<z.locationSize;je++)A(z.location+je);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let je=0;je<z.locationSize;je++)N(z.location+je,fe/z.locationSize,ye,ae,fe*re,fe/z.locationSize*je*re,ve)}}else if(Z!==void 0){const ae=Z[U];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(z.location,ae);break;case 3:t.vertexAttrib3fv(z.location,ae);break;case 4:t.vertexAttrib4fv(z.location,ae);break;default:t.vertexAttrib1fv(z.location,ae)}}}}k()}function C(){j();for(const R in o){const W=o[R];for(const K in W){const V=W[K];for(const te in V)x(V[te].object),delete V[te];delete W[K]}delete o[R]}}function D(R){if(o[R.id]===void 0)return;const W=o[R.id];for(const K in W){const V=W[K];for(const te in V)x(V[te].object),delete V[te];delete W[K]}delete o[R.id]}function F(R){for(const W in o){const K=o[W];if(K[R.id]===void 0)continue;const V=K[R.id];for(const te in V)x(V[te].object),delete V[te];delete K[R.id]}}function j(){q(),d=!0,u!==l&&(u=l,m(u.object))}function q(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:f,reset:j,resetDefaultState:q,dispose:C,releaseStatesOfGeometry:D,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:A,disableUnusedAttributes:k}}function p4e(t,e,n,r){const i=r.isWebGL2;let s;function a(d){s=d}function o(d,f){t.drawArrays(s,d,f),n.update(f,s,1)}function l(d,f,g){if(g===0)return;let m,x;if(i)m=t,x="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[x](s,d,f,g),n.update(f,s,g)}function u(d,f,g){if(g===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<g;x++)this.render(d[x],f[x]);else{m.multiDrawArraysWEBGL(s,d,0,f,0,g);let x=0;for(let y=0;y<g;y++)x+=f[y];n.update(x,s,1)}}this.setMode=a,this.render=o,this.renderInstances=l,this.renderMultiDraw=u}function m4e(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const 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 u=a||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),S=g>0,A=a||e.has("OES_texture_float"),T=S&&A,k=a?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:o,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:m,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:E,vertexTextures:S,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:k}}function g4e(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new Cu,o=new hn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const m=f.length!==0||g||r!==0||i;return i=g,r=f.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,m){const x=f.clippingPlanes,y=f.clipIntersection,v=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||s&&!v)s?d(null):u();else{const E=s?0:r,S=E*4;let A=b.clippingState||null;l.value=A,A=d(x,g,S,m);for(let T=0;T!==S;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){l.value!==n&&(l.value=n,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,m,x){const y=f!==null?f.length:0;let v=null;if(y!==0){if(v=l.value,x!==!0||v===null){const b=m+y*4,E=g.matrixWorldInverse;o.getNormalMatrix(E),(v===null||v.length<b)&&(v=new Float32Array(b));for(let S=0,A=m;S!==y;++S,A+=4)a.copy(f[S]).applyMatrix4(E,o),a.normal.toArray(v,A),v[A+3]=a.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function x4e(t){let e=new WeakMap;function n(a,o){return o===wP?a.mapping=Mm:o===SP&&(a.mapping=Am),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===wP||o===SP)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 u=new Nje(l.height/2);return u.fromEquirectangularTexture(t,a),e.set(a,u),a.addEventListener("dispose",i),n(u.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 b4e extends FZ{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 u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,a=s+u*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Gp=4,N$=[.125,.215,.35,.446,.526,.582],sh=20,cN=new b4e,k$=new $t;let uN=null,dN=0,hN=0;const th=(1+Math.sqrt(5))/2,Cp=1/th,P$=[new De(1,1,1),new De(-1,1,1),new De(1,1,-1),new De(-1,1,-1),new De(0,th,Cp),new De(0,th,-Cp),new De(Cp,0,th),new De(-Cp,0,th),new De(th,Cp,0),new De(-th,Cp,0)];class R${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){uN=this._renderer.getRenderTarget(),dN=this._renderer.getActiveCubeFace(),hN=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=j$(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=O$(),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(uN,dN,hN),e.scissorTest=!1,b_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Mm||e.mapping===Am?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),uN=this._renderer.getRenderTarget(),dN=this._renderer.getActiveCubeFace(),hN=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:qa,minFilter:qa,generateMipmaps:!1,type:B0,format:Ka,colorSpace:Oc,depthBuffer:!1},i=D$(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=D$(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=v4e(s)),this._blurMaterial=y4e(s,e,n)}return i}_compileMaterial(e){const n=new ko(this._lodPlanes[0],e);this._renderer.compile(n,cN)}_sceneToCubeUV(e,n,r,i){const o=new ha(90,1,n,r),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,g=d.toneMapping;d.getClearColor(k$),d.toneMapping=Ku,d.autoClear=!1;const m=new jZ({name:"PMREM.Background",side:Ws,depthWrite:!1,depthTest:!1}),x=new ko(new Bb,m);let y=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,y=!0):(m.color.copy(k$),y=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(o.up.set(0,l[b],0),o.lookAt(u[b],0,0)):E===1?(o.up.set(0,0,l[b]),o.lookAt(0,u[b],0)):(o.up.set(0,l[b],0),o.lookAt(0,0,u[b]));const S=this._cubeSize;b_(i,E*S,b>2?S:0,S,S),d.setRenderTarget(i),y&&d.render(x,o),d.render(e,o)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=v}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Mm||e.mapping===Am;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=j$()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=O$());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new ko(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;b_(n,0,0,3*l,2*l),r.setRenderTarget(n),r.render(a,cN)}_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=P$[(i-1)%P$.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,u=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new ko(this._lodPlanes[i],u),g=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*sh-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):sh;v>sh&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${sh}`);const b=[];let E=0;for(let N=0;N<sh;++N){const I=N/y,C=Math.exp(-I*I/2);b.push(C),N===0?E+=C:N<v&&(E+=2*C)}for(let N=0;N<b.length;N++)b[N]=b[N]/E;g.envMap.value=e.texture,g.samples.value=v,g.weights.value=b,g.latitudinal.value=a==="latitudinal",o&&(g.poleAxis.value=o);const{_lodMax:S}=this;g.dTheta.value=x,g.mipInt.value=S-r;const A=this._sizeLods[i],T=3*A*(i>S-Gp?i-S+Gp:0),k=4*(this._cubeSize-A);b_(n,T,k,3*A,2*A),l.setRenderTarget(n),l.render(f,cN)}}function v4e(t){const e=[],n=[],r=[];let i=t;const s=t-Gp+1+N$.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);n.push(o);let l=1/o;a>t-Gp?l=N$[a-t+Gp-1]:a===0&&(l=0),r.push(l);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,y=3,v=2,b=1,E=new Float32Array(y*x*m),S=new Float32Array(v*x*m),A=new Float32Array(b*x*m);for(let k=0;k<m;k++){const N=k%3*2/3-1,I=k>2?0:-1,C=[N,I,0,N+2/3,I,0,N+2/3,I+1,0,N,I,0,N+2/3,I+1,0,N,I+1,0];E.set(C,y*x*k),S.set(g,v*x*k);const D=[k,k,k,k,k,k];A.set(D,b*x*k)}const T=new gs;T.setAttribute("position",new va(E,y)),T.setAttribute("uv",new va(S,v)),T.setAttribute("faceIndex",new va(A,b)),e.push(T),i>Gp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function D$(t,e,n){const r=new Qh(t,e,n);return r.texture.mapping=LE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function b_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function y4e(t,e,n){const r=new Float32Array(sh),i=new De(0,1,0);return new dd({name:"SphericalGaussianBlur",defines:{n:sh,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:dj(),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:qu,depthTest:!1,depthWrite:!1})}function O$(){return new dd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:dj(),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:qu,depthTest:!1,depthWrite:!1})}function j$(){return new dd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:dj(),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:qu,depthTest:!1,depthWrite:!1})}function dj(){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 _4e(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const l=o.mapping,u=l===wP||l===SP,d=l===Mm||l===Am;if(u||d)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new R$(t)),f=u?n.fromEquirectangular(o,f):n.fromCubemap(o,f),e.set(o,f),f.texture}else{if(e.has(o))return e.get(o).texture;{const f=o.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new R$(t));const g=u?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 u=6;for(let d=0;d<u;d++)o[d]!==void 0&&l++;return l===u}function s(o){const l=o.target;l.removeEventListener("dispose",s);const u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function w4e(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 S4e(t,e,n,r){const i={},s=new WeakMap;function a(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const y=g.morphAttributes[x];for(let v=0,b=y.length;v<b;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(f,g){return i[g.id]===!0||(g.addEventListener("dispose",a),i[g.id]=!0,n.memory.geometries++),g}function l(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const x in m){const y=m[x];for(let v=0,b=y.length;v<b;v++)e.update(y[v],t.ARRAY_BUFFER)}}function u(f){const g=[],m=f.index,x=f.attributes.position;let y=0;if(m!==null){const E=m.array;y=m.version;for(let S=0,A=E.length;S<A;S+=3){const T=E[S+0],k=E[S+1],N=E[S+2];g.push(T,k,k,N,N,T)}}else if(x!==void 0){const E=x.array;y=x.version;for(let S=0,A=E.length/3-1;S<A;S+=3){const T=S+0,k=S+1,N=S+2;g.push(T,k,k,N,N,T)}}else return;const v=new(NZ(g)?IZ:LZ)(g,1);v.version=y;const b=s.get(f);b&&e.remove(b),s.set(f,v)}function d(f){const g=s.get(f);if(g){const m=f.index;m!==null&&g.version<m.version&&u(f)}else u(f);return s.get(f)}return{get:o,update:l,getWireframeAttribute:d}}function E4e(t,e,n,r){const i=r.isWebGL2;let s;function a(m){s=m}let o,l;function u(m){o=m.type,l=m.bytesPerElement}function d(m,x){t.drawElements(s,x,o,m*l),n.update(x,s,1)}function f(m,x,y){if(y===0)return;let v,b;if(i)v=t,b="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[b](s,x,o,m*l,y),n.update(x,s,y)}function g(m,x,y){if(y===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let b=0;b<y;b++)this.render(m[b]/l,x[b]);else{v.multiDrawElementsWEBGL(s,x,0,o,m,0,y);let b=0;for(let E=0;E<y;E++)b+=x[E];n.update(b,s,1)}}this.setMode=a,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function M4e(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 A4e(t,e){return t[0]-e[0]}function T4e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function C4e(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,a=new Yn,o=[];for(let u=0;u<8;u++)o[u]=[u,0];function l(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=x!==void 0?x.length:0;let v=s.get(d);if(v===void 0||v.count!==y){let W=function(){q.dispose(),s.delete(d),d.removeEventListener("dispose",W)};var m=W;v!==void 0&&v.texture.dispose();const S=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,k=d.morphAttributes.position||[],N=d.morphAttributes.normal||[],I=d.morphAttributes.color||[];let C=0;S===!0&&(C=1),A===!0&&(C=2),T===!0&&(C=3);let D=d.attributes.position.count*C,F=1;D>e.maxTextureSize&&(F=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const j=new Float32Array(D*F*4*y),q=new RZ(j,D,F,y);q.type=mc,q.needsUpdate=!0;const R=C*4;for(let K=0;K<y;K++){const V=k[K],te=N[K],Y=I[K],Z=D*F*4*K;for(let U=0;U<V.count;U++){const z=U*R;S===!0&&(a.fromBufferAttribute(V,U),j[Z+z+0]=a.x,j[Z+z+1]=a.y,j[Z+z+2]=a.z,j[Z+z+3]=0),A===!0&&(a.fromBufferAttribute(te,U),j[Z+z+4]=a.x,j[Z+z+5]=a.y,j[Z+z+6]=a.z,j[Z+z+7]=0),T===!0&&(a.fromBufferAttribute(Y,U),j[Z+z+8]=a.x,j[Z+z+9]=a.y,j[Z+z+10]=a.z,j[Z+z+11]=Y.itemSize===4?a.w:1)}}v={count:y,texture:q,size:new Yt(D,F)},s.set(d,v),d.addEventListener("dispose",W)}let b=0;for(let S=0;S<g.length;S++)b+=g[S];const E=d.morphTargetsRelative?1:1-b;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const x=g===void 0?0:g.length;let y=r[d.id];if(y===void 0||y.length!==x){y=[];for(let A=0;A<x;A++)y[A]=[A,0];r[d.id]=y}for(let A=0;A<x;A++){const T=y[A];T[0]=A,T[1]=g[A]}y.sort(T4e);for(let A=0;A<8;A++)A<x&&y[A][1]?(o[A][0]=y[A][0],o[A][1]=y[A][1]):(o[A][0]=Number.MAX_SAFE_INTEGER,o[A][1]=0);o.sort(A4e);const v=d.morphAttributes.position,b=d.morphAttributes.normal;let E=0;for(let A=0;A<8;A++){const T=o[A],k=T[0],N=T[1];k!==Number.MAX_SAFE_INTEGER&&N?(v&&d.getAttribute("morphTarget"+A)!==v[k]&&d.setAttribute("morphTarget"+A,v[k]),b&&d.getAttribute("morphNormal"+A)!==b[k]&&d.setAttribute("morphNormal"+A,b[k]),i[A]=N,E+=N):(v&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),b&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const S=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:l}}function N4e(t,e,n,r){let i=new WeakMap;function s(l){const u=r.render.frame,d=l.geometry,f=e.get(l,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),i.get(l)!==u&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),i.set(l,u))),l.isSkinnedMesh){const g=l.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function a(){i=new WeakMap}function o(l){const u=l.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:a}}class HZ extends qs{constructor(e,n,r,i,s,a,o,l,u,d){if(d=d!==void 0?d:Ah,d!==Ah&&d!==Tm)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Ah&&(r=Fu),r===void 0&&d===Tm&&(r=Mh),super(null,i,s,a,o,l,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Xi,this.minFilter=l!==void 0?l:Xi,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 $Z=new qs,VZ=new HZ(1,1);VZ.compareFunction=TZ;const GZ=new RZ,WZ=new fje,qZ=new zZ,L$=[],I$=[],U$=new Float32Array(16),F$=new Float32Array(9),z$=new Float32Array(4);function rg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=L$[i];if(s===void 0&&(s=new Float32Array(i),L$[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 pi(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 mi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function FE(t,e){let n=I$[e];n===void 0&&(n=new Int32Array(e),I$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function k4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function P4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(pi(n,e))return;t.uniform2fv(this.addr,e),mi(n,e)}}function R4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.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(pi(n,e))return;t.uniform3fv(this.addr,e),mi(n,e)}}function D4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.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(pi(n,e))return;t.uniform4fv(this.addr,e),mi(n,e)}}function O4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;z$.set(r),t.uniformMatrix2fv(this.addr,!1,z$),mi(n,r)}}function j4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;F$.set(r),t.uniformMatrix3fv(this.addr,!1,F$),mi(n,r)}}function L4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(pi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),mi(n,e)}else{if(pi(n,r))return;U$.set(r),t.uniformMatrix4fv(this.addr,!1,U$),mi(n,r)}}function I4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function U4e(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(pi(n,e))return;t.uniform2iv(this.addr,e),mi(n,e)}}function F4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(pi(n,e))return;t.uniform3iv(this.addr,e),mi(n,e)}}function z4e(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(pi(n,e))return;t.uniform4iv(this.addr,e),mi(n,e)}}function B4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function H4e(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(pi(n,e))return;t.uniform2uiv(this.addr,e),mi(n,e)}}function $4e(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(pi(n,e))return;t.uniform3uiv(this.addr,e),mi(n,e)}}function V4e(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(pi(n,e))return;t.uniform4uiv(this.addr,e),mi(n,e)}}function G4e(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?VZ:$Z;n.setTexture2D(e||s,i)}function W4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||WZ,i)}function q4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||qZ,i)}function K4e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||GZ,i)}function X4e(t){switch(t){case 5126:return k4e;case 35664:return P4e;case 35665:return R4e;case 35666:return D4e;case 35674:return O4e;case 35675:return j4e;case 35676:return L4e;case 5124:case 35670:return I4e;case 35667:case 35671:return U4e;case 35668:case 35672:return F4e;case 35669:case 35673:return z4e;case 5125:return B4e;case 36294:return H4e;case 36295:return $4e;case 36296:return V4e;case 35678:case 36198:case 36298:case 36306:case 35682:return G4e;case 35679:case 36299:case 36307:return W4e;case 35680:case 36300:case 36308:case 36293:return q4e;case 36289:case 36303:case 36311:case 36292:return K4e}}function Y4e(t,e){t.uniform1fv(this.addr,e)}function Z4e(t,e){const n=rg(e,this.size,2);t.uniform2fv(this.addr,n)}function Q4e(t,e){const n=rg(e,this.size,3);t.uniform3fv(this.addr,n)}function J4e(t,e){const n=rg(e,this.size,4);t.uniform4fv(this.addr,n)}function eUe(t,e){const n=rg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function tUe(t,e){const n=rg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function nUe(t,e){const n=rg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function rUe(t,e){t.uniform1iv(this.addr,e)}function iUe(t,e){t.uniform2iv(this.addr,e)}function sUe(t,e){t.uniform3iv(this.addr,e)}function aUe(t,e){t.uniform4iv(this.addr,e)}function oUe(t,e){t.uniform1uiv(this.addr,e)}function lUe(t,e){t.uniform2uiv(this.addr,e)}function cUe(t,e){t.uniform3uiv(this.addr,e)}function uUe(t,e){t.uniform4uiv(this.addr,e)}function dUe(t,e,n){const r=this.cache,i=e.length,s=FE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||$Z,s[a])}function hUe(t,e,n){const r=this.cache,i=e.length,s=FE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||WZ,s[a])}function fUe(t,e,n){const r=this.cache,i=e.length,s=FE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||qZ,s[a])}function pUe(t,e,n){const r=this.cache,i=e.length,s=FE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||GZ,s[a])}function mUe(t){switch(t){case 5126:return Y4e;case 35664:return Z4e;case 35665:return Q4e;case 35666:return J4e;case 35674:return eUe;case 35675:return tUe;case 35676:return nUe;case 5124:case 35670:return rUe;case 35667:case 35671:return iUe;case 35668:case 35672:return sUe;case 35669:case 35673:return aUe;case 5125:return oUe;case 36294:return lUe;case 36295:return cUe;case 36296:return uUe;case 35678:case 36198:case 36298:case 36306:case 35682:return dUe;case 35679:case 36299:case 36307:return hUe;case 35680:case 36300:case 36308:case 36293:return fUe;case 36289:case 36303:case 36311:case 36292:return pUe}}class gUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=X4e(n.type)}}class xUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=mUe(n.type)}}class bUe{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 fN=/(\w+)(\])?(\[|\.)?/g;function B$(t,e){t.seq.push(e),t.map[e.id]=e}function vUe(t,e,n){const r=t.name,i=r.length;for(fN.lastIndex=0;;){const s=fN.exec(r),a=fN.lastIndex;let o=s[1];const l=s[2]==="]",u=s[3];if(l&&(o=o|0),u===void 0||u==="["&&a+2===i){B$(n,u===void 0?new gUe(o,t,e):new xUe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new bUe(o),B$(n,f)),n=f}}}class a1{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);vUe(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 H$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const yUe=37297;let _Ue=0;function wUe(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 SUe(t){const e=Kn.getPrimaries(Kn.workingColorSpace),n=Kn.getPrimaries(t);let r;switch(e===n?r="":e===Nw&&n===Cw?r="LinearDisplayP3ToLinearSRGB":e===Cw&&n===Nw&&(r="LinearSRGBToLinearDisplayP3"),t){case Oc:case IE:return[r,"LinearTransferOETF"];case Yi:case aj:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function $$(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+`
- `+wUe(t.getShaderSource(e),a)}else return i}function EUe(t,e){const n=SUe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function MUe(t,e){let n;switch(e){case EOe:n="Linear";break;case MOe:n="Reinhard";break;case AOe:n="OptimizedCineon";break;case TOe:n="ACESFilmic";break;case COe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function AUe(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(Nx).join(`
- `)}function TUe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function CUe(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 Nx(t){return t!==""}function V$(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 G$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const NUe=/^[ \t]*#include +<([\w\d./]+)>/gm;function NP(t){return t.replace(NUe,PUe)}const kUe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function PUe(t,e){let n=an[e];if(n===void 0){const r=kUe.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 NP(n)}const RUe=/#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 W$(t){return t.replace(RUe,DUe)}function DUe(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 q$(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 OUe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===gZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===QDe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===rc&&(e="SHADOWMAP_TYPE_VSM"),e}function jUe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Mm:case Am:e="ENVMAP_TYPE_CUBE";break;case LE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function LUe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Am:e="ENVMAP_MODE_REFRACTION";break}return e}function IUe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case ij:e="ENVMAP_BLENDING_MULTIPLY";break;case wOe:e="ENVMAP_BLENDING_MIX";break;case SOe:e="ENVMAP_BLENDING_ADD";break}return e}function UUe(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 FUe(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const l=OUe(n),u=jUe(n),d=LUe(n),f=IUe(n),g=UUe(n),m=n.isWebGL2?"":AUe(n),x=TUe(s),y=i.createProgram();let v,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Nx).join(`
- `),v.length>0&&(v+=`
- `),b=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Nx).join(`
- `),b.length>0&&(b+=`
- `)):(v=[q$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+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(Nx).join(`
- `),b=[m,q$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+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!==Ku?"#define TONE_MAPPING":"",n.toneMapping!==Ku?an.tonemapping_pars_fragment:"",n.toneMapping!==Ku?MUe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,EUe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Nx).join(`
- `)),a=NP(a),a=V$(a,n),a=G$(a,n),o=NP(o),o=V$(o,n),o=G$(o,n),a=W$(a),o=W$(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,b=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===d$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===d$?"":"#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(`
- `)+`
- `+b);const S=E+v+a,A=E+b+o,T=H$(i,i.VERTEX_SHADER,S),k=H$(i,i.FRAGMENT_SHADER,A);i.attachShader(y,T),i.attachShader(y,k),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function N(F){if(t.debug.checkShaderErrors){const j=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(T).trim(),R=i.getShaderInfoLog(k).trim();let W=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const V=$$(i,T,"vertex"),te=$$(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+j+`
- `+V+`
- `+te)}else j!==""?console.warn("THREE.WebGLProgram: Program Info Log:",j):(q===""||R==="")&&(K=!1);K&&(F.diagnostics={runnable:W,programLog:j,vertexShader:{log:q,prefix:v},fragmentShader:{log:R,prefix:b}})}i.deleteShader(T),i.deleteShader(k),I=new a1(i,y),C=CUe(i,y)}let I;this.getUniforms=function(){return I===void 0&&N(this),I};let C;this.getAttributes=function(){return C===void 0&&N(this),C};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,yUe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=_Ue++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let zUe=0;class BUe{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 HUe(e),n.set(e,r)),r}}class HUe{constructor(e){this.id=zUe++,this.code=e,this.usedTimes=0}}function $Ue(t,e,n,r,i,s,a){const o=new DZ,l=new BUe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let m=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(C){return C===0?"uv":`uv${C}`}function v(C,D,F,j,q){const R=j.fog,W=q.geometry,K=C.isMeshStandardMaterial?j.environment:null,V=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),te=V&&V.mapping===LE?V.image.height:null,Y=x[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Z=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Z!==void 0?Z.length:0;let z=0;W.morphAttributes.position!==void 0&&(z=1),W.morphAttributes.normal!==void 0&&(z=2),W.morphAttributes.color!==void 0&&(z=3);let ee,ae,fe,de;if(Y){const cn=Hs[Y];ee=cn.vertexShader,ae=cn.fragmentShader}else ee=C.vertexShader,ae=C.fragmentShader,l.update(C),fe=l.getVertexShaderID(C),de=l.getFragmentShaderID(C);const xe=t.getRenderTarget(),ye=q.isInstancedMesh===!0,re=q.isBatchedMesh===!0,ve=!!C.map,je=!!C.matcap,ue=!!V,ut=!!C.aoMap,$=!!C.lightMap,H=!!C.bumpMap,ie=!!C.normalMap,G=!!C.displacementMap,J=!!C.emissiveMap,le=!!C.metalnessMap,ke=!!C.roughnessMap,Ne=C.anisotropy>0,Se=C.clearcoat>0,B=C.iridescence>0,L=C.sheen>0,ne=C.transmission>0,be=Ne&&!!C.anisotropyMap,we=Se&&!!C.clearcoatMap,ge=Se&&!!C.clearcoatNormalMap,me=Se&&!!C.clearcoatRoughnessMap,Ae=B&&!!C.iridescenceMap,ze=B&&!!C.iridescenceThicknessMap,st=L&&!!C.sheenColorMap,Ve=L&&!!C.sheenRoughnessMap,ce=!!C.specularMap,Ye=!!C.specularColorMap,$e=!!C.specularIntensityMap,Ze=ne&&!!C.transmissionMap,at=ne&&!!C.thicknessMap,Q=!!C.gradientMap,Fe=!!C.alphaMap,pe=C.alphaTest>0,Ue=!!C.alphaHash,Ce=!!C.extensions,_e=!!W.attributes.uv1,He=!!W.attributes.uv2,ht=!!W.attributes.uv3;let wt=Ku;return C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(wt=t.toneMapping),{isWebGL2:d,shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:ee,fragmentShader:ae,defines:C.defines,customVertexShaderID:fe,customFragmentShaderID:de,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:re,instancing:ye,instancingColor:ye&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Oc,map:ve,matcap:je,envMap:ue,envMapMode:ue&&V.mapping,envMapCubeUVHeight:te,aoMap:ut,lightMap:$,bumpMap:H,normalMap:ie,displacementMap:g&&G,emissiveMap:J,normalMapObjectSpace:ie&&C.normalMapType===zOe,normalMapTangentSpace:ie&&C.normalMapType===AZ,metalnessMap:le,roughnessMap:ke,anisotropy:Ne,anisotropyMap:be,clearcoat:Se,clearcoatMap:we,clearcoatNormalMap:ge,clearcoatRoughnessMap:me,iridescence:B,iridescenceMap:Ae,iridescenceThicknessMap:ze,sheen:L,sheenColorMap:st,sheenRoughnessMap:Ve,specularMap:ce,specularColorMap:Ye,specularIntensityMap:$e,transmission:ne,transmissionMap:Ze,thicknessMap:at,gradientMap:Q,opaque:C.transparent===!1&&C.blending===tm,alphaMap:Fe,alphaTest:pe,alphaHash:Ue,combine:C.combine,mapUv:ve&&y(C.map.channel),aoMapUv:ut&&y(C.aoMap.channel),lightMapUv:$&&y(C.lightMap.channel),bumpMapUv:H&&y(C.bumpMap.channel),normalMapUv:ie&&y(C.normalMap.channel),displacementMapUv:G&&y(C.displacementMap.channel),emissiveMapUv:J&&y(C.emissiveMap.channel),metalnessMapUv:le&&y(C.metalnessMap.channel),roughnessMapUv:ke&&y(C.roughnessMap.channel),anisotropyMapUv:be&&y(C.anisotropyMap.channel),clearcoatMapUv:we&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:ge&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:me&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ae&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:ze&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:st&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&y(C.sheenRoughnessMap.channel),specularMapUv:ce&&y(C.specularMap.channel),specularColorMapUv:Ye&&y(C.specularColorMap.channel),specularIntensityMapUv:$e&&y(C.specularIntensityMap.channel),transmissionMapUv:Ze&&y(C.transmissionMap.channel),thicknessMapUv:at&&y(C.thicknessMap.channel),alphaMapUv:Fe&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ie||Ne),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:_e,vertexUv2s:He,vertexUv3s:ht,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(ve||Fe),fog:!!R,useFog:C.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:U,morphTextureStride:z,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:wt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ve&&C.map.isVideoTexture===!0&&Kn.getTransfer(C.map.colorSpace)===lr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===cc,flipSided:C.side===Ws,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Ce&&C.extensions.derivatives===!0,extensionFragDepth:Ce&&C.extensions.fragDepth===!0,extensionDrawBuffers:Ce&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ce&&C.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()}}function b(C){const D=[];if(C.shaderID?D.push(C.shaderID):(D.push(C.customVertexShaderID),D.push(C.customFragmentShaderID)),C.defines!==void 0)for(const F in C.defines)D.push(F),D.push(C.defines[F]);return C.isRawShaderMaterial===!1&&(E(D,C),S(D,C),D.push(t.outputColorSpace)),D.push(C.customProgramCacheKey),D.join()}function E(C,D){C.push(D.precision),C.push(D.outputColorSpace),C.push(D.envMapMode),C.push(D.envMapCubeUVHeight),C.push(D.mapUv),C.push(D.alphaMapUv),C.push(D.lightMapUv),C.push(D.aoMapUv),C.push(D.bumpMapUv),C.push(D.normalMapUv),C.push(D.displacementMapUv),C.push(D.emissiveMapUv),C.push(D.metalnessMapUv),C.push(D.roughnessMapUv),C.push(D.anisotropyMapUv),C.push(D.clearcoatMapUv),C.push(D.clearcoatNormalMapUv),C.push(D.clearcoatRoughnessMapUv),C.push(D.iridescenceMapUv),C.push(D.iridescenceThicknessMapUv),C.push(D.sheenColorMapUv),C.push(D.sheenRoughnessMapUv),C.push(D.specularMapUv),C.push(D.specularColorMapUv),C.push(D.specularIntensityMapUv),C.push(D.transmissionMapUv),C.push(D.thicknessMapUv),C.push(D.combine),C.push(D.fogExp2),C.push(D.sizeAttenuation),C.push(D.morphTargetsCount),C.push(D.morphAttributeCount),C.push(D.numDirLights),C.push(D.numPointLights),C.push(D.numSpotLights),C.push(D.numSpotLightMaps),C.push(D.numHemiLights),C.push(D.numRectAreaLights),C.push(D.numDirLightShadows),C.push(D.numPointLightShadows),C.push(D.numSpotLightShadows),C.push(D.numSpotLightShadowsWithMaps),C.push(D.numLightProbes),C.push(D.shadowMapType),C.push(D.toneMapping),C.push(D.numClippingPlanes),C.push(D.numClipIntersection),C.push(D.depthPacking)}function S(C,D){o.disableAll(),D.isWebGL2&&o.enable(0),D.supportsVertexTextures&&o.enable(1),D.instancing&&o.enable(2),D.instancingColor&&o.enable(3),D.matcap&&o.enable(4),D.envMap&&o.enable(5),D.normalMapObjectSpace&&o.enable(6),D.normalMapTangentSpace&&o.enable(7),D.clearcoat&&o.enable(8),D.iridescence&&o.enable(9),D.alphaTest&&o.enable(10),D.vertexColors&&o.enable(11),D.vertexAlphas&&o.enable(12),D.vertexUv1s&&o.enable(13),D.vertexUv2s&&o.enable(14),D.vertexUv3s&&o.enable(15),D.vertexTangents&&o.enable(16),D.anisotropy&&o.enable(17),D.alphaHash&&o.enable(18),D.batching&&o.enable(19),C.push(o.mask),o.disableAll(),D.fog&&o.enable(0),D.useFog&&o.enable(1),D.flatShading&&o.enable(2),D.logarithmicDepthBuffer&&o.enable(3),D.skinning&&o.enable(4),D.morphTargets&&o.enable(5),D.morphNormals&&o.enable(6),D.morphColors&&o.enable(7),D.premultipliedAlpha&&o.enable(8),D.shadowMapEnabled&&o.enable(9),D.useLegacyLights&&o.enable(10),D.doubleSided&&o.enable(11),D.flipSided&&o.enable(12),D.useDepthPacking&&o.enable(13),D.dithering&&o.enable(14),D.transmission&&o.enable(15),D.sheen&&o.enable(16),D.opaque&&o.enable(17),D.pointsUvs&&o.enable(18),D.decodeVideoTexture&&o.enable(19),C.push(o.mask)}function A(C){const D=x[C.type];let F;if(D){const j=Hs[D];F=cj.clone(j.uniforms)}else F=C.uniforms;return F}function T(C,D){let F;for(let j=0,q=u.length;j<q;j++){const R=u[j];if(R.cacheKey===D){F=R,++F.usedTimes;break}}return F===void 0&&(F=new FUe(t,D,C,s),u.push(F)),F}function k(C){if(--C.usedTimes===0){const D=u.indexOf(C);u[D]=u[u.length-1],u.pop(),C.destroy()}}function N(C){l.remove(C)}function I(){l.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:u,dispose:I}}function VUe(){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 GUe(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 K$(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 X$(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function a(f,g,m,x,y,v){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:m,groupOrder:x,renderOrder:f.renderOrder,z:y,group:v},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=m,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=y,b.group=v),e++,b}function o(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function l(f,g,m,x,y,v){const b=a(f,g,m,x,y,v);m.transmission>0?r.unshift(b):m.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||GUe),r.length>1&&r.sort(g||K$),i.length>1&&i.sort(g||K$)}function d(){for(let f=e,g=t.length;f<g;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:o,unshift:l,finish:d,sort:u}}function WUe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new X$,t.set(r,[a])):i>=s.length?(a=new X$,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function qUe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new De,color:new $t};break;case"SpotLight":n={position:new De,direction:new De,color:new $t,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new De,color:new $t,distance:0,decay:0};break;case"HemisphereLight":n={direction:new De,skyColor:new $t,groundColor:new $t};break;case"RectAreaLight":n={color:new $t,position:new De,halfWidth:new De,halfHeight:new De};break}return t[e.id]=n,n}}}function KUe(){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 Yt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Yt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let XUe=0;function YUe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function ZUe(t,e){const n=new qUe,r=KUe(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new De);const s=new De,a=new sr,o=new sr;function l(d,f){let g=0,m=0,x=0;for(let j=0;j<9;j++)i.probe[j].set(0,0,0);let y=0,v=0,b=0,E=0,S=0,A=0,T=0,k=0,N=0,I=0,C=0;d.sort(YUe);const D=f===!0?Math.PI:1;for(let j=0,q=d.length;j<q;j++){const R=d[j],W=R.color,K=R.intensity,V=R.distance,te=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=W.r*K*D,m+=W.g*K*D,x+=W.b*K*D;else if(R.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(R.sh.coefficients[Y],K);C++}else if(R.isDirectionalLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*D),R.castShadow){const Z=R.shadow,U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,i.directionalShadow[y]=U,i.directionalShadowMap[y]=te,i.directionalShadowMatrix[y]=R.shadow.matrix,A++}i.directional[y]=Y,y++}else if(R.isSpotLight){const Y=n.get(R);Y.position.setFromMatrixPosition(R.matrixWorld),Y.color.copy(W).multiplyScalar(K*D),Y.distance=V,Y.coneCos=Math.cos(R.angle),Y.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),Y.decay=R.decay,i.spot[b]=Y;const Z=R.shadow;if(R.map&&(i.spotLightMap[N]=R.map,N++,Z.updateMatrices(R),R.castShadow&&I++),i.spotLightMatrix[b]=Z.matrix,R.castShadow){const U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,i.spotShadow[b]=U,i.spotShadowMap[b]=te,k++}b++}else if(R.isRectAreaLight){const Y=n.get(R);Y.color.copy(W).multiplyScalar(K),Y.halfWidth.set(R.width*.5,0,0),Y.halfHeight.set(0,R.height*.5,0),i.rectArea[E]=Y,E++}else if(R.isPointLight){const Y=n.get(R);if(Y.color.copy(R.color).multiplyScalar(R.intensity*D),Y.distance=R.distance,Y.decay=R.decay,R.castShadow){const Z=R.shadow,U=r.get(R);U.shadowBias=Z.bias,U.shadowNormalBias=Z.normalBias,U.shadowRadius=Z.radius,U.shadowMapSize=Z.mapSize,U.shadowCameraNear=Z.camera.near,U.shadowCameraFar=Z.camera.far,i.pointShadow[v]=U,i.pointShadowMap[v]=te,i.pointShadowMatrix[v]=R.shadow.matrix,T++}i.point[v]=Y,v++}else if(R.isHemisphereLight){const Y=n.get(R);Y.skyColor.copy(R.color).multiplyScalar(K*D),Y.groundColor.copy(R.groundColor).multiplyScalar(K*D),i.hemi[S]=Y,S++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=vt.LTC_FLOAT_1,i.rectAreaLTC2=vt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=vt.LTC_HALF_1,i.rectAreaLTC2=vt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=m,i.ambient[2]=x;const F=i.hash;(F.directionalLength!==y||F.pointLength!==v||F.spotLength!==b||F.rectAreaLength!==E||F.hemiLength!==S||F.numDirectionalShadows!==A||F.numPointShadows!==T||F.numSpotShadows!==k||F.numSpotMaps!==N||F.numLightProbes!==C)&&(i.directional.length=y,i.spot.length=b,i.rectArea.length=E,i.point.length=v,i.hemi.length=S,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=k,i.spotShadowMap.length=k,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=k+N-I,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=I,i.numLightProbes=C,F.directionalLength=y,F.pointLength=v,F.spotLength=b,F.rectAreaLength=E,F.hemiLength=S,F.numDirectionalShadows=A,F.numPointShadows=T,F.numSpotShadows=k,F.numSpotMaps=N,F.numLightProbes=C,i.version=XUe++)}function u(d,f){let g=0,m=0,x=0,y=0,v=0;const b=f.matrixWorldInverse;for(let E=0,S=d.length;E<S;E++){const A=d[E];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(b),g++}else if(A.isSpotLight){const T=i.spot[x];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(b),x++}else if(A.isRectAreaLight){const T=i.rectArea[y];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),o.identity(),a.copy(A.matrixWorld),a.premultiply(b),o.extractRotation(a),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),y++}else if(A.isPointLight){const T=i.point[m];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),m++}else if(A.isHemisphereLight){const T=i.hemi[v];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(b),v++}}}return{setup:l,setupView:u,state:i}}function Y$(t,e){const n=new ZUe(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function a(f){r.push(f)}function o(f){i.push(f)}function l(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o}}function QUe(t,e){let n=new WeakMap;function r(s,a=0){const o=n.get(s);let l;return o===void 0?(l=new Y$(t,e),n.set(s,[l])):a>=o.length?(l=new Y$(t,e),o.push(l)):l=o[a],l}function i(){n=new WeakMap}return{get:r,dispose:i}}class JUe extends ng{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=UOe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class e5e extends ng{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 t5e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,n5e=`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 r5e(t,e,n){let r=new UE;const i=new Yt,s=new Yt,a=new Yn,o=new JUe({depthPacking:FOe}),l=new e5e,u={},d=n.maxTextureSize,f={[ud]:Ws,[Ws]:ud,[cc]:cc},g=new dd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Yt},radius:{value:4}},vertexShader:t5e,fragmentShader:n5e}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new gs;x.setAttribute("position",new va(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new ko(x,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gZ;let b=this.type;this.render=function(T,k,N){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const I=t.getRenderTarget(),C=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),F=t.state;F.setBlending(qu),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const j=b!==rc&&this.type===rc,q=b===rc&&this.type!==rc;for(let R=0,W=T.length;R<W;R++){const K=T[R],V=K.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const te=V.getFrameExtents();if(i.multiply(te),s.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/te.x),i.x=s.x*te.x,V.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/te.y),i.y=s.y*te.y,V.mapSize.y=s.y)),V.map===null||j===!0||q===!0){const Z=this.type!==rc?{minFilter:Xi,magFilter:Xi}:{};V.map!==null&&V.map.dispose(),V.map=new Qh(i.x,i.y,Z),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const Y=V.getViewportCount();for(let Z=0;Z<Y;Z++){const U=V.getViewport(Z);a.set(s.x*U.x,s.y*U.y,s.x*U.z,s.y*U.w),F.viewport(a),V.updateMatrices(K,Z),r=V.getFrustum(),A(k,N,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===rc&&E(V,N),V.needsUpdate=!1}b=this.type,v.needsUpdate=!1,t.setRenderTarget(I,C,D)};function E(T,k){const N=e.update(y);g.defines.VSM_SAMPLES!==T.blurSamples&&(g.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,g.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Qh(i.x,i.y)),g.uniforms.shadow_pass.value=T.map.texture,g.uniforms.resolution.value=T.mapSize,g.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(k,null,N,g,y,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(k,null,N,m,y,null)}function S(T,k,N,I){let C=null;const D=N.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(D!==void 0)C=D;else if(C=N.isPointLight===!0?l:o,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){const F=C.uuid,j=k.uuid;let q=u[F];q===void 0&&(q={},u[F]=q);let R=q[j];R===void 0&&(R=C.clone(),q[j]=R),C=R}if(C.visible=k.visible,C.wireframe=k.wireframe,I===rc?C.side=k.shadowSide!==null?k.shadowSide:k.side:C.side=k.shadowSide!==null?k.shadowSide:f[k.side],C.alphaMap=k.alphaMap,C.alphaTest=k.alphaTest,C.map=k.map,C.clipShadows=k.clipShadows,C.clippingPlanes=k.clippingPlanes,C.clipIntersection=k.clipIntersection,C.displacementMap=k.displacementMap,C.displacementScale=k.displacementScale,C.displacementBias=k.displacementBias,C.wireframeLinewidth=k.wireframeLinewidth,C.linewidth=k.linewidth,N.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const F=t.properties.get(C);F.light=N}return C}function A(T,k,N,I,C){if(T.visible===!1)return;if(T.layers.test(k.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&C===rc)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const j=e.update(T),q=T.material;if(Array.isArray(q)){const R=j.groups;for(let W=0,K=R.length;W<K;W++){const V=R[W],te=q[V.materialIndex];if(te&&te.visible){const Y=S(T,te,I,C);T.onBeforeShadow(t,T,k,N,j,Y,V),t.renderBufferDirect(N,null,j,Y,T,V),T.onAfterShadow(t,T,k,N,j,Y,V)}}}else if(q.visible){const R=S(T,q,I,C);T.onBeforeShadow(t,T,k,N,j,R,null),t.renderBufferDirect(N,null,j,R,T,null),T.onAfterShadow(t,T,k,N,j,R,null)}}const F=T.children;for(let j=0,q=F.length;j<q;j++)A(F[j],k,N,I,C)}}function i5e(t,e,n){const r=n.isWebGL2;function i(){let pe=!1;const Ue=new Yn;let Ce=null;const _e=new Yn(0,0,0,0);return{setMask:function(He){Ce!==He&&!pe&&(t.colorMask(He,He,He,He),Ce=He)},setLocked:function(He){pe=He},setClear:function(He,ht,wt,Ot,cn){cn===!0&&(He*=Ot,ht*=Ot,wt*=Ot),Ue.set(He,ht,wt,Ot),_e.equals(Ue)===!1&&(t.clearColor(He,ht,wt,Ot),_e.copy(Ue))},reset:function(){pe=!1,Ce=null,_e.set(-1,0,0,0)}}}function s(){let pe=!1,Ue=null,Ce=null,_e=null;return{setTest:function(He){He?re(t.DEPTH_TEST):ve(t.DEPTH_TEST)},setMask:function(He){Ue!==He&&!pe&&(t.depthMask(He),Ue=He)},setFunc:function(He){if(Ce!==He){switch(He){case mOe:t.depthFunc(t.NEVER);break;case gOe:t.depthFunc(t.ALWAYS);break;case xOe:t.depthFunc(t.LESS);break;case Aw:t.depthFunc(t.LEQUAL);break;case bOe:t.depthFunc(t.EQUAL);break;case vOe:t.depthFunc(t.GEQUAL);break;case yOe:t.depthFunc(t.GREATER);break;case _Oe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ce=He}},setLocked:function(He){pe=He},setClear:function(He){_e!==He&&(t.clearDepth(He),_e=He)},reset:function(){pe=!1,Ue=null,Ce=null,_e=null}}}function a(){let pe=!1,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null,Ot=null,cn=null;return{setTest:function(It){pe||(It?re(t.STENCIL_TEST):ve(t.STENCIL_TEST))},setMask:function(It){Ue!==It&&!pe&&(t.stencilMask(It),Ue=It)},setFunc:function(It,Dn,Qn){(Ce!==It||_e!==Dn||He!==Qn)&&(t.stencilFunc(It,Dn,Qn),Ce=It,_e=Dn,He=Qn)},setOp:function(It,Dn,Qn){(ht!==It||wt!==Dn||Ot!==Qn)&&(t.stencilOp(It,Dn,Qn),ht=It,wt=Dn,Ot=Qn)},setLocked:function(It){pe=It},setClear:function(It){cn!==It&&(t.clearStencil(It),cn=It)},reset:function(){pe=!1,Ue=null,Ce=null,_e=null,He=null,ht=null,wt=null,Ot=null,cn=null}}}const o=new i,l=new s,u=new a,d=new WeakMap,f=new WeakMap;let g={},m={},x=new WeakMap,y=[],v=null,b=!1,E=null,S=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,j=null,q=null,R=null,W=null,K=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let te=!1,Y=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(Z)[1]),te=Y>=1):Z.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),te=Y>=2);let U=null,z={};const ee=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),fe=new Yn().fromArray(ee),de=new Yn().fromArray(ae);function xe(pe,Ue,Ce,_e){const He=new Uint8Array(4),ht=t.createTexture();t.bindTexture(pe,ht),t.texParameteri(pe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(pe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let wt=0;wt<Ce;wt++)r&&(pe===t.TEXTURE_3D||pe===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ue,0,t.RGBA,1,1,_e,0,t.RGBA,t.UNSIGNED_BYTE,He):t.texImage2D(Ue+wt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,He);return ht}const ye={};ye[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),ye[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(ye[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ye[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),u.setClear(0),re(t.DEPTH_TEST),l.setFunc(Aw),J(!1),le(RH),re(t.CULL_FACE),ie(qu);function re(pe){g[pe]!==!0&&(t.enable(pe),g[pe]=!0)}function ve(pe){g[pe]!==!1&&(t.disable(pe),g[pe]=!1)}function je(pe,Ue){return m[pe]!==Ue?(t.bindFramebuffer(pe,Ue),m[pe]=Ue,r&&(pe===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ue),pe===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ue)),!0):!1}function ue(pe,Ue){let Ce=y,_e=!1;if(pe)if(Ce=x.get(Ue),Ce===void 0&&(Ce=[],x.set(Ue,Ce)),pe.isWebGLMultipleRenderTargets){const He=pe.texture;if(Ce.length!==He.length||Ce[0]!==t.COLOR_ATTACHMENT0){for(let ht=0,wt=He.length;ht<wt;ht++)Ce[ht]=t.COLOR_ATTACHMENT0+ht;Ce.length=He.length,_e=!0}}else Ce[0]!==t.COLOR_ATTACHMENT0&&(Ce[0]=t.COLOR_ATTACHMENT0,_e=!0);else Ce[0]!==t.BACK&&(Ce[0]=t.BACK,_e=!0);_e&&(n.isWebGL2?t.drawBuffers(Ce):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ce))}function ut(pe){return v!==pe?(t.useProgram(pe),v=pe,!0):!1}const $={[ih]:t.FUNC_ADD,[eOe]:t.FUNC_SUBTRACT,[tOe]:t.FUNC_REVERSE_SUBTRACT};if(r)$[LH]=t.MIN,$[IH]=t.MAX;else{const pe=e.get("EXT_blend_minmax");pe!==null&&($[LH]=pe.MIN_EXT,$[IH]=pe.MAX_EXT)}const H={[nOe]:t.ZERO,[rOe]:t.ONE,[iOe]:t.SRC_COLOR,[yP]:t.SRC_ALPHA,[uOe]:t.SRC_ALPHA_SATURATE,[lOe]:t.DST_COLOR,[aOe]:t.DST_ALPHA,[sOe]:t.ONE_MINUS_SRC_COLOR,[_P]:t.ONE_MINUS_SRC_ALPHA,[cOe]:t.ONE_MINUS_DST_COLOR,[oOe]:t.ONE_MINUS_DST_ALPHA,[dOe]:t.CONSTANT_COLOR,[hOe]:t.ONE_MINUS_CONSTANT_COLOR,[fOe]:t.CONSTANT_ALPHA,[pOe]:t.ONE_MINUS_CONSTANT_ALPHA};function ie(pe,Ue,Ce,_e,He,ht,wt,Ot,cn,It){if(pe===qu){b===!0&&(ve(t.BLEND),b=!1);return}if(b===!1&&(re(t.BLEND),b=!0),pe!==JDe){if(pe!==E||It!==F){if((S!==ih||k!==ih)&&(t.blendEquation(t.FUNC_ADD),S=ih,k=ih),It)switch(pe){case tm:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case DH:t.blendFunc(t.ONE,t.ONE);break;case OH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case jH:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",pe);break}else switch(pe){case tm:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case DH:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case OH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case jH:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",pe);break}A=null,T=null,N=null,I=null,C.set(0,0,0),D=0,E=pe,F=It}return}He=He||Ue,ht=ht||Ce,wt=wt||_e,(Ue!==S||He!==k)&&(t.blendEquationSeparate($[Ue],$[He]),S=Ue,k=He),(Ce!==A||_e!==T||ht!==N||wt!==I)&&(t.blendFuncSeparate(H[Ce],H[_e],H[ht],H[wt]),A=Ce,T=_e,N=ht,I=wt),(Ot.equals(C)===!1||cn!==D)&&(t.blendColor(Ot.r,Ot.g,Ot.b,cn),C.copy(Ot),D=cn),E=pe,F=!1}function G(pe,Ue){pe.side===cc?ve(t.CULL_FACE):re(t.CULL_FACE);let Ce=pe.side===Ws;Ue&&(Ce=!Ce),J(Ce),pe.blending===tm&&pe.transparent===!1?ie(qu):ie(pe.blending,pe.blendEquation,pe.blendSrc,pe.blendDst,pe.blendEquationAlpha,pe.blendSrcAlpha,pe.blendDstAlpha,pe.blendColor,pe.blendAlpha,pe.premultipliedAlpha),l.setFunc(pe.depthFunc),l.setTest(pe.depthTest),l.setMask(pe.depthWrite),o.setMask(pe.colorWrite);const _e=pe.stencilWrite;u.setTest(_e),_e&&(u.setMask(pe.stencilWriteMask),u.setFunc(pe.stencilFunc,pe.stencilRef,pe.stencilFuncMask),u.setOp(pe.stencilFail,pe.stencilZFail,pe.stencilZPass)),Ne(pe.polygonOffset,pe.polygonOffsetFactor,pe.polygonOffsetUnits),pe.alphaToCoverage===!0?re(t.SAMPLE_ALPHA_TO_COVERAGE):ve(t.SAMPLE_ALPHA_TO_COVERAGE)}function J(pe){j!==pe&&(pe?t.frontFace(t.CW):t.frontFace(t.CCW),j=pe)}function le(pe){pe!==YDe?(re(t.CULL_FACE),pe!==q&&(pe===RH?t.cullFace(t.BACK):pe===ZDe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ve(t.CULL_FACE),q=pe}function ke(pe){pe!==R&&(te&&t.lineWidth(pe),R=pe)}function Ne(pe,Ue,Ce){pe?(re(t.POLYGON_OFFSET_FILL),(W!==Ue||K!==Ce)&&(t.polygonOffset(Ue,Ce),W=Ue,K=Ce)):ve(t.POLYGON_OFFSET_FILL)}function Se(pe){pe?re(t.SCISSOR_TEST):ve(t.SCISSOR_TEST)}function B(pe){pe===void 0&&(pe=t.TEXTURE0+V-1),U!==pe&&(t.activeTexture(pe),U=pe)}function L(pe,Ue,Ce){Ce===void 0&&(U===null?Ce=t.TEXTURE0+V-1:Ce=U);let _e=z[Ce];_e===void 0&&(_e={type:void 0,texture:void 0},z[Ce]=_e),(_e.type!==pe||_e.texture!==Ue)&&(U!==Ce&&(t.activeTexture(Ce),U=Ce),t.bindTexture(pe,Ue||ye[pe]),_e.type=pe,_e.texture=Ue)}function ne(){const pe=z[U];pe!==void 0&&pe.type!==void 0&&(t.bindTexture(pe.type,null),pe.type=void 0,pe.texture=void 0)}function be(){try{t.compressedTexImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ge(){try{t.texSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function me(){try{t.texSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ae(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ze(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function st(){try{t.texStorage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ve(){try{t.texStorage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function ce(){try{t.texImage2D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function Ye(){try{t.texImage3D.apply(t,arguments)}catch(pe){console.error("THREE.WebGLState:",pe)}}function $e(pe){fe.equals(pe)===!1&&(t.scissor(pe.x,pe.y,pe.z,pe.w),fe.copy(pe))}function Ze(pe){de.equals(pe)===!1&&(t.viewport(pe.x,pe.y,pe.z,pe.w),de.copy(pe))}function at(pe,Ue){let Ce=f.get(Ue);Ce===void 0&&(Ce=new WeakMap,f.set(Ue,Ce));let _e=Ce.get(pe);_e===void 0&&(_e=t.getUniformBlockIndex(Ue,pe.name),Ce.set(pe,_e))}function Q(pe,Ue){const _e=f.get(Ue).get(pe);d.get(Ue)!==_e&&(t.uniformBlockBinding(Ue,_e,pe.__bindingPointIndex),d.set(Ue,_e))}function Fe(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},U=null,z={},m={},x=new WeakMap,y=[],v=null,b=!1,E=null,S=null,A=null,T=null,k=null,N=null,I=null,C=new $t(0,0,0),D=0,F=!1,j=null,q=null,R=null,W=null,K=null,fe.set(0,0,t.canvas.width,t.canvas.height),de.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),u.reset()}return{buffers:{color:o,depth:l,stencil:u},enable:re,disable:ve,bindFramebuffer:je,drawBuffers:ue,useProgram:ut,setBlending:ie,setMaterial:G,setFlipSided:J,setCullFace:le,setLineWidth:ke,setPolygonOffset:Ne,setScissorTest:Se,activeTexture:B,bindTexture:L,unbindTexture:ne,compressedTexImage2D:be,compressedTexImage3D:we,texImage2D:ce,texImage3D:Ye,updateUBOMapping:at,uniformBlockBinding:Q,texStorage2D:st,texStorage3D:Ve,texSubImage2D:ge,texSubImage3D:me,compressedTexSubImage2D:Ae,compressedTexSubImage3D:ze,scissor:$e,viewport:Ze,reset:Fe}}function s5e(t,e,n,r,i,s,a){const o=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let y;const v=new WeakMap;let b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(B,L){return b?new OffscreenCanvas(B,L):Pw("canvas")}function S(B,L,ne,be){let we=1;if((B.width>be||B.height>be)&&(we=be/Math.max(B.width,B.height)),we<1||L===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){const ge=L?kw:Math.floor,me=ge(we*B.width),Ae=ge(we*B.height);y===void 0&&(y=E(me,Ae));const ze=ne?E(me,Ae):y;return ze.width=me,ze.height=Ae,ze.getContext("2d").drawImage(B,0,0,me,Ae),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+me+"x"+Ae+")."),ze}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function A(B){return CP(B.width)&&CP(B.height)}function T(B){return o?!1:B.wrapS!==Ao||B.wrapT!==Ao||B.minFilter!==Xi&&B.minFilter!==qa}function k(B,L){return B.generateMipmaps&&L&&B.minFilter!==Xi&&B.minFilter!==qa}function N(B){t.generateMipmap(B)}function I(B,L,ne,be,we=!1){if(o===!1)return L;if(B!==null){if(t[B]!==void 0)return t[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ge=L;if(L===t.RED&&(ne===t.FLOAT&&(ge=t.R32F),ne===t.HALF_FLOAT&&(ge=t.R16F),ne===t.UNSIGNED_BYTE&&(ge=t.R8)),L===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ge=t.R8UI),ne===t.UNSIGNED_SHORT&&(ge=t.R16UI),ne===t.UNSIGNED_INT&&(ge=t.R32UI),ne===t.BYTE&&(ge=t.R8I),ne===t.SHORT&&(ge=t.R16I),ne===t.INT&&(ge=t.R32I)),L===t.RG&&(ne===t.FLOAT&&(ge=t.RG32F),ne===t.HALF_FLOAT&&(ge=t.RG16F),ne===t.UNSIGNED_BYTE&&(ge=t.RG8)),L===t.RGBA){const me=we?Tw:Kn.getTransfer(be);ne===t.FLOAT&&(ge=t.RGBA32F),ne===t.HALF_FLOAT&&(ge=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ge=me===lr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ge=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ge=t.RGB5_A1)}return(ge===t.R16F||ge===t.R32F||ge===t.RG16F||ge===t.RG32F||ge===t.RGBA16F||ge===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ge}function C(B,L,ne){return k(B,ne)===!0||B.isFramebufferTexture&&B.minFilter!==Xi&&B.minFilter!==qa?Math.log2(Math.max(L.width,L.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?L.mipmaps.length:1}function D(B){return B===Xi||B===UH||B===zC?t.NEAREST:t.LINEAR}function F(B){const L=B.target;L.removeEventListener("dispose",F),q(L),L.isVideoTexture&&x.delete(L)}function j(B){const L=B.target;L.removeEventListener("dispose",j),W(L)}function q(B){const L=r.get(B);if(L.__webglInit===void 0)return;const ne=B.source,be=v.get(ne);if(be){const we=be[L.__cacheKey];we.usedTimes--,we.usedTimes===0&&R(B),Object.keys(be).length===0&&v.delete(ne)}r.remove(B)}function R(B){const L=r.get(B);t.deleteTexture(L.__webglTexture);const ne=B.source,be=v.get(ne);delete be[L.__cacheKey],a.memory.textures--}function W(B){const L=B.texture,ne=r.get(B),be=r.get(L);if(be.__webglTexture!==void 0&&(t.deleteTexture(be.__webglTexture),a.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(ne.__webglFramebuffer[we]))for(let ge=0;ge<ne.__webglFramebuffer[we].length;ge++)t.deleteFramebuffer(ne.__webglFramebuffer[we][ge]);else t.deleteFramebuffer(ne.__webglFramebuffer[we]);ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer[we])}else{if(Array.isArray(ne.__webglFramebuffer))for(let we=0;we<ne.__webglFramebuffer.length;we++)t.deleteFramebuffer(ne.__webglFramebuffer[we]);else t.deleteFramebuffer(ne.__webglFramebuffer);if(ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let we=0;we<ne.__webglColorRenderbuffer.length;we++)ne.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(ne.__webglColorRenderbuffer[we]);ne.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let we=0,ge=L.length;we<ge;we++){const me=r.get(L[we]);me.__webglTexture&&(t.deleteTexture(me.__webglTexture),a.memory.textures--),r.remove(L[we])}r.remove(L),r.remove(B)}let K=0;function V(){K=0}function te(){const B=K;return B>=l&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+l),K+=1,B}function Y(B){const L=[];return L.push(B.wrapS),L.push(B.wrapT),L.push(B.wrapR||0),L.push(B.magFilter),L.push(B.minFilter),L.push(B.anisotropy),L.push(B.internalFormat),L.push(B.format),L.push(B.type),L.push(B.generateMipmaps),L.push(B.premultiplyAlpha),L.push(B.flipY),L.push(B.unpackAlignment),L.push(B.colorSpace),L.join()}function Z(B,L){const ne=r.get(B);if(B.isVideoTexture&&Ne(B),B.isRenderTargetTexture===!1&&B.version>0&&ne.__version!==B.version){const be=B.image;if(be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(ne,B,L);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+L)}function U(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){re(ne,B,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+L)}function z(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){re(ne,B,L);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+L)}function ee(B,L){const ne=r.get(B);if(B.version>0&&ne.__version!==B.version){ve(ne,B,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+L)}const ae={[EP]:t.REPEAT,[Ao]:t.CLAMP_TO_EDGE,[MP]:t.MIRRORED_REPEAT},fe={[Xi]:t.NEAREST,[UH]:t.NEAREST_MIPMAP_NEAREST,[zC]:t.NEAREST_MIPMAP_LINEAR,[qa]:t.LINEAR,[NOe]:t.LINEAR_MIPMAP_NEAREST,[z0]:t.LINEAR_MIPMAP_LINEAR},de={[BOe]:t.NEVER,[qOe]:t.ALWAYS,[HOe]:t.LESS,[TZ]:t.LEQUAL,[$Oe]:t.EQUAL,[WOe]:t.GEQUAL,[VOe]:t.GREATER,[GOe]:t.NOTEQUAL};function xe(B,L,ne){if(ne?(t.texParameteri(B,t.TEXTURE_WRAP_S,ae[L.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,ae[L.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,ae[L.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,fe[L.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,fe[L.minFilter])):(t.texParameteri(B,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(B,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==Ao||L.wrapT!==Ao)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(B,t.TEXTURE_MAG_FILTER,D(L.magFilter)),t.texParameteri(B,t.TEXTURE_MIN_FILTER,D(L.minFilter)),L.minFilter!==Xi&&L.minFilter!==qa&&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(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,de[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const be=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Xi||L.minFilter!==zC&&L.minFilter!==z0||L.type===mc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===B0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(B,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function ye(B,L){let ne=!1;B.__webglInit===void 0&&(B.__webglInit=!0,L.addEventListener("dispose",F));const be=L.source;let we=v.get(be);we===void 0&&(we={},v.set(be,we));const ge=Y(L);if(ge!==B.__cacheKey){we[ge]===void 0&&(we[ge]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,ne=!0),we[ge].usedTimes++;const me=we[B.__cacheKey];me!==void 0&&(we[B.__cacheKey].usedTimes--,me.usedTimes===0&&R(L)),B.__cacheKey=ge,B.__webglTexture=we[ge].texture}return ne}function re(B,L,ne){let be=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(be=t.TEXTURE_3D);const we=ye(B,L),ge=L.source;n.bindTexture(be,B.__webglTexture,t.TEXTURE0+ne);const me=r.get(ge);if(ge.version!==me.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Ae=Kn.getPrimaries(Kn.workingColorSpace),ze=L.colorSpace===Xa?null:Kn.getPrimaries(L.colorSpace),st=L.colorSpace===Xa||Ae===ze?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);const Ve=T(L)&&A(L.image)===!1;let ce=S(L.image,Ve,!1,d);ce=Se(L,ce);const Ye=A(ce)||o,$e=s.convert(L.format,L.colorSpace);let Ze=s.convert(L.type),at=I(L.internalFormat,$e,Ze,L.colorSpace,L.isVideoTexture);xe(be,L,Ye);let Q;const Fe=L.mipmaps,pe=o&&L.isVideoTexture!==!0&&at!==EZ,Ue=me.__version===void 0||we===!0,Ce=C(L,ce,Ye);if(L.isDepthTexture)at=t.DEPTH_COMPONENT,o?L.type===mc?at=t.DEPTH_COMPONENT32F:L.type===Fu?at=t.DEPTH_COMPONENT24:L.type===Mh?at=t.DEPTH24_STENCIL8:at=t.DEPTH_COMPONENT16:L.type===mc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===Ah&&at===t.DEPTH_COMPONENT&&L.type!==sj&&L.type!==Fu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Fu,Ze=s.convert(L.type)),L.format===Tm&&at===t.DEPTH_COMPONENT&&(at=t.DEPTH_STENCIL,L.type!==Mh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Mh,Ze=s.convert(L.type))),Ue&&(pe?n.texStorage2D(t.TEXTURE_2D,1,at,ce.width,ce.height):n.texImage2D(t.TEXTURE_2D,0,at,ce.width,ce.height,0,$e,Ze,null));else if(L.isDataTexture)if(Fe.length>0&&Ye){pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],pe?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,Q.width,Q.height,$e,Ze,Q.data):n.texImage2D(t.TEXTURE_2D,_e,at,Q.width,Q.height,0,$e,Ze,Q.data);L.generateMipmaps=!1}else pe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ce.width,ce.height,$e,Ze,ce.data)):n.texImage2D(t.TEXTURE_2D,0,at,ce.width,ce.height,0,$e,Ze,ce.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){pe&&Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,at,Fe[0].width,Fe[0].height,ce.depth);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],L.format!==Ka?$e!==null?pe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,Q.width,Q.height,ce.depth,$e,Q.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,_e,at,Q.width,Q.height,ce.depth,0,Q.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,_e,0,0,0,Q.width,Q.height,ce.depth,$e,Ze,Q.data):n.texImage3D(t.TEXTURE_2D_ARRAY,_e,at,Q.width,Q.height,ce.depth,0,$e,Ze,Q.data)}else{pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],L.format!==Ka?$e!==null?pe?n.compressedTexSubImage2D(t.TEXTURE_2D,_e,0,0,Q.width,Q.height,$e,Q.data):n.compressedTexImage2D(t.TEXTURE_2D,_e,at,Q.width,Q.height,0,Q.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):pe?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,Q.width,Q.height,$e,Ze,Q.data):n.texImage2D(t.TEXTURE_2D,_e,at,Q.width,Q.height,0,$e,Ze,Q.data)}else if(L.isDataArrayTexture)pe?(Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,at,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ce.width,ce.height,ce.depth,$e,Ze,ce.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,at,ce.width,ce.height,ce.depth,0,$e,Ze,ce.data);else if(L.isData3DTexture)pe?(Ue&&n.texStorage3D(t.TEXTURE_3D,Ce,at,ce.width,ce.height,ce.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ce.width,ce.height,ce.depth,$e,Ze,ce.data)):n.texImage3D(t.TEXTURE_3D,0,at,ce.width,ce.height,ce.depth,0,$e,Ze,ce.data);else if(L.isFramebufferTexture){if(Ue)if(pe)n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height);else{let _e=ce.width,He=ce.height;for(let ht=0;ht<Ce;ht++)n.texImage2D(t.TEXTURE_2D,ht,at,_e,He,0,$e,Ze,null),_e>>=1,He>>=1}}else if(Fe.length>0&&Ye){pe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,Fe[0].width,Fe[0].height);for(let _e=0,He=Fe.length;_e<He;_e++)Q=Fe[_e],pe?n.texSubImage2D(t.TEXTURE_2D,_e,0,0,$e,Ze,Q):n.texImage2D(t.TEXTURE_2D,_e,at,$e,Ze,Q);L.generateMipmaps=!1}else pe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Ce,at,ce.width,ce.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,$e,Ze,ce)):n.texImage2D(t.TEXTURE_2D,0,at,$e,Ze,ce);k(L,Ye)&&N(be),me.__version=ge.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function ve(B,L,ne){if(L.image.length!==6)return;const be=ye(B,L),we=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+ne);const ge=r.get(we);if(we.version!==ge.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const me=Kn.getPrimaries(Kn.workingColorSpace),Ae=L.colorSpace===Xa?null:Kn.getPrimaries(L.colorSpace),ze=L.colorSpace===Xa||me===Ae?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ze);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,Ve=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let _e=0;_e<6;_e++)!st&&!Ve?ce[_e]=S(L.image[_e],!1,!0,u):ce[_e]=Ve?L.image[_e].image:L.image[_e],ce[_e]=Se(L,ce[_e]);const Ye=ce[0],$e=A(Ye)||o,Ze=s.convert(L.format,L.colorSpace),at=s.convert(L.type),Q=I(L.internalFormat,Ze,at,L.colorSpace),Fe=o&&L.isVideoTexture!==!0,pe=ge.__version===void 0||be===!0;let Ue=C(L,Ye,$e);xe(t.TEXTURE_CUBE_MAP,L,$e);let Ce;if(st){Fe&&pe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,Q,Ye.width,Ye.height);for(let _e=0;_e<6;_e++){Ce=ce[_e].mipmaps;for(let He=0;He<Ce.length;He++){const ht=Ce[He];L.format!==Ka?Ze!==null?Fe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,Ze,ht.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,Q,ht.width,ht.height,0,ht.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,0,0,ht.width,ht.height,Ze,at,ht.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He,Q,ht.width,ht.height,0,Ze,at,ht.data)}}}else{Ce=L.mipmaps,Fe&&pe&&(Ce.length>0&&Ue++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,Q,ce[0].width,ce[0].height));for(let _e=0;_e<6;_e++)if(Ve){Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,ce[_e].width,ce[_e].height,Ze,at,ce[_e].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,Q,ce[_e].width,ce[_e].height,0,Ze,at,ce[_e].data);for(let He=0;He<Ce.length;He++){const wt=Ce[He].image[_e].image;Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,wt.width,wt.height,Ze,at,wt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,Q,wt.width,wt.height,0,Ze,at,wt.data)}}else{Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,0,0,Ze,at,ce[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,Q,Ze,at,ce[_e]);for(let He=0;He<Ce.length;He++){const ht=Ce[He];Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,0,0,Ze,at,ht.image[_e]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+_e,He+1,Q,Ze,at,ht.image[_e])}}}k(L,$e)&&N(t.TEXTURE_CUBE_MAP),ge.__version=we.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function je(B,L,ne,be,we,ge){const me=s.convert(ne.format,ne.colorSpace),Ae=s.convert(ne.type),ze=I(ne.internalFormat,me,Ae,ne.colorSpace);if(!r.get(L).__hasExternalTextures){const Ve=Math.max(1,L.width>>ge),ce=Math.max(1,L.height>>ge);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ge,ze,Ve,ce,L.depth,0,me,Ae,null):n.texImage2D(we,ge,ze,Ve,ce,0,me,Ae,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),ke(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,we,r.get(ne).__webglTexture,0,le(L)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,we,r.get(ne).__webglTexture,ge),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(B,L,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,B),L.depthBuffer&&!L.stencilBuffer){let be=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||ke(L)){const we=L.depthTexture;we&&we.isDepthTexture&&(we.type===mc?be=t.DEPTH_COMPONENT32F:we.type===Fu&&(be=t.DEPTH_COMPONENT24));const ge=le(L);ke(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ge,be,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ge,be,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,be,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,B)}else if(L.depthBuffer&&L.stencilBuffer){const be=le(L);ne&&ke(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,L.width,L.height):ke(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,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,B)}else{const be=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let we=0;we<be.length;we++){const ge=be[we],me=s.convert(ge.format,ge.colorSpace),Ae=s.convert(ge.type),ze=I(ge.internalFormat,me,Ae,ge.colorSpace),st=le(L);ne&&ke(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,ze,L.width,L.height):ke(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,ze,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ze,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ut(B,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(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),Z(L.depthTexture,0);const be=r.get(L.depthTexture).__webglTexture,we=le(L);if(L.depthTexture.format===Ah)ke(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0);else if(L.depthTexture.format===Tm)ke(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0);else throw new Error("Unknown depthTexture format")}function $(B){const L=r.get(B),ne=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!L.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");ut(L.__webglFramebuffer,B)}else if(ne){L.__webglDepthbuffer=[];for(let be=0;be<6;be++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[be]),L.__webglDepthbuffer[be]=t.createRenderbuffer(),ue(L.__webglDepthbuffer[be],B,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),ue(L.__webglDepthbuffer,B,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H(B,L,ne){const be=r.get(B);L!==void 0&&je(be.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&$(B)}function ie(B){const L=B.texture,ne=r.get(B),be=r.get(L);B.addEventListener("dispose",j),B.isWebGLMultipleRenderTargets!==!0&&(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=L.version,a.memory.textures++);const we=B.isWebGLCubeRenderTarget===!0,ge=B.isWebGLMultipleRenderTargets===!0,me=A(B)||o;if(we){ne.__webglFramebuffer=[];for(let Ae=0;Ae<6;Ae++)if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer[Ae]=[];for(let ze=0;ze<L.mipmaps.length;ze++)ne.__webglFramebuffer[Ae][ze]=t.createFramebuffer()}else ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ae=0;Ae<L.mipmaps.length;Ae++)ne.__webglFramebuffer[Ae]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(ge)if(i.drawBuffers){const Ae=B.texture;for(let ze=0,st=Ae.length;ze<st;ze++){const Ve=r.get(Ae[ze]);Ve.__webglTexture===void 0&&(Ve.__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&&B.samples>0&&ke(B)===!1){const Ae=ge?L:[L];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let ze=0;ze<Ae.length;ze++){const st=Ae[ze];ne.__webglColorRenderbuffer[ze]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[ze]);const Ve=s.convert(st.format,st.colorSpace),ce=s.convert(st.type),Ye=I(st.internalFormat,Ve,ce,st.colorSpace,B.isXRRenderTarget===!0),$e=le(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,$e,Ye,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ze,t.RENDERBUFFER,ne.__webglColorRenderbuffer[ze])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),ue(ne.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),xe(t.TEXTURE_CUBE_MAP,L,me);for(let Ae=0;Ae<6;Ae++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)je(ne.__webglFramebuffer[Ae][ze],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,ze);else je(ne.__webglFramebuffer[Ae],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0);k(L,me)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ge){const Ae=B.texture;for(let ze=0,st=Ae.length;ze<st;ze++){const Ve=Ae[ze],ce=r.get(Ve);n.bindTexture(t.TEXTURE_2D,ce.__webglTexture),xe(t.TEXTURE_2D,Ve,me),je(ne.__webglFramebuffer,B,Ve,t.COLOR_ATTACHMENT0+ze,t.TEXTURE_2D,0),k(Ve,me)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Ae=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(o?Ae=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ae,be.__webglTexture),xe(Ae,L,me),o&&L.mipmaps&&L.mipmaps.length>0)for(let ze=0;ze<L.mipmaps.length;ze++)je(ne.__webglFramebuffer[ze],B,L,t.COLOR_ATTACHMENT0,Ae,ze);else je(ne.__webglFramebuffer,B,L,t.COLOR_ATTACHMENT0,Ae,0);k(L,me)&&N(Ae),n.unbindTexture()}B.depthBuffer&&$(B)}function G(B){const L=A(B)||o,ne=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let be=0,we=ne.length;be<we;be++){const ge=ne[be];if(k(ge,L)){const me=B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ae=r.get(ge).__webglTexture;n.bindTexture(me,Ae),N(me),n.unbindTexture()}}}function J(B){if(o&&B.samples>0&&ke(B)===!1){const L=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],ne=B.width,be=B.height;let we=t.COLOR_BUFFER_BIT;const ge=[],me=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ae=r.get(B),ze=B.isWebGLMultipleRenderTargets===!0;if(ze)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ae.__webglFramebuffer);for(let st=0;st<L.length;st++){ge.push(t.COLOR_ATTACHMENT0+st),B.depthBuffer&&ge.push(me);const Ve=Ae.__ignoreDepthValues!==void 0?Ae.__ignoreDepthValues:!1;if(Ve===!1&&(B.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),ze&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ae.__webglColorRenderbuffer[st]),Ve===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[me]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[me])),ze){const ce=r.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ce,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,we,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ge)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ze)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,Ae.__webglColorRenderbuffer[st]);const Ve=r.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ve,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ae.__webglMultisampledFramebuffer)}}function le(B){return Math.min(f,B.samples)}function ke(B){const L=r.get(B);return o&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ne(B){const L=a.render.frame;x.get(B)!==L&&(x.set(B,L),B.update())}function Se(B,L){const ne=B.colorSpace,be=B.format,we=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===TP||ne!==Oc&&ne!==Xa&&(Kn.getTransfer(ne)===lr?o===!1?e.has("EXT_sRGB")===!0&&be===Ka?(B.format=TP,B.minFilter=qa,B.generateMipmaps=!1):L=kZ.sRGBToLinear(L):(be!==Ka||we!==Xu)&&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=te,this.resetTextureUnits=V,this.setTexture2D=Z,this.setTexture2DArray=U,this.setTexture3D=z,this.setTextureCube=ee,this.rebindTextures=H,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=$,this.setupFrameBufferTexture=je,this.useMultisampledRTT=ke}function a5e(t,e,n){const r=n.isWebGL2;function i(s,a=Xa){let o;const l=Kn.getTransfer(a);if(s===Xu)return t.UNSIGNED_BYTE;if(s===vZ)return t.UNSIGNED_SHORT_4_4_4_4;if(s===yZ)return t.UNSIGNED_SHORT_5_5_5_1;if(s===kOe)return t.BYTE;if(s===POe)return t.SHORT;if(s===sj)return t.UNSIGNED_SHORT;if(s===bZ)return t.INT;if(s===Fu)return t.UNSIGNED_INT;if(s===mc)return t.FLOAT;if(s===B0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===ROe)return t.ALPHA;if(s===Ka)return t.RGBA;if(s===DOe)return t.LUMINANCE;if(s===OOe)return t.LUMINANCE_ALPHA;if(s===Ah)return t.DEPTH_COMPONENT;if(s===Tm)return t.DEPTH_STENCIL;if(s===TP)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===jOe)return t.RED;if(s===_Z)return t.RED_INTEGER;if(s===LOe)return t.RG;if(s===wZ)return t.RG_INTEGER;if(s===SZ)return t.RGBA_INTEGER;if(s===BC||s===HC||s===$C||s===VC)if(l===lr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===BC)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===HC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===$C)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===VC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===BC)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===HC)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===$C)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===VC)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===FH||s===zH||s===BH||s===HH)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===FH)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===zH)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===BH)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===HH)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===EZ)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===$H||s===VH)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===$H)return l===lr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===VH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===GH||s===WH||s===qH||s===KH||s===XH||s===YH||s===ZH||s===QH||s===JH||s===e$||s===t$||s===n$||s===r$||s===i$)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===GH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===WH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===qH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===KH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===XH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===YH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ZH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===QH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===JH)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===e$)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===t$)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===n$)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===r$)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===i$)return l===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===GC||s===s$||s===a$)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===GC)return l===lr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===s$)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===a$)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===IOe||s===o$||s===l$||s===c$)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===GC)return o.COMPRESSED_RED_RGTC1_EXT;if(s===o$)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===l$)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===c$)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Mh?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 o5e extends ha{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class kx extends As{constructor(){super(),this.isGroup=!0,this.type="Group"}}const l5e={type:"move"};class pN{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new kx,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 kx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new De,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new De),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new kx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new De,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new De),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){a=!0;for(const y of e.hand.values()){const v=n.getJointPose(y,r),b=this._getHandJoint(u,y);v!==null&&(b.matrix.fromArray(v.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=v.radius),b.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),m=.02,x=.005;u.inputState.pinching&&g>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=m-x&&(u.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(l5e)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new kx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class c5e extends hf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,u=null,d=null,f=null,g=null,m=null,x=null;const y=n.getContextAttributes();let v=null,b=null;const E=[],S=[],A=new Yt;let T=null;const k=new ha;k.layers.enable(1),k.viewport=new Yn;const N=new ha;N.layers.enable(2),N.viewport=new Yn;const I=[k,N],C=new o5e;C.layers.enable(1),C.layers.enable(2);let D=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ae=E[ee];return ae===void 0&&(ae=new pN,E[ee]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(ee){let ae=E[ee];return ae===void 0&&(ae=new pN,E[ee]=ae),ae.getGripSpace()},this.getHand=function(ee){let ae=E[ee];return ae===void 0&&(ae=new pN,E[ee]=ae),ae.getHandSpace()};function j(ee){const ae=S.indexOf(ee.inputSource);if(ae===-1)return;const fe=E[ae];fe!==void 0&&(fe.update(ee.inputSource,ee.frame,u||a),fe.dispatchEvent({type:ee.type,data:ee.inputSource}))}function q(){i.removeEventListener("select",j),i.removeEventListener("selectstart",j),i.removeEventListener("selectend",j),i.removeEventListener("squeeze",j),i.removeEventListener("squeezestart",j),i.removeEventListener("squeezeend",j),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let ee=0;ee<E.length;ee++){const ae=S[ee];ae!==null&&(S[ee]=null,E[ee].disconnect(ae))}D=null,F=null,e.setRenderTarget(v),m=null,g=null,f=null,i=null,b=null,z.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){s=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){o=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(ee){u=ee},this.getBaseLayer=function(){return g!==null?g:m},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ee){if(i=ee,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",j),i.addEventListener("selectstart",j),i.addEventListener("selectend",j),i.addEventListener("squeeze",j),i.addEventListener("squeezestart",j),i.addEventListener("squeezeend",j),i.addEventListener("end",q),i.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ae={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,ae),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new Qh(m.framebufferWidth,m.framebufferHeight,{format:Ka,type:Xu,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,fe=null,de=null;y.depth&&(de=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?Tm:Ah,fe=y.stencil?Mh:Fu);const xe={colorFormat:n.RGBA8,depthFormat:de,scaleFactor:s};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(xe),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),b=new Qh(g.textureWidth,g.textureHeight,{format:Ka,type:Xu,depthTexture:new HZ(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 ye=e.properties.get(b);ye.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(l),u=null,a=await i.requestReferenceSpace(o),z.setContext(i),z.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function R(ee){for(let ae=0;ae<ee.removed.length;ae++){const fe=ee.removed[ae],de=S.indexOf(fe);de>=0&&(S[de]=null,E[de].disconnect(fe))}for(let ae=0;ae<ee.added.length;ae++){const fe=ee.added[ae];let de=S.indexOf(fe);if(de===-1){for(let ye=0;ye<E.length;ye++)if(ye>=S.length){S.push(fe),de=ye;break}else if(S[ye]===null){S[ye]=fe,de=ye;break}if(de===-1)break}const xe=E[de];xe&&xe.connect(fe)}}const W=new De,K=new De;function V(ee,ae,fe){W.setFromMatrixPosition(ae.matrixWorld),K.setFromMatrixPosition(fe.matrixWorld);const de=W.distanceTo(K),xe=ae.projectionMatrix.elements,ye=fe.projectionMatrix.elements,re=xe[14]/(xe[10]-1),ve=xe[14]/(xe[10]+1),je=(xe[9]+1)/xe[5],ue=(xe[9]-1)/xe[5],ut=(xe[8]-1)/xe[0],$=(ye[8]+1)/ye[0],H=re*ut,ie=re*$,G=de/(-ut+$),J=G*-ut;ae.matrixWorld.decompose(ee.position,ee.quaternion,ee.scale),ee.translateX(J),ee.translateZ(G),ee.matrixWorld.compose(ee.position,ee.quaternion,ee.scale),ee.matrixWorldInverse.copy(ee.matrixWorld).invert();const le=re+G,ke=ve+G,Ne=H-J,Se=ie+(de-J),B=je*ve/ke*le,L=ue*ve/ke*le;ee.projectionMatrix.makePerspective(Ne,Se,B,L,le,ke),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert()}function te(ee,ae){ae===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ae.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(i===null)return;C.near=N.near=k.near=ee.near,C.far=N.far=k.far=ee.far,(D!==C.near||F!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),D=C.near,F=C.far);const ae=ee.parent,fe=C.cameras;te(C,ae);for(let de=0;de<fe.length;de++)te(fe[de],ae);fe.length===2?V(C,k,N):C.projectionMatrix.copy(k.projectionMatrix),Y(ee,C,ae)};function Y(ee,ae,fe){fe===null?ee.matrix.copy(ae.matrixWorld):(ee.matrix.copy(fe.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ae.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ae.projectionMatrix),ee.projectionMatrixInverse.copy(ae.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=$0*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(g===null&&m===null))return l},this.setFoveation=function(ee){l=ee,g!==null&&(g.fixedFoveation=ee),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ee)};let Z=null;function U(ee,ae){if(d=ae.getViewerPose(u||a),x=ae,d!==null){const fe=d.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let de=!1;fe.length!==C.cameras.length&&(C.cameras.length=0,de=!0);for(let xe=0;xe<fe.length;xe++){const ye=fe[xe];let re=null;if(m!==null)re=m.getViewport(ye);else{const je=f.getViewSubImage(g,ye);re=je.viewport,xe===0&&(e.setRenderTargetTextures(b,je.colorTexture,g.ignoreDepthValues?void 0:je.depthStencilTexture),e.setRenderTarget(b))}let ve=I[xe];ve===void 0&&(ve=new ha,ve.layers.enable(xe),ve.viewport=new Yn,I[xe]=ve),ve.matrix.fromArray(ye.transform.matrix),ve.matrix.decompose(ve.position,ve.quaternion,ve.scale),ve.projectionMatrix.fromArray(ye.projectionMatrix),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert(),ve.viewport.set(re.x,re.y,re.width,re.height),xe===0&&(C.matrix.copy(ve.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),de===!0&&C.cameras.push(ve)}}for(let fe=0;fe<E.length;fe++){const de=S[fe],xe=E[fe];de!==null&&xe!==void 0&&xe.update(de,ae,u||a)}Z&&Z(ee,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),x=null}const z=new BZ;z.setAnimationLoop(U),this.setAnimationLoop=function(ee){Z=ee},this.dispose=function(){}}}function u5e(t,e){function n(v,b){v.matrixAutoUpdate===!0&&v.updateMatrix(),b.value.copy(v.matrix)}function r(v,b){b.color.getRGB(v.fogColor.value,UZ(t)),b.isFog?(v.fogNear.value=b.near,v.fogFar.value=b.far):b.isFogExp2&&(v.fogDensity.value=b.density)}function i(v,b,E,S,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?s(v,b):b.isMeshToonMaterial?(s(v,b),f(v,b)):b.isMeshPhongMaterial?(s(v,b),d(v,b)):b.isMeshStandardMaterial?(s(v,b),g(v,b),b.isMeshPhysicalMaterial&&m(v,b,A)):b.isMeshMatcapMaterial?(s(v,b),x(v,b)):b.isMeshDepthMaterial?s(v,b):b.isMeshDistanceMaterial?(s(v,b),y(v,b)):b.isMeshNormalMaterial?s(v,b):b.isLineBasicMaterial?(a(v,b),b.isLineDashedMaterial&&o(v,b)):b.isPointsMaterial?l(v,b,E,S):b.isSpriteMaterial?u(v,b):b.isShadowMaterial?(v.color.value.copy(b.color),v.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function s(v,b){v.opacity.value=b.opacity,b.color&&v.diffuse.value.copy(b.color),b.emissive&&v.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.bumpMap&&(v.bumpMap.value=b.bumpMap,n(b.bumpMap,v.bumpMapTransform),v.bumpScale.value=b.bumpScale,b.side===Ws&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===Ws&&v.normalScale.value.negate()),b.displacementMap&&(v.displacementMap.value=b.displacementMap,n(b.displacementMap,v.displacementMapTransform),v.displacementScale.value=b.displacementScale,v.displacementBias.value=b.displacementBias),b.emissiveMap&&(v.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,v.emissiveMapTransform)),b.specularMap&&(v.specularMap.value=b.specularMap,n(b.specularMap,v.specularMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest);const E=e.get(b).envMap;if(E&&(v.envMap.value=E,v.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=b.reflectivity,v.ior.value=b.ior,v.refractionRatio.value=b.refractionRatio),b.lightMap){v.lightMap.value=b.lightMap;const S=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=b.lightMapIntensity*S,n(b.lightMap,v.lightMapTransform)}b.aoMap&&(v.aoMap.value=b.aoMap,v.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,v.aoMapTransform))}function a(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform))}function o(v,b){v.dashSize.value=b.dashSize,v.totalSize.value=b.dashSize+b.gapSize,v.scale.value=b.scale}function l(v,b,E,S){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*E,v.scale.value=S*.5,b.map&&(v.map.value=b.map,n(b.map,v.uvTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function u(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.rotation.value=b.rotation,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function d(v,b){v.specular.value.copy(b.specular),v.shininess.value=Math.max(b.shininess,1e-4)}function f(v,b){b.gradientMap&&(v.gradientMap.value=b.gradientMap)}function g(v,b){v.metalness.value=b.metalness,b.metalnessMap&&(v.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,v.metalnessMapTransform)),v.roughness.value=b.roughness,b.roughnessMap&&(v.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,v.roughnessMapTransform)),e.get(b).envMap&&(v.envMapIntensity.value=b.envMapIntensity)}function m(v,b,E){v.ior.value=b.ior,b.sheen>0&&(v.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),v.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(v.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,v.sheenColorMapTransform)),b.sheenRoughnessMap&&(v.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,v.sheenRoughnessMapTransform))),b.clearcoat>0&&(v.clearcoat.value=b.clearcoat,v.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(v.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,v.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(v.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Ws&&v.clearcoatNormalScale.value.negate())),b.iridescence>0&&(v.iridescence.value=b.iridescence,v.iridescenceIOR.value=b.iridescenceIOR,v.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(v.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,v.iridescenceMapTransform)),b.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),b.transmission>0&&(v.transmission.value=b.transmission,v.transmissionSamplerMap.value=E.texture,v.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(v.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,v.transmissionMapTransform)),v.thickness.value=b.thickness,b.thicknessMap&&(v.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=b.attenuationDistance,v.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(v.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(v.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=b.specularIntensity,v.specularColor.value.copy(b.specularColor),b.specularColorMap&&(v.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,v.specularColorMapTransform)),b.specularIntensityMap&&(v.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,b){b.matcap&&(v.matcap.value=b.matcap)}function y(v,b){const E=e.get(b).light;v.referencePosition.value.setFromMatrixPosition(E.matrixWorld),v.nearDistance.value=E.shadow.camera.near,v.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function d5e(t,e,n,r){let i={},s={},a=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(E,S){const A=S.program;r.uniformBlockBinding(E,A)}function u(E,S){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",v));const T=S.program;r.updateUBOMapping(E,T);const k=e.render.frame;s[E.id]!==k&&(g(E),s[E.id]=k)}function d(E){const S=f();E.__bindingPointIndex=S;const A=t.createBuffer(),T=E.__size,k=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,k),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,S,A),A}function f(){for(let E=0;E<o;E++)if(a.indexOf(E)===-1)return a.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const S=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,S);for(let k=0,N=A.length;k<N;k++){const I=A[k];if(m(I,k,T)===!0){const C=I.__offset,D=Array.isArray(I.value)?I.value:[I.value];let F=0;for(let j=0;j<D.length;j++){const q=D[j],R=y(q);typeof q=="number"?(I.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,C+F,I.__data)):q.isMatrix3?(I.__data[0]=q.elements[0],I.__data[1]=q.elements[1],I.__data[2]=q.elements[2],I.__data[3]=q.elements[0],I.__data[4]=q.elements[3],I.__data[5]=q.elements[4],I.__data[6]=q.elements[5],I.__data[7]=q.elements[0],I.__data[8]=q.elements[6],I.__data[9]=q.elements[7],I.__data[10]=q.elements[8],I.__data[11]=q.elements[0]):(q.toArray(I.__data,F),F+=R.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,C,I.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(E,S,A){const T=E.value;if(A[S]===void 0){if(typeof T=="number")A[S]=T;else{const k=Array.isArray(T)?T:[T],N=[];for(let I=0;I<k.length;I++)N.push(k[I].clone());A[S]=N}return!0}else if(typeof T=="number"){if(A[S]!==T)return A[S]=T,!0}else{const k=Array.isArray(A[S])?A[S]:[A[S]],N=Array.isArray(T)?T:[T];for(let I=0;I<k.length;I++){const C=k[I];if(C.equals(N[I])===!1)return C.copy(N[I]),!0}}return!1}function x(E){const S=E.uniforms;let A=0;const T=16;let k=0;for(let N=0,I=S.length;N<I;N++){const C=S[N],D={boundary:0,storage:0},F=Array.isArray(C.value)?C.value:[C.value];for(let j=0,q=F.length;j<q;j++){const R=F[j],W=y(R);D.boundary+=W.boundary,D.storage+=W.storage}if(C.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=A,N>0){k=A%T;const j=T-k;k!==0&&j-D.boundary<0&&(A+=T-k,C.__offset=A)}A+=D.storage}return k=A%T,k>0&&(A+=T-k),E.__size=A,E.__cache={},this}function y(E){const S={boundary:0,storage:0};return typeof E=="number"?(S.boundary=4,S.storage=4):E.isVector2?(S.boundary=8,S.storage=8):E.isVector3||E.isColor?(S.boundary=16,S.storage=12):E.isVector4?(S.boundary=16,S.storage=16):E.isMatrix3?(S.boundary=48,S.storage=48):E.isMatrix4?(S.boundary=64,S.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),S}function v(E){const S=E.target;S.removeEventListener("dispose",v);const A=a.indexOf(S.__bindingPointIndex);a.splice(A,1),t.deleteBuffer(i[S.id]),delete i[S.id],delete s[S.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);a=[],i={},s={}}return{bind:l,update:u,dispose:b}}class kP{constructor(e={}){const{canvas:n=lje(),context:r=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=a;const m=new Uint32Array(4),x=new Int32Array(4);let y=null,v=null;const b=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Yi,this._useLegacyLights=!1,this.toneMapping=Ku,this.toneMappingExposure=1;const S=this;let A=!1,T=0,k=0,N=null,I=-1,C=null;const D=new Yn,F=new Yn;let j=null;const q=new $t(0);let R=0,W=n.width,K=n.height,V=1,te=null,Y=null;const Z=new Yn(0,0,W,K),U=new Yn(0,0,W,K);let z=!1;const ee=new UE;let ae=!1,fe=!1,de=null;const xe=new sr,ye=new Yt,re=new De,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function je(){return N===null?V:1}let ue=r;function ut(he,Ge){for(let nt=0;nt<he.length;nt++){const rt=he[nt],et=n.getContext(rt,Ge);if(et!==null)return et}return null}try{const he={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${jE}`),n.addEventListener("webglcontextlost",Fe,!1),n.addEventListener("webglcontextrestored",pe,!1),n.addEventListener("webglcontextcreationerror",Ue,!1),ue===null){const Ge=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&Ge.shift(),ue=ut(Ge,he),ue===null)throw ut(Ge)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ue instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ue.getShaderPrecisionFormat===void 0&&(ue.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(he){throw console.error("THREE.WebGLRenderer: "+he.message),he}let $,H,ie,G,J,le,ke,Ne,Se,B,L,ne,be,we,ge,me,Ae,ze,st,Ve,ce,Ye,$e,Ze;function at(){$=new w4e(ue),H=new m4e(ue,$,e),$.init(H),Ye=new a5e(ue,$,H),ie=new i5e(ue,$,H),G=new M4e(ue),J=new VUe,le=new s5e(ue,$,ie,J,H,Ye,G),ke=new x4e(S),Ne=new _4e(S),Se=new Rje(ue,H),$e=new f4e(ue,$,Se,H),B=new S4e(ue,Se,G,$e),L=new N4e(ue,B,Se,G),st=new C4e(ue,H,le),me=new g4e(J),ne=new $Ue(S,ke,Ne,$,H,$e,me),be=new u5e(S,J),we=new WUe,ge=new QUe($,H),ze=new h4e(S,ke,Ne,ie,L,g,l),Ae=new r5e(S,L,H),Ze=new d5e(ue,G,H,ie),Ve=new p4e(ue,$,G,H),ce=new E4e(ue,$,G,H),G.programs=ne.programs,S.capabilities=H,S.extensions=$,S.properties=J,S.renderLists=we,S.shadowMap=Ae,S.state=ie,S.info=G}at();const Q=new c5e(S,ue);this.xr=Q,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){const he=$.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=$.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(he){he!==void 0&&(V=he,this.setSize(W,K,!1))},this.getSize=function(he){return he.set(W,K)},this.setSize=function(he,Ge,nt=!0){if(Q.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=he,K=Ge,n.width=Math.floor(he*V),n.height=Math.floor(Ge*V),nt===!0&&(n.style.width=he+"px",n.style.height=Ge+"px"),this.setViewport(0,0,he,Ge)},this.getDrawingBufferSize=function(he){return he.set(W*V,K*V).floor()},this.setDrawingBufferSize=function(he,Ge,nt){W=he,K=Ge,V=nt,n.width=Math.floor(he*nt),n.height=Math.floor(Ge*nt),this.setViewport(0,0,he,Ge)},this.getCurrentViewport=function(he){return he.copy(D)},this.getViewport=function(he){return he.copy(Z)},this.setViewport=function(he,Ge,nt,rt){he.isVector4?Z.set(he.x,he.y,he.z,he.w):Z.set(he,Ge,nt,rt),ie.viewport(D.copy(Z).multiplyScalar(V).floor())},this.getScissor=function(he){return he.copy(U)},this.setScissor=function(he,Ge,nt,rt){he.isVector4?U.set(he.x,he.y,he.z,he.w):U.set(he,Ge,nt,rt),ie.scissor(F.copy(U).multiplyScalar(V).floor())},this.getScissorTest=function(){return z},this.setScissorTest=function(he){ie.setScissorTest(z=he)},this.setOpaqueSort=function(he){te=he},this.setTransparentSort=function(he){Y=he},this.getClearColor=function(he){return he.copy(ze.getClearColor())},this.setClearColor=function(){ze.setClearColor.apply(ze,arguments)},this.getClearAlpha=function(){return ze.getClearAlpha()},this.setClearAlpha=function(){ze.setClearAlpha.apply(ze,arguments)},this.clear=function(he=!0,Ge=!0,nt=!0){let rt=0;if(he){let et=!1;if(N!==null){const St=N.texture.format;et=St===SZ||St===wZ||St===_Z}if(et){const St=N.texture.type,se=St===Xu||St===Fu||St===sj||St===Mh||St===vZ||St===yZ,Ee=ze.getClearColor(),Le=ze.getClearAlpha(),Oe=Ee.r,Te=Ee.g,ot=Ee.b;se?(m[0]=Oe,m[1]=Te,m[2]=ot,m[3]=Le,ue.clearBufferuiv(ue.COLOR,0,m)):(x[0]=Oe,x[1]=Te,x[2]=ot,x[3]=Le,ue.clearBufferiv(ue.COLOR,0,x))}else rt|=ue.COLOR_BUFFER_BIT}Ge&&(rt|=ue.DEPTH_BUFFER_BIT),nt&&(rt|=ue.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ue.clear(rt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Fe,!1),n.removeEventListener("webglcontextrestored",pe,!1),n.removeEventListener("webglcontextcreationerror",Ue,!1),we.dispose(),ge.dispose(),J.dispose(),ke.dispose(),Ne.dispose(),L.dispose(),$e.dispose(),Ze.dispose(),ne.dispose(),Q.dispose(),Q.removeEventListener("sessionstart",cn),Q.removeEventListener("sessionend",It),de&&(de.dispose(),de=null),Dn.stop()};function Fe(he){he.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function pe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const he=G.autoReset,Ge=Ae.enabled,nt=Ae.autoUpdate,rt=Ae.needsUpdate,et=Ae.type;at(),G.autoReset=he,Ae.enabled=Ge,Ae.autoUpdate=nt,Ae.needsUpdate=rt,Ae.type=et}function Ue(he){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Ce(he){const Ge=he.target;Ge.removeEventListener("dispose",Ce),_e(Ge)}function _e(he){He(he),J.remove(he)}function He(he){const Ge=J.get(he).programs;Ge!==void 0&&(Ge.forEach(function(nt){ne.releaseProgram(nt)}),he.isShaderMaterial&&ne.releaseShaderCache(he))}this.renderBufferDirect=function(he,Ge,nt,rt,et,St){Ge===null&&(Ge=ve);const se=et.isMesh&&et.matrixWorld.determinant()<0,Ee=Dr(he,Ge,nt,rt,et);ie.setMaterial(rt,se);let Le=nt.index,Oe=1;if(rt.wireframe===!0){if(Le=B.getWireframeAttribute(nt),Le===void 0)return;Oe=2}const Te=nt.drawRange,ot=nt.attributes.position;let ft=Te.start*Oe,bt=(Te.start+Te.count)*Oe;St!==null&&(ft=Math.max(ft,St.start*Oe),bt=Math.min(bt,(St.start+St.count)*Oe)),Le!==null?(ft=Math.max(ft,0),bt=Math.min(bt,Le.count)):ot!=null&&(ft=Math.max(ft,0),bt=Math.min(bt,ot.count));const xt=bt-ft;if(xt<0||xt===1/0)return;$e.setup(et,rt,Ee,nt,Le);let jt,Mt=Ve;if(Le!==null&&(jt=Se.get(Le),Mt=ce,Mt.setIndex(jt)),et.isMesh)rt.wireframe===!0?(ie.setLineWidth(rt.wireframeLinewidth*je()),Mt.setMode(ue.LINES)):Mt.setMode(ue.TRIANGLES);else if(et.isLine){let mt=rt.linewidth;mt===void 0&&(mt=1),ie.setLineWidth(mt*je()),et.isLineSegments?Mt.setMode(ue.LINES):et.isLineLoop?Mt.setMode(ue.LINE_LOOP):Mt.setMode(ue.LINE_STRIP)}else et.isPoints?Mt.setMode(ue.POINTS):et.isSprite&&Mt.setMode(ue.TRIANGLES);if(et.isBatchedMesh)Mt.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)Mt.renderInstances(ft,xt,et.count);else if(nt.isInstancedBufferGeometry){const mt=nt._maxInstanceCount!==void 0?nt._maxInstanceCount:1/0,Kt=Math.min(nt.instanceCount,mt);Mt.renderInstances(ft,xt,Kt)}else Mt.render(ft,xt)};function ht(he,Ge,nt){he.transparent===!0&&he.side===cc&&he.forceSinglePass===!1?(he.side=Ws,he.needsUpdate=!0,ts(he,Ge,nt),he.side=ud,he.needsUpdate=!0,ts(he,Ge,nt),he.side=cc):ts(he,Ge,nt)}this.compile=function(he,Ge,nt=null){nt===null&&(nt=he),v=ge.get(nt),v.init(),E.push(v),nt.traverseVisible(function(et){et.isLight&&et.layers.test(Ge.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),he!==nt&&he.traverseVisible(function(et){et.isLight&&et.layers.test(Ge.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),v.setupLights(S._useLegacyLights);const rt=new Set;return he.traverse(function(et){const St=et.material;if(St)if(Array.isArray(St))for(let se=0;se<St.length;se++){const Ee=St[se];ht(Ee,nt,et),rt.add(Ee)}else ht(St,nt,et),rt.add(St)}),E.pop(),v=null,rt},this.compileAsync=function(he,Ge,nt=null){const rt=this.compile(he,Ge,nt);return new Promise(et=>{function St(){if(rt.forEach(function(se){J.get(se).currentProgram.isReady()&&rt.delete(se)}),rt.size===0){et(he);return}setTimeout(St,10)}$.get("KHR_parallel_shader_compile")!==null?St():setTimeout(St,10)})};let wt=null;function Ot(he){wt&&wt(he)}function cn(){Dn.stop()}function It(){Dn.start()}const Dn=new BZ;Dn.setAnimationLoop(Ot),typeof self<"u"&&Dn.setContext(self),this.setAnimationLoop=function(he){wt=he,Q.setAnimationLoop(he),he===null?Dn.stop():Dn.start()},Q.addEventListener("sessionstart",cn),Q.addEventListener("sessionend",It),this.render=function(he,Ge){if(Ge!==void 0&&Ge.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),Ge.parent===null&&Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),Q.enabled===!0&&Q.isPresenting===!0&&(Q.cameraAutoUpdate===!0&&Q.updateCamera(Ge),Ge=Q.getCamera()),he.isScene===!0&&he.onBeforeRender(S,he,Ge,N),v=ge.get(he,E.length),v.init(),E.push(v),xe.multiplyMatrices(Ge.projectionMatrix,Ge.matrixWorldInverse),ee.setFromProjectionMatrix(xe),fe=this.localClippingEnabled,ae=me.init(this.clippingPlanes,fe),y=we.get(he,b.length),y.init(),b.push(y),Qn(he,Ge,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(te,Y),this.info.render.frame++,ae===!0&&me.beginShadows();const nt=v.state.shadowsArray;if(Ae.render(nt,he,Ge),ae===!0&&me.endShadows(),this.info.autoReset===!0&&this.info.reset(),ze.render(y,he),v.setupLights(S._useLegacyLights),Ge.isArrayCamera){const rt=Ge.cameras;for(let et=0,St=rt.length;et<St;et++){const se=rt[et];wi(y,he,se,se.viewport)}}else wi(y,he,Ge);N!==null&&(le.updateMultisampleRenderTarget(N),le.updateRenderTargetMipmap(N)),he.isScene===!0&&he.onAfterRender(S,he,Ge),$e.resetDefaultState(),I=-1,C=null,E.pop(),E.length>0?v=E[E.length-1]:v=null,b.pop(),b.length>0?y=b[b.length-1]:y=null};function Qn(he,Ge,nt,rt){if(he.visible===!1)return;if(he.layers.test(Ge.layers)){if(he.isGroup)nt=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(Ge);else if(he.isLight)v.pushLight(he),he.castShadow&&v.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||ee.intersectsSprite(he)){rt&&re.setFromMatrixPosition(he.matrixWorld).applyMatrix4(xe);const se=L.update(he),Ee=he.material;Ee.visible&&y.push(he,se,Ee,nt,re.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||ee.intersectsObject(he))){const se=L.update(he),Ee=he.material;if(rt&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),re.copy(he.boundingSphere.center)):(se.boundingSphere===null&&se.computeBoundingSphere(),re.copy(se.boundingSphere.center)),re.applyMatrix4(he.matrixWorld).applyMatrix4(xe)),Array.isArray(Ee)){const Le=se.groups;for(let Oe=0,Te=Le.length;Oe<Te;Oe++){const ot=Le[Oe],ft=Ee[ot.materialIndex];ft&&ft.visible&&y.push(he,se,ft,nt,re.z,ot)}}else Ee.visible&&y.push(he,se,Ee,nt,re.z,null)}}const St=he.children;for(let se=0,Ee=St.length;se<Ee;se++)Qn(St[se],Ge,nt,rt)}function wi(he,Ge,nt,rt){const et=he.opaque,St=he.transmissive,se=he.transparent;v.setupLightsView(nt),ae===!0&&me.setGlobalState(S.clippingPlanes,nt),St.length>0&&si(et,St,Ge,nt),rt&&ie.viewport(D.copy(rt)),et.length>0&&Si(et,Ge,nt),St.length>0&&Si(St,Ge,nt),se.length>0&&Si(se,Ge,nt),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function si(he,Ge,nt,rt){if((nt.isScene===!0?nt.overrideMaterial:null)!==null)return;const St=H.isWebGL2;de===null&&(de=new Qh(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")?B0:Xu,minFilter:z0,samples:St?4:0})),S.getDrawingBufferSize(ye),St?de.setSize(ye.x,ye.y):de.setSize(kw(ye.x),kw(ye.y));const se=S.getRenderTarget();S.setRenderTarget(de),S.getClearColor(q),R=S.getClearAlpha(),R<1&&S.setClearColor(16777215,.5),S.clear();const Ee=S.toneMapping;S.toneMapping=Ku,Si(he,nt,rt),le.updateMultisampleRenderTarget(de),le.updateRenderTargetMipmap(de);let Le=!1;for(let Oe=0,Te=Ge.length;Oe<Te;Oe++){const ot=Ge[Oe],ft=ot.object,bt=ot.geometry,xt=ot.material,jt=ot.group;if(xt.side===cc&&ft.layers.test(rt.layers)){const Mt=xt.side;xt.side=Ws,xt.needsUpdate=!0,Ui(ft,nt,rt,bt,xt,jt),xt.side=Mt,xt.needsUpdate=!0,Le=!0}}Le===!0&&(le.updateMultisampleRenderTarget(de),le.updateRenderTargetMipmap(de)),S.setRenderTarget(se),S.setClearColor(q,R),S.toneMapping=Ee}function Si(he,Ge,nt){const rt=Ge.isScene===!0?Ge.overrideMaterial:null;for(let et=0,St=he.length;et<St;et++){const se=he[et],Ee=se.object,Le=se.geometry,Oe=rt===null?se.material:rt,Te=se.group;Ee.layers.test(nt.layers)&&Ui(Ee,Ge,nt,Le,Oe,Te)}}function Ui(he,Ge,nt,rt,et,St){he.onBeforeRender(S,Ge,nt,rt,et,St),he.modelViewMatrix.multiplyMatrices(nt.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),et.onBeforeRender(S,Ge,nt,rt,he,St),et.transparent===!0&&et.side===cc&&et.forceSinglePass===!1?(et.side=Ws,et.needsUpdate=!0,S.renderBufferDirect(nt,Ge,rt,et,he,St),et.side=ud,et.needsUpdate=!0,S.renderBufferDirect(nt,Ge,rt,et,he,St),et.side=cc):S.renderBufferDirect(nt,Ge,rt,et,he,St),he.onAfterRender(S,Ge,nt,rt,et,St)}function ts(he,Ge,nt){Ge.isScene!==!0&&(Ge=ve);const rt=J.get(he),et=v.state.lights,St=v.state.shadowsArray,se=et.state.version,Ee=ne.getParameters(he,et.state,St,Ge,nt),Le=ne.getProgramCacheKey(Ee);let Oe=rt.programs;rt.environment=he.isMeshStandardMaterial?Ge.environment:null,rt.fog=Ge.fog,rt.envMap=(he.isMeshStandardMaterial?Ne:ke).get(he.envMap||rt.environment),Oe===void 0&&(he.addEventListener("dispose",Ce),Oe=new Map,rt.programs=Oe);let Te=Oe.get(Le);if(Te!==void 0){if(rt.currentProgram===Te&&rt.lightsStateVersion===se)return br(he,Ee),Te}else Ee.uniforms=ne.getUniforms(he),he.onBuild(nt,Ee,S),he.onBeforeCompile(Ee,S),Te=ne.acquireProgram(Ee,Le),Oe.set(Le,Te),rt.uniforms=Ee.uniforms;const ot=rt.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(ot.clippingPlanes=me.uniform),br(he,Ee),rt.needsLights=zc(he),rt.lightsStateVersion=se,rt.needsLights&&(ot.ambientLightColor.value=et.state.ambient,ot.lightProbe.value=et.state.probe,ot.directionalLights.value=et.state.directional,ot.directionalLightShadows.value=et.state.directionalShadow,ot.spotLights.value=et.state.spot,ot.spotLightShadows.value=et.state.spotShadow,ot.rectAreaLights.value=et.state.rectArea,ot.ltc_1.value=et.state.rectAreaLTC1,ot.ltc_2.value=et.state.rectAreaLTC2,ot.pointLights.value=et.state.point,ot.pointLightShadows.value=et.state.pointShadow,ot.hemisphereLights.value=et.state.hemi,ot.directionalShadowMap.value=et.state.directionalShadowMap,ot.directionalShadowMatrix.value=et.state.directionalShadowMatrix,ot.spotShadowMap.value=et.state.spotShadowMap,ot.spotLightMatrix.value=et.state.spotLightMatrix,ot.spotLightMap.value=et.state.spotLightMap,ot.pointShadowMap.value=et.state.pointShadowMap,ot.pointShadowMatrix.value=et.state.pointShadowMatrix),rt.currentProgram=Te,rt.uniformsList=null,Te}function zr(he){if(he.uniformsList===null){const Ge=he.currentProgram.getUniforms();he.uniformsList=a1.seqWithValue(Ge.seq,he.uniforms)}return he.uniformsList}function br(he,Ge){const nt=J.get(he);nt.outputColorSpace=Ge.outputColorSpace,nt.batching=Ge.batching,nt.instancing=Ge.instancing,nt.instancingColor=Ge.instancingColor,nt.skinning=Ge.skinning,nt.morphTargets=Ge.morphTargets,nt.morphNormals=Ge.morphNormals,nt.morphColors=Ge.morphColors,nt.morphTargetsCount=Ge.morphTargetsCount,nt.numClippingPlanes=Ge.numClippingPlanes,nt.numIntersection=Ge.numClipIntersection,nt.vertexAlphas=Ge.vertexAlphas,nt.vertexTangents=Ge.vertexTangents,nt.toneMapping=Ge.toneMapping}function Dr(he,Ge,nt,rt,et){Ge.isScene!==!0&&(Ge=ve),le.resetTextureUnits();const St=Ge.fog,se=rt.isMeshStandardMaterial?Ge.environment:null,Ee=N===null?S.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Oc,Le=(rt.isMeshStandardMaterial?Ne:ke).get(rt.envMap||se),Oe=rt.vertexColors===!0&&!!nt.attributes.color&&nt.attributes.color.itemSize===4,Te=!!nt.attributes.tangent&&(!!rt.normalMap||rt.anisotropy>0),ot=!!nt.morphAttributes.position,ft=!!nt.morphAttributes.normal,bt=!!nt.morphAttributes.color;let xt=Ku;rt.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(xt=S.toneMapping);const jt=nt.morphAttributes.position||nt.morphAttributes.normal||nt.morphAttributes.color,Mt=jt!==void 0?jt.length:0,mt=J.get(rt),Kt=v.state.lights;if(ae===!0&&(fe===!0||he!==C)){const Or=he===C&&rt.id===I;me.setState(rt,he,Or)}let Ft=!1;rt.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Kt.state.version||mt.outputColorSpace!==Ee||et.isBatchedMesh&&mt.batching===!1||!et.isBatchedMesh&&mt.batching===!0||et.isInstancedMesh&&mt.instancing===!1||!et.isInstancedMesh&&mt.instancing===!0||et.isSkinnedMesh&&mt.skinning===!1||!et.isSkinnedMesh&&mt.skinning===!0||et.isInstancedMesh&&mt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&mt.instancingColor===!1&&et.instanceColor!==null||mt.envMap!==Le||rt.fog===!0&&mt.fog!==St||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==me.numPlanes||mt.numIntersection!==me.numIntersection)||mt.vertexAlphas!==Oe||mt.vertexTangents!==Te||mt.morphTargets!==ot||mt.morphNormals!==ft||mt.morphColors!==bt||mt.toneMapping!==xt||H.isWebGL2===!0&&mt.morphTargetsCount!==Mt)&&(Ft=!0):(Ft=!0,mt.__version=rt.version);let nn=mt.currentProgram;Ft===!0&&(nn=ts(rt,Ge,et));let dn=!1,xn=!1,Ut=!1;const Zt=nn.getUniforms(),Jt=mt.uniforms;if(ie.useProgram(nn.program)&&(dn=!0,xn=!0,Ut=!0),rt.id!==I&&(I=rt.id,xn=!0),dn||C!==he){Zt.setValue(ue,"projectionMatrix",he.projectionMatrix),Zt.setValue(ue,"viewMatrix",he.matrixWorldInverse);const Or=Zt.map.cameraPosition;Or!==void 0&&Or.setValue(ue,re.setFromMatrixPosition(he.matrixWorld)),H.logarithmicDepthBuffer&&Zt.setValue(ue,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(rt.isMeshPhongMaterial||rt.isMeshToonMaterial||rt.isMeshLambertMaterial||rt.isMeshBasicMaterial||rt.isMeshStandardMaterial||rt.isShaderMaterial)&&Zt.setValue(ue,"isOrthographic",he.isOrthographicCamera===!0),C!==he&&(C=he,xn=!0,Ut=!0)}if(et.isSkinnedMesh){Zt.setOptional(ue,et,"bindMatrix"),Zt.setOptional(ue,et,"bindMatrixInverse");const Or=et.skeleton;Or&&(H.floatVertexTextures?(Or.boneTexture===null&&Or.computeBoneTexture(),Zt.setValue(ue,"boneTexture",Or.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."))}et.isBatchedMesh&&(Zt.setOptional(ue,et,"batchingTexture"),Zt.setValue(ue,"batchingTexture",et._matricesTexture,le));const Mr=nt.morphAttributes;if((Mr.position!==void 0||Mr.normal!==void 0||Mr.color!==void 0&&H.isWebGL2===!0)&&st.update(et,nt,nn),(xn||mt.receiveShadow!==et.receiveShadow)&&(mt.receiveShadow=et.receiveShadow,Zt.setValue(ue,"receiveShadow",et.receiveShadow)),rt.isMeshGouraudMaterial&&rt.envMap!==null&&(Jt.envMap.value=Le,Jt.flipEnvMap.value=Le.isCubeTexture&&Le.isRenderTargetTexture===!1?-1:1),xn&&(Zt.setValue(ue,"toneMappingExposure",S.toneMappingExposure),mt.needsLights&&uo(Jt,Ut),St&&rt.fog===!0&&be.refreshFogUniforms(Jt,St),be.refreshMaterialUniforms(Jt,rt,V,K,de),a1.upload(ue,zr(mt),Jt,le)),rt.isShaderMaterial&&rt.uniformsNeedUpdate===!0&&(a1.upload(ue,zr(mt),Jt,le),rt.uniformsNeedUpdate=!1),rt.isSpriteMaterial&&Zt.setValue(ue,"center",et.center),Zt.setValue(ue,"modelViewMatrix",et.modelViewMatrix),Zt.setValue(ue,"normalMatrix",et.normalMatrix),Zt.setValue(ue,"modelMatrix",et.matrixWorld),rt.isShaderMaterial||rt.isRawShaderMaterial){const Or=rt.uniformsGroups;for(let Pn=0,ho=Or.length;Pn<ho;Pn++)if(H.isWebGL2){const On=Or[Pn];Ze.update(On,nn),Ze.bind(On,nn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return nn}function uo(he,Ge){he.ambientLightColor.needsUpdate=Ge,he.lightProbe.needsUpdate=Ge,he.directionalLights.needsUpdate=Ge,he.directionalLightShadows.needsUpdate=Ge,he.pointLights.needsUpdate=Ge,he.pointLightShadows.needsUpdate=Ge,he.spotLights.needsUpdate=Ge,he.spotLightShadows.needsUpdate=Ge,he.rectAreaLights.needsUpdate=Ge,he.hemisphereLights.needsUpdate=Ge}function zc(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(he,Ge,nt){J.get(he.texture).__webglTexture=Ge,J.get(he.depthTexture).__webglTexture=nt;const rt=J.get(he);rt.__hasExternalTextures=!0,rt.__hasExternalTextures&&(rt.__autoAllocateDepthBuffer=nt===void 0,rt.__autoAllocateDepthBuffer||$.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),rt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,Ge){const nt=J.get(he);nt.__webglFramebuffer=Ge,nt.__useDefaultFramebuffer=Ge===void 0},this.setRenderTarget=function(he,Ge=0,nt=0){N=he,T=Ge,k=nt;let rt=!0,et=null,St=!1,se=!1;if(he){const Le=J.get(he);Le.__useDefaultFramebuffer!==void 0?(ie.bindFramebuffer(ue.FRAMEBUFFER,null),rt=!1):Le.__webglFramebuffer===void 0?le.setupRenderTarget(he):Le.__hasExternalTextures&&le.rebindTextures(he,J.get(he.texture).__webglTexture,J.get(he.depthTexture).__webglTexture);const Oe=he.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(se=!0);const Te=J.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(Te[Ge])?et=Te[Ge][nt]:et=Te[Ge],St=!0):H.isWebGL2&&he.samples>0&&le.useMultisampledRTT(he)===!1?et=J.get(he).__webglMultisampledFramebuffer:Array.isArray(Te)?et=Te[nt]:et=Te,D.copy(he.viewport),F.copy(he.scissor),j=he.scissorTest}else D.copy(Z).multiplyScalar(V).floor(),F.copy(U).multiplyScalar(V).floor(),j=z;if(ie.bindFramebuffer(ue.FRAMEBUFFER,et)&&H.drawBuffers&&rt&&ie.drawBuffers(he,et),ie.viewport(D),ie.scissor(F),ie.setScissorTest(j),St){const Le=J.get(he.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Le.__webglTexture,nt)}else if(se){const Le=J.get(he.texture),Oe=Ge||0;ue.framebufferTextureLayer(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,Le.__webglTexture,nt||0,Oe)}I=-1},this.readRenderTargetPixels=function(he,Ge,nt,rt,et,St,se){if(!(he&&he.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=J.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&se!==void 0&&(Ee=Ee[se]),Ee){ie.bindFramebuffer(ue.FRAMEBUFFER,Ee);try{const Le=he.texture,Oe=Le.format,Te=Le.type;if(Oe!==Ka&&Ye.convert(Oe)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ot=Te===B0&&($.has("EXT_color_buffer_half_float")||H.isWebGL2&&$.has("EXT_color_buffer_float"));if(Te!==Xu&&Ye.convert(Te)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===mc&&(H.isWebGL2||$.has("OES_texture_float")||$.has("WEBGL_color_buffer_float")))&&!ot){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ge>=0&&Ge<=he.width-rt&&nt>=0&&nt<=he.height-et&&ue.readPixels(Ge,nt,rt,et,Ye.convert(Oe),Ye.convert(Te),St)}finally{const Le=N!==null?J.get(N).__webglFramebuffer:null;ie.bindFramebuffer(ue.FRAMEBUFFER,Le)}}},this.copyFramebufferToTexture=function(he,Ge,nt=0){const rt=Math.pow(2,-nt),et=Math.floor(Ge.image.width*rt),St=Math.floor(Ge.image.height*rt);le.setTexture2D(Ge,0),ue.copyTexSubImage2D(ue.TEXTURE_2D,nt,0,0,he.x,he.y,et,St),ie.unbindTexture()},this.copyTextureToTexture=function(he,Ge,nt,rt=0){const et=Ge.image.width,St=Ge.image.height,se=Ye.convert(nt.format),Ee=Ye.convert(nt.type);le.setTexture2D(nt,0),ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,nt.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,nt.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,nt.unpackAlignment),Ge.isDataTexture?ue.texSubImage2D(ue.TEXTURE_2D,rt,he.x,he.y,et,St,se,Ee,Ge.image.data):Ge.isCompressedTexture?ue.compressedTexSubImage2D(ue.TEXTURE_2D,rt,he.x,he.y,Ge.mipmaps[0].width,Ge.mipmaps[0].height,se,Ge.mipmaps[0].data):ue.texSubImage2D(ue.TEXTURE_2D,rt,he.x,he.y,se,Ee,Ge.image),rt===0&&nt.generateMipmaps&&ue.generateMipmap(ue.TEXTURE_2D),ie.unbindTexture()},this.copyTextureToTexture3D=function(he,Ge,nt,rt,et=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const St=he.max.x-he.min.x+1,se=he.max.y-he.min.y+1,Ee=he.max.z-he.min.z+1,Le=Ye.convert(rt.format),Oe=Ye.convert(rt.type);let Te;if(rt.isData3DTexture)le.setTexture3D(rt,0),Te=ue.TEXTURE_3D;else if(rt.isDataArrayTexture)le.setTexture2DArray(rt,0),Te=ue.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,rt.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,rt.unpackAlignment);const ot=ue.getParameter(ue.UNPACK_ROW_LENGTH),ft=ue.getParameter(ue.UNPACK_IMAGE_HEIGHT),bt=ue.getParameter(ue.UNPACK_SKIP_PIXELS),xt=ue.getParameter(ue.UNPACK_SKIP_ROWS),jt=ue.getParameter(ue.UNPACK_SKIP_IMAGES),Mt=nt.isCompressedTexture?nt.mipmaps[0]:nt.image;ue.pixelStorei(ue.UNPACK_ROW_LENGTH,Mt.width),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,Mt.height),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,he.min.x),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,he.min.y),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,he.min.z),nt.isDataTexture||nt.isData3DTexture?ue.texSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,se,Ee,Le,Oe,Mt.data):nt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ue.compressedTexSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,se,Ee,Le,Mt.data)):ue.texSubImage3D(Te,et,Ge.x,Ge.y,Ge.z,St,se,Ee,Le,Oe,Mt),ue.pixelStorei(ue.UNPACK_ROW_LENGTH,ot),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,ft),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,bt),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,xt),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,jt),et===0&&rt.generateMipmaps&&ue.generateMipmap(Te),ie.unbindTexture()},this.initTexture=function(he){he.isCubeTexture?le.setTextureCube(he,0):he.isData3DTexture?le.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?le.setTexture2DArray(he,0):le.setTexture2D(he,0),ie.unbindTexture()},this.resetState=function(){T=0,k=0,N=null,ie.reset(),$e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return al}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===aj?"display-p3":"srgb",n.unpackColorSpace=Kn.workingColorSpace===IE?"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===Yi?Th:MZ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Th?Yi:Oc}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 h5e extends kP{}h5e.prototype.isWebGL1Renderer=!0;class hj{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new $t(e),this.near=n,this.far=r}clone(){return new hj(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class f5e extends As{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 p5e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=AP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=wc()}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=wc()),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=wc()),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 vs=new De;class zu{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++)vs.fromBufferAttribute(this,n),vs.applyMatrix4(e),this.setXYZ(n,vs.x,vs.y,vs.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)vs.fromBufferAttribute(this,n),vs.applyNormalMatrix(e),this.setXYZ(n,vs.x,vs.y,vs.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)vs.fromBufferAttribute(this,n),vs.transformDirection(e),this.setXYZ(n,vs.x,vs.y,vs.z);return this}setX(e,n){return this.normalized&&(n=qn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=qn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=qn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=qn(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=nl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=nl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=nl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=nl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=qn(n,this.array),r=qn(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=qn(n,this.array),r=qn(r,this.array),i=qn(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=qn(n,this.array),r=qn(r,this.array),i=qn(i,this.array),s=qn(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 va(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 zu(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 m5e extends qs{constructor(e=null,n=1,r=1,i,s,a,o,l,u=Xi,d=Xi,f,g){super(null,a,o,l,u,d,i,s,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function g5e(t,e){return t.z-e.z}function x5e(t,e){return e.z-t.z}class b5e{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 Np="batchId",_u=new sr,Z$=new sr,v5e=new sr,Q$=new sr,mN=new UE,v_=new to,Yd=new ll,vx=new De,gN=new b5e,ls=new ko,y_=[];function y5e(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 _5e extends ko{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new gs,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 m5e(n,e,e,Ka,mc);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:u,itemSize:d,normalized:f}=l,g=new u.constructor(r*d),m=new l.constructor(g,d,f);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 va(o,1))}const a=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Np,new va(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Np))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Np}"`);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===Np)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 to);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,_u),this.getBoundingBoxAt(i,v_).applyMatrix4(_u),n.union(v_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ll);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,_u),this.getBoundingSphereAt(i,Yd).applyMatrix4(_u),n.union(Yd))}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 u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.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 f=this._visibility,g=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,v5e.toArray(x,y*16),m.needsUpdate=!0,a.push(i),o.push({start:d?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new to,sphereInitialized:!1,sphere:new ll});const v=this.geometry.getAttribute(Np);for(let b=0;b<i.vertexCount;b++)v.setX(i.vertexStart+b,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,u=o.vertexCount;for(const m in r.attributes){if(m===Np)continue;const x=n.getAttribute(m),y=r.getAttribute(m);y5e(x,y,l);const v=x.itemSize;for(let b=x.count,E=u;b<E;b++){const S=l+b;for(let A=0;A<v;A++)y.setComponent(S,A,0)}y.needsUpdate=!0}if(i){const m=o.indexStart;for(let x=0;x<a.count;x++)s.setX(m+x,l+a.getX(x));for(let x=a.count,y=o.indexCount;x<y;x++)s.setX(m+x,l);s.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.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,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let g=d;o&&(g=o.getX(g)),s.expandByPoint(vx.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,v_),v_.getCenter(s.center);const o=a.index,l=a.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,g=u.start+u.count;f<g;f++){let m=f;o&&(m=o.getX(m)),vx.fromBufferAttribute(l,m),d=Math.max(d,s.center.distanceToSquared(vx))}s.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(s),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,s=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?this:(n.toArray(s,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,s=this._geometryCount;return e>=s||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,s=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,l=this.geometry;ls.material=this.material,ls.geometry.index=l.index,ls.geometry.attributes=l.attributes,ls.geometry.boundingBox===null&&(ls.geometry.boundingBox=new to),ls.geometry.boundingSphere===null&&(ls.geometry.boundingSphere=new ll);for(let u=0;u<a;u++){if(!r[u]||!i[u])continue;const d=s[u];ls.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ls.matrixWorld).premultiply(o),this.getBoundingBoxAt(u,ls.geometry.boundingBox),this.getBoundingSphereAt(u,ls.geometry.boundingSphere),ls.raycast(e,y_);for(let f=0,g=y_.length;f<g;f++){const m=y_[f];m.object=this,m.batchId=u,n.push(m)}y_.length=0}ls.material=null,ls.geometry.index=null,ls.geometry.attributes={},ls.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,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(Q$.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),mN.setFromProjectionMatrix(Q$,e.isWebGPURenderer?H0:al));let m=0;if(this.sortObjects){Z$.copy(this.matrixWorld).invert(),vx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(Z$);for(let v=0,b=l.length;v<b;v++)if(l[v]){this.getMatrixAt(v,_u),this.getBoundingSphereAt(v,Yd).applyMatrix4(_u);let E=!1;if(g&&(E=!mN.intersectsSphere(Yd)),!E){const S=vx.distanceTo(Yd.center);gN.push(f[v],S)}}const x=gN.list,y=this.customSort;y===null?x.sort(s.transparent?x5e:g5e):y.call(this,x,r);for(let v=0,b=x.length;v<b;v++){const E=x[v];u[m]=E.start*o,d[m]=E.count,m++}gN.reset()}else for(let x=0,y=l.length;x<y;x++)if(l[x]){let v=!1;if(g&&(this.getMatrixAt(x,_u),this.getBoundingSphereAt(x,Yd).applyMatrix4(_u),v=!mN.intersectsSphere(Yd)),!v){const b=f[x];u[m]=b.start*o,d[m]=b.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,a){this.onBeforeRender(e,null,i,s,a)}}class Hb extends ng{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new $t(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const J$=new De,eV=new De,tV=new sr,xN=new lj,__=new ll;class w5e extends As{constructor(e=new gs,n=new Hb){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++)J$.fromBufferAttribute(n,i-1),eV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=J$.distanceTo(eV);e.setAttribute("lineDistance",new Fr(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(),__.copy(r.boundingSphere),__.applyMatrix4(i),__.radius+=s,e.ray.intersectsSphere(__)===!1)return;tV.copy(i).invert(),xN.copy(e.ray).applyMatrix4(tV);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,u=new De,d=new De,f=new De,g=new De,m=this.isLineSegments?2:1,x=r.index,v=r.attributes.position;if(x!==null){const b=Math.max(0,a.start),E=Math.min(x.count,a.start+a.count);for(let S=b,A=E-1;S<A;S+=m){const T=x.getX(S),k=x.getX(S+1);if(u.fromBufferAttribute(v,T),d.fromBufferAttribute(v,k),xN.distanceSqToSegment(u,d,g,f)>l)continue;g.applyMatrix4(this.matrixWorld);const I=e.ray.origin.distanceTo(g);I<e.near||I>e.far||n.push({distance:I,point:f.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const b=Math.max(0,a.start),E=Math.min(v.count,a.start+a.count);for(let S=b,A=E-1;S<A;S+=m){if(u.fromBufferAttribute(v,S),d.fromBufferAttribute(v,S+1),xN.distanceSqToSegment(u,d,g,f)>l)continue;g.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(g);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:S,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 nV=new De,rV=new De;class zE extends w5e{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)nV.fromBufferAttribute(n,i),rV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+nV.distanceTo(rV);e.setAttribute("lineDistance",new Fr(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class S5e extends gs{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new De,s=new De;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 u=0,d=l.length;u<d;++u){const f=l[u],g=f.start,m=f.count;for(let x=g,y=g+m;x<y;x+=3)for(let v=0;v<3;v++){const b=o.getX(x+v),E=o.getX(x+(v+1)%3);i.fromBufferAttribute(a,b),s.fromBufferAttribute(a,E),iV(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 u=0;u<3;u++){const d=3*o+u,f=3*o+(u+1)%3;i.fromBufferAttribute(a,d),s.fromBufferAttribute(a,f),iV(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Fr(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function iV(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 E5e extends ng{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new $t(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new $t(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=AZ,this.normalScale=new Yt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ij,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 M5e extends Hb{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 KZ extends As{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new $t(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}const bN=new sr,sV=new De,aV=new De;class A5e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Yt(512,512),this.map=null,this.mapPass=null,this.matrix=new sr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new UE,this._frameExtents=new Yt(1,1),this._viewportCount=1,this._viewports=[new Yn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;sV.setFromMatrixPosition(e.matrixWorld),n.position.copy(sV),aV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(aV),n.updateMatrixWorld(),bN.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bN),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(bN)}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 oV=new sr,yx=new De,vN=new De;class T5e extends A5e{constructor(){super(new ha(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Yt(4,2),this._viewportCount=6,this._viewports=[new Yn(2,1,1,1),new Yn(0,1,1,1),new Yn(3,1,1,1),new Yn(1,1,1,1),new Yn(3,0,1,1),new Yn(1,0,1,1)],this._cubeDirections=[new De(1,0,0),new De(-1,0,0),new De(0,0,1),new De(0,0,-1),new De(0,1,0),new De(0,-1,0)],this._cubeUps=[new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,1,0),new De(0,0,1),new De(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,s=e.distance||r.far;s!==r.far&&(r.far=s,r.updateProjectionMatrix()),yx.setFromMatrixPosition(e.matrixWorld),r.position.copy(yx),vN.copy(r.position),vN.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(vN),r.updateMatrixWorld(),i.makeTranslation(-yx.x,-yx.y,-yx.z),oV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(oV)}}class C5e extends KZ{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 T5e}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 N5e extends KZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class k5e extends gs{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 PP extends p5e{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 lV{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(Zi(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const cV=new De,w_=new De;class P5e{constructor(e=new De,n=new De){this.start=e,this.end=n}set(e,n){return this.start.copy(e),this.end.copy(n),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){cV.subVectors(e,this.start),w_.subVectors(this.end,this.start);const r=w_.dot(w_);let s=w_.dot(cV)/r;return n&&(s=Zi(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 R5e extends zE{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 gs;i.setAttribute("position",new Fr(n,3)),i.setAttribute("color",new Fr(r,3));const s=new Hb({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,n,r){const i=new $t,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(n),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:jE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jE);class cl{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"),cl.nextNameID=cl.nextNameID||0,this.$name.id=`lil-gui-name-${++cl.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 D5e extends cl{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 RP(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 O5e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:RP,toHexString:RP},V0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},j5e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=V0.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 V0.toHexString(i)}},L5e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=V0.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 V0.toHexString(i)}},I5e=[O5e,V0,j5e,L5e];function U5e(t){return I5e.find(e=>e.match(t))}class F5e extends cl{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=U5e(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=RP(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 yN extends cl{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 z5e extends cl{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 E=parseFloat(this.$input.value);isNaN(E)||(this._stepExplicit&&(E=this._snap(E)),this.setValue(this._clamp(E)))},r=E=>{const S=parseFloat(this.$input.value);isNaN(S)||(this._snapClampSetValue(S+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},s=E=>{this._inputFocused&&(E.preventDefault(),r(this._step*this._normalizeMouseWheel(E)))};let a=!1,o,l,u,d,f;const g=5,m=E=>{o=E.clientX,l=u=E.clientY,a=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=E=>{if(a){const S=E.clientX-o,A=E.clientY-l;Math.abs(A)>g?(E.preventDefault(),this.$input.blur(),a=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(S)>g&&y()}if(!a){const S=E.clientY-u;f-=S*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",y)},v=()=>{this._inputFocused=!0},b=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",b)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(b,E,S,A,T)=>(b-E)/(S-E)*(T-A)+A,n=b=>{const E=this.$slider.getBoundingClientRect();let S=e(b,E.left,E.right,this._min,this._max);this._snapClampSetValue(S)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=b=>{n(b.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let a=!1,o,l;const u=b=>{b.preventDefault(),this._setDraggingStyle(!0),n(b.touches[0].clientX),a=!1},d=b=>{b.touches.length>1||(this._hasScrollBar?(o=b.touches[0].clientX,l=b.touches[0].clientY,a=!0):u(b),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=b=>{if(a){const E=b.touches[0].clientX-o,S=b.touches[0].clientY-l;Math.abs(E)>Math.abs(S)?u(b):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else b.preventDefault(),n(b.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},m=this._callOnFinishChange.bind(this),x=400;let y;const v=b=>{if(Math.abs(b.deltaX)<Math.abs(b.deltaY)&&this._hasScrollBar)return;b.preventDefault();const S=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+S),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{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 B5e extends cl{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 H5e extends cl{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 $5e=`.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 V5e(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 uV=!1;class Rw{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",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(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"),!uV&&o&&(V5e($5e),uV=!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 B5e(this,e,n,r);const a=e[n];switch(typeof a){case"number":return new z5e(this,e,n,r,i,s);case"boolean":return new D5e(this,e,n);case"string":return new H5e(this,e,n);case"function":return new yN(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,a)}addColor(e,n,r=1){return new F5e(this,e,n,r)}addFolder(e){const n=new Rw({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof yN||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 yN)){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 _N(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(u){try{l(r.next(u))}catch(d){s(d)}}function o(u){try{l(r.throw(u))}catch(d){s(d)}}function l(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(a,o)}l((r=r.apply(t,[])).next())}))}class fj{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 fj(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 pj{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class dV extends pj{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class wu extends pj{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class hV{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class Dw{constructor(e){this.lines=[],this.preamble=new hV(-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((d=>d.trim())),l=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",u=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 dV(e,l,u,a);case"t0":return new wu(e,l,a,0);case"t1":return new wu(e,l,a,1);case"t2":return new wu(e,l,a,2);case"t3":return new wu(e,l,a,3);case"t4":return new wu(e,l,a,4);case"t5":return new wu(e,l,a,5);case"t6":return new wu(e,l,a,6);case"t7":return new wu(e,l,a,7);default:return new pj(e,l,u,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 dV){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 hV(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=fj.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}}}Dw.prototype.parseGcode=Dw.prototype.parseGCode;const fV={type:"change"},wN={type:"start"},pV={type:"end"},S_=new lj,mV=new Cu,G5e=Math.cos(70*CZ.DEG2RAD);class W5e extends hf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new De,this.cursor=new De,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:dp.ROTATE,MIDDLE:dp.DOLLY,RIGHT:dp.PAN},this.touches={ONE:hp.ROTATE,TWO:hp.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(H){H.addEventListener("keydown",je),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",je),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(fV),r.update(),s=i.NONE},this.update=(function(){const H=new De,ie=new Jh().setFromUnitVectors(e.up,new De(0,1,0)),G=ie.clone().invert(),J=new De,le=new Jh,ke=new De,Ne=2*Math.PI;return function(Se=null){const B=r.object.position;H.copy(B).sub(r.target),H.applyQuaternion(ie),o.setFromVector3(H),r.autoRotate&&s===i.NONE&&D((function(we){return we!==null?2*Math.PI/60*r.autoRotateSpeed*we: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+=Ne:L>Math.PI&&(L-=Ne),ne<-Math.PI?ne+=Ne:ne>Math.PI&&(ne-=Ne),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(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&k||r.object.isOrthographicCamera?o.radius=te(o.radius):o.radius=te(o.radius*u),H.setFromSpherical(o),H.applyQuaternion(G),B.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(l.theta*=1-r.dampingFactor,l.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(l.set(0,0,0),d.set(0,0,0));let be=!1;if(r.zoomToCursor&&k){let we=null;if(r.object.isPerspectiveCamera){const ge=H.length();we=te(ge*u);const me=ge-we;r.object.position.addScaledVector(A,me),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ge=new De(T.x,T.y,0);ge.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0;const me=new De(T.x,T.y,0);me.unproject(r.object),r.object.position.sub(me).add(ge),r.object.updateMatrixWorld(),we=H.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;we!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(we).add(r.object.position):(S_.origin.copy(r.object.position),S_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(S_.direction))<G5e?e.lookAt(r.target):(mV.setFromNormalAndCoplanarPoint(r.object.up,r.target),S_.intersectPlane(mV,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0);return u=1,k=!1,!!(be||J.distanceToSquared(r.object.position)>a||8*(1-le.dot(r.object.quaternion))>a||ke.distanceToSquared(r.target)>0)&&(r.dispatchEvent(fV),J.copy(r.object.position),le.copy(r.object.quaternion),ke.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ue),r.domElement.removeEventListener("pointerdown",xe),r.domElement.removeEventListener("pointercancel",re),r.domElement.removeEventListener("wheel",ve),r.domElement.removeEventListener("pointermove",ye),r.domElement.removeEventListener("pointerup",re),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",je),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 lV,l=new lV;let u=1;const d=new De,f=new Yt,g=new Yt,m=new Yt,x=new Yt,y=new Yt,v=new Yt,b=new Yt,E=new Yt,S=new Yt,A=new De,T=new Yt;let k=!1;const N=[],I={};function C(){return Math.pow(.95,r.zoomSpeed)}function D(H){l.theta-=H}function F(H){l.phi-=H}const j=(function(){const H=new De;return function(ie,G){H.setFromMatrixColumn(G,0),H.multiplyScalar(-ie),d.add(H)}})(),q=(function(){const H=new De;return function(ie,G){r.screenSpacePanning===!0?H.setFromMatrixColumn(G,1):(H.setFromMatrixColumn(G,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(ie),d.add(H)}})(),R=(function(){const H=new De;return function(ie,G){const J=r.domElement;if(r.object.isPerspectiveCamera){const le=r.object.position;H.copy(le).sub(r.target);let ke=H.length();ke*=Math.tan(r.object.fov/2*Math.PI/180),j(2*ie*ke/J.clientHeight,r.object.matrix),q(2*G*ke/J.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(j(ie*(r.object.right-r.object.left)/r.object.zoom/J.clientWidth,r.object.matrix),q(G*(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 W(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(H){if(!r.zoomToCursor)return;k=!0;const ie=r.domElement.getBoundingClientRect(),G=H.clientX-ie.left,J=H.clientY-ie.top,le=ie.width,ke=ie.height;T.x=G/le*2-1,T.y=-J/ke*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function te(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function Y(H){f.set(H.clientX,H.clientY)}function Z(H){x.set(H.clientX,H.clientY)}function U(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);f.set(H,ie)}}function z(){if(N.length===1)x.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);x.set(H,ie)}}function ee(){const H=N[0].pageX-N[1].pageX,ie=N[0].pageY-N[1].pageY,G=Math.sqrt(H*H+ie*ie);b.set(0,G)}function ae(H){if(N.length==1)g.set(H.pageX,H.pageY);else{const G=$(H),J=.5*(H.pageX+G.x),le=.5*(H.pageY+G.y);g.set(J,le)}m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ie=r.domElement;D(2*Math.PI*m.x/ie.clientHeight),F(2*Math.PI*m.y/ie.clientHeight),f.copy(g)}function fe(H){if(N.length===1)y.set(H.pageX,H.pageY);else{const ie=$(H),G=.5*(H.pageX+ie.x),J=.5*(H.pageY+ie.y);y.set(G,J)}v.subVectors(y,x).multiplyScalar(r.panSpeed),R(v.x,v.y),x.copy(y)}function de(H){const ie=$(H),G=H.pageX-ie.x,J=H.pageY-ie.y,le=Math.sqrt(G*G+J*J);E.set(0,le),S.set(0,Math.pow(E.y/b.y,r.zoomSpeed)),W(S.y),b.copy(E)}function xe(H){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture(H.pointerId),r.domElement.addEventListener("pointermove",ye),r.domElement.addEventListener("pointerup",re)),(function(ie){N.push(ie)})(H),H.pointerType==="touch"?(function(ie){switch(ut(ie),N.length){case 1:switch(r.touches.ONE){case hp.ROTATE:if(r.enableRotate===!1)return;U(),s=i.TOUCH_ROTATE;break;case hp.PAN:if(r.enablePan===!1)return;z(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case hp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ee(),r.enablePan&&z(),s=i.TOUCH_DOLLY_PAN;break;case hp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ee(),r.enableRotate&&U(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(wN)})(H):(function(ie){let G;switch(ie.button){case 0:G=r.mouseButtons.LEFT;break;case 1:G=r.mouseButtons.MIDDLE;break;case 2:G=r.mouseButtons.RIGHT;break;default:G=-1}switch(G){case dp.DOLLY:if(r.enableZoom===!1)return;(function(J){V(J),b.set(J.clientX,J.clientY)})(ie),s=i.DOLLY;break;case dp.ROTATE:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enablePan===!1)return;Z(ie),s=i.PAN}else{if(r.enableRotate===!1)return;Y(ie),s=i.ROTATE}break;case dp.PAN:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enableRotate===!1)return;Y(ie),s=i.ROTATE}else{if(r.enablePan===!1)return;Z(ie),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(wN)})(H))}function ye(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(ie){switch(ut(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(G){r.enableZoom&&de(G),r.enablePan&&fe(G)})(ie),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(G){r.enableZoom&&de(G),r.enableRotate&&ae(G)})(ie),r.update();break;default:s=i.NONE}})(H):(function(ie){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(G){g.set(G.clientX,G.clientY),m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const J=r.domElement;D(2*Math.PI*m.x/J.clientHeight),F(2*Math.PI*m.y/J.clientHeight),f.copy(g),r.update()})(ie);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(G){E.set(G.clientX,G.clientY),S.subVectors(E,b),S.y>0?W(C()):S.y<0&&K(C()),b.copy(E),r.update()})(ie);break;case i.PAN:if(r.enablePan===!1)return;(function(G){y.set(G.clientX,G.clientY),v.subVectors(y,x).multiplyScalar(r.panSpeed),R(v.x,v.y),x.copy(y),r.update()})(ie)}})(H))}function re(H){(function(ie){delete I[ie.pointerId];for(let G=0;G<N.length;G++)if(N[G].pointerId==ie.pointerId)return void N.splice(G,1)})(H),N.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",ye),r.domElement.removeEventListener("pointerup",re)),r.dispatchEvent(pV),s=i.NONE}function ve(H){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(H.preventDefault(),r.dispatchEvent(wN),(function(ie){V(ie),ie.deltaY<0?K(C()):ie.deltaY>0&&W(C()),r.update()})(H),r.dispatchEvent(pV))}function je(H){r.enabled!==!1&&r.enablePan!==!1&&(function(ie){let G=!1;switch(ie.code){case r.keys.UP:ie.ctrlKey||ie.metaKey||ie.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),G=!0;break;case r.keys.BOTTOM:ie.ctrlKey||ie.metaKey||ie.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),G=!0;break;case r.keys.LEFT:ie.ctrlKey||ie.metaKey||ie.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),G=!0;break;case r.keys.RIGHT:ie.ctrlKey||ie.metaKey||ie.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),G=!0}G&&(ie.preventDefault(),r.update())})(H)}function ue(H){r.enabled!==!1&&H.preventDefault()}function ut(H){let ie=I[H.pointerId];ie===void 0&&(ie=new Yt,I[H.pointerId]=ie),ie.set(H.pageX,H.pageY)}function $(H){const ie=H.pointerId===N[0].pointerId?N[1]:N[0];return I[ie.pointerId]}r.domElement.addEventListener("contextmenu",ue),r.domElement.addEventListener("pointerdown",xe),r.domElement.addEventListener("pointercancel",re),r.domElement.addEventListener("wheel",ve,{passive:!1}),this.update()}}vt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Yt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Hs.line={uniforms:cj.merge([vt.common,vt.fog,vt.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 XZ extends dd{constructor(e){super({type:"LineMaterial",uniforms:cj.clone(Hs.line.uniforms),vertexShader:Hs.line.vertexShader,fragmentShader:Hs.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 gV=new to,E_=new De;class YZ extends k5e{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 Fr([-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 Fr([-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 PP(n,6,1);return this.setAttribute("instanceStart",new zu(r,3,0)),this.setAttribute("instanceEnd",new zu(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 PP(n,6,1);return this.setAttribute("instanceColorStart",new zu(r,3,0)),this.setAttribute("instanceColorEnd",new zu(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 S5e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new to);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),gV.setFromBufferAttribute(n),this.boundingBox.union(gV))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ll),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++)E_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(E_)),E_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(E_));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 xV=new De,bV=new De,Vi=new Yn,Gi=new Yn,qo=new Yn,SN=new De,EN=new sr,Wi=new P5e,vV=new De,M_=new to,A_=new ll,Ko=new Yn;let Xo,ah;function yV(t,e,n){return Ko.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Ko.multiplyScalar(1/Ko.w),Ko.x=ah/n.width,Ko.y=ah/n.height,Ko.applyMatrix4(t.projectionMatrixInverse),Ko.multiplyScalar(1/Ko.w),Math.abs(Math.max(Ko.x,Ko.y))}class q5e extends ko{constructor(e=new YZ,n=new XZ({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)xV.fromBufferAttribute(n,a),bV.fromBufferAttribute(r,a),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+xV.distanceTo(bV);const s=new PP(i,2,1);return e.setAttribute("instanceDistanceStart",new zu(s,1,0)),e.setAttribute("instanceDistanceEnd",new zu(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;Xo=e.ray;const a=this.matrixWorld,o=this.geometry,l=this.material;let u,d;ah=l.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),A_.copy(o.boundingSphere).applyMatrix4(a),r?u=.5*ah:u=yV(i,Math.max(i.near,A_.distanceToPoint(Xo.origin)),l.resolution),A_.radius+=u,Xo.intersectsSphere(A_)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),M_.copy(o.boundingBox).applyMatrix4(a),r?d=.5*ah:d=yV(i,Math.max(i.near,M_.distanceToPoint(Xo.origin)),l.resolution),M_.expandByScalar(d),Xo.intersectsBox(M_)!==!1&&(r?(function(f,g){const m=f.matrixWorld,x=f.geometry,y=x.attributes.instanceStart,v=x.attributes.instanceEnd;for(let b=0,E=Math.min(x.instanceCount,y.count);b<E;b++){Wi.start.fromBufferAttribute(y,b),Wi.end.fromBufferAttribute(v,b),Wi.applyMatrix4(m);const S=new De,A=new De;Xo.distanceSqToSegment(Wi.start,Wi.end,A,S),A.distanceTo(S)<.5*ah&&g.push({point:A,pointOnLine:S,distance:Xo.origin.distanceTo(A),object:f,face:null,faceIndex:b,uv:null,uv1:null})}})(this,n):(function(f,g,m){const x=g.projectionMatrix,y=f.material.resolution,v=f.matrixWorld,b=f.geometry,E=b.attributes.instanceStart,S=b.attributes.instanceEnd,A=Math.min(b.instanceCount,E.count),T=-g.near;Xo.at(1,qo),qo.w=1,qo.applyMatrix4(g.matrixWorldInverse),qo.applyMatrix4(x),qo.multiplyScalar(1/qo.w),qo.x*=y.x/2,qo.y*=y.y/2,qo.z=0,SN.copy(qo),EN.multiplyMatrices(g.matrixWorldInverse,v);for(let k=0,N=A;k<N;k++){if(Vi.fromBufferAttribute(E,k),Gi.fromBufferAttribute(S,k),Vi.w=1,Gi.w=1,Vi.applyMatrix4(EN),Gi.applyMatrix4(EN),Vi.z>T&&Gi.z>T)continue;if(Vi.z>T){const j=Vi.z-Gi.z,q=(Vi.z-T)/j;Vi.lerp(Gi,q)}else if(Gi.z>T){const j=Gi.z-Vi.z,q=(Gi.z-T)/j;Gi.lerp(Vi,q)}Vi.applyMatrix4(x),Gi.applyMatrix4(x),Vi.multiplyScalar(1/Vi.w),Gi.multiplyScalar(1/Gi.w),Vi.x*=y.x/2,Vi.y*=y.y/2,Gi.x*=y.x/2,Gi.y*=y.y/2,Wi.start.copy(Vi),Wi.start.z=0,Wi.end.copy(Gi),Wi.end.z=0;const I=Wi.closestPointToPointParameter(SN,!0);Wi.at(I,vV);const C=CZ.lerp(Vi.z,Gi.z,I),D=C>=-1&&C<=1,F=SN.distanceTo(vV)<.5*ah;if(D&&F){Wi.start.fromBufferAttribute(E,k),Wi.end.fromBufferAttribute(S,k),Wi.start.applyMatrix4(v),Wi.end.applyMatrix4(v);const j=new De,q=new De;Xo.distanceSqToSegment(Wi.start,Wi.end,q,j),m.push({point:q,pointOnLine:j,distance:Xo.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class K5e extends zE{constructor(e,n,r,i,s=4473924,a=8947848){s=new $t(s),a=new $t(a);const o=Math.round(e/n);r=Math.round(r/i)*i/2;const l=[],u=[];let d=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){l.push(g,0,-1*r,g,0,r);const m=g===0?s:a;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}for(let g=-1*r;g<=r;g+=i){l.push(-1*e,0,g,e,0,g);const m=g===0?s:a;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}const f=new gs;f.setAttribute("position",new Fr(l,3)),f.setAttribute("color",new Fr(u,3)),super(f,new Hb({vertexColors:!0,toneMapped:!1}))}}function X5e(t,e,n,r){const i=(function(a,o,l){a*=.5,o*=.5,l*=.5;const u=new gs,d=[];return d.push(-a,-o,-l,-a,o,-l,-a,o,-l,a,o,-l,a,o,-l,a,-o,-l,a,-o,-l,-a,-o,-l,-a,-o,l,-a,o,l,-a,o,l,a,o,l,a,o,l,a,-o,l,a,-o,l,-a,-o,l,-a,-o,-l,-a,-o,l,-a,o,-l,-a,o,l,a,o,-l,a,o,l,a,-o,-l,a,-o,l),u.setAttribute("position",new Fr(d,3)),u})(t,e,n),s=new zE(i,new M5e({color:new $t(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var $x=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),s=i,a=0,o=n(new $x.Panel("FPS","#0ff","#002")),l=n(new $x.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new $x.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){a++;var d=(performance||Date).now();if(l.update(d-i,200),d>=s+1e3&&(o.update(1e3*a/(d-s),100),s=d,a=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};$x.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,u=3*a,d=2*a,f=3*a,g=15*a,m=74*a,x=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,u,d),v.fillRect(f,g,m,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f,g,m,x),{dom:y,update:function(b,E){r=Math.min(r,b),i=Math.max(i,b),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,o,g),v.fillStyle=e,v.fillText(s(b)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),v.drawImage(y,f+a,g,m-a,x,f,g,m-a,x),v.fillRect(f+m-a,g,a,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f+m-a,g,a,s((1-b/E)*x))}}};var Y5e=$x;class _V{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new Rw,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 Rw,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 Z5e extends gs{constructor(e=[new De],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const s=new De,a=new De,o=new Yt,l=[],u=[],d=[],f=[];function g(m){const[x,y,v]=(function(b){const E=e[b],S=new De,A=new De,T=new De,k=new De;S.copy(E).sub(e[b-1]||E).normalize().add((e[b+1]||E).clone().sub(E).normalize()).normalize();let N=Number.MAX_VALUE;const I=Math.abs(S.x),C=Math.abs(S.y),D=Math.abs(S.z);return I<=N&&(N=I,A.set(1,0,0)),C<=N&&(N=C,A.set(0,1,0)),D<=N&&A.set(0,0,1),k.crossVectors(S,A).normalize(),A.crossVectors(S,k),T.crossVectors(S,A),[E,A,T]})(m);for(let b=0;b<=i;b++){const E=b/i*Math.PI*2,S=Math.sin(E),A=-Math.cos(E);a.x=A*y.x+S*v.x,a.y=A*y.y+S*v.y,a.z=A*y.z+S*v.z,a.normalize(),u.push(a.x,a.y,a.z),s.x=x.x+n*a.x*.5,s.y=x.y+n*a.y*.5,s.z=x.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 x=0;x<=i;x++)o.x=m/e.length,o.y=x/i,d.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let x=1;x<=i;x++){const y=(i+1)*(m-1)+(x-1),v=(i+1)*m+(x-1),b=(i+1)*m+x,E=(i+1)*(m-1)+x;f.push(y,v,E),f.push(v,b,E)}})()})(),this.setIndex(f),this.setAttribute("position",new Fr(l,3)),this.setAttribute("normal",new Fr(u,3)),this.setAttribute("uv",new Fr(d,2))}}class Vx{static get initial(){const e=new Vx;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const MN={h:0,s:0,l:0};class rm{constructor(e){var n,r,i,s,a,o,l,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Vx.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=rm.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new $t(14737632),this._travelColor=new $t(10027008),this._toolColors={},this.devMode=!1,this._lastRenderTime=0,this._wireframe=!1,this.minLayerThreshold=(n=e.minLayerThreshold)!==null&&n!==void 0?n:this.minLayerThreshold,this.parser=new Dw(this.minLayerThreshold),this.scene=new f5e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new $t(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(s=e.renderExtrusion)!==null&&s!==void 0?s:this.renderExtrusion,this.renderTravel=(a=e.renderTravel)!==null&&a!==void 0?a:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(l=e.renderTubes)!==null&&l!==void 0?l:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new Y5e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new $t(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new $t(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new $t(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,x]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new $t(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+jE),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 kP({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 kP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ha(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,g=.8*f;this.scene.fog=new hj(this._backgroundColor,g,f),this.resize(),this.controls=new W5e(this.camera,this.renderer.domElement),this.initScene(),this.animate(),e.allowDragNDrop&&this._enableDropHandler(),this.initStats()}get extrusionColor(){return this._extrusionColor}set extrusionColor(e){if(Array.isArray(e)){this._extrusionColor=[];for(const[n,r]of e.entries())this._extrusionColor[n]=new $t(r)}else this._extrusionColor=new $t(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?rm.defaultExtrusionColor:this._extrusionColor instanceof $t?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:rm.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new $t(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new $t(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new $t(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new $t(e):void 0}get layers(){return[this.parser.preamble].concat(this.parser.layers.concat())}get maxLayerIndex(){var e;return((e=this.endLayer)!==null&&e!==void 0?e:this.layers.length)-1}get minLayerIndex(){var e;return this.singleLayerMode?this.maxLayerIndex:((e=this.startLayer)!==null&&e!==void 0?e:0)-1}animate(){var e;this.animationFrameId=requestAnimationFrame((()=>this.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)===null||e===void 0||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){const e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){const e=new R5e(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 N5e(13421772,.3*Math.PI),n=new C5e(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 kx;return n.name=e,n.quaternion.setFromEuler(new zb(-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=Vx.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 _N(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,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const m=g;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const m=g,x={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=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,y))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let s=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const a=.1+.7*n/this.layers.length;s.getHSL(MN),s=new $t().setHSL(MN.h,MN.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),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,a.getHex(),e.height),this.addTubeLine([...u,...l],o.getHex(),e.height)):(this.addLine(e.extrusion,a.getHex()),this.addLine([...u,...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 K5e(this.buildVolume.x,10,this.buildVolume.y,10));const e=X5e(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 Dw(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Vx.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,u=n.z,d=r.x,f=r.y,g=r.z;let m=r.r,x=r.i,y=r.j;if(m){const W=d-o,K=f-l,V=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));m=Math.max(m,V);const te=Math.pow(W,2)+Math.pow(K,2),Y=Math.pow(m,2)-te/4;let Z=Math.sqrt(Y/te);(s&&m<0||!s&&m>0)&&(Z=-Z),x=W/2+K*Z,y=K/2-W*Z}const v=o==d&&l==f,b=o+x,E=l+y,S=Math.sqrt(x*x+y*y),A=Math.atan2(-y,-x),T=Math.atan2(f-E,d-b);let k;v?k=2*Math.PI:(k=s?A-T:T-A,k<0&&(k+=2*Math.PI));let N=S*k/1.8;this.inches&&(N*=25),N<1&&(N=1);let I=k/N;I*=s?-1:1;const C=[];C.push({x:o,y:l,z:u});const D=(u-g)/N;let F=o,j=l,q=u,R=A;for(let W=0;W<N-1;W++)R+=I,F=b+S*Math.cos(R),j=E+S*Math.sin(R),q+=D,C.push({x:F,y:j,z:q});C.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<C.length-1;W++)a.push(C[W].x,C[W].y,C[W].z,C[W+1].x,C[W+1].y,C[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new gs;i.setAttribute("position",new Fr(e,3)),this.disposables.push(i);const s=new Hb({color:n});this.disposables.push(s);const a=new zE(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 De(o[0],o[1],o[2]),u=new De(o[3],o[4],o[5]),d=new De(o[6],o[7],o[8]);i.push(l),u.equals(d)||(i.push(u),s.push(i),i=[])}s.forEach((a=>{var o;const l=new Z5e(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 YZ;this.disposables.push(i);const s=new XZ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const a=new q5e(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=>_N(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 E5e({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((o,l)=>3*l.attributes.position.count+o),0),a=new _5e(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 _N(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 u=(l=s.value,new TextDecoder("utf-8").decode(l)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(a+f),a=u.slice(d)}while(!s.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new _V(this):typeof this.devMode=="object"&&(this.devGui=new _V(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())}}rm.defaultExtrusionColor=new $t("hotpink");const Q5e=function(t){return new rm(t)};function J5e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=M.useRef(null),i=M.useRef(null),[s,a]=M.useState(!0),[o,l]=M.useState(null),[u,d]=M.useState(!1),[f,g]=M.useState(0),[m,x]=M.useState(0);M.useEffect(()=>{if(!r.current)return;const b=r.current,E=Q5e({canvas:b,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});i.current=E,a(!0),l(null),d(!1),fetch(t).then(async A=>{if(!A.ok)throw A.status===404&&(await A.json().catch(()=>({}))).detail?.includes("sliced")?(d(!0),new Error("not_sliced")):new Error("Failed to load G-code");return A.text()}).then(A=>{E.processGCode(A);const T=E.layers?.length||0;x(T),g(T),E.render(),a(!1)}).catch(A=>{l(A.message),a(!1)});const S=()=>{if(b.parentElement){const A=b.parentElement.getBoundingClientRect();b.width=A.width,b.height=A.height,E.resize()}};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S),E.dispose()}},[t,e]);const y=b=>{if(!i.current)return;const E=Math.max(1,Math.min(b,m));g(E),i.current.render()},v=b=>{y(parseInt(b.target.value,10))};return c.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[c.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[c.jsx("canvas",{ref:r,className:"w-full h-full"}),s&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsxs("div",{className:"text-center",children:[c.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),c.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),u&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsxs("div",{className:"text-center max-w-sm px-4",children:[c.jsx(Xoe,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),c.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),c.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&&!u&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:c.jsx("div",{className:"text-center text-red-400",children:c.jsx("p",{className:"text-sm",children:o})})})]}),!s&&!o&&!u&&m>0&&c.jsx("div",{className:"mt-4 px-2",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Fh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),c.jsx("button",{onClick:()=>y(f-1),disabled:f<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:c.jsx(Ih,{className:"w-4 h-4"})}),c.jsx("input",{type:"range",min:1,max:m,value:f,onChange:v,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),c.jsx("button",{onClick:()=>y(f+1),disabled:f>=m,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:c.jsx(of,{className:"w-4 h-4"})}),c.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[f," / ",m]})]})})]})}function eFe({archiveId:t,title:e,onClose:n}){const[r,i]=M.useState(null),[s,a]=M.useState(null),[o,l]=M.useState(!0);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),M.useEffect(()=>{Pe.getArchiveCapabilities(t).then(d=>{a(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),l(!1)}).catch(()=>{a({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),l(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${Pe.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:u,children:[c.jsx(io,{className:"w-4 h-4"}),"Open in Slicer"]}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,children:c.jsx(Gt,{className:"w-5 h-5"})})]})]}),s&&c.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[c.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:[c.jsx(lm,{className:"w-4 h-4"}),"3D Model",!s.has_model&&c.jsx("span",{className:"text-xs",children:"(not available)"})]}),c.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:[c.jsx(Eoe,{className:"w-4 h-4"}),"G-code Preview",!s.has_gcode&&c.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),c.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?c.jsx("div",{className:"w-full h-full flex items-center justify-center",children:c.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&s?c.jsx(XDe,{url:Pe.getArchiveDownload(t),buildVolume:s.build_volume,className:"w-full h-full"}):r==="gcode"&&s?c.jsx(J5e,{gcodeUrl:Pe.getArchiveGcode(t),buildVolume:s.build_volume,className:"w-full h-full"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function tFe({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const[i,s]=M.useState(null);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);const{data:a,isLoading:o}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),l=_t({mutationFn:()=>{if(!i)throw new Error("No printer selected");return Pe.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),u=a?.filter(d=>d.is_active)||[];return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:c.jsx(kt,{className:"w-full max-w-md",children:c.jsxs(Dt,{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",c.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u.length===0?c.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):c.jsx("div",{className:"space-y-2 mb-6",children:u.map(d=>c.jsxs("button",{onClick:()=>s(d.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${i===d.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[c.jsx("div",{className:`p-2 rounded-lg ${i===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:c.jsx(Lo,{className:`w-5 h-5 ${i===d.id?"text-bambu-green":"text-bambu-gray"}`})}),c.jsxs("div",{className:"text-left",children:[c.jsx("p",{className:"text-white font-medium",children:d.name}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),l.isError&&c.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"}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{onClick:()=>l.mutate(),disabled:!i||l.isPending,className:"flex-1",children:l.isPending?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Lo,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function nFe({onClose:t,initialFiles:e}){const n=En(),{showToast:r}=ii(),i=M.useRef(null),[s,a]=M.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[o,l]=M.useState(!1),[u,d]=M.useState(),[f,g]=M.useState(null);M.useEffect(()=>{const N=I=>{I.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);const{data:m}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),x=_t({mutationFn:N=>Pe.uploadArchivesBulk(N,u),onSuccess:N=>{g(N),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),a(I=>I.map(C=>{const D=N.results.find(j=>j.filename===C.file.name),F=N.errors.find(j=>j.filename===C.file.name);return D?{...C,status:"success",archiveId:D.id}:F?{...C,status:"error",error:F.error}:C})),N.failed===0?r(`${N.uploaded} file${N.uploaded!==1?"s":""} uploaded`):N.uploaded===0?r(`Failed to upload ${N.failed} file${N.failed!==1?"s":""}`,"error"):r(`${N.uploaded} uploaded, ${N.failed} failed`,"warning")},onError:()=>{a(N=>N.map(I=>({...I,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=M.useCallback(N=>{N.preventDefault(),l(!0)},[]),v=M.useCallback(N=>{N.preventDefault(),l(!1)},[]),b=M.useCallback(N=>{N.preventDefault(),l(!1);const I=Array.from(N.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));I.length>0&&a(C=>[...C,...I.map(D=>({file:D,status:"pending"}))])},[]),E=M.useCallback(N=>{const I=Array.from(N.target.files||[]).filter(C=>C.name.endsWith(".3mf"));I.length>0&&a(C=>[...C,...I.map(D=>({file:D,status:"pending"}))]),i.current&&(i.current.value="")},[]),S=M.useCallback(N=>{a(I=>I.filter((C,D)=>D!==N))},[]),A=()=>{if(s.length===0)return;const N=s.filter(I=>I.status==="pending");N.length!==0&&(a(I=>I.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),x.mutate(N.map(I=>I.file)))},T=s.filter(N=>N.status==="pending").length,k=x.isPending;return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(kt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:c.jsxs(Dt,{className:"p-0 flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"p-4",children:c.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:b,children:[c.jsx(ga,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),c.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),c.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),c.jsx(Ie,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),c.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),c.jsxs("div",{className:"px-4 pb-4",children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),c.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:N=>d(N.target.value?Number(N.target.value):void 0),disabled:k,children:[c.jsx("option",{value:"",children:"No printer"}),m?.map(N=>c.jsx("option",{value:N.id,children:N.name},N.id))]})]}),s.length>0&&c.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:c.jsx("div",{className:"space-y-2",children:s.map((N,I)=>c.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[c.jsx(QG,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),c.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),c.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&c.jsx("button",{onClick:()=>S(I),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:c.jsx(Gt,{className:"w-4 h-4"})}),N.status==="uploading"&&c.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&c.jsx(fs,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs text-red-400",children:N.error}),c.jsx(jo,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${I}`))})}),f&&c.jsx("div",{className:"px-4 pb-4",children:c.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:c.jsxs("p",{className:"text-sm text-white",children:[c.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&c.jsxs(c.Fragment,{children:[", ",c.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),c.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[c.jsx(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&c.jsx(Ie,{onClick:A,disabled:T===0||k,className:"flex-1",children:k?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):c.jsxs(c.Fragment,{children:[c.jsx(ga,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const rFe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function iFe({archive:t,onClose:e,existingTags:n=[]}){M.useEffect(()=>{const U=z=>{z.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const r=En(),[i,s]=M.useState(t.print_name||""),[a,o]=M.useState(t.printer_id),[l,u]=M.useState(t.project_id??null),[d,f]=M.useState(t.notes||""),[g,m]=M.useState(t.tags||""),[x,y]=M.useState(t.failure_reason||""),[v,b]=M.useState(t.photos||[]),[E,S]=M.useState(!1),[A,T]=M.useState(!1),k=M.useRef(null),N=M.useRef(null),I=M.useRef(null),{data:C}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:D}=yt({queryKey:["projects"],queryFn:()=>Pe.getProjects()}),{data:F}=yt({queryKey:["archives"],queryFn:()=>Pe.getArchives(void 0,1e3,0),enabled:n.length===0}),j=n.length>0?n:[...new Set(F?.flatMap(U=>U.tags?.split(",").map(z=>z.trim())||[]).filter(Boolean)||[])].sort(),q=g.split(",").map(U=>U.trim()).filter(Boolean),R=j.filter(U=>!q.includes(U)),W=U=>{if(!q.includes(U)){const z=[...q,U].join(", ");m(z)}I.current!==null&&clearTimeout(I.current),k.current?.focus()},K=U=>{const z=q.filter(ee=>ee!==U).join(", ");m(z)},V=_t({mutationFn:U=>Pe.updateArchive(t.id,U),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),te=async U=>{const z=U.target.files?.[0];if(z){S(!0);try{const ee=await Pe.uploadArchivePhoto(t.id,z);b(ee.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ee){console.error("Failed to upload photo:",ee)}finally{S(!1),N.current&&(N.current.value="")}}},Y=async U=>{try{const z=await Pe.deleteArchivePhoto(t.id,U);b(z.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(z){console.error("Failed to delete photo:",z)}},Z=U=>{U.preventDefault(),V.mutate({print_name:i||void 0,printer_id:a,project_id:l,notes:d||void 0,tags:g||void 0,failure_reason:t.status==="failed"&&x||void 0})};return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:c.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:U=>U.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:Z,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),c.jsx("input",{type:"text",value:i,onChange:U=>s(U.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),c.jsxs("select",{value:a??"",onChange:U=>o(U.target.value?Number(U.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:[c.jsx("option",{value:"",children:"No printer"}),C?.map(U=>c.jsx("option",{value:U.id,children:U.name},U.id))]})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[c.jsx(bh,{className:"w-4 h-4 inline mr-1"}),"Project"]}),c.jsxs("select",{value:l??"",onChange:U=>u(U.target.value?Number(U.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:[c.jsx("option",{value:"",children:"No project"}),D?.map(U=>c.jsx("option",{value:U.id,children:U.name},U.id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),c.jsx("textarea",{value:d,onChange:U=>f(U.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..."})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),q.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:q.map(U=>c.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[c.jsx(x0,{className:"w-3 h-3"}),U,c.jsx("button",{type:"button",onClick:()=>K(U),className:"ml-0.5 text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-3 h-3"})})]},U))}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:k,type:"text",value:g,onChange:U=>m(U.target.value),onFocus:()=>{I.current!==null&&clearTimeout(I.current),T(!0)},onBlur:()=>{I.current=window.setTimeout(()=>T(!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:q.length>0?"Add more tags...":"Add tags..."}),A&&R.length>0&&c.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:[c.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),c.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:R.map(U=>c.jsx("button",{type:"button",onClick:()=>W(U),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:U},U))})]})]})]}),t.status==="failed"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),c.jsxs("select",{value:x,onChange:U=>y(U.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:[c.jsx("option",{value:"",children:"Select reason..."}),rFe.map(U=>c.jsx("option",{value:U,children:U},U))]})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[c.jsx(u0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),c.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[v.map(U=>c.jsxs("div",{className:"relative group",children:[c.jsx("img",{src:Pe.getArchivePhotoUrl(t.id,U),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),c.jsx("button",{type:"button",onClick:()=>Y(U),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:c.jsx(kn,{className:"w-3 h-3 text-white"})})]},U)),c.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:[c.jsx("input",{ref:N,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:te,className:"hidden",disabled:E}),E?c.jsx(At,{className:"w-6 h-6 text-bambu-gray animate-spin"}):c.jsx(pr,{className:"w-6 h-6 text-bambu-gray"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:V.isPending,className:"flex-1",children:[c.jsx(Co,{className:"w-4 h-4"}),V.isPending?"Saving...":"Save"]})]})]})]})})}function sFe({x:t,y:e,items:n,onClose:r}){const i=M.useRef(null),[s,a]=M.useState(null),o=M.useRef(null);M.useEffect(()=>{const d=m=>{i.current&&!i.current.contains(m.target)&&r()},f=m=>{m.key==="Escape"&&r()},g=()=>{r()};return document.addEventListener("mousedown",d),document.addEventListener("keydown",f),document.addEventListener("scroll",g,!0),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",f),document.removeEventListener("scroll",g,!0),o.current&&clearTimeout(o.current)}},[r]),M.useEffect(()=>{if(i.current){const d=i.current.getBoundingClientRect(),f=window.innerWidth,g=window.innerHeight;let m=t,x=e;t+d.width>f&&(m=f-d.width-8),e+d.height>g&&(x=g-d.height-8),i.current.style.left=`${m}px`,i.current.style.top=`${x}px`}},[t,e]);const l=d=>{o.current&&(clearTimeout(o.current),o.current=null),a(d)},u=()=>{o.current=window.setTimeout(()=>{a(null)},150)};return c.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:t,top:e},children:n.map((d,f)=>{if(d.divider)return c.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},f);const g=d.submenu&&d.submenu.length>0;return c.jsxs("div",{className:"relative",onMouseEnter:()=>g&&l(f),onMouseLeave:()=>g&&u(),children:[c.jsxs("button",{onClick:()=>{g?a(s===f?null:f):d.disabled||(d.onClick(),r())},disabled:d.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${d.disabled?"text-bambu-gray cursor-not-allowed":d.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${g&&s===f?"bg-bambu-dark-tertiary":""}`,children:[d.icon&&c.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:d.icon}),c.jsx("span",{className:"flex-1",children:d.label}),g&&c.jsx(of,{className:"w-4 h-4 text-bambu-gray"})]}),g&&s===f&&c.jsx("div",{className:"absolute left-full top-0 ml-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60]",onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null)},onMouseLeave:()=>u(),children:d.submenu.map((m,x)=>c.jsxs("button",{onClick:()=>{m.disabled||(m.onClick(),r())},disabled:m.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${m.disabled?"text-bambu-gray cursor-not-allowed":m.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[m.icon&&c.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:m.icon}),m.label]},x))})]},f)})})}function aFe({selectedIds:t,existingTags:e,onClose:n}){const r=En(),{showToast:i}=ii(),[s,a]=M.useState(""),[o,l]=M.useState(new Set),[u,d]=M.useState("add");M.useEffect(()=>{const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=_t({mutationFn:async()=>{const y=Array.from(o);let v=0;for(const b of t)try{const E=await Pe.getArchive(b),S=E.tags?E.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...S,...y])]:A=S.filter(T=>!o.has(T)),await Pe.updateArchive(b,{tags:A.join(", ")}),v++}catch(E){throw console.error(`Failed to update archive ${b}:`,E),new Error(`Failed on archive ${b}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:v,mode:u,tags:y}},onSuccess:({count:y,mode:v,tags:b})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${v==="add"?"Added":"Removed"} ${b.length} tag${b.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 b=new Set(v);return b.has(y)?b.delete(y):b.add(y),b})},m=()=>{s.trim()&&!o.has(s.trim())&&(l(y=>new Set([...y,s.trim()])),a(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(kt,{className:"w-full max-w-md",children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(x0,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"p-4 space-y-4",children:[c.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),c.jsx(Ie,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&c.jsxs("div",{className:"flex gap-2",children:[c.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:x}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:c.jsx(pr,{className:"w-4 h-4"})})]}),e.length>0&&c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>c.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&&c.jsxs("div",{children:[c.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),c.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(y=>c.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,c.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:c.jsx(Gt,{className:"w-3 h-3"})})]},y))})]})]}),c.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[c.jsx(Ie,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):c.jsxs(c.Fragment,{children:[c.jsx(x0,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function oFe(t,e){return new Date(t,e+1,0).getDate()}function lFe(t,e){return new Date(t,e,1).getDay()}const cFe=["January","February","March","April","May","June","July","August","September","October","November","December"],uFe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function dFe({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=M.useState(n.getMonth()),[s,a]=M.useState(n.getFullYear()),[o,l]=M.useState(null),u=M.useMemo(()=>{const b=new Map;return t.forEach(E=>{const S=new Date(E.completed_at||E.created_at),A=`${S.getFullYear()}-${String(S.getMonth()+1).padStart(2,"0")}-${String(S.getDate()).padStart(2,"0")}`,T=b.get(A)||[];T.push(E),b.set(A,T)}),b},[t]),d=oFe(s,r),f=lFe(s,r),g=()=>{r===0?(i(11),a(s-1)):i(r-1)},m=()=>{r===11?(i(0),a(s+1)):i(r+1)},x=()=>{i(n.getMonth()),a(n.getFullYear())},y=[];for(let b=0;b<f;b++)y.push(null);for(let b=1;b<=d;b++)y.push(b);const v=o?u.get(o)||[]:[];return c.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Ih,{className:"w-5 h-5 text-bambu-gray"})}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white",children:[cFe[r]," ",s]}),c.jsx("button",{onClick:x,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),c.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(of,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:uFe.map(b=>c.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:b},b))}),c.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((b,E)=>{if(b===null)return c.jsx("div",{className:"aspect-square"},`empty-${E}`);const S=`${s}-${String(r+1).padStart(2,"0")}-${String(b).padStart(2,"0")}`,A=u.get(S)||[],T=A.length>0,k=b===n.getDate()&&r===n.getMonth()&&s===n.getFullYear(),N=S===o,I=A.filter(D=>D.status==="completed").length,C=A.filter(D=>D.status==="failed").length;return c.jsxs("button",{onClick:()=>l(N?null:S),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${N?"bg-bambu-green text-white":k?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[c.jsx("span",{className:`text-sm font-medium ${k&&!N?"text-bambu-green":""}`,children:b}),T&&c.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[c.jsx("div",{className:`w-2 h-2 rounded-full ${C>0&&I===0?"bg-red-400":C>0?"bg-yellow-400":"bg-green-400"}`}),c.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},b)})}),c.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s}).length}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s&&b.status==="completed"}).length}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s&&b.status==="failed"}).length}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),c.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?c.jsxs(c.Fragment,{children:[c.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?c.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(b=>c.jsxs("button",{onClick:()=>e?.(b),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[b.thumbnail_path?c.jsx("img",{src:Pe.getArchiveThumbnail(b.id),alt:"",className:"w-12 h-12 rounded object-cover"}):c.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:c.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-sm text-white truncate",children:b.print_name||b.filename}),c.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[c.jsx("span",{className:b.status==="failed"?"text-red-400":"text-green-400",children:b.status==="failed"?"Failed":"Completed"}),b.filament_color&&c.jsx("div",{className:"flex gap-0.5",children:b.filament_color.split(",").map((E,S)=>c.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},S))})]})]})]},b.id))}):c.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):c.jsx("div",{className:"text-center py-8",children:c.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function hFe({archiveId:t,archiveName:e,onClose:n}){const r=Pe.getArchiveQRCodeUrl(t,300);M.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 c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"p-6 flex flex-col items-center",children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),c.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:c.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),c.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),c.jsxs(Ie,{onClick:i,className:"w-full",children:[c.jsx(_a,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function fFe({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,a]=M.useState(0),[o,l]=M.useState(!1);if(M.useEffect(()=>{const m=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&a(y=>Math.max(0,y-1)),x.key==="ArrowRight"&&a(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),M.useEffect(()=>{s>=n.length&&a(Math.max(0,n.length-1))},[n.length,s]),n.length===0)return r(),null;const u=n[s],d=Pe.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${s+1}.jpg`,m.click()},g=()=>{i&&l(!0)};return c.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[c.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:f,children:[c.jsx(_a,{className:"w-4 h-4"}),"Download"]}),i&&c.jsx(Ie,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})}),c.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-6 h-6"})})]})]}),c.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&c.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:c.jsx(Ih,{className:"w-8 h-8 text-white"})}),c.jsx("img",{src:d,alt:`Photo ${s+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),s<n.length-1&&c.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:c.jsx(of,{className:"w-8 h-8 text-white"})})]}),n.length>1&&c.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,x)=>c.jsx("button",{onClick:()=>a(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===s?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:c.jsx("img",{src:Pe.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&c.jsx(Yr,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),l(!1)},onCancel:()=>l(!1)})]})}function Ki(t){this.content=t}Ki.prototype={constructor:Ki,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 Ki(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 Ki(n)},addToStart:function(t,e){return new Ki([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Ki(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 Ki(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=Ki.from(t),t.size?new Ki(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ki.from(t),t.size?new Ki(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ki.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}};Ki.from=function(t){if(t instanceof Ki)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ki(e)};function ZZ(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=ZZ(i.content,s.content,n+1);if(a!=null)return a}n+=i.nodeSize}}function QZ(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 u=0,d=Math.min(a.text.length,o.text.length);for(;u<d&&a.text[a.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(a.content.size||o.content.size){let u=QZ(a.content,o.content,n-1,r-1);if(u)return u}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],u=o+l.nodeSize;if(u>e&&r(l,i+o,s||null,a)!==!1&&l.content.size){let d=o+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,i+d)}o=u}}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 u=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&&u||o.isTextblock)&&r&&(a?a=!1:s+=r),s+=u},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 ZZ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return QZ(this,e,n,r)}findIndex(e){if(e==0)return T_(0,e);if(e==this.size)return T_(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?T_(n+1,s):T_(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 AN={index:0,offset:0};function T_(t,e){return AN.index=t,AN.offset=e,AN}function Ow(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(!Ow(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Ow(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let tr=class DP{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&&Ow(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 DP.none;if(e instanceof DP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};tr.none=[];class jw extends Error{}class Ct{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=eQ(this.content,e+this.openStart,n);return r&&new Ct(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ct(JZ(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 Ct.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 Ct(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 Ct(e,r,i)}}Ct.empty=new Ct(pt.empty,0,0);function JZ(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(JZ(s.content,e-i-1,n-i-1)))}function eQ(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=eQ(a.content,e-s-1,n,a);return o&&t.replaceChild(i,a.copy(o))}function pFe(t,e,n){if(n.openStart>t.depth)throw new jw("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new jw("Inconsistent open depths");return tQ(t,e,n,0)}function tQ(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=tQ(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 Nh(a,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:a,end:o}=mFe(n,t);return Nh(s,rQ(t,a,o,e,r))}else return Nh(s,Lw(t,e,r))}function nQ(t,e){if(!e.type.compatibleContent(t.type))throw new jw("Cannot join "+e.type.name+" onto "+t.type.name)}function OP(t,e,n){let r=t.node(n);return nQ(r,e.node(n)),r}function Ch(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 Gx(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&&(Ch(t.nodeAfter,r),s++));for(let o=s;o<a;o++)Ch(i.child(o),r);e&&e.depth==n&&e.textOffset&&Ch(e.nodeBefore,r)}function Nh(t,e){return t.type.checkContent(e),t.copy(e)}function rQ(t,e,n,r,i){let s=t.depth>i&&OP(t,e,i+1),a=r.depth>i&&OP(n,r,i+1),o=[];return Gx(null,t,i,o),s&&a&&e.index(i)==n.index(i)?(nQ(s,a),Ch(Nh(s,rQ(t,e,n,r,i+1)),o)):(s&&Ch(Nh(s,Lw(t,e,i+1)),o),Gx(e,n,i,o),a&&Ch(Nh(a,Lw(n,r,i+1)),o)),Gx(r,null,i,o),new pt(o)}function Lw(t,e,n){let r=[];if(Gx(null,t,n,r),t.depth>n){let i=OP(t,e,n+1);Ch(Nh(i,Lw(t,e,n+1)),r)}return Gx(e,null,n,r),new pt(r)}function mFe(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(pt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class G0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return tr.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 Iw(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),u=s-l;if(r.push(a,o,i+l),!u||(a=a.child(o),a.isText))break;s=u-1,i+=l+1}return new G0(n,r,s)}static resolveCached(e,n){let r=wV.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 wV.set(e,r=new gFe);let i=r.elts[r.i]=G0.resolve(e,n);return r.i=(r.i+1)%xFe,i}}class gFe{constructor(){this.elts=[],this.i=0}}const xFe=12,wV=new WeakMap;class Iw{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 bFe=Object.create(null);let Yu=class jP{constructor(e,n,r,i=tr.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&&Ow(this.attrs,n||e.defaultAttrs||bFe)&&tr.sameSet(this.marks,r||tr.none)}copy(e=null){return e==this.content?this:new jP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new jP(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 Ct.empty;let i=this.resolve(e),s=this.resolve(n),a=r?0:i.sharedDepth(n),o=i.start(a),u=i.node(a).content.cut(i.pos-o,s.pos-o);return new Ct(u,i.depth-a,s.depth-a)}replace(e,n,r){return pFe(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return G0.resolveCached(this,e)}resolveNoCache(e){return G0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),iQ(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=tr.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(!tr.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}};Yu.prototype.text=void 0;class Uw extends Yu{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):iQ(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 Uw(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Uw(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 iQ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class ef{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new vFe(e,n);if(r.next==null)return ef.empty;let i=sQ(r);r.next&&r.err("Unexpected trailing text");let s=AFe(MFe(i));return TFe(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(u=>u.createAndFill()));for(let u=0;u<a.next.length;u++){let{type:d,next:f}=a.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=s(f,o.concat(d));if(g)return g}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let a=[];for(let o=i;o.type;o=o.via)a.push(o.type);return a.reverse()}for(let a=0;a<s.next.length;a++){let{type:o,next:l}=s.next[a];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let a=0;a<r.next.length;a++)s+=(a?", ":"")+r.next[a].type.name+"->"+e.indexOf(r.next[a].next);return s}).join(`
- `)}}ef.empty=new ef(!0);class vFe{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 sQ(t){let e=[];do e.push(yFe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function yFe(t){let e=[];do e.push(_Fe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _Fe(t){let e=EFe(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=wFe(t,e);else break;return e}function SV(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function wFe(t,e){let n=SV(t),r=n;return t.eat(",")&&(t.next!="}"?r=SV(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function SFe(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 EFe(t){if(t.eat("(")){let e=sQ(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=SFe(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 MFe(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(a,o,l){let u={term:l,to:o};return e[a].push(u),u}function i(a,o){a.forEach(l=>l.to=o)}function s(a,o){if(a.type=="choice")return a.exprs.reduce((l,u)=>l.concat(s(u,o)),[]);if(a.type=="seq")for(let l=0;;l++){let u=s(a.exprs[l],o);if(l==a.exprs.length-1)return u;i(u,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 u=0;u<a.min;u++){let d=n();i(s(a.expr,l),d),l=d}if(a.max==-1)i(s(a.expr,l),l);else for(let u=a.min;u<a.max;u++){let d=n();r(l,d),i(s(a.expr,l),d),l=d}return[r(l)]}else{if(a.type=="name")return[r(o,void 0,a.value)];throw new Error("Unknown expr type")}}}}function aQ(t,e){return e-t}function EV(t,e){let n=[];return r(e),n.sort(aQ);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 AFe(t){let e=Object.create(null);return n(EV(t,0));function n(r){let i=[];r.forEach(a=>{t[a].forEach(({term:o,to:l})=>{if(!o)return;let u;for(let d=0;d<i.length;d++)i[d][0]==o&&(u=i[d][1]);EV(t,l).forEach(d=>{u||i.push([o,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new ef(r.indexOf(t.length-1)>-1);for(let a=0;a<i.length;a++){let o=i[a][1].sort(aQ);s.next.push({type:i[a][0],next:e[o.join(",")]||n(o)})}return s}}function TFe(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:u}=i.next[o];a.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function oQ(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 lQ(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 cQ(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 uQ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new NFe(t,r,e[r]);return n}let MV=class dQ{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=uQ(e,r.attrs),this.defaultAttrs=oQ(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==ef.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:lQ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Yu(this,this.computeAttrs(e),pt.from(n),tr.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new Yu(this,this.computeAttrs(e),n,tr.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 Yu(this,e,n.append(s),tr.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){cQ(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:tr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,a)=>r[s]=new dQ(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 CFe(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 NFe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?CFe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class BE{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=uQ(e,i.attrs),this.excluded=null;let s=oQ(this.attrs);this.instance=s?new tr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new tr(this,lQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,a)=>r[s]=new BE(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){cQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class hQ{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=Ki.from(e.nodes),n.marks=Ki.from(e.marks||{}),this.nodes=MV.compile(this.spec.nodes,this),this.marks=BE.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]=ef.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?AV(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==""?[]:AV(this,a.split(" "))}this.nodeFromJSON=i=>Yu.fromJSON(this,i),this.markFromJSON=i=>tr.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 MV){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 Uw(r,r.defaultAttrs,e,tr.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 AV(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 kFe(t){return t.tag!=null}function PFe(t){return t.style!=null}let Wx=class LP{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(kFe(i))this.tags.push(i);else if(PFe(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 CV(this,n,!1);return r.addAll(e,tr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new CV(this,n,!0);return r.addAll(e,tr.none,n.from,n.to),Ct.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(OFe(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=NV(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=NV(a)),a.node||a.ignore||a.mark||(a.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new LP(e,LP.schemaRules(e)))}};const fQ={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},RFe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},pQ={ol:!0,ul:!0},W0=1,IP=2,qx=4;function TV(t,e,n){return e!=null?(e?W0:0)|(e==="full"?IP:0):t&&t.whitespace=="pre"?W0|IP:n&~qx}class C_{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=tr.none,this.match=s||(a&qx?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&W0)){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&&!fQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class CV{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=TV(null,n.preserveWhitespace,0)|(r?qx:0);i?s=new C_(i.type,i.attrs,tr.none,!0,n.topMatch||i.type.contentMatch,a):r?s=new C_(null,null,tr.none,!0,null,a):s=new C_(e.schema.topNodeType,null,tr.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&IP?"full":this.localPreserveWS||(i.options&W0)>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;pQ.hasOwnProperty(a)&&this.parser.normalizeLists&&DFe(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:RFe.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 u,d=this.needsBlock;if(fQ.hasOwnProperty(a))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(s),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,l,u,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(u=>!l.clearMark(u)):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],u=l.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,s=l,!u.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=tr.none;for(let o of i.concat(e.marks))(s.type?s.type.allowsMarkType(o.type):kV(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=TV(e,s,a.options);a.options&qx&&a.content.length==0&&(o|=qx);let l=tr.none;return r=r.filter(u=>(a.type?a.type.allowsMarkType(u.type):kV(u.type,e))?(l=u.addToSet(l),!1):!0),this.nodes.push(new C_(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|=W0)}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 u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;l>=s;l--)if(a(o-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=u&&!d.isInGroup(u))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 DFe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&pQ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function OFe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function NV(t){let e={};for(let n in t)e[n]=t[n];return e}function kV(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:u,next:d}=o.edge(l);if(u==e||s.indexOf(d)<0&&a(d))return!0}};if(a(i.contentMatch))return!0}}class ff{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=TN(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 u=a.marks[l];if(!this.marks[u.type.name]){l++;continue}if(!u.eq(s[o][0])||u.type.spec.spanning===!1)break;o++,l++}for(;o<s.length;)i=s.pop()[1];for(;l<a.marks.length;){let u=a.marks[l++],d=this.serializeMark(u,a.isInline,n);d&&(s.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(a,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=o1(TN(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&&o1(TN(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return o1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ff(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=PV(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return PV(e.marks)}}function PV(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function TN(t){return t.document||window.document}const RV=new WeakMap;function jFe(t){let e=RV.get(t);return e===void 0&&RV.set(t,e=LFe(t)),e}function LFe(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 o1(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=jFe(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),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?l.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&l.style?l.style.cssText=u[f]:l.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:x}=o1(t,g,n,r);if(l.appendChild(m),x){if(o)throw new RangeError("Multiple content holes");o=x}}}return{dom:l,contentDOM:o}}const mQ=65535,gQ=Math.pow(2,16);function IFe(t,e){return t+e*gQ}function DV(t){return t&mQ}function UFe(t){return(t-(t&mQ))/gQ}const xQ=1,bQ=2,l1=4,vQ=8;class UP{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&vQ)>0}get deletedBefore(){return(this.delInfo&(xQ|l1))>0}get deletedAfter(){return(this.delInfo&(bQ|l1))>0}get deletedAcross(){return(this.delInfo&l1)>0}}class pa{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&pa.empty)return pa.empty}recover(e){let n=0,r=DV(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+UFe(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 u=this.ranges[o+s],d=this.ranges[o+a],f=l+u;if(e<=f){let g=u?e==l?-1:e==f?1:n:n,m=l+i+(g<0?0:d);if(r)return m;let x=e==(n<0?l:f)?null:IFe(o/3,e-l),y=e==l?bQ:e==f?xQ:l1;return(n<0?e!=l:e!=f)&&(y|=vQ),new UP(m,y,x)}i+=d-u}return r?e+i:new UP(e+i,0,null)}touches(e,n){let r=0,i=DV(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 u=this.ranges[o+s],d=l+u;if(e<=d&&o==i*3)return!0;r+=this.ranges[o+a]-u}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),u=this.ranges[i+n],d=this.ranges[i+r];e(o,o+u,l,l+d),s+=d-u}}invert(){return new pa(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?pa.empty:new pa(e<0?[0,-e,0]:[0,0,e])}}pa.empty=new pa([]);class q0{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 q0(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 q0;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 UP(e,i,null)}}const CN=Object.create(null);class xs{getMap(){return pa.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=CN[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 CN)throw new RangeError("Duplicate use of step JSON ID "+e);return CN[e]=n,n.prototype.jsonID=e,n}}class Qr{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Qr(e,null)}static fail(e){return new Qr(null,e)}static fromReplace(e,n,r,i){try{return Qr.ok(e.replace(n,r,i))}catch(s){if(s instanceof jw)return Qr.fail(s.message);throw s}}}function mj(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(mj(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return pt.fromArray(r)}class Bu extends xs{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 Ct(mj(n.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),n.openStart,n.openEnd);return Qr.fromReplace(e,this.from,this.to,s)}invert(){return new Po(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 Bu(n.pos,r.pos,this.mark)}merge(e){return e instanceof Bu&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Bu(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 Bu(n.from,n.to,e.markFromJSON(n.mark))}}xs.jsonID("addMark",Bu);class Po extends xs{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 Ct(mj(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Qr.fromReplace(e,this.from,this.to,r)}invert(){return new Bu(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 Po(n.pos,r.pos,this.mark)}merge(e){return e instanceof Po&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Po(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 Po(n.from,n.to,e.markFromJSON(n.mark))}}xs.jsonID("removeMark",Po);class Hu extends xs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Qr.fromReplace(e,this.pos,this.pos+1,new Ct(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 Hu(this.pos,n.marks[i]);return new Hu(this.pos,this.mark)}}return new tf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Hu(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 Hu(n.pos,e.markFromJSON(n.mark))}}xs.jsonID("addNodeMark",Hu);class tf extends xs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qr.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Qr.fromReplace(e,this.pos,this.pos+1,new Ct(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 Hu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new tf(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 tf(n.pos,e.markFromJSON(n.mark))}}xs.jsonID("removeNodeMark",tf);class Di extends xs{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&FP(e,this.from,this.to)?Qr.fail("Structure replace would overwrite content"):Qr.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pa([this.from,this.to-this.from,this.slice.size])}invert(e){return new Di(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 Di(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Di)||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?Ct.empty:new Ct(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Di(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?Ct.empty:new Ct(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Di(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 Di(n.from,n.to,Ct.fromJSON(e,n.slice),!!n.structure)}}xs.jsonID("replace",Di);class ji extends xs{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&&(FP(e,this.from,this.gapFrom)||FP(e,this.gapTo,this.to)))return Qr.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Qr.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Qr.fromReplace(e,this.from,this.to,r):Qr.fail("Content does not fit in gap")}getMap(){return new pa([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 ji(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 ji(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 ji(n.from,n.to,n.gapFrom,n.gapTo,Ct.fromJSON(e,n.slice),n.insert,!!n.structure)}}xs.jsonID("replaceAround",ji);function FP(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 FFe(t,e,n,r){let i=[],s=[],a,o;t.doc.nodesBetween(e,n,(l,u,d)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),m=Math.min(u+l.nodeSize,n),x=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(x)||(a&&a.to==g&&a.mark.eq(f[y])?a.to=m:i.push(a=new Po(g,m,f[y])));o&&o.to==g?o.to=m:s.push(o=new Bu(g,m,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function zFe(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 BE){let u=a.marks,d;for(;d=r.isInSet(u);)(l||(l=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(a.marks)&&(l=[r]):l=a.marks;if(l&&l.length){let u=Math.min(o+a.nodeSize,n);for(let d=0;d<l.length;d++){let f=l[d],g;for(let m=0;m<i.length;m++){let x=i[m];x.step==s-1&&f.eq(i[m].style)&&(g=x)}g?(g.to=u,g.step=s):i.push({style:f,from:Math.max(o,e),to:u,step:s})}}}),i.forEach(a=>t.step(new Po(a.from,a.to,a.style)))}function gj(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 u=s.child(l),d=o+u.nodeSize,f=r.matchType(u.type);if(!f)a.push(new Di(o,d,Ct.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Po(o,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,m=/\r?\n|\r/g,x;for(;g=m.exec(u.text);)x||(x=new Ct(pt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),a.push(new Di(o+g.index,o+g.index+g[0].length,x))}}o=d}if(!r.validEnd){let l=r.fillBefore(pt.empty,!0);t.replace(o,o,new Ct(l,0,0))}for(let l=a.length-1;l>=0;l--)t.step(a[l])}function BFe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ig(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||!BFe(a,o,l))break;o&&(i=1),l<a.childCount&&(s=1)}return null}function HFe(t,e,n){let{$from:r,$to:i,depth:s}=e,a=r.before(s+1),o=i.after(s+1),l=a,u=o,d=pt.empty,f=0;for(let x=s,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=pt.from(r.node(x).copy(d)),f++):l--;let g=pt.empty,m=0;for(let x=s,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,g=pt.from(i.node(x).copy(g)),m++):u++;t.step(new ji(l,u,a,o,new Ct(d.append(g),f,m),d.size-f,!0))}function xj(t,e,n=null,r=t){let i=$Fe(t,e),s=i&&VFe(r,e);return s?i.map(OV).concat({type:e,attrs:n}).concat(s.map(OV)):null}function OV(t){return{type:t,attrs:null}}function $Fe(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 VFe(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 u=r;l&&u<i;u++)l=l.matchType(n.child(u).type);return!l||!l.validEnd?null:a}function GFe(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 ji(i,s,i,s,new Ct(r,0,0),n.length,!0))}function WFe(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)&&qFe(t.doc,t.mapping.slice(s).map(o),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!x?u=!1:!m&&x&&(u=!0)}u===!1&&_Q(t,a,o,s),gj(t,t.mapping.slice(s).map(o,1),r,void 0,u===null);let d=t.mapping.slice(s),f=d.map(o,1),g=d.map(o+a.nodeSize,1);return t.step(new ji(f,g,f+1,g-1,new Ct(pt.from(r.create(l,null,a.marks)),0,0),1,!0)),u===!0&&yQ(t,a,o,s),!1}})}function yQ(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 _Q(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 qFe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function KFe(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 ji(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Ct(pt.from(a),0,0),1,!0))}function Sc(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 u=i.depth-1,d=n-2;u>s;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||f;if(!f.canReplace(g+1,f.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 XFe(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,u=n-1;o>l;o--,u--){s=pt.from(i.node(o).copy(s));let d=r&&r[u];a=pt.from(d?d.type.create(d.attrs,a):i.node(o).copy(a))}t.step(new Di(e,e,new Ct(s.append(a),n,n),!0))}function _d(t,e){let n=t.resolve(e),r=n.index();return wQ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function YFe(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 wQ(t,e){return!!(t&&e&&!t.isLeaf&&YFe(t,e))}function HE(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&&wQ(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 ZFe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),a=s.node().type;if(i&&a.inlineContent){let d=a.whitespace=="pre",f=!!a.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let o=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);_Q(t,d.node(),d.before(),o)}a.inlineContent&&gj(t,e+n-1,a,s.node().contentMatchAt(s.index()),r==null);let l=t.mapping.slice(o),u=l.map(e-n);if(t.step(new Di(u,l.map(e+n,-1),Ct.empty,!0)),r===!0){let d=t.doc.resolve(u);yQ(t,d.node(),d.before(),t.steps.length)}return t}function QFe(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 SQ(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),u=r.node(a),d=!1;if(s==1)d=u.canReplace(l,l,i);else{let f=u.contentMatchAt(l).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(l,l,f[0])}if(d)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}function $E(t,e,n=e,r=Ct.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return EQ(i,s,r)?new Di(e,n,r):new JFe(i,s,r).fit()}function EQ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class JFe{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 u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,a=r.depth,o=i.depth;for(;a&&o&&s.childCount==1;)s=s.firstChild.content,a--,o--;let l=new Ct(s,a,o);return e>-1?new ji(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Di(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=NN(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:u}=this.frontier[o],d,f=null;if(n==1&&(a?u.matchType(a.type)||(f=u.fillBefore(pt.from(a),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:o,parent:s,inject:f};if(n==2&&a&&(d=u.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:o,parent:s,wrap:d};if(s&&u.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=NN(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ct(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=NN(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Ct(Px(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Ct(Px(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,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let m=o.size+e-(a.content.size-a.openEnd);for(;u<o.childCount;){let y=o.child(u),v=f.matchType(y.type);if(!v)break;u++,(u>1||l==0||y.content.size)&&(f=v,d.push(MQ(y.mark(g.allowedMarks(y.marks)),u==1?l:0,u==o.childCount?m:-1)))}let x=u==o.childCount;x||(m=-1),this.placed=Rx(this.placed,n,pt.from(d)),this.frontier[n].match=f,x&&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 b=v.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),v=b.content}this.unplaced=x?e==0?Ct.empty:new Ct(Px(a.content,e-1,1),e-1,m<0?a.openEnd:e-1):new Ct(Px(a.content,e,u),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!kN(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=kN(e,n,i,r,s);if(a){for(let o=n-1;o>=0;o--){let{match:l,type:u}=this.frontier[o],d=kN(e,o,u,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:a,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Rx(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=Rx(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=Rx(this.placed,this.frontier.length,n))}}function Px(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Px(t.firstChild.content,e-1,n)))}function Rx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Rx(t.lastChild.content,e-1,n)))}function NN(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function MQ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,MQ(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 kN(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&&!eze(n,s.content,a)?o:null}function eze(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function tze(t){return t.spec.defining||t.spec.definingForContent}function nze(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(EQ(i,s,r))return t.step(new Di(e,n,r));let a=TQ(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 x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;a.indexOf(g)>-1?o=g:i.before(g)==m&&a.splice(1,0,-g)}let l=a.indexOf(o),u=[],d=r.openStart;for(let g=r.content,m=0;;m++){let x=g.firstChild;if(u.push(x),m==r.openStart)break;g=x.content}for(let g=d-1;g>=0;g--){let m=u[g],x=tze(m.type);if(x&&!m.sameMarkup(i.node(Math.abs(o)-1)))d=g;else if(x||!m.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let m=(g+d+1)%(r.openStart+1),x=u[m];if(x)for(let y=0;y<a.length;y++){let v=a[(y+l)%a.length],b=!0;v<0&&(b=!1,v=-v);let E=i.node(v-1),S=i.index(v-1);if(E.canReplaceWith(S,S,x.type,x.marks))return t.replace(i.before(v),b?s.after(v):n,new Ct(AQ(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let g=a.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let m=a[g];m<0||(e=i.before(m),n=s.after(m))}}function AQ(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(AQ(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 rze(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=QFe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ct(pt.from(r),0,0))}function ize(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=TQ(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 TQ(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 im extends xs{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Qr.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Qr.fromReplace(e,this.pos,this.pos+1,new Ct(pt.from(i),0,n.isLeaf?0:1))}getMap(){return pa.empty}invert(e){return new im(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 im(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 im(n.pos,n.attr,n.value)}}xs.jsonID("attr",im);class K0 extends xs{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Qr.ok(r)}getMap(){return pa.empty}invert(e){return new K0(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 K0(n.attr,n.value)}}xs.jsonID("docAttr",K0);let Nm=class extends Error{};Nm=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Nm.prototype=Object.create(Error.prototype);Nm.prototype.constructor=Nm;Nm.prototype.name="TransformError";class CQ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new q0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Nm(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=Ct.empty){let i=$E(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ct(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,Ct.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return nze(this,e,n,r),this}replaceRangeWith(e,n,r){return rze(this,e,n,r),this}deleteRange(e,n){return ize(this,e,n),this}lift(e,n){return HFe(this,e,n),this}join(e,n=1){return ZFe(this,e,n),this}wrap(e,n){return GFe(this,e,n),this}setBlockType(e,n=e,r,i=null){return WFe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return KFe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new im(e,n,r)),this}setDocAttribute(e,n){return this.step(new K0(e,n)),this}addNodeMark(e,n){return this.step(new Hu(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 tr)n.isInSet(r.marks)&&this.step(new tf(e,n));else{let i=r.marks,s,a=[];for(;s=n.isInSet(i);)a.push(new tf(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 XFe(this,e,n,r),this}addMark(e,n,r){return FFe(this,e,n,r),this}removeMark(e,n,r){return zFe(this,e,n,r),this}clearIncompatible(e,n,r){return gj(this,e,n,r),this}}const PN=Object.create(null);class ln{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new sze(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=Ct.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:u}=a[o],d=e.mapping.slice(s);e.replaceRange(d.map(l.pos),d.map(u.pos),o?Ct.empty:n),o==0&&IV(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),u=l.map(a.pos),d=l.map(o.pos);s?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),IV(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new qt(e):Lp(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?Lp(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Lp(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 ya(e.node(0))}static atStart(e){return Lp(e,e,0,0,1)||new ya(e)}static atEnd(e){return Lp(e,e,e.content.size,e.childCount,-1)||new ya(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=PN[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 PN)throw new RangeError("Duplicate use of selection JSON ID "+e);return PN[e]=n,n.prototype.jsonID=e,n}getBookmark(){return qt.between(this.$anchor,this.$head).getBookmark()}}ln.prototype.visible=!0;class sze{constructor(e,n){this.$from=e,this.$to=n}}let jV=!1;function LV(t){!jV&&!t.parent.inlineContent&&(jV=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class qt extends ln{constructor(e,n=e){LV(e),LV(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 qt(i.parent.inlineContent?i:r,r)}replace(e,n=Ct.empty){if(super.replace(e,n),n==Ct.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof qt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new VE(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 qt(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 qt(e,n)}}ln.jsonID("text",qt);class VE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new VE(e.map(this.anchor),e.map(this.head))}resolve(e){return qt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends ln{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?ln.near(s):new Ht(s)}content(){return new Ct(pt.from(this.node),0,0)}eq(e){return e instanceof Ht&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bj(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ht(e.resolve(n.anchor))}static create(e,n){return new Ht(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ht.prototype.visible=!1;ln.jsonID("node",Ht);class bj{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new VE(r,r):new bj(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ht.isSelectable(r)?new Ht(n):ln.near(n)}}class ya extends ln{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ct.empty){if(n==Ct.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 ya(e)}map(e){return new ya(e)}eq(e){return e instanceof ya}getBookmark(){return aze}}ln.jsonID("all",ya);const aze={map(){return this},resolve(t){return new ya(t)}};function Lp(t,e,n,r,i,s=!1){if(e.inlineContent)return qt.create(t,n);for(let a=r-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let o=e.child(a);if(o.isAtom){if(!s&&Ht.isSelectable(o))return Ht.create(t,n-(i<0?o.nodeSize:0))}else{let l=Lp(t,o,n+i,i<0?o.childCount:0,i,s);if(l)return l}n+=o.nodeSize*i}return null}function IV(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Di||i instanceof ji))return;let s=t.mapping.maps[r],a;s.forEach((o,l,u,d)=>{a==null&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}const UV=1,N_=2,FV=4;class oze extends CQ{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|UV)&~N_,this.storedMarks=null,this}get selectionSet(){return(this.updated&UV)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=N_,this}ensureMarks(e){return tr.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&N_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~N_,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)||tr.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|=FV,this}get scrolledIntoView(){return(this.updated&FV)>0}}function zV(t,e){return!e||!t?t:t.bind(e)}class Dx{constructor(e,n,r){this.name=e,this.init=zV(n.init,r),this.apply=zV(n.apply,r)}}const lze=[new Dx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Dx("selection",{init(t,e){return t.selection||ln.atStart(e.doc)},apply(t){return t.selection}}),new Dx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Dx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class RN{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=lze.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Dx(r.key,r.spec.state,r))})}}class Wp{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,u=i?i[a].state:this,d=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,u,r);if(d&&r.filterTransaction(d,a)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<a?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),s=!0}i&&(i[a]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Wp(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 oze(this)}static create(e){let n=new RN(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Wp(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 RN(this.schema,e.plugins),r=n.fields,i=new Wp(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 RN(e.schema,e.plugins),s=new Wp(i);return i.fields.forEach(a=>{if(a.name=="doc")s.doc=Yu.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],u=l.spec.state;if(l.key==a.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){s[a.name]=u.fromJSON.call(l,e,n[o],s);return}}s[a.name]=a.init(e,s)}}),s}}function NQ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=NQ(i,e,{})),n[r]=i}return n}class Er{constructor(e){this.spec=e,this.props={},e.props&&NQ(e.props,this,this.props),this.key=e.key?e.key.key:kQ("plugin")}getState(e){return e[this.key]}}const DN=Object.create(null);function kQ(t){return t in DN?t+"$"+ ++DN[t]:(DN[t]=0,t+"$")}class _i{constructor(e="key"){this.key=kQ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const vj=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function PQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const RQ=(t,e,n)=>{let r=PQ(t,n);if(!r)return!1;let i=yj(r);if(!i){let a=r.blockRange(),o=a&&ig(a);return o==null?!1:(e&&e(t.tr.lift(a,o).scrollIntoView()),!0)}let s=i.nodeBefore;if(BQ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(km(s,"end")||Ht.isSelectable(s)))for(let a=r.depth;;a--){let o=$E(t.doc,r.before(a),r.after(a),Ct.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(km(s,"end")?ln.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):Ht.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(a==1||r.node(a-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},cze=(t,e,n)=>{let r=PQ(t,n);if(!r)return!1;let i=yj(r);return i?DQ(t,i,e):!1},uze=(t,e,n)=>{let r=jQ(t,n);if(!r)return!1;let i=_j(r);return i?DQ(t,i,e):!1};function DQ(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let a=e.nodeAfter,o=a,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let u=$E(t.doc,s,l,Ct.empty);if(!u||u.from!=s||u instanceof Di&&u.slice.size>=l-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(qt.create(d.doc,s)),n(d.scrollIntoView())}return!0}function km(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 OQ=(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=yj(r)}let a=s&&s.nodeBefore;return!a||!Ht.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function yj(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 jQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const LQ=(t,e,n)=>{let r=jQ(t,n);if(!r)return!1;let i=_j(r);if(!i)return!1;let s=i.nodeAfter;if(BQ(t,i,e,1))return!0;if(r.parent.content.size==0&&(km(s,"start")||Ht.isSelectable(s))){let a=$E(t.doc,r.before(),r.after(),Ct.empty);if(a&&a.slice.size<a.to-a.from){if(e){let o=t.tr.step(a);o.setSelection(km(s,"start")?ln.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ht.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},IQ=(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=_j(r)}let a=s&&s.nodeAfter;return!a||!Ht.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ht.create(t.doc,s.pos)).scrollIntoView()),!0)};function _j(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 dze=(t,e)=>{let n=t.selection,r=n instanceof Ht,i;if(r){if(n.node.isTextblock||!_d(t.doc,n.from))return!1;i=n.from}else if(i=HE(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(Ht.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},hze=(t,e)=>{let n=t.selection,r;if(n instanceof Ht){if(n.node.isTextblock||!_d(t.doc,n.to))return!1;r=n.to}else if(r=HE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},fze=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&ig(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},UQ=(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 wj(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 pze=(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=wj(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},FQ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof ya||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=wj(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(qt.create(o.doc,a+1)),e(o.scrollIntoView())}return!0},zQ=(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(Sc(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&ig(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function mze(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ht&&e.selection.node.isBlock)return!r.parentOffset||!Sc(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,u=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){l=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),o=wj(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(l&&o?{type:o}:null),a=m;break}else{if(m==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof qt||e.selection instanceof ya)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Sc(d.doc,f,s.length,s);if(g||(s[0]=o?{type:o}:null,g=Sc(d.doc,f,s.length,s)),!g)return!1;if(d.split(f,s.length,s),!l&&u&&r.node(a).type!=o){let m=d.mapping.map(r.before(a)),x=d.doc.resolve(m);o&&r.node(a-1).canReplaceWith(x.index(),x.index()+1,o)&&d.setNodeMarkup(d.mapping.map(r.before(a)),o)}return n&&n(d.scrollIntoView()),!0}}const gze=mze(),xze=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(Ht.create(t.doc,i))),!0)};function bze(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||_d(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function BQ(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,a,o,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&bze(t,e,n))return!0;let u=!l&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(a=(o=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&o.matchType(a[0]||s.type).validEnd){if(n){let m=e.pos+s.nodeSize,x=pt.empty;for(let b=a.length-1;b>=0;b--)x=pt.from(a[b].create(null,x));x=pt.from(i.copy(x));let y=t.tr.step(new ji(e.pos-1,m,e.pos,m,new Ct(x,1,0),a.length,!0)),v=y.doc.resolve(m+2*a.length);v.nodeAfter&&v.nodeAfter.type==i.type&&_d(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&l?null:ln.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&ig(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&km(s,"start",!0)&&km(i,"end")){let m=i,x=[];for(;x.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 b=pt.empty;for(let S=x.length-1;S>=0;S--)b=pt.from(x[S].copy(b));let E=t.tr.step(new ji(e.pos-x.length,e.pos+s.nodeSize,e.pos+v,e.pos+s.nodeSize-v,new Ct(b,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function HQ(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(qt.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const vze=HQ(-1),yze=HQ(1);function _ze(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s),o=a&&xj(a,t,e);return o?(r&&r(n.tr.wrap(a,o).scrollIntoView()),!0):!1}}function BV(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,u)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let 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 Sj(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Sj(vj,RQ,OQ);Sj(vj,LQ,IQ);Sj(UQ,FQ,zQ,gze);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function wze(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 Sze(o,a,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function Sze(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 Iw(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Iw(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=xj(s,n,r,e);return o?(t&&Eze(t,e,o,i,n),!0):!1}function Eze(t,e,n,r,i){let s=pt.empty;for(let d=n.length-1;d>=0;d--)s=pt.from(n[d].type.create(n[d].attrs,s));t.step(new ji(e.start-(r?2:0),e.end,e.start,e.end,new Ct(s,0,0),n.length,!0));let a=0;for(let d=0;d<n.length;d++)n[d].type==i&&(a=d+1);let o=n.length-a,l=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&Sc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=u.child(d).nodeSize;return t}function Mze(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?Aze(e,n,t,s):Tze(e,n,s):!0:!1}}function Aze(t,e,n,r){let i=t.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new ji(s-1,a,s,a,new Ct(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Iw(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));const o=ig(r);if(o==null)return!1;i.lift(r,o);let l=i.doc.resolve(i.mapping.map(s,-1)-1);return _d(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function Tze(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)m-=i.child(x).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,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(o?0:1),d+1,a.content.append(l?pt.empty:pt.from(i))))return!1;let f=s.pos,g=f+a.nodeSize;return r.step(new ji(f-(o?1:0),g+(l?1:0),f+1,g-1,new Ct((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 Cze(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,u=>u.childCount>0&&u.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 u=l.lastChild&&l.lastChild.type==o.type,d=pt.from(u?t.create():null),f=new Ct(pt.from(t.create(null,pt.from(o.type.create(null,d)))),u?3:1,0),g=s.start,m=s.end;n(e.tr.step(new ji(g-(u?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}const Qi=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Pm=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let zP=null;const sc=function(t,e,n){let r=zP||(zP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Nze=function(){zP=null},nf=function(t,e,n,r){return n&&(HV(t,e,n,r,-1)||HV(t,e,n,r,1))},kze=/^(img|br|input|textarea|hr)$/i;function HV(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ya(t))){let a=t.parentNode;if(!a||a.nodeType!=1||$b(t)||kze.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?Ya(t):0}else return!1}}function Ya(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Pze(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=Ya(t)}else if(t.parentNode&&!$b(t))e=Qi(t),t=t.parentNode;else return null}}function Rze(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&&!$b(t))e=Qi(t)+1,t=t.parentNode;else return null}}function Dze(t,e,n){for(let r=e==0,i=e==Ya(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==Ya(t)}}function $b(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 GE=function(t){return t.focusNode&&nf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function oh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Oze(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function jze(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ya(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ya(r.startContainer),r.startOffset)}}}const gl=typeof navigator<"u"?navigator:null,$V=typeof document<"u"?document:null,wd=gl&&gl.userAgent||"",BP=/Edge\/(\d+)/.exec(wd),$Q=/MSIE \d/.exec(wd),HP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wd),Ks=!!($Q||HP||BP),Zu=$Q?document.documentMode:HP?+HP[1]:BP?+BP[1]:0,no=!Ks&&/gecko\/(\d+)/i.test(wd);no&&+(/Firefox\/(\d+)/.exec(wd)||[0,0])[1];const $P=!Ks&&/Chrome\/(\d+)/.exec(wd),hs=!!$P,VQ=$P?+$P[1]:0,Ns=!Ks&&!!gl&&/Apple Computer/.test(gl.vendor),Rm=Ns&&(/Mobile\/\w+/.test(wd)||!!gl&&gl.maxTouchPoints>2),Va=Rm||(gl?/Mac/.test(gl.platform):!1),Lze=gl?/Win/.test(gl.platform):!1,gc=/Android \d/.test(wd),Vb=!!$V&&"webkitFontSmoothing"in $V.documentElement.style,Ize=Vb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Uze(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 Jl(t,e){return typeof t=="number"?t:t[e]}function Fze(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 VV(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=Pm(a);continue}let o=a,l=o==s.body,u=l?Uze(s):Fze(o),d=0,f=0;if(e.top<u.top+Jl(r,"top")?f=-(u.top-e.top+Jl(i,"top")):e.bottom>u.bottom-Jl(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Jl(i,"top")-u.top:e.bottom-u.bottom+Jl(i,"bottom")),e.left<u.left+Jl(r,"left")?d=-(u.left-e.left+Jl(i,"left")):e.right>u.right-Jl(r,"right")&&(d=e.right-u.right+Jl(i,"right")),d||f)if(l)s.defaultView.scrollBy(d,f);else{let m=o.scrollLeft,x=o.scrollTop;f&&(o.scrollTop+=f),d&&(o.scrollLeft+=d);let y=o.scrollLeft-m,v=o.scrollTop-x;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:Pm(a)}}function zze(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:GQ(t.dom)}}function GQ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Pm(r));return e}function Bze({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;WQ(n,r==0?0:r-e)}function WQ(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 kp=null;function Hze(t){if(t.setActive)return t.setActive();if(kp)return t.focus(kp);let e=GQ(t);t.focus(kp==null?{get preventScroll(){return kp={preventScroll:!0},!0}}:void 0),kp||(kp=!1,WQ(e,0))}function qQ(t,e){let n,r=2e8,i,s=0,a=e.top,o=e.top,l,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=sc(d).getClientRects();else continue;for(let m=0;m<g.length;m++){let x=g[m];if(x.top<=a&&x.bottom>=o){a=Math.max(x.bottom,a),o=Math.min(x.top,o);let y=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&y&&(s=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!l&&x.left<=e.left&&x.right>=e.left&&(l=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=f+1)}}return!n&&l&&(n=l,i=u,r=0),n&&n.nodeType==3?$ze(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:qQ(n,i)}function $ze(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=Eu(r,1);if(s.top!=s.bottom&&Ej(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function Ej(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Vze(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Gze(t,e,n){let{node:r,offset:i}=qQ(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 Wze(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 KQ(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 u=o[l];if(Ej(e,u))return KQ(a,e,u)}}if((s=(s+1)%r)==i)break}return t}function qze(t,e){let n=t.dom.ownerDocument,r,i=0,s=jze(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 u=t.dom.getBoundingClientRect();if(!Ej(e,u)||(a=KQ(t.dom,e,u),!a))return null}if(Ns)for(let u=a;r&&u;u=Pm(u))u.draggable&&(r=void 0);if(a=Vze(a,e),r){if(no&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;Vb&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(o=Wze(t,r,i,e))}o==null&&(o=Gze(t,a,e));let l=t.docView.nearestDesc(a,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function GV(t){return t.top<t.bottom||t.left<t.right}function Eu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(GV(r))return r}return Array.prototype.find.call(n,GV)||t.getBoundingClientRect()}const Kze=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function XQ(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),a=Vb||no;if(r.nodeType==3)if(a&&(Kze.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let l=Eu(sc(r,i,i),n);if(no&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Eu(sc(r,i-1,i-1),-1);if(u.top==l.top){let d=Eu(sc(r,i,i+1),-1);if(d.top!=l.top)return _x(d,d.left<u.left)}}return l}else{let l=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(l--,d=1):n<0?l--:u++,_x(Eu(sc(r,l,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Ya(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return ON(l.getBoundingClientRect(),!1)}if(s==null&&i<Ya(r)){let l=r.childNodes[i];if(l.nodeType==1)return ON(l.getBoundingClientRect(),!0)}return ON(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Ya(r))){let l=r.childNodes[i-1],u=l.nodeType==3?sc(l,Ya(l)-(a?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(u)return _x(Eu(u,1),!1)}if(s==null&&i<Ya(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let u=l?l.nodeType==3?sc(l,0,a?0:1):l.nodeType==1?l:null:null;if(u)return _x(Eu(u,-1),!0)}return _x(Eu(r.nodeType==3?sc(r):r,-n),n>=0)}function _x(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 ON(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 YQ(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 Xze(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return YQ(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=XQ(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=sc(o,0,o.nodeValue.length).getClientRects();else continue;for(let u=0;u<l.length;u++){let d=l[u];if(d.bottom>d.top+1&&(n=="up"?a.top-d.top>(d.bottom-a.top)*2:d.bottom-a.bottom>(a.bottom-d.top)*2))return!1}}return!0})}const Yze=/[\u0590-\u08ac]/;function Zze(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?!Yze.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?s:a:YQ(t,e,()=>{let{focusNode:l,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=o.caretBidiLevel;o.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),v=x&&!m.contains(x.nodeType==1?x:x.parentNode)||l==x&&u==y;try{o.collapse(d,f),l&&(l!=d||u!=f)&&o.extend&&o.extend(l,u)}catch{}return g!=null&&(o.caretBidiLevel=g),v}):r.pos==r.start()||r.pos==r.end()}let WV=null,qV=null,KV=!1;function Qze(t,e,n){return WV==e&&qV==n?KV:(WV=e,qV=n,KV=n=="up"||n=="down"?Xze(t,e,n):Zze(t,e,n))}const ro=0,XV=1,fh=2,xl=3;class Gb{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=ro,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 QQ){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 ZQ&&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],u=a+l.size;if(i==-1&&e<=u){let d=a+l.border;if(e>=d&&n<=u-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=a;for(let f=o;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=Qi(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||o==this.children.length-1)){n=u;for(let d=o+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Qi(f.dom);break}n+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}a=u}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,x=0;m<this.children.length;m++){let y=this.children[m],v=x+y.size;if(s>x&&a<v)return y.setSelection(e-x-y.border,n-x-y.border,r,i);x=v}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((no||Ns)&&e==n){let{node:m,offset:x}=o;if(m.nodeType==3){if(f=!!(x&&m.nodeValue[x-1]==`
- `),f&&x==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 b=y.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let y=m.childNodes[x-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(no&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ns)&&nf(o.node,o.offset,d.anchorNode,d.anchorOffset)&&nf(l.node,l.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&no)){u.collapse(o.node,o.offset);try{e!=n&&u.extend(l.node,l.offset),g=!0}catch{}}if(!g){if(e>n){let x=o;o=l,l=x}let m=document.createRange();m.setEnd(l.node,l.offset),m.setStart(o.node,o.offset),u.removeAllRanges(),u.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?fh:XV,e==o&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=xl:s.markDirty(e-o,n-o);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?fh:xl}r=a}this.dirty=fh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?fh:XV;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ZQ extends Gb{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==ro&&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 Jze extends Gb{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 rf extends Gb{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=ff.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new rf(e,n,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&xl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=xl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ro){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ro}}slice(e,n,r){let i=rf.create(this.parent,this.mark,!0,r),s=this.children,a=this.size;n<a&&(s=GP(s,n,a,r)),e>0&&(s=GP(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 Qu extends Gb{constructor(e,n,r,i,s,a,o,l,u){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,u=o&&o(n,s,()=>{if(!l)return a;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=ff.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let g=d;return d=tJ(d,r,n),u?l=new eBe(e,n,r,i,d,f||null,g,u,s,a+1):n.isText?new WE(e,n,r,i,d,g,s):new Qu(e,n,r,i,d,f||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==ro&&e.eq(this.node)&&Fw(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 nBe(this,a&&a.node,e);sBe(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?l.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&l.syncToMarks(d==this.node.childCount?tr.none:this.node.child(d).marks,r,e),l.placeWidget(u,e,i)},(u,d,f,g)=>{l.syncToMarks(u.marks,r,e);let m;l.findNodeMatch(u,d,f,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(u,d,f,m,e)||l.updateNextNode(u,d,f,e,g,i)||l.addNode(u,d,f,e,i),i+=u.nodeSize}),l.syncToMarks([],r,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==fh)&&(a&&this.protectLocalComposition(e,a),JQ(this.contentDOM,this.children,e),Rm&&aBe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof qt)||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=oBe(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 Jze(this,s,n,i);e.input.compositionNodes.push(a),this.children=GP(this.children,r,r+i.length,e,a)}update(e,n,r,i){return this.dirty==xl||!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=ro}updateOuterDeco(e){if(Fw(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=eJ(this.dom,this.nodeDOM,VP(this.outerDeco,this.node,n),VP(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 YV(t,e,n,r,i){tJ(r,e,t);let s=new Qu(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class WE extends Qu{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==xl||this.dirty!=ro&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ro||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=ro,!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 WE(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=xl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class QQ extends Gb{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ro&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class eBe extends Qu{constructor(e,n,r,i,s,a,o,l,u,d){super(e,n,r,i,s,a,o,u,d),this.spec=l}update(e,n,r,i){if(this.dirty==xl)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 JQ(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=ZV(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(a instanceof rf){let l=r?r.previousSibling:t.lastChild;JQ(a.contentDOM,a.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=ZV(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Kx=function(t){t&&(this.nodeName=t)};Kx.prototype=Object.create(null);const ph=[new Kx];function VP(t,e,n){if(t.length==0)return ph;let r=n?ph[0]:new Kx,i=[r];for(let s=0;s<t.length;s++){let a=t[s].type.attrs;if(a){a.nodeName&&i.push(r=new Kx(a.nodeName));for(let o in a){let l=a[o];l!=null&&(n&&i.length==1&&i.push(r=new Kx(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 eJ(t,e,n,r){if(n==ph&&r==ph)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=ph[0]),i=l}tBe(i,o||ph[0],a)}return i}function tBe(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 tJ(t,e,n){return eJ(t,t,ph,VP(e,n,t.nodeType!=1))}function Fw(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 ZV(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class nBe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=rBe(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=ro,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 u=this.top.children[l];if(u.matchesMark(e[s])&&!this.isLocked(u.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=rf.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 u=this.top.children[o];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){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==xl&&a.dom==a.contentDOM&&(a.dirty=fh),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 Qu){let u=this.preMatch.matched.get(l);if(u!=null&&u!=s)return!1;let d=l.dom,f,g=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=xl&&Fw(n,l.outerDeco));if(!g&&l.update(e,n,r,i))return this.destroyBetween(this.index,o),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(l,e,n,r,i,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=fh,f.updateChildren(i,a+1),f.dirty=ro),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)||!Fw(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=Qu.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=Qu.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 ZQ(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 rf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof WE)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ns||hs)&&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 QQ(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 rBe(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 u=n.children[r-1];if(u instanceof rf)n=u,r=u.children.length;else{o=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let 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 iBe(t,e){return t.type.side-e.type.side}function sBe(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(s,d),u),s+=d.nodeSize}return}let a=0,o=[],l=null;for(let u=0;;){let d,f;for(;a<i.length&&i[a].to==s;){let v=i[a++];v.widget&&(d?(f||(f=[d])).push(v):d=v)}if(d)if(f){f.sort(iBe);for(let v=0;v<f.length;v++)n(f[v],u,!!l)}else n(d,u,!!l);let g,m;if(l)m=-1,g=l,l=null;else if(u<t.childCount)m=u,g=t.child(u++);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 x=s+g.nodeSize;if(g.isText){let v=x;a<i.length&&i[a].from<v&&(v=i[a].from);for(let b=0;b<o.length;b++)o[b].to<v&&(v=o[b].to);v<x&&(l=g.cut(v-s),g=g.cut(0,v-s),x=v,m=-1)}else for(;a<i.length&&i[a].to<x;)a++;let y=g.isInline&&!g.isLeaf?o.filter(v=>!v.inline):o.slice();r(g,y,e.forChild(s,g),m),s=x}}function aBe(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 oBe(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 u=t.child(i++);if(s+=u.nodeSize,!u.isText)break;l+=u.text}if(s>=n){if(s>=r&&l.slice(r-e.length-o,r-o)==e)return r-e.length;let u=o<r?l.lastIndexOf(e,r-o-1):-1;if(u>=0&&u+e.length+o>=n)return o+u;if(n==r&&l.length>=r+e.length-o&&l.slice(r-o,r-o+e.length)==e)return r}}return-1}function GP(t,e,n,r,i){let s=[];for(let a=0,o=0;a<t.length;a++){let l=t[a],u=o,d=o+=l.size;u>=n||d<=e?s.push(l):(u<e&&s.push(l.slice(0,e-u,r)),i&&(s.push(i),i=void 0),d>n&&s.push(l.slice(n-u,l.size,r)))}return s}function Mj(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,u;if(GE(n)){for(l=a;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ht.isSelectable(f)&&i.parent&&!(f.isInline&&Dze(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new Ht(a==g?o:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=a,g=a;for(let m=0;m<n.rangeCount;m++){let x=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[l,a]=g==t.state.selection.anchor?[g,f]:[f,g],o=r.resolve(a)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!u){let f=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;u=Aj(t,d,o,f)}return u}function nJ(t){return t.editable?t.hasFocus():iJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ec(t,e=!1){let n=t.state.selection;if(rJ(t,n),!!nJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&hs){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&nf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)cBe(t);else{let{anchor:r,head:i}=n,s,a;QV&&!(n instanceof qt)&&(n.$from.parent.inlineContent||(s=JV(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=JV(t,n.to))),t.docView.setSelection(r,i,t,e),QV&&(s&&e9(s),a&&e9(a)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&lBe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const QV=Ns||hs&&VQ<63;function JV(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(Ns&&i&&i.contentEditable=="false")return jN(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return jN(i);if(s)return jN(s)}}function jN(t){return t.contentEditable="true",Ns&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function e9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function lBe(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(()=>{(!nJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function cBe(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&&Ks&&Zu<=11&&(n.disabled=!0,n.disabled=!1)}function rJ(t,e){if(e instanceof Ht){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(t9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else t9(t)}function t9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Aj(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||qt.between(e,n,r)}function n9(t){return t.editable&&!t.hasFocus()?!1:iJ(t)}function iJ(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 uBe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return nf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function WP(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 Nu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function r9(t,e,n){let r=t.state.selection;if(r instanceof qt)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 Nu(t,new qt(r.$anchor,a))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=WP(t.state,e);return i&&i instanceof Ht?Nu(t,i):!1}else if(!(Va&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!s||s.isText)return!1;let o=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(a=t.docView.descAt(o))&&!a.contentDOM?Ht.isSelectable(s)?Nu(t,new Ht(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Vb?Nu(t,new qt(t.state.doc.resolve(e<0?o:o+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Nu(t,new qt(e>0?r.$to:r.$from));{let i=WP(t.state,e);return i?Nu(t,i):!1}}}function zw(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Xx(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?dBe(t):hBe(t)}function dBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,a=!1;for(no&&n.nodeType==1&&r<zw(n)&&Xx(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(Xx(o,-1))i=n,s=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(sJ(n))break;{let o=n.previousSibling;for(;o&&Xx(o,-1);)i=n.parentNode,s=Qi(o),o=o.previousSibling;if(o)n=o,r=zw(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}a?qP(t,n,r):i&&qP(t,i,s)}function hBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=zw(n),s,a;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(Xx(o,1))s=n,a=++r;else break}else{if(sJ(n))break;{let o=n.nextSibling;for(;o&&Xx(o,1);)s=o.parentNode,a=Qi(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=zw(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&qP(t,s,a)}function sJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function fBe(t,e){for(;t&&e==t.childNodes.length&&!$b(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 pBe(t,e){for(;t&&!e&&!$b(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 qP(t,e,n){if(e.nodeType!=3){let s,a;(a=fBe(e,n))?(e=a,n=0):(s=pBe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(GE(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&&Ec(t)},50)}function i9(t,e){let n=t.state.doc.resolve(e);if(!(hs||Lze)&&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 s9(t,e,n){let r=t.state.selection;if(r instanceof qt&&!r.empty||n.indexOf("s")>-1||Va&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let a=WP(t.state,e);if(a&&a instanceof Ht)return Nu(t,a)}if(!i.parent.inlineContent){let a=e<0?i:s,o=r instanceof ya?ln.near(a,e):ln.findFrom(a,e);return o?Nu(t,o):!1}return!1}function a9(t,e){if(!(t.state.selection instanceof qt))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 o9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function mBe(t){if(!Ns||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;o9(t,r,"true"),setTimeout(()=>o9(t,r,"false"),20)}return!1}function gBe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function xBe(t,e){let n=e.keyCode,r=gBe(e);if(n==8||Va&&n==72&&r=="c")return a9(t,-1)||Pp(t,-1);if(n==46&&!e.shiftKey||Va&&n==68&&r=="c")return a9(t,1)||Pp(t,1);if(n==13||n==27)return!0;if(n==37||Va&&n==66&&r=="c"){let i=n==37?i9(t,t.state.selection.from)=="ltr"?-1:1:-1;return r9(t,i,r)||Pp(t,i)}else if(n==39||Va&&n==70&&r=="c"){let i=n==39?i9(t,t.state.selection.from)=="ltr"?1:-1:1;return r9(t,i,r)||Pp(t,i)}else{if(n==38||Va&&n==80&&r=="c")return s9(t,-1,r)||Pp(t,-1);if(n==40||Va&&n==78&&r=="c")return mBe(t)||s9(t,1,r)||Pp(t,1);if(r==(Va?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Tj(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")||ff.fromSchema(t.state.schema),o=dJ(),l=o.createElement("div");l.appendChild(a.serializeFragment(r,{document:o}));let u=l.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=uJ[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let x=o.createElement(d[m]);for(;l.firstChild;)x.appendChild(l.firstChild);l.appendChild(x),f++}u=l.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${f?` -${f}`:""} ${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 aJ(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 Ct(pt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",g=>{o=g(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)o=f;else{let g=i.marks(),{schema:m}=t.state,x=ff.fromSchema(m);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let v=a.appendChild(document.createElement("p"));y&&v.appendChild(x.serializeNode(m.text(y,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),a=_Be(n),Vb&&wBe(a);let u=a&&a.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let g=a.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;a=g}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||Wx.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!bBe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=SBe(l9(o,+d[1],+d[2]),d[4]);else if(o=Ct.maxOpen(vBe(o.content,i),!0),o.openStart||o.openEnd){let f=0,g=0;for(let m=o.content.firstChild;f<o.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=o.content.lastChild;g<o.openEnd&&!m.type.spec.isolating;g++,m=m.lastChild);o=l9(o,f,g)}return t.someProp("transformPasted",f=>{o=f(o,t,l)}),o}const bBe=/^(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 vBe(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),u;if(!l)return a=null;if(u=a.length&&s.length&&lJ(l,s,o,a[a.length-1],0))a[a.length-1]=u;else{a.length&&(a[a.length-1]=cJ(a[a.length-1],s.length));let d=oJ(o,l);a.push(d),i=i.matchType(d.type),s=l}}),a)return pt.from(a)}return t}function oJ(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function lJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=lJ(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(oJ(n,t,i+1))))}}function cJ(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,cJ(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function KP(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=KP(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 l9(t,e,n){return e<t.openStart&&(t=new Ct(KP(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ct(KP(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const uJ={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 c9=null;function dJ(){return c9||(c9=document.implementation.createHTMLDocument("title"))}let LN=null;function yBe(t){let e=window.trustedTypes;return e?(LN||(LN=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),LN.createHTML(t)):t}function _Be(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=dJ().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&uJ[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=yBe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function wBe(t){let e=t.querySelectorAll(hs?"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 SBe(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 Ct(i,s,a)}const ks={},Ps={},EBe={touchstart:!0,touchmove:!0};class MBe{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 ABe(t){for(let e in ks){let n=ks[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{CBe(t,r)&&!Cj(t,r)&&(t.editable||!(r.type in Ps))&&n(t,r)},EBe[e]?{passive:!0}:void 0)}Ns&&t.dom.addEventListener("input",()=>null),XP(t)}function $u(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function TBe(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 XP(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Cj(t,r))})}function Cj(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function CBe(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function NBe(t,e){!Cj(t,e)&&ks[e.type]&&(t.editable||!(e.type in Ps))&&ks[e.type](t,e)}Ps.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!fJ(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(gc&&hs&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Rm&&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,oh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||xBe(t,n)?n.preventDefault():$u(t,"key")};Ps.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ps.keypress=(t,e)=>{let n=e;if(fJ(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Va&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof qt)||!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 qE(t){return{left:t.clientX,top:t.clientY}}function kBe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Nj(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 sm(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 PBe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ht.isSelectable(r)?(sm(t,new Ht(n)),!0):!1}function RBe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ht&&(r=n.node);let s=t.state.doc.resolve(e);for(let a=s.depth+1;a>0;a--){let o=a>s.depth?s.nodeAfter:s.node(a);if(Ht.isSelectable(o)){r&&n.$from.depth>0&&a>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(a);break}}return i!=null?(sm(t,Ht.create(t.state.doc,i)),!0):!1}function DBe(t,e,n,r,i){return Nj(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?RBe(t,n):PBe(t,n))}function OBe(t,e,n,r){return Nj(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function jBe(t,e,n,r){return Nj(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||LBe(t,n,r)}function LBe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(sm(t,qt.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)sm(t,qt.create(r,o+1,o+1+a.content.size));else if(Ht.isSelectable(a))sm(t,Ht.create(r,o));else continue;return!0}}function kj(t){return Bw(t)}const hJ=Va?"metaKey":"ctrlKey";ks.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=kj(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&kBe(n,t.input.lastClick)&&!n[hJ]&&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(qE(n));a&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new IBe(t,a,n,!!r)):(s=="doubleClick"?OBe:jBe)(t,a.pos,a.inside,n)?n.preventDefault():$u(t,"pointer"))};class IBe{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[hJ],this.allowDefault=r.shiftKey;let s,a;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),a=n.inside;else{let d=e.state.doc.resolve(n.pos);s=d.parent,a=d.depth?d.before():0}const o=i?null:r.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||u instanceof Ht&&u.from<=a&&u.to>a)&&(this.mightDrag={node:s,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&no&&!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)),$u(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(()=>Ec(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(qE(e))),this.updateAllowDefault(e),this.allowDefault||!n?$u(this.view,"pointer"):DBe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ns&&this.mightDrag&&!this.mightDrag.node.isAtom||hs&&!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)?(sm(this.view,ln.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):$u(this.view,"pointer")}move(e){this.updateAllowDefault(e),$u(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)}}ks.touchstart=t=>{t.input.lastTouch=Date.now(),kj(t),$u(t,"pointer")};ks.touchmove=t=>{t.input.lastTouch=Date.now(),$u(t,"pointer")};ks.contextmenu=t=>kj(t);function fJ(t,e){return t.composing?!0:Ns&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const UBe=gc?5e3:-1;Ps.compositionstart=Ps.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof qt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Bw(t,!0),t.markCursor=null;else if(Bw(t,!e.selection.empty),no&&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}pJ(t,UBe)};Ps.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++,pJ(t,20))};function pJ(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Bw(t),e))}function mJ(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=zBe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function FBe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Pze(e.focusNode,e.focusOffset),r=Rze(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 zBe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Bw(t,e=!1){if(!(gc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),mJ(t),e||t.docView&&t.docView.dirty){let n=Mj(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 BBe(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 X0=Ks&&Zu<15||Rm&&Ize<604;ks.copy=Ps.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=X0?null:n.clipboardData,a=r.content(),{dom:o,text:l}=Tj(t,a);s?(n.preventDefault(),s.clearData(),s.setData("text/html",o.innerHTML),s.setData("text/plain",l)):BBe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function HBe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $Be(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?Y0(t,r.value,null,i,e):Y0(t,r.textContent,r.innerHTML,i,e)},50)}function Y0(t,e,n,r,i){let s=aJ(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,i,s||Ct.empty)))return!0;if(!s)return!1;let a=HBe(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 gJ(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," "):""}Ps.paste=(t,e)=>{let n=e;if(t.composing&&!gc)return;let r=X0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Y0(t,gJ(r),r.getData("text/html"),i,n)?n.preventDefault():$Be(t,n)};class xJ{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const VBe=Va?"altKey":"ctrlKey";function bJ(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[VBe]}ks.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(qE(n)),a;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Ht?i.to-1:i.to))){if(r&&r.mightDrag)a=Ht.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(a=Ht.create(t.state.doc,f.posBefore))}}let o=(a||t.state.selection).content(),{dom:l,text:u,slice:d}=Tj(t,o);(!n.dataTransfer.files.length||!hs||VQ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(X0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",X0||n.dataTransfer.setData("text/plain",u),t.dragging=new xJ(d,bJ(t,n),a)};ks.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ps.dragover=Ps.dragenter=(t,e)=>e.preventDefault();Ps.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(qE(n));if(!i)return;let s=t.state.doc.resolve(i.pos),a=r&&r.slice;a?t.someProp("transformPasted",x=>{a=x(a,t,!1)}):a=aJ(t,gJ(n.dataTransfer),X0?null:n.dataTransfer.getData("text/html"),!1,s);let o=!!(r&&bJ(t,n));if(t.someProp("handleDrop",x=>x(t,n,a||Ct.empty,o))){n.preventDefault();return}if(!a)return;n.preventDefault();let l=a?SQ(t.state.doc,s.pos,a):s.pos;l==null&&(l=s.pos);let u=t.state.tr;if(o){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(l),f=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,a.content.firstChild):u.replaceRange(d,d,a),u.doc.eq(g))return;let m=u.doc.resolve(d);if(f&&Ht.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))u.setSelection(new Ht(m));else{let x=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((y,v,b,E)=>x=E),u.setSelection(Aj(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};ks.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())&&Ec(t)},20))};ks.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)};ks.beforeinput=(t,e)=>{if(hs&&gc&&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,oh(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 Ps)ks[t]=Ps[t];function Z0(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 Hw{constructor(e,n){this.toDOM=e,this.spec=n||kh,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 Ms(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Hw&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Z0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ju{constructor(e,n){this.attrs=e,this.spec=n||kh}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 Ms(s,a,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ju&&Z0(this.attrs,e.attrs)&&Z0(this.spec,e.spec)}static is(e){return e.type instanceof Ju}destroy(){}}class Pj{constructor(e,n){this.attrs=e,this.spec=n||kh}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 Ms(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 Pj&&Z0(this.attrs,e.attrs)&&Z0(this.spec,e.spec)}destroy(){}}class Ms{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ms(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 Ms(e,e,new Hw(n,r))}static inline(e,n,r,i){return new Ms(e,n,new Ju(r,i))}static node(e,n,r,i){return new Ms(e,n,new Pj(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ju}get widget(){return this.type instanceof Hw}}const Ip=[],kh={};class vr{constructor(e,n){this.local=e.length?e:Ip,this.children=n.length?n:Ip}static create(e,n){return n.length?$w(n,e,0,kh):us}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==us||e.maps.length==0?this:this.mapInner(e,n,0,0,r||kh)}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?GBe(this.children,a||[],e,n,r,i,s):a?new vr(a.sort(Ph),Ip):us}add(e,n){return n.length?this==us?vr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((o,l)=>{let u=l+r,d;if(d=yJ(n,o,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<l;)s+=3;i[s]==l?i[s+2]=i[s+2].addInner(o,d,u+1):i.splice(s,0,l,l+o.nodeSize,$w(d,o,u+1,kh)),s+=3}});let a=vJ(s?_J(n):n,-r);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||a.splice(o--,1);return new vr(a.length?this.local.concat(a).sort(Ph):this.local,i||this.children)}remove(e){return e.length==0||this==us?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let a,o=r[s]+n,l=r[s+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>o&&f.to<l&&(e[d]=null,(a||(a=[])).push(f));if(!a)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(a,o+1);u!=us?r[s+2]=u:(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 vr(i,r):us}forChild(e,n){if(this==us)return this;if(n.isLeaf)return vr.empty;let r,i;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(r=this.children[o+2]);break}let 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 Ju){let u=Math.max(s,l.from)-s,d=Math.min(a,l.to)-s;u<d&&(i||(i=[])).push(l.copy(u,d))}}if(i){let o=new vr(i.sort(Ph),Ip);return r?new ju([o,r]):o}return r||us}eq(e){if(this==e)return!0;if(!(e instanceof vr)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Rj(this.localsInner(e))}localsInner(e){if(this==us)return Ip;if(e.inlineContent||!this.local.some(Ju.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ju||n.push(this.local[r]);return n}forEachSet(e){e(this)}}vr.empty=new vr([],[]);vr.removeOverlap=Rj;const us=vr.empty;class ju{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,kh));return ju.from(r)}forChild(e,n){if(n.isLeaf)return vr.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=us&&(s instanceof ju?r=r.concat(s.members):r.push(s))}return ju.from(r)}eq(e){if(!(e instanceof ju)||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?Rj(r?n:n.sort(Ph)):Ip}static from(e){switch(e.length){case 0:return us;case 1:return e[0];default:return new ju(e.every(n=>n instanceof vr)?e:e.reduce((n,r)=>n.concat(r instanceof vr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function GBe(t,e,n,r,i,s,a){let o=t.slice();for(let u=0,d=s;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,m,x,y)=>{let v=y-x-(m-g);for(let b=0;b<o.length;b+=3){let E=o[b+1];if(E<0||g>E+d-f)continue;let S=o[b]+d-f;m>=S?o[b+1]=g<=S?-2:-1:g>=d&&v&&(o[b]+=v,o[b+1]+=v)}f+=v}),d=n.maps[u].map(d,-1)}let l=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){l=!0,o[u+1]=-1;continue}let d=n.map(t[u]+s),f=d-i;if(f<0||f>=r.content.size){l=!0;continue}let g=n.map(t[u+1]+s,-1),m=g-i,{index:x,offset:y}=r.content.findIndex(f),v=r.maybeChild(x);if(v&&y==f&&y+v.nodeSize==m){let b=o[u+2].mapInner(n,v,d+1,t[u]+s+1,a);b!=us?(o[u]=f,o[u+1]=m,o[u+2]=b):(o[u+1]=-2,l=!0)}else l=!0}if(l){let u=WBe(o,t,e,n,i,s,a),d=$w(u,r,0,a);e=d.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let m=d.children[f];for(;g<o.length&&o[g]<m;)g+=3;o.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new vr(e.sort(Ph),o)}function vJ(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 Ms(i.from+e,i.to+e,i.type))}return n}function WBe(t,e,n,r,i,s,a){function o(l,u){for(let d=0;d<l.local.length;d++){let f=l.local[d].map(r,i,u);f?n.push(f):a.onRemove&&a.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)o(l.children[d+2],l.children[d]+u+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 yJ(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 _J(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function $w(t,e,n,r){let i=[],s=!1;e.forEach((o,l)=>{let u=yJ(t,o,l+n);if(u){s=!0;let d=$w(u,o,n+l+1,r);d!=us&&i.push(l,l+o.nodeSize,d)}});let a=vJ(s?_J(t):t,-n).sort(Ph);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 vr(a,i):us}function Ph(t,e){return t.from-e.from||t.to-e.to}function Rj(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),u9(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),u9(e,i,r.copy(s.from,r.to)));break}}}return e}function u9(t,e,n){for(;e<t.length&&Ph(n,t[e])>0;)e++;t.splice(e,0,n)}function IN(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=us&&e.push(r)}),t.cursorWrapper&&e.push(vr.create(t.state.doc,[t.cursorWrapper.deco])),ju.from(e)}const qBe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},KBe=Ks&&Zu<=11;class XBe{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 YBe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new XBe,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]);Ks&&Zu<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),KBe&&(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,qBe)),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(n9(this.view)){if(this.suppressingSelectionUpdates)return Ec(this.view);if(Ks&&Zu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nf(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=Pm(s))n.add(s);for(let s=e.anchorNode;s;s=Pm(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)&&n9(e)&&!this.ignoreSelectionChange(r),s=-1,a=-1,o=!1,l=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],l);f&&(s=s<0?f.from:Math.min(f.from,s),a=a<0?f.to:Math.max(f.to,a),f.typeOver&&(o=!0))}if(no&&l.length){let d=l.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let m=g.parentNode;m&&m.nodeName=="LI"&&(!f||JBe(e,f)!=m)&&g.remove()}}}let u=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&GE(r)&&(u=Mj(e))&&u.eq(ln.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ec(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),ZBe(e)),this.handleDOMChange(s,a,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ec(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Ks&&Zu<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:g}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(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,u=r.localPosFromDOM(e.target,l,1);return{from:o,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let d9=new WeakMap,h9=!1;function ZBe(t){if(!d9.has(t)&&(d9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=no,h9)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."),h9=!0}}function f9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return nf(a.node,a.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function QBe(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return f9(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?f9(t,n):null}function JBe(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 e6e(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:a,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),u,d=l.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:l.anchorOffset}],GE(l)||u.push({node:l.focusNode,offset:l.focusOffset})),hs&&t.input.lastKeyCode===8)for(let v=s;v>i;v--){let b=r.childNodes[v-1],E=b.pmViewDesc;if(b.nodeName=="BR"&&!E){s=v;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||Wx.fromSchema(t.state.schema),m=f.resolve(a),x=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:u,ruleFromNode:t6e,context:m});if(u&&u[0].pos!=null){let v=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=v),x={anchor:v+a,head:b+a}}return{doc:y,sel:x,from:a,to:o}}function t6e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ns&&/^(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||Ns&&/^(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 n6e=/^(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 r6e(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=Mj(t,N);if(I&&!t.state.selection.eq(I)){if(hs&&gc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,oh(13,"Enter"))))return;let C=t.state.tr.setSelection(I);N=="pointer"?C.setMeta("pointer",!0):N=="key"&&C.scrollIntoView(),s&&C.setMeta("composition",s),t.dispatch(C)}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,u=e6e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.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 x=a6e(f.content,u.doc.content,u.from,g,m);if(x&&t.input.domChangeCount++,(Rm&&t.input.lastIOSEnter>Date.now()-225||gc)&&i.some(N=>N.nodeType==1&&!n6e.test(N.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",N=>N(t,oh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&l instanceof qt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let N=p9(t,t.state.doc,u.sel);if(N&&!N.eq(t.state.selection)){let I=t.state.tr.setSelection(N);s&&I.setMeta("composition",s),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof qt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Ks&&Zu<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)==" "&&(x.start--,x.endA--,x.endB--);let y=u.doc.resolveNoCache(x.start-u.from),v=u.doc.resolveNoCache(x.endB-u.from),b=d.resolve(x.start),E=y.sameParent(v)&&y.parent.inlineContent&&b.end()>=x.endA;if((Rm&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!E&&y.pos<u.doc.content.size&&(!y.sameParent(v)||!y.parent.inlineContent)&&y.pos<v.pos&&!/\S/.test(u.doc.textBetween(y.pos,v.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,oh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&s6e(d,x.start,x.endA,y,v)&&t.someProp("handleKeyDown",N=>N(t,oh(8,"Backspace")))){gc&&hs&&t.domObserver.suppressSelectionUpdates();return}hs&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),gc&&!E&&y.start()!=v.start()&&v.parentOffset==0&&y.depth==v.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,v=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,oh(13,"Enter"))})},20));let S=x.start,A=x.endA,T=N=>{let I=N||t.state.tr.replace(S,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let C=p9(t,I.doc,u.sel);C&&!(hs&&t.composing&&C.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==S||C.head==I.mapping.map(A)-1)||Ks&&C.empty&&C.head==S)&&I.setSelection(C)}return s&&I.setMeta("composition",s),I.scrollIntoView()},k;if(E)if(y.pos==v.pos){Ks&&Zu<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ec(t),20));let N=T(t.state.tr.delete(S,A)),I=d.resolve(x.start).marksAcross(d.resolve(x.endA));I&&N.ensureMarks(I),t.dispatch(N)}else if(x.endA==x.endB&&(k=i6e(y.parent.content.cut(y.parentOffset,v.parentOffset),b.parent.content.cut(b.parentOffset,x.endA-b.start())))){let N=T(t.state.tr);k.type=="add"?N.addMark(S,A,k.mark):N.removeMark(S,A,k.mark),t.dispatch(N)}else if(y.parent.child(y.index()).isText&&y.index()==v.index()-(v.textOffset?0:1)){let N=y.parent.textBetween(y.parentOffset,v.parentOffset),I=()=>T(t.state.tr.insertText(N,S,A));t.someProp("handleTextInput",C=>C(t,S,A,N,I))||t.dispatch(I())}else t.dispatch(T());else t.dispatch(T())}function p9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Aj(t,e.resolve(n.anchor),e.resolve(n.head))}function i6e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,a,o,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);if(i.length==1&&s.length==0)o=i[0],a="add",l=d=>d.mark(o.addToSet(d.marks));else if(i.length==0&&s.length==1)o=s[0],a="remove",l=d=>d.mark(o.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(l(e.child(d)));if(pt.from(u).eq(t))return{mark:o,type:a}}function s6e(t,e,n,r,i){if(n-e<=i.pos-r.pos||UN(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(UN(s,!0,!0));return!a.parent.isTextblock||a.pos>n||UN(a,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(a.parent.content)}function UN(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 a6e(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&&m9(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&&m9(t.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-o),o=s}return{start:s,endA:a,endB:o}}function m9(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 wJ{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 MBe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(y9),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=b9(this),x9(this),this.nodeViews=v9(this),this.docView=YV(this.state.doc,g9(this),IN(this),this.dom,this),this.domObserver=new YBe(this,(r,i,s,a)=>r6e(this,r,i,s,a)),this.domObserver.start(),ABe(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&&XP(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(y9),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&&(mJ(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=v9(this);l6e(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&XP(this),this.editable=b9(this),x9(this);let l=IN(this),u=g9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,u,l);(f||!e.selection.eq(i.selection))&&(a=!0);let g=d=="preserve"&&a&&this.dom.style.overflowAnchor==null&&zze(this);if(a){this.domObserver.stop();let m=f&&(Ks||hs)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&o6e(i.selection,e.selection);if(f){let x=hs?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=FBe(this)),(s||!this.docView.update(e.doc,u,l,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=YV(e.doc,u,l,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&uBe(this))?Ec(this,m):(rJ(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():g&&Bze(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Ht){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&VV(this,n.getBoundingClientRect(),e)}else VV(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 xJ(e.slice,e.move,i<0?void 0:Ht.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let a=0;a<this.directPlugins.length;a++){let o=this.directPlugins[a].props[e];if(o!=null&&(i=n?n(o):o))return i}let s=this.state.plugins;if(s)for(let a=0;a<s.length;a++){let o=s[a].props[e];if(o!=null&&(i=n?n(o):o))return i}}hasFocus(){if(Ks){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&&Hze(this.dom),Ec(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 qze(this,e)}coordsAtPos(e,n=1){return XQ(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 Qze(this,n||this.state,e)}pasteHTML(e,n){return Y0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Y0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Tj(this,e)}destroy(){this.docView&&(TBe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],IN(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Nze())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return NBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ns&&this.root.nodeType===11&&Oze(this.dom.ownerDocument)==this.dom&&QBe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}wJ.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function g9(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"),[Ms.node(0,t.state.doc.content.size,e)]}function x9(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:Ms.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function b9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function o6e(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 v9(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 l6e(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 y9(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 hd={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:"'"},Vw={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},c6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),u6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ji=0;Ji<10;Ji++)hd[48+Ji]=hd[96+Ji]=String(Ji);for(var Ji=1;Ji<=24;Ji++)hd[Ji+111]="F"+Ji;for(var Ji=65;Ji<=90;Ji++)hd[Ji]=String.fromCharCode(Ji+32),Vw[Ji]=String.fromCharCode(Ji);for(var FN in hd)Vw.hasOwnProperty(FN)||(Vw[FN]=hd[FN]);function d6e(t){var e=c6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||u6e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Vw:hd)[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 h6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),f6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function p6e(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))h6e?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 m6e(t){let e=Object.create(null);for(let n in t)e[p6e(n)]=t[n];return e}function zN(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 g6e(t){return new Er({props:{handleKeyDown:SJ(t)}})}function SJ(t){let e=m6e(t);return function(n,r){let i=d6e(r),s,a=e[zN(i,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[zN(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(f6e&&r.ctrlKey&&r.altKey)&&(s=hd[r.keyCode])&&s!=i){let o=e[zN(s,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var x6e=Object.defineProperty,Dj=(t,e)=>{for(var n in e)x6e(t,n,{get:e[n],enumerable:!0})};function KE(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 XE=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,(...u)=>{const d=o(...u)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,a=[],o=!!t,l=t||i.tr,u=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const y=this.buildProps(l,e),v=g(...x)(y);return a.push(v),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([o,l])=>[o,(...u)=>l(...u)({...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:KE({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,(...u)=>l(...u)(a)]))}};return a}},EJ={};Dj(EJ,{blur:()=>b6e,clearContent:()=>v6e,clearNodes:()=>y6e,command:()=>_6e,createParagraphNear:()=>w6e,cut:()=>S6e,deleteCurrentNode:()=>E6e,deleteNode:()=>M6e,deleteRange:()=>A6e,deleteSelection:()=>T6e,enter:()=>C6e,exitCode:()=>N6e,extendMarkRange:()=>k6e,first:()=>P6e,focus:()=>D6e,forEach:()=>O6e,insertContent:()=>j6e,insertContentAt:()=>U6e,joinBackward:()=>B6e,joinDown:()=>z6e,joinForward:()=>H6e,joinItemBackward:()=>$6e,joinItemForward:()=>V6e,joinTextblockBackward:()=>G6e,joinTextblockForward:()=>W6e,joinUp:()=>F6e,keyboardShortcut:()=>K6e,lift:()=>X6e,liftEmptyBlock:()=>Y6e,liftListItem:()=>Z6e,newlineInCode:()=>Q6e,resetAttributes:()=>J6e,scrollIntoView:()=>e8e,selectAll:()=>t8e,selectNodeBackward:()=>n8e,selectNodeForward:()=>r8e,selectParentNode:()=>i8e,selectTextblockEnd:()=>s8e,selectTextblockStart:()=>a8e,setContent:()=>o8e,setMark:()=>M8e,setMeta:()=>A8e,setNode:()=>T8e,setNodeSelection:()=>C8e,setTextDirection:()=>N8e,setTextSelection:()=>k8e,sinkListItem:()=>P8e,splitBlock:()=>R8e,splitListItem:()=>D8e,toggleList:()=>O8e,toggleMark:()=>j8e,toggleNode:()=>L8e,toggleWrap:()=>I8e,undoInputRule:()=>U8e,unsetAllMarks:()=>F8e,unsetMark:()=>z8e,unsetTextDirection:()=>B8e,updateAttributes:()=>H8e,wrapIn:()=>$8e,wrapInList:()=>V8e});var b6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),v6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),y6e=()=>({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:u,mapping:d}=e,f=u.resolve(d.map(l)),g=u.resolve(d.map(l+o.nodeSize)),m=f.blockRange(g);if(!m)return;const x=ig(m);if(o.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,y)}(x||x===0)&&e.lift(m,x)})}),!0},_6e=t=>e=>t(e),w6e=()=>({state:t,dispatch:e})=>FQ(t,e),S6e=(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 qt(r.doc.resolve(Math.max(a-1,0)))),!0},E6e=()=>({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 ri(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 M6e=t=>({tr:e,state:n,dispatch:r})=>{const i=ri(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),u=s.after(a);e.delete(l,u).scrollIntoView()}return!0}return!1},A6e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},T6e=()=>({state:t,dispatch:e})=>vj(t,e),C6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),N6e=()=>({state:t,dispatch:e})=>pze(t,e);function Oj(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Gw(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Oj(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function MJ(t,e,n={}){return t.find(r=>r.type===e&&Gw(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function _9(t,e,n={}){return!!MJ(t,e,n)}function jj(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!MJ([...i.node.marks],e,n)))return;let a=i.index,o=t.start()+i.offset,l=a+1,u=o+i.node.nodeSize;for(;a>0&&_9([...t.parent.child(a-1).marks],e,n);)a-=1,o-=t.parent.child(a).nodeSize;for(;l<t.parent.childCount&&_9([...t.parent.child(l).marks],e,n);)u+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:u}}function Fc(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 k6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Fc(t,r.schema),{doc:a,selection:o}=n,{$from:l,from:u,to:d}=o;if(i){const f=jj(l,s,e);if(f&&f.from<=u&&f.to>=d){const g=qt.create(a,f.from,f.to);n.setSelection(g)}}return!0},P6e=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 AJ(t){return t instanceof qt}function mh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function TJ(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"?qt.create(t,mh(0,i,s),mh(t.content.size,i,s)):qt.create(t,mh(e,i,s),mh(e,i,s))}function R6e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Lj(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var D6e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const a=()=>{(Lj()||R6e())&&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&&!AJ(n.state.selection))return a(),!0;const o=TJ(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},O6e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),j6e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),CJ=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&&CJ(r)}return t};function k_(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 CJ(n)}function Q0(t,e,n){if(t instanceof Yu||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),Q0("",e,n)}if(i){if(n.errorOnInvalidContent){let a=!1,o="";const l=new hQ({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(a=!0,o=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?Wx.fromSchema(l).parseSlice(k_(t),n.parseOptions):Wx.fromSchema(l).parse(k_(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const s=Wx.fromSchema(e);return n.slice?s.parseSlice(k_(t),n.parseOptions).content:s.parse(k_(t),n.parseOptions)}return Q0("",e,n)}function L6e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Di||i instanceof ji))return;const s=t.mapping.maps[r];let a=0;s.forEach((o,l,u,d)=>{a===0&&(a=d)}),t.setSelection(ln.near(t.doc.resolve(a),n))}var I6e=t=>!("type"in t),U6e=(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)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Q0(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(v){l(v)}try{o=Q0(e,s.schema,{parseOptions:u,errorOnInvalidContent:(a=n.errorOnInvalidContent)!=null?a:s.options.enableContentCheck})}catch(v){return l(v),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,m=!0;if((I6e(o)?o:[o]).forEach(v=>{v.check(),g=g?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),d===f&&m){const{parent:v}=r.doc.resolve(d);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(d-=1,f+=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(b=>{b.text&&(v+=b.text)}),y=v}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=o;const v=r.doc.resolve(d),b=v.node(),E=v.parentOffset===0,S=b.isText||b.isTextblock,A=b.content.size>0;E&&S&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&L6e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},F6e=()=>({state:t,dispatch:e})=>dze(t,e),z6e=()=>({state:t,dispatch:e})=>hze(t,e),B6e=()=>({state:t,dispatch:e})=>RQ(t,e),H6e=()=>({state:t,dispatch:e})=>LQ(t,e),$6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=HE(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},V6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=HE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},G6e=()=>({state:t,dispatch:e})=>cze(t,e),W6e=()=>({state:t,dispatch:e})=>uze(t,e);function NJ(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function q6e(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))Lj()||NJ()?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 K6e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=q6e(t).split(/-(?!$)/),a=s.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),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",u=>u(n,o))});return l?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function fd(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,a=e?ri(e,t.schema):null,o=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const m=Math.max(r,g),x=Math.min(i,g+f.nodeSize);o.push({node:f,from:m,to:x})});const l=i-r,u=o.filter(f=>a?a.name===f.node.type.name:!0).filter(f=>Gw(f.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=l}var X6e=(t,e={})=>({state:n,dispatch:r})=>{const i=ri(t,n.schema);return fd(n,i,e)?fze(n,r):!1},Y6e=()=>({state:t,dispatch:e})=>zQ(t,e),Z6e=t=>({state:e,dispatch:n})=>{const r=ri(t,e.schema);return Mze(r)(e,n)},Q6e=()=>({state:t,dispatch:e})=>UQ(t,e);function YE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function w9(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 J6e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=YE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=ri(t,r.schema)),o==="mark"&&(a=Fc(t,r.schema));let l=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{s&&s===d.type&&(l=!0,i&&n.setNodeMarkup(f,void 0,w9(d.attrs,e))),a&&d.marks.length&&d.marks.forEach(g=>{a===g.type&&(l=!0,i&&n.addMark(f,f+d.nodeSize,a.create(w9(g.attrs,e))))})})}),l},e8e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),t8e=()=>({tr:t,dispatch:e})=>{if(e){const n=new ya(t.doc);t.setSelection(n)}return!0},n8e=()=>({state:t,dispatch:e})=>OQ(t,e),r8e=()=>({state:t,dispatch:e})=>IQ(t,e),i8e=()=>({state:t,dispatch:e})=>xze(t,e),s8e=()=>({state:t,dispatch:e})=>yze(t,e),a8e=()=>({state:t,dispatch:e})=>vze(t,e);function YP(t,e,n={},r={}){return Q0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var o8e=(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 u=YP(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return a&&s.replaceWith(0,l.content.size,u).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 kJ(t,e){const n=Fc(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 PJ(t,e){const n=new CQ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function l8e(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 c8e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function u8e(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 ZE(t){return e=>u8e(e.$from,t)}function Bt(t,e,n){return t.config[e]===void 0&&t.parent?Bt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Bt(t.parent,e,n):null}):t.config[e]}function Ij(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Bt(e,"addExtensions",n);return r?[e,...Ij(r())]:e}).flat(10)}function Uj(t,e){const n=ff.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function RJ(t){return typeof t=="function"}function In(t,e=void 0,...n){return RJ(t)?e?t.bind(e)(...n):t(...n):t}function d8e(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 DJ(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=Bt(a,"addGlobalAttributes",o);if(!l)return;l().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,m])=>{e.push({type:f,name:g,attribute:{...s,...m}})})})})}),i.forEach(a=>{const o={name:a.name,options:a.options,storage:a.storage},l=Bt(a,"addAttributes",o);if(!l)return;const u=l();Object.entries(u).forEach(([d,f])=>{const g={...s,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:a.name,name:d,attribute:g})})}),e}function Rr(...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(" "):[],u=o.filter(d=>!l.includes(d));r[i]=[...l,...u].join(" ")}else if(i==="style"){const o=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],l=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;l.forEach(d=>{const[f,g]=d.split(":").map(m=>m.trim());u.set(f,g)}),o.forEach(d=>{const[f,g]=d.split(":").map(m=>m.trim());u.set(f,g)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=s}),r},{})}function Ww(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)=>Rr(n,r),{})}function h8e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function S9(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):h8e(n.getAttribute(a.name));return o==null?s:{...s,[a.name]:o}},{});return{...r,...i}}}}function E9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&d8e(n)?!1:n!=null))}function M9(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 f8e(t,e){var n;const r=DJ(t),{nodeExtensions:i,markExtensions:s}=Dm(t),a=(n=i.find(u=>Bt(u,"topNode")))==null?void 0:n.name,o=Object.fromEntries(i.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,E)=>{const S=Bt(E,"extendNodeSchema",f);return{...b,...S?S(u):{}}},{}),m=E9({...g,content:In(Bt(u,"content",f)),marks:In(Bt(u,"marks",f)),group:In(Bt(u,"group",f)),inline:In(Bt(u,"inline",f)),atom:In(Bt(u,"atom",f)),selectable:In(Bt(u,"selectable",f)),draggable:In(Bt(u,"draggable",f)),code:In(Bt(u,"code",f)),whitespace:In(Bt(u,"whitespace",f)),linebreakReplacement:In(Bt(u,"linebreakReplacement",f)),defining:In(Bt(u,"defining",f)),isolating:In(Bt(u,"isolating",f)),attrs:Object.fromEntries(d.map(M9))}),x=In(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(b=>S9(b,d)));const y=Bt(u,"renderHTML",f);y&&(m.toDOM=b=>y({node:b,HTMLAttributes:Ww(b,d)}));const v=Bt(u,"renderText",f);return v&&(m.toText=v),[u.name,m]})),l=Object.fromEntries(s.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((v,b)=>{const E=Bt(b,"extendMarkSchema",f);return{...v,...E?E(u):{}}},{}),m=E9({...g,inclusive:In(Bt(u,"inclusive",f)),excludes:In(Bt(u,"excludes",f)),group:In(Bt(u,"group",f)),spanning:In(Bt(u,"spanning",f)),code:In(Bt(u,"code",f)),attrs:Object.fromEntries(d.map(M9))}),x=In(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(v=>S9(v,d)));const y=Bt(u,"renderHTML",f);return y&&(m.toDOM=v=>y({mark:v,HTMLAttributes:Ww(v,d)})),[u.name,m]}));return new hQ({topNode:a,nodes:o,marks:l})}function p8e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Fj(t){return t.sort((n,r)=>{const i=Bt(n,"priority")||100,s=Bt(r,"priority")||100;return i>s?-1:i<s?1:0})}function OJ(t){const e=Fj(Ij(t)),n=p8e(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 jJ(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
- `,textSerializers:a={}}=n||{};let o="";return t.nodesBetween(r,i,(l,u,d,f)=>{var g;l.isBlock&&u>r&&(o+=s);const m=a?.[l.type.name];if(m)return d&&(o+=m({node:l,pos:u,parent:d,index:f,range:e})),!1;l.isText&&(o+=(g=l?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),o}function m8e(t,e){const n={from:0,to:t.content.size};return jJ(t,n,e)}function LJ(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function g8e(t,e){const n=ri(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 IJ(t,e){const n=YE(typeof e=="string"?e:e.name,t.schema);return n==="node"?g8e(t,e):n==="mark"?kJ(t,e):{}}function x8e(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 b8e(t){const e=x8e(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 UJ(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 u=e.slice(s).map(o,-1),d=e.slice(s).map(l),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),b8e(r)}function zj(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),a=jj(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 v8e=(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 BN(t,e){return e.nodes[t]||e.marks[t]||null}function c1(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 y8e=(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,u;const d=((u=(l=i.type.spec).toText)==null?void 0:u.call(l,{node:i,pos:s,parent:a,index:o}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),n};function ZP(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Fc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>Gw(f.attrs,n,{strict:!1}));let a=0;const o=[];if(i.forEach(({$from:f,$to:g})=>{const m=f.pos,x=g.pos;t.doc.nodesBetween(m,x,(y,v)=>{if(!y.isText&&!y.marks.length)return;const b=Math.max(m,v),E=Math.min(x,v+y.nodeSize),S=E-b;a+=S,o.push(...y.marks.map(A=>({mark:A,from:b,to:E})))})}),a===0)return!1;const l=o.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>Gw(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=o.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,g)=>f+g.to-g.from,0);return(l>0?l+u:l)>=a}function _8e(t,e,n={}){if(!e)return fd(t,null,n)||ZP(t,null,n);const r=YE(e,t.schema);return r==="node"?fd(t,e,n):r==="mark"?ZP(t,e,n):!1}var w8e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=ZE(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)},S8e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function A9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function T9(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=In(Bt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function QE(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&&(QE(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function FJ(t){return t instanceof Ht}function E8e(t,e,n){var r;const{selection:i}=e;let s=null;if(AJ(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(u=>u.type.excludes(n)))}const{ranges:a}=i;return a.some(({$from:o,$to:l})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const m=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=m&&x}return!u}),u})}var M8e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:a,ranges:o}=s,l=Fc(t,r.schema);if(i)if(a){const u=kJ(r,l);n.addStoredMark(l.create({...u,...e}))}else o.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,m)=>{const x=Math.max(m,d),y=Math.min(m+g.nodeSize,f);g.marks.find(b=>b.type===l)?g.marks.forEach(b=>{l===b.type&&n.addMark(x,y,l.create({...b.attrs,...e}))}):n.addMark(x,y,l.create(e))})});return E8e(r,n,l)},A8e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),T8e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=ri(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})=>BV(s,{...a,...e})(n)?!0:o.clearNodes()).command(({state:o})=>BV(s,{...a,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},C8e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=mh(t,0,r.content.size),s=Ht.create(r,i);e.setSelection(s)}return!0},N8e=(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,u)=>{l.isText||n.setNodeMarkup(u,void 0,{...l.attrs,dir:t})}),!0},k8e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,a=qt.atStart(r).from,o=qt.atEnd(r).to,l=mh(i,a,o),u=mh(s,a,o),d=qt.create(r,l,u);e.setSelection(d)}return!0},P8e=t=>({state:e,dispatch:n})=>{const r=ri(t,e.schema);return Cze(r)(e,n)};function C9(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 R8e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:a}=e,{$from:o,$to:l}=s,u=i.extensionManager.attributes,d=c1(u,o.node().type.name,o.node().attrs);if(s instanceof Ht&&s.node.isBlock)return!o.parentOffset||!Sc(a,o.pos)?!1:(r&&(t&&C9(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,g=o.depth===0?void 0:l8e(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=f&&g?[{type:g,attrs:d}]:void 0,x=Sc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!x&&Sc(e.doc,e.mapping.map(o.pos),1,g?[{type:g}]:void 0)&&(x=!0,m=g?[{type:g,attrs:d}]:void 0),r){if(x&&(s instanceof qt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),g&&!f&&!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&&C9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},D8e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var a;const o=ri(t,r.schema),{$from:l,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(u))return!1;const f=l.node(-1);if(f.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 b=pt.empty;const E=l.index(-1)?1:l.index(-2)?2:3;for(let I=l.depth-E;I>=l.depth-3;I-=1)b=pt.from(l.node(I).copy(b));const S=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...c1(g,l.node().type.name,l.node().attrs),...e},T=((a=o.contentMatch.defaultType)==null?void 0:a.createAndFill(A))||void 0;b=b.append(pt.from(o.createAndFill(null,T)||void 0));const k=l.before(l.depth-(E-1));n.replace(k,l.after(-S),new Ct(b,4-E,0));let N=-1;n.doc.nodesBetween(k,n.doc.content.size,(I,C)=>{if(N>-1)return!1;I.isTextblock&&I.content.size===0&&(N=C+1)}),N>-1&&n.setSelection(qt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const m=u.pos===l.end()?f.contentMatchAt(0).defaultType:null,x={...c1(g,f.type.name,f.attrs),...e},y={...c1(g,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,u.pos);const v=m?[{type:o,attrs:x},{type:m,attrs:y}]:[{type:o,attrs:x}];if(!Sc(n.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:E}=r,{splittableMarks:S}=s.extensionManager,A=E||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,v).scrollIntoView(),!A||!i)return!0;const T=A.filter(k=>S.includes(k.type.name));n.ensureMarks(T)}return!0},HN=(t,e)=>{const n=ZE(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&&_d(t.doc,n.pos)&&t.join(n.pos),!0},$N=(t,e)=>{const n=ZE(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&&_d(t.doc,r)&&t.join(r),!0},O8e=(t,e,n,r={})=>({editor:i,tr:s,state:a,dispatch:o,chain:l,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,m=ri(t,a.schema),x=ri(e,a.schema),{selection:y,storedMarks:v}=a,{$from:b,$to:E}=y,S=b.blockRange(E),A=v||y.$to.parentOffset&&y.$from.marks();if(!S)return!1;const T=ZE(k=>T9(k.type.name,f))(y);if(S.depth>=1&&T&&S.depth-T.depth<=1){if(T.node.type===m)return u.liftListItem(x);if(T9(T.node.type.name,f)&&m.validContent(T.node.content)&&o)return l().command(()=>(s.setNodeMarkup(T.pos,m),!0)).command(()=>HN(s,m)).command(()=>$N(s,m)).run()}return!n||!A||!o?l().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>HN(s,m)).command(()=>$N(s,m)).run():l().command(()=>{const k=d().wrapInList(m,r),N=A.filter(I=>g.includes(I.type.name));return s.ensureMarks(N),k?!0:u.clearNodes()}).wrapInList(m,r).command(()=>HN(s,m)).command(()=>$N(s,m)).run()},j8e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,a=Fc(t,r.schema);return ZP(r,a,e)?i.unsetMark(a,{extendEmptyMarkRange:s}):i.setMark(a,e)},L8e=(t,e,n={})=>({state:r,commands:i})=>{const s=ri(t,r.schema),a=ri(e,r.schema),o=fd(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})},I8e=(t,e={})=>({state:n,commands:r})=>{const i=ri(t,n.schema);return fd(n,i,e)?r.lift(i):r.wrapIn(i,e)},U8e=()=>({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},F8e=()=>({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},z8e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:a=!1}=e,{selection:o}=n,l=Fc(t,r.schema),{$from:u,empty:d,ranges:f}=o;if(!i)return!0;if(d&&a){let{from:g,to:m}=o;const x=(s=u.marks().find(v=>v.type===l))==null?void 0:s.attrs,y=jj(u,l,x);y&&(g=y.from,m=y.to),n.removeMark(g,m,l)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,l)});return n.removeStoredMark(l),!0},B8e=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 u={...o.attrs};delete u.dir,e.setNodeMarkup(l,void 0,u)}),!0},H8e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=YE(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=ri(t,r.schema)),o==="mark"&&(a=Fc(t,r.schema));let l=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,m,x,y;n.selection.empty?r.doc.nodesBetween(d,f,(v,b)=>{s&&s===v.type&&(l=!0,x=Math.max(b,d),y=Math.min(b+v.nodeSize,f),g=b,m=v)}):r.doc.nodesBetween(d,f,(v,b)=>{b<d&&s&&s===v.type&&(l=!0,x=Math.max(b,d),y=Math.min(b+v.nodeSize,f),g=b,m=v),b>=d&&b<=f&&(s&&s===v.type&&(l=!0,i&&n.setNodeMarkup(b,void 0,{...v.attrs,...e})),a&&v.marks.length&&v.marks.forEach(E=>{if(a===E.type&&(l=!0,i)){const S=Math.max(b,d),A=Math.min(b+v.nodeSize,f);n.addMark(S,A,a.create({...E.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(x,y,a.create({...v.attrs,...e}))}))}),l},$8e=(t,e={})=>({state:n,dispatch:r})=>{const i=ri(t,n.schema);return _ze(i,e)(n,r)},V8e=(t,e={})=>({state:n,dispatch:r})=>{const i=ri(t,n.schema);return wze(i,e)(n,r)},G8e=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},JE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},W8e=(t,e)=>{if(Oj(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 P_(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 u=l.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=y8e(u)+s;return a.forEach(g=>{if(d)return;const m=W8e(f,g.find);if(!m)return;const x=l.state.tr,y=KE({state:l.state,transaction:x}),v={from:r-(m[0].length-s.length),to:i},{commands:b,chain:E,can:S}=new XE({editor:n,state:y});g.handler({state:y,range:v,match:m,commands:b,chain:E,can:S})===null||!x.steps.length||(g.undoable&&x.setMeta(o,{transform:x,from:r,to:i,text:s}),l.dispatch(x),d=!0)}),d}function q8e(t){const{editor:e,rules:n}=t,r=new Er({state:{init(){return null},apply(i,s,a){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=Uj(pt.from(d),a.schema);const{from:f}=l,g=f+d.length;P_({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,a,o){return P_({editor:e,from:s,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&P_({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?P_({editor:e,from:a.pos,to:a.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function K8e(t){return Object.prototype.toString.call(t).slice(8,-1)}function R_(t){return K8e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function zJ(t,e){const n={...t};return R_(t)&&R_(e)&&Object.keys(e).forEach(r=>{R_(e[r])&&R_(t[r])?n[r]=zJ(t[r],e[r]):n[r]=e[r]}),n}var Bj=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{...In(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...In(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>zJ(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}},Sd=class BJ extends Bj{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new BJ(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(u=>u?.type.name===n.name))return!1;const l=a.find(u=>u?.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 X8e(t){return typeof t=="number"}var Y8e=class{constructor(t){this.find=t.find,this.handler=t.handler}},Z8e=(t,e,n)=>{if(Oj(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 Q8e(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:a,dropEvent:o}=t,{commands:l,chain:u,can:d}=new XE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,x)=>{var y,v,b,E,S;if((v=(y=m.type)==null?void 0:y.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const A=(S=(E=(b=m.content)==null?void 0:b.size)!=null?E:m.nodeSize)!=null?S:0,T=Math.max(r,x),k=Math.min(i,x+A);if(T>=k)return;const N=m.isText?m.text||"":m.textBetween(T-x,k-x,void 0,"");Z8e(N,s.find,a).forEach(C=>{if(C.index===void 0)return;const D=T+C.index+1,F=D+C[0].length,j={from:n.tr.mapping.map(D),to:n.tr.mapping.map(F)},q=s.handler({state:n,range:j,match:C,commands:l,chain:u,can:d,pasteEvent:a,dropEvent:o});f.push(q)})}),f.every(m=>m!==null)}var D_=null,J8e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function eHe(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:d,from:f,to:g,rule:m,pasteEvt:x})=>{const y=d.tr,v=KE({state:d,transaction:y});if(!(!Q8e({editor:e,state:v,from:Math.max(f-1,0),to:g.b-1,rule:m,pasteEvent:x,dropEvent:o})||!y.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Er({view(f){const g=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(D_=e)},m=()=>{D_&&(D_=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(s=r===f.dom.parentElement,o=g,!s){const m=D_;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var m;const x=(m=g.clipboardData)==null?void 0:m.getData("text/html");return a=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,m)=>{const x=f[0],y=x.getMeta("uiEvent")==="paste"&&!i,v=x.getMeta("uiEvent")==="drop"&&!s,b=x.getMeta("applyPasteRules"),E=!!b;if(!y&&!v&&!E)return;if(E){let{text:T}=b;typeof T=="string"?T=T:T=Uj(pt.from(T),m.schema);const{from:k}=b,N=k+T.length,I=J8e(T);return l({rule:d,state:m,from:k,to:{b:N},pasteEvt:I})}const S=g.doc.content.findDiffStart(m.doc.content),A=g.doc.content.findDiffEnd(m.doc.content);if(!(!X8e(S)||!A||S===A.b))return l({rule:d,state:m,from:S,to:A,pasteEvt:a})}}))}var eM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=OJ(t),this.schema=f8e(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:BN(e.name,this.schema)},r=Bt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Fj([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:BN(r.name,this.schema)},s=[],a=Bt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Bt(r,"exitable",i)&&(o.ArrowRight=()=>Sd.handleExit({editor:t,mark:r})),a){const g=Object.fromEntries(Object.entries(a()).map(([m,x])=>[m,()=>x({editor:t})]));o={...o,...g}}const l=g6e(o);s.push(l);const u=Bt(r,"addInputRules",i);if(A9(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const m=q8e({editor:t,rules:g}),x=Array.isArray(m)?m:[m];s.push(...x)}}const d=Bt(r,"addPasteRules",i);if(A9(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const m=eHe({editor:t,rules:g});s.push(...m)}}const f=Bt(r,"addProseMirrorPlugins",i);if(f){const g=f();s.push(...g)}return s})}get attributes(){return DJ(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Dm(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ri(n.name,this.schema)},s=Bt(n,"addNodeView",i);if(!s)return[];const a=s();if(!a)return[];const o=(l,u,d,f,g)=>{const m=Ww(l,r);return a({node:l,view:u,getPos:d,decorations:f,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=>!!Bt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(o=>o.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Fc(n.name,this.schema)},s=Bt(n,"addMarkView",i);if(!s)return[];const a=(o,l,u)=>{const d=Ww(o,r);return s()({mark:o,view:l,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{mHe(o,t,f)}})};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:BN(e.name,this.schema)};e.type==="mark"&&((n=In(Bt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Bt(e,"onBeforeCreate",r),s=Bt(e,"onCreate",r),a=Bt(e,"onUpdate",r),o=Bt(e,"onSelectionUpdate",r),l=Bt(e,"onTransaction",r),u=Bt(e,"onFocus",r),d=Bt(e,"onBlur",r),f=Bt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),a&&this.editor.on("update",a),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};eM.resolve=OJ;eM.sort=Fj;eM.flatten=Ij;var tHe={};Dj(tHe,{ClipboardTextSerializer:()=>$J,Commands:()=>VJ,Delete:()=>GJ,Drop:()=>WJ,Editable:()=>qJ,FocusEvents:()=>XJ,Keymap:()=>YJ,Paste:()=>ZJ,Tabindex:()=>QJ,TextDirection:()=>JJ,focusEventsPluginKey:()=>KJ});var Zn=class HJ extends Bj{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new HJ(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},$J=Zn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Er({key:new _i("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,a=Math.min(...s.map(d=>d.$from.pos)),o=Math.max(...s.map(d=>d.$to.pos)),l=LJ(n);return jJ(r,{from:a,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),VJ=Zn.create({name:"commands",addCommands(){return{...EJ}}}),GJ=Zn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var a,o,l,u;if((u=(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?u:t.getMeta("y-sync$"))return;const d=PJ(t.before,[t,...e]);UJ(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(x,y)=>{const v=y+x.nodeSize-2,b=m.oldRange.from<=y&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:y,to:v,newFrom:d.mapping.map(y),newTo:d.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((m,x)=>{var y,v;if(m instanceof Po){const b=g.slice(x).map(m.from,-1),E=g.slice(x).map(m.to),S=g.invert().map(b,-1),A=g.invert().map(E),T=(y=d.doc.nodeAt(b-1))==null?void 0:y.marks.some(N=>N.eq(m.mark)),k=(v=d.doc.nodeAt(E))==null?void 0:v.marks.some(N=>N.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:S,to:A},newRange:{from:b,to:E},partial:!!(k||T),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),WJ=Zn.create({name:"drop",addProseMirrorPlugins(){return[new Er({key:new _i("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),qJ=Zn.create({name:"editable",addProseMirrorPlugins(){return[new Er({key:new _i("editable"),props:{editable:()=>this.editor.options.editable}})]}}),KJ=new _i("focusEvents"),XJ=Zn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Er({key:KJ,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}}}})]}}),YJ=Zn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:o})=>{const{selection:l,doc:u}=o,{empty:d,$anchor:f}=l,{pos:g,parent:m}=f,x=f.parent.isTextblock&&g>0?o.doc.resolve(g-1):f,y=x.parent.type.spec.isolating,v=f.pos-f.parentOffset,b=y&&x.parent.childCount===1?v===f.pos:ln.atStart(u).from===g;return!d||!m.type.isTextblock||m.textContent.length||!b||b&&f.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 Lj()||NJ()?s:i},addProseMirrorPlugins(){return[new Er({key:new _i("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,u=ln.atEnd(e.doc).to;if(s||!(a===l&&o===u)||!QE(n.doc))return;const g=n.tr,m=KE({state:n,transaction:g}),{commands:x}=new XE({editor:this.editor,state:m});if(x.clearNodes(),!!g.steps.length)return g}})]}}),ZJ=Zn.create({name:"paste",addProseMirrorPlugins(){return[new Er({key:new _i("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),QJ=Zn.create({name:"tabindex",addProseMirrorPlugins(){return[new Er({key:new _i("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),JJ=Zn.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 Er({key:new _i("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),nHe=class Up{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 Up(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 Up(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 Up(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 Up(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new Up(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)}},rHe=`.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 iHe(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 sHe=class extends G8e{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=TJ(e,this.options.autofocus);this.editorState=Wp.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=iHe(rHe,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=RJ(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?[qJ,$J.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),VJ,XJ,YJ,QJ,WJ,ZJ,GJ,JJ.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 eM(r,this)}createCommandManager(){this.commandManager=new XE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=YP(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=YP(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new wJ(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),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(u=>u.getMeta("focus")||u.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(u=>u.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return IJ(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return _8e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Uj(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return m8e(this.state.doc,{blockSeparator:e,textSerializers:{...LJ(this.schema),...n}})}get isEmpty(){return QE(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new nHe(e,this)}get $doc(){return this.$pos(0)}};function Om(t){return new JE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=In(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/),u=n.from+o.indexOf(a),d=u+a.length;if(zj(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>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+l,u);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 eee(t){return new JE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=In(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 u=r[0].lastIndexOf(r[1]);let d=a+u;d>o?d=o:o=d+r[1].length;const f=r[0][r[0].length-1];s.insertText(f,a+r[0].length-1),s.replaceWith(d,o,l)}else if(r[0]){const u=t.type.isInline?a:a-1;s.insert(u,t.type.create(i)).delete(s.mapping.map(a),s.mapping.map(o))}s.scrollIntoView()},undoable:t.undoable})}function QP(t){return new JE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=In(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 jm(t){return new JE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=In(t.getAttributes,void 0,r)||{},a=e.tr.delete(n.from,n.to),l=a.doc.resolve(n.from).blockRange(),u=l&&xj(l,t.type,s);if(!u)return null;if(a.wrap(l,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:m}=t.editor.extensionManager,x=g||f.$to.parentOffset&&f.$from.marks();if(x){const y=x.filter(v=>m.includes(v.type.name));a.ensureMarks(y)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,s).run()}const d=a.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&_d(a.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&a.join(n.from-1)},undoable:t.undoable})}var aHe=t=>"touches"in t,oHe=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,u=o.clientY-this.startY;this.handleResize(l,u)},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,aHe(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 u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let o=t,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 lHe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ht){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var cHe={};Dj(cHe,{createAtomBlockMarkdownSpec:()=>uHe,createBlockMarkdownSpec:()=>dHe,createInlineMarkdownSpec:()=>pHe,parseAttributes:()=>Hj,parseIndentedBlocks:()=>JP,renderNestedMarkdownContent:()=>Vj,serializeAttributes:()=>$j});function Hj(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const 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(([,u,d])=>{var f;const g=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),m=n[g];m&&(e[u]=m.slice(1,-1))});const l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function $j(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 uHe(t){const{nodeName:e,name:n,parseAttributes:r=Hj,serializeAttributes:i=$j,defaultAttributes:s={},requiredAttributes:a=[],allowedAttributes:o}=t,l=n||e,u=d=>{if(!o)return d;const f={};return o.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...s,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(f=d.match(g))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,g){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(m);if(!x)return;const y=x[1]||"",v=r(y);if(!a.find(E=>!(E in v)))return{type:e,raw:x[0],attributes:v}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),m=g?` {${g}}`:"";return`:::${l}${m} :::`}}}function dHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Hj,serializeAttributes:s=$j,defaultAttributes:a={},content:o="block",allowedAttributes:l}=t,u=n||e,d=f=>{if(!l)return f;const g={};return l.forEach(m=>{m in f&&(g[m]=f[m])}),g};return{parseMarkdown:(f,g)=>{let m;if(r){const y=r(f);m=typeof y=="string"?[{type:"text",text:y}]:y}else o==="block"?m=g.parseChildren(f.tokens||[]):m=g.parseInline(f.tokens||[]);const x={...a,...f.attributes};return g.createNode(e,x,m)},markdownTokenizer:{name:e,level:"block",start(f){var g;const m=new RegExp(`^:::${u}`,"m"),x=(g=f.match(m))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(f,g,m){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=f.match(y);if(!v)return;const[b,E=""]=v,S=i(E);let A=1;const T=b.length;let k="";const N=/^:::([\w-]*)(\s.*)?/gm,I=f.slice(T);for(N.lastIndex=0;;){const C=N.exec(I);if(C===null)break;const D=C.index,F=C[1];if(!((x=C[2])!=null&&x.endsWith(":::"))){if(F)A+=1;else if(A-=1,A===0){const j=I.slice(0,D);k=j.trim();const q=f.slice(0,T+D+C[0].length);let R=[];if(k)if(o==="block")for(R=m.blockTokens(j),R.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=m.inlineTokens(W.text))});R.length>0;){const W=R[R.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))R.pop();else break}else R=m.inlineTokens(k);return{type:e,raw:q,attributes:S,content:k,tokens:R}}}}}},renderMarkdown:(f,g)=>{const m=d(f.attrs||{}),x=s(m),y=x?` {${x}}`:"",v=g.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${v}
- :::`}}}function hHe(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 fHe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function pHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=hHe,serializeAttributes:s=fHe,defaultAttributes:a={},selfClosing:o=!1,allowedAttributes:l}=t,u=n||e,d=g=>{if(!l)return g;const m={};return l.forEach(x=>{x in g&&(m[x]=g[x])}),m},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,m)=>{const x={...a,...g.attributes};if(o)return m.createNode(e,x);const y=r?r(g):g.content||"";return y?m.createNode(e,x,[m.createTextNode(y)]):m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const m=o?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=g.match(m),y=x?.index;return y!==void 0?y:-1},tokenize(g,m,x){const y=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),v=g.match(y);if(!v)return;let b="",E="";if(o){const[,A]=v;E=A}else{const[,A,T]=v;E=A,b=T||""}const S=i(E.trim());return{type:e,raw:v[0],content:b.trim(),attributes:S}}},renderMarkdown:g=>{let m="";r?m=r(g):g.content&&g.content.length>0&&(m=g.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const x=d(g.attrs||{}),y=s(x),v=y?` ${y}`:"";return o?`[${u}${v}]`:`[${u}${v}]${m}[/${u}]`}}}function JP(t,e,n){var r,i,s,a;const o=t.split(`
- `),l=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<o.length;){const g=o[d],m=g.match(e.itemPattern);if(!m){if(l.length>0)break;if(g.trim()===""){d+=1,u=`${u}${g}
- `;continue}else return}const x=e.extractItemData(m),{indentLevel:y,mainContent:v}=x;u=`${u}${g}
- `;const b=[v];for(d+=1;d<o.length;){const T=o[d];if(T.trim()===""){const N=o.slice(d+1).findIndex(D=>D.trim()!=="");if(N===-1)break;if((((i=(r=o[d+1+N].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){b.push(T),u=`${u}${T}
- `,d+=1;continue}else break}if((((a=(s=T.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:a.length)||0)>y)b.push(T),u=`${u}${T}
- `,d+=1;else break}let E;const S=b.slice(1);if(S.length>0){const T=S.map(k=>k.slice(y+f)).join(`
- `);T.trim()&&(e.customNestedParser?E=e.customNestedParser(T):E=n.blockTokens(T))}const A=e.createToken(x,E);l.push(A)}if(l.length!==0)return{items:l,raw:u}}function Vj(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(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(g=>g?e.indent(g):"").join(`
- `);l.push(f)}}),l.join(`
- `)}function mHe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,a=t;i.descendants((o,l)=>{const u=s.mapping.map(l),d=s.mapping.map(l)+o.nodeSize;let f=null;if(o.marks.forEach(m=>{if(m!==a)return!1;f=m}),!f)return;let g=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(g=!0)}),g){const m=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,m)}}),s.docChanged&&e.view.dispatch(s)}var Qs=class tee extends Bj{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new tee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function sf(t){return new Y8e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=In(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 u=n.to;if(o){const d=l.search(/\S/),f=n.from+l.indexOf(o),g=f+o.length;if(zj(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(v=>v===t.type&&v!==x.mark.type)).filter(x=>x.to>f).length)return null;g<n.to&&a.delete(g,n.to),f>n.from&&a.delete(n.from+d,f),u=n.from+d+o.length,a.addMark(n.from+d,u,t.type.create(s||{})),a.removeStoredMark(t.type)}}})}var VN,N9;function gHe(){return N9||(N9=1,VN=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}),VN}var xHe=gHe();const bHe=lo(xHe);var vHe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},yHe=({contentComponent:t})=>{const e=vR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return c.jsx(c.Fragment,{children:Object.values(e)})};function _He(){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]:Jse.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 wHe=class extends mr.Component{constructor(t){var e;super(t),this.editorContentRef=mr.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=_He(),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 c.jsxs(c.Fragment,{children:[c.jsx("div",{ref:vHe(e,this.editorContentRef),...n}),t?.contentComponent&&c.jsx(yHe,{contentComponent:t.contentComponent})]})}},SHe=M.forwardRef((t,e)=>{const n=mr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mr.createElement(wHe,{key:n,innerRef:e,...t})}),EHe=mr.memo(SHe),MHe=typeof window<"u"?M.useLayoutEffect:M.useEffect,AHe=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 THe(t){var e;const[n]=M.useState(()=>new AHe(t.editor)),r=J7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:bHe);return MHe(()=>n.watch(t.editor),[t.editor,n]),M.useDebugValue(r),r}var CHe=!1,eR=typeof window>"u",NHe=eR||!!(typeof window<"u"&&window.next),kHe=class nee{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?eR||NHe?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 sHe(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?nee.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 PHe(t={},e=[]){const n=M.useRef(t);n.current=t;const[r]=M.useState(()=>new kHe(n)),i=vR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(i),M.useEffect(r.onRender(e)),THe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var RHe=M.createContext({editor:null});RHe.Consumer;var DHe=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),OHe=()=>M.useContext(DHe);mr.forwardRef((t,e)=>{const{onDragStart:n}=OHe(),r=t.as||"div";return c.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});mr.createContext({markViewContentRef:()=>{}});var qw=(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]},jHe=/^\s*>\s$/,LHe=Qs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return qw("blockquote",{...Rr(this.options.HTMLAttributes,t),children:qw("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[jm({find:jHe,type:this.type})]}}),IHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,UHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,FHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,zHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,BHe=Sd.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 qw("strong",{...Rr(this.options.HTMLAttributes,t),children:qw("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[Om({find:IHe,type:this.type}),Om({find:FHe,type:this.type})]},addPasteRules(){return[sf({find:UHe,type:this.type}),sf({find:zHe,type:this.type})]}}),HHe=/(^|[^`])`([^`]+)`(?!`)$/,$He=/(^|[^`])`([^`]+)`(?!`)/g,VHe=Sd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Rr(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[Om({find:HHe,type:this.type})]},addPasteRules(){return[sf({find:$He,type:this.type})]}}),GN=4,GHe=/^```([a-z]+)?[\s\n]$/,WHe=/^~~~([a-z]+)?[\s\n]$/,qHe=Qs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:GN,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",Rr(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:GN,{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:u,to:d}=i,m=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>o+x).join(`
- `);return l.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:GN,{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:u}=s,d=s.start(),f=s.end(),m=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,y=0;const v=u-d;for(let k=0;k<m.length;k+=1){if(y+m[k].length>=v){x=k;break}y+=m[k].length+1}const E=((l=m[x].match(/^ */))==null?void 0:l[0])||"",S=Math.min(E.length,n);if(S===0)return!0;let A=d;for(let k=0;k<x;k+=1)A+=m[k].length+1;return o.delete(A,A+S),u-A<=S&&o.setSelection(qt.create(o.doc,A)),!0}):t.commands.command(({tr:o})=>{const{from:l,to:u}=i,g=r.doc.textBetween(l,u,`
- `,`
- `).split(`
- `).map(m=>{var x;const y=((x=m.match(/^ */))==null?void 0:x[0])||"",v=Math.min(y.length,n);return m.slice(v)}).join(`
- `);return o.replaceWith(l,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const 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:u})=>(u.setSelection(ln.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[QP({find:GHe,type:this.type,getAttributes:t=>({language:t[1]})}),QP({find:WHe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Er({key:new _i("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(qt.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),KHe=Qs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),XHe=Qs.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",Rr(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:u,dispatch:d})=>{if(d&&l&&a){const f=l.filter(g=>o.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),YHe=Qs.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]}`,Rr(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=>QP({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),ZHe=Qs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Rr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!lHe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return FJ(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,u=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?a.setSelection(qt.create(a.doc,l.pos+1)):l.nodeAfter.isBlock?a.setSelection(Ht.create(a.doc,l.pos)):a.setSelection(qt.create(a.doc,l.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,f=d?.create();f&&(a.insert(u,f),a.setSelection(qt.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[eee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),QHe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,JHe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,e$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,t$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,n$e=Sd.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",Rr(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[Om({find:QHe,type:this.type}),Om({find:e$e,type:this.type})]},addPasteRules(){return[sf({find:JHe,type:this.type}),sf({find:t$e,type:this.type})]}});const r$e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",i$e="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",tR="numeric",nR="ascii",rR="alpha",Yx="asciinumeric",Ox="alphanumeric",iR="domain",ree="emoji",s$e="scheme",a$e="slashscheme",WN="whitespace";function o$e(t,e){return t in e||(e[t]=[]),e[t]}function gh(t,e,n){e[tR]&&(e[Yx]=!0,e[Ox]=!0),e[nR]&&(e[Yx]=!0,e[rR]=!0),e[Yx]&&(e[Ox]=!0),e[rR]&&(e[Ox]=!0),e[Ox]&&(e[iR]=!0),e[ree]&&(e[iR]=!0);for(const r in e){const i=o$e(r,n);i.indexOf(t)<0&&i.push(t)}}function l$e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function $s(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}$s.groups={};$s.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||$s.groups;let i;return e&&e.j?i=e:(i=new $s(e),n&&r&&gh(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||$s.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 $s,Object.assign(a.j,o.j),a.jr.push.apply(a.jr,o.jr),a.jd=o.jd,a.t=o.t):a=new $s,s){if(r)if(a.t&&typeof a.t=="string"){const l=Object.assign(l$e(a.t,r),n);gh(s,l,r)}else n&&gh(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),Cr=(t,e,n,r,i)=>t.tr(e,n,r,i),k9=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),ic="WORD",sR="UWORD",iee="ASCIINUMERICAL",see="ALPHANUMERICAL",J0="LOCALHOST",aR="TLD",oR="UTLD",u1="SCHEME",Fp="SLASH_SCHEME",Gj="NUM",lR="WS",Wj="NL",Zx="OPENBRACE",Qx="CLOSEBRACE",Kw="OPENBRACKET",Xw="CLOSEBRACKET",Yw="OPENPAREN",Zw="CLOSEPAREN",Qw="OPENANGLEBRACKET",Jw="CLOSEANGLEBRACKET",eS="FULLWIDTHLEFTPAREN",tS="FULLWIDTHRIGHTPAREN",nS="LEFTCORNERBRACKET",rS="RIGHTCORNERBRACKET",iS="LEFTWHITECORNERBRACKET",sS="RIGHTWHITECORNERBRACKET",aS="FULLWIDTHLESSTHAN",oS="FULLWIDTHGREATERTHAN",lS="AMPERSAND",cS="APOSTROPHE",uS="ASTERISK",ku="AT",dS="BACKSLASH",hS="BACKTICK",fS="CARET",Lu="COLON",qj="COMMA",pS="DOLLAR",Yo="DOT",mS="EQUALS",Kj="EXCLAMATION",za="HYPHEN",Jx="PERCENT",gS="PIPE",xS="PLUS",bS="POUND",e0="QUERY",Xj="QUOTE",aee="FULLWIDTHMIDDLEDOT",Yj="SEMI",Zo="SLASH",t0="TILDE",vS="UNDERSCORE",oee="EMOJI",yS="SYM";var lee=Object.freeze({__proto__:null,ALPHANUMERICAL:see,AMPERSAND:lS,APOSTROPHE:cS,ASCIINUMERICAL:iee,ASTERISK:uS,AT:ku,BACKSLASH:dS,BACKTICK:hS,CARET:fS,CLOSEANGLEBRACKET:Jw,CLOSEBRACE:Qx,CLOSEBRACKET:Xw,CLOSEPAREN:Zw,COLON:Lu,COMMA:qj,DOLLAR:pS,DOT:Yo,EMOJI:oee,EQUALS:mS,EXCLAMATION:Kj,FULLWIDTHGREATERTHAN:oS,FULLWIDTHLEFTPAREN:eS,FULLWIDTHLESSTHAN:aS,FULLWIDTHMIDDLEDOT:aee,FULLWIDTHRIGHTPAREN:tS,HYPHEN:za,LEFTCORNERBRACKET:nS,LEFTWHITECORNERBRACKET:iS,LOCALHOST:J0,NL:Wj,NUM:Gj,OPENANGLEBRACKET:Qw,OPENBRACE:Zx,OPENBRACKET:Kw,OPENPAREN:Yw,PERCENT:Jx,PIPE:gS,PLUS:xS,POUND:bS,QUERY:e0,QUOTE:Xj,RIGHTCORNERBRACKET:rS,RIGHTWHITECORNERBRACKET:sS,SCHEME:u1,SEMI:Yj,SLASH:Zo,SLASH_SCHEME:Fp,SYM:yS,TILDE:t0,TLD:aR,UNDERSCORE:vS,UTLD:oR,UWORD:sR,WORD:ic,WS:lR});const ec=/[a-z]/,wx=new RegExp("\\p{L}","u"),qN=new RegExp("\\p{Emoji}","u"),tc=/\d/,KN=/\s/,P9="\r",XN=`
- `,c$e="️",u$e="",YN="";let O_=null,j_=null;function d$e(t=[]){const e={};$s.groups=e;const n=new $s;O_==null&&(O_=R9(r$e)),j_==null&&(j_=R9(i$e)),gt(n,"'",cS),gt(n,"{",Zx),gt(n,"}",Qx),gt(n,"[",Kw),gt(n,"]",Xw),gt(n,"(",Yw),gt(n,")",Zw),gt(n,"<",Qw),gt(n,">",Jw),gt(n,"(",eS),gt(n,")",tS),gt(n,"「",nS),gt(n,"」",rS),gt(n,"『",iS),gt(n,"』",sS),gt(n,"<",aS),gt(n,">",oS),gt(n,"&",lS),gt(n,"*",uS),gt(n,"@",ku),gt(n,"`",hS),gt(n,"^",fS),gt(n,":",Lu),gt(n,",",qj),gt(n,"$",pS),gt(n,".",Yo),gt(n,"=",mS),gt(n,"!",Kj),gt(n,"-",za),gt(n,"%",Jx),gt(n,"|",gS),gt(n,"+",xS),gt(n,"#",bS),gt(n,"?",e0),gt(n,'"',Xj),gt(n,"/",Zo),gt(n,";",Yj),gt(n,"~",t0),gt(n,"_",vS),gt(n,"\\",dS),gt(n,"・",aee);const r=Cr(n,tc,Gj,{[tR]:!0});Cr(r,tc,r);const i=Cr(r,ec,iee,{[Yx]:!0}),s=Cr(r,wx,see,{[Ox]:!0}),a=Cr(n,ec,ic,{[nR]:!0});Cr(a,tc,i),Cr(a,ec,a),Cr(i,tc,i),Cr(i,ec,i);const o=Cr(n,wx,sR,{[rR]:!0});Cr(o,ec),Cr(o,tc,s),Cr(o,wx,o),Cr(s,tc,s),Cr(s,ec),Cr(s,wx,s);const l=gt(n,XN,Wj,{[WN]:!0}),u=gt(n,P9,lR,{[WN]:!0}),d=Cr(n,KN,lR,{[WN]:!0});gt(n,YN,d),gt(u,XN,l),gt(u,YN,d),Cr(u,KN,d),gt(d,P9),gt(d,XN),Cr(d,KN,d),gt(d,YN,d);const f=Cr(n,qN,oee,{[ree]:!0});gt(f,"#"),Cr(f,qN,f),gt(f,c$e,f);const g=gt(f,u$e);gt(g,"#"),Cr(g,qN,f);const m=[[ec,a],[tc,i]],x=[[ec,null],[wx,o],[tc,s]];for(let y=0;y<O_.length;y++)Su(n,O_[y],aR,ic,m);for(let y=0;y<j_.length;y++)Su(n,j_[y],oR,sR,x);gh(aR,{tld:!0,ascii:!0},e),gh(oR,{utld:!0,alpha:!0},e),Su(n,"file",u1,ic,m),Su(n,"mailto",u1,ic,m),Su(n,"http",Fp,ic,m),Su(n,"https",Fp,ic,m),Su(n,"ftp",Fp,ic,m),Su(n,"ftps",Fp,ic,m),gh(u1,{scheme:!0,ascii:!0},e),gh(Fp,{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],E=t[y][1]?{[s$e]:!0}:{[a$e]:!0};v.indexOf("-")>=0?E[iR]=!0:ec.test(v)?tc.test(v)?E[Yx]=!0:E[nR]=!0:E[tR]=!0,k9(n,v,v,E)}return k9(n,"localhost",J0,{ascii:!0}),n.jd=new $s(yS),{start:n,tokens:Object.assign({groups:e},lee)}}function cee(t,e){const n=h$e(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,u=0,d=null,f=-1,g=-1;for(;a<r&&(l=o.go(n[a]));)o=l,o.accepts()?(f=0,g=0,d=o):f>=0&&(f+=n[a].length,g++),u+=n[a].length,s+=n[a].length,a++;s-=f,a-=g,u-=f,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function h$e(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 Su(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 $s(r),s.jr=i.slice(),t.j[l]=s),t=s}return s=new $s(n),s.jr=i.slice(),t.j[e[a-1]]=s,s}function R9(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 eb={defaultProtocol:"http",events:null,format:D9,formatHref:D9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Zj(t,e=null){let n=Object.assign({},eb);t&&(n=Object.assign(n,t instanceof Zj?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}Zj.prototype={o:eb,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]:eb[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 D9(t){return t}function uee(t,e){this.t="token",this.v=t,this.tk=e}uee.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=eb.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),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return a.href=r,o&&(a.class=o),l&&(a.target=l),u&&(a.rel=u),d&&Object.assign(a,d),{tagName:i,attributes:a,content:s,eventListeners:f}}};function tM(t,e){class n extends uee{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 O9=tM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),j9=tM("text"),f$e=tM("nl"),L_=tM("url",{isLink:!0,toHref(t=eb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==J0&&t[1].t===Lu}}),La=t=>new $s(t);function p$e({groups:t}){const e=t.domain.concat([lS,uS,ku,dS,hS,fS,pS,mS,za,Gj,Jx,gS,xS,bS,Zo,yS,t0,vS]),n=[cS,Lu,qj,Yo,Kj,Jx,e0,Xj,Yj,Qw,Jw,Zx,Qx,Xw,Kw,Yw,Zw,eS,tS,nS,rS,iS,sS,aS,oS],r=[lS,cS,uS,dS,hS,fS,pS,mS,za,Zx,Qx,Jx,gS,xS,bS,e0,Zo,yS,t0,vS],i=La(),s=gt(i,t0);rn(s,r,s),rn(s,t.domain,s);const a=La(),o=La(),l=La();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 u=gt(a,ku);gt(s,ku,u),gt(o,ku,u),gt(l,ku,u);const d=gt(s,Yo);rn(d,r,s),rn(d,t.domain,s);const f=La();rn(u,t.domain,f),rn(f,t.domain,f);const g=gt(f,Yo);rn(g,t.domain,f);const m=La(O9);rn(g,t.tld,m),rn(g,t.utld,m),gt(u,J0,m);const x=gt(f,za);gt(x,za,x),rn(x,t.domain,f),rn(m,t.domain,f),gt(m,Yo,g),gt(m,za,x);const y=gt(m,Lu);rn(y,t.numeric,O9);const v=gt(a,za),b=gt(a,Yo);gt(v,za,v),rn(v,t.domain,a),rn(b,r,s),rn(b,t.domain,a);const E=La(L_);rn(b,t.tld,E),rn(b,t.utld,E),rn(E,t.domain,a),rn(E,r,s),gt(E,Yo,b),gt(E,za,v),gt(E,ku,u);const S=gt(E,Lu),A=La(L_);rn(S,t.numeric,A);const T=La(L_),k=La();rn(T,e,T),rn(T,n,k),rn(k,e,T),rn(k,n,k),gt(E,Zo,T),gt(A,Zo,T);const N=gt(o,Lu),I=gt(l,Lu),C=gt(I,Zo),D=gt(C,Zo);rn(o,t.domain,a),gt(o,Yo,b),gt(o,za,v),rn(l,t.domain,a),gt(l,Yo,b),gt(l,za,v),rn(N,t.domain,T),gt(N,Zo,T),gt(N,e0,T),rn(D,t.domain,T),rn(D,e,T),gt(D,Zo,T);const F=[[Zx,Qx],[Kw,Xw],[Yw,Zw],[Qw,Jw],[eS,tS],[nS,rS],[iS,sS],[aS,oS]];for(let j=0;j<F.length;j++){const[q,R]=F[j],W=gt(T,q);gt(k,q,W),gt(W,R,T);const K=La(L_);rn(W,e,K);const V=La();rn(W,n),rn(K,e,K),rn(K,n,V),rn(V,e,K),rn(V,n,V),gt(K,R,T),gt(V,R,T)}return gt(i,J0,E),gt(i,Wj,f$e),{start:i,tokens:lee}}function m$e(t,e,n){let r=n.length,i=0,s=[],a=[];for(;i<r;){let o=t,l=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(l=o.go(n[i].t));)a.push(n[i++]);for(;i<r&&(u=l||o.go(n[i].t));)l=null,o=u,o.accepts()?(g=0,f=o):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(a.push(n[i]),i++);else{a.length>0&&(s.push(ZN(j9,e,a)),a=[]),i-=g,d-=g;const m=f.t,x=n.slice(i-d,i);s.push(ZN(m,e,x))}}return a.length>0&&s.push(ZN(j9,e,a)),s}function ZN(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 g$e=typeof console<"u"&&console&&console.warn||(()=>{}),x$e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",cr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function b$e(){return $s.groups={},cr.scanner=null,cr.parser=null,cr.tokenQueue=[],cr.pluginQueue=[],cr.customSchemes=[],cr.initialized=!1,cr}function L9(t,e=!1){if(cr.initialized&&g$e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${x$e}`),!/^[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`);cr.customSchemes.push([t,e])}function v$e(){cr.scanner=d$e(cr.customSchemes);for(let t=0;t<cr.tokenQueue.length;t++)cr.tokenQueue[t][1]({scanner:cr.scanner});cr.parser=p$e(cr.scanner.tokens);for(let t=0;t<cr.pluginQueue.length;t++)cr.pluginQueue[t][1]({scanner:cr.scanner,parser:cr.parser});return cr.initialized=!0,cr}function Qj(t){return cr.initialized||v$e(),m$e(cr.parser.start,t,cee(cr.scanner.start,t))}Qj.scan=cee;function dee(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 Zj(n),i=Qj(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 Jj="[\0- -\u2029 ]",y$e=new RegExp(Jj),_$e=new RegExp(`${Jj}$`),w$e=new RegExp(Jj,"g");function S$e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function E$e(t){return new Er({key:new _i("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),s=e.some(u=>u.getMeta("preventAutolink"));if(!i||s)return;const{tr:a}=r,o=PJ(n.doc,[...e]);if(UJ(o).forEach(({newRange:u})=>{const d=c8e(r.doc,u,m=>m.isTextblock);let f,g;if(d.length>1)f=d[0],g=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!_$e.test(m))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const m=g.split(y$e).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],y=f.pos+g.lastIndexOf(x);if(!x)return!1;const v=Qj(x).map(b=>b.toObject(t.defaultProtocol));if(!S$e(v))return!1;v.filter(b=>b.isLink).map(b=>({...b,from:y+b.start+1,to:y+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{zj(b.from,b.to,r.doc).some(E=>E.mark.type===t.type)||a.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!a.steps.length)return a}})}function M$e(t){return new Er({key:new _i("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let a=null;if(r.target instanceof HTMLAnchorElement)a=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;a=f.find(g=>g.nodeName==="A")}if(!a)return!1;const o=IJ(e.state,t.type.name),l=(i=a?.href)!=null?i:o.href,u=(s=a?.target)!=null?s:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),a&&l?(window.open(l,u),!0):!1}}})}function A$e(t){return new Er({key:new _i("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:a}=s,{empty:o}=a;if(o)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const u=dee(l,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function Zd(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(w$e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var hee=Sd.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"){L9(t);return}L9(t.scheme,t.optionalSlashes)})},onDestroy(){b$e()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Zd(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=>!!Zd(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=>!!Zd(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Rr(this.options.HTMLAttributes,t),0]:["a",Rr(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=>!!Zd(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=>!!Zd(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[sf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=dee(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:a=>!!Zd(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(E$e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Zd(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(M$e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(A$e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),T$e=hee,C$e=Object.defineProperty,N$e=(t,e)=>{for(var n in e)C$e(t,n,{get:e[n],enumerable:!0})},k$e="listItem",I9="textStyle",U9=/^\s*([-+*])\s$/,fee=Qs.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",Rr(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(k$e,this.editor.getAttributes(I9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=jm({find:U9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=jm({find:U9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(I9),editor:this.editor})),[t]}}),pee=Qs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Rr(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)=>Vj(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)}}}),P$e={};N$e(P$e,{findListItemPos:()=>Wb,getNextListDepth:()=>eL,handleBackspace:()=>cR,handleDelete:()=>uR,hasListBefore:()=>mee,hasListItemAfter:()=>R$e,hasListItemBefore:()=>gee,listItemHasSubList:()=>xee,nextListIsDeeper:()=>bee,nextListIsHigher:()=>vee});var Wb=(t,e)=>{const{$from:n}=e.selection,r=ri(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}},eL=(t,e)=>{const n=Wb(t,e);if(!n)return!1;const[,r]=v8e(e,t,n.$pos.pos+4);return r},mee=(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))},gee=(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)},xee=(t,e,n)=>{if(!n)return!1;const r=ri(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},cR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!fd(t.state,e)&&mee(t.state,e,n)){const{$anchor:o}=t.state.selection,l=t.state.doc.resolve(o.before()-1),u=[];l.node().descendants((g,m)=>{g.type.name===e&&u.push({node:g,pos:m})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(l.start()+d.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!fd(t.state,e)||!S8e(t.state))return!1;const r=Wb(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=xee(e,t.state,s);return gee(e,t.state)&&!a?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},bee=(t,e)=>{const n=eL(t,e),r=Wb(t,e);return!r||!n?!1:n>r.depth},vee=(t,e)=>{const n=eL(t,e),r=Wb(t,e);return!r||!n?!1:n<r.depth},uR=(t,e)=>{if(!fd(t.state,e)||!w8e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:bee(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():vee(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},R$e=(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)},yee=Zn.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&&uR(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&&uR(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&&cR(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&&cR(t,n,r)&&(e=!0)}),e}}}}),F9=/^(\s*)(\d+)\.\s+(.*)$/,D$e=/^\s/;function O$e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(F9);if(!s)break;const[,a,o,l]=s,u=a.length;let d=l,f=n+1;const g=[i];for(;f<t.length;){const m=t[f];if(m.match(F9))break;if(m.trim()==="")g.push(m),d+=`
- `,f+=1;else if(m.match(D$e))g.push(m),d+=`
- ${m.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(o,10),content:d.trim(),raw:g.join(`
- `)}),r=f,n=f}return[e,r]}function _ee(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())||"",u=[];l&&u.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const d=o.slice(1).join(`
- `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let f=s+1;const g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const m=Math.min(...g.map(y=>y.indent)),x=_ee(g,m,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:a.raw,tokens:u}),s=f}else s+=1}return i}function j$e(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 L$e="listItem",z9="textStyle",B9=/^(\d+)\.\s$/,wee=Qs.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",Rr(this.options.HTMLAttributes,n),0]:["ol",Rr(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?j$e(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]=O$e(i);if(s.length===0)return;const o=_ee(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(L$e,this.editor.getAttributes(z9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=jm({find:B9,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=jm({find:B9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(z9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),I$e=/^\s*(\[([( |x])?\])\s$/,U$e=Qs.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",Rr(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 Vj(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"),u=d=>{var f,g;o.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),s.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const m=n();if(typeof m!="number")return!1;const x=g.doc.nodeAt(m);return g.setNodeMarkup(m,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,s.append(o,a),i.append(s,l),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:l,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[jm({find:I$e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),F$e=Qs.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",Rr(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=JP(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=JP(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()}}});Zn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(fee.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(pee.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(yee.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(wee.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(U$e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(F$e.configure(this.options.taskList)),t}});var z$e=Qs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Rr(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()}}}),B$e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,H$e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,$$e=Sd.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",Rr(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[Om({find:B$e,type:this.type})]},addPasteRules(){return[sf({find:H$e,type:this.type})]}}),V$e=Qs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),See=Sd.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",Rr(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()}}}),G$e=See;function W$e(t={}){return new Er({view(e){return new q$e(e,t)}})}class q$e{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 f=e.nodeBefore,g=e.nodeAfter;if(f||g){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let x=m.getBoundingClientRect(),y=f?x.bottom:x.top;f&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*o;r={left:x.left,right:x.right,top:y-v,bottom:y+v}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*a;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=l.getBoundingClientRect(),g=f.width/l.offsetWidth,m=f.height/l.offsetHeight;u=f.left-l.scrollLeft*g,d=f.top-l.scrollTop*m}this.element.style.left=(r.left-u)/a+"px",this.element.style.top=(r.top-d)/o+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let a=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=SQ(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 kr extends ln{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return kr.valid(r)?new kr(r):ln.near(r)}content(){return Ct.empty}eq(e){return e instanceof kr&&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 kr(e.resolve(n.pos))}getBookmark(){return new tL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!K$e(e)||!X$e(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&&kr.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(kr.valid(l))return l}for(;;){let a=n>0?s.firstChild:s.lastChild;if(!a){if(s.isAtom&&!s.isText&&!Ht.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=a,i+=n;let o=e.doc.resolve(i);if(kr.valid(o))return o}return null}}}kr.prototype.visible=!1;kr.findFrom=kr.findGapCursorFrom;ln.jsonID("gapcursor",kr);class tL{constructor(e){this.pos=e}map(e){return new tL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return kr.valid(n)?new kr(n):ln.near(n)}}function Eee(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function K$e(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||Eee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function X$e(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||Eee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y$e(){return new Er({props:{decorations:eVe,createSelectionBetween(t,e,n){return e.pos==n.pos&&kr.valid(n)?new kr(n):null},handleClick:Q$e,handleKeyDown:Z$e,handleDOMEvents:{beforeinput:J$e}}})}const Z$e=SJ({ArrowLeft:I_("horiz",-1),ArrowRight:I_("horiz",1),ArrowUp:I_("vert",-1),ArrowDown:I_("vert",1)});function I_(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 qt){if(!s.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=kr.findGapCursorFrom(o,e,l);return u?(i&&i(r.tr.setSelection(new kr(u))),!0):!1}}function Q$e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!kr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ht.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new kr(r))),!0)}function J$e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof kr))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 Ct(i,0,0));return s.setSelection(qt.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function eVe(t){if(!(t.selection instanceof kr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",vr.create(t.doc,[Ms.widget(t.selection.head,e,{key:"gapcursor"})])}var _S=200,Li=function(){};Li.prototype.append=function(e){return e.length?(e=Li.from(e),!this.length&&e||e.length<_S&&this.leafAppend(e)||this.length<_S&&e.leafPrepend(this)||this.appendInner(e)):this};Li.prototype.prepend=function(e){return e.length?Li.from(e).append(this):this};Li.prototype.appendInner=function(e){return new tVe(this,e)};Li.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Li.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Li.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Li.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)};Li.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};Li.from=function(e){return e instanceof Li?e:e&&e.length?new Mee(e):Li.empty};var Mee=(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<=_S)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=_S)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})(Li);Li.empty=new Mee([]);var tVe=(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})(Li);const nVe=500;class To{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,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),s=i.maps.length),s--,d.push(f);return}if(i){d.push(new Qo(f.map));let m=f.step.map(i.slice(s)),x;m&&a.maybeStep(m).doc&&(x=a.mapping.maps[a.mapping.maps.length-1],u.push(new Qo(x,void 0,void 0,u.length+d.length))),s--,x&&i.appendMap(x,s)}else a.maybeStep(f.step);if(f.selection)return o=i?f.selection.map(i.slice(s)):f.selection,l=new To(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:a,selection:o}}addTransform(e,n,r,i){let s=[],a=this.eventCount,o=this.items,l=!i&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new Qo(e.mapping.maps[d],f,n),m;(m=l&&l.merge(g))&&(g=m,d?s.pop():o=o.slice(0,o.length-1)),s.push(g),n&&(a++,n=void 0),i||(l=g)}let u=a-r.depth;return u>iVe&&(o=rVe(o,u),a-=u),new To(o.append(s),a)}remapping(e,n){let r=new q0;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 To(this.items.append(e.map(n=>new Qo(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,a=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let l=n;this.items.forEach(g=>{let m=s.getMirror(--l);if(m==null)return;a=Math.min(a,m);let x=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 Qo(x,y,v))}else r.push(new Qo(x))},i);let u=[];for(let g=n;g<a;g++)u.push(new Qo(s.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new To(d,o);return f.emptyItemCount()>nVe&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],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)),u=l&&l.getMap();if(r--,u&&n.appendMap(u,r),l){let d=a.selection&&a.selection.map(n.slice(r));d&&s++;let f=new Qo(u.invert(),l,d),g,m=i.length-1;(g=i.length&&i[m].merge(f))?i[m]=g:i.push(f)}}else a.map&&r--},this.items.length,0),new To(Li.from(i.reverse()),s)}}To.empty=new To(Li.empty,0);function rVe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Qo{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Qo(n.getMap().invert(),n,this.selection)}}}class Pu{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const iVe=20;function sVe(t,e,n,r){let i=n.getMeta(Rh),s;if(i)return i.historyState;n.getMeta(lVe)&&(t=new Pu(t.done,t.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(a&&a.getMeta(Rh))return a.getMeta(Rh).redo?new Pu(t.done.addTransform(n,void 0,r,d1(e)),t.undone,H9(n.mapping.maps),t.prevTime,t.prevComposition):new Pu(t.done,t.undone.addTransform(n,void 0,r,d1(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||!aVe(n,t.prevRanges)),u=a?QN(t.prevRanges,n.mapping):H9(n.mapping.maps);return new Pu(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,d1(e)),To.empty,u,n.time,o??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Pu(t.done.rebased(n,s),t.undone.rebased(n,s),QN(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Pu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),QN(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function aVe(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 H9(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 QN(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 oVe(t,e,n){let r=d1(e),i=Rh.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 Pu(n?o:s.remaining,n?s.remaining:o,null,0,-1);return s.transform.setSelection(a).setMeta(Rh,{redo:n,historyState:l})}let JN=!1,$9=null;function d1(t){let e=t.plugins;if($9!=e){JN=!1,$9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){JN=!0;break}}return JN}const Rh=new _i("history"),lVe=new _i("closeHistory");function cVe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Er({key:Rh,state:{init(){return new Pu(To.empty,To.empty,null,0,-1)},apply(e,n,r){return sVe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Tee:r=="historyRedo"?Cee:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Aee(t,e){return(n,r)=>{let i=Rh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=oVe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const Tee=Aee(!1,!0),Cee=Aee(!0,!0);Zn.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 Er({key:new _i("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 u=r.tr.deleteRange(o,l);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),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,u=o-l,d=o;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var uVe=Zn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[W$e(this.options)]}});Zn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Er({key:new _i("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return vr.create(t,[]);let a=0;this.options.mode==="deepest"&&t.descendants((l,u)=>{if(l.isText)return;if(!(i>=u&&i<=u+l.nodeSize-1))return!1;a+=1});let o=0;return t.descendants((l,u)=>{if(l.isText||!(i>=u&&i<=u+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(Ms.node(u,u+l.nodeSize,{class:this.options.className}))}),vr.create(t,s)}}})]}});var dVe=Zn.create({name:"gapCursor",addProseMirrorPlugins(){return[Y$e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=In(Bt(t,"allowGapCursor",n)))!=null?e:null}}});Zn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Er({key:new _i("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,u=!a.isLeaf&&QE(a);if((l||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const f=Ms.node(o,o+a.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:o,hasAnchor:l}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),vr.create(t,i)}}})]}});Zn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Er({key:new _i("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||FJ(n.selection)||t.view.dragging?null:vr.create(n.doc,[Ms.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function V9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var hVe=Zn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new _i(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 Er({key:e,appendTransaction:(i,s,a)=>{const{doc:o,tr:l,schema:u}=a,d=e.getState(a),f=o.content.size,g=u.nodes[n];if(d)return l.insert(f,g.create())},state:{init:(i,s)=>{const a=s.tr.doc.lastChild;return!V9({node:a,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const a=i.doc.lastChild;return!V9({node:a,types:r})}}})]}}),fVe=Zn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Tee(t,e),redo:()=>({state:t,dispatch:e})=>Cee(t,e)}},addProseMirrorPlugins(){return[cVe(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()}}}),pVe=Zn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(BHe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(LHe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(fee.configure(this.options.bulletList)),this.options.code!==!1&&i.push(VHe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(qHe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(KHe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(uVe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(dVe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(XHe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(YHe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(fVe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(ZHe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(n$e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(pee.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(yee.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(hee.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(wee.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(z$e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push($$e.configure(this.options.strike)),this.options.text!==!1&&i.push(V$e.configure(this.options.text)),this.options.underline!==!1&&i.push(See.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(hVe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),mVe=pVe,gVe=Zn.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")}}}),xVe=gVe,bVe=20,Nee=(t,e=0)=>{const n=[];return!t.children.length||e>bVe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Nee(r,e+1))}),n},vVe=t=>{if(!t.children.length)return;const e=Nee(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}`)})},kee=Sd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&vVe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Rr(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}}}}),yVe=Zn.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()}}}),Pee=Zn.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()}}}),_Ve=Zn.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()}}}),wVe=Zn.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()}}}),SVe=Zn.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()}}});Zn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(yVe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Pee.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(_Ve.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(wVe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(SVe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(kee.configure(this.options.textStyle)),t}});var EVe=Pee,MVe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,AVe=Qs.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",Rr(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:"",u=(a=(s=t.attrs)==null?void 0:s.title)!=null?a:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:a})=>{const o=document.createElement("img");Object.entries(a).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:o.setAttribute(d,f);break}}),o.src=a.src;const l=new oHe({element:o,node:i,getPos:s,onResize:(d,f)=>{o.style.width=`${d}px`,o.style.height=`${f}px`},onCommit:(d,f)=>{const g=s();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",o.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},l}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[eee({find:MVe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),TVe=AVe;function G9({content:t,onChange:e,placeholder:n}){const r=PHe({extensions:[mVe.configure({heading:!1,codeBlock:!1,code:!1}),G$e,T$e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),xVe.configure({types:["paragraph"]}),kee,EVe,TVe.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:u})=>c.jsx("button",{type:"button",onClick:a,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:l}),s=()=>{const a=window.prompt("Enter URL:");a&&r.chain().focus().setLink({href:a}).run()};return c.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[c.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[c.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:c.jsx(Kae,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:c.jsx(Sle,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:c.jsx(fue,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),c.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:c.jsx(OR,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:c.jsx(r7,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),c.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:c.jsx(sue,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:c.jsx(tue,{className:"w-4 h-4"})}),c.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:c.jsx(rue,{className:"w-4 h-4"})}),c.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),c.jsx(i,{onClick:s,isActive:r.isActive("link"),title:"Add Link",children:c.jsx(OS,{className:"w-4 h-4"})}),r.isActive("link")&&c.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:c.jsx(c7,{className:"w-4 h-4"})})]}),c.jsx(EHe,{editor:r})]})}function CVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),[i,s]=M.useState(!1),[a,o]=M.useState(null),[l,u]=M.useState({}),{data:d,isLoading:f,error:g}=yt({queryKey:["archive-project-page",t],queryFn:()=>Pe.getArchiveProjectPage(t)}),m=_t({mutationFn:T=>Pe.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});M.useEffect(()=>{const T=k=>{k.key==="Escape"&&(a!==null?o(null):i?b():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[a,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),s(!0)},v=()=>{m.mutate(l)},b=()=>{s(!1),u({})},E=T=>{const k=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],N=new DOMParser().parseFromString(T,"text/html"),I=C=>{if(C.nodeType===Node.TEXT_NODE)return C.textContent||"";if(C.nodeType===Node.ELEMENT_NODE){const D=C,F=D.tagName.toLowerCase();if(!k.includes(F))return Array.from(D.childNodes).map(I).join("");let j="";if(F==="a"&&D.getAttribute("href")){const R=D.getAttribute("href");R?.toLowerCase().startsWith("http")&&(j=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const R=D.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";j=` src="${R}" style="max-width: 100%; height: auto;"`}const q=Array.from(D.childNodes).map(I).join("");return["br","img"].includes(F)?`<${F}${j} />`:`<${F}${j}>${q}</${F}>`}return""};return Array.from(N.body.childNodes).map(I).join("")},S=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=T=>{T.target===T.currentTarget&&n()};return c.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(Za,{className:"w-5 h-5 text-bambu-green"}),c.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&c.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[!i&&S&&c.jsxs(Ie,{variant:"ghost",size:"sm",onClick:y,children:[c.jsx(m0,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&c.jsxs(c.Fragment,{children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),c.jsxs(Ie,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[c.jsx(Co,{className:"w-4 h-4 mr-1"}),"Save"]})]}),c.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&c.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&c.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[c.jsx(Za,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),c.jsx("p",{children:"No project page data found in this 3MF file."}),c.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&S&&c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-4",children:[i?c.jsx("input",{type:"text",value:l.title||"",onChange:T=>u({...l,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&c.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),c.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(C3,{className:"w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:l.designer||"",onChange:T=>u({...l,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[c.jsx(C3,{className:"w-4 h-4"}),c.jsx("span",{children:d.designer}),d.designer_user_id&&c.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:c.jsx(io,{className:"w-3 h-3"})})]}),d.creation_date&&c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[c.jsx(Xr,{className:"w-4 h-4"}),c.jsx("span",{children:d.creation_date})]}),i?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Za,{className:"w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:l.license||"",onChange:T=>u({...l,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[c.jsx(Za,{className:"w-4 h-4"}),c.jsx("span",{children:d.license})]}),d.origin&&c.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?c.jsx(G9,{content:l.description||"",onChange:T=>u({...l,description:T}),placeholder:"Enter description..."}):c.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&c.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?c.jsxs("div",{className:"space-y-2",children:[c.jsx("input",{type:"text",value:l.profile_title||"",onChange:T=>u({...l,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),c.jsx(G9,{content:l.profile_description||"",onChange:T=>u({...l,profile_description:T}),placeholder:"Profile description..."})]}):c.jsxs(c.Fragment,{children:[d.profile_title&&c.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&c.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&c.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[c.jsx(cb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),c.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((T,k)=>c.jsx("button",{onClick:()=>o(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:c.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&c.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[c.jsx(io,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),a!==null&&x[a]&&c.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[c.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,a-1))},disabled:a===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:c.jsx(Ih,{className:"w-6 h-6 text-white"})}),c.jsx("img",{src:x[a].url,alt:x[a].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),c.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(x.length-1,a+1))},disabled:a===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:c.jsx(of,{className:"w-6 h-6 text-white"})}),c.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:c.jsx(Gt,{className:"w-6 h-6 text-white"})}),c.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[a+1," / ",x.length]})]})]})}const NVe=[.25,.5,.75,1,1.5,2,3,4];function kVe({src:t,title:e,downloadFilename:n,onClose:r}){const i=M.useRef(null),[s,a]=M.useState(!0),[o,l]=M.useState(.5),[u,d]=M.useState(0),[f,g]=M.useState(0);M.useEffect(()=>{const S=i.current;S&&(S.playbackRate=o)},[o]),M.useEffect(()=>{const S=A=>{A.key==="Escape"&&r()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r]),M.useEffect(()=>{const S=i.current;if(!S)return;const A=()=>d(S.currentTime),T=()=>g(S.duration),k=()=>a(!0),N=()=>a(!1);return S.addEventListener("timeupdate",A),S.addEventListener("durationchange",T),S.addEventListener("play",k),S.addEventListener("pause",N),()=>{S.removeEventListener("timeupdate",A),S.removeEventListener("durationchange",T),S.removeEventListener("play",k),S.removeEventListener("pause",N)}},[]);const m=()=>{const S=i.current;S&&(s?S.pause():S.play())},x=S=>{const A=i.current;A&&(A.currentTime=parseFloat(S.target.value))},y=()=>{const S=i.current;S&&(S.currentTime=Math.max(0,S.currentTime-5))},v=()=>{const S=i.current;S&&(S.currentTime=Math.min(f,S.currentTime+5))},b=S=>{const A=Math.floor(S/60),T=Math.floor(S%60);return`${A}:${T.toString().padStart(2,"0")}`},E=()=>{const S=document.createElement("a");S.href=t,S.download=n,S.click()};return c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:c.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(qp,{className:"w-5 h-5 text-bambu-green"}),e]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:E,children:[c.jsx(_a,{className:"w-4 h-4"}),"Download"]}),c.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),c.jsxs("div",{className:"p-4",children:[c.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),c.jsxs("div",{className:"mt-4 space-y-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:b(u)}),c.jsx("input",{type:"range",min:0,max:f||100,value:u,onChange:x,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-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`}),c.jsx("span",{className:"text-xs text-bambu-gray w-12",children:b(f)})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:c.jsx(Hce,{className:"w-5 h-5 text-bambu-gray"})}),c.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:s?c.jsx(uce,{className:"w-5 h-5 text-white"}):c.jsx(jS,{className:"w-5 h-5 text-white"})}),c.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:c.jsx(w1,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),c.jsx("div",{className:"flex gap-1",children:NVe.map(S=>c.jsxs("button",{onClick:()=>l(S),className:`px-2 py-1 text-xs rounded transition-colors ${o===S?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[S,"x"]},S))})]})]})]})]})]})})}function PVe({archiveId:t,archiveName:e,onClose:n}){const r=En(),{showToast:i}=ii(),[s,a]=M.useState(null),[o,l]=M.useState("asap"),[u,d]=M.useState(""),[f,g]=M.useState(!1),[m,x]=M.useState(!1),{data:y}=yt({queryKey:["printers"],queryFn:()=>Pe.getPrinters()});M.useEffect(()=>{y?.length===1&&!s&&a(y[0].id)},[y,s]),M.useEffect(()=>{const S=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]);const v=_t({mutationFn:S=>Pe.addToQueue(S),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:S=>{i(S.message||"Failed to add to queue","error")}}),b=S=>{if(S.preventDefault(),!s){i("Please select a printer","error");return}const A={printer_id:s,archive_id:t,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u&&(A.scheduled_time=new Date(u).toISOString()),v.mutate(A)},E=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:c.jsx(kt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),c.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),c.jsx("p",{className:"text-white font-medium truncate",children:e})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?c.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[c.jsx(jo,{className:"w-4 h-4"}),"No printers configured"]}):c.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:S=>a(S.target.value?Number(S.target.value):null),required:!0,children:[c.jsx("option",{value:"",children:"Select printer..."}),y?.map(S=>c.jsx("option",{value:S.id,children:S.name},S.id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),c.jsxs("div",{className:"flex gap-2",children:[c.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:[c.jsx(ni,{className:"w-4 h-4"}),"ASAP (when idle)"]}),c.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:[c.jsx(Xr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),c.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:E(),required:!0})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[c.jsx(gd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),c.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."}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",disabled:v.isPending||!s||y?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function RVe({archiveIds:t,onClose:e}){M.useEffect(()=>{const s=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e]);const{data:n,isLoading:r,error:i}=yt({queryKey:["archive-comparison",t],queryFn:()=>Pe.compareArchives(t)});return c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:s=>s.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?c.jsxs("div",{className:"text-center py-12 text-red-400",children:[c.jsx(Jr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),c.jsx("p",{children:"Failed to load comparison"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?c.jsx(DVe,{comparison:n}):null}),c.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:c.jsx(Ie,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function DVe({comparison:t}){return c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{className:"overflow-x-auto",children:c.jsxs("table",{className:"w-full",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>c.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[c.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),c.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),c.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>c.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[c.jsx("td",{className:"py-2 pr-4 text-sm",children:c.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&c.jsx(Jr,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),c.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>c.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??c.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&c.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&c.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[c.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[c.jsx(Jr,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),c.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>c.jsxs("li",{children:[c.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&c.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?c.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[c.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[c.jsx(Lh,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),c.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[c.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),c.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?c.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>c.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[c.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",c.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):c.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):c.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:c.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function dR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Sx(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function W9(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function OVe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s}){const a=En(),{showToast:o}=ii(),l=p7(),[u,d]=M.useState(!1),[f,g]=M.useState(!1),[m,x]=M.useState(!1),[y,v]=M.useState(!1),[b,E]=M.useState(!1),[S,A]=M.useState(!1),[T,k]=M.useState([]),[N,I]=M.useState(!1),[C,D]=M.useState(!1),[F,j]=M.useState(!1),[q,R]=M.useState(!1),[W,K]=M.useState(!1),[V,te]=M.useState(null),Y=M.useRef(null),Z=_t({mutationFn:re=>Pe.uploadSource3mf(t.id,re),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),o(`Source 3MF attached: ${re.filename}`)},onError:re=>{o(re.message||"Failed to upload source 3MF","error")}}),U=_t({mutationFn:()=>Pe.deleteSource3mf(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),o("Source 3MF removed")},onError:re=>{o(re.message||"Failed to remove source 3MF","error")}}),z=_t({mutationFn:()=>Pe.scanArchiveTimelapse(t.id),onSuccess:re=>{re.status==="attached"?(a.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${re.filename}`)):re.status==="exists"?o("Timelapse already attached"):re.status==="not_found"&&re.available_files&&re.available_files.length>0?(k(re.available_files),A(!0)):o(re.message||"No matching timelapse found","warning")},onError:re=>{o(re.message||"Failed to scan for timelapse","error")}}),ee=_t({mutationFn:re=>Pe.selectArchiveTimelapse(t.id,re),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),o(`Timelapse attached: ${re.filename}`),A(!1),k([])},onError:re=>{o(re.message||"Failed to attach timelapse","error")}}),ae=_t({mutationFn:()=>Pe.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),o("Archive deleted")},onError:()=>{o("Failed to delete archive","error")}}),fe=_t({mutationFn:()=>Pe.toggleFavorite(t.id),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),o(re.is_favorite?"Added to favorites":"Removed from favorites")}}),de=_t({mutationFn:re=>Pe.updateArchive(t.id,{project_id:re}),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),a.invalidateQueries({queryKey:["projects"]}),o("Project updated")},onError:()=>{o("Failed to update project","error")}}),xe=re=>{re.preventDefault(),te({x:re.clientX,y:re.clientY})},ye=[{label:"Print",icon:c.jsx(Lo,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"Schedule",icon:c.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"Open in Bambu Studio",icon:c.jsx(io,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",ve=`${window.location.origin}${Pe.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`}},{label:"View on MakerWorld",icon:c.jsx(h0,{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:c.jsx(lm,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:c.jsx(qp,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:c.jsx(kce,{className:"w-4 h-4"}),onClick:()=>z.mutate(),disabled:!t.printer_id||!!t.timelapse_path||z.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:c.jsx(z5,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const re=document.createElement("a");re.href=Pe.getSource3mfDownloadUrl(t.id),re.download=`${t.print_name||t.filename}_source.3mf`,re.click()}else Y.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:c.jsx(ga,{className:"w-4 h-4"}),onClick:()=>Y.current?.click()},{label:"Remove Source 3MF",icon:c.jsx(kn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:c.jsx(_a,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=Pe.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()}},{label:"Copy Download Link",icon:c.jsx(Uh,{className:"w-4 h-4"}),onClick:()=>{const re=`${window.location.origin}${Pe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(re).then(()=>{o("Link copied to clipboard")}).catch(()=>{o("Failed to copy link","error")})}},{label:"QR Code",icon:c.jsx(Sce,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:c.jsx(u0,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:c.jsx(Za,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:c.jsx(um,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>fe.mutate()},{label:"Edit",icon:c.jsx(ed,{className:"w-4 h-4"}),onClick:()=>v(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:c.jsx(bh,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:c.jsx(bh,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const re=[];if(t.project_id&&re.push({label:"Remove from Project",icon:c.jsx(Gt,{className:"w-4 h-4"}),onClick:()=>de.mutate(null)}),!s)re.push({label:"Loading...",icon:c.jsx(At,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const ve=s.filter(je=>je.status==="active");ve.length===0?re.push({label:"No projects available",icon:c.jsx(bh,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):ve.forEach(je=>{re.push({label:je.name,icon:c.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:je.color||"#888"}}),onClick:()=>de.mutate(je.id),disabled:t.project_id===je.id})})}return re})()},{label:n?"Deselect":"Select",icon:n?c.jsx(zh,{className:"w-4 h-4"}):c.jsx(cm,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:c.jsx(kn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return c.jsxs(kt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:xe,onClick:i?()=>r(t.id):void 0,children:[i&&c.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),r(t.id)},children:n?c.jsx(zh,{className:"w-5 h-5 text-bambu-green"}):c.jsx(cm,{className:"w-5 h-5 text-white"})}),c.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?c.jsx("img",{src:Pe.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center",children:c.jsx(cb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),l&&c.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation();const ve=re.currentTarget.getBoundingClientRect();te({x:ve.left,y:ve.bottom+4})},title:"Menu",children:c.jsx(ZG,{className:"w-5 h-5 text-white"})}),c.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),fe.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:c.jsx(um,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&c.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&&c.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:[c.jsx(Uh,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&c.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation();const ve=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",je=`${window.location.origin}${Pe.getSource3mfForSlicer(t.id,ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(je)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:c.jsx(z5,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&c.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation(),E(!0)},title:"View timelapse",children:c.jsx(qp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&c.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:re=>{re.stopPropagation(),D(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[c.jsx(u0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&c.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})]})]}),c.jsxs(Dt,{className:"p-4 flex-1 flex flex-col",children:[c.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:e}),t.project_name&&c.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${s?.find(re=>re.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(re=>re.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),c.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)&&c.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Sx(t.print_time_seconds||0)}
- Actual: ${Sx(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Sx(t.actual_time_seconds)}`:`Estimated: ${Sx(t.print_time_seconds||0)}`,children:[c.jsx(ni,{className:"w-3 h-3"}),Sx(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&c.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&&c.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[c.jsx(p0,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&c.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[c.jsx(Fh,{className:"w-3 h-3"}),t.total_layers&&c.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&c.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&c.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&c.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[c.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&c.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((re,ve)=>c.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},ve))})]})]}),(t.tags||t.notes)&&c.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&c.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:c.jsx(i7,{className:"w-3 h-3"})}),t.tags?.split(",").map((re,ve)=>c.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},ve))]}),c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[c.jsx("span",{children:W9(t.created_at)}),c.jsx("span",{children:dR(t.file_size)})]}),c.jsxs("div",{className:"flex gap-1 mt-3",children:[c.jsxs(Ie,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[c.jsx(Lo,{className:"w-3 h-3 flex-shrink-0"}),c.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",ve=`${window.location.origin}${Pe.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`},title:"Open in Bambu Studio",children:c.jsx(io,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{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:c.jsx(h0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:c.jsx(lm,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=document.createElement("a");re.href=Pe.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},title:"Download",children:c.jsx(_a,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>v(!0),title:"Edit",children:c.jsx(ed,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:c.jsx(kn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&c.jsx(iFe,{archive:t,onClose:()=>v(!1)}),u&&c.jsx(eFe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&c.jsx(tFe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),m&&c.jsx(Yr,{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:()=>{ae.mutate(),x(!1)},onCancel:()=>x(!1)}),W&&c.jsx(Yr,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{U.mutate(),K(!1)},onCancel:()=>K(!1)}),V&&c.jsx(sFe,{x:V.x,y:V.y,items:ye,onClose:()=>te(null)}),b&&t.timelapse_path&&c.jsx(kVe,{src:Pe.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>E(!1)}),S&&T.length>0&&c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),c.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),c.jsx("button",{onClick:()=>{A(!1),k([])},className:"text-gray-400 hover:text-white p-1",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(re=>c.jsxs("button",{onClick:()=>ee.mutate(re.name),disabled:ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[c.jsx(qp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-white font-medium truncate",children:re.name}),c.jsxs("p",{className:"text-sm text-gray-400",children:[dR(re.size),re.mtime&&` • ${W9(re.mtime)}`]})]})]},re.name))}),c.jsx("div",{className:"p-4 border-t border-gray-700",children:c.jsx(Ie,{variant:"secondary",onClick:()=>{A(!1),k([])},className:"w-full",children:"Cancel"})})]})}),N&&c.jsx(hFe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),C&&t.photos&&t.photos.length>0&&c.jsx(fFe,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>D(!1),onDelete:async re=>{try{await Pe.deleteArchivePhoto(t.id,re),a.invalidateQueries({queryKey:["archives"]}),o("Photo deleted")}catch{o("Failed to delete photo","error")}}}),F&&c.jsx(CVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),q&&c.jsx(PVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),c.jsx("input",{ref:Y,type:"file",accept:".3mf",className:"hidden",onChange:re=>{const ve=re.target.files?.[0];ve&&Z.mutate(ve),re.target.value=""}})]})}const jVe=[{id:"all",label:"All Archives",icon:c.jsx(ile,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:c.jsx(ni,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:c.jsx(Xr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:c.jsx(Xr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:c.jsx(um,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:c.jsx(jo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:c.jsx(Uh,{className:"w-4 h-4"})}];function LVe(){const t=En(),{showToast:e}=ii(),n=M.useRef(null),[r,i]=M.useState(""),[s,a]=M.useState(null),[o,l]=M.useState(null),[u,d]=M.useState(new Set),[f,g]=M.useState("or"),[m,x]=M.useState(!1),[y,v]=M.useState(null),[b,E]=M.useState(!1),[S,A]=M.useState([]),[T,k]=M.useState(!1),[N,I]=M.useState(new Set),[C,D]=M.useState(!1),[F,j]=M.useState(!1),[q,R]=M.useState(!1),[W,K]=M.useState("grid"),[V,te]=M.useState("date-desc"),[Y,Z]=M.useState("all"),[U,z]=M.useState(!1),[ee,ae]=M.useState(!1),[fe,de]=M.useState(!1),{data:xe,isLoading:ye}=yt({queryKey:["archives",s],queryFn:()=>Pe.getArchives(s||void 0)}),{data:re}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:ve}=yt({queryKey:["projects"],queryFn:()=>Pe.getProjects()}),je=_t({mutationFn:async me=>(await Promise.all(me.map(Ae=>Pe.deleteArchive(Ae))),me.length),onSuccess:me=>{t.invalidateQueries({queryKey:["archives"]}),I(new Set),e(`${me} archive${me!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),ue=new Map(re?.map(me=>[me.id,me.name])||[]),ut=[...new Set(xe?.flatMap(me=>me.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),$=[...new Set(xe?.flatMap(me=>me.filament_color?.split(",")||[]).filter(Boolean)||[])],H=[...new Set(xe?.flatMap(me=>me.tags?.split(",").map(Ae=>Ae.trim())||[]).filter(Boolean)||[])].sort(),ie=xe?.filter(me=>{const Ae=new Date,ze=new Date(me.created_at);let st=!0;switch(Y){case"recent":st=Ae.getTime()-ze.getTime()<1440*60*1e3;break;case"this-week":st=Ae.getTime()-ze.getTime()<10080*60*1e3;break;case"this-month":st=ze.getMonth()===Ae.getMonth()&&ze.getFullYear()===Ae.getFullYear();break;case"favorites":st=me.is_favorite===!0;break;case"failed":st=me.status==="failed";break;case"duplicates":st=me.duplicate_count>0;break}const Ve=(me.print_name||me.filename).toLowerCase().includes(r.toLowerCase()),ce=!o||me.filament_type?.split(", ").includes(o),Ye=me.filament_color?.split(",")||[],$e=u.size===0||(f==="or"?Ye.some(Fe=>u.has(Fe)):[...u].every(Fe=>Ye.includes(Fe))),Ze=Y==="favorites"||!m||me.is_favorite,at=me.tags?.split(",").map(Fe=>Fe.trim())||[],Q=!y||at.includes(y);return st&&Ve&&ce&&$e&&Ze&&Q}).sort((me,Ae)=>{switch(V){case"date-desc":return new Date(Ae.created_at).getTime()-new Date(me.created_at).getTime();case"date-asc":return new Date(me.created_at).getTime()-new Date(Ae.created_at).getTime();case"name-asc":return(me.print_name||me.filename).localeCompare(Ae.print_name||Ae.filename);case"name-desc":return(Ae.print_name||Ae.filename).localeCompare(me.print_name||me.filename);case"size-desc":return Ae.file_size-me.file_size;case"size-asc":return me.file_size-Ae.file_size;default:return 0}}),G=C||N.size>0,J=me=>{I(Ae=>{const ze=new Set(Ae);return ze.has(me)?ze.delete(me):ze.add(me),ze})},le=()=>{ie&&I(new Set(ie.map(me=>me.id)))},ke=()=>{I(new Set),D(!1)},Ne=me=>{d(Ae=>{const ze=new Set(Ae);return ze.has(me)?ze.delete(me):ze.add(me),ze})},Se=()=>{d(new Set)},B=()=>{i(""),a(null),l(null),x(!1),v(null)},L=r||s||o||m||y,ne=M.useCallback(me=>{me.preventDefault(),me.dataTransfer.types.includes("Files")&&k(!0)},[]),be=M.useCallback(me=>{me.preventDefault(),me.currentTarget===me.target&&k(!1)},[]),we=M.useCallback(me=>{me.preventDefault(),k(!1);const Ae=Array.from(me.dataTransfer.files).filter(ze=>ze.name.endsWith(".3mf"));Ae.length>0?(A(Ae),E(!0)):me.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ge=M.useCallback(me=>{const Ae=me.target;if(Ae.tagName==="INPUT"||Ae.tagName==="TEXTAREA"||Ae.isContentEditable){me.key==="Escape"&&Ae.blur();return}switch(me.key){case"/":me.preventDefault(),n.current?.focus();break;case"u":case"U":!me.metaKey&&!me.ctrlKey&&(me.preventDefault(),E(!0));break;case"Escape":G&&ke();break}},[G]);return M.useEffect(()=>(document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)),[ge]),c.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:ne,onDragLeave:be,onDrop:we,children:[T&&c.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:c.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[c.jsx(ga,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),c.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),c.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),G&&c.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:[c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:ke,children:[c.jsx(Gt,{className:"w-4 h-4"}),"Close"]}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsxs("span",{className:"text-white font-medium",children:[N.size," selected"]}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:le,children:"Select All"}),c.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>R(!0),children:[c.jsx(x0,{className:"w-4 h-4"}),"Tags"]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>{const me=Array.from(N);Promise.all(me.map(Ae=>Pe.toggleFavorite(Ae))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${me.length} archive${me.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[c.jsx(um,{className:"w-4 h-4"}),"Favorite"]}),c.jsxs(Ie,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>j(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]}),c.jsxs("div",{className:"flex items-center justify-between mb-8",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),c.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:Y,onChange:me=>Z(me.target.value),children:jVe.map(me=>c.jsx("option",{value:me.id,children:me.label},me.id))})]}),c.jsxs("p",{className:"text-bambu-gray",children:[ie?.length||0," of ",xe?.length||0," prints"]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"relative",children:[c.jsxs(Ie,{variant:"secondary",onClick:()=>z(!U),disabled:ee,children:[ee?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(y1,{className:"w-4 h-4"}),"Export"]}),U&&c.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{z(!1),ae(!0);try{const{blob:me,filename:Ae}=await Pe.exportArchives({format:"csv",printerId:s||void 0,status:Y==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(me),st=document.createElement("a");st.href=ze,st.download=Ae,st.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[c.jsx(Za,{className:"w-4 h-4"}),"Export as CSV"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{z(!1),ae(!0);try{const{blob:me,filename:Ae}=await Pe.exportArchives({format:"xlsx",printerId:s||void 0,status:Y==="failed"?"failed":void 0,search:r||void 0}),ze=URL.createObjectURL(me),st=document.createElement("a");st.href=ze,st.download=Ae,st.click(),URL.revokeObjectURL(ze),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[c.jsx(y1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),N.size>=2&&N.size<=5&&c.jsxs(Ie,{variant:"secondary",onClick:()=>de(!0),children:[c.jsx(Kp,{className:"w-4 h-4"}),"Compare (",N.size,")"]}),!G&&c.jsxs(Ie,{variant:"secondary",onClick:()=>D(!0),children:[c.jsx(zh,{className:"w-4 h-4"}),"Select"]}),c.jsxs(Ie,{onClick:()=>E(!0),children:[c.jsx(ga,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),c.jsx(kt,{className:"mb-6",children:c.jsxs(Dt,{className:"py-4",children:[c.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[c.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[c.jsx(td,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:me=>i(me.target.value)})]}),c.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(RR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.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:me=>a(me.target.value?Number(me.target.value):null),children:[c.jsx("option",{value:"",children:"All Printers"}),re?.map(me=>c.jsx("option",{value:me.id,children:me.name},me.id))]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(p0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.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:me=>l(me.target.value||null),children:[c.jsx("option",{value:"",children:"All Materials"}),ut.map(me=>c.jsx("option",{value:me,children:me},me))]})]}),c.jsxs("button",{onClick:()=>x(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${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:[c.jsx(um,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),c.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),H.length>0&&c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(x0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.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:me=>v(me.target.value||null),children:[c.jsx("option",{value:"",children:"All Tags"}),H.map(me=>c.jsx("option",{value:me,children:me},me))]})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c.jsx(Vae,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),c.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:me=>te(me.target.value),children:[c.jsx("option",{value:"date-desc",children:"Newest first"}),c.jsx("option",{value:"date-asc",children:"Oldest first"}),c.jsx("option",{value:"name-asc",children:"Name A-Z"}),c.jsx("option",{value:"name-desc",children:"Name Z-A"}),c.jsx("option",{value:"size-desc",children:"Largest first"}),c.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),c.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[c.jsx("button",{className:`p-2 ${W==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("grid"),title:"Grid view",children:c.jsx(n7,{className:"w-4 h-4"})}),c.jsx("button",{className:`p-2 ${W==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("list"),title:"List view",children:c.jsx(OR,{className:"w-4 h-4"})}),c.jsx("button",{className:`p-2 ${W==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>K("calendar"),title:"Calendar view",children:c.jsx(roe,{className:"w-4 h-4"})})]})]}),L&&c.jsxs(Ie,{variant:"ghost",size:"sm",onClick:B,className:"text-bambu-gray hover:text-white",children:[c.jsx(Gt,{className:"w-4 h-4"}),"Reset"]})]}),$.length>0&&c.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&c.jsx("button",{onClick:()=>g(me=>me==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),c.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:$.map(me=>c.jsx("button",{onClick:()=>Ne(me),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(me)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:me},title:me},me))}),u.size>0&&c.jsxs("button",{onClick:Se,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[c.jsx(Gt,{className:"w-3 h-3"}),"Clear"]})]})]})}),ye?c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ie?.length===0?c.jsx(kt,{children:c.jsxs(Dt,{className:"text-center py-12",children:[c.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):W==="calendar"?c.jsx(kt,{className:"p-6",children:c.jsx(dFe,{archives:ie||[],onArchiveClick:me=>{i(me.print_name||me.filename),K("grid")}})}):W==="grid"?c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:ie?.map(me=>c.jsx(OVe,{archive:me,printerName:me.printer_id?ue.get(me.printer_id)||"Unknown":"No Printer",isSelected:N.has(me.id),onSelect:J,selectionMode:G,projects:ve},me.id))}):W==="list"?c.jsx(kt,{children:c.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[c.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[c.jsx("div",{className:"col-span-1"}),c.jsx("div",{className:"col-span-4",children:"Name"}),c.jsx("div",{className:"col-span-2",children:"Printer"}),c.jsx("div",{className:"col-span-2",children:"Date"}),c.jsx("div",{className:"col-span-1",children:"Size"}),c.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),ie?.map(me=>c.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${N.has(me.id)?"bg-bambu-green/10":""}`,children:[c.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[G&&c.jsx("button",{onClick:()=>J(me.id),children:N.has(me.id)?c.jsx(zh,{className:"w-4 h-4 text-bambu-green"}):c.jsx(cm,{className:"w-4 h-4 text-bambu-gray"})}),me.thumbnail_path?c.jsx("img",{src:Pe.getArchiveThumbnail(me.id),alt:"",className:"w-10 h-10 object-cover rounded"}):c.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:c.jsx(cb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),c.jsxs("div",{className:"col-span-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-white text-sm truncate",children:me.print_name||me.filename}),me.timelapse_path&&c.jsx("span",{title:"Has timelapse",children:c.jsx(qp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),me.filament_type&&c.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:me.filament_type}),me.filament_color&&c.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:me.filament_color.split(",").map((Ae,ze)=>c.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Ae},title:Ae},ze))})]})]}),c.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:me.printer_id?ue.get(me.printer_id)||"Unknown":"No Printer"}),c.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(me.created_at).toLocaleDateString()}),c.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:dR(me.file_size)}),c.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{const Ae=me.print_name||me.filename||"model",ze=`${window.location.origin}${Pe.getArchiveForSlicer(me.id,Ae)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ze)}`},title:"Open in Slicer",children:c.jsx(io,{className:"w-4 h-4"})}),me.makerworld_url&&c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>window.open(me.makerworld_url,"_blank"),title:"MakerWorld",children:c.jsx(h0,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{const Ae=document.createElement("a");Ae.href=Pe.getArchiveDownload(me.id),Ae.download=`${me.print_name||me.filename}.3mf`,Ae.click()},title:"Download",children:c.jsx(_a,{className:"w-4 h-4"})})]})]},me.id))]})}):null,b&&c.jsx(nFe,{onClose:()=>{E(!1),A([])},initialFiles:S}),F&&c.jsx(Yr,{title:"Delete Archives",message:`Are you sure you want to delete ${N.size} archive${N.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${N.size}`,variant:"danger",onConfirm:()=>{je.mutate(Array.from(N)),j(!1)},onCancel:()=>j(!1)}),q&&c.jsx(aFe,{selectedIds:Array.from(N),existingTags:H,onClose:()=>R(!1)}),fe&&N.size>=2&&N.size<=5&&c.jsx(RVe,{archiveIds:Array.from(N),onClose:()=>{de(!1),I(new Set),D(!1)}})]})}function IVe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const nM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function sg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function nL(t){return"nodeType"in t}function Js(t){var e,n;return t?sg(t)?t:nL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function rL(t){const{Document:e}=Js(t);return t instanceof e}function qb(t){return sg(t)?!1:t instanceof Js(t).HTMLElement}function Ree(t){return t instanceof Js(t).SVGElement}function ag(t){return t?sg(t)?t.document:nL(t)?rL(t)?t:qb(t)||Ree(t)?t.ownerDocument:document:document:document}const bl=nM?M.useLayoutEffect:M.useEffect;function iL(t){const e=M.useRef(t);return bl(()=>{e.current=t}),M.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function UVe(){const t=M.useRef(null),e=M.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=M.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function tb(t,e){e===void 0&&(e=[t]);const n=M.useRef(t);return bl(()=>{n.current!==t&&(n.current=t)},e),n}function Kb(t,e){const n=M.useRef();return M.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function wS(t){const e=iL(t),n=M.useRef(null),r=M.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function hR(t){const e=M.useRef();return M.useEffect(()=>{e.current=t},[t]),e.current}let e3={};function Xb(t,e){return M.useMemo(()=>{if(e)return e;const n=e3[t]==null?0:e3[t]+1;return e3[t]=n,t+"-"+n},[t,e])}function Dee(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,u]of o){const d=s[l];d!=null&&(s[l]=d+t*u)}return s},{...e})}}const am=Dee(1),nb=Dee(-1);function FVe(t){return"clientX"in t&&"clientY"in t}function sL(t){if(!t)return!1;const{KeyboardEvent:e}=Js(t.target);return e&&t instanceof e}function zVe(t){if(!t)return!1;const{TouchEvent:e}=Js(t.target);return e&&t instanceof e}function fR(t){if(zVe(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 FVe(t)?{x:t.clientX,y:t.clientY}:null}const Lm=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[Lm.Translate.toString(t),Lm.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),q9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function BVe(t){return t.matches(q9)?t:t.querySelector(q9)}const HVe={display:"none"};function $Ve(t){let{id:e,value:n}=t;return mr.createElement("div",{id:e,style:HVe},n)}function VVe(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 mr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function GVe(){const[t,e]=M.useState("");return{announce:M.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Oee=M.createContext(null);function WVe(t){const e=M.useContext(Oee);M.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function qVe(){const[t]=M.useState(()=>new Set),e=M.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[M.useCallback(r=>{let{type:i,event:s}=r;t.forEach(a=>{var o;return(o=a[i])==null?void 0:o.call(a,s)})},[t]),e]}const KVe={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.
- `},XVe={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 YVe(t){let{announcements:e=XVe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=KVe}=t;const{announce:s,announcement:a}=GVe(),o=Xb("DndLiveRegion"),[l,u]=M.useState(!1);if(M.useEffect(()=>{u(!0)},[]),WVe(M.useMemo(()=>({onDragStart(f){let{active:g}=f;s(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:m}=f;e.onDragMove&&s(e.onDragMove({active:g,over:m}))},onDragOver(f){let{active:g,over:m}=f;s(e.onDragOver({active:g,over:m}))},onDragEnd(f){let{active:g,over:m}=f;s(e.onDragEnd({active:g,over:m}))},onDragCancel(f){let{active:g,over:m}=f;s(e.onDragCancel({active:g,over:m}))}}),[s,e])),!l)return null;const d=mr.createElement(mr.Fragment,null,mr.createElement($Ve,{id:r,value:i.draggable}),mr.createElement(VVe,{id:o,announcement:a}));return n?uc.createPortal(d,n):d}var ui;(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"})(ui||(ui={}));function SS(){}function ES(t,e){return M.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function jee(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Uo=Object.freeze({x:0,y:0});function Lee(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Iee(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function ZVe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function K9(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 Uee(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function X9(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 Fee=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=X9(e,e.left,e.top),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const u=Lee(X9(l),i);s.push({id:o,data:{droppableContainer:a,value:u}})}}return s.sort(Iee)},QVe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=K9(e),s=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const u=K9(l),d=i.reduce((g,m,x)=>g+Lee(u[x],m),0),f=Number((d/4).toFixed(4));s.push({id:o,data:{droppableContainer:a,value:f}})}}return s.sort(Iee)};function JVe(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,u=t.width*t.height,d=a*o,f=d/(l+u-d);return Number(f.toFixed(4))}return 0}const e9e=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=JVe(o,e);l>0&&i.push({id:a,data:{droppableContainer:s,value:l}})}}return i.sort(ZVe)};function t9e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function zee(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Uo}function n9e(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 r9e=n9e(1);function i9e(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 s9e(t,e,n){const r=i9e(e);if(!r)return t;const{scaleX:i,scaleY:s,x:a,y:o}=r,l=t.left-a-(1-i)*parseFloat(n),u=t.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=s?t.height/s:t.height;return{width:d,height:f,top:u,right:l+d,bottom:u+f,left:l}}const a9e={ignoreTransform:!1};function og(t,e){e===void 0&&(e=a9e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Js(t).getComputedStyle(t);u&&(n=s9e(n,u,d))}const{top:r,left:i,width:s,height:a,bottom:o,right:l}=n;return{top:r,left:i,width:s,height:a,bottom:o,right:l}}function Y9(t){return og(t,{ignoreTransform:!0})}function o9e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function l9e(t,e){return e===void 0&&(e=Js(t).getComputedStyle(t)),e.position==="fixed"}function c9e(t,e){e===void 0&&(e=Js(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 rM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(rL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!qb(i)||Ree(i)||n.includes(i))return n;const s=Js(t).getComputedStyle(i);return i!==t&&c9e(i,s)&&n.push(i),l9e(i,s)?n:r(i.parentNode)}return t?r(t):n}function Bee(t){const[e]=rM(t,1);return e??null}function t3(t){return!nM||!t?null:sg(t)?t:nL(t)?rL(t)||t===ag(t).scrollingElement?window:qb(t)?t:null:null}function Hee(t){return sg(t)?t.scrollX:t.scrollLeft}function $ee(t){return sg(t)?t.scrollY:t.scrollTop}function pR(t){return{x:Hee(t),y:$ee(t)}}var Ri;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Ri||(Ri={}));function Vee(t){return!nM||!t?!1:t===document.scrollingElement}function Gee(t){const e={x:0,y:0},n=Vee(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 u9e={x:.2,y:.2};function d9e(t,e,n,r,i){let{top:s,left:a,right:o,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=u9e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=Gee(t),m={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&s<=e.top+y.height?(m.y=Ri.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&l>=e.bottom-y.height&&(m.y=Ri.Forward,x.y=r*Math.abs((e.bottom-y.height-l)/y.height)),!g&&o>=e.right-y.width?(m.x=Ri.Forward,x.x=r*Math.abs((e.right-y.width-o)/y.width)):!f&&a<=e.left+y.width&&(m.x=Ri.Backward,x.x=r*Math.abs((e.left+y.width-a)/y.width)),{direction:m,speed:x}}function h9e(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 Wee(t){return t.reduce((e,n)=>am(e,pR(n)),Uo)}function f9e(t){return t.reduce((e,n)=>e+Hee(n),0)}function p9e(t){return t.reduce((e,n)=>e+$ee(n),0)}function m9e(t,e){if(e===void 0&&(e=og),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);Bee(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const g9e=[["x",["left","right"],f9e],["y",["top","bottom"],p9e]];class aL{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=rM(n),i=Wee(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,o]of g9e)for(const l of a)Object.defineProperty(this,l,{get:()=>{const u=o(r),d=i[s]-u;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class n0{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 x9e(t){const{EventTarget:e}=Js(t);return t instanceof e?t:ag(t)}function n3(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 Ga;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Ga||(Ga={}));function Z9(t){t.preventDefault()}function b9e(t){t.stopPropagation()}var wn;(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"})(wn||(wn={}));const qee={start:[wn.Space,wn.Enter],cancel:[wn.Esc],end:[wn.Space,wn.Enter,wn.Tab]},v9e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case wn.Right:return{...n,x:n.x+25};case wn.Left:return{...n,x:n.x-25};case wn.Down:return{...n,y:n.y+25};case wn.Up:return{...n,y:n.y-25}}};class iM{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 n0(ag(n)),this.windowListeners=new n0(Js(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ga.Resize,this.handleCancel),this.windowListeners.add(Ga.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ga.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&m9e(r),n(Uo)}handleKeyDown(e){if(sL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=qee,coordinateGetter:a=v9e,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:u}=r.current,d=u?{x:u.left,y:u.top}:Uo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=a(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=nb(f,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const v=e.code,{isTop:b,isRight:E,isLeft:S,isBottom:A,maxScroll:T,minScroll:k}=Gee(y),N=h9e(y),I={x:Math.min(v===wn.Right?N.right-N.width/2:N.right,Math.max(v===wn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(v===wn.Down?N.bottom-N.height/2:N.bottom,Math.max(v===wn.Down?N.top:N.top+N.height/2,f.y))},C=v===wn.Right&&!E||v===wn.Left&&!S,D=v===wn.Down&&!A||v===wn.Up&&!b;if(C&&I.x!==f.x){const F=y.scrollLeft+g.x,j=v===wn.Right&&F<=T.x||v===wn.Left&&F>=k.x;if(j&&!g.y){y.scrollTo({left:F,behavior:o});return}j?m.x=y.scrollLeft-F:m.x=v===wn.Right?y.scrollLeft-T.x:y.scrollLeft-k.x,m.x&&y.scrollBy({left:-m.x,behavior:o});break}else if(D&&I.y!==f.y){const F=y.scrollTop+g.y,j=v===wn.Down&&F<=T.y||v===wn.Up&&F>=k.y;if(j&&!g.x){y.scrollTo({top:F,behavior:o});return}j?m.y=y.scrollTop-F:m.y=v===wn.Down?y.scrollTop-T.y:y.scrollTop-k.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,am(nb(f,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}iM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=qee,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 Q9(t){return!!(t&&"distance"in t)}function J9(t){return!!(t&&"delay"in t)}class oL{constructor(e,n,r){var i;r===void 0&&(r=x9e(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=ag(a),this.documentListeners=new n0(this.document),this.listeners=new n0(r),this.windowListeners=new n0(Js(a)),this.initialCoordinates=(i=fR(s))!=null?i:Uo,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(Ga.Resize,this.handleCancel),this.windowListeners.add(Ga.DragStart,Z9),this.windowListeners.add(Ga.VisibilityChange,this.handleCancel),this.windowListeners.add(Ga.ContextMenu,Z9),this.documentListeners.add(Ga.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(J9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Q9(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(Ga.Click,b9e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ga.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=fR(e))!=null?n:Uo,u=nb(i,l);if(!r&&o){if(Q9(o)){if(o.tolerance!=null&&n3(u,o.tolerance))return this.handleCancel();if(n3(u,o.distance))return this.handleStart()}if(J9(o)&&n3(u,o.tolerance))return this.handleCancel();this.handlePending(o,u);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===wn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const y9e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class sM extends oL{constructor(e){const{event:n}=e,r=ag(n.target);super(e,y9e,r)}}sM.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 _9e={move:{name:"mousemove"},end:{name:"mouseup"}};var mR;(function(t){t[t.RightClick=2]="RightClick"})(mR||(mR={}));class w9e extends oL{constructor(e){super(e,_9e,ag(e.event.target))}}w9e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===mR.RightClick?!1:(r?.({event:n}),!0)}}];const r3={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class S9e extends oL{constructor(e){super(e,r3)}static setup(){return window.addEventListener(r3.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(r3.move.name,e)};function e(){}}}S9e.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 r0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(r0||(r0={}));var MS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(MS||(MS={}));function E9e(t){let{acceleration:e,activator:n=r0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:a=5,order:o=MS.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const m=A9e({delta:f,disabled:!s}),[x,y]=UVe(),v=M.useRef({x:0,y:0}),b=M.useRef({x:0,y:0}),E=M.useMemo(()=>{switch(n){case r0.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case r0.DraggableRect:return i}},[n,i,l]),S=M.useRef(null),A=M.useCallback(()=>{const k=S.current;if(!k)return;const N=v.current.x*b.current.x,I=v.current.y*b.current.y;k.scrollBy(N,I)},[]),T=M.useMemo(()=>o===MS.TreeOrder?[...u].reverse():u,[o,u]);M.useEffect(()=>{if(!s||!u.length||!E){y();return}for(const k of T){if(r?.(k)===!1)continue;const N=u.indexOf(k),I=d[N];if(!I)continue;const{direction:C,speed:D}=d9e(k,I,E,e,g);for(const F of["x","y"])m[F][C[F]]||(D[F]=0,C[F]=0);if(D.x>0||D.y>0){y(),S.current=k,x(A,a),v.current=D,b.current=C;return}}v.current={x:0,y:0},b.current={x:0,y:0},y()},[e,A,r,y,s,a,JSON.stringify(E),JSON.stringify(m),x,u,T,d,JSON.stringify(g)])}const M9e={x:{[Ri.Backward]:!1,[Ri.Forward]:!1},y:{[Ri.Backward]:!1,[Ri.Forward]:!1}};function A9e(t){let{delta:e,disabled:n}=t;const r=hR(e);return Kb(i=>{if(n||!r||!i)return M9e;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Ri.Backward]:i.x[Ri.Backward]||s.x===-1,[Ri.Forward]:i.x[Ri.Forward]||s.x===1},y:{[Ri.Backward]:i.y[Ri.Backward]||s.y===-1,[Ri.Forward]:i.y[Ri.Forward]||s.y===1}}},[n,e,r])}function T9e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Kb(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function C9e(t,e){return M.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 rb;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(rb||(rb={}));var gR;(function(t){t.Optimized="optimized"})(gR||(gR={}));const eG=new Map;function N9e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,a]=M.useState(null),{frequency:o,measure:l,strategy:u}=i,d=M.useRef(t),f=v(),g=tb(f),m=M.useCallback(function(b){b===void 0&&(b=[]),!g.current&&a(E=>E===null?b:E.concat(b.filter(S=>!E.includes(S))))},[g]),x=M.useRef(null),y=Kb(b=>{if(f&&!n)return eG;if(!b||b===eG||d.current!==t||s!=null){const E=new Map;for(let S of t){if(!S)continue;if(s&&s.length>0&&!s.includes(S.id)&&S.rect.current){E.set(S.id,S.rect.current);continue}const A=S.node.current,T=A?new aL(l(A),A):null;S.rect.current=T,T&&E.set(S.id,T)}return E}return b},[t,s,n,f,l]);return M.useEffect(()=>{d.current=t},[t]),M.useEffect(()=>{f||m()},[n,f]),M.useEffect(()=>{s&&s.length>0&&a(null)},[JSON.stringify(s)]),M.useEffect(()=>{f||typeof o!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},o))},[o,f,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:s!=null};function v(){switch(u){case rb.Always:return!1;case rb.BeforeDragging:return n;default:return!n}}}function Kee(t,e){return Kb(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function k9e(t,e){return Kee(t,e)}function P9e(t){let{callback:e,disabled:n}=t;const r=iL(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function aM(t){let{callback:e,disabled:n}=t;const r=iL(e),i=M.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return M.useEffect(()=>()=>i?.disconnect(),[i]),i}function R9e(t){return new aL(og(t),t)}function tG(t,e,n){e===void 0&&(e=R9e);const[r,i]=M.useState(null);function s(){i(l=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=l??n)!=null?u:null}const d=e(t);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const a=P9e({callback(l){if(t)for(const u of l){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){s();break}}}}),o=aM({callback:s});return bl(()=>{s(),t?(o?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),a?.disconnect())},[t]),r}function D9e(t){const e=Kee(t);return zee(t,e)}const nG=[];function O9e(t){const e=M.useRef(t),n=Kb(r=>t?r&&r!==nG&&t&&e.current&&t.parentNode===e.current.parentNode?r:rM(t):nG,[t]);return M.useEffect(()=>{e.current=t},[t]),n}function j9e(t){const[e,n]=M.useState(null),r=M.useRef(t),i=M.useCallback(s=>{const a=t3(s.target);a&&n(o=>o?(o.set(a,pR(a)),new Map(o)):null)},[]);return M.useEffect(()=>{const s=r.current;if(t!==s){a(s);const o=t.map(l=>{const u=t3(l);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,pR(u)]):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 u=t3(l);u?.removeEventListener("scroll",i)})}},[i,t]),M.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,a)=>am(s,a),Uo):Wee(t):Uo,[t,e])}function rG(t,e){e===void 0&&(e=[]);const n=M.useRef(null);return M.useEffect(()=>{n.current=null},e),M.useEffect(()=>{const r=t!==Uo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?nb(t,n.current):Uo}function L9e(t){M.useEffect(()=>{if(!nM)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 I9e(t,e){return M.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=a=>{s(a,e)},n},{}),[t,e])}function Xee(t){return M.useMemo(()=>t?o9e(t):null,[t])}const iG=[];function U9e(t,e){e===void 0&&(e=og);const[n]=t,r=Xee(n?Js(n):null),[i,s]=M.useState(iG);function a(){s(()=>t.length?t.map(l=>Vee(l)?r:new aL(e(l),l)):iG)}const o=aM({callback:a});return bl(()=>{o?.disconnect(),a(),t.forEach(l=>o?.observe(l))},[t]),i}function F9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return qb(e)?e:t}function z9e(t){let{measure:e}=t;const[n,r]=M.useState(null),i=M.useCallback(u=>{for(const{target:d}of u)if(qb(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),s=aM({callback:i}),a=M.useCallback(u=>{const d=F9e(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[o,l]=wS(a);return M.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const B9e=[{sensor:sM,options:{}},{sensor:iM,options:{}}],H9e={current:{}},h1={draggable:{measure:Y9},droppable:{measure:Y9,strategy:rb.WhileDragging,frequency:gR.Optimized},dragOverlay:{measure:og}};class i0 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 $9e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new i0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:SS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:h1,measureDroppableContainers:SS,windowRect:null,measuringScheduled:!1},V9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:SS,draggableNodes:new Map,over:null,measureDroppableContainers:SS},oM=M.createContext(V9e),Yee=M.createContext($9e);function G9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new i0}}}function W9e(t,e){switch(e.type){case ui.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ui.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 ui.DragEnd:case ui.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ui.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new i0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case ui.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 i0(t.droppable.containers);return a.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case ui.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new i0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function q9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=M.useContext(oM),s=hR(r),a=hR(n?.id);return M.useEffect(()=>{if(!e&&!r&&s&&a!=null){if(!sL(s)||document.activeElement===s.target)return;const o=i.get(a);if(!o)return;const{activatorNode:l,node:u}=o;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[l.current,u.current]){if(!d)continue;const f=BVe(d);if(f){f.focus();break}}})}},[r,e,i,a,s]),null}function K9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function X9e(t){return M.useMemo(()=>({draggable:{...h1.draggable,...t?.draggable},droppable:{...h1.droppable,...t?.droppable},dragOverlay:{...h1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function Y9e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=M.useRef(!1),{x:a,y:o}=typeof i=="boolean"?{x:i,y:i}:i;bl(()=>{if(!a&&!o||!e){s.current=!1;return}if(s.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=zee(d,r);if(a||(f.x=0),o||(f.y=0),s.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=Bee(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,a,o,r,n])}const Zee=M.createContext({...Uo,scaleX:1,scaleY:1});var Ru;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ru||(Ru={}));const Qee=M.memo(function(e){var n,r,i,s;let{id:a,accessibility:o,autoScroll:l=!0,children:u,sensors:d=B9e,collisionDetection:f=e9e,measuring:g,modifiers:m,...x}=e;const y=M.useReducer(W9e,void 0,G9e),[v,b]=y,[E,S]=qVe(),[A,T]=M.useState(Ru.Uninitialized),k=A===Ru.Initialized,{draggable:{active:N,nodes:I,translate:C},droppable:{containers:D}}=v,F=N!=null?I.get(N):null,j=M.useRef({initial:null,translated:null}),q=M.useMemo(()=>{var Ue;return N!=null?{id:N,data:(Ue=F?.data)!=null?Ue:H9e,rect:j}:null},[N,F]),R=M.useRef(null),[W,K]=M.useState(null),[V,te]=M.useState(null),Y=tb(x,Object.values(x)),Z=Xb("DndDescribedBy",a),U=M.useMemo(()=>D.getEnabled(),[D]),z=X9e(g),{droppableRects:ee,measureDroppableContainers:ae,measuringScheduled:fe}=N9e(U,{dragging:k,dependencies:[C.x,C.y],config:z.droppable}),de=T9e(I,N),xe=M.useMemo(()=>V?fR(V):null,[V]),ye=pe(),re=k9e(de,z.draggable.measure);Y9e({activeNode:N!=null?I.get(N):null,config:ye.layoutShiftCompensation,initialRect:re,measure:z.draggable.measure});const ve=tG(de,z.draggable.measure,re),je=tG(de?de.parentElement:null),ue=M.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ut=D.getNodeFor((n=ue.current.over)==null?void 0:n.id),$=z9e({measure:z.dragOverlay.measure}),H=(r=$.nodeRef.current)!=null?r:de,ie=k?(i=$.rect)!=null?i:ve:null,G=!!($.nodeRef.current&&$.rect),J=D9e(G?null:ve),le=Xee(H?Js(H):null),ke=O9e(k?ut??de:null),Ne=U9e(ke),Se=K9e(m,{transform:{x:C.x-J.x,y:C.y-J.y,scaleX:1,scaleY:1},activatorEvent:V,active:q,activeNodeRect:ve,containerNodeRect:je,draggingNodeRect:ie,over:ue.current.over,overlayNodeRect:$.rect,scrollableAncestors:ke,scrollableAncestorRects:Ne,windowRect:le}),B=xe?am(xe,C):null,L=j9e(ke),ne=rG(L),be=rG(L,[ve]),we=am(Se,ne),ge=ie?r9e(ie,Se):null,me=q&&ge?f({active:q,collisionRect:ge,droppableRects:ee,droppableContainers:U,pointerCoordinates:B}):null,Ae=Uee(me,"id"),[ze,st]=M.useState(null),Ve=G?Se:am(Se,be),ce=t9e(Ve,(s=ze?.rect)!=null?s:null,ve),Ye=M.useRef(null),$e=M.useCallback((Ue,Ce)=>{let{sensor:_e,options:He}=Ce;if(R.current==null)return;const ht=I.get(R.current);if(!ht)return;const wt=Ue.nativeEvent,Ot=new _e({active:R.current,activeNode:ht,event:wt,options:He,context:ue,onAbort(It){if(!I.get(It))return;const{onDragAbort:Qn}=Y.current,wi={id:It};Qn?.(wi),E({type:"onDragAbort",event:wi})},onPending(It,Dn,Qn,wi){if(!I.get(It))return;const{onDragPending:Si}=Y.current,Ui={id:It,constraint:Dn,initialCoordinates:Qn,offset:wi};Si?.(Ui),E({type:"onDragPending",event:Ui})},onStart(It){const Dn=R.current;if(Dn==null)return;const Qn=I.get(Dn);if(!Qn)return;const{onDragStart:wi}=Y.current,si={activatorEvent:wt,active:{id:Dn,data:Qn.data,rect:j}};uc.unstable_batchedUpdates(()=>{wi?.(si),T(Ru.Initializing),b({type:ui.DragStart,initialCoordinates:It,active:Dn}),E({type:"onDragStart",event:si}),K(Ye.current),te(wt)})},onMove(It){b({type:ui.DragMove,coordinates:It})},onEnd:cn(ui.DragEnd),onCancel:cn(ui.DragCancel)});Ye.current=Ot;function cn(It){return async function(){const{active:Qn,collisions:wi,over:si,scrollAdjustedTranslate:Si}=ue.current;let Ui=null;if(Qn&&Si){const{cancelDrop:ts}=Y.current;Ui={activatorEvent:wt,active:Qn,collisions:wi,delta:Si,over:si},It===ui.DragEnd&&typeof ts=="function"&&await Promise.resolve(ts(Ui))&&(It=ui.DragCancel)}R.current=null,uc.unstable_batchedUpdates(()=>{b({type:It}),T(Ru.Uninitialized),st(null),K(null),te(null),Ye.current=null;const ts=It===ui.DragEnd?"onDragEnd":"onDragCancel";if(Ui){const zr=Y.current[ts];zr?.(Ui),E({type:ts,event:Ui})}})}}},[I]),Ze=M.useCallback((Ue,Ce)=>(_e,He)=>{const ht=_e.nativeEvent,wt=I.get(He);if(R.current!==null||!wt||ht.dndKit||ht.defaultPrevented)return;const Ot={active:wt};Ue(_e,Ce.options,Ot)===!0&&(ht.dndKit={capturedBy:Ce.sensor},R.current=He,$e(_e,Ce))},[I,$e]),at=C9e(d,Ze);L9e(d),bl(()=>{ve&&A===Ru.Initializing&&T(Ru.Initialized)},[ve,A]),M.useEffect(()=>{const{onDragMove:Ue}=Y.current,{active:Ce,activatorEvent:_e,collisions:He,over:ht}=ue.current;if(!Ce||!_e)return;const wt={active:Ce,activatorEvent:_e,collisions:He,delta:{x:we.x,y:we.y},over:ht};uc.unstable_batchedUpdates(()=>{Ue?.(wt),E({type:"onDragMove",event:wt})})},[we.x,we.y]),M.useEffect(()=>{const{active:Ue,activatorEvent:Ce,collisions:_e,droppableContainers:He,scrollAdjustedTranslate:ht}=ue.current;if(!Ue||R.current==null||!Ce||!ht)return;const{onDragOver:wt}=Y.current,Ot=He.get(Ae),cn=Ot&&Ot.rect.current?{id:Ot.id,rect:Ot.rect.current,data:Ot.data,disabled:Ot.disabled}:null,It={active:Ue,activatorEvent:Ce,collisions:_e,delta:{x:ht.x,y:ht.y},over:cn};uc.unstable_batchedUpdates(()=>{st(cn),wt?.(It),E({type:"onDragOver",event:It})})},[Ae]),bl(()=>{ue.current={activatorEvent:V,active:q,activeNode:de,collisionRect:ge,collisions:me,droppableRects:ee,draggableNodes:I,draggingNode:H,draggingNodeRect:ie,droppableContainers:D,over:ze,scrollableAncestors:ke,scrollAdjustedTranslate:we},j.current={initial:ie,translated:ge}},[q,de,me,ge,I,H,ie,ee,D,ze,ke,we]),E9e({...ye,delta:C,draggingRect:ge,pointerCoordinates:B,scrollableAncestors:ke,scrollableAncestorRects:Ne});const Q=M.useMemo(()=>({active:q,activeNode:de,activeNodeRect:ve,activatorEvent:V,collisions:me,containerNodeRect:je,dragOverlay:$,draggableNodes:I,droppableContainers:D,droppableRects:ee,over:ze,measureDroppableContainers:ae,scrollableAncestors:ke,scrollableAncestorRects:Ne,measuringConfiguration:z,measuringScheduled:fe,windowRect:le}),[q,de,ve,V,me,je,$,I,D,ee,ze,ae,ke,Ne,z,fe,le]),Fe=M.useMemo(()=>({activatorEvent:V,activators:at,active:q,activeNodeRect:ve,ariaDescribedById:{draggable:Z},dispatch:b,draggableNodes:I,over:ze,measureDroppableContainers:ae}),[V,at,q,ve,b,Z,I,ze,ae]);return mr.createElement(Oee.Provider,{value:S},mr.createElement(oM.Provider,{value:Fe},mr.createElement(Yee.Provider,{value:Q},mr.createElement(Zee.Provider,{value:ce},u)),mr.createElement(q9e,{disabled:o?.restoreFocus===!1})),mr.createElement(YVe,{...o,hiddenTextDescribedById:Z}));function pe(){const Ue=W?.autoScrollEnabled===!1,Ce=typeof l=="object"?l.enabled===!1:l===!1,_e=k&&!Ue&&!Ce;return typeof l=="object"?{...l,enabled:_e}:{enabled:_e}}}),Z9e=M.createContext(null),sG="button",Q9e="Draggable";function J9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Xb(Q9e),{activators:a,activatorEvent:o,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=M.useContext(oM),{role:m=sG,roleDescription:x="draggable",tabIndex:y=0}=i??{},v=l?.id===e,b=M.useContext(v?Zee:Z9e),[E,S]=wS(),[A,T]=wS(),k=I9e(a,e),N=tb(n);bl(()=>(f.set(e,{id:e,key:s,node:E,activatorNode:A,data:N}),()=>{const C=f.get(e);C&&C.key===s&&f.delete(e)}),[f,e]);const I=M.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&m===sG?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,y,v,x,d.draggable]);return{active:l,activatorEvent:o,activeNodeRect:u,attributes:I,isDragging:v,listeners:r?void 0:k,node:E,over:g,setNodeRef:S,setActivatorNodeRef:T,transform:b}}function eGe(){return M.useContext(Yee)}const tGe="Droppable",nGe={timeout:25};function rGe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Xb(tGe),{active:a,dispatch:o,over:l,measureDroppableContainers:u}=M.useContext(oM),d=M.useRef({disabled:n}),f=M.useRef(!1),g=M.useRef(null),m=M.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:v}={...nGe,...i},b=tb(y??r),E=M.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(b.current)?b.current:[b.current]),m.current=null},v)},[v]),S=aM({callback:E,disabled:x||!a}),A=M.useCallback((I,C)=>{S&&(C&&(S.unobserve(C),f.current=!1),I&&S.observe(I))},[S]),[T,k]=wS(A),N=tb(e);return M.useEffect(()=>{!S||!T.current||(S.disconnect(),f.current=!1,S.observe(T.current))},[T,S]),M.useEffect(()=>(o({type:ui.RegisterDroppable,element:{id:r,key:s,disabled:n,node:T,rect:g,data:N}}),()=>o({type:ui.UnregisterDroppable,key:s,id:r})),[r]),M.useEffect(()=>{n!==d.current.disabled&&(o({type:ui.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,o]),{active:a,rect:g,isOver:l?.id===r,node:T,over:l,setNodeRef:k}}function lM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function iGe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function U_(t){return t!==null&&t>=0}function sGe(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 aGe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const lL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=lM(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}},F_={scaleX:1,scaleY:1},oGe=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 u=s[a];return u?{x:0,y:n<a?u.top+u.height-(o.top+o.height):u.top-o.top,...F_}:null}const l=lGe(s,i,n);return i>n&&i<=a?{x:0,y:-o.height-l,...F_}:i<n&&i>=a?{x:0,y:o.height+l,...F_}:{x:0,y:0,...F_}};function lGe(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 Jee="Sortable",ete=mr.createContext({activeIndex:-1,containerId:Jee,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lL,disabled:{draggable:!1,droppable:!1}});function tte(t){let{children:e,id:n,items:r,strategy:i=lL,disabled:s=!1}=t;const{active:a,dragOverlay:o,droppableRects:l,over:u,measureDroppableContainers:d}=eGe(),f=Xb(Jee,n),g=o.rect!==null,m=M.useMemo(()=>r.map(k=>typeof k=="object"&&"id"in k?k.id:k),[r]),x=a!=null,y=a?m.indexOf(a.id):-1,v=u?m.indexOf(u.id):-1,b=M.useRef(m),E=!sGe(m,b.current),S=v!==-1&&y===-1||E,A=aGe(s);bl(()=>{E&&x&&d(m)},[E,m,x,d]),M.useEffect(()=>{b.current=m},[m]);const T=M.useMemo(()=>({activeIndex:y,containerId:f,disabled:A,disableTransforms:S,items:m,overIndex:v,useDragOverlay:g,sortedRects:iGe(m,l),strategy:i}),[y,f,A.draggable,A.droppable,S,m,v,l,g,i]);return mr.createElement(ete.Provider,{value:T},e)}const cGe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return lM(n,r,i).indexOf(e)},uGe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:a,previousItems:o,previousContainerId:l,transition:u}=t;return!u||!r||o!==s&&i===a?!1:n?!0:a!==i&&e===l},dGe={duration:200,easing:"ease"},nte="transform",hGe=Lm.Transition.toString({property:nte,duration:0,easing:"linear"}),fGe={roleDescription:"sortable"};function pGe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,a]=M.useState(null),o=M.useRef(n);return bl(()=>{if(!e&&n!==o.current&&r.current){const l=i.current;if(l){const u=og(r.current,{ignoreTransform:!0}),d={x:l.left-u.left,y:l.top-u.top,scaleX:l.width/u.width,scaleY:l.height/u.height};(d.x||d.y)&&a(d)}}n!==o.current&&(o.current=n)},[e,n,r,i]),M.useEffect(()=>{s&&a(null)},[s]),s}function rte(t){let{animateLayoutChanges:e=uGe,attributes:n,disabled:r,data:i,getNewIndex:s=cGe,id:a,strategy:o,resizeObserverConfig:l,transition:u=dGe}=t;const{items:d,containerId:f,activeIndex:g,disabled:m,disableTransforms:x,sortedRects:y,overIndex:v,useDragOverlay:b,strategy:E}=M.useContext(ete),S=mGe(r,m),A=d.indexOf(a),T=M.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),k=M.useMemo(()=>d.slice(d.indexOf(a)),[d,a]),{rect:N,node:I,isOver:C,setNodeRef:D}=rGe({id:a,data:T,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...l}}),{active:F,activatorEvent:j,activeNodeRect:q,attributes:R,setNodeRef:W,listeners:K,isDragging:V,over:te,setActivatorNodeRef:Y,transform:Z}=J9e({id:a,data:T,attributes:{...fGe,...n},disabled:S.draggable}),U=IVe(D,W),z=!!F,ee=z&&!x&&U_(g)&&U_(v),ae=!b&&V,fe=ae&&ee?Z:null,xe=ee?fe??(o??E)({rects:y,activeNodeRect:q,activeIndex:g,overIndex:v,index:A}):null,ye=U_(g)&&U_(v)?s({id:a,items:d,activeIndex:g,overIndex:v}):A,re=F?.id,ve=M.useRef({activeId:re,items:d,newIndex:ye,containerId:f}),je=d!==ve.current.items,ue=e({active:F,containerId:f,isDragging:V,isSorting:z,id:a,index:A,items:d,newIndex:ve.current.newIndex,previousItems:ve.current.items,previousContainerId:ve.current.containerId,transition:u,wasDragging:ve.current.activeId!=null}),ut=pGe({disabled:!ue,index:A,node:I,rect:N});return M.useEffect(()=>{z&&ve.current.newIndex!==ye&&(ve.current.newIndex=ye),f!==ve.current.containerId&&(ve.current.containerId=f),d!==ve.current.items&&(ve.current.items=d)},[z,ye,f,d]),M.useEffect(()=>{if(re===ve.current.activeId)return;if(re!=null&&ve.current.activeId==null){ve.current.activeId=re;return}const H=setTimeout(()=>{ve.current.activeId=re},50);return()=>clearTimeout(H)},[re]),{active:F,activeIndex:g,attributes:R,data:T,rect:N,index:A,newIndex:ye,items:d,isOver:C,isSorting:z,isDragging:V,listeners:K,node:I,overIndex:v,over:te,setNodeRef:U,setActivatorNodeRef:Y,setDroppableNodeRef:D,setDraggableNodeRef:W,transform:ut??xe,transition:$()};function $(){if(ut||je&&ve.current.newIndex===A)return hGe;if(!(ae&&!sL(j)||!u)&&(z||ue))return Lm.Transition.toString({...u,property:nte})}}function mGe(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 AS(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 gGe=[wn.Down,wn.Right,wn.Up,wn.Left],ite=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:a,scrollableAncestors:o}}=e;if(gGe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case wn.Down:r.top<g.top&&l.push(f);break;case wn.Up:r.top>g.top&&l.push(f);break;case wn.Left:r.left>g.left&&l.push(f);break;case wn.Right:r.left<g.left&&l.push(f);break}});const u=QVe({collisionRect:r,droppableRects:i,droppableContainers:l});let d=Uee(u,"id");if(d===a?.id&&u.length>1&&(d=u[1].id),d!=null){const f=s.get(n.id),g=s.get(d),m=g?i.get(g.id):null,x=g?.node.current;if(x&&m&&f&&g){const v=rM(x).some((k,N)=>o[N]!==k),b=ste(f,g),E=xGe(f,g),S=v||!b?{x:0,y:0}:{x:E?r.width-m.width:0,y:E?r.height-m.height:0},A={x:m.left,y:m.top};return S.x&&S.y?A:nb(A,S)}}}};function ste(t,e){return!AS(t)||!AS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function xGe(t,e){return!AS(t)||!AS(e)||!ste(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function bGe({item:t,onClose:e}){const n=En(),{showToast:r}=ii(),[i,s]=M.useState(t.printer_id),a=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,l]=M.useState(t.scheduled_time&&!a?"scheduled":"asap"),[u,d]=M.useState(()=>t.scheduled_time&&!a?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=M.useState(t.require_previous_success),[m,x]=M.useState(t.auto_off_after),{data:y}=yt({queryKey:["printers"],queryFn:()=>Pe.getPrinters()});M.useEffect(()=>{const S=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const v=_t({mutationFn:S=>Pe.updateQueueItem(t.id,S),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:S=>{r(S.message||"Failed to update queue item","error")}}),b=S=>{S.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:m};o==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,v.mutate(A)},E=()=>{const S=new Date;return S.setMinutes(S.getMinutes()+1),S.toISOString().slice(0,16)};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsx(kt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ed,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),c.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?c.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[c.jsx(jo,{className:"w-4 h-4"}),"No printers configured"]}):c.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:S=>s(Number(S.target.value)),required:!0,children:y?.map(S=>c.jsx("option",{value:S.id,children:S.name},S.id))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),c.jsxs("div",{className:"flex gap-2",children:[c.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:[c.jsx(ni,{className:"w-4 h-4"}),"ASAP (when idle)"]}),c.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:[c.jsx(Xr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),c.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:E(),required:!0})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),c.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[c.jsx(gd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),c.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."}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsx(Ie,{type:"submit",className:"flex-1",disabled:v.isPending||y?.length===0,children:v.isPending?"Saving...":"Save Changes"})]})]})]})})})}function ate(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 vGe(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 yGe({status:t}){const e={pending:{icon:ni,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:jS,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:fs,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:md,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:w1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Gt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return c.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[c.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function i3({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:a}){const{attributes:o,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:g}=rte({id:t.id,disabled:t.status!=="pending"}),m={transform:Lm.Transform.toString(d),transition:f},x=t.status==="printing",y=t.status==="pending",v=["completed","failed","skipped","cancelled"].includes(t.status);return c.jsx("div",{ref:u,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":""}
- ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:c.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?c.jsx("div",{...o,...l,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:c.jsx(f0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?c.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]}):c.jsx("div",{className:"w-8"}),c.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?c.jsx("img",{src:Pe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:c.jsx(Fh,{className:"w-6 h-6"})})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),c.jsx(kS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:c.jsx(io,{className:"w-3.5 h-3.5"})})]}),c.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Lo,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Iu,{className:"w-3.5 h-3.5"}),ate(t.print_time_seconds)]}),y&&c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(ni,{className:"w-3.5 h-3.5"}),vGe(t.scheduled_time)]})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&c.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&&c.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:[c.jsx(gd,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&c.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[c.jsx(jo,{className:"w-3 h-3"}),t.error_message]})]}),c.jsx(yGe,{status:t.status}),c.jsxs("div",{className:"flex items-center gap-1",children:[x&&c.jsx(Ie,{variant:"ghost",size:"sm",onClick:s,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:c.jsx(voe,{className:"w-4 h-4"})}),y&&c.jsxs(c.Fragment,{children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:c.jsx(ed,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),v&&c.jsxs(c.Fragment,{children:[c.jsx(Ie,{variant:"ghost",size:"sm",onClick:a,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:c.jsx(Xs,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:c.jsx(kn,{className:"w-4 h-4"})})]})]})]})})}function _Ge(){const t=En(),{showToast:e}=ii(),[n,r]=M.useState(null),[i,s]=M.useState(""),[a,o]=M.useState(!1),[l,u]=M.useState(null),[d,f]=M.useState(null),[g,m]=M.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,y]=M.useState(()=>{const Y=localStorage.getItem("queue.historySortAsc");return Y!==null?Y==="true":!1}),[v,b]=M.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[E,S]=M.useState(()=>{const Y=localStorage.getItem("queue.pendingSortAsc");return Y!==null?Y==="true":!0});M.useEffect(()=>{localStorage.setItem("queue.historySortBy",g)},[g]),M.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",v)},[v]),M.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(E))},[E]);const A=jee(ES(sM,{activationConstraint:{distance:8}}),ES(iM,{coordinateGetter:ite})),{data:T,isLoading:k}=yt({queryKey:["queue",n,i],queryFn:()=>Pe.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:N}=yt({queryKey:["printers"],queryFn:()=>Pe.getPrinters()}),I=_t({mutationFn:Y=>Pe.cancelQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),C=_t({mutationFn:Y=>Pe.removeFromQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=_t({mutationFn:Y=>Pe.stopQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=_t({mutationFn:Y=>Pe.reorderQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),j=_t({mutationFn:Y=>{const Z=new Date;return Z.setFullYear(Z.getFullYear()+1),Pe.addToQueue({printer_id:Y.printer_id,archive_id:Y.archive_id,scheduled_time:Z.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),u(Y)},onError:Y=>e(Y.message||"Failed to re-queue item","error")}),q=_t({mutationFn:async()=>{const Y=T?.filter(Z=>["completed","failed","skipped","cancelled"].includes(Z.status))||[];for(const Z of Y)await Pe.removeFromQueue(Z.id);return Y.length},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Y} history item${Y!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),R=M.useMemo(()=>{const Y=T?.filter(U=>U.status==="pending")||[],Z=U=>{if(!U.scheduled_time)return 0;const z=new Date(U.scheduled_time).getTime(),ee=Date.now()+4320*60*60*1e3;return z>ee?0:z};return[...Y].sort((U,z)=>{let ee;return v==="name"?ee=(U.archive_name||"").localeCompare(z.archive_name||""):v==="printer"?ee=(U.printer_name||"").localeCompare(z.printer_name||""):v==="time"?ee=Z(U)-Z(z):ee=U.position-z.position,E?ee:-ee})},[T,v,E]),W=T?.filter(Y=>Y.status==="printing")||[],K=M.useMemo(()=>[...T?.filter(Z=>["completed","failed","skipped","cancelled"].includes(Z.status))||[]].sort((Z,U)=>{let z;return g==="name"?z=(Z.archive_name||"").localeCompare(U.archive_name||""):g==="printer"?z=(Z.printer_name||"").localeCompare(U.printer_name||""):z=new Date(U.completed_at||U.created_at).getTime()-new Date(Z.completed_at||Z.created_at).getTime(),x?-z:z}),[T,g,x]),V=M.useMemo(()=>R.reduce((Y,Z)=>Y+(Z.print_time_seconds||0),0),[R]),te=Y=>{const{active:Z,over:U}=Y;if(!U||Z.id===U.id)return;const z=R.findIndex(ae=>ae.id===Z.id),ee=R.findIndex(ae=>ae.id===U.id);if(z!==-1&&ee!==-1){const fe=lM(R,z,ee).map((de,xe)=>({id:de.id,position:xe+1}));F.mutate(fe)}};return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsx("div",{className:"flex items-center justify-between mb-8",children:c.jsxs("div",{children:[c.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[c.jsx(r7,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),c.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[c.jsx(kt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:c.jsx(jS,{className:"w-5 h-5 text-blue-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),c.jsx(kt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:c.jsx(ni,{className:"w-5 h-5 text-yellow-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:R.length}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),c.jsx(kt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:c.jsx(Iu,{className:"w-5 h-5 text-bambu-green"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:ate(V)}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),c.jsx(kt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:c.jsx(Dt,{className:"p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:c.jsx(fs,{className:"w-5 h-5 text-gray-400"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),c.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Y=>r(Y.target.value?Number(Y.target.value):null),children:[c.jsx("option",{value:"",children:"All Printers"}),N?.map(Y=>c.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),c.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:Y=>s(Y.target.value),children:[c.jsx("option",{value:"",children:"All Status"}),c.jsx("option",{value:"pending",children:"Pending"}),c.jsx("option",{value:"printing",children:"Printing"}),c.jsx("option",{value:"completed",children:"Completed"}),c.jsx("option",{value:"failed",children:"Failed"}),c.jsx("option",{value:"skipped",children:"Skipped"}),c.jsx("option",{value:"cancelled",children:"Cancelled"})]}),c.jsx("div",{className:"flex-1"}),K.length>0&&c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Clear History"]})]}),k?c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?c.jsxs(kt,{className:"p-12 text-center border-dashed",children:[c.jsx(Xr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),c.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),c.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.'})]}):c.jsxs("div",{className:"space-y-8",children:[W.length>0&&c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),c.jsx("div",{className:"space-y-3",children:W.map(Y=>c.jsx(i3,{item:Y,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>f({type:"stop",item:Y}),onRequeue:()=>{}},Y.id))})]}),R.length>0&&c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(ni,{className:"w-5 h-5 text-yellow-400"}),"Queued",c.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",R.length," item",R.length!==1?"s":"",")"]}),c.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)"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.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:Y=>b(Y.target.value),children:[c.jsx("option",{value:"position",children:"Sort by Position"}),c.jsx("option",{value:"name",children:"Sort by Name"}),c.jsx("option",{value:"printer",children:"Sort by Printer"}),c.jsx("option",{value:"time",children:"Sort by Schedule"})]}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>S(!E),title:E?"Ascending":"Descending",className:"px-2",children:E?c.jsx(om,{className:"w-4 h-4"}):c.jsx(c0,{className:"w-4 h-4"})})]})]}),c.jsx(Qee,{sensors:A,collisionDetection:Fee,onDragEnd:te,children:c.jsx(tte,{items:R.map(Y=>Y.id),strategy:oGe,children:c.jsx("div",{className:"space-y-3",children:R.map((Y,Z)=>c.jsx(i3,{item:Y,position:Z+1,onEdit:()=>u(Y),onCancel:()=>f({type:"cancel",item:Y}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Y.id))})})})]}),K.length>0&&c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(fs,{className:"w-5 h-5 text-bambu-gray"}),"History",c.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:g,onChange:Y=>m(Y.target.value),children:[c.jsx("option",{value:"date",children:"Sort by Date"}),c.jsx("option",{value:"name",children:"Sort by Name"}),c.jsx("option",{value:"printer",children:"Sort by Printer"})]}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>y(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?c.jsx(om,{className:"w-4 h-4"}):c.jsx(c0,{className:"w-4 h-4"})})]})]}),c.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Y,Z)=>c.jsx(i3,{item:Y,position:Z+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Y}),onStop:()=>{},onRequeue:()=>j.mutate(Y)},Y.id))})]})]}),l&&c.jsx(bGe,{item:l,onClose:()=>u(null)}),d&&c.jsx(Yr,{title:d.type==="cancel"?"Cancel Scheduled Print":d.type==="stop"?"Stop Print":"Remove from History",message:d.type==="cancel"?`Are you sure you want to cancel "${d.item.archive_name||"this print"}"?`:d.type==="stop"?`Are you sure you want to stop the current print "${d.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${d.item.archive_name||"this item"}" from the queue history?`,confirmText:d.type==="cancel"?"Cancel Print":d.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{d.type==="cancel"?I.mutate(d.item.id):d.type==="stop"?D.mutate(d.item.id):C.mutate(d.item.id),f(null)},onCancel:()=>f(null)}),a&&c.jsx(Yr,{title:"Clear History",message:`Are you sure you want to remove all ${K.length} item${K.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{q.mutate(),o(!1)},onCancel:()=>o(!1)})]})}function wGe({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=M.useMemo(()=>{const l={};t.forEach(b=>{const E=b.split("T")[0];l[E]=(l[E]||0)+1});const u=new Date,d=new Date(u);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const f=[],g=[];let m=[],x=-1;const y=new Date(d);let v=0;for(;y<=u;)y.getDay()===0&&m.length>0&&(f.push(m),m=[],v++),y.getMonth()!==x&&(g.push({month:y.toLocaleDateString("en-US",{month:"short"}),weekIndex:v}),x=y.getMonth()),m.push(new Date(y)),y.setDate(y.getDate()+1);return m.length>0&&f.push(m),{weeks:f,monthLabels:g,printCounts:l}},[t,e]),s=Math.max(1,...Object.values(i)),a=l=>{if(l===0)return"bg-bambu-dark";const u=l/s;return u<=.25?"bg-bambu-green/30":u<=.5?"bg-bambu-green/50":u<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return c.jsxs("div",{className:"overflow-x-auto",children:[c.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:l,weekIndex:u},d)=>c.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(u-(r[d-1]?.weekIndex||0))*14-24}px`},children:l},d))}),c.jsxs("div",{className:"flex gap-0.5",children:[c.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,u)=>c.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:u%2===1?"visible":"hidden"},children:l},l))}),n.map((l,u)=>c.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=l.find(y=>y.getDay()===d);if(!f)return c.jsx("div",{className:"w-3 h-3"},d);const g=f.toISOString().split("T")[0],m=i[g]||0,x=g===new Date().toISOString().split("T")[0];return c.jsx("div",{className:`w-3 h-3 rounded-sm ${a(m)} ${x?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},d)})},u))]}),c.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[c.jsx("span",{children:"Less"}),c.jsxs("div",{className:"flex gap-0.5",children:[c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),c.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),c.jsx("span",{children:"More"})]})]})}const z_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function SGe(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 EGe({archives:t,currency:e="$"}){const[n,r]=M.useState("30d"),i=M.useMemo(()=>{const g=SGe(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=g)},[t,n]),s=M.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,x)=>m.date.localeCompare(x.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),a=M.useMemo(()=>{if(n==="7d"||n==="30d")return s;const g=new Map;return i.forEach(m=>{const x=new Date(m.completed_at||m.created_at),y=new Date(x);y.setDate(x.getDate()-x.getDay());const v=y.toISOString().split("T")[0],b=g.get(v)||{week:v,filament:0,cost:0,prints:0};b.filament+=m.filament_used_grams||0,b.cost+=m.cost||0,b.prints+=1,g.set(v,b)}),Array.from(g.values()).sort((m,x)=>m.week.localeCompare(x.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=M.useMemo(()=>{const g=new Map;return i.forEach(m=>{const y=(m.filament_type||"Unknown").split(", ");y.forEach(v=>{const b=(m.filament_used_grams||0)/y.length;g.set(v,(g.get(v)||0)+b)})}),Array.from(g.entries()).map(([m,x])=>({name:m,value:Math.round(x)})).sort((m,x)=>x.value-m.value)},[i]),l=M.useMemo(()=>{const g=new Date,m=[];for(let x=5;x>=0;x--){const y=new Date(g.getFullYear(),g.getMonth()-x,1),v=new Date(g.getFullYear(),g.getMonth()-x+1,0),b=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(S=>{const A=new Date(S.completed_at||S.created_at);return A>=y&&A<=v});m.push({month:b,filament:Math.round(E.reduce((S,A)=>S+(A.filament_used_grams||0),0)),cost:E.reduce((S,A)=>S+(A.cost||0),0),prints:E.length})}return m},[t]),u=n==="7d"||n==="30d"?s:a,d=i.reduce((g,m)=>g+(m.filament_used_grams||0),0),f=i.reduce((g,m)=>g+(m.cost||0),0);return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),c.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>c.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))})]}),c.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),c.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),c.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),c.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),c.jsx(K_,{width:"100%",height:250,children:c.jsxs(HTe,{data:u,children:[c.jsx("defs",{children:c.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[c.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),c.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),c.jsx(mw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),c.jsx(xw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),c.jsx(bw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),c.jsx(Y_,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),c.jsx(pY,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):c.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx(K_,{width:160,height:160,children:c.jsxs(zTe,{children:[c.jsx(UX,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>c.jsx(Lb,{fill:z_[m%z_.length]},`cell-${m}`))}),c.jsx(Y_,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),c.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const x=o.reduce((v,b)=>v+b.value,0),y=x>0?(g.value/x*100).toFixed(0):0;return c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:z_[m%z_.length]}}),c.jsx("span",{className:"text-white truncate flex-1",children:g.name}),c.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):c.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[c.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),c.jsx(K_,{width:"100%",height:200,children:c.jsxs(CTe,{data:l,children:[c.jsx(mw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),c.jsx(xw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),c.jsx(bw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),c.jsx(Y_,{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"]}),c.jsx(hD,{}),c.jsx(VX,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function MGe({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:a}){const{attributes:o,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:g}=rte({id:t}),m={transform:Lm.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:c.jsxs("div",{ref:u,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:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.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:c.jsx(f0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),c.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.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?c.jsx(Jle,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):c.jsx(qle,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),c.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:c.jsx(PR,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),c.jsx("div",{className:"p-4",children:n})]})}function AGe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i}){const s=()=>{const E={};return t.forEach(S=>{E[S.id]=S.defaultSize||4}),E},[a,o]=M.useState(()=>{const E=localStorage.getItem(e);if(E)try{const S=JSON.parse(E);return S.sizes||(S.sizes=s()),S}catch{}return{order:t.map(S=>S.id),hidden:t.filter(S=>S.defaultVisible===!1).map(S=>S.id),sizes:s()}}),[l,u]=M.useState(!1);M.useEffect(()=>{localStorage.setItem(e,JSON.stringify(a))},[a,e]),M.useEffect(()=>{const S=t.map(A=>A.id).filter(A=>!a.order.includes(A));S.length>0&&o(A=>({...A,order:[...A.order,...S]}))},[t,a.order]);const d=jee(ES(sM,{activationConstraint:{distance:8}}),ES(iM,{coordinateGetter:ite})),f=E=>{const{active:S,over:A}=E;A&&S.id!==A.id&&o(T=>{const k=T.order.indexOf(S.id),N=T.order.indexOf(A.id);return{...T,order:lM(T.order,k,N)}})},g=E=>{o(S=>({...S,hidden:S.hidden.includes(E)?S.hidden.filter(A=>A!==E):[...S.hidden,E]}))},m=E=>{o(S=>{const A=S.sizes[E]||4,T=A===1?2:A===2?4:1;return{...S,sizes:{...S.sizes,[E]:T}}})},x=()=>{const E={order:t.map(S=>S.id),hidden:t.filter(S=>S.defaultVisible===!1).map(S=>S.id),sizes:s()};o(E),i?.()},y=a.order.map(E=>t.find(S=>S.id===E)).filter(Boolean),v=y.filter(E=>!a.hidden.includes(E.id)),b=y.filter(E=>a.hidden.includes(E.id));return c.jsxs("div",{className:"space-y-4",children:[!r&&c.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b.length>0&&c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>u(!l),children:[c.jsx(d0,{className:"w-4 h-4"}),b.length," Hidden"]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:x,children:[c.jsx(Bm,{className:"w-4 h-4"}),"Reset Layout"]})]}),l&&b.length>0&&c.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(E=>c.jsxs("button",{onClick:()=>g(E.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:[c.jsx(d0,{className:"w-3 h-3"}),E.title]},E.id))})]}),c.jsx(Qee,{sensors:d,collisionDetection:Fee,onDragEnd:f,children:c.jsx(tte,{items:v.map(E=>E.id),strategy:lL,children:c.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(E=>c.jsx(MGe,{id:E.id,title:E.title,isHidden:a.hidden.includes(E.id),size:a.sizes[E.id]||2,onToggleVisibility:()=>g(E.id),onToggleSize:()=>m(E.id),children:E.component},E.id))})})}),v.length===0&&c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx("p",{children:"All widgets are hidden."}),c.jsx(Ie,{className:"mt-4",onClick:x,children:"Reset Layout"})]})]})}function TGe({stats:t,currency:e}){return c.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:c.jsx(p0,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),c.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:c.jsx(ni,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:c.jsx(p0,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:c.jsx(S3,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:c.jsx(dm,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:c.jsx(S3,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),c.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function CGe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return c.jsxs("div",{className:"flex items-center gap-6",children:[c.jsxs("div",{className:"relative w-28 h-28",children:[c.jsxs("svg",{className:"w-full h-full -rotate-90",children:[c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),c.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:c.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(fs,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),c.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(md,{className:"w-4 h-4 text-red-400"}),c.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),c.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function NGe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return c.jsx("div",{className:"flex items-center justify-center h-full",children:c.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 c.jsxs("div",{className:"flex items-center gap-6",children:[c.jsxs("div",{className:"relative w-28 h-28",children:[c.jsxs("svg",{className:"w-full h-full -rotate-90",children:[c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),c.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:a,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),c.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[c.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),c.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),c.jsxs("div",{className:"space-y-2 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[c.jsx(s7,{className:"w-3 h-3"}),c.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&c.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,u])=>c.jsxs("div",{className:"flex items-center justify-between text-xs",children:[c.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),c.jsxs("span",{className:`font-medium ${u>=95&&u<=105?"text-bambu-green":u>105?"text-blue-400":"text-orange-400"}`,children:[u.toFixed(0),"%"]})]},l))})]})]})}function kGe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return c.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 c.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return c.jsxs("div",{children:[c.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[c.jsx("span",{className:"text-white",children:n}),c.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),c.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:c.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function PGe({printDates:t}){return c.jsx(wGe,{printDates:t,months:4})}function RGe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>c.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[c.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:c.jsx(Lo,{className:"w-4 h-4 text-bambu-green"})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function DGe({archives:t,currency:e}){return!t||t.length===0?c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):c.jsx(EGe,{archives:t,currency:e})}function OGe(){const{data:t,isLoading:e}=yt({queryKey:["failureAnalysis"],queryFn:()=>Pe.getFailureAnalysis({days:30})});if(e)return c.jsx("div",{className:"flex justify-center py-4",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!t||t.total_prints===0)return c.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const n=Object.entries(t.failures_by_reason).sort(([,r],[,i])=>i-r).slice(0,5);return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Jr,{className:`w-5 h-5 ${t.failure_rate>20?"text-red-400":t.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),c.jsxs("span",{className:"text-2xl font-bold text-white",children:[t.failure_rate.toFixed(1),"%"]}),c.jsx("span",{className:"text-sm text-bambu-gray",children:"failure rate"})]}),c.jsxs("div",{className:"text-sm text-bambu-gray",children:[t.failed_prints," / ",t.total_prints," prints failed"]})]}),n.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray font-medium",children:"Top Failure Reasons"}),n.map(([r,i])=>c.jsxs("div",{className:"flex items-center justify-between text-sm",children:[c.jsx("span",{className:"text-white truncate max-w-[200px]",children:r||"Unknown"}),c.jsx("span",{className:"text-bambu-gray",children:i})]},r))]}),t.trend&&t.trend.length>=2&&c.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(o7,{className:`w-4 h-4 ${t.trend[t.trend.length-1].failure_rate<t.trend[t.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),c.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",t.trend[t.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]})}function jGe(){const{showToast:t}=ii(),[e,n]=M.useState(!1),[r,i]=M.useState(!1),[s,a]=M.useState(0),{data:o,isLoading:l}=yt({queryKey:["archiveStats"],queryFn:Pe.getArchiveStats}),{data:u}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:d}=yt({queryKey:["archives"],queryFn:()=>Pe.getArchives(void 0,1e3,0)}),{data:f}=yt({queryKey:["settings"],queryFn:Pe.getSettings}),g=async E=>{i(!1),n(!0);try{const{blob:S,filename:A}=await Pe.exportStats({format:E,days:90}),T=URL.createObjectURL(S),k=document.createElement("a");k.href=T,k.download=A,k.click(),URL.revokeObjectURL(T),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},m=f?.currency||"$",x=new Map(u?.map(E=>[String(E.id),E.name])||[]),y=d?.map(E=>E.created_at)||[];if(l)return c.jsx("div",{className:"p-4 md:p-8",children:c.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const v=[{id:"quick-stats",title:"Quick Stats",component:c.jsx(TGe,{stats:o,currency:m}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:c.jsx(CGe,{stats:o}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:c.jsx(NGe,{stats:o,printerMap:x}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:c.jsx(kGe,{stats:o}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:c.jsx(OGe,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:c.jsx(PGe,{printDates:y}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:c.jsx(RGe,{stats:o,printerMap:x}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:c.jsx(DGe,{archives:d||[],currency:m}),defaultSize:4}],b=()=>{localStorage.removeItem("bambusy-dashboard-layout"),a(E=>E+1),t("Layout reset")};return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"flex items-center justify-between mb-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),c.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{variant:"secondary",onClick:b,children:[c.jsx(Bm,{className:"w-4 h-4"}),"Reset Layout"]}),c.jsxs("div",{className:"relative",children:[c.jsxs(Ie,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(y1,{className:"w-4 h-4"}),"Export Stats"]}),r&&c.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>g("csv"),children:[c.jsx(Za,{className:"w-4 h-4"}),"Export as CSV"]}),c.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>g("xlsx"),children:[c.jsx(y1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),c.jsx(AGe,{widgets:v,storageKey:"bambusy-dashboard-layout",hideControls:!0},s)]})}function LGe({plug:t,onEdit:e}){const n=En(),[r,i]=M.useState(!1),[s,a]=M.useState(!1),[o,l]=M.useState(!1),[u,d]=M.useState(!1),{data:f,isLoading:g,refetch:m}=yt({queryKey:["smart-plug-status",t.id],queryFn:()=>Pe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),y=x?.find(k=>k.id===t.printer_id),v=_t({mutationFn:k=>Pe.controlSmartPlug(t.id,k),onSuccess:()=>{m()}}),b=_t({mutationFn:k=>Pe.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=_t({mutationFn:()=>Pe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=f?.state==="ON",A=f?.reachable??!1,T=v.isPending;return c.jsxs(c.Fragment,{children:[c.jsx(kt,{className:"relative",children:c.jsxs(Dt,{className:"p-4",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-lg ${A?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:c.jsx(Ux,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-white",children:t.name}),c.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),c.jsx("div",{className:"flex items-center gap-2",children:g?c.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?c.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[c.jsx(d7,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:S?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):c.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[c.jsx(FR,{className:"w-4 h-4"}),c.jsx("span",{children:"Offline"})]})})]}),y&&c.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),c.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&c.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&c.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[c.jsx(xh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&c.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[c.jsx(Xr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),c.jsxs("div",{className:"flex gap-2 mb-3",children:[c.jsxs(Ie,{size:"sm",variant:S?"primary":"secondary",disabled:!A||T,onClick:()=>a(!0),className:"flex-1",children:[T?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(gd,{className:"w-4 h-4"}),"On"]}),c.jsxs(Ie,{size:"sm",variant:S?"secondary":"primary",disabled:!A||T,onClick:()=>l(!0),className:"flex-1",children:[T?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(LR,{className:"w-4 h-4"}),"Off"]})]}),c.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(LS,{className:"w-4 h-4"}),"Automation Settings"]}),c.jsx("span",{children:u?"-":"+"})]}),u&&c.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Enabled"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t.enabled,onChange:k=>b.mutate({enabled:k.target.checked}),className:"sr-only peer"}),c.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"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Auto On"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:k=>b.mutate({auto_on:k.target.checked}),className:"sr-only peer"}),c.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"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:k=>b.mutate({auto_off:k.target.checked}),className:"sr-only peer"}),c.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&&c.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[c.jsx(ni,{className:"w-4 h-4"}),"Time"]}),c.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[c.jsx(vh,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),c.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:k=>b.mutate({off_delay_minutes:parseInt(k.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"})]}):c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),c.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:k=>b.mutate({off_temp_threshold:parseInt(k.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"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),c.jsxs("div",{className:"flex gap-2 pt-2",children:[c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[c.jsx(jR,{className:"w-4 h-4"}),"Edit"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})})]})]})]})}),r&&c.jsx(Yr,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(),i(!1)},onCancel:()=>i(!1)}),s&&c.jsx(Yr,{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&&c.jsx(Yr,{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 IGe({plug:t,onClose:e}){const n=En(),r=!!t,[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.ip_address||""),[l,u]=M.useState(t?.username||""),[d,f]=M.useState(t?.password||""),[g,m]=M.useState(t?.printer_id||null),[x,y]=M.useState(null),[v,b]=M.useState(null),[E,S]=M.useState(t?.power_alert_enabled||!1),[A,T]=M.useState(t?.power_alert_high?.toString()||""),[k,N]=M.useState(t?.power_alert_low?.toString()||""),[I,C]=M.useState(t?.schedule_enabled||!1),[D,F]=M.useState(t?.schedule_on_time||""),[j,q]=M.useState(t?.schedule_off_time||""),{data:R}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:W}=yt({queryKey:["smart-plugs"],queryFn:Pe.getSmartPlugs});M.useEffect(()=>{const z=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const K=_t({mutationFn:()=>Pe.testSmartPlugConnection(a,l||null,d||null),onSuccess:z=>{y(z),b(null),!i&&z.device_name&&s(z.device_name)},onError:z=>{y(null),b(z.message)}}),V=_t({mutationFn:z=>Pe.createSmartPlug(z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{b(z.message)}}),te=_t({mutationFn:z=>Pe.updateSmartPlug(t.id,z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{b(z.message)}}),Y=R?.filter(z=>!W?.some(ae=>ae.printer_id===z.id&&ae.id!==t?.id)),Z=z=>{if(z.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!a.trim()){b("IP address is required");return}const ee={name:i.trim(),ip_address:a.trim(),username:l.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:A?parseFloat(A):null,power_alert_low:k?parseFloat(k):null,schedule_enabled:I,schedule_on_time:D||null,schedule_off_time:j||null};r?te.mutate(ee):V.mutate(ee)},U=V.isPending||te.isPending;return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:z=>z.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:Z,className:"p-6 space-y-4",children:[v&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",value:a,onChange:z=>{o(z.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"}),c.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!a.trim()||K.isPending,children:[K.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(d7,{className:"w-4 h-4"}),"Test"]})]})]}),x&&c.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?c.jsxs(c.Fragment,{children:[c.jsx(fs,{className:"w-5 h-5"}),c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Connected!"}),c.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(FR,{className:"w-5 h-5"}),c.jsx("span",{children:"Connection failed"})]})}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),c.jsx("input",{type:"text",value:i,onChange:z=>s(z.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"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),c.jsx("input",{type:"text",value:l,onChange:z=>u(z.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),c.jsx("input",{type:"password",value:d,onChange:z=>f(z.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"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),c.jsxs("select",{value:g??"",onChange:z=>m(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:[c.jsx("option",{value:"",children:"No printer (manual control only)"}),Y?.map(z=>c.jsx("option",{value:z.id,children:z.name},z.id))]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),c.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(xh,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:E,onChange:z=>S(z.target.checked),className:"sr-only peer"}),c.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),c.jsx("input",{type:"number",value:A,onChange:z=>T(z.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),c.jsx("input",{type:"number",value:k,onChange:z=>N(z.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),c.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ni,{className:"w-4 h-4 text-bambu-green"}),c.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:I,onChange:z=>C(z.target.checked),className:"sr-only peer"}),c.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&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),c.jsx("input",{type:"time",value:D,onChange:z=>F(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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),c.jsx("input",{type:"time",value:j,onChange:z=>q(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"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:U,className:"flex-1",children:[U?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(Co,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Un({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return c.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:c.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const UGe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function FGe({provider:t,onEdit:e}){const n=En(),[r,i]=M.useState(!1),[s,a]=M.useState(!1),[o,l]=M.useState(null),{data:u}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=_t({mutationFn:y=>Pe.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=_t({mutationFn:()=>Pe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=_t({mutationFn:()=>Pe.testNotificationProvider(t.id),onSuccess:y=>{l(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{l({success:!1,message:y.message})}}),x=y=>y||"";return c.jsxs(c.Fragment,{children:[c.jsx(kt,{className:"relative",children:c.jsxs(Dt,{className:"p-4",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:c.jsx(xh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-white",children:t.name}),c.jsx("p",{className:"text-sm text-bambu-gray",children:UGe[t.provider_type]||t.provider_type})]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&c.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&c.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),c.jsx(Un,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),d&&c.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),c.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&c.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:c.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),c.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&c.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&c.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&c.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&c.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&c.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&c.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&c.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&c.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&&c.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&c.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"Humidity"}),t.on_ams_temperature_high&&c.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"Temperature"}),t.quiet_hours_enabled&&c.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[c.jsx(_1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&c.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[c.jsx(Xr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),c.jsx("div",{className:"mb-3",children:c.jsxs(Ie,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(IR,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&c.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?c.jsx(fs,{className:"w-4 h-4"}):c.jsx(md,{className:"w-4 h-4"}),c.jsx("span",{children:o.message})]}),c.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:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(LS,{className:"w-4 h-4"}),"Event Settings"]}),s?c.jsx(RS,{className:"w-4 h-4"}):c.jsx(af,{className:"w-4 h-4"})]}),s&&c.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Enabled"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),c.jsx(Un,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Started"}),c.jsx(Un,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),c.jsx(Un,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),c.jsx(Un,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),c.jsx(Un,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),c.jsx(Un,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),c.jsx(Un,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),c.jsx(Un,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),c.jsx(Un,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),c.jsx(Un,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Humidity High"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when humidity exceeds threshold"})]}),c.jsx(Un,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Temperature High"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when temperature exceeds threshold"})]}),c.jsx(Un,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_1,{className:"w-4 h-4 text-purple-400"}),c.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),c.jsx(Un,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&c.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ni,{className:"w-4 h-4 text-bambu-gray"}),c.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Xr,{className:"w-4 h-4 text-emerald-400"}),c.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),c.jsx(Un,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&c.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[c.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ni,{className:"w-4 h-4 text-bambu-gray"}),c.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),c.jsxs("div",{className:"flex gap-2 pt-2",children:[c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[c.jsx(jR,{className:"w-4 h-4"}),"Edit"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})})]})]})]})}),r&&c.jsx(Yr,{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 aG=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function zGe({provider:t,onClose:e}){const n=En(),r=!!t,[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.provider_type||"email"),[l,u]=M.useState(t?.printer_id||null),[d,f]=M.useState(t?.quiet_hours_enabled||!1),[g,m]=M.useState(t?.quiet_hours_start||"22:00"),[x,y]=M.useState(t?.quiet_hours_end||"07:00"),[v,b]=M.useState(t?.daily_digest_enabled||!1),[E,S]=M.useState(t?.daily_digest_time||"08:00"),[A,T]=M.useState(t?.on_print_start??!1),[k,N]=M.useState(t?.on_print_complete??!0),[I,C]=M.useState(t?.on_print_failed??!0),[D,F]=M.useState(t?.on_print_stopped??!0),[j,q]=M.useState(t?.on_print_progress??!1),[R,W]=M.useState(t?.on_printer_offline??!1),[K,V]=M.useState(t?.on_printer_error??!1),[te,Y]=M.useState(t?.on_filament_low??!1),[Z,U]=M.useState(t?.on_maintenance_due??!1),[z,ee]=M.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([G,J])=>[G,String(J)])):{}),[ae,fe]=M.useState(null),[de,xe]=M.useState(null),{data:ye}=yt({queryKey:["printers"],queryFn:Pe.getPrinters});M.useEffect(()=>{const G=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[e]);const re=_t({mutationFn:()=>Pe.testNotificationConfig({provider_type:a,config:z}),onSuccess:G=>{fe(G),xe(null)},onError:G=>{fe({success:!1,message:G.message})}}),ve=_t({mutationFn:G=>Pe.createNotificationProvider(G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),je=_t({mutationFn:G=>Pe.updateNotificationProvider(t.id,G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),ue=G=>{if(G.preventDefault(),xe(null),!i.trim()){xe("Name is required");return}const J=H(a);for(const ke of J)if(!z[ke.key]?.trim()){xe(`${ke.label} is required`);return}const le={name:i.trim(),provider_type:a,config:z,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:v,daily_digest_time:v?E:null,on_print_start:A,on_print_complete:k,on_print_failed:I,on_print_stopped:D,on_print_progress:j,on_printer_offline:R,on_printer_error:K,on_filament_low:te,on_maintenance_due:Z};r?je.mutate(le):ve.mutate(le)},ut=ve.isPending||je.isPending,$=G=>{switch(G){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},H=G=>$(G).filter(J=>J.required),ie=$(a);return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:G=>G.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:ue,className:"p-6 space-y-4",children:[de&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:de}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),c.jsx("input",{type:"text",value:i,onChange:G=>s(G.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),c.jsx("select",{value:a,onChange:G=>{o(G.target.value),ee({}),fe(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:aG.map(G=>c.jsx("option",{value:G.value,children:G.label},G.value))}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:aG.find(G=>G.value===a)?.description})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ie.map(G=>c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[G.label," ",G.required&&"*"]}),G.type==="select"&&G.options?c.jsx("select",{value:z[G.key]||G.options[0]?.value||"",onChange:J=>{ee({...z,[G.key]:J.target.value}),fe(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:G.options.map(J=>c.jsx("option",{value:J.value,children:J.label},J.value))}):c.jsx("input",{type:G.type,value:z[G.key]||"",onChange:J=>{ee({...z,[G.key]:J.target.value}),fe(null)},placeholder:G.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"})]},G.key))]}),c.jsx("div",{className:"flex gap-2",children:c.jsxs(Ie,{type:"button",variant:"secondary",onClick:()=>{fe(null),re.mutate()},disabled:re.isPending||!z[H(a)[0]?.key],className:"flex-1",children:[re.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(IR,{className:"w-4 h-4"}),"Test Configuration"]})}),ae&&c.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ae.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:ae.success?c.jsxs(c.Fragment,{children:[c.jsx(fs,{className:"w-5 h-5"}),c.jsx("span",{children:ae.message})]}):c.jsxs(c.Fragment,{children:[c.jsx(md,{className:"w-5 h-5"}),c.jsx("span",{children:ae.message})]})}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),c.jsxs("select",{value:l??"",onChange:G=>u(G.target.value?Number(G.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:[c.jsx("option",{value:"",children:"All printers"}),ye?.map(G=>c.jsx("option",{value:G.id,children:G.name},G.id))]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),c.jsx(Un,{checked:d,onChange:f})]}),d&&c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),c.jsx("input",{type:"time",value:g,onChange:G=>m(G.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),c.jsx("input",{type:"time",value:x,onChange:G=>y(G.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"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),c.jsx(Un,{checked:v,onChange:b})]}),v&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),c.jsx("input",{type:"time",value:E,onChange:G=>S(G.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"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),c.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),c.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Start"}),c.jsx(Un,{checked:A,onChange:T})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Complete"}),c.jsx(Un,{checked:k,onChange:N})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Failed"}),c.jsx(Un,{checked:I,onChange:C})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Stopped"}),c.jsx(Un,{checked:D,onChange:F})]}),c.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-sm text-white",children:"Progress"}),c.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),c.jsx(Un,{checked:j,onChange:q})]})]})]}),c.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[c.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),c.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Offline"}),c.jsx(Un,{checked:R,onChange:W})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Error"}),c.jsx(Un,{checked:K,onChange:V})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),c.jsx(Un,{checked:te,onChange:Y})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),c.jsx(Un,{checked:Z,onChange:U})]})]})]})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:ut,className:"flex-1",children:[ut?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(Co,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function BGe({template:t,onClose:e}){const n=En(),r=M.useRef(null),[i,s]=M.useState(t.title_template),[a,o]=M.useState(t.body_template),[l,u]=M.useState(null),[d,f]=M.useState(!0),{data:g}=yt({queryKey:["template-variables"],queryFn:Pe.getTemplateVariables}),m=g?.find(T=>T.event_type===t.event_type),{data:x,isLoading:y}=yt({queryKey:["template-preview",t.event_type,i,a],queryFn:()=>Pe.previewTemplate({event_type:t.event_type,title_template:i,body_template:a}),enabled:d&&i.length>0&&a.length>0});M.useEffect(()=>{const T=k=>{k.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const v=_t({mutationFn:T=>Pe.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),b=_t({mutationFn:()=>Pe.resetNotificationTemplate(t.id),onSuccess:T=>{s(T.title_template),o(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),E=T=>{if(T.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!a.trim()){u("Body is required");return}v.mutate({title_template:i,body_template:a})},S=T=>{const k=r.current;if(!k)return;const N=k.selectionStart,I=k.selectionEnd,C=a,D=C.substring(0,N),F=C.substring(I),j=D+`{${T}}`+F;o(j),setTimeout(()=>{k.focus();const q=N+T.length+2;k.setSelectionRange(q,q)},0)},A=i!==t.title_template||a!==t.body_template;return c.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),c.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:c.jsx(Gt,{className:"w-5 h-5 text-bambu-gray"})})]}),c.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[l&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:l}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),c.jsx("input",{type:"text",value:i,onChange:T=>s(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),c.jsx("textarea",{ref:r,value:a,onChange:T=>o(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>c.jsxs("button",{type:"button",onClick:()=>S(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[c.jsx(pr,{className:"w-3 h-3"}),T]},T))}),c.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[c.jsx(d0,{className:"w-4 h-4"}),"Live Preview"]}),c.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&c.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),c.jsx("div",{className:"text-white font-medium",children:x.title})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),c.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):c.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[c.jsxs(Ie,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):c.jsx(Bm,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),c.jsxs(Ie,{onClick:E,disabled:v.isPending||!A,children:[v.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):c.jsx(Co,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const HGe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},$Ge={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function VGe({onClose:t}){const e=En(),{showToast:n}=ii(),[r,i]=M.useState(7),[s,a]=M.useState(null),[o,l]=M.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=yt({queryKey:["notification-logs",r,o],queryFn:()=>Pe.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=yt({queryKey:["notification-log-stats",r],queryFn:()=>Pe.getNotificationLogStats(r)}),x=_t({mutationFn:()=>Pe.clearNotificationLogs(30),onSuccess:v=>{n(v.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:v=>{n(`Failed to clear logs: ${v.message}`,"error")}}),y=v=>{const b=new Date(v),S=new Date().getTime()-b.getTime();return S<6e4?"Just now":S<36e5?`${Math.floor(S/6e4)}m ago`:S<864e5?`${Math.floor(S/36e5)}h ago`:b.toLocaleDateString()+" "+b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[c.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(E3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&c.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:c.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[c.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",c.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),c.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[c.jsx(fs,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&c.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[c.jsx(md,{className:"w-4 h-4"}),m.failure_count," failed"]})]})}),c.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[c.jsxs("select",{value:r,onChange:v=>i(Number(v.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[c.jsx("option",{value:1,children:"Last 24 hours"}),c.jsx("option",{value:7,children:"Last 7 days"}),c.jsx("option",{value:30,children:"Last 30 days"}),c.jsx("option",{value:90,children:"Last 90 days"})]}),c.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:o,onChange:v=>l(v.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),c.jsx("div",{className:"flex-1"}),c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(Xs,{className:"w-4 h-4"}),"Refresh"]}),c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Clear Old"]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?c.jsx("div",{className:"space-y-2",children:u.map(v=>c.jsx(GGe,{log:v,isExpanded:s===v.id,onToggle:()=>a(s===v.id?null:v.id),formatDate:y},v.id))}):c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx(E3,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function GGe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return c.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[c.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?c.jsx(fs,{className:"w-4 h-4 text-bambu-green shrink-0"}):c.jsx(md,{className:"w-4 h-4 text-red-400 shrink-0"}),c.jsx("span",{className:`text-xs font-medium ${$Ge[t.event_type]||"text-bambu-gray"}`,children:HGe[t.event_type]||t.event_type}),c.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&c.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),c.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?c.jsx(RS,{className:"w-4 h-4 text-bambu-gray shrink-0"}):c.jsx(af,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&c.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),c.jsx("p",{className:"text-sm text-white",children:t.title})]}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),c.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&c.jsxs("div",{children:[c.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),c.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),c.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[c.jsxs("span",{children:["Provider: ",t.provider_type]}),c.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const B_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:c.jsx(UR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:c.jsx(xh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:c.jsx(Za,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:c.jsx(Ux,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:c.jsx(Lo,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:c.jsx(lce,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:c.jsx(nd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:c.jsx(PS,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function WGe({onClose:t,onExport:e}){const{t:n}=sb(),[r,i]=M.useState(()=>{const x={};return B_.forEach(y=>{x[y.id]=y.default}),x}),[s,a]=M.useState(!1),[o,l]=M.useState(!1);M.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(y=>({...y,[x]:!y[x]}))},d=()=>{const x={};B_.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};B_.forEach(y=>{x[y.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,m=async()=>{l(!0);try{await e({...r,access_codes:s&&r.printers})}finally{l(!1)}};return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:c.jsx(kt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:c.jsx(_a,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),c.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),c.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[c.jsx("button",{onClick:d,disabled:o,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),c.jsx("span",{className:"text-bambu-gray",children:"|"}),c.jsx("button",{onClick:f,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),c.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:B_.map(x=>c.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[c.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),c.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),c.jsxs("div",{className:"flex-1",children:[c.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),c.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&c.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[c.jsx(PS,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),c.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[c.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),c.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&c.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsx(zp,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),c.jsx(Un,{checked:s,onChange:a})]}),s&&c.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[c.jsx(Jr,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),c.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),c.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),c.jsx(Ie,{onClick:m,disabled:g===0||o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:o?c.jsxs(c.Fragment,{children:[c.jsx(At,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):c.jsxs(c.Fragment,{children:[c.jsx(_a,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const oG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives"};function qGe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=M.useState("options"),[s,a]=M.useState(!1),[o,l]=M.useState(null),[u,d]=M.useState(null),[f,g]=M.useState(new Set),m=M.useRef(null);M.useEffect(()=>{const S=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[t,r]);const x=S=>{const A=S.target.files?.[0];A&&l(A)},y=async()=>{if(o){i("restoring");try{const S=await e(o,s);d(S),i("result"),S.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},v=S=>{g(A=>{const T=new Set(A);return T.has(S)?T.delete(S):T.add(S),T})},b=u?.restored?Object.values(u.restored).reduce((S,A)=>S+A,0)+(u.files_restored||0):0,E=u?.total_skipped||0;return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:S=>{S.target===S.currentTarget&&r!=="restoring"&&t()},children:c.jsx(kt,{className:"w-full max-w-lg",children:c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?c.jsx(fs,{className:"w-5 h-5"}):r==="result"&&!u?.success?c.jsx(Jr,{className:"w-5 h-5"}):c.jsx(ga,{className:"w-5 h-5"})}),c.jsxs("div",{children:[c.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&c.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),r==="options"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),c.jsx("button",{type:"button",onClick:()=>m.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o?c.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[c.jsx(fs,{className:"w-5 h-5"}),c.jsx("span",{className:"font-medium",children:o.name})]}):c.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[c.jsx(ga,{className:"w-8 h-8"}),c.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),c.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[c.jsx(Jr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),c.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[c.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),c.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[c.jsxs("li",{children:[c.jsx("strong",{children:"Printers"})," - matched by serial number"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),c.jsxs("li",{children:[c.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),c.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[s?c.jsx(Xs,{className:"w-4 h-4 text-orange-400"}):c.jsx(w1,{className:"w-4 h-4 text-bambu-gray"}),s?"Replace existing data":"Keep existing data"]}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:s?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),c.jsx(Un,{checked:s,onChange:a})]})}),s&&c.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:c.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[c.jsx(Jr,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),c.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[c.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),c.jsxs(Ie,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[c.jsx(ga,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&c.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[c.jsx(At,{className:"w-12 h-12 text-bambu-green animate-spin"}),c.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[c.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:b}),c.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),c.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[c.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:E}),c.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,S])=>S>0)&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[c.jsx(fs,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),c.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,S])=>S>0).map(([S,A])=>c.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[c.jsx("span",{className:"text-white",children:oG[S]||S}),c.jsx("span",{className:"text-bambu-green font-medium",children:A})]},S)),(u.files_restored||0)>0&&c.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[c.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),c.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,S])=>S>0)&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[c.jsx(w1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),c.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,S])=>S>0).map(([S,A])=>{const T=u.skipped_details?.[S]||[],k=f.has(S);return c.jsxs("div",{children:[c.jsxs("button",{onClick:()=>T.length>0&&v(S),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[c.jsxs("span",{className:"text-white flex items-center gap-2",children:[oG[S]||S,T.length>0&&(k?c.jsx(RS,{className:"w-3 h-3"}):c.jsx(af,{className:"w-3 h-3"}))]}),c.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),k&&T.length>0&&c.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((N,I)=>c.jsx("div",{children:N},I)),T.length>10&&c.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},S)})})]}),b===0&&E===0&&c.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),c.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:c.jsx(Ie,{onClick:t,children:"Close"})})]})]})})})}async function KGe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function XGe(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 YGe(){const t=En(),[e,n]=M.useState(!1),[r,i]=M.useState(""),[s,a]=M.useState("auto"),[o,l]=M.useState(!1),[u,d]=M.useState("all"),[f,g]=M.useState(!1),{data:m,isLoading:x}=yt({queryKey:["spoolman-settings"],queryFn:KGe}),{data:y,isLoading:v,refetch:b}=yt({queryKey:["spoolman-status"],queryFn:Pe.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=yt({queryKey:["printers"],queryFn:Pe.getPrinters});M.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),i(m.spoolman_url||""),a(m.spoolman_sync_mode||"auto"),g(!0))},[m]),M.useEffect(()=>{if(!f||!m)return;if(m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==r||(m.spoolman_sync_mode||"auto")!==s){const q=setTimeout(()=>{S.mutate()},500);return()=>clearTimeout(q)}},[e,r,s,f]);const S=_t({mutationFn:()=>XGe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!0),setTimeout(()=>l(!1),2e3)}}),A=_t({mutationFn:Pe.connectSpoolman,onSuccess:()=>{b()}}),T=_t({mutationFn:Pe.disconnectSpoolman,onSuccess:()=>{b()}}),k=_t({mutationFn:Pe.syncAllPrintersAms,onSuccess:j=>{j.success}}),N=_t({mutationFn:j=>Pe.syncPrinterAms(j),onSuccess:j=>{j.success}}),I=()=>{u==="all"?k.mutate():N.mutate(u)},C=k.isPending||N.isPending,D=u==="all"?k.data:N.data,F=u==="all"?k.isSuccess:N.isSuccess;return x?c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(v1,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),c.jsx(Dt,{children:c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(v1,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),S.isPending&&c.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&c.jsx(Lh,{className:"w-4 h-4 text-bambu-green"})]})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Enable Spoolman"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),c.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"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),c.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),c.jsxs("select",{value:s,onChange:j=>a(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[c.jsx("option",{value:"auto",children:"Automatic"}),c.jsx("option",{value:"manual",children:"Manual Only"})]}),c.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&&c.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?c.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?c.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[c.jsx(Lh,{className:"w-4 h-4"}),"Connected"]}):c.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[c.jsx(Gt,{className:"w-4 h-4"}),"Disconnected"]})]}),c.jsx("div",{className:"flex gap-2",children:y?.connected?c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(Ple,{className:"w-4 h-4"}),"Disconnect"]}):c.jsxs(Ie,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(A3,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&c.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),y?.connected&&c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsxs("select",{value:u,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[c.jsx("option",{value:"all",children:"All Printers"}),E?.map(j=>c.jsx("option",{value:j.id,children:j.name},j.id))]}),c.jsx(af,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:I,disabled:C,children:[C?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(Xs,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&D&&c.jsx("div",{className:`mt-2 p-2 rounded text-sm ${D.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:D.success?`Synced ${D.synced_count} trays successfully`:`Synced ${D.synced_count} trays with ${D.errors.length} errors`})]})]})]})}function ZGe({link:t,onClose:e}){const n=En(),{theme:r}=ub(),i=!!t,s=M.useRef(null),[a,o]=M.useState(t?.name||""),[l,u]=M.useState(t?.url||""),[d,f]=M.useState(t?.icon||"link"),[g,m]=M.useState(!!t?.custom_icon),[x,y]=M.useState(t?.custom_icon?Pe.getExternalLinkIconUrl(t.id):null),[v,b]=M.useState(null),[E,S]=M.useState(null);M.useEffect(()=>{const F=j=>{j.key==="Escape"&&e()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[e]);const A=_t({mutationFn:async F=>{const j=await Pe.createExternalLink(F);return v?await Pe.uploadExternalLinkIcon(j.id,v):j},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),T=_t({mutationFn:async F=>{let j=await Pe.updateExternalLink(t.id,F);return v?j=await Pe.uploadExternalLinkIcon(t.id,v):!g&&t?.custom_icon&&(j=await Pe.deleteExternalLinkIcon(t.id)),j},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),k=F=>{const j=F.target.files?.[0];if(j){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(j.type)){S("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(j.size>1024*1024){S("Image file must be less than 1MB");return}b(j),m(!0);const R=new FileReader;R.onload=W=>{y(W.target?.result)},R.readAsDataURL(j)}},N=()=>{b(null),y(null),m(!1),s.current&&(s.current.value="")},I=F=>{if(F.preventDefault(),S(null),!a.trim()){S("Name is required");return}if(!l.trim()){S("URL is required");return}if(!l.startsWith("http://")&&!l.startsWith("https://")){S("URL must start with http:// or https://");return}const j={name:a.trim(),url:l.trim(),icon:d};i?T.mutate(j):A.mutate(j)},C=A.isPending||T.isPending,D=IS(d);return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?c.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):c.jsx(D,{className:"w-5 h-5"})}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),c.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:I,className:"p-6 space-y-4",children:[E&&c.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),c.jsx("input",{type:"text",value:a,onChange:F=>o(F.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),c.jsx("input",{type:"text",value:l,onChange:F=>u(F.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),c.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),c.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:k}),g&&x?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),c.jsx("button",{type:"button",onClick:N,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:c.jsx(kn,{className:"w-4 h-4"})})]}):c.jsxs(Ie,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[c.jsx(ga,{className:"w-4 h-4"}),"Upload"]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&c.jsxs("div",{children:[c.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),c.jsx(Oue,{value:d,onChange:f})]})]}),c.jsxs("div",{className:"flex gap-3 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:C,className:"flex-1",children:[C?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(Co,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function QGe(){const t=En(),[e,n]=M.useState(!1),[r,i]=M.useState(null),[s,a]=M.useState(null),[o,l]=M.useState(null),{data:u,isLoading:d}=yt({queryKey:["external-links"],queryFn:Pe.getExternalLinks}),f=_t({mutationFn:E=>Pe.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=_t({mutationFn:E=>Pe.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(E,S)=>{l(S),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},y=(E,S)=>{if(E.preventDefault(),o===null||o===S||!u)return;const A=u.map(I=>I.id),T=A.indexOf(o),k=A.indexOf(S);if(T===-1||k===-1)return;const N=[...A];N.splice(T,1),N.splice(k,0,o),g.mutate(N),l(null)},v=E=>{a(E)},b=()=>{s&&(f.mutate(s.id),a(null))};return c.jsxs(c.Fragment,{children:[c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(A3,{className:"w-5 h-5 text-bambu-green"}),c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),c.jsxs(Ie,{size:"sm",onClick:()=>n(!0),children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Link"]})]})}),c.jsxs(Dt,{children:[c.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?c.jsx("div",{className:"space-y-2",children:u.map(E=>{const S=IS(E.icon);return c.jsxs("div",{draggable:!0,onDragStart:A=>m(A,E.id),onDragOver:x,onDrop:A=>y(A,E.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${o===E.id?"opacity-50":""}`,children:[c.jsx(f0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),c.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:c.jsx(S,{className:"w-4 h-4"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-white font-medium truncate",children:E.name}),c.jsx(io,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),c.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[c.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:c.jsx(ed,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>v(E),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:c.jsx(kn,{className:"w-4 h-4"})})]})]},E.id)})}):c.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[c.jsx(A3,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),c.jsx("p",{children:"No external links configured"}),c.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&c.jsx(ZGe,{link:r,onClose:()=>{n(!1),i(null)}}),s&&c.jsx(Yr,{title:"Delete Link",message:`Are you sure you want to delete "${s.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:b,onCancel:()=>a(null)})]})}function JGe(){const t=En(),{t:e,i18n:n}=sb(),{showToast:r}=ii(),[i,s]=M.useState(null),[a,o]=M.useState(!1),[l,u]=M.useState(null),[d,f]=M.useState(!1),[g,m]=M.useState(null),[x,y]=M.useState(null),[v,b]=M.useState(!1),[E,S]=M.useState(m7()),[A,T]=M.useState("general"),[k,N]=M.useState(!1),[I,C]=M.useState(""),[D,F]=M.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[j,q]=M.useState(null),[R,W]=M.useState(null),[K,V]=M.useState(!1),[te,Y]=M.useState(!1),[Z,U]=M.useState(null),[z,ee]=M.useState(!1),[ae,fe]=M.useState(!1),de=Q=>{S(Q),Iue(Q)},xe=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:ye,isLoading:re}=yt({queryKey:["settings"],queryFn:Pe.getSettings}),{data:ve,isLoading:je}=yt({queryKey:["smart-plugs"],queryFn:Pe.getSmartPlugs}),{data:ue,isLoading:ut}=yt({queryKey:["smart-plugs-energy",ve?.map(Q=>Q.id)],queryFn:async()=>{if(!ve||ve.length===0)return null;const Q=await Promise.all(ve.filter(He=>He.enabled).map(async He=>{try{const ht=await Pe.getSmartPlugStatus(He.id);return{plug:He,status:ht}}catch{return{plug:He,status:null}}}));let Fe=0,pe=0,Ue=0,Ce=0,_e=0;for(const{status:He}of Q)He?.reachable&&He.energy&&(_e++,He.energy.power!=null&&(Fe+=He.energy.power),He.energy.today!=null&&(pe+=He.energy.today),He.energy.yesterday!=null&&(Ue+=He.energy.yesterday),He.energy.total!=null&&(Ce+=He.energy.total));return{totalPower:Fe,totalToday:pe,totalYesterday:Ue,totalLifetime:Ce,reachableCount:_e,totalPlugs:ve.filter(He=>He.enabled).length}},enabled:A==="plugs"&&!!ve&&ve.length>0,refetchInterval:A==="plugs"?1e4:!1}),{data:$,isLoading:H}=yt({queryKey:["notification-providers"],queryFn:Pe.getNotificationProviders}),{data:ie,isLoading:G}=yt({queryKey:["api-keys"],queryFn:Pe.getAPIKeys,enabled:A==="apikeys"}),J=_t({mutationFn:Q=>Pe.createAPIKey(Q),onSuccess:Q=>{q(Q.key||null),N(!1),C(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:Q=>{r(`Failed to create API key: ${Q.message}`,"error")}}),le=_t({mutationFn:Q=>Pe.deleteAPIKey(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:Q=>{r(`Failed to delete API key: ${Q.message}`,"error")}}),{data:ke}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:Ne,isLoading:Se}=yt({queryKey:["notification-templates"],queryFn:Pe.getNotificationTemplates}),{data:B}=yt({queryKey:["ffmpeg-status"],queryFn:Pe.checkFfmpeg}),{data:L}=yt({queryKey:["version"],queryFn:Pe.getVersion}),{data:ne,refetch:be,isRefetching:we}=yt({queryKey:["updateCheck"],queryFn:Pe.checkForUpdates,staleTime:300*1e3}),{data:ge,refetch:me}=yt({queryKey:["updateStatus"],queryFn:Pe.getUpdateStatus,refetchInterval:Q=>{const Fe=Q.state.data;return Fe?.status==="downloading"||Fe?.status==="installing"?1e3:!1}}),Ae=_t({mutationFn:Pe.applyUpdate,onSuccess:()=>{me()}}),[ze,st]=M.useState(null),Ve=_t({mutationFn:Pe.testAllNotificationProviders,onSuccess:Q=>{st(Q),t.invalidateQueries({queryKey:["notification-providers"]}),Q.failed===0?r(`All ${Q.tested} providers tested successfully!`,"success"):r(`${Q.success}/${Q.tested} providers succeeded`,Q.failed>0?"error":"success")},onError:Q=>{r(`Failed to test providers: ${Q.message}`,"error")}}),ce=_t({mutationFn:async Q=>{if(!ve)return{success:0,failed:0};const Fe=ve.filter(Ue=>Ue.enabled),pe=await Promise.all(Fe.map(async Ue=>{try{return await Pe.controlSmartPlug(Ue.id,Q),{success:!0}}catch{return{success:!1}}}));return{success:pe.filter(Ue=>Ue.success).length,failed:pe.filter(Ue=>!Ue.success).length}},onSuccess:(Q,Fe)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Q.failed===0?r(`All ${Q.success} plugs turned ${Fe}`,"success"):r(`${Q.success} plugs turned ${Fe}, ${Q.failed} failed`,"error")},onError:Q=>{r(`Failed: ${Q.message}`,"error")}}),Ye=M.useRef(null),$e=M.useRef(!0);M.useEffect(()=>{ye&&!i&&(s(ye),setTimeout(()=>{$e.current=!1},100))},[ye,i]);const Ze=_t({mutationFn:Pe.updateSettings,onSuccess:Q=>{t.setQueryData(["settings"],Q),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Q=>{r(`Failed to save: ${Q.message}`,"error")}});M.useEffect(()=>{if(!($e.current||!i||!ye||!(ye.auto_archive!==i.auto_archive||ye.save_thumbnails!==i.save_thumbnails||ye.capture_finish_photo!==i.capture_finish_photo||ye.default_filament_cost!==i.default_filament_cost||ye.currency!==i.currency||ye.energy_cost_per_kwh!==i.energy_cost_per_kwh||ye.energy_tracking_mode!==i.energy_tracking_mode||ye.check_updates!==i.check_updates||ye.notification_language!==i.notification_language||ye.ams_humidity_good!==i.ams_humidity_good||ye.ams_humidity_fair!==i.ams_humidity_fair||ye.ams_temp_good!==i.ams_temp_good||ye.ams_temp_fair!==i.ams_temp_fair||ye.ams_history_retention_days!==i.ams_history_retention_days||ye.date_format!==i.date_format||ye.time_format!==i.time_format||ye.default_printer_id!==i.default_printer_id)))return Ye.current&&clearTimeout(Ye.current),Ye.current=setTimeout(()=>{Ze.mutate(i)},500),()=>{Ye.current&&clearTimeout(Ye.current)}},[i,ye,Ze]);const at=M.useCallback((Q,Fe)=>{s(pe=>pe?{...pe,[Q]:Fe}:null)},[]);return re||!i?c.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"mb-8",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),c.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),c.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[c.jsx("button",{onClick:()=>T("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${A==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),c.jsxs("button",{onClick:()=>T("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(Ux,{className:"w-4 h-4"}),"Smart Plugs",ve&&ve.length>0&&c.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ve.length})]}),c.jsxs("button",{onClick:()=>T("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(xh,{className:"w-4 h-4"}),"Notifications",$&&$.length>0&&c.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:$.length})]}),c.jsxs("button",{onClick:()=>T("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${A==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[c.jsx(zp,{className:"w-4 h-4"}),"API Keys",ie&&ie.length>0&&c.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ie.length})]})]}),A==="general"&&c.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[c.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[c.jsx(h0,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),c.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:_5.map(Q=>c.jsxs("option",{value:Q.code,children:[Q.nativeName," (",Q.name,")"]},Q.code))}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),c.jsx("select",{value:E,onChange:Q=>de(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:b0.map(Q=>c.jsx("option",{value:Q.to,children:e(Q.labelKey)},Q.id))}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),c.jsxs("select",{value:i.date_format||"system",onChange:Q=>at("date_format",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:[c.jsx("option",{value:"system",children:"System Default"}),c.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),c.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),c.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),c.jsxs("select",{value:i.time_format||"system",onChange:Q=>at("time_format",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:[c.jsx("option",{value:"system",children:"System Default"}),c.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),c.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),c.jsxs("select",{value:i.default_printer_id??"",onChange:Q=>at("default_printer_id",Q.target.value?Number(Q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[c.jsx("option",{value:"",children:"No default (ask each time)"}),ke?.map(Q=>c.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Sidebar order"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:xe,children:[c.jsx(Bm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Auto-archive prints"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:Q=>at("auto_archive",Q.target.checked),className:"sr-only peer"}),c.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"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Save thumbnails"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:Q=>at("save_thumbnails",Q.target.checked),className:"sr-only peer"}),c.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"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Capture finish photo"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:Q=>at("capture_finish_photo",Q.target.checked),className:"sr-only peer"}),c.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&&B&&!B.installed&&c.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[c.jsx(Jr,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),c.jsxs("div",{className:"text-sm",children:[c.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),c.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",c.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",c.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),c.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:Q=>at("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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),c.jsxs("select",{value:i.currency,onChange:Q=>at("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:[c.jsx("option",{value:"USD",children:"USD ($)"}),c.jsx("option",{value:"EUR",children:"EUR (€)"}),c.jsx("option",{value:"GBP",children:"GBP (£)"}),c.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),c.jsx("option",{value:"JPY",children:"JPY (¥)"}),c.jsx("option",{value:"CNY",children:"CNY (¥)"}),c.jsx("option",{value:"CAD",children:"CAD ($)"}),c.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),c.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:Q=>at("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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),c.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:Q=>at("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:[c.jsx("option",{value:"print",children:"Prints Only"}),c.jsx("option",{value:"total",children:"Total Consumption"})]}),c.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"})]})]})]})]}),c.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-white",children:[c.jsx(YG,{className:"w-4 h-4 text-blue-400"}),c.jsx("span",{className:"font-medium",children:"Humidity"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_good??40,onChange:Q=>at("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"}),c.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_fair??60,onChange:Q=>at("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"}),c.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),c.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2 text-white",children:[c.jsx(vh,{className:"w-4 h-4 text-orange-400"}),c.jsx("span",{className:"font-medium",children:"Temperature"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_good??28,onChange:Q=>at("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"}),c.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_fair??35,onChange:Q=>at("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"}),c.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),c.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-2 text-white",children:[c.jsx(v1,{className:"w-4 h-4 text-purple-400"}),c.jsx("span",{className:"font-medium",children:"History Retention"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",min:"1",max:"365",value:i.ams_history_retention_days??30,onChange:Q=>at("ams_history_retention_days",parseInt(Q.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),c.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]}),c.jsx(YGe,{}),c.jsx(QGe,{})]}),c.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Check for updates"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),c.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:Q=>at("check_updates",Q.target.checked),className:"sr-only peer"}),c.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"})]})]}),c.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Current version"}),c.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",L?.version||"..."]})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>be(),disabled:we,children:[we?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(Xs,{className:"w-4 h-4"}),"Check now"]})]}),ne?.update_available?c.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{children:[c.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",ne.latest_version]}),ne.release_name&&ne.release_name!==ne.latest_version&&c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ne.release_name}),ne.release_notes&&c.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:ne.release_notes})]}),ne.release_url&&c.jsx("a",{href:ne.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:c.jsx(io,{className:"w-4 h-4"})})]}),ge?.status==="downloading"||ge?.status==="installing"?c.jsxs("div",{className:"mt-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[c.jsx(At,{className:"w-4 h-4 animate-spin"}),c.jsx("span",{children:ge.message})]}),c.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:c.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ge.progress}%`}})})]}):ge?.status==="complete"?c.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:ge.message}):ge?.status==="error"?c.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:ge.error||ge.message}):c.jsxs(Ie,{className:"mt-3",onClick:()=>Ae.mutate(),disabled:Ae.isPending,children:[Ae.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(_a,{className:"w-4 h-4"}),"Install Update"]})]}):ne?.error?c.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: ",ne.error]}):ne&&!ne.update_available?c.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),c.jsxs(kt,{children:[c.jsx(Ba,{children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Backup Data"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>ee(!0),children:[c.jsx(_a,{className:"w-4 h-4"}),"Export"]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Restore Backup"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>fe(!0),children:[c.jsx(ga,{className:"w-4 h-4"}),"Restore"]})]}),c.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>V(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Clear"]})]})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[c.jsx(kn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),A==="plugs"&&c.jsxs("div",{className:"max-w-4xl",children:[c.jsxs("div",{className:"flex items-start justify-between mb-6",children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(Ux,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),c.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."})]}),c.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ve&&ve.filter(Q=>Q.enabled).length>1&&c.jsxs(c.Fragment,{children:[c.jsxs(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("on"),disabled:ce.isPending,title:"Turn all plugs on",children:[ce.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(gd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),c.jsxs(Ie,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("off"),disabled:ce.isPending,title:"Turn all plugs off",children:[ce.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(LR,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),c.jsxs(Ie,{className:"whitespace-nowrap",onClick:()=>{u(null),o(!0)},children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ve&&ve.length>0&&c.jsxs(kt,{className:"mb-6",children:[c.jsx(Ba,{children:c.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[c.jsx(dm,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",ut&&c.jsx(At,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),c.jsx(Dt,{children:ue?c.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(dm,{className:"w-3 h-3"}),"Current Power"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalPower.toFixed(1),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[ue.reachableCount,"/",ue.totalPlugs," plugs online"]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(Xr,{className:"w-3 h-3"}),"Today"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalToday.toFixed(2),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalToday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(l7,{className:"w-3 h-3"}),"Yesterday"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalYesterday.toFixed(2),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalYesterday*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]}),c.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[c.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[c.jsx(S3,{className:"w-3 h-3"}),"Total"]}),c.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalLifetime.toFixed(1),c.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),i&&i.energy_cost_per_kwh>0&&c.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalLifetime*i.energy_cost_per_kwh).toFixed(2)," ",i.currency]})]})]}):ut?null:c.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),je?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ve&&ve.length>0?c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ve.map(Q=>c.jsx(LGe,{plug:Q,onEdit:Fe=>{u(Fe),o(!0)}},Q.id))}):c.jsx(kt,{children:c.jsx(Dt,{className:"py-12",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(Ux,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),c.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),c.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),c.jsxs(Ie,{onClick:()=>{u(null),o(!0)},children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),A==="notifications"&&c.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(xh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>b(!0),children:[c.jsx(E3,{className:"w-4 h-4"}),"Log"]}),$&&$.length>0&&c.jsxs(Ie,{size:"sm",variant:"secondary",onClick:()=>{st(null),Ve.mutate()},disabled:Ve.isPending,children:[Ve.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(IR,{className:"w-4 h-4"}),"Test All"]}),c.jsxs(Ie,{size:"sm",onClick:()=>{m(null),f(!0)},children:[c.jsx(pr,{className:"w-4 h-4"}),"Add"]})]})]}),c.jsx(kt,{className:"mb-4",children:c.jsx(Dt,{className:"py-3",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),c.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),c.jsx("select",{value:i.notification_language||"en",onChange:Q=>at("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:_5.map(Q=>c.jsx("option",{value:Q.code,children:Q.nativeName},Q.code))})]})})}),ze&&c.jsx(kt,{className:"mb-4",children:c.jsxs(Dt,{className:"py-3",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),c.jsx("button",{onClick:()=>st(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),c.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[c.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[c.jsx(fs,{className:"w-4 h-4"}),ze.success," passed"]}),ze.failed>0&&c.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[c.jsx(md,{className:"w-4 h-4"}),ze.failed," failed"]})]}),ze.results.filter(Q=>!Q.success).length>0&&c.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ze.results.filter(Q=>!Q.success).map(Q=>c.jsxs("div",{className:"text-xs text-red-400",children:[c.jsxs("span",{className:"font-medium",children:[Q.provider_name,":"]})," ",Q.message]},Q.provider_id))})]})}),H?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):$&&$.length>0?c.jsx("div",{className:"space-y-3",children:$.map(Q=>c.jsx(FGe,{provider:Q,onEdit:Fe=>{m(Fe),f(!0)}},Q.id))}):c.jsx(kt,{children:c.jsx(Dt,{className:"py-8",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(xh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),c.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),c.jsxs(Ie,{size:"sm",onClick:()=>{m(null),f(!0)},children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),c.jsxs("div",{children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[c.jsx(Za,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),c.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Se?c.jsx("div",{className:"flex justify-center py-8",children:c.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ne&&Ne.length>0?c.jsx("div",{className:"space-y-2",children:Ne.map(Q=>c.jsx(kt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>y(Q),children:c.jsx(Dt,{className:"py-2.5 px-3",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-white font-medium text-sm truncate",children:Q.name}),c.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Q.title_template})]}),c.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Fe=>{Fe.stopPropagation(),y(Q)},children:c.jsx(jR,{className:"w-4 h-4 text-bambu-gray"})})]})})},Q.id))}):c.jsx(kt,{children:c.jsx(Dt,{className:"py-8",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(Za,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),c.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),A==="apikeys"&&c.jsxs("div",{className:"max-w-3xl",children:[c.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[c.jsxs("div",{className:"flex-1",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(zp,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks. Use these keys to control your printers from automation tools like Home Assistant."})]}),c.jsxs(Ie,{size:"sm",onClick:()=>N(!0),className:"flex-shrink-0",children:[c.jsx(pr,{className:"w-4 h-4"}),"Create Key"]})]}),j&&c.jsx(kt,{className:"mb-6 border-bambu-green",children:c.jsx(Dt,{className:"py-4",children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx(fs,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),c.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),c.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[c.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:j}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(j);else{const Q=document.createElement("textarea");Q.value=j,Q.style.position="fixed",Q.style.left="-999999px",document.body.appendChild(Q),Q.select(),document.execCommand("copy"),document.body.removeChild(Q)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:c.jsx(Uh,{className:"w-4 h-4"})})]}),c.jsx(Ie,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>q(null),children:"Dismiss"})]})]})})}),k&&c.jsxs(kt,{className:"mb-6",children:[c.jsx(Ba,{children:c.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),c.jsxs(Dt,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),c.jsx("input",{type:"text",value:I,onChange:Q=>C(Q.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:D.can_read_status,onChange:Q=>F(Fe=>({...Fe,can_read_status:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-white",children:"Read Status"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:D.can_queue,onChange:Q=>F(Fe=>({...Fe,can_queue:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-white",children:"Manage Queue"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:D.can_control_printer,onChange:Q=>F(Fe=>({...Fe,can_control_printer:Q.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),c.jsxs("div",{children:[c.jsx("span",{className:"text-white",children:"Control Printer"}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),c.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[c.jsxs(Ie,{onClick:()=>J.mutate({name:I||"Unnamed Key",...D}),disabled:J.isPending,children:[J.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(pr,{className:"w-4 h-4"}),"Create Key"]}),c.jsx(Ie,{variant:"secondary",onClick:()=>N(!1),children:"Cancel"})]})]})]}),G?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ie&&ie.length>0?c.jsx("div",{className:"space-y-3",children:ie.map(Q=>c.jsx(kt,{children:c.jsx(Dt,{className:"py-3",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(zp,{className:`w-5 h-5 ${Q.enabled?"text-bambu-green":"text-bambu-gray"}`}),c.jsxs("div",{children:[c.jsx("p",{className:"text-white font-medium",children:Q.name}),c.jsxs("p",{className:"text-xs text-bambu-gray",children:[Q.key_prefix,"••••••••",Q.last_used&&` · Last used: ${new Date(Q.last_used).toLocaleDateString()}`]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"flex gap-1 text-xs",children:[Q.can_read_status&&c.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),Q.can_queue&&c.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),Q.can_control_printer&&c.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),c.jsx(Ie,{variant:"secondary",size:"sm",onClick:()=>W(Q.id),children:c.jsx(kn,{className:"w-4 h-4 text-red-400"})})]})]})})},Q.id))}):c.jsx(kt,{children:c.jsx(Dt,{className:"py-12",children:c.jsxs("div",{className:"text-center text-bambu-gray",children:[c.jsx(zp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),c.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),c.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),c.jsxs(Ie,{onClick:()=>N(!0),children:[c.jsx(pr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),c.jsxs(kt,{className:"mt-6",children:[c.jsx(Ba,{children:c.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),c.jsxs(Dt,{className:"space-y-3 text-sm",children:[c.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",c.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),c.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-blue-400",children:"GET"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),c.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-blue-400",children:"GET"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),c.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-green-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),c.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-orange-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),c.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-orange-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),c.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),c.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[c.jsx("span",{className:"text-red-400",children:"POST"})," ",c.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),c.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),R!==null&&c.jsx(Yr,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{le.mutate(R),W(null)},onCancel:()=>W(null)}),a&&c.jsx(IGe,{plug:l,onClose:()=>{o(!1),u(null)}}),d&&c.jsx(zGe,{provider:g,onClose:()=>{f(!1),m(null)}}),x&&c.jsx(BGe,{template:x,onClose:()=>y(null)}),v&&c.jsx(VGe,{onClose:()=>b(!1)}),K&&c.jsx(Yr,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{V(!1);try{const Q=await Pe.clearNotificationLogs(30);r(Q.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>V(!1)}),te&&c.jsx(Yr,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{Y(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>Y(!1)}),Z&&c.jsx(Yr,{title:`Turn All Plugs ${Z==="on"?"On":"Off"}`,message:`This will turn ${Z==="on"?"ON":"OFF"} all ${ve?.filter(Q=>Q.enabled).length||0} enabled smart plugs. ${Z==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${Z==="on"?"On":"Off"}`,variant:Z==="off"?"danger":"warning",onConfirm:()=>{const Q=Z;U(null),ce.mutate(Q)},onCancel:()=>U(null)}),z&&c.jsx(WGe,{onClose:()=>ee(!1),onExport:async Q=>{ee(!1);try{const{blob:Fe,filename:pe}=await Pe.exportBackup(Q),Ue=URL.createObjectURL(Fe),Ce=document.createElement("a");Ce.href=Ue,Ce.download=pe,Ce.click(),URL.revokeObjectURL(Ue),r("Backup downloaded","success")}catch{r("Failed to create backup","error")}}}),ae&&c.jsx(qGe,{onClose:()=>fe(!1),onRestore:async(Q,Fe)=>await Pe.importBackup(Q,Fe),onSuccess:()=>{t.invalidateQueries()}})]})}const ote=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},e7e=t=>t.startsWith("HH")?"HF":"S",t7e=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},xR=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 s3({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:a}){const o=e7e(t.nozzle_id),l=t.nozzle_diameter,u=()=>{r&&s?s():e()};return c.jsxs("div",{className:"flex items-center gap-2",children:[r&&c.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?c.jsx(zh,{className:"w-4 h-4 text-bambu-green"}):c.jsx(cm,{className:"w-4 h-4"})}),c.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:ote(t.k_value)}),c.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),a&&c.jsx("span",{title:"Has note",children:c.jsx(i7,{className:"w-3 h-3 text-yellow-500"})}),c.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),a&&c.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&&c.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:c.jsx(Uh,{className:"w-4 h-4"})})]})}function a3({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:a=null,onClose:o,onSave:l,onSaveNote:u}){const{showToast:d}=ii(),[f,g]=M.useState(t?.name||""),[m,x]=M.useState(t?.k_value?ote(t.k_value):"0.020"),[y,v]=M.useState(t?.filament_id||""),[b,E]=M.useState(t?.nozzle_id?t7e(t.nozzle_id):"HH00"),[S,A]=M.useState(t?.nozzle_diameter||n),[T,k]=M.useState(t?[t.extruder_id]:i?[0,1]:[0]),[N,I]=M.useState(!1),[C,D]=M.useState({current:0,total:0}),[F,j]=M.useState(s),q=mr.useMemo(()=>{const Z=new Map;for(const U of r)if(U.filament_id&&!Z.has(U.filament_id)){const z=xR(U.name||"");Z.set(U.filament_id,{id:U.filament_id,name:z||U.filament_id})}return Array.from(Z.values()).sort((U,z)=>U.name.localeCompare(z.name))},[r]),R=_t({mutationFn:Z=>(console.log("[KProfile] Calling API..."),Pe.setKProfile(e,Z)),onSuccess:Z=>{if(console.log("[KProfile] Save success:",Z),d("K-profile saved"),u&&F!==s){let U;F===""&&a?U=a:t&&t.slot_id>0?U=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:U=`name_${f}_${y}`,u(U,F)}I(!0),setTimeout(()=>{I(!1),l()},2500)},onError:Z=>{console.error("[KProfile] Save error:",Z),d(Z.message,"error"),I(!1)}}),W=_t({mutationFn:Z=>(console.log("[KProfile] Deleting profile..."),Pe.deleteKProfile(e,Z)),onSuccess:Z=>{console.log("[KProfile] Delete success:",Z),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:Z=>{console.error("[KProfile] Delete error:",Z),d(Z.message,"error"),I(!1)}}),[K,V]=M.useState(!1),te=()=>{t&&W.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},Y=async Z=>{if(Z.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const U=parseFloat(m).toFixed(6),z=`${b}-${S}`;if(t||T.length===1){const ae={name:f,k_value:U,filament_id:y,nozzle_id:z,nozzle_diameter:S,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ae),R.mutate(ae);return}I(!0),D({current:1,total:T.length});const ee=T.map(ae=>({name:f,k_value:U,filament_id:y,nozzle_id:z,nozzle_diameter:S,extruder_id:ae,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ee.length} profiles in batch:`,ee);try{if(await Pe.setKProfilesBatch(e,ee),d(`K-profile saved to ${T.length} extruders`),u&&F){const ae=`name_${f}_${y}`;u(ae,F)}}catch(ae){console.error("[KProfile] Failed to save batch:",ae),d("Failed to save K-profiles","error"),I(!1),D({current:0,total:0});return}D({current:T.length,total:T.length}),setTimeout(()=>{I(!1),D({current:0,total:0}),l()},3e3)};return c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[c.jsxs(kt,{className:"w-full max-w-md relative",children:[N&&c.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),c.jsx("p",{className:"text-white font-medium",children:C.total>1?`Saving to extruder ${C.current}/${C.total}...`:"Syncing with printer..."}),c.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),c.jsxs(Dt,{className:"p-0",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),c.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:N,children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("form",{onSubmit:Y,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),c.jsx("input",{type:"text",value:f,onChange:Z=>g(Z.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})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),c.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:Z=>{const U=Z.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&x(U)},onBlur:Z=>{const U=parseFloat(Z.target.value);isNaN(U)||x((Math.trunc(U*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),c.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"})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),c.jsxs("select",{value:y,onChange:Z=>{const U=Z.target.value;if(v(U),!t&&U&&!f){const z=q.find(ee=>ee.id===U);z&&g(`${b==="HH00"?"HF":"S"} ${z.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:[c.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&c.jsx("option",{value:t.filament_id,children:q.find(Z=>Z.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Z=>c.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),!t&&q.length===0&&c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),c.jsxs("select",{value:b,onChange:Z=>{const U=Z.target.value;if(E(U),!t&&y&&!f){const z=q.find(ee=>ee.id===y);z&&g(`${U==="HS00"?"HF":"S"} ${z.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:[c.jsx("option",{value:"HH00",children:"High Flow"}),c.jsx("option",{value:"HS00",children:"Standard"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),c.jsxs("select",{value:S,onChange:Z=>A(Z.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:[c.jsx("option",{value:"0.2",children:"0.2mm"}),c.jsx("option",{value:"0.4",children:"0.4mm"}),c.jsx("option",{value:"0.6",children:"0.6mm"}),c.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?c.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"}):c.jsxs("div",{className:"flex gap-4",children:[c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:Z=>{Z.target.checked?k([...T,1]):k(T.filter(U=>U!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),c.jsx("span",{className:"text-white",children:"Left"})]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:Z=>{Z.target.checked?k([...T,0]):k(T.filter(U=>U!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),c.jsx("span",{className:"text-white",children:"Right"})]})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),c.jsx("textarea",{value:F,onChange:Z=>j(Z.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"}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),c.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&c.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>V(!0),disabled:W.isPending||N,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"})}),c.jsx(Ie,{type:"button",variant:"secondary",onClick:o,disabled:N,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{type:"submit",disabled:R.isPending||N,className:"flex-1",children:[R.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(DR,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:c.jsx(kt,{className:"w-full max-w-sm",children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:c.jsx(kn,{className:"w-5 h-5 text-red-500"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),c.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",c.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:()=>{V(!1),te()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const H_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function n7e(){const{showToast:t}=ii(),[e,n]=M.useState(null),[r,i]=M.useState(()=>localStorage.getItem(H_.NOZZLE_DIAMETER)||"0.4"),[s,a]=M.useState(null),[o,l]=M.useState(!1),[u,d]=M.useState(null),[f,g]=M.useState(""),[m,x]=M.useState("all"),[y,v]=M.useState("all"),[b,E]=M.useState(()=>localStorage.getItem(H_.SORT_OPTION)||"name"),[S,A]=M.useState(!1),[T,k]=M.useState(new Set),[N,I]=M.useState(!1),[C,D]=M.useState(!1),F=G=>`${G.slot_id}_${G.extruder_id}`;M.useEffect(()=>{localStorage.setItem(H_.NOZZLE_DIAMETER,r)},[r]),M.useEffect(()=>{localStorage.setItem(H_.SORT_OPTION,b)},[b]);const{data:j,isLoading:q}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:R,isLoading:W,isFetching:K,error:V,refetch:te}=yt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const G=await Pe.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",G?.profiles?.length||0,"profiles"),G},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Y}=yt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>Pe.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Z,refetch:U}=yt({queryKey:["kprofile-notes",e],queryFn:()=>Pe.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),z=V?.message?.includes("not connected");M.useEffect(()=>{if(!e&&j&&j.length>0){const G=j.find(J=>J.is_active);G&&n(G.id)}},[e,j]),M.useEffect(()=>{if(e){const G=setTimeout(()=>{te()},150);return()=>clearTimeout(G)}},[e,r]);const ee=j?.filter(G=>G.is_active)||[],ae=mr.useMemo(()=>R?.profiles?R.profiles.filter(J=>{const le=f.toLowerCase(),ke=!le||J.name.toLowerCase().includes(le)||J.filament_id.toLowerCase().includes(le),Ne=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 ke&&Ne&&Se}).sort((J,le)=>{switch(b){case"k_value":return parseFloat(J.k_value)-parseFloat(le.k_value);case"filament":return xR(J.name).localeCompare(xR(le.name));case"name":default:return J.name.localeCompare(le.name)}}):[],[R?.profiles,f,m,y,b]),fe=j?.find(G=>G.id===e),de=fe?.nozzle_count===2;M.useEffect(()=>{const G=J=>{J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLSelectElement||s||o||u||(J.key==="r"||J.key==="R"?(J.preventDefault(),te()):J.key==="n"||J.key==="N"?(J.preventDefault(),l(!0)):J.key==="Escape"&&S&&(J.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[s,o,u,S,te]);const xe=M.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const G={version:1,exported_at:new Date().toISOString(),printer:fe?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Ne=>({name:Ne.name,k_value:Ne.k_value,filament_id:Ne.filament_id,nozzle_id:Ne.nozzle_id,nozzle_diameter:Ne.nozzle_diameter,extruder_id:Ne.extruder_id}))},J=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),ke=document.createElement("a");ke.href=le,ke.download=`kprofiles_${fe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke),URL.revokeObjectURL(le),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,fe,r,t]),ye=M.useCallback(()=>{const G=document.createElement("input");G.type="file",G.accept=".json",G.onchange=async J=>{const le=J.target.files?.[0];if(le)try{const ke=await le.text(),Ne=JSON.parse(ke);if(!Ne.profiles||!Array.isArray(Ne.profiles)){t("Invalid file format","error");return}let Se=0;for(const B of Ne.profiles)if(!(!B.name||!B.k_value||!B.filament_id))try{await Pe.setKProfile(e,{name:B.name,k_value:parseFloat(B.k_value).toFixed(6),filament_id:B.filament_id,nozzle_id:B.nozzle_id||`HH00-${r}`,nozzle_diameter:B.nozzle_diameter||r,extruder_id:B.extruder_id??0,slot_id:0}),Se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",B.name,L)}t(`Imported ${Se} of ${Ne.profiles.length} profiles`),te()}catch(ke){console.error("Import error:",ke),t("Failed to parse import file","error")}},G.click()},[e,r,t,te]),re=M.useCallback(G=>{k(J=>{const le=new Set(J);return le.has(G)?le.delete(G):le.add(G),le})},[]),ve=M.useCallback(()=>{k(new Set(ae.map(G=>F(G))))},[ae,F]),je=M.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),ue=M.useCallback(async()=>{const G=ae.filter(le=>T.has(F(le)));D(!0);let J=0;for(const le of G)try{await Pe.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(ke=>setTimeout(ke,300))}catch(ke){console.error("Failed to delete profile:",le.name,ke)}t(`Deleted ${J} profiles`),D(!1),I(!1),A(!1),k(new Set),te()},[e,T,ae,t,te,F]),ut=M.useCallback(G=>{const J=[];return G.setting_id&&J.push(G.setting_id),J.push(`slot_${G.slot_id}_${G.filament_id}_${G.extruder_id}`),J.push(`name_${G.name}_${G.filament_id}`),J},[]),$=M.useCallback(async(G,J)=>{if(e)try{await Pe.setKProfileNote(e,G,J),U()}catch(le){console.error("Failed to save note:",le),t("Failed to save note","error")}},[e,U,t]),H=M.useCallback(G=>{if(!Z?.notes)return{note:"",key:null};const J=ut(G);for(const le of J)if(Z.notes[le])return{note:Z.notes[le],key:le};return{note:"",key:null}},[Z,ut]),ie=M.useCallback(G=>H(G).note,[H]);return q?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?c.jsx(kt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(jo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),c.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ee.length===0?c.jsx(kt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(Lo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),c.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):c.jsxs(c.Fragment,{children:[K&&!W&&c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[c.jsx(At,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),c.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),c.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[c.jsxs("div",{className:"flex-1 min-w-48",children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),c.jsx("select",{value:e||"",onChange:G=>n(parseInt(G.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ee.map(G=>c.jsx("option",{value:G.id,children:G.name},G.id))})]}),c.jsxs("div",{className:"w-32",children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),c.jsxs("select",{value:r,onChange:G=>i(G.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:[c.jsx("option",{value:"0.2",children:"0.2mm"}),c.jsx("option",{value:"0.4",children:"0.4mm"}),c.jsx("option",{value:"0.6",children:"0.6mm"}),c.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs(Ie,{variant:"secondary",onClick:()=>te(),disabled:K,children:[c.jsx(Xs,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),c.jsxs(Ie,{onClick:()=>l(!0),children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),c.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[c.jsxs("div",{className:"flex-1 min-w-48 relative",children:[c.jsx(td,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:f,onChange:G=>g(G.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"})]}),de&&c.jsx("div",{className:"w-36",children:c.jsxs("select",{value:m,onChange:G=>x(G.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:[c.jsx("option",{value:"all",children:"All Extruders"}),c.jsx("option",{value:"left",children:"Left Only"}),c.jsx("option",{value:"right",children:"Right Only"})]})}),c.jsx("div",{className:"w-32",children:c.jsxs("select",{value:y,onChange:G=>v(G.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:[c.jsx("option",{value:"all",children:"All Flow"}),c.jsx("option",{value:"hf",children:"HF Only"}),c.jsx("option",{value:"s",children:"S Only"})]})}),c.jsx("div",{className:"w-32",children:c.jsxs("select",{value:b,onChange:G=>E(G.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:[c.jsx("option",{value:"name",children:"Sort: Name"}),c.jsx("option",{value:"k_value",children:"Sort: K-Value"}),c.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),c.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[c.jsxs(Ie,{variant:"secondary",onClick:xe,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[c.jsx(_a,{className:"w-4 h-4"}),"Export"]}),c.jsxs(Ie,{variant:"secondary",onClick:ye,title:"Import profiles from JSON",children:[c.jsx(ga,{className:"w-4 h-4"}),"Import"]}),c.jsx("div",{className:"flex-1"}),S?c.jsxs(c.Fragment,{children:[c.jsxs(Ie,{variant:"secondary",onClick:ve,title:"Select all visible profiles",children:[c.jsx(zh,{className:"w-4 h-4"}),"Select All"]}),c.jsxs(Ie,{variant:"secondary",onClick:je,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),c.jsxs(Ie,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[c.jsx(Gt,{className:"w-4 h-4"}),"Cancel"]})]}):c.jsxs(Ie,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[c.jsx(zh,{className:"w-4 h-4"}),"Select"]})]}),W?c.jsx("div",{className:"flex justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):z?c.jsx(kt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(FR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),c.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),c.jsxs(Ie,{variant:"secondary",onClick:()=>te(),children:[c.jsx(Xs,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?de?c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),c.jsx("div",{className:"space-y-1",children:ae.filter(G=>G.extruder_id===1).map(G=>c.jsx(s3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ie(G)},F(G)))})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),c.jsx("div",{className:"space-y-1",children:ae.filter(G=>G.extruder_id===0).map(G=>c.jsx(s3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ie(G)},F(G)))})]})]}):c.jsx("div",{className:"space-y-1",children:ae.map(G=>c.jsx(s3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ie(G)},F(G)))}):f||m!=="all"||y!=="all"?c.jsx(kt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(td,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),c.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):c.jsx(kt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(DR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),c.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),c.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),c.jsxs(Ie,{onClick:()=>l(!0),children:[c.jsx(pr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:G,key:J}=H(s);return c.jsx(a3,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:de,initialNote:G,initialNoteKey:J,onSaveNote:$,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),te()},onSave:()=>{a(null),te()}})})(),o&&e&&c.jsx(a3,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:$,onClose:()=>{l(!1),te()},onSave:()=>{l(!1),te()}}),u&&e&&c.jsx(a3,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:$,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),te()},onSave:()=>{d(null),te()}}),N&&c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(kt,{className:"w-full max-w-sm",children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:c.jsx(kn,{className:"w-5 h-5 text-red-500"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),c.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",c.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),c.jsxs("div",{className:"flex gap-3",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>I(!1),disabled:C,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:ue,disabled:C,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[C?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function cL(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,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:a,layerHeight:l,filamentType:d}}function ib(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function r7e(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 i7e({onSuccess:t}){const{showToast:e}=ii(),[n,r]=M.useState("email"),[i,s]=M.useState(""),[a,o]=M.useState(""),[l,u]=M.useState(""),[d,f]=M.useState(""),[g,m]=M.useState("global"),x=_t({mutationFn:()=>Pe.cloudLogin(i,a,g),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):S.needs_verification?(e("Verification code sent to your email"),r("code")):e(S.message,"error")},onError:S=>e(S.message,"error")}),y=_t({mutationFn:()=>Pe.cloudVerify(i,l),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),v=_t({mutationFn:()=>Pe.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:S=>e(S.message,"error")}),b=S=>{S.preventDefault(),n==="email"?x.mutate():n==="code"?y.mutate():n==="token"&&v.mutate()},E=x.isPending||y.isPending||v.isPending;return c.jsx(kt,{className:"max-w-md mx-auto",children:c.jsxs(Dt,{children:[c.jsxs("div",{className:"text-center mb-6",children:[c.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:c.jsx(DS,{className:"w-6 h-6 text-bambu-green"})}),c.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),c.jsxs("form",{onSubmit:b,className:"space-y-4",children:[n==="email"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),c.jsx("input",{type:"email",value:i,onChange:S=>s(S.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})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),c.jsx("input",{type:"password",value:a,onChange:S=>o(S.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})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),c.jsxs("select",{value:g,onChange:S=>m(S.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:[c.jsx("option",{value:"global",children:"Global"}),c.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),c.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),c.jsx("input",{type:"text",value:l,onChange:S=>u(S.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"&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),c.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),c.jsx("textarea",{value:d,onChange:S=>f(S.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})]}),c.jsxs("div",{className:"flex gap-2",children:[n==="code"&&c.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),c.jsxs(Ie,{type:"submit",disabled:E,className:"flex-1",children:[E?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(H5,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&c.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[c.jsx(zp,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&c.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:c.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[c.jsx(H5,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Rp({label:t,value:e,options:n,onChange:r}){const[i,s]=M.useState(!1),a=n.find(o=>o.value===e);return c.jsxs("div",{className:"relative",children:[c.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:[c.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),c.jsx("span",{children:a?.label||"All"}),c.jsx(af,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),c.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=>c.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:[c.jsx("span",{children:o.label}),o.count!==void 0&&c.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function s7e(){const[t,e]=M.useState(!1);M.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?c.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:c.jsx(om,{className:"w-5 h-5"})}):null}function o3({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:a}){const o=cL(t.name),l=ib(t.setting_id);return c.jsxs("div",{className:"flex items-center gap-2 group",children:[c.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:c.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&c.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&&c.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),c.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),c.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:c.jsx(Uh,{className:"w-4 h-4"})})]})}function bR(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+" "+bR(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)+": "+bR(a,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function a7e({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:s}=ii(),a=En(),[o,l]=M.useState(!1),{data:u,isLoading:d}=yt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Pe.getCloudSettingDetail(t.setting_id)}),f=_t({mutationFn:()=>Pe.deleteCloudSetting(t.setting_id),onSuccess:()=>{s("Preset deleted"),a.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>s(x.message,"error")}),g=ib(t.setting_id),m=cL(t.name,u?.setting?.inherits);return c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:c.jsx(kt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:c.jsxs(Dt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&c.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[c.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&c.jsxs(c.Fragment,{children:[c.jsx("span",{children:"•"}),c.jsx("span",{children:m.printer})]})]})]}),c.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?c.jsx("div",{className:"flex items-center justify-center py-16",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?c.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:bR(u)}):c.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?c.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[c.jsx(Jr,{className:"w-5 h-5"}),c.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),c.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>l(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]}):c.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),c.jsxs(Ie,{variant:"secondary",onClick:r,children:[c.jsx(Uh,{className:"w-4 h-4"}),"Duplicate"]}),g&&c.jsxs(c.Fragment,{children:[c.jsxs(Ie,{variant:"secondary",onClick:i,disabled:d||!u,children:[c.jsx(ed,{className:"w-4 h-4"}),"Edit"]}),c.jsx(Ie,{variant:"danger",onClick:()=>l(!0),children:c.jsx(kn,{className:"w-4 h-4"})})]})]})})]})})})}function lte(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function cte(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function o7e({onClose:t,onApply:e}){const{showToast:n}=ii(),[r,i]=M.useState(lte),[s,a]=M.useState("all"),[o,l]=M.useState(null),[u,d]=M.useState(""),[f,g]=M.useState(""),[m,x]=M.useState("{}"),[y,v]=M.useState(null),[b,E]=M.useState(null),S=s==="all"?r:r.filter(j=>j.type===s),A=j=>{i(j),cte(j)},T=j=>{const q=r.filter(R=>R.id!==j);A(q),E(null),n("Template deleted")},k=j=>{l(j.id),d(j.name),g(j.description),x(JSON.stringify(j.settings,null,2)),v(null)},N=()=>{if(!(!o||!u.trim()))try{const j=JSON.parse(m),q=r.map(R=>R.id===o?{...R,name:u.trim(),description:f.trim(),settings:j}:R);A(q),l(null),n("Template updated")}catch(j){v(j.message)}},I=()=>{l(null),d(""),g(""),x("{}"),v(null)},C=j=>{const q=r.map(R=>R.id===j?{...R,showInModal:!R.showInModal}:R);A(q)},D={filament:{label:"Filament",icon:kR,color:"text-amber-400"},print:{label:"Process",icon:LS,color:"text-blue-400"},printer:{label:"Printer",icon:Lo,color:"text-purple-400"}},F=b?r.find(j=>j.id===b):null;return M.useEffect(()=>{const j=q=>{q.key==="Escape"&&(b?E(null):o?I():t())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[b,o,t]),c.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&c.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:c.jsx(kt,{className:"w-full max-w-md",children:c.jsxs(Dt,{className:"p-6",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[c.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:c.jsx(Jr,{className:"w-6 h-6 text-red-400"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),c.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',c.jsx("span",{className:"font-medium",children:F.name}),'"?']}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:()=>T(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[c.jsx(kn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),c.jsx(kt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:c.jsxs(Dt,{className:"p-0 flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(g0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(j=>c.jsx("button",{onClick:()=>a(j),className:`px-3 py-1 text-sm rounded-lg transition-colors ${s===j?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:j==="all"?"All":D[j].label},j))]}),c.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx(g0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),c.jsx("p",{children:"No templates yet"}),c.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):c.jsx("div",{className:"space-y-2",children:S.map(j=>{const q=D[j.type],R=q.icon;return o===j.id?c.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[c.jsx("input",{type:"text",value:u,onChange:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),c.jsx("input",{type:"text",value:f,onChange:W=>g(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),c.jsxs("div",{className:"mb-3",children:[c.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),c.jsx("textarea",{value:m,onChange:W=>{x(W.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&&c.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{size:"sm",onClick:N,disabled:!u.trim(),children:[c.jsx(Co,{className:"w-4 h-4"}),"Save"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:I,children:"Cancel"})]})]},j.id):c.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:[c.jsx(R,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-sm font-medium text-white",children:j.name}),c.jsx("p",{className:"text-xs text-bambu-gray truncate",children:j.description})]}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(j.settings).length," fields"]}),c.jsx("button",{onClick:()=>C(j.id),className:`p-1 transition-colors ${j.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:j.showInModal?"Shown in modals":"Hidden in modals",children:j.showInModal?c.jsx(d0,{className:"w-4 h-4"}):c.jsx(PR,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>e(j),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),c.jsx("button",{onClick:()=>k(j),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:c.jsx(ed,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>E(j.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:c.jsx(kn,{className:"w-4 h-4"})})]},j.id)})})})]})})]})}function ute({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[s,a]=M.useState("changes"),[o,l]=M.useState(""),u=M.useMemo(()=>{const m=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const y of m){if(y==="inherits"||y==="version")continue;const v=e[y],b=n[y],E=y in e,S=y in n;let A;!E&&S?A="added":E&&!S?A="removed":JSON.stringify(v)!==JSON.stringify(b)?A="changed":A="same",x.push({key:y,left:v,right:b,status:A})}return x.sort((y,v)=>{const b={changed:0,added:1,removed:2,same:3};return b[y.status]!==b[v.status]?b[y.status]-b[v.status]:y.key.localeCompare(v.key)})},[e,n]),d=M.useMemo(()=>{let m=[...u];if(s==="changes"&&(m=m.filter(x=>x.status!=="same")),o){const x=o.toLowerCase();m=m.filter(y=>y.key.toLowerCase().includes(x)||String(y.left).toLowerCase().includes(x)||String(y.right).toLowerCase().includes(x))}return m},[u,s,o]),f=M.useMemo(()=>({added:u.filter(m=>m.status==="added").length,removed:u.filter(m=>m.status==="removed").length,changed:u.filter(m=>m.status==="changed").length,same:u.filter(m=>m.status==="same").length}),[u]),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 x=String(m);if(x.includes("\\n")||x.length>100){const y=x.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return M.useEffect(()=>{const m=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:c.jsx(kt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:c.jsxs(Dt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[c.jsx(Kp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),c.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:c.jsx(Gt,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[c.jsxs("div",{className:"text-center",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),c.jsx("p",{className:"text-white font-medium truncate",children:r})]}),c.jsxs("div",{className:"text-center",children:[c.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),c.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),c.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[c.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[c.jsx(pr,{className:"w-3.5 h-3.5"}),f.added," added"]}),c.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[c.jsx(T3,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),c.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[c.jsx(w3,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),c.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[c.jsx(AA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"relative",children:[c.jsx(td,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.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"})]}),f.same>0&&c.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[c.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"}),c.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"})]})]})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?c.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[c.jsx(AA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),c.jsx("p",{children:s==="changes"?"No differences found":"No fields match the search"})]}):c.jsxs("table",{className:"w-full",children:[c.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:c.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[c.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),c.jsx("th",{className:"text-left p-3 w-1/3",children:r}),c.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),c.jsx("tbody",{children:d.map(m=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],y={added:c.jsx(pr,{className:"w-3.5 h-3.5 text-green-400"}),removed:c.jsx(T3,{className:"w-3.5 h-3.5 text-red-400"}),changed:c.jsx(w3,{className:"w-3.5 h-3.5 text-amber-400"}),same:c.jsx(AA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[m.status];return c.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[c.jsx("td",{className:"p-3",children:c.jsxs("div",{className:"flex items-center gap-2",children:[y,c.jsx("span",{className:"text-sm text-white font-mono",children:m.key})]})}),c.jsx("td",{className:"p-3",children:c.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)})}),c.jsx("td",{className:"p-3",children:c.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 l7e({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=ii(),i=En(),s=!!e?.setting_id,[a,o]=M.useState("common"),[l,u]=M.useState(e?.type||"filament"),[d,f]=M.useState(e?.name?s?e.name:`${e.name} (Copy)`:""),[g,m]=M.useState(e?.base_id||""),[x,y]=M.useState(""),[v,b]=M.useState(e?.setting||{inherits:""}),[E,S]=M.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,T]=M.useState(null),[k,N]=M.useState(""),[I,C]=M.useState(!1),[D,F]=M.useState(""),[j,q]=M.useState(!1),[R,W]=M.useState(lte),[K,V]=M.useState(!1),[te,Y]=M.useState(""),[Z,U]=M.useState(""),[z,ee]=M.useState(!0),[ae,fe]=M.useState(null),[de,xe]=M.useState(!1),ye=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[l]||[],[n,l]),re=M.useMemo(()=>ye.filter(ce=>ib(ce.setting_id)),[ye]),{data:ve}=yt({queryKey:["cloudFields",l],queryFn:()=>Pe.getCloudFields(l==="print"?"process":l),staleTime:1e3*60*60}),{data:je}=yt({queryKey:["allPresetDetails",l,re.map(ce=>ce.setting_id).join(",")],queryFn:async()=>{const ce={};for(let $e=0;$e<re.length;$e+=5){const Ze=re.slice($e,$e+5);(await Promise.all(Ze.map(async Q=>{try{const Fe=await Pe.getCloudSettingDetail(Q.setting_id);return{id:Q.setting_id,detail:Fe}}catch{return null}}))).forEach(Q=>{Q&&(ce[Q.id]=Q.detail)})}return ce},enabled:re.length>0,staleTime:1e3*60*10}),{data:ue,isLoading:ut}=yt({queryKey:["cloudSettingDetail",g],queryFn:()=>Pe.getCloudSettingDetail(g),enabled:!!g});M.useEffect(()=>{a!=="json"&&S(JSON.stringify(v,null,2))},[v,a]);const $=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[l]||[]).filter(Ye=>!ib(Ye.setting_id)).sort((Ye,$e)=>Ye.name.localeCompare($e.name)),[n,l]);M.useEffect(()=>{if(!g)return;const ce=$.find(Ye=>Ye.setting_id===g);ce&&(y(ce.name),s||(b({inherits:ce.name}),S(JSON.stringify({inherits:ce.name},null,2))))},[g,$,s]);const H=M.useMemo(()=>{const ce=ve?.fields||[],Ye=new Set(ce.map(Q=>Q.key)),$e=new Set,Ze=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);je&&Object.values(je).forEach(Q=>{Q?.setting&&Object.keys(Q.setting).forEach(Fe=>{!Ye.has(Fe)&&!Ze.has(Fe)&&$e.add(Fe)})}),Object.keys(v).forEach(Q=>{!Ye.has(Q)&&!Ze.has(Q)&&$e.add(Q)});const at=Array.from($e).sort().map(Q=>({key:Q,label:Q.replace(/_/g," ").replace(/\b\w/g,Fe=>Fe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ce,...at]},[ve,je,v]),ie=H.filter(ce=>ce.label.toLowerCase().includes(k.toLowerCase())||ce.key.toLowerCase().includes(k.toLowerCase())),G=()=>{if(D.trim()){const ce=D.trim().toLowerCase().replace(/\s+/g,"_");J(ce,""),F(""),q(!1),r(`Field "${ce}" added`)}},J=(ce,Ye)=>{b($e=>{const Ze={...$e};return Ye===""||Ye===void 0?delete Ze[ce]:Ze[ce]=Ye,Ze})},le=ce=>{b(Ye=>({...Ye,...ce.settings})),fe(ce.name),r("Template applied")},ke=()=>{if(!te.trim())return;const ce={...v};if(delete ce.inherits,Object.keys(ce).length===0){r("No overrides to save","error");return}const Ye={id:Date.now().toString(),name:te.trim(),description:Z.trim()||"Custom template",type:l,settings:ce,showInModal:z},$e=[...R,Ye];W($e),cte($e),V(!1),Y(""),U(""),ee(!0),r("Template saved")},Ne=M.useMemo(()=>R.filter(ce=>ce.type===l&&ce.showInModal),[l,R]),Se=ce=>{S(ce);try{const Ye=JSON.parse(ce);b(Ye),T(null)}catch(Ye){T(Ye.message)}},B=ce=>{ce.preventDefault(),C(!1);const Ye=ce.dataTransfer.files[0];if(Ye&&Ye.name.endsWith(".json")){const $e=new FileReader;$e.onload=Ze=>{try{const at=Ze.target?.result,Q=JSON.parse(at),Fe=Q.setting||Q;b(pe=>({...pe,...Fe})),S(JSON.stringify({...v,...Fe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},$e.readAsText(Ye)}},L=_t({mutationFn:()=>{const ce={...v},Ye=l==="filament"?"filament_settings_id":l==="print"?"print_settings_id":"printer_settings_id";ce[Ye]=`"${d}"`;const $e={type:l,name:d,base_id:g,setting:ce};return Pe.createCloudSetting($e)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),ne=_t({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return Pe.updateCloudSetting(e.setting_id,{name:d,setting:v})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ce=>r(ce.message,"error")}),be=s?ne:L,we=ue?.setting?.inherits,ge=we?$.find(ce=>ce.name===we):void 0,{data:me}=yt({queryKey:["cloudSettingDetail",ge?.setting_id],queryFn:()=>Pe.getCloudSettingDetail(ge.setting_id),enabled:!!ge?.setting_id}),Ae=M.useMemo(()=>{const ce=me?.setting||{},Ye=ue?.setting||{},$e=g&&je?.[g]?.setting?je[g].setting:{};return{...ce,...Ye,...$e}},[g,ue,me,je]),ze=ce=>{if(ce==null)return"";if(Array.isArray(ce)){const Ye=[...new Set(ce.map($e=>String($e)))];return Ye.length===1?Ye[0]:ce.join(", ")}return String(ce)},st=ce=>{const Ye=v[ce.key],$e=Ae[ce.key],Ze=ze($e),at=ut?"Loading...":Ze||"",Q="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 Fe=Ye==="1"||Ye===void 0&&$e==="1";return c.jsx("button",{type:"button",onClick:()=>J(ce.key,Ye==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Fe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:c.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Fe?"translate-x-3.5":"translate-x-0.5"}`})})}return ce.type==="select"?c.jsxs("select",{value:Ye||"",onChange:Fe=>J(ce.key,Fe.target.value),className:Q,children:[c.jsx("option",{value:"",children:at}),ce.options?.map(Fe=>c.jsx("option",{value:Fe.value,children:Fe.label},Fe.value))]}):c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:ce.type==="number"?"number":"text",value:Ye!==void 0?String(Ye):"",onChange:Fe=>J(ce.key,Fe.target.value),step:ce.step,min:ce.min,max:ce.max,placeholder:at,className:Q}),ce.unit&&c.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ce.unit})]})},Ve=M.useMemo(()=>ue?.setting?ue.setting:{},[ue]);return c.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ce=>{ce.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:B,children:[de&&g&&c.jsx(ute,{onClose:()=>xe(!1),leftPreset:Ve,rightPreset:v,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),c.jsx(kt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:c.jsxs(Dt,{className:"p-0 flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:s?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[g&&c.jsxs("button",{onClick:()=>xe(!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:[c.jsx(Kp,{className:"w-4 h-4"}),"Compare"]}),c.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:c.jsx(Gt,{className:"w-5 h-5"})})]})]}),I&&c.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:c.jsxs("div",{className:"text-center",children:[c.jsx(ga,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),c.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),c.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[c.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),c.jsxs("select",{value:l,onChange:ce=>{u(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:[c.jsx("option",{value:"filament",children:"Filament"}),c.jsx("option",{value:"print",children:"Process"}),c.jsx("option",{value:"printer",children:"Printer"})]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),c.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:[c.jsx("option",{value:"",children:"Select base preset..."}),$.map(ce=>c.jsx("option",{value:ce.setting_id,children:ce.name},ce.setting_id))]})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),c.jsx("input",{type:"text",value:d,onChange:ce=>f(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"})]})]}),x&&c.jsx("div",{className:"text-xs text-bambu-gray",children:c.jsxs("p",{className:"flex items-center gap-1",children:[c.jsx(Lh,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",c.jsx("span",{className:"text-white",children:x}),ut&&c.jsx(At,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),c.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[c.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:[c.jsx($5,{className:"w-4 h-4"}),"Common"]}),c.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:[c.jsx(OR,{className:"w-4 h-4"}),"All Fields"]}),c.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:[c.jsx(XG,{className:"w-4 h-4"}),"JSON",A&&c.jsx(jo,{className:"w-3 h-3 text-red-400"})]}),c.jsx("div",{className:"flex-1"}),c.jsxs("button",{onClick:()=>{const ce={name:d,type:l,base_id:g,setting:v},Ye=new Blob([JSON.stringify(ce,null,2)],{type:"application/json"}),$e=URL.createObjectURL(Ye),Ze=document.createElement("a");Ze.href=$e,Ze.download=`${d||"preset"}.json`,document.body.appendChild(Ze),Ze.click(),document.body.removeChild(Ze),URL.revokeObjectURL($e),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[c.jsx(_a,{className:"w-4 h-4"}),"Export"]}),c.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:[c.jsx(ga,{className:"w-4 h-4"}),"Import"]}),c.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ce=>{const Ye=ce.target.files?.[0];if(Ye){const $e=new FileReader;$e.onload=Ze=>{try{const at=JSON.parse(Ze.target?.result),Q=at.setting||at;b(Fe=>({...Fe,...Q})),r("File imported")}catch{r("Invalid JSON","error")}},$e.readAsText(Ye)}}})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[a==="common"&&c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[c.jsx(g0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(v).filter(ce=>ce!=="inherits").length>0&&c.jsxs("button",{onClick:()=>V(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[c.jsx(Co,{className:"w-3 h-3"}),"Save as template"]})]}),K&&c.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[c.jsx("input",{type:"text",value:te,onChange:ce=>Y(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}),c.jsx("input",{type:"text",value:Z,onChange:ce=>U(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"})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{size:"sm",onClick:ke,disabled:!te.trim(),children:[c.jsx(Co,{className:"w-3 h-3"}),"Save"]}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),c.jsxs("button",{onClick:()=>ee(!z),className:`flex items-center gap-1.5 text-xs transition-colors ${z?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[z?c.jsx(d0,{className:"w-3.5 h-3.5"}):c.jsx(PR,{className:"w-3.5 h-3.5"}),z?"Show in modals":"Hidden in modals"]})]})]}),ae&&c.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:[c.jsx(Lh,{className:"w-4 h-4 text-bambu-green"}),c.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",c.jsx("span",{className:"font-medium",children:ae})]}),c.jsx("button",{onClick:()=>fe(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),c.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ne.map(ce=>c.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:[c.jsx("p",{className:"text-sm font-medium text-white",children:ce.name}),c.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ce.description})]},ce.id)),Ne.length===0&&c.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."})]}),c.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),c.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:H.slice(0,10).map(ce=>c.jsxs("div",{className:"flex items-center justify-between gap-4",children:[c.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ce.label}),c.jsx("div",{className:"w-48",children:st(ce)})]},ce.key))})]}),Object.keys(v).length>1&&c.jsxs("div",{children:[c.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([ce])=>ce!=="inherits").map(([ce,Ye])=>c.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(Ye).slice(0,20),c.jsx("button",{onClick:()=>J(ce,void 0),className:"hover:text-white",children:c.jsx(Gt,{className:"w-3 h-3"})})]},ce))})]})]}),a==="fields"&&c.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[c.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[c.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),c.jsx("span",{className:"text-xs text-bambu-gray",children:je?`${H.length} fields`:"Loading..."})]}),c.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[c.jsx(td,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:k,onChange:ce=>N(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"})]}),c.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 Ye=Ae[ce.key],$e=ze(Ye);return c.jsxs("div",{onClick:()=>{b(Ze=>({...Ze,[ce.key]:$e||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"text-sm text-white truncate",children:ce.label}),c.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ce.key})]}),c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[$e&&c.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:$e,children:[$e.slice(0,20),$e.length>20?"...":""]}),c.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:c.jsx(pr,{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&&c.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),c.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:j?c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",value:D,onChange:ce=>F(ce.target.value),onKeyDown:ce=>ce.key==="Enter"&&G(),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}),c.jsx(Ie,{size:"sm",onClick:G,disabled:!D.trim(),children:c.jsx(pr,{className:"w-4 h-4"})}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>{q(!1),F("")},children:c.jsx(Gt,{className:"w-4 h-4"})})]}):c.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[c.jsx(pr,{className:"w-4 h-4"}),"Add custom field"]})})]}),c.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[c.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),c.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(v).filter(ce=>ce!=="inherits").length," fields"]})]}),c.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,Ye])=>{const $e=H.find(Ze=>Ze.key===ce);return c.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium text-white",children:$e?.label||ce}),c.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ce})]}),c.jsx("button",{onClick:()=>J(ce,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:c.jsx(Gt,{className:"w-4 h-4"})})]}),$e?st($e):c.jsx("input",{type:"text",value:String(Ye),onChange:Ze=>J(ce,Ze.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&&c.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[c.jsx($5,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),c.jsx("p",{className:"text-sm",children:"No overrides yet"}),c.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&&c.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:c.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:[c.jsx(Co,{className:"w-4 h-4"}),"Save as template"]})})]})]}),a==="json"&&c.jsxs("div",{className:"space-y-2",children:[A&&c.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[c.jsx(jo,{className:"w-4 h-4"}),A]}),c.jsx("textarea",{value:E,onChange:ce=>Se(ce.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),c.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),c.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[c.jsx(Ie,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),c.jsxs(Ie,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!s&&!g||!!A,className:"flex-1",children:[be.isPending?c.jsx(At,{className:"w-4 h-4 animate-spin"}):s?c.jsx(Co,{className:"w-4 h-4"}):c.jsx(pr,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function c7e({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[s,a]=M.useState(""),[o,l]=M.useState("all"),[u,d]=M.useState("all"),[f,g]=M.useState("all"),[m,x]=M.useState("all"),[y,v]=M.useState("all"),[b,E]=M.useState("all"),[S,A]=M.useState(null),[T,k]=M.useState(!1),[N,I]=M.useState(!1),[C,D]=M.useState(null),[F,j]=M.useState(null),[q,R]=M.useState(null),[W,K]=M.useState(!1),[V,te]=M.useState([null,null]),[Y,Z]=M.useState(!1),[U,z]=M.useState(null),ee=En(),ae=M.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:cL(ie.name)})),[t]),fe=M.useMemo(()=>{const H=new Set,ie=new Set,G=new Set;return ae.forEach(J=>{J.meta.nozzle&&H.add(J.meta.nozzle),J.meta.filamentType&&ie.add(J.meta.filamentType),J.meta.layerHeight&&G.add(J.meta.layerHeight)}),{printers:i.map(J=>({id:J.id.toString(),name:J.name})),nozzles:Array.from(H).sort((J,le)=>parseFloat(J)-parseFloat(le)),filaments:Array.from(ie).sort(),layerHeights:Array.from(G).sort((J,le)=>parseFloat(J)-parseFloat(le))}},[ae,i]),de=M.useMemo(()=>f==="all"?null:i.find(ie=>ie.id.toString()===f)?.model||null,[f,i]),xe=M.useMemo(()=>ae.filter(H=>o==="all"||H.type===o).filter(H=>{if(u==="all")return!0;const ie=ib(H.setting_id);return u==="custom"?ie:!ie}).filter(H=>{if(f==="all"||!de)return!0;const ie=H.meta.printer?.toLowerCase()||"",G=de.toLowerCase();return ie.includes(G)||G.includes(ie)}).filter(H=>m==="all"||H.meta.nozzle===m).filter(H=>y==="all"||H.meta.filamentType===y).filter(H=>b==="all"||H.meta.layerHeight===b).filter(H=>s===""||H.name.toLowerCase().includes(s.toLowerCase())).sort((H,ie)=>H.name.localeCompare(ie.name)),[ae,o,u,f,de,m,y,b,s]),ye=H=>{if(W){const ie=V[0]?.setting_id===H.setting_id,G=V[1]?.setting_id===H.setting_id;if(ie)te([V[1],null]);else if(G)te([V[0],null]);else if(!V[0])te([H,null]);else if(V[1]){if(V[0].type!==H.type)return;te([V[0],H])}else{if(V[0].type!==H.type)return;te([V[0],H])}}else A(H)},re=H=>{if(V[0]?.setting_id===H.setting_id)return 0;if(V[1]?.setting_id===H.setting_id)return 1},ve=async H=>{try{const ie=await Pe.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;D({type:G,name:H.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{}}),A(null)}catch(ie){console.error("Failed to fetch preset details for duplication:",ie)}},je=async H=>{try{ee.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const ie=await Pe.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;j({type:G,name:H.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{},setting_id:H.setting_id}),A(null)}catch(ie){console.error("Failed to fetch preset details for editing:",ie)}},ue=()=>{l("all"),d("all"),g("all"),x("all"),v("all"),E("all"),a("")},ut=o!=="all"||u!=="all"||f!=="all"||m!=="all"||y!=="all"||b!=="all"||s!=="",$=t.filament.length+t.printer.length+t.process.length;return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"space-y-4 mb-6",children:[c.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(td,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),c.jsx("input",{type:"text",value:s,onChange:H=>a(H.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"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ie,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),te([null,null])):K(!0)},children:[c.jsx(Kp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),c.jsxs(Ie,{variant:"secondary",onClick:()=>I(!0),children:[c.jsx(g0,{className:"w-4 h-4"}),"Templates"]}),c.jsxs(Ie,{variant:"secondary",onClick:n,disabled:r,children:[c.jsx(Xs,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),c.jsxs(Ie,{onClick:()=>k(!0),children:[c.jsx(pr,{className:"w-4 h-4"}),"New Preset"]})]})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsx(RR,{className:"w-4 h-4 text-bambu-gray"}),c.jsx(Rp,{label:"Type",value:o,options:[{value:"all",label:"All",count:$},{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:H=>l(H)}),c.jsx(Rp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:H=>d(H)}),fe.printers.length>0&&c.jsx(Rp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...fe.printers.map(H=>({value:H.id,label:H.name}))],onChange:g}),fe.nozzles.length>0&&c.jsx(Rp,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...fe.nozzles.map(H=>({value:H,label:H}))],onChange:x}),fe.filaments.length>0&&(o==="all"||o==="filament")&&c.jsx(Rp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...fe.filaments.map(H=>({value:H,label:H}))],onChange:v}),fe.layerHeights.length>0&&(o==="all"||o==="process")&&c.jsx(Rp,{label:"Layer",value:b,options:[{value:"all",label:"All"},...fe.layerHeights.map(H=>({value:H,label:H}))],onChange:E}),ut&&c.jsx("button",{onClick:ue,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&c.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx(Kp,{className:"w-5 h-5 text-blue-400"}),c.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),c.jsx("span",{className:"text-bambu-gray",children:V[0]?`Select another ${V[0].type} preset`:"Click two presets of the same type to compare"})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.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"}),c.jsx(w3,{className:"w-4 h-4 text-bambu-gray"}),c.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]&&c.jsxs(Ie,{size:"sm",onClick:async()=>{try{const[H,ie]=await Promise.all([Pe.getCloudSettingDetail(V[0].setting_id),Pe.getCloudSettingDetail(V[1].setting_id)]);z([H.setting||{},ie.setting||{}]),Z(!0)}catch{}},children:[c.jsx(Kp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),c.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(ni,{className:"w-3 h-3"}),"Last synced: ",r7e(e.toISOString())]}),c.jsxs("span",{children:["Showing ",xe.length," of ",$," presets"]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),c.jsx("span",{children:"= My preset (editable)"})]})]}),xe.length===0?c.jsxs("div",{className:"text-center py-16",children:[c.jsx(Fh,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),c.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),ut&&c.jsx("button",{onClick:ue,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[c.jsx(kR,{className:"w-4 h-4 text-amber-400"}),c.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="filament").length,")"]})]}),c.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(H=>H.type==="filament").map(H=>c.jsx(o3,{setting:H,onClick:()=>ye(H),onDuplicate:()=>ve(H),compareMode:W,isCompareSelected:re(H)!==void 0,compareIndex:re(H),compareDisabled:W&&!!V[0]&&V[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="filament").length===0&&c.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[c.jsx(LS,{className:"w-4 h-4 text-blue-400"}),c.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="process").length,")"]})]}),c.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(H=>H.type==="process").map(H=>c.jsx(o3,{setting:H,onClick:()=>ye(H),onDuplicate:()=>ve(H),compareMode:W,isCompareSelected:re(H)!==void 0,compareIndex:re(H),compareDisabled:W&&!!V[0]&&V[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="process").length===0&&c.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[c.jsx(Lo,{className:"w-4 h-4 text-purple-400"}),c.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),c.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="printer").length,")"]})]}),c.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[xe.filter(H=>H.type==="printer").map(H=>c.jsx(o3,{setting:H,onClick:()=>ye(H),onDuplicate:()=>ve(H),compareMode:W,isCompareSelected:re(H)!==void 0,compareIndex:re(H),compareDisabled:W&&!!V[0]&&V[0].type!==H.type},H.setting_id)),xe.filter(H=>H.type==="printer").length===0&&c.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&c.jsx(a7e,{setting:S,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>ve(S),onEdit:()=>je(S)}),(T||C||F||q)&&c.jsx(l7e,{onClose:()=>{k(!1),D(null),j(null),R(null)},initialData:F||C||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),N&&c.jsx(o7e,{onClose:()=>I(!1),onApply:H=>{R({type:H.type,setting:H.settings}),I(!1)}}),Y&&U&&V[0]&&V[1]&&c.jsx(ute,{onClose:()=>{Z(!1),z(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function u7e(){const t=En(),{showToast:e}=ii(),[n,r]=M.useState("cloud"),[i,s]=M.useState(),{data:a,isLoading:o}=yt({queryKey:["cloudStatus"],queryFn:Pe.getCloudStatus}),{data:l=[]}=yt({queryKey:["printers"],queryFn:Pe.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=yt({queryKey:["cloudSettings"],queryFn:()=>Pe.getCloudSettings(),enabled:!!a?.is_authenticated,retry:!1,staleTime:1e3*60*5});M.useEffect(()=>{g&&s(new Date(g))},[g]);const m=_t({mutationFn:Pe.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?c.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c.jsxs("div",{className:"p-6 lg:p-8",children:[c.jsxs("div",{className:"mb-6",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),c.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),c.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[c.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:[c.jsx(DS,{className:"w-4 h-4"}),"Cloud Profiles"]}),c.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:[c.jsx(DR,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&c.jsxs(c.Fragment,{children:[a?.is_authenticated&&c.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),c.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",c.jsx("span",{className:"text-white",children:a.email})]})]}),c.jsxs(Ie,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[c.jsx(Ble,{className:"w-4 h-4"}),"Logout"]})]}),a?.is_authenticated?d?c.jsx("div",{className:"flex items-center justify-center py-16",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?c.jsx(c7e,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:l}):c.jsxs("div",{className:"text-center py-16",children:[c.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),c.jsx(Ie,{onClick:()=>f(),children:"Retry"})]}):c.jsx(i7e,{onSuccess:x})]}),n==="kprofiles"&&c.jsx(n7e,{}),c.jsx(s7e,{})]})}const jx={Droplet:kR,Flame:tle,Ruler:Tce,Sparkles:g0,Square:cm,Cable:toe,Wrench:nd,Calendar:Xr,Timer:Iu,Cog:Noe,Fan:Voe,Zap:dm,Wind:Sue,Thermometer:vh,Layers:Fh,Box:lm,Target:s7,RefreshCw:Xs,Settings:UR,Filter:RR,CircleDot:xoe};function s0(t){return t&&jx[t]||nd}function Dp(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 l3(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 d7e({item:t,onPerform:e,onToggle:n}){const r=s0(t.maintenance_type_icon),i=t.interval_type||"hours",a=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),o=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",l=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${Dp(Math.abs(f),"days")}`:t.is_warning?`Due in ${Dp(f,"days")}`:`${Dp(f,"days")} left`}else return t.is_due?`Overdue by ${Dp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Dp(t.hours_until_due,"hours")}`:`${Dp(t.hours_until_due,"hours")} left`};return c.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.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:[c.jsx(r,{className:`w-5 h-5 ${o()}`}),t.enabled&&(t.is_due||t.is_warning)&&c.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`})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&c.jsx("span",{title:"Time-based interval",children:c.jsx(Xr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),c.jsx("div",{className:"mt-2 mb-1.5",children:c.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:c.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${l()}`,style:{width:`${a}%`}})})}),c.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&c.jsx(Jr,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&c.jsx(ni,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&c.jsx(Lh,{className:"w-3 h-3"}),d()]})]}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[c.jsx(Un,{checked:t.enabled,onChange:f=>n(t.id,f)}),c.jsxs(Ie,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[c.jsx(Bm,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function h7e({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,s]=M.useState(!0),[a,o]=M.useState(!1),[l,u]=M.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((m,x)=>m.is_due&&!x.is_due?-1:!m.is_due&&x.is_due?1:m.is_warning&&!x.is_warning?-1:!m.is_warning&&x.is_warning?1:m.maintenance_type_id-x.maintenance_type_id),f=d.find(m=>m.enabled&&(m.is_due||m.is_warning)),g=()=>{const m=parseFloat(l);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return c.jsxs(kt,{className:"overflow-hidden",children:[c.jsxs("div",{className:"p-5",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),c.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&c.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:[c.jsx(Jr,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&c.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:[c.jsx(ni,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&c.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:[c.jsx(Lh,{className:"w-3 h-3"}),"All good"]})]})]}),c.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?c.jsx(RS,{className:"w-4 h-4"}):c.jsx(af,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),c.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:c.jsx(Iu,{className:"w-4 h-4 text-bambu-gray"})}),a?c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{type:"number",value:l,onChange:m=>u(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}),c.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),c.jsx(Ie,{size:"sm",onClick:g,children:"Save"}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):c.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[c.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",c.jsx(m0,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),c.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),c.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const m=s0(f.maintenance_type_icon);return c.jsx(m,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),c.jsxs("div",{children:[c.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),c.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&c.jsx(Dt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:c.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(m=>c.jsx(d7e,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function f7e({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s}){const[a,o]=M.useState(null),[l,u]=M.useState(""),[d,f]=M.useState("hours"),[g,m]=M.useState(!1),[x,y]=M.useState(""),[v,b]=M.useState("100"),[E,S]=M.useState("hours"),[A,T]=M.useState("Wrench"),[k,N]=M.useState(null),[I,C]=M.useState(""),[D,F]=M.useState(""),[j,q]=M.useState("hours"),[R,W]=M.useState("Wrench"),K=ee=>{N(ee),C(ee.name),F(ee.default_interval_hours.toString()),q(ee.interval_type||"hours"),W(ee.icon||"Wrench")},V=()=>{k&&I.trim()&&parseFloat(D)>0&&(i(k.id,{name:I.trim(),default_interval_hours:parseFloat(D),interval_type:j,icon:R}),N(null))},te=(ee,ae,fe)=>{const de=parseFloat(l);if(!isNaN(de)&&de>0){const xe=Math.abs(de-ae)<.01?null:de;n(ee,{custom_interval_hours:xe,custom_interval_type:d!==fe?d:null})}o(null)},Y=ee=>{ee.preventDefault(),x.trim()&&parseFloat(v)>0&&(r({name:x.trim(),default_interval_hours:parseFloat(v),interval_type:E,icon:A}),y(""),b("100"),S("hours"),m(!1))},Z=t?.map(ee=>({printerId:ee.printer_id,printerName:ee.printer_name,items:ee.maintenance_items.sort((ae,fe)=>ae.maintenance_type_id-fe.maintenance_type_id)})).sort((ee,ae)=>ee.printerName.localeCompare(ae.printerName))||[],U=e.filter(ee=>ee.is_system),z=e.filter(ee=>!ee.is_system);return c.jsxs("div",{className:"space-y-8",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),c.jsxs(Ie,{onClick:()=>m(!g),children:[c.jsx(pr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&c.jsx(kt,{className:"mb-6",children:c.jsx(Dt,{className:"py-4",children:c.jsxs("form",{onSubmit:Y,children:[c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[c.jsxs("div",{className:"lg:col-span-2",children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),c.jsx("input",{type:"text",value:x,onChange:ee=>y(ee.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})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),c.jsxs("select",{value:E,onChange:ee=>{S(ee.target.value),ee.target.value==="days"?b("30"):b("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:[c.jsx("option",{value:"hours",children:"Print Hours"}),c.jsx("option",{value:"days",children:"Calendar Days"})]})]}),c.jsxs("div",{children:[c.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",E==="days"?"days":"hours",")"]}),c.jsx("input",{type:"number",value:v,onChange:ee=>b(ee.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"})]})]}),c.jsxs("div",{className:"mt-4 flex items-end justify-between",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),c.jsx("div",{className:"flex gap-1",children:Object.keys(jx).map(ee=>{const ae=jx[ee];return c.jsx("button",{type:"button",onClick:()=>T(ee),className:`p-2 rounded-lg transition-colors ${A===ee?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:c.jsx(ae,{className:"w-4 h-4"})},ee)})})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),c.jsx(Ie,{type:"submit",disabled:!x.trim(),children:"Add Type"})]})]})]})})}),c.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U.map(ee=>{const ae=s0(ee.icon),fe=ee.interval_type||"hours";return c.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:c.jsx(ae,{className:"w-5 h-5 text-bambu-gray"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-medium text-white truncate",children:ee.name}),c.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?c.jsx(Xr,{className:"w-3 h-3"}):c.jsx(Iu,{className:"w-3 h-3"}),l3(ee.default_interval_hours,fe)]})]})]})},ee.id)}),z.map(ee=>{const ae=s0(ee.icon),fe=ee.interval_type||"hours";return k?.id===ee.id?c.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:c.jsxs("div",{className:"space-y-3",children:[c.jsx("input",{type:"text",value:I,onChange:xe=>C(xe.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}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("select",{value:j,onChange:xe=>q(xe.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:[c.jsx("option",{value:"hours",children:"Print Hours"}),c.jsx("option",{value:"days",children:"Calendar Days"})]}),c.jsx("input",{type:"number",value:D,onChange:xe=>F(xe.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"})]}),c.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(jx).map(xe=>{const ye=jx[xe];return c.jsx("button",{type:"button",onClick:()=>W(xe),className:`p-1.5 rounded transition-colors ${R===xe?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:c.jsx(ye,{className:"w-3.5 h-3.5"})},xe)})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ie,{size:"sm",onClick:V,disabled:!I.trim(),children:"Save"}),c.jsx(Ie,{size:"sm",variant:"secondary",onClick:()=>N(null),children:"Cancel"})]})]})},ee.id):c.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:c.jsx(ae,{className:"w-5 h-5 text-bambu-green"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-white truncate",children:ee.name}),c.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),c.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[fe==="days"?c.jsx(Xr,{className:"w-3 h-3"}):c.jsx(Iu,{className:"w-3 h-3"}),l3(ee.default_interval_hours,fe)]})]}),c.jsx("button",{onClick:()=>K(ee),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:c.jsx(m0,{className:"w-4 h-4"})}),c.jsx("button",{onClick:()=>{confirm(`Delete "${ee.name}"?`)&&s(ee.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:c.jsx(kn,{className:"w-4 h-4"})})]})},ee.id)})]})]}),Z.length>0&&c.jsxs("div",{children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),c.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),c.jsx("div",{className:"space-y-4",children:Z.map(ee=>c.jsx(kt,{children:c.jsxs(Dt,{className:"py-4",children:[c.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:ee.printerName}),c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:ee.items.map(ae=>{const fe=s0(ae.maintenance_type_icon),de=e.find(je=>je.id===ae.maintenance_type_id),xe=de?.default_interval_hours||ae.interval_hours,ye=de?.interval_type||"hours",re=ae.interval_type||"hours",ve=a===ae.id;return c.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[c.jsx(fe,{className:"w-4 h-4 text-bambu-gray shrink-0"}),c.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:ae.maintenance_type_name}),ve?c.jsxs("div",{className:"flex items-center gap-1",children:[d==="days"?c.jsx(Xr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):c.jsx(Iu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),c.jsxs("select",{value:d,onChange:je=>f(je.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[c.jsx("option",{value:"hours",children:"Print Hours"}),c.jsx("option",{value:"days",children:"Calendar Days"})]}),c.jsx("input",{type:"number",value:l,onChange:je=>u(je.target.value),onKeyDown:je=>{je.key==="Enter"&&te(ae.id,xe,ye),je.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"}),c.jsx(Ie,{size:"sm",onClick:()=>te(ae.id,xe,ye),children:"OK"})]}):c.jsxs("button",{onClick:()=>{o(ae.id),u(ae.interval_hours.toString()),f(re)},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:[re==="days"?c.jsx(Xr,{className:"w-3 h-3"}):c.jsx(Iu,{className:"w-3 h-3"}),l3(ae.interval_hours,re),c.jsx(m0,{className:"w-3 h-3 text-bambu-gray"})]})]},ae.id)})})]})},ee.printerId))})]}),Z.length===0&&c.jsx(kt,{children:c.jsxs(Dt,{className:"text-center py-12",children:[c.jsx(ni,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),c.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),c.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function p7e(){const t=En(),{showToast:e}=ii(),[n,r]=M.useState("status"),{data:i,isLoading:s}=yt({queryKey:["maintenanceOverview"],queryFn:Pe.getMaintenanceOverview}),{data:a}=yt({queryKey:["maintenanceTypes"],queryFn:Pe.getMaintenanceTypes}),o=_t({mutationFn:({id:E,notes:S})=>Pe.performMaintenance(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:E=>{e(E.message,"error")}}),l=_t({mutationFn:({id:E,data:S})=>Pe.updateMaintenanceItem(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:E=>{e(E.message,"error")}}),u=_t({mutationFn:Pe.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:E=>{e(E.message,"error")}}),d=_t({mutationFn:({id:E,data:S})=>Pe.updateMaintenanceType(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:E=>{e(E.message,"error")}}),f=_t({mutationFn:Pe.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:E=>{e(E.message,"error")}}),g=_t({mutationFn:({printerId:E,hours:S})=>Pe.setPrinterHours(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:E=>{e(E.message,"error")}}),m=E=>{o.mutate({id:E})},x=(E,S)=>{l.mutate({id:E,data:{enabled:S}})},y=(E,S)=>{g.mutate({printerId:E,hours:S})};if(s)return c.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((E,S)=>E+S.due_count,0)||0,b=i?.reduce((E,S)=>E+S.warning_count,0)||0;return c.jsxs("div",{className:"p-4 md:p-8",children:[c.jsxs("div",{className:"mb-6",children:[c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),c.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?c.jsxs(c.Fragment,{children:[v>0&&c.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&b>0&&" · ",b>0&&c.jsxs("span",{className:"text-amber-400",children:[b," due soon"]}),v===0&&b===0&&c.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),c.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[c.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"}),c.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"?c.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((E,S)=>{const A=E.due_count*10+E.warning_count,T=S.due_count*10+S.warning_count;return A!==T?T-A:E.printer_name.localeCompare(S.printer_name)}).map(E=>c.jsx(h7e,{overview:E,onPerform:m,onToggle:x,onSetHours:y},E.printer_id)):c.jsx(kt,{children:c.jsxs(Dt,{className:"text-center py-16",children:[c.jsx(nd,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),c.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),c.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):c.jsx(f7e,{overview:i,types:a||[],onUpdateInterval:(E,S)=>l.mutate({id:E,data:S}),onAddType:E=>u.mutate(E),onUpdateType:(E,S)=>d.mutate({id:E,data:S}),onDeleteType:E=>f.mutate(E)})]})}const lG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function m7e({project:t,onClose:e,onSave:n,isLoading:r}){const[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.description||""),[l,u]=M.useState(t?.color||lG[0]),[d,f]=M.useState(t?.target_count?.toString()||""),[g,m]=M.useState(t?.status||"active"),x=y=>{y.preventDefault(),n({name:i.trim(),description:a.trim()||void 0,color:l,target_count:d?parseInt(d,10):void 0,...t&&{status:g}})};return c.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:c.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[c.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:c.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),c.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),c.jsx("input",{type:"text",value:i,onChange:y=>s(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),c.jsx("textarea",{value:a,onChange:y=>o(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:"Optional description...",rows:2})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),c.jsx("div",{className:"flex gap-2 flex-wrap",children:lG.map(y=>c.jsx("button",{type:"button",onClick:()=>u(y),className:`w-8 h-8 rounded-full transition-transform ${l===y?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:y}},y))})]}),c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),c.jsx("input",{type:"number",value:d,onChange:y=>f(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 50 parts to print",min:"1"})]}),t&&c.jsxs("div",{children:[c.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),c.jsxs("select",{value:g,onChange:y=>m(y.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[c.jsx("option",{value:"active",children:"Active"}),c.jsx("option",{value:"completed",children:"Completed"}),c.jsx("option",{value:"archived",children:"Archived"})]})]}),c.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[c.jsx(Ie,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),c.jsx(Ie,{type:"submit",disabled:!i.trim()||r,children:r?c.jsx(At,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function g7e({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,s=t.status==="completed",a=t.status==="archived";return c.jsx(kt,{className:"hover:border-bambu-gray/30 transition-colors cursor-pointer",onClick:e,children:c.jsxs(Dt,{className:"p-4",children:[c.jsxs("div",{className:"flex items-start justify-between mb-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:t.color||"#6b7280"}}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-medium text-white",children:t.name}),t.description&&c.jsx("p",{className:"text-sm text-bambu-gray/70 mt-0.5 line-clamp-1",children:t.description})]})]}),c.jsxs("div",{className:"flex items-center gap-1",onClick:o=>o.stopPropagation(),children:[s&&c.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded",children:"Completed"}),a&&c.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded",children:"Archived"}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,className:"p-1",children:c.jsx(m0,{className:"w-4 h-4"})}),c.jsx(Ie,{variant:"ghost",size:"sm",onClick:r,className:"p-1 text-red-400 hover:text-red-300",children:c.jsx(kn,{className:"w-4 h-4"})})]})]}),t.target_count&&c.jsxs("div",{className:"mb-3",children:[c.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[c.jsxs("span",{children:[t.archive_count," / ",t.target_count," prints"]}),c.jsxs("span",{children:[i.toFixed(0),"%"]})]}),c.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full transition-all duration-300",style:{width:`${Math.min(i,100)}%`,backgroundColor:i>=100?"#22c55e":t.color||"#6b7280"}})})]}),t.archives&&t.archives.length>0&&c.jsx("div",{className:"mb-3",children:c.jsxs("div",{className:"flex gap-2",children:[t.archives.slice(0,5).map(o=>c.jsxs("a",{href:`/archives?search=${encodeURIComponent(o.print_name||"")}`,onClick:l=>l.stopPropagation(),className:"relative w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:o.print_name||"Unknown",children:[o.thumbnail_path?c.jsx("img",{src:`/api/v1/archives/${o.id}/thumbnail`,alt:o.print_name||"",className:"w-full h-full object-cover"}):c.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:c.jsx(p0,{className:"w-6 h-6"})}),o.status==="failed"&&c.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:c.jsx("span",{className:"text-white text-xs font-bold",children:"✗"})})]},o.id)),t.archive_count>5&&c.jsxs("div",{className:"w-14 h-14 rounded-lg bg-bambu-dark flex-shrink-0 flex items-center justify-center text-sm text-bambu-gray border border-bambu-dark-tertiary",children:["+",t.archive_count-5]})]})}),c.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[c.jsxs("div",{className:"flex items-center gap-1",title:"Archives",children:[c.jsx(PS,{className:"w-4 h-4"}),c.jsx("span",{children:t.archive_count})]}),c.jsxs("div",{className:"flex items-center gap-1",title:"Queued",children:[c.jsx(Lle,{className:"w-4 h-4"}),c.jsx("span",{children:t.queue_count})]})]})]})})}function x7e(){const t=En(),{showToast:e}=ii(),[n,r]=M.useState(!1),[i,s]=M.useState(),[a,o]=M.useState("active"),[l,u]=M.useState(null),{data:d,isLoading:f}=yt({queryKey:["projects",a==="all"?void 0:a],queryFn:()=>Pe.getProjects(a==="all"?void 0:a)}),g=_t({mutationFn:A=>Pe.createProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),e("Project created","success")},onError:A=>{e(A.message,"error")}}),m=_t({mutationFn:({id:A,data:T})=>Pe.updateProject(A,T),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),s(void 0),e("Project updated","success")},onError:A=>{e(A.message,"error")}}),x=_t({mutationFn:A=>Pe.deleteProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),u(null),e("Project deleted","success")},onError:A=>{e(A.message,"error")}}),y=A=>{i?m.mutate({id:i.id,data:A}):g.mutate(A)},v=A=>{s(A),r(!0)},b=A=>{v(A)},E=A=>{u(A)},S=()=>{l!==null&&x.mutate(l)};return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx(bh,{className:"w-6 h-6 text-bambu-green"}),c.jsx("h1",{className:"text-2xl font-bold text-white",children:"Projects"})]}),c.jsxs(Ie,{onClick:()=>r(!0),children:[c.jsx(pr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),c.jsx("div",{className:"flex gap-2",children:["active","completed","archived","all"].map(A=>c.jsx("button",{onClick:()=>o(A),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${a===A?"bg-bambu-green text-white":"bg-bambu-card text-bambu-gray hover:bg-bambu-gray/20"}`,children:A.charAt(0).toUpperCase()+A.slice(1)},A))}),f?c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):d?.length===0?c.jsx(kt,{children:c.jsxs(Dt,{className:"py-12 text-center",children:[c.jsx(bh,{className:"w-12 h-12 text-bambu-gray/50 mx-auto mb-4"}),c.jsx("p",{className:"text-bambu-gray",children:"No projects found"}),c.jsx("p",{className:"text-bambu-gray/70 text-sm mt-1",children:"Create a project to group related prints together"})]})}):c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d?.map(A=>c.jsx(g7e,{project:A,onClick:()=>b(A),onEdit:()=>v(A),onDelete:()=>E(A.id)},A.id))}),l!==null&&c.jsx(Yr,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:S,onCancel:()=>u(null)}),n&&c.jsx(m7e,{project:i,onClose:()=>{r(!1),s(void 0)},onSave:y,isLoading:g.isPending||m.isPending})]})}function b7e(){const{printerId:t}=NG(),e=parseInt(t||"0",10),[n,r]=M.useState("stream"),[i,s]=M.useState(!1),[a,o]=M.useState(!0),[l,u]=M.useState(Date.now()),[d,f]=M.useState(!1),[g,m]=M.useState(!1),x=M.useRef(null),y=M.useRef(null),{data:v}=yt({queryKey:["printer",e],queryFn:()=>Pe.getPrinter(e),enabled:e>0});M.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambuddy"}),[v]),M.useEffect(()=>()=>{x.current&&(x.current.src="")},[]),M.useEffect(()=>{if(a&&!d){const C=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(C)}},[n,a,l,d]),M.useEffect(()=>{const I=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",I),()=>document.removeEventListener("fullscreenchange",I)},[]);const b=()=>{s(!0),o(!1)},E=()=>{o(!1),s(!1)},S=I=>{n===I||d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),setTimeout(()=>{r(I),u(Date.now()),f(!1)},100))},A=()=>{d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),setTimeout(()=>{u(Date.now()),f(!1)},100))},T=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},k=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${l}`:`/api/v1/printers/${e}/camera/snapshot?t=${l}`,N=a||d;return e?c.jsxs("div",{ref:y,className:"min-h-screen bg-black flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[c.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[c.jsx(u0,{className:"w-4 h-4"}),v?.name||`Printer ${e}`]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[c.jsx("button",{onClick:()=>S("stream"),disabled:N,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"}),c.jsx("button",{onClick:()=>S("snapshot"),disabled:N,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"})]}),c.jsx("button",{onClick:A,disabled:N,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:c.jsx(Xs,{className:`w-4 h-4 text-bambu-gray ${N?"animate-spin":""}`})}),c.jsx("button",{onClick:T,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?c.jsx(tce,{className:"w-4 h-4 text-bambu-gray"}):c.jsx(Xle,{className:"w-4 h-4 text-bambu-gray"})})]})]}),c.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:c.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(a||d)&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Xs,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),c.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:c.jsxs("div",{className:"text-center p-4",children:[c.jsx(Jr,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),c.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),c.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),c.jsx("button",{onClick:A,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),c.jsx("img",{ref:x,src:k,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:k?b:void 0,onLoad:k?E:void 0},l)]})})]}):c.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:c.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function v7e(){const{id:t}=NG(),{theme:e}=ub(),{data:n,isLoading:r,error:i}=yt({queryKey:["external-link",t],queryFn:()=>Pe.getExternalLink(Number(t)),enabled:!!t});return r?c.jsx("div",{className:"flex items-center justify-center h-full",children:c.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[c.jsx(Jr,{className:"w-12 h-12"}),c.jsx("p",{children:"Link not found"})]}):c.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function y7e(){const t=M.useRef(null),e=M.useRef(null),n=En(),[r,i]=M.useState(!1),s=M.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const u=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,d=new WebSocket(u);let f=null;d.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),f=window.setInterval(()=>{d.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"}))},3e4)},d.onmessage=g=>{try{const m=JSON.parse(g.data);a(m)}catch{}},d.onclose=g=>{console.log("[WebSocket] Closed",g.code,g.reason),f&&(clearInterval(f),f=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{s()},3e3)},d.onerror=g=>{console.error("[WebSocket] Error",g),d.close()},t.current=d},[]),a=M.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],u=>{const d={...u,...l.data};return d.wifi_signal==null&&u?.wifi_signal!=null&&(d.wifi_signal=u.wifi_signal),d});break;case"print_complete":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break;case"archive_created":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break}},[n]);M.useEffect(()=>(s(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[s]);const o=M.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:r,sendMessage:o}}const _7e=new wae({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function w7e({children:t}){return y7e(),c.jsx(c.Fragment,{children:t})}function S7e(){return c.jsx(Pue,{children:c.jsx(Bue,{children:c.jsx(Sae,{client:_7e,children:c.jsx(w7e,{children:c.jsx(Vse,{children:c.jsxs(_se,{children:[c.jsx(Ia,{path:"/camera/:printerId",element:c.jsx(b7e,{})}),c.jsxs(Ia,{path:"/",element:c.jsx(Uue,{}),children:[c.jsx(Ia,{index:!0,element:c.jsx(uCe,{})}),c.jsx(Ia,{path:"archives",element:c.jsx(LVe,{})}),c.jsx(Ia,{path:"queue",element:c.jsx(_Ge,{})}),c.jsx(Ia,{path:"stats",element:c.jsx(jGe,{})}),c.jsx(Ia,{path:"profiles",element:c.jsx(u7e,{})}),c.jsx(Ia,{path:"maintenance",element:c.jsx(p7e,{})}),c.jsx(Ia,{path:"projects",element:c.jsx(x7e,{})}),c.jsx(Ia,{path:"settings",element:c.jsx(JGe,{})}),c.jsx(Ia,{path:"external/:id",element:c.jsx(v7e,{})})]})]})})})})})})}Mre.createRoot(document.getElementById("root")).render(c.jsx(M.StrictMode,{children:c.jsx(S7e,{})}));
|