| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611 |
- function _re(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 hy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vA={exports:{}},rx={};var Y5;function wre(){if(Y5)return rx;Y5=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 rx.Fragment=e,rx.jsx=n,rx.jsxs=n,rx}var Z5;function Sre(){return Z5||(Z5=1,vA.exports=wre()),vA.exports}var l=Sre(),yA={exports:{}},en={};var Q5;function Ere(){if(Q5)return en;Q5=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"),c=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,J){this.props=U,this.context=z,this.refs=v,this.updater=J||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,J){this.props=U,this.context=z,this.refs=v,this.updater=J||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,J){var se=J.ref;return{$$typeof:t,type:U,key:z,ref:se!==void 0?se:null,props:J}}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(J){return z[J]})}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,J,se,me){var fe=typeof U;(fe==="undefined"||fe==="boolean")&&(U=null);var xe=!1;if(U===null)xe=!0;else switch(fe){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,J,se,me)}}if(xe)return me=me(U),xe=se===""?"."+R(U,0):se,T(me)?(J="",xe!=null&&(J=xe.replace(q,"$&/")+"/"),K(me,z,J,"",function(we){return we})):me!=null&&(F(me)&&(me=D(me,J+(me.key==null||U&&U.key===me.key?"":(""+me.key).replace(q,"$&/")+"/")+xe)),z.push(me)),1;xe=0;var Ee=se===""?".":se+":";if(T(U))for(var re=0;re<U.length;re++)se=U[re],fe=Ee+R(se,re),xe+=K(se,z,J,fe,me);else if(re=m(U),typeof re=="function")for(U=re.call(U),re=0;!(se=U.next()).done;)se=se.value,fe=Ee+R(se,re++),xe+=K(se,z,J,fe,me);else if(fe==="object"){if(typeof U.then=="function")return K(W(U),z,J,se,me);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,J){if(U==null)return U;var se=[],me=0;return K(U,se,"","",function(fe){return z.call(J,fe,me++)}),se}function ee(U){if(U._status===-1){var z=U._result;z=z(),z.then(function(J){(U._status===0||U._status===-1)&&(U._status=1,U._result=J)},function(J){(U._status===0||U._status===-1)&&(U._status=2,U._result=J)}),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)},Q={map:V,forEach:function(U,z,J){V(U,function(){z.apply(this,arguments)},J)},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 en.Activity=f,en.Children=Q,en.Component=b,en.Fragment=n,en.Profiler=i,en.PureComponent=S,en.StrictMode=r,en.Suspense=c,en.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,en.__COMPILER_RUNTIME={__proto__:null,c:function(U){return N.H.useMemoCache(U)}},en.cache=function(U){return function(){return U.apply(null,arguments)}},en.cacheSignal=function(){return null},en.cloneElement=function(U,z,J){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var se=y({},U.props),me=U.key;if(z!=null)for(fe in z.key!==void 0&&(me=""+z.key),z)!I.call(z,fe)||fe==="key"||fe==="__self"||fe==="__source"||fe==="ref"&&z.ref===void 0||(se[fe]=z[fe]);var fe=arguments.length-2;if(fe===1)se.children=J;else if(1<fe){for(var xe=Array(fe),Ee=0;Ee<fe;Ee++)xe[Ee]=arguments[Ee+2];se.children=xe}return C(U.type,me,se)},en.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},en.createElement=function(U,z,J){var se,me={},fe=null;if(z!=null)for(se in z.key!==void 0&&(fe=""+z.key),z)I.call(z,se)&&se!=="key"&&se!=="__self"&&se!=="__source"&&(me[se]=z[se]);var xe=arguments.length-2;if(xe===1)me.children=J;else if(1<xe){for(var Ee=Array(xe),re=0;re<xe;re++)Ee[re]=arguments[re+2];me.children=Ee}if(U&&U.defaultProps)for(se in xe=U.defaultProps,xe)me[se]===void 0&&(me[se]=xe[se]);return C(U,fe,me)},en.createRef=function(){return{current:null}},en.forwardRef=function(U){return{$$typeof:o,render:U}},en.isValidElement=F,en.lazy=function(U){return{$$typeof:d,_payload:{_status:-1,_result:U},_init:ee}},en.memo=function(U,z){return{$$typeof:u,type:U,compare:z===void 0?null:z}},en.startTransition=function(U){var z=N.T,J={};N.T=J;try{var se=U(),me=N.S;me!==null&&me(J,se),typeof se=="object"&&se!==null&&typeof se.then=="function"&&se.then(k,Y)}catch(fe){Y(fe)}finally{z!==null&&J.types!==null&&(z.types=J.types),N.T=z}},en.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},en.use=function(U){return N.H.use(U)},en.useActionState=function(U,z,J){return N.H.useActionState(U,z,J)},en.useCallback=function(U,z){return N.H.useCallback(U,z)},en.useContext=function(U){return N.H.useContext(U)},en.useDebugValue=function(){},en.useDeferredValue=function(U,z){return N.H.useDeferredValue(U,z)},en.useEffect=function(U,z){return N.H.useEffect(U,z)},en.useEffectEvent=function(U){return N.H.useEffectEvent(U)},en.useId=function(){return N.H.useId()},en.useImperativeHandle=function(U,z,J){return N.H.useImperativeHandle(U,z,J)},en.useInsertionEffect=function(U,z){return N.H.useInsertionEffect(U,z)},en.useLayoutEffect=function(U,z){return N.H.useLayoutEffect(U,z)},en.useMemo=function(U,z){return N.H.useMemo(U,z)},en.useOptimistic=function(U,z){return N.H.useOptimistic(U,z)},en.useReducer=function(U,z,J){return N.H.useReducer(U,z,J)},en.useRef=function(U){return N.H.useRef(U)},en.useState=function(U){return N.H.useState(U)},en.useSyncExternalStore=function(U,z,J){return N.H.useSyncExternalStore(U,z,J)},en.useTransition=function(){return N.H.useTransition()},en.version="19.2.0",en}var J5;function Vm(){return J5||(J5=1,yA.exports=Ere()),yA.exports}var M=Vm();const mr=fo(M),Mre=_re({__proto__:null,default:mr},[M]);var _A={exports:{}},ix={},wA={exports:{}},SA={};var eU;function Are(){return eU||(eU=1,(function(t){function e(K,V){var ee=K.length;K.push(V);e:for(;0<ee;){var Y=ee-1>>>1,Q=K[Y];if(0<i(Q,V))K[Y]=V,K[ee]=Q,ee=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],ee=K.pop();if(ee!==V){K[0]=ee;e:for(var Y=0,Q=K.length,U=Q>>>1;Y<U;){var z=2*(Y+1)-1,J=K[z],se=z+1,me=K[se];if(0>i(J,ee))se<Q&&0>i(me,J)?(K[Y]=me,K[se]=ee,Y=se):(K[Y]=J,K[z]=ee,Y=z);else if(se<Q&&0>i(me,ee))K[Y]=me,K[se]=ee,Y=se;else break e}}return V}function i(K,V){var ee=K.sortIndex-V.sortIndex;return ee!==0?ee: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 c=[],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(c,V);else break;V=n(u)}}function T(K){if(y=!1,A(K),!x)if(n(c)!==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 ee=g;try{t:{for(A(K),f=n(c);f!==null&&!(f.expirationTime>K&&D());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,g=f.priorityLevel;var Q=Y(f.expirationTime<=K);if(K=t.unstable_now(),typeof Q=="function"){f.callback=Q,A(K),V=!0;break t}f===n(c)&&r(c),A(K)}else r(c);f=n(c)}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=ee,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 ee=g;g=V;try{return K()}finally{g=ee}},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 ee=g;g=K;try{return V()}finally{g=ee}},t.unstable_scheduleCallback=function(K,V,ee){var Y=t.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?Y+ee:Y):ee=Y,K){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=ee+Q,K={id:d++,callback:V,priorityLevel:K,startTime:ee,expirationTime:Q,sortIndex:-1},ee>Y?(K.sortIndex=ee,e(u,K),n(c)===null&&K===n(u)&&(y?(E(N),N=-1):y=!0,W(T,ee-Y))):(K.sortIndex=Q,e(c,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 ee=g;g=V;try{return K.apply(this,arguments)}finally{g=ee}}}})(SA)),SA}var tU;function Tre(){return tU||(tU=1,wA.exports=Are()),wA.exports}var EA={exports:{}},is={};var nU;function Cre(){if(nU)return is;nU=1;var t=Vm();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var a=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return is.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,is.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return s(c,u,null,d)},is.flushSync=function(c){var u=a.T,d=r.p;try{if(a.T=null,r.p=2,c)return c()}finally{a.T=u,r.p=d,r.d.f()}},is.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},is.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},is.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},is.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=o(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},is.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},is.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=o(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},is.requestFormReset=function(c){r.d.r(c)},is.unstable_batchedUpdates=function(c,u){return c(u)},is.useFormState=function(c,u,d){return a.H.useFormState(c,u,d)},is.useFormStatus=function(){return a.H.useHostTransitionStatus()},is.version="19.2.0",is}var rU;function gG(){if(rU)return EA.exports;rU=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(),EA.exports=Cre(),EA.exports}var iU;function Nre(){if(iU)return ix;iU=1;var t=Tre(),e=Vm(),n=gG();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 c(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 c(P),h;if(O===w)return c(P),p;O=O.sibling}throw Error(r(188))}if(_.return!==w.return)_=P,w=O;else{for(var X=!1,le=P.child;le;){if(le===_){X=!0,_=P,w=O;break}if(le===w){X=!0,w=P,_=O;break}le=le.sibling}if(!X){for(le=O.child;le;){if(le===_){X=!0,_=O,w=P;break}if(le===w){X=!0,w=O,_=P;break}le=le.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,ee={pending:!1,data:null,method:null,action:null},Y=[],Q=-1;function U(h){return{current:h}}function z(h){0>Q||(h.current=Y[Q],Y[Q]=null,Q--)}function J(h,p){Q++,Y[Q]=h.current,h.current=p}var se=U(null),me=U(null),fe=U(null),xe=U(null);function Ee(h,p){switch(J(fe,p),J(me,h),J(se,null),p.nodeType){case 9:case 11:h=(h=p.documentElement)&&(h=h.namespaceURI)?v5(h):0;break;default:if(h=p.tagName,p=p.namespaceURI)p=v5(p),h=y5(p,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}z(se),J(se,h)}function re(){z(se),z(me),z(fe)}function we(h){h.memoizedState!==null&&J(xe,h);var p=se.current,_=y5(p,h.type);p!==_&&(J(me,h),J(se,_))}function Oe(h){me.current===h&&(z(se),z(me)),xe.current===h&&(z(xe),Jg._currentValue=ee)}var he,ht;function $(h){if(he===void 0)try{throw Error()}catch(_){var p=_.stack.trim().match(/\n( *(at )?)/);he=p&&p[1]||"",ht=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+he+h+ht}var H=!1;function ne(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(st){var Ze=st}Reflect.construct(h,[],dt)}else{try{dt.call()}catch(st){Ze=st}h.call(dt.prototype)}}else{try{throw Error()}catch(st){Ze=st}(dt=h())&&typeof dt.catch=="function"&&dt.catch(function(){})}}catch(st){if(st&&Ze&&typeof st.stack=="string")return[st.stack,Ze.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],le=O[1];if(X&&le){var Ae=X.split(`
- `),Xe=le.split(`
- `);for(P=w=0;w<Ae.length&&!Ae[w].includes("DetermineComponentFrameRoot");)w++;for(;P<Xe.length&&!Xe[P].includes("DetermineComponentFrameRoot");)P++;if(w===Ae.length||P===Xe.length)for(w=Ae.length-1,P=Xe.length-1;1<=w&&0<=P&&Ae[w]!==Xe[P];)P--;for(;1<=w&&0<=P;w--,P--)if(Ae[w]!==Xe[P]){if(w!==1||P!==1)do if(w--,P--,0>P||Ae[w]!==Xe[P]){var lt=`
- `+Ae[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 ne(h.type,!1);case 11:return ne(h.type.render,!1);case 1:return ne(h.type,!0);case 31:return $("Activity");default:return""}}function Z(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 oe=Object.prototype.hasOwnProperty,Ne=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,Se=t.unstable_shouldYield,B=t.unstable_requestPaint,L=t.unstable_now,te=t.unstable_getCurrentPriorityLevel,ve=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,be=t.unstable_NormalPriority,nt=t.unstable_LowPriority,Be=t.unstable_IdlePriority,ue=t.log,Ve=t.unstable_setDisableYieldValue,Ue=null,ae=null;function Je(h){if(typeof ue=="function"&&Ve(h),ae&&typeof ae.setStrictMode=="function")try{ae.setStrictMode(Ue,h)}catch{}}var He=Math.clz32?Math.clz32:de,Ke=Math.log,ct=Math.LN2;function de(h){return h>>>=0,h===0?32:31-(Ke(h)/ct|0)|0}var Ye=256,ge=262144,Fe=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 ye(h,p,_){var w=h.pendingLanes;if(w===0)return 0;var P=0,O=h.suspendedLanes,X=h.pingedLanes;h=h.warmLanes;var le=w&134217727;return le!==0?(w=le&~O,w!==0?P=Ce(w):(X&=le,X!==0?P=Ce(X):_||(_=le&~h,_!==0&&(P=Ce(_))))):(le=w&~O,le!==0?P=Ce(le):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 ce(h,p){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&p)===0}function at(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 xt(){var h=Fe;return Fe<<=1,(Fe&62914560)===0&&(Fe=4194304),h}function St(h){for(var p=[],_=0;31>_;_++)p.push(h);return p}function Qt(h,p){h.pendingLanes|=p,p!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function jt(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 le=h.entanglements,Ae=h.expirationTimes,Xe=h.hiddenUpdates;for(_=X&~_;0<_;){var lt=31-He(_),dt=1<<lt;le[lt]=0,Ae[lt]=-1;var Ze=Xe[lt];if(Ze!==null)for(Xe[lt]=null,lt=0;lt<Ze.length;lt++){var st=Ze[lt];st!==null&&(st.lane&=-536870913)}_&=~dt}w!==0&&Vt(h,w,0),O!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=O&~(X&~p))}function Vt(h,p,_){h.pendingLanes|=p,h.suspendedLanes&=~p;var w=31-He(p);h.entangledLanes|=p,h.entanglements[w]=h.entanglements[w]|1073741824|_&261930}function jn(h,p){var _=h.entangledLanes|=p;for(h=h.entanglements;_;){var w=31-He(_),P=1<<w;P&p|h[w]&p&&(h[w]|=p),_&=~P}}function Ei(h,p){var _=p&-p;return _=(_&42)!==0?1:ai(_),(_&(h.suspendedLanes|p))!==0?0:_}function ai(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 Mi(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function zi(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:$5(h.type))}function rs(h,p){var _=V.p;try{return V.p=h,p()}finally{V.p=_}}var Hr=Math.random().toString(36).slice(2),br="__reactFiber$"+Hr,Or="__reactProps$"+Hr,mo="__reactContainer$"+Hr,Hc="__reactEvents$"+Hr,pe="__reactListeners$"+Hr,$e="__reactHandles$"+Hr,rt="__reactResources$"+Hr,it="__reactMarker$"+Hr;function et(h){delete h[br],delete h[Or],delete h[Hc],delete h[pe],delete h[$e]}function Et(h){var p=h[br];if(p)return p;for(var _=h.parentNode;_;){if(p=_[mo]||_[br]){if(_=p.alternate,p.child!==null||_!==null&&_.child!==null)for(h=T5(h);h!==null;){if(_=h[br])return _;h=T5(h)}return p}h=_,_=h.parentNode}return null}function ie(h){if(h=h[br]||h[mo]){var p=h.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return h}return null}function Me(h){var p=h.tag;if(p===5||p===26||p===27||p===6)return h.stateNode;throw Error(r(33))}function Ie(h){var p=h[rt];return p||(p=h[rt]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function je(h){h[it]=!0}var Te=new Set,ot={};function ft(h,p){vt(h,p),vt(h+"Capture",p)}function vt(h,p){for(ot[h]=p,h=0;h<p.length;h++)Te.add(p[h])}var bt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Lt={},Tt={};function mt(h){return oe.call(Tt,h)?!0:oe.call(Lt,h)?!1:bt.test(h)?Tt[h]=!0:(Lt[h]=!0,!1)}function Xt(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 sn(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 hn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function bn(h){var 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 Jt(h){if(!h._valueTracker){var p=bn(h)?"checked":"value";h._valueTracker=Ut(h,p,""+h[p])}}function tn(h){if(!h)return!1;var p=h._valueTracker;if(!p)return!0;var _=p.getValue(),w="";return h&&(w=bn(h)?h.checked?"true":"false":h.value),h=w,h!==_?(p.setValue(h),!0):!1}function Ar(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 jr=/[\n"\\]/g;function Dn(h){return h.replace(jr,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function go(h,p,_,w,P,O,X,le){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=""+hn(p)):h.value!==""+hn(p)&&(h.value=""+hn(p)):X!=="submit"&&X!=="reset"||h.removeAttribute("value"),p!=null?Ai(h,X,hn(p)):_!=null?Ai(h,X,hn(_)):w!=null&&h.removeAttribute("value"),P==null&&O!=null&&(h.defaultChecked=!!O),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),le!=null&&typeof le!="function"&&typeof le!="symbol"&&typeof le!="boolean"?h.name=""+hn(le):h.removeAttribute("name")}function Ln(h,p,_,w,P,O,X,le){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)){Jt(h);return}_=_!=null?""+hn(_):"",p=p!=null?""+hn(p):_,le||p===h.value||(h.value=p),h.defaultValue=p}w=w??P,w=typeof w!="function"&&typeof w!="symbol"&&!!w,h.checked=le?h.checked:!!w,h.defaultChecked=!!w,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(h.name=X),Jt(h)}function Ai(h,p,_){p==="number"&&Ar(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function oi(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(_=""+hn(_),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 Ti(h,p,_){if(p!=null&&(p=""+hn(p),p!==h.value&&(h.value=p),_==null)){h.defaultValue!==p&&(h.defaultValue=p);return}h.defaultValue=_!=null?""+hn(_):""}function Bi(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=_}_=hn(p),h.defaultValue=_,w=h.textContent,w===_&&w!==""&&w!==null&&(h.value=w),Jt(h)}function Vo(h,p){if(p){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=p;return}}h.textContent=p}var Al=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 gL(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||Al.has(p)?p==="float"?h.cssFloat=_:h[p]=(""+_).trim():h[p]=_+"px"}function xL(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&&gL(h,P,w)}else for(var O in p)p.hasOwnProperty(O)&&gL(h,O,p[O])}function mM(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 xte=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"]]),bte=/^[\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 rv(h){return bte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Tl(){}var gM=null;function xM(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var bf=null,vf=null;function bL(h){var p=ie(h);if(p&&(h=p.stateNode)){var _=h[Or]||null;e:switch(h=p.stateNode,p.type){case"input":if(go(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),p=_.name,_.type==="radio"&&p!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Dn(""+p)+'"][type="radio"]'),p=0;p<_.length;p++){var w=_[p];if(w!==h&&w.form===h.form){var P=w[Or]||null;if(!P)throw Error(r(90));go(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&&tn(w)}break e;case"textarea":Ti(h,_.value,_.defaultValue);break e;case"select":p=_.value,p!=null&&oi(h,!!_.multiple,p,!1)}}}var bM=!1;function vL(h,p,_){if(bM)return h(p,_);bM=!0;try{var w=h(p);return w}finally{if(bM=!1,(bf!==null||vf!==null)&&(Vv(),bf&&(p=bf,h=vf,vf=bf=null,bL(p),h)))for(p=0;p<h.length;p++)bL(h[p])}}function gg(h,p){var _=h.stateNode;if(_===null)return null;var w=_[Or]||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 Cl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vM=!1;if(Cl)try{var xg={};Object.defineProperty(xg,"passive",{get:function(){vM=!0}}),window.addEventListener("test",xg,xg),window.removeEventListener("test",xg,xg)}catch{vM=!1}var $c=null,yM=null,iv=null;function yL(){if(iv)return iv;var h,p=yM,_=p.length,w,P="value"in $c?$c.value:$c.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 iv=P.slice(h,1<w?1-w:void 0)}function sv(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 av(){return!0}function _L(){return!1}function js(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 le in h)h.hasOwnProperty(le)&&(_=h[le],this[le]=_?_(O):O[le]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?av:_L,this.isPropagationStopped=_L,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=av)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=av)},persist:function(){},isPersistent:av}),p}var Ad={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ov=js(Ad),bg=f({},Ad,{view:0,detail:0}),vte=js(bg),_M,wM,vg,lv=f({},bg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:EM,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!==vg&&(vg&&h.type==="mousemove"?(_M=h.screenX-vg.screenX,wM=h.screenY-vg.screenY):wM=_M=0,vg=h),_M)},movementY:function(h){return"movementY"in h?h.movementY:wM}}),wL=js(lv),yte=f({},lv,{dataTransfer:0}),_te=js(yte),wte=f({},bg,{relatedTarget:0}),SM=js(wte),Ste=f({},Ad,{animationName:0,elapsedTime:0,pseudoElement:0}),Ete=js(Ste),Mte=f({},Ad,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Ate=js(Mte),Tte=f({},Ad,{data:0}),SL=js(Tte),Cte={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nte={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"},kte={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Pte(h){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(h):(h=kte[h])?!!p[h]:!1}function EM(){return Pte}var Rte=f({},bg,{key:function(h){if(h.key){var p=Cte[h.key]||h.key;if(p!=="Unidentified")return p}return h.type==="keypress"?(h=sv(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Nte[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:EM,charCode:function(h){return h.type==="keypress"?sv(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?sv(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Dte=js(Rte),Ote=f({},lv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),EL=js(Ote),jte=f({},bg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:EM}),Lte=js(jte),Ite=f({},Ad,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ute=js(Ite),Fte=f({},lv,{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}),zte=js(Fte),Bte=f({},Ad,{newState:0,oldState:0}),Hte=js(Bte),$te=[9,13,27,32],MM=Cl&&"CompositionEvent"in window,yg=null;Cl&&"documentMode"in document&&(yg=document.documentMode);var Vte=Cl&&"TextEvent"in window&&!yg,ML=Cl&&(!MM||yg&&8<yg&&11>=yg),AL=" ",TL=!1;function CL(h,p){switch(h){case"keyup":return $te.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function NL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var yf=!1;function Gte(h,p){switch(h){case"compositionend":return NL(p);case"keypress":return p.which!==32?null:(TL=!0,AL);case"textInput":return h=p.data,h===AL&&TL?null:h;default:return null}}function Wte(h,p){if(yf)return h==="compositionend"||!MM&&CL(h,p)?(h=yL(),iv=yM=$c=null,yf=!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 ML&&p.locale!=="ko"?null:p.data;default:return null}}var qte={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function kL(h){var p=h&&h.nodeName&&h.nodeName.toLowerCase();return p==="input"?!!qte[h.type]:p==="textarea"}function PL(h,p,_,w){bf?vf?vf.push(w):vf=[w]:bf=w,p=Zv(p,"onChange"),0<p.length&&(_=new ov("onChange","change",null,_,w),h.push({event:_,listeners:p}))}var _g=null,wg=null;function Kte(h){f5(h,0)}function cv(h){var p=Me(h);if(tn(p))return h}function RL(h,p){if(h==="change")return p}var DL=!1;if(Cl){var AM;if(Cl){var TM="oninput"in document;if(!TM){var OL=document.createElement("div");OL.setAttribute("oninput","return;"),TM=typeof OL.oninput=="function"}AM=TM}else AM=!1;DL=AM&&(!document.documentMode||9<document.documentMode)}function jL(){_g&&(_g.detachEvent("onpropertychange",LL),wg=_g=null)}function LL(h){if(h.propertyName==="value"&&cv(wg)){var p=[];PL(p,wg,h,xM(h)),vL(Kte,p)}}function Xte(h,p,_){h==="focusin"?(jL(),_g=p,wg=_,_g.attachEvent("onpropertychange",LL)):h==="focusout"&&jL()}function Yte(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return cv(wg)}function Zte(h,p){if(h==="click")return cv(p)}function Qte(h,p){if(h==="input"||h==="change")return cv(p)}function Jte(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var na=typeof Object.is=="function"?Object.is:Jte;function Sg(h,p){if(na(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(!oe.call(p,P)||!na(h[P],p[P]))return!1}return!0}function IL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function UL(h,p){var _=IL(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}_=IL(_)}}function FL(h,p){return h&&p?h===p?!0:h&&h.nodeType===3?!1:p&&p.nodeType===3?FL(h,p.parentNode):"contains"in h?h.contains(p):h.compareDocumentPosition?!!(h.compareDocumentPosition(p)&16):!1:!1}function zL(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var p=Ar(h.document);p instanceof h.HTMLIFrameElement;){try{var _=typeof p.contentWindow.location.href=="string"}catch{_=!1}if(_)h=p.contentWindow;else break;p=Ar(h.document)}return p}function CM(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 ene=Cl&&"documentMode"in document&&11>=document.documentMode,_f=null,NM=null,Eg=null,kM=!1;function BL(h,p,_){var w=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;kM||_f==null||_f!==Ar(w)||(w=_f,"selectionStart"in w&&CM(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}),Eg&&Sg(Eg,w)||(Eg=w,w=Zv(NM,"onSelect"),0<w.length&&(p=new ov("onSelect","select",null,p,_),h.push({event:p,listeners:w}),p.target=_f)))}function Td(h,p){var _={};return _[h.toLowerCase()]=p.toLowerCase(),_["Webkit"+h]="webkit"+p,_["Moz"+h]="moz"+p,_}var wf={animationend:Td("Animation","AnimationEnd"),animationiteration:Td("Animation","AnimationIteration"),animationstart:Td("Animation","AnimationStart"),transitionrun:Td("Transition","TransitionRun"),transitionstart:Td("Transition","TransitionStart"),transitioncancel:Td("Transition","TransitionCancel"),transitionend:Td("Transition","TransitionEnd")},PM={},HL={};Cl&&(HL=document.createElement("div").style,"AnimationEvent"in window||(delete wf.animationend.animation,delete wf.animationiteration.animation,delete wf.animationstart.animation),"TransitionEvent"in window||delete wf.transitionend.transition);function Cd(h){if(PM[h])return PM[h];if(!wf[h])return h;var p=wf[h],_;for(_ in p)if(p.hasOwnProperty(_)&&_ in HL)return PM[h]=p[_];return h}var $L=Cd("animationend"),VL=Cd("animationiteration"),GL=Cd("animationstart"),tne=Cd("transitionrun"),nne=Cd("transitionstart"),rne=Cd("transitioncancel"),WL=Cd("transitionend"),qL=new Map,RM="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(" ");RM.push("scrollEnd");function xo(h,p){qL.set(h,p),ft(p,[h])}var uv=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)},ka=[],Sf=0,DM=0;function dv(){for(var h=Sf,p=DM=Sf=0;p<h;){var _=ka[p];ka[p++]=null;var w=ka[p];ka[p++]=null;var P=ka[p];ka[p++]=null;var O=ka[p];if(ka[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&&KL(_,P,O)}}function hv(h,p,_,w){ka[Sf++]=h,ka[Sf++]=p,ka[Sf++]=_,ka[Sf++]=w,DM|=w,h.lanes|=w,h=h.alternate,h!==null&&(h.lanes|=w)}function OM(h,p,_,w){return hv(h,p,_,w),fv(h)}function Nd(h,p){return hv(h,null,null,p),fv(h)}function KL(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-He(_),h=O.hiddenUpdates,w=h[P],w===null?h[P]=[p]:w.push(p),p.lane=_|536870912),O):null}function fv(h){if(50<Wg)throw Wg=0,$2=null,Error(r(185));for(var p=h.return;p!==null;)h=p,p=h.return;return h.tag===3?h.stateNode:null}var Ef={};function ine(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 ra(h,p,_,w){return new ine(h,p,_,w)}function jM(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Nl(h,p){var _=h.alternate;return _===null?(_=ra(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 XL(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 pv(h,p,_,w,P,O){var X=0;if(w=h,typeof h=="function")jM(h)&&(X=1);else if(typeof h=="string")X=cre(h,_,se.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case C:return h=ra(31,_,p,P),h.elementType=C,h.lanes=O,h;case y:return kd(_.children,P,O,p);case v:X=8,P|=24;break;case b:return h=ra(12,_,p,P|2),h.elementType=b,h.lanes=O,h;case T:return h=ra(13,_,p,P),h.elementType=T,h.lanes=O,h;case k:return h=ra(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=ra(X,_,p,P),p.elementType=h,p.type=w,p.lanes=O,p}function kd(h,p,_,w){return h=ra(7,h,w,p),h.lanes=_,h}function LM(h,p,_){return h=ra(6,h,null,p),h.lanes=_,h}function YL(h){var p=ra(18,null,null,0);return p.stateNode=h,p}function IM(h,p,_){return p=ra(4,h.children!==null?h.children:[],h.key,p),p.lanes=_,p.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},p}var ZL=new WeakMap;function Pa(h,p){if(typeof h=="object"&&h!==null){var _=ZL.get(h);return _!==void 0?_:(p={value:h,source:p,stack:Z(p)},ZL.set(h,p),p)}return{value:h,source:p,stack:Z(p)}}var Mf=[],Af=0,mv=null,Mg=0,Ra=[],Da=0,Vc=null,Go=1,Wo="";function kl(h,p){Mf[Af++]=Mg,Mf[Af++]=mv,mv=h,Mg=p}function QL(h,p,_){Ra[Da++]=Go,Ra[Da++]=Wo,Ra[Da++]=Vc,Vc=h;var w=Go;h=Wo;var P=32-He(w)-1;w&=~(1<<P),_+=1;var O=32-He(p)+P;if(30<O){var X=P-P%5;O=(w&(1<<X)-1).toString(32),w>>=X,P-=X,Go=1<<32-He(p)+P|_<<P|w,Wo=O+h}else Go=1<<O|_<<P|w,Wo=h}function UM(h){h.return!==null&&(kl(h,1),QL(h,1,0))}function FM(h){for(;h===mv;)mv=Mf[--Af],Mf[Af]=null,Mg=Mf[--Af],Mf[Af]=null;for(;h===Vc;)Vc=Ra[--Da],Ra[Da]=null,Wo=Ra[--Da],Ra[Da]=null,Go=Ra[--Da],Ra[Da]=null}function JL(h,p){Ra[Da++]=Go,Ra[Da++]=Wo,Ra[Da++]=Vc,Go=p.id,Wo=p.overflow,Vc=h}var Hi=null,ar=null,wn=!1,Gc=null,Oa=!1,zM=Error(r(519));function Wc(h){var p=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ag(Pa(p,h)),zM}function eI(h){var p=h.stateNode,_=h.type,w=h.memoizedProps;switch(p[br]=h,p[Or]=w,_){case"dialog":mn("cancel",p),mn("close",p);break;case"iframe":case"object":case"embed":mn("load",p);break;case"video":case"audio":for(_=0;_<Kg.length;_++)mn(Kg[_],p);break;case"source":mn("error",p);break;case"img":case"image":case"link":mn("error",p),mn("load",p);break;case"details":mn("toggle",p);break;case"input":mn("invalid",p),Ln(p,w.value,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name,!0);break;case"select":mn("invalid",p);break;case"textarea":mn("invalid",p),Bi(p,w.value,w.defaultValue,w.children)}_=w.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||p.textContent===""+_||w.suppressHydrationWarning===!0||x5(p.textContent,_)?(w.popover!=null&&(mn("beforetoggle",p),mn("toggle",p)),w.onScroll!=null&&mn("scroll",p),w.onScrollEnd!=null&&mn("scrollend",p),w.onClick!=null&&(p.onclick=Tl),p=!0):p=!1,p||Wc(h,!0)}function tI(h){for(Hi=h.return;Hi;)switch(Hi.tag){case 5:case 31:case 13:Oa=!1;return;case 27:case 3:Oa=!0;return;default:Hi=Hi.return}}function Tf(h){if(h!==Hi)return!1;if(!wn)return tI(h),wn=!0,!1;var p=h.tag,_;if((_=p!==3&&p!==27)&&((_=p===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||iA(h.type,h.memoizedProps)),_=!_),_&&ar&&Wc(h),tI(h),p===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));ar=A5(h)}else if(p===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));ar=A5(h)}else p===27?(p=ar,au(h.type)?(h=cA,cA=null,ar=h):ar=p):ar=Hi?La(h.stateNode.nextSibling):null;return!0}function Pd(){ar=Hi=null,wn=!1}function BM(){var h=Gc;return h!==null&&(Fs===null?Fs=h:Fs.push.apply(Fs,h),Gc=null),h}function Ag(h){Gc===null?Gc=[h]:Gc.push(h)}var HM=U(null),Rd=null,Pl=null;function qc(h,p,_){J(HM,p._currentValue),p._currentValue=_}function Rl(h){h._currentValue=HM.current,z(HM)}function $M(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 VM(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 le=O;O=P;for(var Ae=0;Ae<p.length;Ae++)if(le.context===p[Ae]){O.lanes|=_,le=O.alternate,le!==null&&(le.lanes|=_),$M(O.return,_,h),w||(X=null);break e}O=le.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|=_),$M(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 Cf(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 le=P.type;na(P.pendingProps.value,X.value)||(h!==null?h.push(le):h=[le])}}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(Jg):h=[Jg])}P=P.return}h!==null&&VM(p,h,_,w),p.flags|=262144}function gv(h){for(h=h.firstContext;h!==null;){if(!na(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Dd(h){Rd=h,Pl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function $i(h){return nI(Rd,h)}function xv(h,p){return Rd===null&&Dd(h),nI(h,p)}function nI(h,p){var _=p._currentValue;if(p={context:p,memoizedValue:_,next:null},Pl===null){if(h===null)throw Error(r(308));Pl=p,h.dependencies={lanes:0,firstContext:p},h.flags|=524288}else Pl=Pl.next=p;return _}var sne=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 _()})}},ane=t.unstable_scheduleCallback,one=t.unstable_NormalPriority,$r={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function GM(){return{controller:new sne,data:new Map,refCount:0}}function Tg(h){h.refCount--,h.refCount===0&&ane(one,function(){h.controller.abort()})}var Cg=null,WM=0,Nf=0,kf=null;function lne(h,p){if(Cg===null){var _=Cg=[];WM=0,Nf=X2(),kf={status:"pending",value:void 0,then:function(w){_.push(w)}}}return WM++,p.then(rI,rI),p}function rI(){if(--WM===0&&Cg!==null){kf!==null&&(kf.status="fulfilled");var h=Cg;Cg=null,Nf=0,kf=null;for(var p=0;p<h.length;p++)(0,h[p])()}}function cne(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 iI=K.S;K.S=function(h,p){B4=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&lne(h,p),iI!==null&&iI(h,p)};var Od=U(null);function qM(){var h=Od.current;return h!==null?h:Jn.pooledCache}function bv(h,p){p===null?J(Od,Od.current):J(Od,p.pool)}function sI(){var h=qM();return h===null?null:{parent:$r._currentValue,pool:h}}var Pf=Error(r(460)),KM=Error(r(474)),vv=Error(r(542)),yv={then:function(){}};function aI(h){return h=h.status,h==="fulfilled"||h==="rejected"}function oI(h,p,_){switch(_=h[_],_===void 0?h.push(p):_!==p&&(p.then(Tl,Tl),p=_),p.status){case"fulfilled":return p.value;case"rejected":throw h=p.reason,cI(h),h;default:if(typeof p.status=="string")p.then(Tl,Tl);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,cI(h),h}throw Ld=p,Pf}}function jd(h){try{var p=h._init;return p(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Ld=_,Pf):_}}var Ld=null;function lI(){if(Ld===null)throw Error(r(459));var h=Ld;return Ld=null,h}function cI(h){if(h===Pf||h===vv)throw Error(r(483))}var Rf=null,Ng=0;function _v(h){var p=Ng;return Ng+=1,Rf===null&&(Rf=[]),oI(Rf,h,p)}function kg(h,p){p=p.props.ref,h.ref=p!==void 0?p:null}function wv(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 uI(h){function p(ze,Re){if(h){var We=ze.deletions;We===null?(ze.deletions=[Re],ze.flags|=16):We.push(Re)}}function _(ze,Re){if(!h)return null;for(;Re!==null;)p(ze,Re),Re=Re.sibling;return null}function w(ze){for(var Re=new Map;ze!==null;)ze.key!==null?Re.set(ze.key,ze):Re.set(ze.index,ze),ze=ze.sibling;return Re}function P(ze,Re){return ze=Nl(ze,Re),ze.index=0,ze.sibling=null,ze}function O(ze,Re,We){return ze.index=We,h?(We=ze.alternate,We!==null?(We=We.index,We<Re?(ze.flags|=67108866,Re):We):(ze.flags|=67108866,Re)):(ze.flags|=1048576,Re)}function X(ze){return h&&ze.alternate===null&&(ze.flags|=67108866),ze}function le(ze,Re,We,ut){return Re===null||Re.tag!==6?(Re=LM(We,ze.mode,ut),Re.return=ze,Re):(Re=P(Re,We),Re.return=ze,Re)}function Ae(ze,Re,We,ut){var zt=We.type;return zt===y?lt(ze,Re,We.props.children,ut,We.key):Re!==null&&(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&jd(zt)===Re.type)?(Re=P(Re,We.props),kg(Re,We),Re.return=ze,Re):(Re=pv(We.type,We.key,We.props,null,ze.mode,ut),kg(Re,We),Re.return=ze,Re)}function Xe(ze,Re,We,ut){return Re===null||Re.tag!==4||Re.stateNode.containerInfo!==We.containerInfo||Re.stateNode.implementation!==We.implementation?(Re=IM(We,ze.mode,ut),Re.return=ze,Re):(Re=P(Re,We.children||[]),Re.return=ze,Re)}function lt(ze,Re,We,ut,zt){return Re===null||Re.tag!==7?(Re=kd(We,ze.mode,ut,zt),Re.return=ze,Re):(Re=P(Re,We),Re.return=ze,Re)}function dt(ze,Re,We){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return Re=LM(""+Re,ze.mode,We),Re.return=ze,Re;if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case m:return We=pv(Re.type,Re.key,Re.props,null,ze.mode,We),kg(We,Re),We.return=ze,We;case x:return Re=IM(Re,ze.mode,We),Re.return=ze,Re;case I:return Re=jd(Re),dt(ze,Re,We)}if(W(Re)||j(Re))return Re=kd(Re,ze.mode,We,null),Re.return=ze,Re;if(typeof Re.then=="function")return dt(ze,_v(Re),We);if(Re.$$typeof===S)return dt(ze,xv(ze,Re),We);wv(ze,Re)}return null}function Ze(ze,Re,We,ut){var zt=Re!==null?Re.key:null;if(typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint")return zt!==null?null:le(ze,Re,""+We,ut);if(typeof We=="object"&&We!==null){switch(We.$$typeof){case m:return We.key===zt?Ae(ze,Re,We,ut):null;case x:return We.key===zt?Xe(ze,Re,We,ut):null;case I:return We=jd(We),Ze(ze,Re,We,ut)}if(W(We)||j(We))return zt!==null?null:lt(ze,Re,We,ut,null);if(typeof We.then=="function")return Ze(ze,Re,_v(We),ut);if(We.$$typeof===S)return Ze(ze,Re,xv(ze,We),ut);wv(ze,We)}return null}function st(ze,Re,We,ut,zt){if(typeof ut=="string"&&ut!==""||typeof ut=="number"||typeof ut=="bigint")return ze=ze.get(We)||null,le(Re,ze,""+ut,zt);if(typeof ut=="object"&&ut!==null){switch(ut.$$typeof){case m:return ze=ze.get(ut.key===null?We:ut.key)||null,Ae(Re,ze,ut,zt);case x:return ze=ze.get(ut.key===null?We:ut.key)||null,Xe(Re,ze,ut,zt);case I:return ut=jd(ut),st(ze,Re,We,ut,zt)}if(W(ut)||j(ut))return ze=ze.get(We)||null,lt(Re,ze,ut,zt,null);if(typeof ut.then=="function")return st(ze,Re,We,_v(ut),zt);if(ut.$$typeof===S)return st(ze,Re,We,xv(Re,ut),zt);wv(Re,ut)}return null}function Ot(ze,Re,We,ut){for(var zt=null,An=null,It=Re,rn=Re=0,yn=null;It!==null&&rn<We.length;rn++){It.index>rn?(yn=It,It=null):yn=It.sibling;var Tn=Ze(ze,It,We[rn],ut);if(Tn===null){It===null&&(It=yn);break}h&&It&&Tn.alternate===null&&p(ze,It),Re=O(Tn,Re,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn,It=yn}if(rn===We.length)return _(ze,It),wn&&kl(ze,rn),zt;if(It===null){for(;rn<We.length;rn++)It=dt(ze,We[rn],ut),It!==null&&(Re=O(It,Re,rn),An===null?zt=It:An.sibling=It,An=It);return wn&&kl(ze,rn),zt}for(It=w(It);rn<We.length;rn++)yn=st(It,ze,rn,We[rn],ut),yn!==null&&(h&&yn.alternate!==null&&It.delete(yn.key===null?rn:yn.key),Re=O(yn,Re,rn),An===null?zt=yn:An.sibling=yn,An=yn);return h&&It.forEach(function(du){return p(ze,du)}),wn&&kl(ze,rn),zt}function Gt(ze,Re,We,ut){if(We==null)throw Error(r(151));for(var zt=null,An=null,It=Re,rn=Re=0,yn=null,Tn=We.next();It!==null&&!Tn.done;rn++,Tn=We.next()){It.index>rn?(yn=It,It=null):yn=It.sibling;var du=Ze(ze,It,Tn.value,ut);if(du===null){It===null&&(It=yn);break}h&&It&&du.alternate===null&&p(ze,It),Re=O(du,Re,rn),An===null?zt=du:An.sibling=du,An=du,It=yn}if(Tn.done)return _(ze,It),wn&&kl(ze,rn),zt;if(It===null){for(;!Tn.done;rn++,Tn=We.next())Tn=dt(ze,Tn.value,ut),Tn!==null&&(Re=O(Tn,Re,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn);return wn&&kl(ze,rn),zt}for(It=w(It);!Tn.done;rn++,Tn=We.next())Tn=st(It,ze,rn,Tn.value,ut),Tn!==null&&(h&&Tn.alternate!==null&&It.delete(Tn.key===null?rn:Tn.key),Re=O(Tn,Re,rn),An===null?zt=Tn:An.sibling=Tn,An=Tn);return h&&It.forEach(function(yre){return p(ze,yre)}),wn&&kl(ze,rn),zt}function Gn(ze,Re,We,ut){if(typeof We=="object"&&We!==null&&We.type===y&&We.key===null&&(We=We.props.children),typeof We=="object"&&We!==null){switch(We.$$typeof){case m:e:{for(var zt=We.key;Re!==null;){if(Re.key===zt){if(zt=We.type,zt===y){if(Re.tag===7){_(ze,Re.sibling),ut=P(Re,We.props.children),ut.return=ze,ze=ut;break e}}else if(Re.elementType===zt||typeof zt=="object"&&zt!==null&&zt.$$typeof===I&&jd(zt)===Re.type){_(ze,Re.sibling),ut=P(Re,We.props),kg(ut,We),ut.return=ze,ze=ut;break e}_(ze,Re);break}else p(ze,Re);Re=Re.sibling}We.type===y?(ut=kd(We.props.children,ze.mode,ut,We.key),ut.return=ze,ze=ut):(ut=pv(We.type,We.key,We.props,null,ze.mode,ut),kg(ut,We),ut.return=ze,ze=ut)}return X(ze);case x:e:{for(zt=We.key;Re!==null;){if(Re.key===zt)if(Re.tag===4&&Re.stateNode.containerInfo===We.containerInfo&&Re.stateNode.implementation===We.implementation){_(ze,Re.sibling),ut=P(Re,We.children||[]),ut.return=ze,ze=ut;break e}else{_(ze,Re);break}else p(ze,Re);Re=Re.sibling}ut=IM(We,ze.mode,ut),ut.return=ze,ze=ut}return X(ze);case I:return We=jd(We),Gn(ze,Re,We,ut)}if(W(We))return Ot(ze,Re,We,ut);if(j(We)){if(zt=j(We),typeof zt!="function")throw Error(r(150));return We=zt.call(We),Gt(ze,Re,We,ut)}if(typeof We.then=="function")return Gn(ze,Re,_v(We),ut);if(We.$$typeof===S)return Gn(ze,Re,xv(ze,We),ut);wv(ze,We)}return typeof We=="string"&&We!==""||typeof We=="number"||typeof We=="bigint"?(We=""+We,Re!==null&&Re.tag===6?(_(ze,Re.sibling),ut=P(Re,We),ut.return=ze,ze=ut):(_(ze,Re),ut=LM(We,ze.mode,ut),ut.return=ze,ze=ut),X(ze)):_(ze,Re)}return function(ze,Re,We,ut){try{Ng=0;var zt=Gn(ze,Re,We,ut);return Rf=null,zt}catch(It){if(It===Pf||It===vv)throw It;var An=ra(29,It,null,ze.mode);return An.lanes=ut,An.return=ze,An}finally{}}}var Id=uI(!0),dI=uI(!1),Kc=!1;function XM(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function YM(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 Xc(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Yc(h,p,_){var w=h.updateQueue;if(w===null)return null;if(w=w.shared,(kn&2)!==0){var P=w.pending;return P===null?p.next=p:(p.next=P.next,P.next=p),w.pending=p,p=fv(h),KL(h,null,_),p}return hv(h,w,p,_),fv(h)}function Pg(h,p,_){if(p=p.updateQueue,p!==null&&(p=p.shared,(_&4194048)!==0)){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,jn(h,_)}}function ZM(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 QM=!1;function Rg(){if(QM){var h=kf;if(h!==null)throw h}}function Dg(h,p,_,w){QM=!1;var P=h.updateQueue;Kc=!1;var O=P.firstBaseUpdate,X=P.lastBaseUpdate,le=P.shared.pending;if(le!==null){P.shared.pending=null;var Ae=le,Xe=Ae.next;Ae.next=null,X===null?O=Xe:X.next=Xe,X=Ae;var lt=h.alternate;lt!==null&&(lt=lt.updateQueue,le=lt.lastBaseUpdate,le!==X&&(le===null?lt.firstBaseUpdate=Xe:le.next=Xe,lt.lastBaseUpdate=Ae))}if(O!==null){var dt=P.baseState;X=0,lt=Xe=Ae=null,le=O;do{var Ze=le.lane&-536870913,st=Ze!==le.lane;if(st?(vn&Ze)===Ze:(w&Ze)===Ze){Ze!==0&&Ze===Nf&&(QM=!0),lt!==null&&(lt=lt.next={lane:0,tag:le.tag,payload:le.payload,callback:null,next:null});e:{var Ot=h,Gt=le;Ze=p;var Gn=_;switch(Gt.tag){case 1:if(Ot=Gt.payload,typeof Ot=="function"){dt=Ot.call(Gn,dt,Ze);break e}dt=Ot;break e;case 3:Ot.flags=Ot.flags&-65537|128;case 0:if(Ot=Gt.payload,Ze=typeof Ot=="function"?Ot.call(Gn,dt,Ze):Ot,Ze==null)break e;dt=f({},dt,Ze);break e;case 2:Kc=!0}}Ze=le.callback,Ze!==null&&(h.flags|=64,st&&(h.flags|=8192),st=P.callbacks,st===null?P.callbacks=[Ze]:st.push(Ze))}else st={lane:Ze,tag:le.tag,payload:le.payload,callback:le.callback,next:null},lt===null?(Xe=lt=st,Ae=dt):lt=lt.next=st,X|=Ze;if(le=le.next,le===null){if(le=P.shared.pending,le===null)break;st=le,le=st.next,st.next=null,P.lastBaseUpdate=st,P.shared.pending=null}}while(!0);lt===null&&(Ae=dt),P.baseState=Ae,P.firstBaseUpdate=Xe,P.lastBaseUpdate=lt,O===null&&(P.shared.lanes=0),tu|=X,h.lanes=X,h.memoizedState=dt}}function hI(h,p){if(typeof h!="function")throw Error(r(191,h));h.call(p)}function fI(h,p){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)hI(_[h],p)}var Df=U(null),Sv=U(0);function pI(h,p){h=Bl,J(Sv,h),J(Df,p),Bl=h|p.baseLanes}function JM(){J(Sv,Bl),J(Df,Df.current)}function e2(){Bl=Sv.current,z(Df),z(Sv)}var ia=U(null),ja=null;function Zc(h){var p=h.alternate;J(Lr,Lr.current&1),J(ia,h),ja===null&&(p===null||Df.current!==null||p.memoizedState!==null)&&(ja=h)}function t2(h){J(Lr,Lr.current),J(ia,h),ja===null&&(ja=h)}function mI(h){h.tag===22?(J(Lr,Lr.current),J(ia,h),ja===null&&(ja=h)):Qc()}function Qc(){J(Lr,Lr.current),J(ia,ia.current)}function sa(h){z(ia),ja===h&&(ja=null),z(Lr)}var Lr=U(0);function Ev(h){for(var p=h;p!==null;){if(p.tag===13){var _=p.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||oA(_)||lA(_)))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 Dl=0,nn=null,$n=null,Vr=null,Mv=!1,Of=!1,Ud=!1,Av=0,Og=0,jf=null,une=0;function Tr(){throw Error(r(321))}function n2(h,p){if(p===null)return!1;for(var _=0;_<p.length&&_<h.length;_++)if(!na(h[_],p[_]))return!1;return!0}function r2(h,p,_,w,P,O){return Dl=O,nn=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,K.H=h===null||h.memoizedState===null?QI:b2,Ud=!1,O=_(w,P),Ud=!1,Of&&(O=xI(p,_,w,P)),gI(h),O}function gI(h){K.H=Ig;var p=$n!==null&&$n.next!==null;if(Dl=0,Vr=$n=nn=null,Mv=!1,Og=0,jf=null,p)throw Error(r(300));h===null||Gr||(h=h.dependencies,h!==null&&gv(h)&&(Gr=!0))}function xI(h,p,_,w){nn=h;var P=0;do{if(Of&&(jf=null),Og=0,Of=!1,25<=P)throw Error(r(301));if(P+=1,Vr=$n=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=JI,O=p(_,w)}while(Of);return O}function dne(){var h=K.H,p=h.useState()[0];return p=typeof p.then=="function"?jg(p):p,h=h.useState()[0],($n!==null?$n.memoizedState:null)!==h&&(nn.flags|=1024),p}function i2(){var h=Av!==0;return Av=0,h}function s2(h,p,_){p.updateQueue=h.updateQueue,p.flags&=-2053,h.lanes&=~_}function a2(h){if(Mv){for(h=h.memoizedState;h!==null;){var p=h.queue;p!==null&&(p.pending=null),h=h.next}Mv=!1}Dl=0,Vr=$n=nn=null,Of=!1,Og=Av=0,jf=null}function vs(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vr===null?nn.memoizedState=Vr=h:Vr=Vr.next=h,Vr}function Ir(){if($n===null){var h=nn.alternate;h=h!==null?h.memoizedState:null}else h=$n.next;var p=Vr===null?nn.memoizedState:Vr.next;if(p!==null)Vr=p,$n=h;else{if(h===null)throw nn.alternate===null?Error(r(467)):Error(r(310));$n=h,h={memoizedState:$n.memoizedState,baseState:$n.baseState,baseQueue:$n.baseQueue,queue:$n.queue,next:null},Vr===null?nn.memoizedState=Vr=h:Vr=Vr.next=h}return Vr}function Tv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function jg(h){var p=Og;return Og+=1,jf===null&&(jf=[]),h=oI(jf,h,p),p=nn,(Vr===null?p.memoizedState:Vr.next)===null&&(p=p.alternate,K.H=p===null||p.memoizedState===null?QI:b2),h}function Cv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return jg(h);if(h.$$typeof===S)return $i(h)}throw Error(r(438,String(h)))}function o2(h){var p=null,_=nn.updateQueue;if(_!==null&&(p=_.memoCache),p==null){var w=nn.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&&(_=Tv(),nn.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 Ol(h,p){return typeof p=="function"?p(h):p}function Nv(h){var p=Ir();return l2(p,$n,h)}function l2(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 le=X=null,Ae=null,Xe=p,lt=!1;do{var dt=Xe.lane&-536870913;if(dt!==Xe.lane?(vn&dt)===dt:(Dl&dt)===dt){var Ze=Xe.revertLane;if(Ze===0)Ae!==null&&(Ae=Ae.next={lane:0,revertLane:0,gesture:null,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null}),dt===Nf&&(lt=!0);else if((Dl&Ze)===Ze){Xe=Xe.next,Ze===Nf&&(lt=!0);continue}else dt={lane:0,revertLane:Xe.revertLane,gesture:null,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},Ae===null?(le=Ae=dt,X=O):Ae=Ae.next=dt,nn.lanes|=Ze,tu|=Ze;dt=Xe.action,Ud&&_(O,dt),O=Xe.hasEagerState?Xe.eagerState:_(O,dt)}else Ze={lane:dt,revertLane:Xe.revertLane,gesture:Xe.gesture,action:Xe.action,hasEagerState:Xe.hasEagerState,eagerState:Xe.eagerState,next:null},Ae===null?(le=Ae=Ze,X=O):Ae=Ae.next=Ze,nn.lanes|=dt,tu|=dt;Xe=Xe.next}while(Xe!==null&&Xe!==p);if(Ae===null?X=O:Ae.next=le,!na(O,h.memoizedState)&&(Gr=!0,lt&&(_=kf,_!==null)))throw _;h.memoizedState=O,h.baseState=X,h.baseQueue=Ae,w.lastRenderedState=O}return P===null&&(w.lanes=0),[h.memoizedState,w.dispatch]}function c2(h){var p=Ir(),_=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);na(O,p.memoizedState)||(Gr=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),_.lastRenderedState=O}return[O,w]}function bI(h,p,_){var w=nn,P=Ir(),O=wn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=p();var X=!na(($n||P).memoizedState,_);if(X&&(P.memoizedState=_,Gr=!0),P=P.queue,h2(_I.bind(null,w,P,h),[h]),P.getSnapshot!==p||X||Vr!==null&&Vr.memoizedState.tag&1){if(w.flags|=2048,Lf(9,{destroy:void 0},yI.bind(null,w,P,_,p),null),Jn===null)throw Error(r(349));O||(Dl&127)!==0||vI(w,p,_)}return _}function vI(h,p,_){h.flags|=16384,h={getSnapshot:p,value:_},p=nn.updateQueue,p===null?(p=Tv(),nn.updateQueue=p,p.stores=[h]):(_=p.stores,_===null?p.stores=[h]:_.push(h))}function yI(h,p,_,w){p.value=_,p.getSnapshot=w,wI(p)&&SI(h)}function _I(h,p,_){return _(function(){wI(p)&&SI(h)})}function wI(h){var p=h.getSnapshot;h=h.value;try{var _=p();return!na(h,_)}catch{return!0}}function SI(h){var p=Nd(h,2);p!==null&&zs(p,h,2)}function u2(h){var p=vs();if(typeof h=="function"){var _=h;if(h=_(),Ud){Je(!0);try{_()}finally{Je(!1)}}}return p.memoizedState=p.baseState=h,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ol,lastRenderedState:h},p}function EI(h,p,_,w){return h.baseState=_,l2(h,$n,typeof w=="function"?w:Ol)}function hne(h,p,_,w,P){if(Rv(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,MI(p,O)):(O.next=_.next,p.pending=_.next=O)}}function MI(h,p){var _=p.action,w=p.payload,P=h.state;if(p.isTransition){var O=K.T,X={};K.T=X;try{var le=_(P,w),Ae=K.S;Ae!==null&&Ae(X,le),AI(h,p,le)}catch(Xe){d2(h,p,Xe)}finally{O!==null&&X.types!==null&&(O.types=X.types),K.T=O}}else try{O=_(P,w),AI(h,p,O)}catch(Xe){d2(h,p,Xe)}}function AI(h,p,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(w){TI(h,p,w)},function(w){return d2(h,p,w)}):TI(h,p,_)}function TI(h,p,_){p.status="fulfilled",p.value=_,CI(p),h.state=_,p=h.pending,p!==null&&(_=p.next,_===p?h.pending=null:(_=_.next,p.next=_,MI(h,_)))}function d2(h,p,_){var w=h.pending;if(h.pending=null,w!==null){w=w.next;do p.status="rejected",p.reason=_,CI(p),p=p.next;while(p!==w)}h.action=null}function CI(h){h=h.listeners;for(var p=0;p<h.length;p++)(0,h[p])()}function NI(h,p){return p}function kI(h,p){if(wn){var _=Jn.formState;if(_!==null){e:{var w=nn;if(wn){if(ar){t:{for(var P=ar,O=Oa;P.nodeType!==8;){if(!O){P=null;break t}if(P=La(P.nextSibling),P===null){P=null;break t}}O=P.data,P=O==="F!"||O==="F"?P:null}if(P){ar=La(P.nextSibling),w=P.data==="F!";break e}}Wc(w)}w=!1}w&&(p=_[0])}}return _=vs(),_.memoizedState=_.baseState=p,w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:NI,lastRenderedState:p},_.queue=w,_=XI.bind(null,nn,w),w.dispatch=_,w=u2(!1),O=x2.bind(null,nn,!1,w.queue),w=vs(),P={state:p,dispatch:null,action:h,pending:null},w.queue=P,_=hne.bind(null,nn,P,O,_),P.dispatch=_,w.memoizedState=h,[p,_,!1]}function PI(h){var p=Ir();return RI(p,$n,h)}function RI(h,p,_){if(p=l2(h,p,NI)[0],h=Nv(Ol)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var w=jg(p)}catch(X){throw X===Pf?vv:X}else w=p;p=Ir();var P=p.queue,O=P.dispatch;return _!==p.memoizedState&&(nn.flags|=2048,Lf(9,{destroy:void 0},fne.bind(null,P,_),null)),[w,O,h]}function fne(h,p){h.action=p}function DI(h){var p=Ir(),_=$n;if(_!==null)return RI(p,_,h);Ir(),p=p.memoizedState,_=Ir();var w=_.queue.dispatch;return _.memoizedState=h,[p,w,!1]}function Lf(h,p,_,w){return h={tag:h,create:_,deps:w,inst:p,next:null},p=nn.updateQueue,p===null&&(p=Tv(),nn.updateQueue=p),_=p.lastEffect,_===null?p.lastEffect=h.next=h:(w=_.next,_.next=h,h.next=w,p.lastEffect=h),h}function OI(){return Ir().memoizedState}function kv(h,p,_,w){var P=vs();nn.flags|=h,P.memoizedState=Lf(1|p,{destroy:void 0},_,w===void 0?null:w)}function Pv(h,p,_,w){var P=Ir();w=w===void 0?null:w;var O=P.memoizedState.inst;$n!==null&&w!==null&&n2(w,$n.memoizedState.deps)?P.memoizedState=Lf(p,O,_,w):(nn.flags|=h,P.memoizedState=Lf(1|p,O,_,w))}function jI(h,p){kv(8390656,8,h,p)}function h2(h,p){Pv(2048,8,h,p)}function pne(h){nn.flags|=4;var p=nn.updateQueue;if(p===null)p=Tv(),nn.updateQueue=p,p.events=[h];else{var _=p.events;_===null?p.events=[h]:_.push(h)}}function LI(h){var p=Ir().memoizedState;return pne({ref:p,nextImpl:h}),function(){if((kn&2)!==0)throw Error(r(440));return p.impl.apply(void 0,arguments)}}function II(h,p){return Pv(4,2,h,p)}function UI(h,p){return Pv(4,4,h,p)}function FI(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 zI(h,p,_){_=_!=null?_.concat([h]):null,Pv(4,4,FI.bind(null,p,h),_)}function f2(){}function BI(h,p){var _=Ir();p=p===void 0?null:p;var w=_.memoizedState;return p!==null&&n2(p,w[1])?w[0]:(_.memoizedState=[h,p],h)}function HI(h,p){var _=Ir();p=p===void 0?null:p;var w=_.memoizedState;if(p!==null&&n2(p,w[1]))return w[0];if(w=h(),Ud){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[w,p],w}function p2(h,p,_){return _===void 0||(Dl&1073741824)!==0&&(vn&261930)===0?h.memoizedState=p:(h.memoizedState=_,h=$4(),nn.lanes|=h,tu|=h,_)}function $I(h,p,_,w){return na(_,p)?_:Df.current!==null?(h=p2(h,_,w),na(h,p)||(Gr=!0),h):(Dl&42)===0||(Dl&1073741824)!==0&&(vn&261930)===0?(Gr=!0,h.memoizedState=_):(h=$4(),nn.lanes|=h,tu|=h,p)}function VI(h,p,_,w,P){var O=V.p;V.p=O!==0&&8>O?O:8;var X=K.T,le={};K.T=le,x2(h,!1,p,_);try{var Ae=P(),Xe=K.S;if(Xe!==null&&Xe(le,Ae),Ae!==null&&typeof Ae=="object"&&typeof Ae.then=="function"){var lt=cne(Ae,w);Lg(h,p,lt,la(h))}else Lg(h,p,w,la(h))}catch(dt){Lg(h,p,{then:function(){},status:"rejected",reason:dt},la())}finally{V.p=O,X!==null&&le.types!==null&&(X.types=le.types),K.T=X}}function mne(){}function m2(h,p,_,w){if(h.tag!==5)throw Error(r(476));var P=GI(h).queue;VI(h,P,p,ee,_===null?mne:function(){return WI(h),_(w)})}function GI(h){var p=h.memoizedState;if(p!==null)return p;p={memoizedState:ee,baseState:ee,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ol,lastRenderedState:ee},next:null};var _={};return p.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ol,lastRenderedState:_},next:null},h.memoizedState=p,h=h.alternate,h!==null&&(h.memoizedState=p),p}function WI(h){var p=GI(h);p.next===null&&(p=h.alternate.memoizedState),Lg(h,p.next.queue,{},la())}function g2(){return $i(Jg)}function qI(){return Ir().memoizedState}function KI(){return Ir().memoizedState}function gne(h){for(var p=h.return;p!==null;){switch(p.tag){case 24:case 3:var _=la();h=Xc(_);var w=Yc(p,h,_);w!==null&&(zs(w,p,_),Pg(w,p,_)),p={cache:GM()},h.payload=p;return}p=p.return}}function xne(h,p,_){var w=la();_={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Rv(h)?YI(p,_):(_=OM(h,p,_,w),_!==null&&(zs(_,h,w),ZI(_,p,w)))}function XI(h,p,_){var w=la();Lg(h,p,_,w)}function Lg(h,p,_,w){var P={lane:w,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Rv(h))YI(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,le=O(X,_);if(P.hasEagerState=!0,P.eagerState=le,na(le,X))return hv(h,p,P,0),Jn===null&&dv(),!1}catch{}finally{}if(_=OM(h,p,P,w),_!==null)return zs(_,h,w),ZI(_,p,w),!0}return!1}function x2(h,p,_,w){if(w={lane:2,revertLane:X2(),gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Rv(h)){if(p)throw Error(r(479))}else p=OM(h,_,w,2),p!==null&&zs(p,h,2)}function Rv(h){var p=h.alternate;return h===nn||p!==null&&p===nn}function YI(h,p){Of=Mv=!0;var _=h.pending;_===null?p.next=p:(p.next=_.next,_.next=p),h.pending=p}function ZI(h,p,_){if((_&4194048)!==0){var w=p.lanes;w&=h.pendingLanes,_|=w,p.lanes=_,jn(h,_)}}var Ig={readContext:$i,use:Cv,useCallback:Tr,useContext:Tr,useEffect:Tr,useImperativeHandle:Tr,useLayoutEffect:Tr,useInsertionEffect:Tr,useMemo:Tr,useReducer:Tr,useRef:Tr,useState:Tr,useDebugValue:Tr,useDeferredValue:Tr,useTransition:Tr,useSyncExternalStore:Tr,useId:Tr,useHostTransitionStatus:Tr,useFormState:Tr,useActionState:Tr,useOptimistic:Tr,useMemoCache:Tr,useCacheRefresh:Tr};Ig.useEffectEvent=Tr;var QI={readContext:$i,use:Cv,useCallback:function(h,p){return vs().memoizedState=[h,p===void 0?null:p],h},useContext:$i,useEffect:jI,useImperativeHandle:function(h,p,_){_=_!=null?_.concat([h]):null,kv(4194308,4,FI.bind(null,p,h),_)},useLayoutEffect:function(h,p){return kv(4194308,4,h,p)},useInsertionEffect:function(h,p){kv(4,2,h,p)},useMemo:function(h,p){var _=vs();p=p===void 0?null:p;var w=h();if(Ud){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[w,p],w},useReducer:function(h,p,_){var w=vs();if(_!==void 0){var P=_(p);if(Ud){Je(!0);try{_(p)}finally{Je(!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=xne.bind(null,nn,h),[w.memoizedState,h]},useRef:function(h){var p=vs();return h={current:h},p.memoizedState=h},useState:function(h){h=u2(h);var p=h.queue,_=XI.bind(null,nn,p);return p.dispatch=_,[h.memoizedState,_]},useDebugValue:f2,useDeferredValue:function(h,p){var _=vs();return p2(_,h,p)},useTransition:function(){var h=u2(!1);return h=VI.bind(null,nn,h.queue,!0,!1),vs().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,p,_){var w=nn,P=vs();if(wn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=p(),Jn===null)throw Error(r(349));(vn&127)!==0||vI(w,p,_)}P.memoizedState=_;var O={value:_,getSnapshot:p};return P.queue=O,jI(_I.bind(null,w,O,h),[h]),w.flags|=2048,Lf(9,{destroy:void 0},yI.bind(null,w,O,_,p),null),_},useId:function(){var h=vs(),p=Jn.identifierPrefix;if(wn){var _=Wo,w=Go;_=(w&~(1<<32-He(w)-1)).toString(32)+_,p="_"+p+"R_"+_,_=Av++,0<_&&(p+="H"+_.toString(32)),p+="_"}else _=une++,p="_"+p+"r_"+_.toString(32)+"_";return h.memoizedState=p},useHostTransitionStatus:g2,useFormState:kI,useActionState:kI,useOptimistic:function(h){var p=vs();p.memoizedState=p.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=_,p=x2.bind(null,nn,!0,_),_.dispatch=p,[h,p]},useMemoCache:o2,useCacheRefresh:function(){return vs().memoizedState=gne.bind(null,nn)},useEffectEvent:function(h){var p=vs(),_={impl:h};return p.memoizedState=_,function(){if((kn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},b2={readContext:$i,use:Cv,useCallback:BI,useContext:$i,useEffect:h2,useImperativeHandle:zI,useInsertionEffect:II,useLayoutEffect:UI,useMemo:HI,useReducer:Nv,useRef:OI,useState:function(){return Nv(Ol)},useDebugValue:f2,useDeferredValue:function(h,p){var _=Ir();return $I(_,$n.memoizedState,h,p)},useTransition:function(){var h=Nv(Ol)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:jg(h),p]},useSyncExternalStore:bI,useId:qI,useHostTransitionStatus:g2,useFormState:PI,useActionState:PI,useOptimistic:function(h,p){var _=Ir();return EI(_,$n,h,p)},useMemoCache:o2,useCacheRefresh:KI};b2.useEffectEvent=LI;var JI={readContext:$i,use:Cv,useCallback:BI,useContext:$i,useEffect:h2,useImperativeHandle:zI,useInsertionEffect:II,useLayoutEffect:UI,useMemo:HI,useReducer:c2,useRef:OI,useState:function(){return c2(Ol)},useDebugValue:f2,useDeferredValue:function(h,p){var _=Ir();return $n===null?p2(_,h,p):$I(_,$n.memoizedState,h,p)},useTransition:function(){var h=c2(Ol)[0],p=Ir().memoizedState;return[typeof h=="boolean"?h:jg(h),p]},useSyncExternalStore:bI,useId:qI,useHostTransitionStatus:g2,useFormState:DI,useActionState:DI,useOptimistic:function(h,p){var _=Ir();return $n!==null?EI(_,$n,h,p):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:o2,useCacheRefresh:KI};JI.useEffectEvent=LI;function v2(h,p,_,w){p=h.memoizedState,_=_(w,p),_=_==null?p:f({},p,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var y2={enqueueSetState:function(h,p,_){h=h._reactInternals;var w=la(),P=Xc(w);P.payload=p,_!=null&&(P.callback=_),p=Yc(h,P,w),p!==null&&(zs(p,h,w),Pg(p,h,w))},enqueueReplaceState:function(h,p,_){h=h._reactInternals;var w=la(),P=Xc(w);P.tag=1,P.payload=p,_!=null&&(P.callback=_),p=Yc(h,P,w),p!==null&&(zs(p,h,w),Pg(p,h,w))},enqueueForceUpdate:function(h,p){h=h._reactInternals;var _=la(),w=Xc(_);w.tag=2,p!=null&&(w.callback=p),p=Yc(h,w,_),p!==null&&(zs(p,h,_),Pg(p,h,_))}};function e4(h,p,_,w,P,O,X){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(w,O,X):p.prototype&&p.prototype.isPureReactComponent?!Sg(_,w)||!Sg(P,O):!0}function t4(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&&y2.enqueueReplaceState(p,p.state,null)}function Fd(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 n4(h){uv(h)}function r4(h){console.error(h)}function i4(h){uv(h)}function Dv(h,p){try{var _=h.onUncaughtError;_(p.value,{componentStack:p.stack})}catch(w){setTimeout(function(){throw w})}}function s4(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 _2(h,p,_){return _=Xc(_),_.tag=3,_.payload={element:null},_.callback=function(){Dv(h,p)},_}function a4(h){return h=Xc(h),h.tag=3,h}function o4(h,p,_,w){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var O=w.value;h.payload=function(){return P(O)},h.callback=function(){s4(p,_,w)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(h.callback=function(){s4(p,_,w),typeof P!="function"&&(nu===null?nu=new Set([this]):nu.add(this));var le=w.stack;this.componentDidCatch(w.value,{componentStack:le!==null?le:""})})}function bne(h,p,_,w,P){if(_.flags|=32768,w!==null&&typeof w=="object"&&typeof w.then=="function"){if(p=_.alternate,p!==null&&Cf(p,_,P,!0),_=ia.current,_!==null){switch(_.tag){case 31:case 13:return ja===null?Gv():_.alternate===null&&Cr===0&&(Cr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,w===yv?_.flags|=16384:(p=_.updateQueue,p===null?_.updateQueue=new Set([w]):p.add(w),W2(h,w,P)),!1;case 22:return _.flags|=65536,w===yv?_.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)),W2(h,w,P)),!1}throw Error(r(435,_.tag))}return W2(h,w,P),Gv(),!1}if(wn)return p=ia.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=P,w!==zM&&(h=Error(r(422),{cause:w}),Ag(Pa(h,_)))):(w!==zM&&(p=Error(r(423),{cause:w}),Ag(Pa(p,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,w=Pa(w,_),P=_2(h.stateNode,w,P),ZM(h,P),Cr!==4&&(Cr=2)),!1;var O=Error(r(520),{cause:w});if(O=Pa(O,_),Gg===null?Gg=[O]:Gg.push(O),Cr!==4&&(Cr=2),p===null)return!0;w=Pa(w,_),_=p;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=_2(_.stateNode,w,h),ZM(_,h),!1;case 1:if(p=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(nu===null||!nu.has(O))))return _.flags|=65536,P&=-P,_.lanes|=P,P=a4(P),o4(P,h,_,w),ZM(_,P),!1}_=_.return}while(_!==null);return!1}var w2=Error(r(461)),Gr=!1;function Vi(h,p,_,w){p.child=h===null?dI(p,null,_,w):Id(p,h.child,_,w)}function l4(h,p,_,w,P){_=_.render;var O=p.ref;if("ref"in w){var X={};for(var le in w)le!=="ref"&&(X[le]=w[le])}else X=w;return Dd(p),w=r2(h,p,_,X,O,P),le=i2(),h!==null&&!Gr?(s2(h,p,P),jl(h,p,P)):(wn&&le&&UM(p),p.flags|=1,Vi(h,p,w,P),p.child)}function c4(h,p,_,w,P){if(h===null){var O=_.type;return typeof O=="function"&&!jM(O)&&O.defaultProps===void 0&&_.compare===null?(p.tag=15,p.type=O,u4(h,p,O,w,P)):(h=pv(_.type,null,w,p,p.mode,P),h.ref=p.ref,h.return=p,p.child=h)}if(O=h.child,!k2(h,P)){var X=O.memoizedProps;if(_=_.compare,_=_!==null?_:Sg,_(X,w)&&h.ref===p.ref)return jl(h,p,P)}return p.flags|=1,h=Nl(O,w),h.ref=p.ref,h.return=p,p.child=h}function u4(h,p,_,w,P){if(h!==null){var O=h.memoizedProps;if(Sg(O,w)&&h.ref===p.ref)if(Gr=!1,p.pendingProps=w=O,k2(h,P))(h.flags&131072)!==0&&(Gr=!0);else return p.lanes=h.lanes,jl(h,p,P)}return S2(h,p,_,w,P)}function d4(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 h4(h,p,O,_,w)}if((_&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},h!==null&&bv(p,O!==null?O.cachePool:null),O!==null?pI(p,O):JM(),mI(p);else return w=p.lanes=536870912,h4(h,p,O!==null?O.baseLanes|_:_,_,w)}else O!==null?(bv(p,O.cachePool),pI(p,O),Qc(),p.memoizedState=null):(h!==null&&bv(p,null),JM(),Qc());return Vi(h,p,P,_),p.child}function Ug(h,p){return h!==null&&h.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function h4(h,p,_,w,P){var O=qM();return O=O===null?null:{parent:$r._currentValue,pool:O},p.memoizedState={baseLanes:_,cachePool:O},h!==null&&bv(p,null),JM(),mI(p),h!==null&&Cf(h,p,w,!0),p.childLanes=P,null}function Ov(h,p){return p=Lv({mode:p.mode,children:p.children},h.mode),p.ref=h.ref,h.child=p,p.return=h,p}function f4(h,p,_){return Id(p,h.child,null,_),h=Ov(p,p.pendingProps),h.flags|=2,sa(p),p.memoizedState=null,h}function vne(h,p,_){var w=p.pendingProps,P=(p.flags&128)!==0;if(p.flags&=-129,h===null){if(wn){if(w.mode==="hidden")return h=Ov(p,w),p.lanes=536870912,Ug(null,h);if(t2(p),(h=ar)?(h=M5(h,Oa),h=h!==null&&h.data==="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Vc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=YL(h),_.return=p,p.child=_,Hi=p,ar=null)):h=null,h===null)throw Wc(p);return p.lanes=536870912,null}return Ov(p,w)}var O=h.memoizedState;if(O!==null){var X=O.dehydrated;if(t2(p),P)if(p.flags&256)p.flags&=-257,p=f4(h,p,_);else if(p.memoizedState!==null)p.child=h.child,p.flags|=128,p=null;else throw Error(r(558));else if(Gr||Cf(h,p,_,!1),P=(_&h.childLanes)!==0,Gr||P){if(w=Jn,w!==null&&(X=Ei(w,_),X!==0&&X!==O.retryLane))throw O.retryLane=X,Nd(h,X),zs(w,h,X),w2;Gv(),p=f4(h,p,_)}else h=O.treeContext,ar=La(X.nextSibling),Hi=p,wn=!0,Gc=null,Oa=!1,h!==null&&JL(p,h),p=Ov(p,w),p.flags|=4096;return p}return h=Nl(h.child,{mode:w.mode,children:w.children}),h.ref=p.ref,p.child=h,h.return=p,h}function jv(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 S2(h,p,_,w,P){return Dd(p),_=r2(h,p,_,w,void 0,P),w=i2(),h!==null&&!Gr?(s2(h,p,P),jl(h,p,P)):(wn&&w&&UM(p),p.flags|=1,Vi(h,p,_,P),p.child)}function p4(h,p,_,w,P,O){return Dd(p),p.updateQueue=null,_=xI(p,w,_,P),gI(h),w=i2(),h!==null&&!Gr?(s2(h,p,O),jl(h,p,O)):(wn&&w&&UM(p),p.flags|=1,Vi(h,p,_,O),p.child)}function m4(h,p,_,w,P){if(Dd(p),p.stateNode===null){var O=Ef,X=_.contextType;typeof X=="object"&&X!==null&&(O=$i(X)),O=new _(w,O),p.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=y2,p.stateNode=O,O._reactInternals=p,O=p.stateNode,O.props=w,O.state=p.memoizedState,O.refs={},XM(p),X=_.contextType,O.context=typeof X=="object"&&X!==null?$i(X):Ef,O.state=p.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(v2(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&&y2.enqueueReplaceState(O,O.state,null),Dg(p,w,O,P),Rg(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),w=!0}else if(h===null){O=p.stateNode;var le=p.memoizedProps,Ae=Fd(_,le);O.props=Ae;var Xe=O.context,lt=_.contextType;X=Ef,typeof lt=="object"&<!==null&&(X=$i(lt));var dt=_.getDerivedStateFromProps;lt=typeof dt=="function"||typeof O.getSnapshotBeforeUpdate=="function",le=p.pendingProps!==le,lt||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(le||Xe!==X)&&t4(p,O,w,X),Kc=!1;var Ze=p.memoizedState;O.state=Ze,Dg(p,w,O,P),Rg(),Xe=p.memoizedState,le||Ze!==Xe||Kc?(typeof dt=="function"&&(v2(p,_,dt,w),Xe=p.memoizedState),(Ae=Kc||e4(p,_,Ae,w,Ze,Xe,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=Xe),O.props=w,O.state=Xe,O.context=X,w=Ae):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),w=!1)}else{O=p.stateNode,YM(h,p),X=p.memoizedProps,lt=Fd(_,X),O.props=lt,dt=p.pendingProps,Ze=O.context,Xe=_.contextType,Ae=Ef,typeof Xe=="object"&&Xe!==null&&(Ae=$i(Xe)),le=_.getDerivedStateFromProps,(Xe=typeof le=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(X!==dt||Ze!==Ae)&&t4(p,O,w,Ae),Kc=!1,Ze=p.memoizedState,O.state=Ze,Dg(p,w,O,P),Rg();var st=p.memoizedState;X!==dt||Ze!==st||Kc||h!==null&&h.dependencies!==null&&gv(h.dependencies)?(typeof le=="function"&&(v2(p,_,le,w),st=p.memoizedState),(lt=Kc||e4(p,_,lt,w,Ze,st,Ae)||h!==null&&h.dependencies!==null&&gv(h.dependencies))?(Xe||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(w,st,Ae),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(w,st,Ae)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=1024),p.memoizedProps=w,p.memoizedState=st),O.props=w,O.state=st,O.context=Ae,w=lt):(typeof O.componentDidUpdate!="function"||X===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&Ze===h.memoizedState||(p.flags|=1024),w=!1)}return O=w,jv(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=Id(p,h.child,null,P),p.child=Id(p,null,_,P)):Vi(h,p,_,P),p.memoizedState=O.state,h=p.child):h=jl(h,p,P),h}function g4(h,p,_,w){return Pd(),p.flags|=256,Vi(h,p,_,w),p.child}var E2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function M2(h){return{baseLanes:h,cachePool:sI()}}function A2(h,p,_){return h=h!==null?h.childLanes&~_:0,p&&(h|=oa),h}function x4(h,p,_){var w=p.pendingProps,P=!1,O=(p.flags&128)!==0,X;if((X=O)||(X=h!==null&&h.memoizedState===null?!1:(Lr.current&2)!==0),X&&(P=!0,p.flags&=-129),X=(p.flags&32)!==0,p.flags&=-33,h===null){if(wn){if(P?Zc(p):Qc(),(h=ar)?(h=M5(h,Oa),h=h!==null&&h.data!=="&"?h:null,h!==null&&(p.memoizedState={dehydrated:h,treeContext:Vc!==null?{id:Go,overflow:Wo}:null,retryLane:536870912,hydrationErrors:null},_=YL(h),_.return=p,p.child=_,Hi=p,ar=null)):h=null,h===null)throw Wc(p);return lA(h)?p.lanes=32:p.lanes=536870912,null}var le=w.children;return w=w.fallback,P?(Qc(),P=p.mode,le=Lv({mode:"hidden",children:le},P),w=kd(w,P,_,null),le.return=p,w.return=p,le.sibling=w,p.child=le,w=p.child,w.memoizedState=M2(_),w.childLanes=A2(h,X,_),p.memoizedState=E2,Ug(null,w)):(Zc(p),T2(p,le))}var Ae=h.memoizedState;if(Ae!==null&&(le=Ae.dehydrated,le!==null)){if(O)p.flags&256?(Zc(p),p.flags&=-257,p=C2(h,p,_)):p.memoizedState!==null?(Qc(),p.child=h.child,p.flags|=128,p=null):(Qc(),le=w.fallback,P=p.mode,w=Lv({mode:"visible",children:w.children},P),le=kd(le,P,_,null),le.flags|=2,w.return=p,le.return=p,w.sibling=le,p.child=w,Id(p,h.child,null,_),w=p.child,w.memoizedState=M2(_),w.childLanes=A2(h,X,_),p.memoizedState=E2,p=Ug(null,w));else if(Zc(p),lA(le)){if(X=le.nextSibling&&le.nextSibling.dataset,X)var Xe=X.dgst;X=Xe,w=Error(r(419)),w.stack="",w.digest=X,Ag({value:w,source:null,stack:null}),p=C2(h,p,_)}else if(Gr||Cf(h,p,_,!1),X=(_&h.childLanes)!==0,Gr||X){if(X=Jn,X!==null&&(w=Ei(X,_),w!==0&&w!==Ae.retryLane))throw Ae.retryLane=w,Nd(h,w),zs(X,h,w),w2;oA(le)||Gv(),p=C2(h,p,_)}else oA(le)?(p.flags|=192,p.child=h.child,p=null):(h=Ae.treeContext,ar=La(le.nextSibling),Hi=p,wn=!0,Gc=null,Oa=!1,h!==null&&JL(p,h),p=T2(p,w.children),p.flags|=4096);return p}return P?(Qc(),le=w.fallback,P=p.mode,Ae=h.child,Xe=Ae.sibling,w=Nl(Ae,{mode:"hidden",children:w.children}),w.subtreeFlags=Ae.subtreeFlags&65011712,Xe!==null?le=Nl(Xe,le):(le=kd(le,P,_,null),le.flags|=2),le.return=p,w.return=p,w.sibling=le,p.child=w,Ug(null,w),w=p.child,le=h.child.memoizedState,le===null?le=M2(_):(P=le.cachePool,P!==null?(Ae=$r._currentValue,P=P.parent!==Ae?{parent:Ae,pool:Ae}:P):P=sI(),le={baseLanes:le.baseLanes|_,cachePool:P}),w.memoizedState=le,w.childLanes=A2(h,X,_),p.memoizedState=E2,Ug(h.child,w)):(Zc(p),_=h.child,h=_.sibling,_=Nl(_,{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 T2(h,p){return p=Lv({mode:"visible",children:p},h.mode),p.return=h,h.child=p}function Lv(h,p){return h=ra(22,h,null,p),h.lanes=0,h}function C2(h,p,_){return Id(p,h.child,null,_),h=T2(p,p.pendingProps.children),h.flags|=2,p.memoizedState=null,h}function b4(h,p,_){h.lanes|=p;var w=h.alternate;w!==null&&(w.lanes|=p),$M(h.return,p,_)}function N2(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 v4(h,p,_){var w=p.pendingProps,P=w.revealOrder,O=w.tail;w=w.children;var X=Lr.current,le=(X&2)!==0;if(le?(X=X&1|2,p.flags|=128):X&=1,J(Lr,X),Vi(h,p,w,_),w=wn?Mg:0,!le&&h!==null&&(h.flags&128)!==0)e:for(h=p.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&b4(h,_,p);else if(h.tag===19)b4(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&&Ev(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=p.child,p.child=null):(P=_.sibling,_.sibling=null),N2(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&&Ev(h)===null){p.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}N2(p,!0,_,null,O,w);break;case"together":N2(p,!1,null,null,void 0,w);break;default:p.memoizedState=null}return p.child}function jl(h,p,_){if(h!==null&&(p.dependencies=h.dependencies),tu|=p.lanes,(_&p.childLanes)===0)if(h!==null){if(Cf(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,_=Nl(h,h.pendingProps),p.child=_,_.return=p;h.sibling!==null;)h=h.sibling,_=_.sibling=Nl(h,h.pendingProps),_.return=p;_.sibling=null}return p.child}function k2(h,p){return(h.lanes&p)!==0?!0:(h=h.dependencies,!!(h!==null&&gv(h)))}function yne(h,p,_){switch(p.tag){case 3:Ee(p,p.stateNode.containerInfo),qc(p,$r,h.memoizedState.cache),Pd();break;case 27:case 5:we(p);break;case 4:Ee(p,p.stateNode.containerInfo);break;case 10:qc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,t2(p),null;break;case 13:var w=p.memoizedState;if(w!==null)return w.dehydrated!==null?(Zc(p),p.flags|=128,null):(_&p.child.childLanes)!==0?x4(h,p,_):(Zc(p),h=jl(h,p,_),h!==null?h.sibling:null);Zc(p);break;case 19:var P=(h.flags&128)!==0;if(w=(_&p.childLanes)!==0,w||(Cf(h,p,_,!1),w=(_&p.childLanes)!==0),P){if(w)return v4(h,p,_);p.flags|=128}if(P=p.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),J(Lr,Lr.current),w)break;return null;case 22:return p.lanes=0,d4(h,p,_,p.pendingProps);case 24:qc(p,$r,h.memoizedState.cache)}return jl(h,p,_)}function y4(h,p,_){if(h!==null)if(h.memoizedProps!==p.pendingProps)Gr=!0;else{if(!k2(h,_)&&(p.flags&128)===0)return Gr=!1,yne(h,p,_);Gr=(h.flags&131072)!==0}else Gr=!1,wn&&(p.flags&1048576)!==0&&QL(p,Mg,p.index);switch(p.lanes=0,p.tag){case 16:e:{var w=p.pendingProps;if(h=jd(p.elementType),p.type=h,typeof h=="function")jM(h)?(w=Fd(h,w),p.tag=1,p=m4(null,p,h,w,_)):(p.tag=0,p=S2(null,p,h,w,_));else{if(h!=null){var P=h.$$typeof;if(P===A){p.tag=11,p=l4(null,p,h,w,_);break e}else if(P===N){p.tag=14,p=c4(null,p,h,w,_);break e}}throw p=R(h)||h,Error(r(306,p,""))}}return p;case 0:return S2(h,p,p.type,p.pendingProps,_);case 1:return w=p.type,P=Fd(w,p.pendingProps),m4(h,p,w,P,_);case 3:e:{if(Ee(p,p.stateNode.containerInfo),h===null)throw Error(r(387));w=p.pendingProps;var O=p.memoizedState;P=O.element,YM(h,p),Dg(p,w,null,_);var X=p.memoizedState;if(w=X.cache,qc(p,$r,w),w!==O.cache&&VM(p,[$r],_,!0),Rg(),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=g4(h,p,w,_);break e}else if(w!==P){P=Pa(Error(r(424)),p),Ag(P),p=g4(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=La(h.firstChild),Hi=p,wn=!0,Gc=null,Oa=!0,_=dI(p,null,w,_),p.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Pd(),w===P){p=jl(h,p,_);break e}Vi(h,p,w,_)}p=p.child}return p;case 26:return jv(h,p),h===null?(_=P5(p.type,null,p.pendingProps,null))?p.memoizedState=_:wn||(_=p.type,h=p.pendingProps,w=Qv(fe.current).createElement(_),w[br]=p,w[Or]=h,Gi(w,_,h),je(w),p.stateNode=w):p.memoizedState=P5(p.type,h.memoizedProps,p.pendingProps,h.memoizedState),null;case 27:return we(p),h===null&&wn&&(w=p.stateNode=C5(p.type,p.pendingProps,fe.current),Hi=p,Oa=!0,P=ar,au(p.type)?(cA=P,ar=La(w.firstChild)):ar=P),Vi(h,p,p.pendingProps.children,_),jv(h,p),h===null&&(p.flags|=4194304),p.child;case 5:return h===null&&wn&&((P=w=ar)&&(w=Yne(w,p.type,p.pendingProps,Oa),w!==null?(p.stateNode=w,Hi=p,ar=La(w.firstChild),Oa=!1,P=!0):P=!1),P||Wc(p)),we(p),P=p.type,O=p.pendingProps,X=h!==null?h.memoizedProps:null,w=O.children,iA(P,O)?w=null:X!==null&&iA(P,X)&&(p.flags|=32),p.memoizedState!==null&&(P=r2(h,p,dne,null,null,_),Jg._currentValue=P),jv(h,p),Vi(h,p,w,_),p.child;case 6:return h===null&&wn&&((h=_=ar)&&(_=Zne(_,p.pendingProps,Oa),_!==null?(p.stateNode=_,Hi=p,ar=null,h=!0):h=!1),h||Wc(p)),null;case 13:return x4(h,p,_);case 4:return Ee(p,p.stateNode.containerInfo),w=p.pendingProps,h===null?p.child=Id(p,null,w,_):Vi(h,p,w,_),p.child;case 11:return l4(h,p,p.type,p.pendingProps,_);case 7:return Vi(h,p,p.pendingProps,_),p.child;case 8:return Vi(h,p,p.pendingProps.children,_),p.child;case 12:return Vi(h,p,p.pendingProps.children,_),p.child;case 10:return w=p.pendingProps,qc(p,p.type,w.value),Vi(h,p,w.children,_),p.child;case 9:return P=p.type._context,w=p.pendingProps.children,Dd(p),P=$i(P),w=w(P),p.flags|=1,Vi(h,p,w,_),p.child;case 14:return c4(h,p,p.type,p.pendingProps,_);case 15:return u4(h,p,p.type,p.pendingProps,_);case 19:return v4(h,p,_);case 31:return vne(h,p,_);case 22:return d4(h,p,_,p.pendingProps);case 24:return Dd(p),w=$i($r),h===null?(P=qM(),P===null&&(P=Jn,O=GM(),P.pooledCache=O,O.refCount++,O!==null&&(P.pooledCacheLanes|=_),P=O),p.memoizedState={parent:w,cache:P},XM(p),qc(p,$r,P)):((h.lanes&_)!==0&&(YM(h,p),Dg(p,null,null,_),Rg()),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),qc(p,$r,w)):(w=O.cache,qc(p,$r,w),w!==P.cache&&VM(p,[$r],_,!0))),Vi(h,p,p.pendingProps.children,_),p.child;case 29:throw p.pendingProps}throw Error(r(156,p.tag))}function Ll(h){h.flags|=4}function P2(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(q4())h.flags|=8192;else throw Ld=yv,KM}else h.flags&=-16777217}function _4(h,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!L5(p))if(q4())h.flags|=8192;else throw Ld=yv,KM}function Iv(h,p){p!==null&&(h.flags|=4),h.flags&16384&&(p=h.tag!==22?xt():536870912,h.lanes|=p,zf|=p)}function Fg(h,p){if(!wn)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 _ne(h,p,_){var w=p.pendingProps;switch(FM(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),Rl($r),re(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Tf(p)?Ll(p):h===null||h.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,BM())),or(p),null;case 26:var P=p.type,O=p.memoizedState;return h===null?(Ll(p),O!==null?(or(p),_4(p,O)):(or(p),P2(p,P,null,w,_))):O?O!==h.memoizedState?(Ll(p),or(p),_4(p,O)):(or(p),p.flags&=-16777217):(h=h.memoizedProps,h!==w&&Ll(p),or(p),P2(p,P,h,w,_)),null;case 27:if(Oe(p),_=fe.current,P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}h=se.current,Tf(p)?eI(p):(h=C5(P,w,_),p.stateNode=h,Ll(p))}return or(p),null;case 5:if(Oe(p),P=p.type,h!==null&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(!w){if(p.stateNode===null)throw Error(r(166));return or(p),null}if(O=se.current,Tf(p))eI(p);else{var X=Qv(fe.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[Or]=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(Gi(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&&Ll(p)}}return or(p),P2(p,p.type,h===null?null:h.memoizedProps,p.pendingProps,_),null;case 6:if(h&&p.stateNode!=null)h.memoizedProps!==w&&Ll(p);else{if(typeof w!="string"&&p.stateNode===null)throw Error(r(166));if(h=fe.current,Tf(p)){if(h=p.stateNode,_=p.memoizedProps,w=null,P=Hi,P!==null)switch(P.tag){case 27:case 5:w=P.memoizedProps}h[br]=p,h=!!(h.nodeValue===_||w!==null&&w.suppressHydrationWarning===!0||x5(h.nodeValue,_)),h||Wc(p,!0)}else h=Qv(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=Tf(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 Pd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),h=!1}else _=BM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return p.flags&256?(sa(p),p):(sa(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=Tf(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 Pd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;or(p),P=!1}else P=BM(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return p.flags&256?(sa(p),p):(sa(p),null)}return sa(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),Iv(p,p.updateQueue),or(p),null);case 4:return re(),h===null&&J2(p.stateNode.containerInfo),or(p),null;case 10:return Rl(p.type),or(p),null;case 19:if(z(Lr),w=p.memoizedState,w===null)return or(p),null;if(P=(p.flags&128)!==0,O=w.rendering,O===null)if(P)Fg(w,!1);else{if(Cr!==0||h!==null&&(h.flags&128)!==0)for(h=p.child;h!==null;){if(O=Ev(h),O!==null){for(p.flags|=128,Fg(w,!1),h=O.updateQueue,p.updateQueue=h,Iv(p,h),p.subtreeFlags=0,h=_,_=p.child;_!==null;)XL(_,h),_=_.sibling;return J(Lr,Lr.current&1|2),wn&&kl(p,w.treeForkCount),p.child}h=h.sibling}w.tail!==null&&L()>Hv&&(p.flags|=128,P=!0,Fg(w,!1),p.lanes=4194304)}else{if(!P)if(h=Ev(O),h!==null){if(p.flags|=128,P=!0,h=h.updateQueue,p.updateQueue=h,Iv(p,h),Fg(w,!0),w.tail===null&&w.tailMode==="hidden"&&!O.alternate&&!wn)return or(p),null}else 2*L()-w.renderingStartTime>Hv&&_!==536870912&&(p.flags|=128,P=!0,Fg(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,_=Lr.current,J(Lr,P?_&1|2:_&1),wn&&kl(p,w.treeForkCount),h):(or(p),null);case 22:case 23:return sa(p),e2(),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&&Iv(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(Od),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),p.memoizedState.cache!==_&&(p.flags|=2048),Rl($r),or(p),null;case 25:return null;case 30:return null}throw Error(r(156,p.tag))}function wne(h,p){switch(FM(p),p.tag){case 1:return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 3:return Rl($r),re(),h=p.flags,(h&65536)!==0&&(h&128)===0?(p.flags=h&-65537|128,p):null;case 26:case 27:case 5:return Oe(p),null;case 31:if(p.memoizedState!==null){if(sa(p),p.alternate===null)throw Error(r(340));Pd()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 13:if(sa(p),h=p.memoizedState,h!==null&&h.dehydrated!==null){if(p.alternate===null)throw Error(r(340));Pd()}return h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 19:return z(Lr),null;case 4:return re(),null;case 10:return Rl(p.type),null;case 22:case 23:return sa(p),e2(),h!==null&&z(Od),h=p.flags,h&65536?(p.flags=h&-65537|128,p):null;case 24:return Rl($r),null;case 25:return null;default:return null}}function w4(h,p){switch(FM(p),p.tag){case 3:Rl($r),re();break;case 26:case 27:case 5:Oe(p);break;case 4:re();break;case 31:p.memoizedState!==null&&sa(p);break;case 13:sa(p);break;case 19:z(Lr);break;case 10:Rl(p.type);break;case 22:case 23:sa(p),e2(),h!==null&&z(Od);break;case 24:Rl($r)}}function zg(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(le){Un(p,p.return,le)}}function Jc(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,le=X.destroy;if(le!==void 0){X.destroy=void 0,P=p;var Ae=_,Xe=le;try{Xe()}catch(lt){Un(P,Ae,lt)}}}w=w.next}while(w!==O)}}catch(lt){Un(p,p.return,lt)}}function S4(h){var p=h.updateQueue;if(p!==null){var _=h.stateNode;try{fI(p,_)}catch(w){Un(h,h.return,w)}}}function E4(h,p,_){_.props=Fd(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(w){Un(h,p,w)}}function Bg(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){Un(h,p,P)}}function qo(h,p){var _=h.ref,w=h.refCleanup;if(_!==null)if(typeof w=="function")try{w()}catch(P){Un(h,p,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Un(h,p,P)}else _.current=null}function M4(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){Un(h,h.return,P)}}function R2(h,p,_){try{var w=h.stateNode;Vne(w,h.type,_,p),w[Or]=p}catch(P){Un(h,h.return,P)}}function A4(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&au(h.type)||h.tag===4}function D2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||A4(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&&au(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 O2(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=Tl));else if(w!==4&&(w===27&&au(h.type)&&(_=h.stateNode,p=null),h=h.child,h!==null))for(O2(h,p,_),h=h.sibling;h!==null;)O2(h,p,_),h=h.sibling}function Uv(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&&au(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Uv(h,p,_),h=h.sibling;h!==null;)Uv(h,p,_),h=h.sibling}function T4(h){var p=h.stateNode,_=h.memoizedProps;try{for(var w=h.type,P=p.attributes;P.length;)p.removeAttributeNode(P[0]);Gi(p,w,_),p[br]=h,p[Or]=_}catch(O){Un(h,h.return,O)}}var Il=!1,Wr=!1,j2=!1,C4=typeof WeakSet=="function"?WeakSet:Set,Ci=null;function Sne(h,p){if(h=h.containerInfo,nA=sy,h=zL(h),CM(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,le=-1,Ae=-1,Xe=0,lt=0,dt=h,Ze=null;t:for(;;){for(var st;dt!==_||P!==0&&dt.nodeType!==3||(le=X+P),dt!==O||w!==0&&dt.nodeType!==3||(Ae=X+w),dt.nodeType===3&&(X+=dt.nodeValue.length),(st=dt.firstChild)!==null;)Ze=dt,dt=st;for(;;){if(dt===h)break t;if(Ze===_&&++Xe===P&&(le=X),Ze===O&&++lt===w&&(Ae=X),(st=dt.nextSibling)!==null)break;dt=Ze,Ze=dt.parentNode}dt=st}_=le===-1||Ae===-1?null:{start:le,end:Ae}}else _=null}_=_||{start:0,end:0}}else _=null;for(rA={focusedElem:h,selectionRange:_},sy=!1,Ci=p;Ci!==null;)if(p=Ci,h=p.child,(p.subtreeFlags&1028)!==0&&h!==null)h.return=p,Ci=h;else for(;Ci!==null;){switch(p=Ci,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 Ot=Fd(_.type,P);h=w.getSnapshotBeforeUpdate(Ot,O),w.__reactInternalSnapshotBeforeUpdate=h}catch(Gt){Un(_,_.return,Gt)}}break;case 3:if((h&1024)!==0){if(h=p.stateNode.containerInfo,_=h.nodeType,_===9)aA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":aA(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,Ci=h;break}Ci=p.return}}function N4(h,p,_){var w=_.flags;switch(_.tag){case 0:case 11:case 15:Fl(h,_),w&4&&zg(5,_);break;case 1:if(Fl(h,_),w&4)if(h=_.stateNode,p===null)try{h.componentDidMount()}catch(X){Un(_,_.return,X)}else{var P=Fd(_.type,p.memoizedProps);p=p.memoizedState;try{h.componentDidUpdate(P,p,h.__reactInternalSnapshotBeforeUpdate)}catch(X){Un(_,_.return,X)}}w&64&&S4(_),w&512&&Bg(_,_.return);break;case 3:if(Fl(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{fI(h,p)}catch(X){Un(_,_.return,X)}}break;case 27:p===null&&w&4&&T4(_);case 26:case 5:Fl(h,_),p===null&&w&4&&M4(_),w&512&&Bg(_,_.return);break;case 12:Fl(h,_);break;case 31:Fl(h,_),w&4&&R4(h,_);break;case 13:Fl(h,_),w&4&&D4(h,_),w&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Rne.bind(null,_),Qne(h,_))));break;case 22:if(w=_.memoizedState!==null||Il,!w){p=p!==null&&p.memoizedState!==null||Wr,P=Il;var O=Wr;Il=w,(Wr=p)&&!O?zl(h,_,(_.subtreeFlags&8772)!==0):Fl(h,_),Il=P,Wr=O}break;case 30:break;default:Fl(h,_)}}function k4(h){var p=h.alternate;p!==null&&(h.alternate=null,k4(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,Ls=!1;function Ul(h,p,_){for(_=_.child;_!==null;)P4(h,p,_),_=_.sibling}function P4(h,p,_){if(ae&&typeof ae.onCommitFiberUnmount=="function")try{ae.onCommitFiberUnmount(Ue,_)}catch{}switch(_.tag){case 26:Wr||qo(_,p),Ul(h,p,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:Wr||qo(_,p);var w=hr,P=Ls;au(_.type)&&(hr=_.stateNode,Ls=!1),Ul(h,p,_),Yg(_.stateNode),hr=w,Ls=P;break;case 5:Wr||qo(_,p);case 6:if(w=hr,P=Ls,hr=null,Ul(h,p,_),hr=w,Ls=P,hr!==null)if(Ls)try{(hr.nodeType===9?hr.body:hr.nodeName==="HTML"?hr.ownerDocument.body:hr).removeChild(_.stateNode)}catch(O){Un(_,p,O)}else try{hr.removeChild(_.stateNode)}catch(O){Un(_,p,O)}break;case 18:hr!==null&&(Ls?(h=hr,S5(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Kf(h)):S5(hr,_.stateNode));break;case 4:w=hr,P=Ls,hr=_.stateNode.containerInfo,Ls=!0,Ul(h,p,_),hr=w,Ls=P;break;case 0:case 11:case 14:case 15:Jc(2,_,p),Wr||Jc(4,_,p),Ul(h,p,_);break;case 1:Wr||(qo(_,p),w=_.stateNode,typeof w.componentWillUnmount=="function"&&E4(_,p,w)),Ul(h,p,_);break;case 21:Ul(h,p,_);break;case 22:Wr=(w=Wr)||_.memoizedState!==null,Ul(h,p,_),Wr=w;break;default:Ul(h,p,_)}}function R4(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Kf(h)}catch(_){Un(p,p.return,_)}}}function D4(h,p){if(p.memoizedState===null&&(h=p.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Kf(h)}catch(_){Un(p,p.return,_)}}function Ene(h){switch(h.tag){case 31:case 13:case 19:var p=h.stateNode;return p===null&&(p=h.stateNode=new C4),p;case 22:return h=h.stateNode,p=h._retryCache,p===null&&(p=h._retryCache=new C4),p;default:throw Error(r(435,h.tag))}}function Fv(h,p){var _=Ene(h);p.forEach(function(w){if(!_.has(w)){_.add(w);var P=Dne.bind(null,h,w);w.then(P,P)}})}function Is(h,p){var _=p.deletions;if(_!==null)for(var w=0;w<_.length;w++){var P=_[w],O=h,X=p,le=X;e:for(;le!==null;){switch(le.tag){case 27:if(au(le.type)){hr=le.stateNode,Ls=!1;break e}break;case 5:hr=le.stateNode,Ls=!1;break e;case 3:case 4:hr=le.stateNode.containerInfo,Ls=!0;break e}le=le.return}if(hr===null)throw Error(r(160));P4(O,X,P),hr=null,Ls=!1,O=P.alternate,O!==null&&(O.return=null),P.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)O4(p,h),p=p.sibling}var bo=null;function O4(h,p){var _=h.alternate,w=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Is(p,h),Us(h),w&4&&(Jc(3,h,h.return),zg(3,h),Jc(5,h,h.return));break;case 1:Is(p,h),Us(h),w&512&&(Wr||_===null||qo(_,_.return)),w&64&&Il&&(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=bo;if(Is(p,h),Us(h),w&512&&(Wr||_===null||qo(_,_.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[it]||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"))),Gi(O,w,_),O[br]=h,je(O),w=O;break e;case"link":var X=O5("link","href",P).get(w+(_.href||""));if(X){for(var le=0;le<X.length;le++)if(O=X[le],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(le,1);break t}}O=P.createElement(w),Gi(O,w,_),P.head.appendChild(O);break;case"meta":if(X=O5("meta","content",P).get(w+(_.content||""))){for(le=0;le<X.length;le++)if(O=X[le],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(le,1);break t}}O=P.createElement(w),Gi(O,w,_),P.head.appendChild(O);break;default:throw Error(r(468,w))}O[br]=h,je(O),w=O}h.stateNode=w}else j5(P,h.type,h.stateNode);else h.stateNode=D5(P,w,h.memoizedProps);else O!==w?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,w===null?j5(P,h.type,h.stateNode):D5(P,w,h.memoizedProps)):w===null&&h.stateNode!==null&&R2(h,h.memoizedProps,_.memoizedProps)}break;case 27:Is(p,h),Us(h),w&512&&(Wr||_===null||qo(_,_.return)),_!==null&&w&4&&R2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Is(p,h),Us(h),w&512&&(Wr||_===null||qo(_,_.return)),h.flags&32){P=h.stateNode;try{Vo(P,"")}catch(Ot){Un(h,h.return,Ot)}}w&4&&h.stateNode!=null&&(P=h.memoizedProps,R2(h,P,_!==null?_.memoizedProps:P)),w&1024&&(j2=!0);break;case 6:if(Is(p,h),Us(h),w&4){if(h.stateNode===null)throw Error(r(162));w=h.memoizedProps,_=h.stateNode;try{_.nodeValue=w}catch(Ot){Un(h,h.return,Ot)}}break;case 3:if(ty=null,P=bo,bo=Jv(p.containerInfo),Is(p,h),bo=P,Us(h),w&4&&_!==null&&_.memoizedState.isDehydrated)try{Kf(p.containerInfo)}catch(Ot){Un(h,h.return,Ot)}j2&&(j2=!1,j4(h));break;case 4:w=bo,bo=Jv(h.stateNode.containerInfo),Is(p,h),Us(h),bo=w;break;case 12:Is(p,h),Us(h);break;case 31:Is(p,h),Us(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Fv(h,w)));break;case 13:Is(p,h),Us(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(Bv=L()),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Fv(h,w)));break;case 22:P=h.memoizedState!==null;var Ae=_!==null&&_.memoizedState!==null,Xe=Il,lt=Wr;if(Il=Xe||P,Wr=lt||Ae,Is(p,h),Wr=lt,Il=Xe,Us(h),w&8192)e:for(p=h.stateNode,p._visibility=P?p._visibility&-2:p._visibility|1,P&&(_===null||Ae||Il||Wr||zd(h)),_=null,p=h;;){if(p.tag===5||p.tag===26){if(_===null){Ae=_=p;try{if(O=Ae.stateNode,P)X=O.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{le=Ae.stateNode;var dt=Ae.memoizedProps.style,Ze=dt!=null&&dt.hasOwnProperty("display")?dt.display:null;le.style.display=Ze==null||typeof Ze=="boolean"?"":(""+Ze).trim()}}catch(Ot){Un(Ae,Ae.return,Ot)}}}else if(p.tag===6){if(_===null){Ae=p;try{Ae.stateNode.nodeValue=P?"":Ae.memoizedProps}catch(Ot){Un(Ae,Ae.return,Ot)}}}else if(p.tag===18){if(_===null){Ae=p;try{var st=Ae.stateNode;P?E5(st,!0):E5(Ae.stateNode,!1)}catch(Ot){Un(Ae,Ae.return,Ot)}}}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,Fv(h,_))));break;case 19:Is(p,h),Us(h),w&4&&(w=h.updateQueue,w!==null&&(h.updateQueue=null,Fv(h,w)));break;case 30:break;case 21:break;default:Is(p,h),Us(h)}}function Us(h){var p=h.flags;if(p&2){try{for(var _,w=h.return;w!==null;){if(A4(w)){_=w;break}w=w.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,O=D2(h);Uv(h,O,P);break;case 5:var X=_.stateNode;_.flags&32&&(Vo(X,""),_.flags&=-33);var le=D2(h);Uv(h,le,X);break;case 3:case 4:var Ae=_.stateNode.containerInfo,Xe=D2(h);O2(h,Xe,Ae);break;default:throw Error(r(161))}}catch(lt){Un(h,h.return,lt)}h.flags&=-3}p&4096&&(h.flags&=-4097)}function j4(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var p=h;j4(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),h=h.sibling}}function Fl(h,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)N4(h,p.alternate,p),p=p.sibling}function zd(h){for(h=h.child;h!==null;){var p=h;switch(p.tag){case 0:case 11:case 14:case 15:Jc(4,p,p.return),zd(p);break;case 1:qo(p,p.return);var _=p.stateNode;typeof _.componentWillUnmount=="function"&&E4(p,p.return,_),zd(p);break;case 27:Yg(p.stateNode);case 26:case 5:qo(p,p.return),zd(p);break;case 22:p.memoizedState===null&&zd(p);break;case 30:zd(p);break;default:zd(p)}h=h.sibling}}function zl(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:zl(P,O,_),zg(4,O);break;case 1:if(zl(P,O,_),w=O,P=w.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(Xe){Un(w,w.return,Xe)}if(w=O,P=w.updateQueue,P!==null){var le=w.stateNode;try{var Ae=P.shared.hiddenCallbacks;if(Ae!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ae.length;P++)hI(Ae[P],le)}catch(Xe){Un(w,w.return,Xe)}}_&&X&64&&S4(O),Bg(O,O.return);break;case 27:T4(O);case 26:case 5:zl(P,O,_),_&&w===null&&X&4&&M4(O),Bg(O,O.return);break;case 12:zl(P,O,_);break;case 31:zl(P,O,_),_&&X&4&&R4(P,O);break;case 13:zl(P,O,_),_&&X&4&&D4(P,O);break;case 22:O.memoizedState===null&&zl(P,O,_),Bg(O,O.return);break;case 30:break;default:zl(P,O,_)}p=p.sibling}}function L2(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&&Tg(_))}function I2(h,p){h=null,p.alternate!==null&&(h=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==h&&(p.refCount++,h!=null&&Tg(h))}function vo(h,p,_,w){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)L4(h,p,_,w),p=p.sibling}function L4(h,p,_,w){var P=p.flags;switch(p.tag){case 0:case 11:case 15:vo(h,p,_,w),P&2048&&zg(9,p);break;case 1:vo(h,p,_,w);break;case 3:vo(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&&Tg(h)));break;case 12:if(P&2048){vo(h,p,_,w),h=p.stateNode;try{var O=p.memoizedProps,X=O.id,le=O.onPostCommit;typeof le=="function"&&le(X,p.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ae){Un(p,p.return,Ae)}}else vo(h,p,_,w);break;case 31:vo(h,p,_,w);break;case 13:vo(h,p,_,w);break;case 23:break;case 22:O=p.stateNode,X=p.alternate,p.memoizedState!==null?O._visibility&2?vo(h,p,_,w):Hg(h,p):O._visibility&2?vo(h,p,_,w):(O._visibility|=2,If(h,p,_,w,(p.subtreeFlags&10256)!==0||!1)),P&2048&&L2(X,p);break;case 24:vo(h,p,_,w),P&2048&&I2(p.alternate,p);break;default:vo(h,p,_,w)}}function If(h,p,_,w,P){for(P=P&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=h,X=p,le=_,Ae=w,Xe=X.flags;switch(X.tag){case 0:case 11:case 15:If(O,X,le,Ae,P),zg(8,X);break;case 23:break;case 22:var lt=X.stateNode;X.memoizedState!==null?lt._visibility&2?If(O,X,le,Ae,P):Hg(O,X):(lt._visibility|=2,If(O,X,le,Ae,P)),P&&Xe&2048&&L2(X.alternate,X);break;case 24:If(O,X,le,Ae,P),P&&Xe&2048&&I2(X.alternate,X);break;default:If(O,X,le,Ae,P)}p=p.sibling}}function Hg(h,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var _=h,w=p,P=w.flags;switch(w.tag){case 22:Hg(_,w),P&2048&&L2(w.alternate,w);break;case 24:Hg(_,w),P&2048&&I2(w.alternate,w);break;default:Hg(_,w)}p=p.sibling}}var $g=8192;function Uf(h,p,_){if(h.subtreeFlags&$g)for(h=h.child;h!==null;)I4(h,p,_),h=h.sibling}function I4(h,p,_){switch(h.tag){case 26:Uf(h,p,_),h.flags&$g&&h.memoizedState!==null&&ure(_,bo,h.memoizedState,h.memoizedProps);break;case 5:Uf(h,p,_);break;case 3:case 4:var w=bo;bo=Jv(h.stateNode.containerInfo),Uf(h,p,_),bo=w;break;case 22:h.memoizedState===null&&(w=h.alternate,w!==null&&w.memoizedState!==null?(w=$g,$g=16777216,Uf(h,p,_),$g=w):Uf(h,p,_));break;default:Uf(h,p,_)}}function U4(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 Vg(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ci=w,z4(w,h)}U4(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)F4(h),h=h.sibling}function F4(h){switch(h.tag){case 0:case 11:case 15:Vg(h),h.flags&2048&&Jc(9,h,h.return);break;case 3:Vg(h);break;case 12:Vg(h);break;case 22:var p=h.stateNode;h.memoizedState!==null&&p._visibility&2&&(h.return===null||h.return.tag!==13)?(p._visibility&=-3,zv(h)):Vg(h);break;default:Vg(h)}}function zv(h){var p=h.deletions;if((h.flags&16)!==0){if(p!==null)for(var _=0;_<p.length;_++){var w=p[_];Ci=w,z4(w,h)}U4(h)}for(h=h.child;h!==null;){switch(p=h,p.tag){case 0:case 11:case 15:Jc(8,p,p.return),zv(p);break;case 22:_=p.stateNode,_._visibility&2&&(_._visibility&=-3,zv(p));break;default:zv(p)}h=h.sibling}}function z4(h,p){for(;Ci!==null;){var _=Ci;switch(_.tag){case 0:case 11:case 15:Jc(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:Tg(_.memoizedState.cache)}if(w=_.child,w!==null)w.return=_,Ci=w;else e:for(_=h;Ci!==null;){w=Ci;var P=w.sibling,O=w.return;if(k4(w),w===_){Ci=null;break e}if(P!==null){P.return=O,Ci=P;break e}Ci=O}}}var Mne={getCacheForType:function(h){var p=$i($r),_=p.data.get(h);return _===void 0&&(_=h(),p.data.set(h,_)),_},cacheSignal:function(){return $i($r).controller.signal}},Ane=typeof WeakMap=="function"?WeakMap:Map,kn=0,Jn=null,pn=null,vn=0,In=0,aa=null,eu=!1,Ff=!1,U2=!1,Bl=0,Cr=0,tu=0,Bd=0,F2=0,oa=0,zf=0,Gg=null,Fs=null,z2=!1,Bv=0,B4=0,Hv=1/0,$v=null,nu=null,li=0,ru=null,Bf=null,Hl=0,B2=0,H2=null,H4=null,Wg=0,$2=null;function la(){return(kn&2)!==0&&vn!==0?vn&-vn:K.T!==null?X2():zi()}function $4(){if(oa===0)if((vn&536870912)===0||wn){var h=ge;ge<<=1,(ge&3932160)===0&&(ge=262144),oa=h}else oa=536870912;return h=ia.current,h!==null&&(h.flags|=32),oa}function zs(h,p,_){(h===Jn&&(In===2||In===9)||h.cancelPendingCommit!==null)&&(Hf(h,0),iu(h,vn,oa,!1)),Qt(h,_),((kn&2)===0||h!==Jn)&&(h===Jn&&((kn&2)===0&&(Bd|=_),Cr===4&&iu(h,vn,oa,!1)),Ko(h))}function V4(h,p,_){if((kn&6)!==0)throw Error(r(327));var w=!_&&(p&127)===0&&(p&h.expiredLanes)===0||ce(h,p),P=w?Nne(h,p):G2(h,p,!0),O=w;do{if(P===0){Ff&&!w&&iu(h,p,0,!1);break}else{if(_=h.current.alternate,O&&!Tne(_)){P=G2(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 le=h;P=Gg;var Ae=le.current.memoizedState.isDehydrated;if(Ae&&(Hf(le,X).flags|=256),X=G2(le,X,!1),X!==2){if(U2&&!Ae){le.errorRecoveryDisabledLanes|=O,Bd|=O,P=4;break e}O=Fs,Fs=P,O!==null&&(Fs===null?Fs=O:Fs.push.apply(Fs,O))}P=X}if(O=!1,P!==2)continue}}if(P===1){Hf(h,0),iu(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:iu(w,p,oa,!eu);break e;case 2:Fs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((p&62914560)===p&&(P=Bv+300-L(),10<P)){if(iu(w,p,oa,!eu),ye(w,0,!0)!==0)break e;Hl=p,w.timeoutHandle=_5(G4.bind(null,w,_,Fs,$v,z2,p,oa,Bd,zf,eu,O,"Throttled",-0,0),P);break e}G4(w,_,Fs,$v,z2,p,oa,Bd,zf,eu,O,null,-0,0)}}break}while(!0);Ko(h)}function G4(h,p,_,w,P,O,X,le,Ae,Xe,lt,dt,Ze,st){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:Tl},I4(p,O,dt);var Ot=(O&62914560)===O?Bv-L():(O&4194048)===O?B4-L():0;if(Ot=dre(dt,Ot),Ot!==null){Hl=O,h.cancelPendingCommit=Ot(J4.bind(null,h,p,O,_,w,P,X,le,Ae,lt,dt,null,Ze,st)),iu(h,O,X,!Xe);return}}J4(h,p,O,_,w,P,X,le,Ae)}function Tne(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(!na(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 iu(h,p,_,w){p&=~F2,p&=~Bd,h.suspendedLanes|=p,h.pingedLanes&=~p,w&&(h.warmLanes|=p),w=h.expirationTimes;for(var P=p;0<P;){var O=31-He(P),X=1<<O;w[O]=-1,P&=~X}_!==0&&Vt(h,_,p)}function Vv(){return(kn&6)===0?(qg(0),!1):!0}function V2(){if(pn!==null){if(In===0)var h=pn.return;else h=pn,Pl=Rd=null,a2(h),Rf=null,Ng=0,h=pn;for(;h!==null;)w4(h.alternate,h),h=h.return;pn=null}}function Hf(h,p){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,qne(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Hl=0,V2(),Jn=h,pn=_=Nl(h.current,null),vn=p,In=0,aa=null,eu=!1,Ff=ce(h,p),U2=!1,zf=oa=F2=Bd=tu=Cr=0,Fs=Gg=null,z2=!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-He(w),O=1<<P;p|=h[P],w&=~O}return Bl=p,dv(),_}function W4(h,p){nn=null,K.H=Ig,p===Pf||p===vv?(p=lI(),In=3):p===KM?(p=lI(),In=4):In=p===w2?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,aa=p,pn===null&&(Cr=1,Dv(h,Pa(p,h.current)))}function q4(){var h=ia.current;return h===null?!0:(vn&4194048)===vn?ja===null:(vn&62914560)===vn||(vn&536870912)!==0?h===ja:!1}function K4(){var h=K.H;return K.H=Ig,h===null?Ig:h}function X4(){var h=K.A;return K.A=Mne,h}function Gv(){Cr=4,eu||(vn&4194048)!==vn&&ia.current!==null||(Ff=!0),(tu&134217727)===0&&(Bd&134217727)===0||Jn===null||iu(Jn,vn,oa,!1)}function G2(h,p,_){var w=kn;kn|=2;var P=K4(),O=X4();(Jn!==h||vn!==p)&&($v=null,Hf(h,p)),p=!1;var X=Cr;e:do try{if(In!==0&&pn!==null){var le=pn,Ae=aa;switch(In){case 8:V2(),X=6;break e;case 3:case 2:case 9:case 6:ia.current===null&&(p=!0);var Xe=In;if(In=0,aa=null,$f(h,le,Ae,Xe),_&&Ff){X=0;break e}break;default:Xe=In,In=0,aa=null,$f(h,le,Ae,Xe)}}Cne(),X=Cr;break}catch(lt){W4(h,lt)}while(!0);return p&&h.shellSuspendCounter++,Pl=Rd=null,kn=w,K.H=P,K.A=O,pn===null&&(Jn=null,vn=0,dv()),X}function Cne(){for(;pn!==null;)Y4(pn)}function Nne(h,p){var _=kn;kn|=2;var w=K4(),P=X4();Jn!==h||vn!==p?($v=null,Hv=L()+500,Hf(h,p)):Ff=ce(h,p);e:do try{if(In!==0&&pn!==null){p=pn;var O=aa;t:switch(In){case 1:In=0,aa=null,$f(h,p,O,1);break;case 2:case 9:if(aI(O)){In=0,aa=null,Z4(p);break}p=function(){In!==2&&In!==9||Jn!==h||(In=7),Ko(h)},O.then(p,p);break e;case 3:In=7;break e;case 4:In=5;break e;case 7:aI(O)?(In=0,aa=null,Z4(p)):(In=0,aa=null,$f(h,p,O,7));break;case 5:var X=null;switch(pn.tag){case 26:X=pn.memoizedState;case 5:case 27:var le=pn;if(X?L5(X):le.stateNode.complete){In=0,aa=null;var Ae=le.sibling;if(Ae!==null)pn=Ae;else{var Xe=le.return;Xe!==null?(pn=Xe,Wv(Xe)):pn=null}break t}}In=0,aa=null,$f(h,p,O,5);break;case 6:In=0,aa=null,$f(h,p,O,6);break;case 8:V2(),Cr=6;break e;default:throw Error(r(462))}}kne();break}catch(lt){W4(h,lt)}while(!0);return Pl=Rd=null,K.H=w,K.A=P,kn=_,pn!==null?0:(Jn=null,vn=0,dv(),Cr)}function kne(){for(;pn!==null&&!Se();)Y4(pn)}function Y4(h){var p=y4(h.alternate,h,Bl);h.memoizedProps=h.pendingProps,p===null?Wv(h):pn=p}function Z4(h){var p=h,_=p.alternate;switch(p.tag){case 15:case 0:p=p4(_,p,p.pendingProps,p.type,void 0,vn);break;case 11:p=p4(_,p,p.pendingProps,p.type.render,p.ref,vn);break;case 5:a2(p);default:w4(_,p),p=pn=XL(p,Bl),p=y4(_,p,Bl)}h.memoizedProps=h.pendingProps,p===null?Wv(h):pn=p}function $f(h,p,_,w){Pl=Rd=null,a2(p),Rf=null,Ng=0;var P=p.return;try{if(bne(h,P,p,_,vn)){Cr=1,Dv(h,Pa(_,h.current)),pn=null;return}}catch(O){if(P!==null)throw pn=P,O;Cr=1,Dv(h,Pa(_,h.current)),pn=null;return}p.flags&32768?(wn||w===1?h=!0:Ff||(vn&536870912)!==0?h=!1:(eu=h=!0,(w===2||w===9||w===3||w===6)&&(w=ia.current,w!==null&&w.tag===13&&(w.flags|=16384))),Q4(p,h)):Wv(p)}function Wv(h){var p=h;do{if((p.flags&32768)!==0){Q4(p,eu);return}h=p.return;var _=_ne(p.alternate,p,Bl);if(_!==null){pn=_;return}if(p=p.sibling,p!==null){pn=p;return}pn=p=h}while(p!==null);Cr===0&&(Cr=5)}function Q4(h,p){do{var _=wne(h.alternate,h);if(_!==null){_.flags&=32767,pn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!p&&(h=h.sibling,h!==null)){pn=h;return}pn=h=_}while(h!==null);Cr=6,pn=null}function J4(h,p,_,w,P,O,X,le,Ae){h.cancelPendingCommit=null;do qv();while(li!==0);if((kn&6)!==0)throw Error(r(327));if(p!==null){if(p===h.current)throw Error(r(177));if(O=p.lanes|p.childLanes,O|=DM,jt(h,_,O,X,le,Ae),h===Jn&&(pn=Jn=null,vn=0),Bf=p,ru=h,Hl=_,B2=O,H2=P,H4=w,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,One(be,function(){return i5(),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=kn,kn|=4;try{Sne(h,p,_)}finally{kn=X,V.p=P,K.T=w}}li=1,e5(),t5(),n5()}}function e5(){if(li===1){li=0;var h=ru,p=Bf,_=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var w=V.p;V.p=2;var P=kn;kn|=4;try{O4(p,h);var O=rA,X=zL(h.containerInfo),le=O.focusedElem,Ae=O.selectionRange;if(X!==le&&le&&le.ownerDocument&&FL(le.ownerDocument.documentElement,le)){if(Ae!==null&&CM(le)){var Xe=Ae.start,lt=Ae.end;if(lt===void 0&&(lt=Xe),"selectionStart"in le)le.selectionStart=Xe,le.selectionEnd=Math.min(lt,le.value.length);else{var dt=le.ownerDocument||document,Ze=dt&&dt.defaultView||window;if(Ze.getSelection){var st=Ze.getSelection(),Ot=le.textContent.length,Gt=Math.min(Ae.start,Ot),Gn=Ae.end===void 0?Gt:Math.min(Ae.end,Ot);!st.extend&&Gt>Gn&&(X=Gn,Gn=Gt,Gt=X);var ze=UL(le,Gt),Re=UL(le,Gn);if(ze&&Re&&(st.rangeCount!==1||st.anchorNode!==ze.node||st.anchorOffset!==ze.offset||st.focusNode!==Re.node||st.focusOffset!==Re.offset)){var We=dt.createRange();We.setStart(ze.node,ze.offset),st.removeAllRanges(),Gt>Gn?(st.addRange(We),st.extend(Re.node,Re.offset)):(We.setEnd(Re.node,Re.offset),st.addRange(We))}}}}for(dt=[],st=le;st=st.parentNode;)st.nodeType===1&&dt.push({element:st,left:st.scrollLeft,top:st.scrollTop});for(typeof le.focus=="function"&&le.focus(),le=0;le<dt.length;le++){var ut=dt[le];ut.element.scrollLeft=ut.left,ut.element.scrollTop=ut.top}}sy=!!nA,rA=nA=null}finally{kn=P,V.p=w,K.T=_}}h.current=p,li=2}}function t5(){if(li===2){li=0;var h=ru,p=Bf,_=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var w=V.p;V.p=2;var P=kn;kn|=4;try{N4(h,p.alternate,p)}finally{kn=P,V.p=w,K.T=_}}li=3}}function n5(){if(li===4||li===3){li=0,B();var h=ru,p=Bf,_=Hl,w=H4;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?li=5:(li=0,Bf=ru=null,r5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(nu=null),Mi(_),p=p.stateNode,ae&&typeof ae.onCommitFiberRoot=="function")try{ae.onCommitFiberRoot(Ue,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 le=w[X];O(le.value,{componentStack:le.stack})}}finally{K.T=p,V.p=P}}(Hl&3)!==0&&qv(),Ko(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===$2?Wg++:(Wg=0,$2=h):Wg=0,qg(0)}}function r5(h,p){(h.pooledCacheLanes&=p)===0&&(p=h.pooledCache,p!=null&&(h.pooledCache=null,Tg(p)))}function qv(){return e5(),t5(),n5(),i5()}function i5(){if(li!==5)return!1;var h=ru,p=B2;B2=0;var _=Mi(Hl),w=K.T,P=V.p;try{V.p=32>_?32:_,K.T=null,_=H2,H2=null;var O=ru,X=Hl;if(li=0,Bf=ru=null,Hl=0,(kn&6)!==0)throw Error(r(331));var le=kn;if(kn|=4,F4(O.current),L4(O,O.current,X,_),kn=le,qg(0,!1),ae&&typeof ae.onPostCommitFiberRoot=="function")try{ae.onPostCommitFiberRoot(Ue,O)}catch{}return!0}finally{V.p=P,K.T=w,r5(h,p)}}function s5(h,p,_){p=Pa(_,p),p=_2(h.stateNode,p,2),h=Yc(h,p,2),h!==null&&(Qt(h,2),Ko(h))}function Un(h,p,_){if(h.tag===3)s5(h,h,_);else for(;p!==null;){if(p.tag===3){s5(p,h,_);break}else if(p.tag===1){var w=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(nu===null||!nu.has(w))){h=Pa(_,h),_=a4(2),w=Yc(p,_,2),w!==null&&(o4(_,w,p,h),Qt(w,2),Ko(w));break}}p=p.return}}function W2(h,p,_){var w=h.pingCache;if(w===null){w=h.pingCache=new Ane;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(_)||(U2=!0,P.add(_),h=Pne.bind(null,h,p,_),p.then(h,h))}function Pne(h,p,_){var w=h.pingCache;w!==null&&w.delete(p),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,Jn===h&&(vn&_)===_&&(Cr===4||Cr===3&&(vn&62914560)===vn&&300>L()-Bv?(kn&2)===0&&Hf(h,0):F2|=_,zf===vn&&(zf=0)),Ko(h)}function a5(h,p){p===0&&(p=xt()),h=Nd(h,p),h!==null&&(Qt(h,p),Ko(h))}function Rne(h){var p=h.memoizedState,_=0;p!==null&&(_=p.retryLane),a5(h,_)}function Dne(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),a5(h,_)}function One(h,p){return Ne(h,p)}var Kv=null,Vf=null,q2=!1,Xv=!1,K2=!1,su=0;function Ko(h){h!==Vf&&h.next===null&&(Vf===null?Kv=Vf=h:Vf=Vf.next=h),Xv=!0,q2||(q2=!0,Lne())}function qg(h,p){if(!K2&&Xv){K2=!0;do for(var _=!1,w=Kv;w!==null;){if(h!==0){var P=w.pendingLanes;if(P===0)var O=0;else{var X=w.suspendedLanes,le=w.pingedLanes;O=(1<<31-He(42|h)+1)-1,O&=P&~(X&~le),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,u5(w,O))}else O=vn,O=ye(w,w===Jn?O:0,w.cancelPendingCommit!==null||w.timeoutHandle!==-1),(O&3)===0||ce(w,O)||(_=!0,u5(w,O));w=w.next}while(_);K2=!1}}function jne(){o5()}function o5(){Xv=q2=!1;var h=0;su!==0&&Wne()&&(h=su);for(var p=L(),_=null,w=Kv;w!==null;){var P=w.next,O=l5(w,p);O===0?(w.next=null,_===null?Kv=P:_.next=P,P===null&&(Vf=_)):(_=w,(h!==0||(O&3)!==0)&&(Xv=!0)),w=P}li!==0&&li!==5||qg(h),su!==0&&(su=0)}function l5(h,p){for(var _=h.suspendedLanes,w=h.pingedLanes,P=h.expirationTimes,O=h.pendingLanes&-62914561;0<O;){var X=31-He(O),le=1<<X,Ae=P[X];Ae===-1?((le&_)===0||(le&w)!==0)&&(P[X]=at(le,p)):Ae<=p&&(h.expiredLanes|=le),O&=~le}if(p=Jn,_=vn,_=ye(h,h===p?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w=h.callbackNode,_===0||h===p&&(In===2||In===9)||h.cancelPendingCommit!==null)return w!==null&&w!==null&&Pe(w),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||ce(h,_)){if(p=_&-_,p===h.callbackPriority)return p;switch(w!==null&&Pe(w),Mi(_)){case 2:case 8:_=_e;break;case 32:_=be;break;case 268435456:_=Be;break;default:_=be}return w=c5.bind(null,h),_=Ne(_,w),h.callbackPriority=p,h.callbackNode=_,p}return w!==null&&w!==null&&Pe(w),h.callbackPriority=2,h.callbackNode=null,2}function c5(h,p){if(li!==0&&li!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(qv()&&h.callbackNode!==_)return null;var w=vn;return w=ye(h,h===Jn?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),w===0?null:(V4(h,w,p),l5(h,L()),h.callbackNode!=null&&h.callbackNode===_?c5.bind(null,h):null)}function u5(h,p){if(qv())return null;V4(h,p,!0)}function Lne(){Kne(function(){(kn&6)!==0?Ne(ve,jne):o5()})}function X2(){if(su===0){var h=Nf;h===0&&(h=Ye,Ye<<=1,(Ye&261888)===0&&(Ye=256)),su=h}return su}function d5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:rv(""+h)}function h5(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 Ine(h,p,_,w,P){if(p==="submit"&&_&&_.stateNode===P){var O=d5((P[Or]||null).action),X=w.submitter;X&&(p=(p=X[Or]||null)?d5(p.formAction):X.getAttribute("formAction"),p!==null&&(O=p,X=null));var le=new ov("action","action",null,w,P);h.push({event:le,listeners:[{instance:null,listener:function(){if(w.defaultPrevented){if(su!==0){var Ae=X?h5(P,X):new FormData(P);m2(_,{pending:!0,data:Ae,method:P.method,action:O},null,Ae)}}else typeof O=="function"&&(le.preventDefault(),Ae=X?h5(P,X):new FormData(P),m2(_,{pending:!0,data:Ae,method:P.method,action:O},O,Ae))},currentTarget:P}]})}}for(var Y2=0;Y2<RM.length;Y2++){var Z2=RM[Y2],Une=Z2.toLowerCase(),Fne=Z2[0].toUpperCase()+Z2.slice(1);xo(Une,"on"+Fne)}xo($L,"onAnimationEnd"),xo(VL,"onAnimationIteration"),xo(GL,"onAnimationStart"),xo("dblclick","onDoubleClick"),xo("focusin","onFocus"),xo("focusout","onBlur"),xo(tne,"onTransitionRun"),xo(nne,"onTransitionStart"),xo(rne,"onTransitionCancel"),xo(WL,"onTransitionEnd"),vt("onMouseEnter",["mouseout","mouseover"]),vt("onMouseLeave",["mouseout","mouseover"]),vt("onPointerEnter",["pointerout","pointerover"]),vt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Kg="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(" "),zne=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Kg));function f5(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 le=w[X],Ae=le.instance,Xe=le.currentTarget;if(le=le.listener,Ae!==O&&P.isPropagationStopped())break e;O=le,P.currentTarget=Xe;try{O(P)}catch(lt){uv(lt)}P.currentTarget=null,O=Ae}else for(X=0;X<w.length;X++){if(le=w[X],Ae=le.instance,Xe=le.currentTarget,le=le.listener,Ae!==O&&P.isPropagationStopped())break e;O=le,P.currentTarget=Xe;try{O(P)}catch(lt){uv(lt)}P.currentTarget=null,O=Ae}}}}function mn(h,p){var _=p[Hc];_===void 0&&(_=p[Hc]=new Set);var w=h+"__bubble";_.has(w)||(p5(p,h,2,!1),_.add(w))}function Q2(h,p,_){var w=0;p&&(w|=4),p5(_,h,w,p)}var Yv="_reactListening"+Math.random().toString(36).slice(2);function J2(h){if(!h[Yv]){h[Yv]=!0,Te.forEach(function(_){_!=="selectionchange"&&(zne.has(_)||Q2(_,!1,h),Q2(_,!0,h))});var p=h.nodeType===9?h:h.ownerDocument;p===null||p[Yv]||(p[Yv]=!0,Q2("selectionchange",!1,p))}}function p5(h,p,_,w){switch($5(p)){case 2:var P=pre;break;case 8:P=mre;break;default:P=pA}_=P.bind(null,p,_,h),P=void 0,!vM||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 eA(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 le=w.stateNode.containerInfo;if(le===P)break;if(X===4)for(X=w.return;X!==null;){var Ae=X.tag;if((Ae===3||Ae===4)&&X.stateNode.containerInfo===P)return;X=X.return}for(;le!==null;){if(X=Et(le),X===null)return;if(Ae=X.tag,Ae===5||Ae===6||Ae===26||Ae===27){w=O=X;continue e}le=le.parentNode}}w=w.return}vL(function(){var Xe=O,lt=xM(_),dt=[];e:{var Ze=qL.get(h);if(Ze!==void 0){var st=ov,Ot=h;switch(h){case"keypress":if(sv(_)===0)break e;case"keydown":case"keyup":st=Dte;break;case"focusin":Ot="focus",st=SM;break;case"focusout":Ot="blur",st=SM;break;case"beforeblur":case"afterblur":st=SM;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":st=wL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":st=_te;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":st=Lte;break;case $L:case VL:case GL:st=Ete;break;case WL:st=Ute;break;case"scroll":case"scrollend":st=vte;break;case"wheel":st=zte;break;case"copy":case"cut":case"paste":st=Ate;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":st=EL;break;case"toggle":case"beforetoggle":st=Hte}var Gt=(p&4)!==0,Gn=!Gt&&(h==="scroll"||h==="scrollend"),ze=Gt?Ze!==null?Ze+"Capture":null:Ze;Gt=[];for(var Re=Xe,We;Re!==null;){var ut=Re;if(We=ut.stateNode,ut=ut.tag,ut!==5&&ut!==26&&ut!==27||We===null||ze===null||(ut=gg(Re,ze),ut!=null&&Gt.push(Xg(Re,ut,We))),Gn)break;Re=Re.return}0<Gt.length&&(Ze=new st(Ze,Ot,null,_,lt),dt.push({event:Ze,listeners:Gt}))}}if((p&7)===0){e:{if(Ze=h==="mouseover"||h==="pointerover",st=h==="mouseout"||h==="pointerout",Ze&&_!==gM&&(Ot=_.relatedTarget||_.fromElement)&&(Et(Ot)||Ot[mo]))break e;if((st||Ze)&&(Ze=lt.window===lt?lt:(Ze=lt.ownerDocument)?Ze.defaultView||Ze.parentWindow:window,st?(Ot=_.relatedTarget||_.toElement,st=Xe,Ot=Ot?Et(Ot):null,Ot!==null&&(Gn=s(Ot),Gt=Ot.tag,Ot!==Gn||Gt!==5&&Gt!==27&&Gt!==6)&&(Ot=null)):(st=null,Ot=Xe),st!==Ot)){if(Gt=wL,ut="onMouseLeave",ze="onMouseEnter",Re="mouse",(h==="pointerout"||h==="pointerover")&&(Gt=EL,ut="onPointerLeave",ze="onPointerEnter",Re="pointer"),Gn=st==null?Ze:Me(st),We=Ot==null?Ze:Me(Ot),Ze=new Gt(ut,Re+"leave",st,_,lt),Ze.target=Gn,Ze.relatedTarget=We,ut=null,Et(lt)===Xe&&(Gt=new Gt(ze,Re+"enter",Ot,_,lt),Gt.target=We,Gt.relatedTarget=Gn,ut=Gt),Gn=ut,st&&Ot)t:{for(Gt=Bne,ze=st,Re=Ot,We=0,ut=ze;ut;ut=Gt(ut))We++;ut=0;for(var zt=Re;zt;zt=Gt(zt))ut++;for(;0<We-ut;)ze=Gt(ze),We--;for(;0<ut-We;)Re=Gt(Re),ut--;for(;We--;){if(ze===Re||Re!==null&&ze===Re.alternate){Gt=ze;break t}ze=Gt(ze),Re=Gt(Re)}Gt=null}else Gt=null;st!==null&&m5(dt,Ze,st,Gt,!1),Ot!==null&&Gn!==null&&m5(dt,Gn,Ot,Gt,!0)}}e:{if(Ze=Xe?Me(Xe):window,st=Ze.nodeName&&Ze.nodeName.toLowerCase(),st==="select"||st==="input"&&Ze.type==="file")var An=RL;else if(kL(Ze))if(DL)An=Qte;else{An=Yte;var It=Xte}else st=Ze.nodeName,!st||st.toLowerCase()!=="input"||Ze.type!=="checkbox"&&Ze.type!=="radio"?Xe&&mM(Xe.elementType)&&(An=RL):An=Zte;if(An&&(An=An(h,Xe))){PL(dt,An,_,lt);break e}It&&It(h,Ze,Xe),h==="focusout"&&Xe&&Ze.type==="number"&&Xe.memoizedProps.value!=null&&Ai(Ze,"number",Ze.value)}switch(It=Xe?Me(Xe):window,h){case"focusin":(kL(It)||It.contentEditable==="true")&&(_f=It,NM=Xe,Eg=null);break;case"focusout":Eg=NM=_f=null;break;case"mousedown":kM=!0;break;case"contextmenu":case"mouseup":case"dragend":kM=!1,BL(dt,_,lt);break;case"selectionchange":if(ene)break;case"keydown":case"keyup":BL(dt,_,lt)}var rn;if(MM)e:{switch(h){case"compositionstart":var yn="onCompositionStart";break e;case"compositionend":yn="onCompositionEnd";break e;case"compositionupdate":yn="onCompositionUpdate";break e}yn=void 0}else yf?CL(h,_)&&(yn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(yn="onCompositionStart");yn&&(ML&&_.locale!=="ko"&&(yf||yn!=="onCompositionStart"?yn==="onCompositionEnd"&&yf&&(rn=yL()):($c=lt,yM="value"in $c?$c.value:$c.textContent,yf=!0)),It=Zv(Xe,yn),0<It.length&&(yn=new SL(yn,h,null,_,lt),dt.push({event:yn,listeners:It}),rn?yn.data=rn:(rn=NL(_),rn!==null&&(yn.data=rn)))),(rn=Vte?Gte(h,_):Wte(h,_))&&(yn=Zv(Xe,"onBeforeInput"),0<yn.length&&(It=new SL("onBeforeInput","beforeinput",null,_,lt),dt.push({event:It,listeners:yn}),It.data=rn)),Ine(dt,h,Xe,_,lt)}f5(dt,p)})}function Xg(h,p,_){return{instance:h,listener:p,currentTarget:_}}function Zv(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=gg(h,_),P!=null&&w.unshift(Xg(h,P,O)),P=gg(h,p),P!=null&&w.push(Xg(h,P,O))),h.tag===3)return w;h=h.return}return[]}function Bne(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function m5(h,p,_,w,P){for(var O=p._reactName,X=[];_!==null&&_!==w;){var le=_,Ae=le.alternate,Xe=le.stateNode;if(le=le.tag,Ae!==null&&Ae===w)break;le!==5&&le!==26&&le!==27||Xe===null||(Ae=Xe,P?(Xe=gg(_,O),Xe!=null&&X.unshift(Xg(_,Xe,Ae))):P||(Xe=gg(_,O),Xe!=null&&X.push(Xg(_,Xe,Ae)))),_=_.return}X.length!==0&&h.push({event:p,listeners:X})}var Hne=/\r\n?/g,$ne=/\u0000|\uFFFD/g;function g5(h){return(typeof h=="string"?h:""+h).replace(Hne,`
- `).replace($ne,"")}function x5(h,p){return p=g5(p),g5(h)===p}function Vn(h,p,_,w,P,O){switch(_){case"children":typeof w=="string"?p==="body"||p==="textarea"&&w===""||Vo(h,w):(typeof w=="number"||typeof w=="bigint")&&p!=="body"&&Vo(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":xL(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=rv(""+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"&&Vn(h,p,"name",P.name,P,null),Vn(h,p,"formEncType",P.formEncType,P,null),Vn(h,p,"formMethod",P.formMethod,P,null),Vn(h,p,"formTarget",P.formTarget,P,null)):(Vn(h,p,"encType",P.encType,P,null),Vn(h,p,"method",P.method,P,null),Vn(h,p,"target",P.target,P,null)));if(w==null||typeof w=="symbol"||typeof w=="boolean"){h.removeAttribute(_);break}w=rv(""+w),h.setAttribute(_,w);break;case"onClick":w!=null&&(h.onclick=Tl);break;case"onScroll":w!=null&&mn("scroll",h);break;case"onScrollEnd":w!=null&&mn("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}_=rv(""+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":mn("beforetoggle",h),mn("toggle",h),Xt(h,"popover",w);break;case"xlinkActuate":sn(h,"http://www.w3.org/1999/xlink","xlink:actuate",w);break;case"xlinkArcrole":sn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",w);break;case"xlinkRole":sn(h,"http://www.w3.org/1999/xlink","xlink:role",w);break;case"xlinkShow":sn(h,"http://www.w3.org/1999/xlink","xlink:show",w);break;case"xlinkTitle":sn(h,"http://www.w3.org/1999/xlink","xlink:title",w);break;case"xlinkType":sn(h,"http://www.w3.org/1999/xlink","xlink:type",w);break;case"xmlBase":sn(h,"http://www.w3.org/XML/1998/namespace","xml:base",w);break;case"xmlLang":sn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",w);break;case"xmlSpace":sn(h,"http://www.w3.org/XML/1998/namespace","xml:space",w);break;case"is":Xt(h,"is",w);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=xte.get(_)||_,Xt(h,_,w))}}function tA(h,p,_,w,P,O){switch(_){case"style":xL(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"?Vo(h,w):(typeof w=="number"||typeof w=="bigint")&&Vo(h,""+w);break;case"onScroll":w!=null&&mn("scroll",h);break;case"onScrollEnd":w!=null&&mn("scrollend",h);break;case"onClick":w!=null&&(h.onclick=Tl);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[Or]||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(_,""):Xt(h,_,w)}}}function Gi(h,p,_){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":mn("error",h),mn("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:Vn(h,p,O,X,_,null)}}P&&Vn(h,p,"srcSet",_.srcSet,_,null),w&&Vn(h,p,"src",_.src,_,null);return;case"input":mn("invalid",h);var le=O=X=P=null,Ae=null,Xe=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":Ae=lt;break;case"defaultChecked":Xe=lt;break;case"value":O=lt;break;case"defaultValue":le=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,p));break;default:Vn(h,p,w,lt,_,null)}}Ln(h,O,le,Ae,Xe,X,P,!1);return;case"select":mn("invalid",h),w=X=O=null;for(P in _)if(_.hasOwnProperty(P)&&(le=_[P],le!=null))switch(P){case"value":O=le;break;case"defaultValue":X=le;break;case"multiple":w=le;default:Vn(h,p,P,le,_,null)}p=O,_=X,h.multiple=!!w,p!=null?oi(h,!!w,p,!1):_!=null&&oi(h,!!w,_,!0);return;case"textarea":mn("invalid",h),O=P=w=null;for(X in _)if(_.hasOwnProperty(X)&&(le=_[X],le!=null))switch(X){case"value":w=le;break;case"defaultValue":P=le;break;case"children":O=le;break;case"dangerouslySetInnerHTML":if(le!=null)throw Error(r(91));break;default:Vn(h,p,X,le,_,null)}Bi(h,w,P,O);return;case"option":for(Ae in _)if(_.hasOwnProperty(Ae)&&(w=_[Ae],w!=null))switch(Ae){case"selected":h.selected=w&&typeof w!="function"&&typeof w!="symbol";break;default:Vn(h,p,Ae,w,_,null)}return;case"dialog":mn("beforetoggle",h),mn("toggle",h),mn("cancel",h),mn("close",h);break;case"iframe":case"object":mn("load",h);break;case"video":case"audio":for(w=0;w<Kg.length;w++)mn(Kg[w],h);break;case"image":mn("error",h),mn("load",h);break;case"details":mn("toggle",h);break;case"embed":case"source":case"link":mn("error",h),mn("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(Xe in _)if(_.hasOwnProperty(Xe)&&(w=_[Xe],w!=null))switch(Xe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,p));default:Vn(h,p,Xe,w,_,null)}return;default:if(mM(p)){for(lt in _)_.hasOwnProperty(lt)&&(w=_[lt],w!==void 0&&tA(h,p,lt,w,_,void 0));return}}for(le in _)_.hasOwnProperty(le)&&(w=_[le],w!=null&&Vn(h,p,le,w,_,null))}function Vne(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,le=null,Ae=null,Xe=null,lt=null;for(st in _){var dt=_[st];if(_.hasOwnProperty(st)&&dt!=null)switch(st){case"checked":break;case"value":break;case"defaultValue":Ae=dt;default:w.hasOwnProperty(st)||Vn(h,p,st,null,w,dt)}}for(var Ze in w){var st=w[Ze];if(dt=_[Ze],w.hasOwnProperty(Ze)&&(st!=null||dt!=null))switch(Ze){case"type":O=st;break;case"name":P=st;break;case"checked":Xe=st;break;case"defaultChecked":lt=st;break;case"value":X=st;break;case"defaultValue":le=st;break;case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,p));break;default:st!==dt&&Vn(h,p,Ze,st,w,dt)}}go(h,X,le,Ae,Xe,lt,O,P);return;case"select":st=X=le=Ze=null;for(O in _)if(Ae=_[O],_.hasOwnProperty(O)&&Ae!=null)switch(O){case"value":break;case"multiple":st=Ae;default:w.hasOwnProperty(O)||Vn(h,p,O,null,w,Ae)}for(P in w)if(O=w[P],Ae=_[P],w.hasOwnProperty(P)&&(O!=null||Ae!=null))switch(P){case"value":Ze=O;break;case"defaultValue":le=O;break;case"multiple":X=O;default:O!==Ae&&Vn(h,p,P,O,w,Ae)}p=le,_=X,w=st,Ze!=null?oi(h,!!_,Ze,!1):!!w!=!!_&&(p!=null?oi(h,!!_,p,!0):oi(h,!!_,_?[]:"",!1));return;case"textarea":st=Ze=null;for(le in _)if(P=_[le],_.hasOwnProperty(le)&&P!=null&&!w.hasOwnProperty(le))switch(le){case"value":break;case"children":break;default:Vn(h,p,le,null,w,P)}for(X in w)if(P=w[X],O=_[X],w.hasOwnProperty(X)&&(P!=null||O!=null))switch(X){case"value":Ze=P;break;case"defaultValue":st=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==O&&Vn(h,p,X,P,w,O)}Ti(h,Ze,st);return;case"option":for(var Ot in _)if(Ze=_[Ot],_.hasOwnProperty(Ot)&&Ze!=null&&!w.hasOwnProperty(Ot))switch(Ot){case"selected":h.selected=!1;break;default:Vn(h,p,Ot,null,w,Ze)}for(Ae in w)if(Ze=w[Ae],st=_[Ae],w.hasOwnProperty(Ae)&&Ze!==st&&(Ze!=null||st!=null))switch(Ae){case"selected":h.selected=Ze&&typeof Ze!="function"&&typeof Ze!="symbol";break;default:Vn(h,p,Ae,Ze,w,st)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Gt in _)Ze=_[Gt],_.hasOwnProperty(Gt)&&Ze!=null&&!w.hasOwnProperty(Gt)&&Vn(h,p,Gt,null,w,Ze);for(Xe in w)if(Ze=w[Xe],st=_[Xe],w.hasOwnProperty(Xe)&&Ze!==st&&(Ze!=null||st!=null))switch(Xe){case"children":case"dangerouslySetInnerHTML":if(Ze!=null)throw Error(r(137,p));break;default:Vn(h,p,Xe,Ze,w,st)}return;default:if(mM(p)){for(var Gn in _)Ze=_[Gn],_.hasOwnProperty(Gn)&&Ze!==void 0&&!w.hasOwnProperty(Gn)&&tA(h,p,Gn,void 0,w,Ze);for(lt in w)Ze=w[lt],st=_[lt],!w.hasOwnProperty(lt)||Ze===st||Ze===void 0&&st===void 0||tA(h,p,lt,Ze,w,st);return}}for(var ze in _)Ze=_[ze],_.hasOwnProperty(ze)&&Ze!=null&&!w.hasOwnProperty(ze)&&Vn(h,p,ze,null,w,Ze);for(dt in w)Ze=w[dt],st=_[dt],!w.hasOwnProperty(dt)||Ze===st||Ze==null&&st==null||Vn(h,p,dt,Ze,w,st)}function b5(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Gne(){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,le=P.duration;if(O&&le&&b5(X)){for(X=0,le=P.responseEnd,w+=1;w<_.length;w++){var Ae=_[w],Xe=Ae.startTime;if(Xe>le)break;var lt=Ae.transferSize,dt=Ae.initiatorType;lt&&b5(dt)&&(Ae=Ae.responseEnd,X+=lt*(Ae<le?1:(le-Xe)/(Ae-Xe)))}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 nA=null,rA=null;function Qv(h){return h.nodeType===9?h:h.ownerDocument}function v5(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 y5(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 iA(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 sA=null;function Wne(){var h=window.event;return h&&h.type==="popstate"?h===sA?!1:(sA=h,!0):(sA=null,!1)}var _5=typeof setTimeout=="function"?setTimeout:void 0,qne=typeof clearTimeout=="function"?clearTimeout:void 0,w5=typeof Promise=="function"?Promise:void 0,Kne=typeof queueMicrotask=="function"?queueMicrotask:typeof w5<"u"?function(h){return w5.resolve(null).then(h).catch(Xne)}:_5;function Xne(h){setTimeout(function(){throw h})}function au(h){return h==="head"}function S5(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),Kf(p);return}w--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")w++;else if(_==="html")Yg(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Yg(_);for(var O=_.firstChild;O;){var X=O.nextSibling,le=O.nodeName;O[it]||le==="SCRIPT"||le==="STYLE"||le==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=X}}else _==="body"&&Yg(h.ownerDocument.body);_=P}while(_);Kf(p)}function E5(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 aA(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":aA(_),et(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Yne(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[it])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=La(h.nextSibling),h===null)break}return null}function Zne(h,p,_){if(p==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=La(h.nextSibling),h===null))return null;return h}function M5(h,p){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!p||(h=La(h.nextSibling),h===null))return null;return h}function oA(h){return h.data==="$?"||h.data==="$~"}function lA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Qne(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 La(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 cA=null;function A5(h){h=h.nextSibling;for(var p=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(p===0)return La(h.nextSibling);p--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||p++}h=h.nextSibling}return null}function T5(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 C5(h,p,_){switch(p=Qv(_),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 Yg(h){for(var p=h.attributes;p.length;)h.removeAttributeNode(p[0]);et(h)}var Ia=new Map,N5=new Set;function Jv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var $l=V.d;V.d={f:Jne,r:ere,D:tre,C:nre,L:rre,m:ire,X:are,S:sre,M:ore};function Jne(){var h=$l.f(),p=Vv();return h||p}function ere(h){var p=ie(h);p!==null&&p.tag===5&&p.type==="form"?WI(p):$l.r(h)}var Gf=typeof document>"u"?null:document;function k5(h,p,_){var w=Gf;if(w&&typeof p=="string"&&p){var P=Dn(p);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),N5.has(P)||(N5.add(P),h={rel:h,crossOrigin:_,href:p},w.querySelector(P)===null&&(p=w.createElement("link"),Gi(p,"link",h),je(p),w.head.appendChild(p)))}}function tre(h){$l.D(h),k5("dns-prefetch",h,null)}function nre(h,p){$l.C(h,p),k5("preconnect",h,p)}function rre(h,p,_){$l.L(h,p,_);var w=Gf;if(w&&h&&p){var P='link[rel="preload"][as="'+Dn(p)+'"]';p==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Dn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Dn(_.imageSizes)+'"]')):P+='[href="'+Dn(h)+'"]';var O=P;switch(p){case"style":O=Wf(h);break;case"script":O=qf(h)}Ia.has(O)||(h=f({rel:"preload",href:p==="image"&&_&&_.imageSrcSet?void 0:h,as:p},_),Ia.set(O,h),w.querySelector(P)!==null||p==="style"&&w.querySelector(Zg(O))||p==="script"&&w.querySelector(Qg(O))||(p=w.createElement("link"),Gi(p,"link",h),je(p),w.head.appendChild(p)))}}function ire(h,p){$l.m(h,p);var _=Gf;if(_&&h){var w=p&&typeof p.as=="string"?p.as:"script",P='link[rel="modulepreload"][as="'+Dn(w)+'"][href="'+Dn(h)+'"]',O=P;switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=qf(h)}if(!Ia.has(O)&&(h=f({rel:"modulepreload",href:h},p),Ia.set(O,h),_.querySelector(P)===null)){switch(w){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Qg(O)))return}w=_.createElement("link"),Gi(w,"link",h),je(w),_.head.appendChild(w)}}}function sre(h,p,_){$l.S(h,p,_);var w=Gf;if(w&&h){var P=Ie(w).hoistableStyles,O=Wf(h);p=p||"default";var X=P.get(O);if(!X){var le={loading:0,preload:null};if(X=w.querySelector(Zg(O)))le.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":p},_),(_=Ia.get(O))&&uA(h,_);var Ae=X=w.createElement("link");je(Ae),Gi(Ae,"link",h),Ae._p=new Promise(function(Xe,lt){Ae.onload=Xe,Ae.onerror=lt}),Ae.addEventListener("load",function(){le.loading|=1}),Ae.addEventListener("error",function(){le.loading|=2}),le.loading|=4,ey(X,p,w)}X={type:"stylesheet",instance:X,count:1,state:le},P.set(O,X)}}}function are(h,p){$l.X(h,p);var _=Gf;if(_&&h){var w=Ie(_).hoistableScripts,P=qf(h),O=w.get(P);O||(O=_.querySelector(Qg(P)),O||(h=f({src:h,async:!0},p),(p=Ia.get(P))&&dA(h,p),O=_.createElement("script"),je(O),Gi(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(P,O))}}function ore(h,p){$l.M(h,p);var _=Gf;if(_&&h){var w=Ie(_).hoistableScripts,P=qf(h),O=w.get(P);O||(O=_.querySelector(Qg(P)),O||(h=f({src:h,async:!0,type:"module"},p),(p=Ia.get(P))&&dA(h,p),O=_.createElement("script"),je(O),Gi(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},w.set(P,O))}}function P5(h,p,_,w){var P=(P=fe.current)?Jv(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=Wf(_.href),_=Ie(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=Wf(_.href);var O=Ie(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(Zg(h)))&&!O._p&&(X.instance=O,X.state.loading=5),Ia.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Ia.set(h,_),O||lre(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=qf(_),_=Ie(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 Wf(h){return'href="'+Dn(h)+'"'}function Zg(h){return'link[rel="stylesheet"]['+h+"]"}function R5(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function lre(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}),Gi(p,"link",_),je(p),h.head.appendChild(p))}function qf(h){return'[src="'+Dn(h)+'"]'}function Qg(h){return"script[async]"+h}function D5(h,p,_){if(p.count++,p.instance===null)switch(p.type){case"style":var w=h.querySelector('style[data-href~="'+Dn(_.href)+'"]');if(w)return p.instance=w,je(w),w;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return w=(h.ownerDocument||h).createElement("style"),je(w),Gi(w,"style",P),ey(w,_.precedence,h),p.instance=w;case"stylesheet":P=Wf(_.href);var O=h.querySelector(Zg(P));if(O)return p.state.loading|=4,p.instance=O,je(O),O;w=R5(_),(P=Ia.get(P))&&uA(w,P),O=(h.ownerDocument||h).createElement("link"),je(O);var X=O;return X._p=new Promise(function(le,Ae){X.onload=le,X.onerror=Ae}),Gi(O,"link",w),p.state.loading|=4,ey(O,_.precedence,h),p.instance=O;case"script":return O=qf(_.src),(P=h.querySelector(Qg(O)))?(p.instance=P,je(P),P):(w=_,(P=Ia.get(O))&&(w=f({},_),dA(w,P)),h=h.ownerDocument||h,P=h.createElement("script"),je(P),Gi(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,ey(w,_.precedence,h));return p.instance}function ey(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 le=w[X];if(le.dataset.precedence===p)O=le;else if(O!==P)break}O?O.parentNode.insertBefore(h,O.nextSibling):(p=_.nodeType===9?_.head:_,p.insertBefore(h,p.firstChild))}function uA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.title==null&&(h.title=p.title)}function dA(h,p){h.crossOrigin==null&&(h.crossOrigin=p.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=p.referrerPolicy),h.integrity==null&&(h.integrity=p.integrity)}var ty=null;function O5(h,p,_){if(ty===null){var w=new Map,P=ty=new Map;P.set(_,w)}else P=ty,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[it]||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 le=w.get(X);le?le.push(O):w.set(X,[O])}}return w}function j5(h,p,_){h=h.ownerDocument||h,h.head.insertBefore(_,p==="title"?h.querySelector("head > title"):null)}function cre(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 L5(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function ure(h,p,_,w){if(_.type==="stylesheet"&&(typeof w.media!="string"||matchMedia(w.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=Wf(w.href),O=p.querySelector(Zg(P));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(h.count++,h=ny.bind(h),p.then(h,h)),_.state.loading|=4,_.instance=O,je(O);return}O=p.ownerDocument||p,w=R5(w),(P=Ia.get(P))&&uA(w,P),O=O.createElement("link"),je(O);var X=O;X._p=new Promise(function(le,Ae){X.onload=le,X.onerror=Ae}),Gi(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++,_=ny.bind(h),p.addEventListener("load",_),p.addEventListener("error",_))}}var hA=0;function dre(h,p){return h.stylesheets&&h.count===0&&iy(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var w=setTimeout(function(){if(h.stylesheets&&iy(h,h.stylesheets),h.unsuspend){var O=h.unsuspend;h.unsuspend=null,O()}},6e4+p);0<h.imgBytes&&hA===0&&(hA=62500*Gne());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&iy(h,h.stylesheets),h.unsuspend)){var O=h.unsuspend;h.unsuspend=null,O()}},(h.imgBytes>hA?50:800)+p);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(w),clearTimeout(P)}}:null}function ny(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)iy(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var ry=null;function iy(h,p){h.stylesheets=null,h.unsuspend!==null&&(h.count++,ry=new Map,p.forEach(hre,h),ry=null,ny.call(h))}function hre(h,p){if(!(p.state.loading&4)){var _=ry.get(h);if(_)var w=_.get(null);else{_=new Map,ry.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=ny.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 Jg={$$typeof:S,Provider:null,Consumer:null,_currentValue:ee,_currentValue2:ee,_threadCount:0};function fre(h,p,_,w,P,O,X,le,Ae){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=St(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=St(0),this.hiddenUpdates=St(null),this.identifierPrefix=w,this.onUncaughtError=P,this.onCaughtError=O,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ae,this.incompleteTransitions=new Map}function I5(h,p,_,w,P,O,X,le,Ae,Xe,lt,dt){return h=new fre(h,p,_,X,Ae,Xe,lt,dt,le),p=1,O===!0&&(p|=24),O=ra(3,null,null,p),h.current=O,O.stateNode=h,p=GM(),p.refCount++,h.pooledCache=p,p.refCount++,O.memoizedState={element:w,isDehydrated:_,cache:p},XM(O),h}function U5(h){return h?(h=Ef,h):Ef}function F5(h,p,_,w,P,O){P=U5(P),w.context===null?w.context=P:w.pendingContext=P,w=Xc(p),w.payload={element:_},O=O===void 0?null:O,O!==null&&(w.callback=O),_=Yc(h,w,p),_!==null&&(zs(_,h,p),Pg(_,h,p))}function z5(h,p){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<p?_:p}}function fA(h,p){z5(h,p),(h=h.alternate)&&z5(h,p)}function B5(h){if(h.tag===13||h.tag===31){var p=Nd(h,67108864);p!==null&&zs(p,h,67108864),fA(h,67108864)}}function H5(h){if(h.tag===13||h.tag===31){var p=la();p=ai(p);var _=Nd(h,p);_!==null&&zs(_,h,p),fA(h,p)}}var sy=!0;function pre(h,p,_,w){var P=K.T;K.T=null;var O=V.p;try{V.p=2,pA(h,p,_,w)}finally{V.p=O,K.T=P}}function mre(h,p,_,w){var P=K.T;K.T=null;var O=V.p;try{V.p=8,pA(h,p,_,w)}finally{V.p=O,K.T=P}}function pA(h,p,_,w){if(sy){var P=mA(w);if(P===null)eA(h,p,w,ay,_),V5(h,w);else if(xre(P,h,p,_,w))w.stopPropagation();else if(V5(h,w),p&4&&-1<gre.indexOf(h)){for(;P!==null;){var O=ie(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 le=O;for(le.pendingLanes|=2,le.entangledLanes|=2;X;){var Ae=1<<31-He(X);le.entanglements[1]|=Ae,X&=~Ae}Ko(O),(kn&6)===0&&(Hv=L()+500,qg(0))}}break;case 31:case 13:le=Nd(O,2),le!==null&&zs(le,O,2),Vv(),fA(O,2)}if(O=mA(w),O===null&&eA(h,p,w,ay,_),O===P)break;P=O}P!==null&&w.stopPropagation()}else eA(h,p,w,null,_)}}function mA(h){return h=xM(h),gA(h)}var ay=null;function gA(h){if(ay=null,h=Et(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 ay=h,null}function $5(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(te()){case ve:return 2;case _e:return 8;case be:case nt:return 32;case Be:return 268435456;default:return 32}default:return 32}}var xA=!1,ou=null,lu=null,cu=null,ex=new Map,tx=new Map,uu=[],gre="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 V5(h,p){switch(h){case"focusin":case"focusout":ou=null;break;case"dragenter":case"dragleave":lu=null;break;case"mouseover":case"mouseout":cu=null;break;case"pointerover":case"pointerout":ex.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":tx.delete(p.pointerId)}}function nx(h,p,_,w,P,O){return h===null||h.nativeEvent!==O?(h={blockedOn:p,domEventName:_,eventSystemFlags:w,nativeEvent:O,targetContainers:[P]},p!==null&&(p=ie(p),p!==null&&B5(p)),h):(h.eventSystemFlags|=w,p=h.targetContainers,P!==null&&p.indexOf(P)===-1&&p.push(P),h)}function xre(h,p,_,w,P){switch(p){case"focusin":return ou=nx(ou,h,p,_,w,P),!0;case"dragenter":return lu=nx(lu,h,p,_,w,P),!0;case"mouseover":return cu=nx(cu,h,p,_,w,P),!0;case"pointerover":var O=P.pointerId;return ex.set(O,nx(ex.get(O)||null,h,p,_,w,P)),!0;case"gotpointercapture":return O=P.pointerId,tx.set(O,nx(tx.get(O)||null,h,p,_,w,P)),!0}return!1}function G5(h){var p=Et(h.target);if(p!==null){var _=s(p);if(_!==null){if(p=_.tag,p===13){if(p=a(_),p!==null){h.blockedOn=p,rs(h.priority,function(){H5(_)});return}}else if(p===31){if(p=o(_),p!==null){h.blockedOn=p,rs(h.priority,function(){H5(_)});return}}else if(p===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function oy(h){if(h.blockedOn!==null)return!1;for(var p=h.targetContainers;0<p.length;){var _=mA(h.nativeEvent);if(_===null){_=h.nativeEvent;var w=new _.constructor(_.type,_);gM=w,_.target.dispatchEvent(w),gM=null}else return p=ie(_),p!==null&&B5(p),h.blockedOn=_,!1;p.shift()}return!0}function W5(h,p,_){oy(h)&&_.delete(p)}function bre(){xA=!1,ou!==null&&oy(ou)&&(ou=null),lu!==null&&oy(lu)&&(lu=null),cu!==null&&oy(cu)&&(cu=null),ex.forEach(W5),tx.forEach(W5)}function ly(h,p){h.blockedOn===p&&(h.blockedOn=null,xA||(xA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,bre)))}var cy=null;function q5(h){cy!==h&&(cy=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){cy===h&&(cy=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(gA(w||_)===null)continue;break}var O=ie(_);O!==null&&(h.splice(p,3),p-=3,m2(O,{pending:!0,data:P,method:_.method,action:w},w,P))}}))}function Kf(h){function p(Ae){return ly(Ae,h)}ou!==null&&ly(ou,h),lu!==null&&ly(lu,h),cu!==null&&ly(cu,h),ex.forEach(p),tx.forEach(p);for(var _=0;_<uu.length;_++){var w=uu[_];w.blockedOn===h&&(w.blockedOn=null)}for(;0<uu.length&&(_=uu[0],_.blockedOn===null);)G5(_),_.blockedOn===null&&uu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(w=0;w<_.length;w+=3){var P=_[w],O=_[w+1],X=P[Or]||null;if(typeof O=="function")X||q5(_);else if(X){var le=null;if(O&&O.hasAttribute("formAction")){if(P=O,X=O[Or]||null)le=X.formAction;else if(gA(P)!==null)continue}else le=X.action;typeof le=="function"?_[w+1]=le:(_.splice(w,3),w-=3),q5(_)}}}function K5(){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 bA(h){this._internalRoot=h}uy.prototype.render=bA.prototype.render=function(h){var p=this._internalRoot;if(p===null)throw Error(r(409));var _=p.current,w=la();F5(_,w,h,p,null,null)},uy.prototype.unmount=bA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var p=h.containerInfo;F5(h.current,2,null,h,null,null),Vv(),p[mo]=null}};function uy(h){this._internalRoot=h}uy.prototype.unstable_scheduleHydration=function(h){if(h){var p=zi();h={blockedOn:null,target:h,priority:p};for(var _=0;_<uu.length&&p!==0&&p<uu[_].priority;_++);uu.splice(_,0,h),_===0&&G5(h)}};var X5=e.version;if(X5!=="19.2.0")throw Error(r(527,X5,"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 vre={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var dy=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!dy.isDisabled&&dy.supportsFiber)try{Ue=dy.inject(vre),ae=dy}catch{}}return ix.createRoot=function(h,p){if(!i(h))throw Error(r(299));var _=!1,w="",P=n4,O=r4,X=i4;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=I5(h,1,!1,null,null,_,w,null,P,O,X,K5),h[mo]=p.current,J2(h),new bA(p)},ix.hydrateRoot=function(h,p,_){if(!i(h))throw Error(r(299));var w=!1,P="",O=n4,X=r4,le=i4,Ae=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&&(le=_.onRecoverableError),_.formState!==void 0&&(Ae=_.formState)),p=I5(h,1,!0,p,_??null,w,P,Ae,O,X,le,K5),p.context=U5(null),_=p.current,w=la(),w=ai(w),P=Xc(w),P.callback=null,Yc(_,P,w),_=w,p.current.lanes=_,Qt(p,_),Ko(p),h[mo]=p.current,J2(h),new uy(p)},ix.version="19.2.0",ix}var sU;function kre(){if(sU)return _A.exports;sU=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),_A.exports=Nre(),_A.exports}var Pre=kre();const qt=t=>typeof t=="string",sx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},aU=t=>t==null?"":""+t,Rre=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Dre=/###/g,oU=t=>t&&t.indexOf("###")>-1?t.replace(Dre,"."):t,lU=t=>!t||qt(t),Gx=(t,e,n)=>{const r=qt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(lU(t))return{};const s=oU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return lU(t)?{}:{obj:t,k:oU(r[i])}},cU=(t,e,n)=>{const{obj:r,k:i}=Gx(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=Gx(t,a,Object);for(;o.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),o=Gx(t,a,Object),o?.obj&&typeof o.obj[`${o.k}.${s}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${s}`]=n},Ore=(t,e,n,r)=>{const{obj:i,k:s}=Gx(t,e,Object);i[s]=i[s]||[],i[s].push(n)},_1=(t,e)=>{const{obj:n,k:r}=Gx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},jre=(t,e,n)=>{const r=_1(t,n);return r!==void 0?r:_1(e,n)},xG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?qt(t[r])||t[r]instanceof String||qt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):xG(t[r],e[r],n):t[r]=e[r]);return t},Xf=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Lre={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Ire=t=>qt(t)?t.replace(/[&<>"'\/]/g,e=>Lre[e]):t;class Ure{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 Fre=[" ",",","?","!",";"],zre=new Ure(20),Bre=(t,e,n)=>{e=e||"",n=n||"";const r=Fre.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=zre.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},m3=(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 c=s;c<r.length;++c)if(c!==s&&(o+=n),o+=r[c],a=i[o],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;s+=c-s+1;break}i=a}return i},p0=t=>t?.replace("_","-"),Hre={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 w1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Hre,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(qt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new w1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new w1(this.logger,e)}}var sl=new w1;let OS=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 uU extends OS{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):qt(r)&&s?o.push(...r.split(s)):o.push(r)));const c=_1(this.data,o);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=o[0],n=o[1],r=o.slice(2).join(".")),c||!a||!qt(r)?c:m3(this.data?.[e]?.[n],r,s)}addResource(e,n,r,i,s={silent:!1}){const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let o=[e,n];r&&(o=o.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(o=e.split("."),i=n,n=o[1]),this.addNamespaces(n),cU(this.data,o,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const s in r)(qt(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 c=_1(this.data,o)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?xG(c,r,s):c={...c,...r},cU(this.data,o,c),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 bG={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 vG=Symbol("i18next/PATH_KEY");function $re(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===vG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function g3(t,e){const{[vG]:n}=t($re());return n.join(e?.keySeparator??".")}const dU={},MA=t=>!qt(t)&&typeof t!="boolean"&&typeof t!="number";class S1 extends OS{constructor(e,n={}){super(),Rre(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=sl.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=MA(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&&!Bre(e,r,i);if(a&&!o){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:qt(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:qt(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=g3(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:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?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&&!qt(i.count),T=S1.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=MA(D),j=Object.prototype.toString.apply(D);if(S&&D&&F&&b.indexOf(j)<0&&!(qt(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:c}):`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:MA(C)?C[K]:void 0,joinArrays:!1,ns:c}):R[K]=this.translate(V,{...i,joinArrays:!1,ns:c}),R[K]===V&&(R[K]=D[K])}x=R}}else if(S&&qt(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(x)&&T&&(q=!0,x=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 ee=[];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++)ee.push(Y[U]);else this.options.saveMissingTo==="all"?ee=this.languageUtils.toResolveHierarchy(i.lng||this.language):ee.push(i.lng||this.language);const Q=(U,z,J)=>{const se=T&&J!==x?J:K;this.options.missingKeyHandler?this.options.missingKeyHandler(U,u,z,se,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(U,u,z,se,V,i),this.emit("missingKey",U,u,z,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?ee.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(J=>{Q([U],o+J,i[`defaultValue${J}`]||C)})}):Q(ee,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 c=qt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!qt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>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=qt(a)?[a]:a;return e!=null&&o?.length&&r.applyPostProcessor!==!1&&(e=bG.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 qt(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!qt(n.count),m=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(qt(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,!dU[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(dU[`${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&&!qt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const 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 hU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=sl.create("languageUtils")}getScriptPartFromCode(e){if(e=p0(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=p0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(qt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const 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)),qt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return qt(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))):qt(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const fU={zero:0,one:1,two:2,few:3,many:4,other:5},pU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Vre{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=sl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=p0(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!"),pU;if(!e.match(/-|_/))return pU;const c=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(c,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)=>fU[i]-fU[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const mU=(t,e,n,r=".",i=!0)=>{let s=jre(t,e,n);return!s&&i&&qt(n)&&(s=m3(t,n,r),s===void 0&&(s=m3(e,n,r))),s},AA=t=>t.replace(/\$/g,"$$$$");class Gre{constructor(e={}){this.logger=sl.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:c,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:Ire,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Xf(s):a||"{{",this.suffix=o?Xf(o):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?Xf(g):m||Xf("$t("),this.nestingSuffix=x?Xf(x):y||Xf(")"),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 c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const b=mU(n,c,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(mU(n,c,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=>AA(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?AA(this.escape(m)):AA(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=qt(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!qt(a)&&!this.useRawValueToEscape&&(a=aU(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=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;c=f[0],g=this.interpolate(g,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 ${c}`,y),`${c}${d}${g}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];a={...r},a=a.replace&&!qt(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&&(c=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&&!qt(s))return s;qt(s)||(s=aU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.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 Wre=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,...c]=a.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=o.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},gU=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(p0(r),i),e[a]=o),o(n)}},qre=t=>(e,n,r)=>t(p0(n),r)(e);class Kre{constructor(e={}){this.logger=sl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?gU:qre;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()]=gU(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(c=>c.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,o)].join(this.formatSeparator)}return s.reduce((o,c)=>{const{formatName:u,formatOptions:d}=Wre(c);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 Xre=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Yre extends OS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=sl.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={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?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),c[f]===void 0&&(c[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(c)}}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(c=>{Ore(c.loaded,[s],a),Xre(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{o[u]||(o[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{o[u][f]===void 0&&(o[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,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)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>o(null,d)).catch(o):o(null,u)}catch(u){o(u)}return}return c(e,n,o)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();qt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),qt(n)&&(n=[n]);const 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 c={...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,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>o(null,f)).catch(o):o(null,d)}catch(d){o(d)}else u(e,n,r,i,o,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const xU=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),qt(t[1])&&(e.defaultValue=t[1]),qt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),bU=t=>(qt(t.ns)&&(t.ns=[t.ns]),qt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),qt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),fy=()=>{},Zre=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Wx extends OS{constructor(e={},n){if(super(),this.options=bU(e),this.services={},this.logger=sl,this.modules={external:[]},Zre(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(qt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=xU();this.options={...r,...this.options,...bU(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?sl.init(i(this.modules.logger),this.options):sl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Kre;const d=new hU(this.options);this.store=new uU(this.options.resources,this.options);const f=this.services;f.logger=sl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Vre(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 Gre(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Yre(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 S1(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=fy),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=sx(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),o}loadResources(e,n=fy){let r=n;const i=qt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const 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(c=>a(c)),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=sx();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=fy),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"&&bG.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=sx();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,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(o,(...u)=>this.t(...u))},a=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const c=qt(o)?o:o&&o[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(qt(o)?[o]:o);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{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 c;typeof a!="object"?c=this.options.overloadTranslationOptionHandler([s,a].concat(o)):c={...a},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(s)?d=s.map(f=>(typeof f=="function"&&(f=g3(f,{...this.options,...a})),`${c.keyPrefix}${u}${f}`)):(typeof s=="function"&&(s=g3(s,{...this.options,...a})),d=c.keyPrefix?`${c.keyPrefix}${u}${s}`:s),this.t(d,c)};return qt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(o,c)=>{const u=this.services.backendConnector.state[`${o}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const o=n.precheck(this,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=sx();return this.options.ns?(qt(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=sx();qt(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 hU(xU());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 Wx(e,n);return r.createInstance=Wx.createInstance,r}cloneInstance(e={},n=fy){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new Wx(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((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});s.store=new uU(o,i),s.services.resourceStore=s.store}return s.translator=new S1(s.services,i),s.translator.on("*",(o,...c)=>{s.emit(o,...c)}),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 Os=Wx.createInstance();Os.createInstance;Os.dir;Os.init;Os.loadResources;Os.reloadResources;Os.use;Os.changeLanguage;Os.getFixedT;Os.t;Os.exists;Os.setDefaultNamespace;Os.hasLoadedNamespace;Os.loadNamespaces;Os.loadLanguages;const Qre=(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);Ih(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},vU={},yG=(t,e,n,r)=>{Ih(n)&&vU[n]||(Ih(n)&&(vU[n]=new Date),Qre(t,e,n,r))},_G=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},x3=(t,e,n)=>{t.loadNamespaces(e,_G(t,n))},yU=(t,e,n,r)=>{if(Ih(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return x3(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,_G(t,r))},Jre=(t,e,n={})=>!e.languages||!e.languages.length?(yG(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}}),Ih=t=>typeof t=="string",eie=t=>typeof t=="object"&&t!==null,tie=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,nie={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},rie=t=>nie[t],iie=t=>t.replace(tie,rie);let b3={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:iie};const sie=(t={})=>{b3={...b3,...t}},aie=()=>b3;let wG;const oie=t=>{wG=t},lie=()=>wG,cie={type:"3rdParty",init(t){sie(t.options.react),oie(t)}},uie=M.createContext();class die{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var TA={exports:{}},CA={};var _U;function hie(){if(_U)return CA;_U=1;var t=Vm();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,c(y)&&v({inst:y})},[f,m,g]),i(function(){return c(y)&&v({inst:y}),f(function(){c(y)&&v({inst:y})})},[f]),a(m),m}function c(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 CA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,CA}var wU;function SG(){return wU||(wU=1,TA.exports=hie()),TA.exports}var ER=SG();const fie=(t,e)=>Ih(e)?e:eie(e)&&Ih(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,pie={t:fie,ready:!1},mie=()=>()=>{},Gm=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=M.useContext(uie)||{},s=n||r||lie();s&&!s.reportNamespaces&&(s.reportNamespaces=new die),s||yG(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const a=M.useMemo(()=>({...aie(),...s?.options?.react,...e}),[s,e]),{useSuspense:o,keyPrefix:c}=a,u=i||s?.options?.defaultNS,d=Ih(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 mie;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 pie;const C=!!(s.isInitialized||s.initializedStoreOnce)&&f.every(W=>Jre(W,s,a)),D=e.lng||s.language,F=g.current,j=x.current;if(j&&j.ready===C&&j.lng===D&&j.keyPrefix===c&&j.revision===F)return j;const R={t:s.getFixedT(D,a.nsMode==="fallback"?f:f[0],c),ready:C,lng:D,keyPrefix:c,revision:F};return x.current=R,R},[s,f,c,a,e.lng]),[v,b]=M.useState(0),{t:E,ready:S}=ER.useSyncExternalStore(m,y,y);M.useEffect(()=>{if(s&&!S&&!o){const C=()=>b(D=>D+1);e.lng?yU(s,e.lng,f,C):x3(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?yU(s,e.lng,f,D):x3(s,f,D)});return I},{slice:gie,forEach:xie}=[];function bie(t){return xie.call(gie.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function vie(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 SU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,yie=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(!SU.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!SU.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},EU={create(t,e,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=yie(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 _ie={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return EU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&EU.create(n,t,r,i,s)}},wie={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}},Sie={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 c=a[o].indexOf("=");c>0&&a[o].substring(0,c)===e&&(r=a[o].substring(c+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 Yf=null;const MU=()=>{if(Yf!==null)return Yf;try{if(Yf=typeof window<"u"&&window.localStorage!==null,!Yf)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Yf=!1}return Yf};var Eie={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&MU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&MU()&&window.localStorage.setItem(n,t)}};let Zf=null;const AU=()=>{if(Zf!==null)return Zf;try{if(Zf=typeof window<"u"&&window.sessionStorage!==null,!Zf)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Zf=!1}return Zf};var Mie={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&AU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&AU()&&window.sessionStorage.setItem(n,t)}},Aie={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}},Tie={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}},Cie={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}},Nie={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 EG=!1;try{document.cookie,EG=!0}catch{}const MG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];EG||MG.splice(1,1);const kie=()=>({order:MG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class AG{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=bie(n,this.options||{},kie()),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(_ie),this.addDetector(wie),this.addDetector(Eie),this.addDetector(Mie),this.addDetector(Aie),this.addDetector(Tie),this.addDetector(Cie),this.addDetector(Nie),this.addDetector(Sie)}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&&!vie(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)}))}}AG.type="languageDetector";const Pie={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app and which versions are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"IP addresses or location data",telemetryInfoNotItem2:"Printer names, serial numbers, or any printer data",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Rie={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},Die={en:{translation:Pie},de:{translation:Rie}};Os.use(AG).use(cie).init({resources:Die,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const TU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var CU="popstate";function Oie(t={}){function e(r,i){let{pathname:s,search:a,hash:o}=r.location;return v3("",{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:m0(i)}return Lie(e,n,null,t)}function yr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Uo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function jie(){return Math.random().toString(36).substring(2,10)}function NU(t,e){return{usr:t.state,key:t.key,idx:e}}function v3(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?Wm(e):e,state:n,key:e&&e.key||r||jie()}}function m0({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 Wm(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 Lie(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,o="POP",c=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,c&&c({action:o,location:y.location,delta:b})}function g(v,b){o="PUSH";let E=v3(y.location,v,b);u=d()+1;let S=NU(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&&c&&c({action:o,location:y.location,delta:1})}function m(v,b){o="REPLACE";let E=v3(y.location,v,b);u=d();let S=NU(E,u),A=y.createHref(E);a.replaceState(S,"",A),s&&c&&c({action:o,location:y.location,delta:0})}function x(v){return Iie(v)}let y={get action(){return o},get location(){return t(i,a)},listen(v){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(CU,f),c=v,()=>{i.removeEventListener(CU,f),c=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 Iie(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:m0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function TG(t,e,n="/"){return Uie(t,e,n,!1)}function Uie(t,e,n,r){let i=typeof e=="string"?Wm(e):e,s=Tc(i.pathname||"/",n);if(s==null)return null;let a=CG(t);Fie(a);let o=null;for(let c=0;o==null&&c<a.length;++c){let u=Yie(s);o=Kie(a[c],u,r)}return o}function CG(t,e=[],n=[],r="",i=!1){let s=(a,o,c=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)&&c)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=vc([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}".`),CG(a.children,e,g,f,c)),!(a.path==null&&!a.index)&&e.push({path:f,score:Wie(f,a.index),routesMeta:g})};return t.forEach((a,o)=>{if(a.path===""||!a.path?.includes("?"))s(a,o);else for(let c of NG(a.path))s(a,o,!0,c)}),e}function NG(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=NG(r.join("/")),o=[];return o.push(...a.map(c=>c===""?s:[s,c].join("/"))),i&&o.push(...a),o.map(c=>t.startsWith("/")&&c===""?"/":c)}function Fie(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:qie(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var zie=/^:[\w-]+$/,Bie=3,Hie=2,$ie=1,Vie=10,Gie=-2,kU=t=>t==="*";function Wie(t,e){let n=t.split("/"),r=n.length;return n.some(kU)&&(r+=Gie),e&&(r+=Hie),n.filter(i=>!kU(i)).reduce((i,s)=>i+(zie.test(s)?Bie:s===""?$ie:Vie),r)}function qie(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 Kie(t,e,n=!1){let{routesMeta:r}=t,i={},s="/",a=[];for(let o=0;o<r.length;++o){let c=r[o],u=o===r.length-1,d=s==="/"?e:e.slice(s.length)||"/",f=E1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=E1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),a.push({params:i,pathname:vc([s,f.pathname]),pathnameBase:tse(vc([s,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(s=vc([s,f.pathnameBase]))}return a}function E1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Xie(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 Xie(t,e=!1,n=!0){Uo(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,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function Yie(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Uo(!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 Tc(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 Zie=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qie=t=>Zie.test(t);function Jie(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Wm(t):t,s;if(n)if(Qie(n))s=n;else{if(n.includes("//")){let a=n;n=n.replace(/\/\/+/g,"/"),Uo(!1,`Pathnames cannot have embedded double slashes - normalizing ${a} -> ${n}`)}n.startsWith("/")?s=PU(n.substring(1),"/"):s=PU(n,e)}else s=e;return{pathname:s,search:nse(r),hash:rse(i)}}function PU(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 NA(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 ese(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function kG(t){let e=ese(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function PG(t,e,n,r=!1){let i;typeof t=="string"?i=Wm(t):(i={...t},yr(!i.pathname||!i.pathname.includes("?"),NA("?","pathname","search",i)),yr(!i.pathname||!i.pathname.includes("#"),NA("#","pathname","hash",i)),yr(!i.search||!i.search.includes("#"),NA("#","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 c=Jie(i,o),u=a&&a!=="/"&&a.endsWith("/"),d=(s||a===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var vc=t=>t.join("/").replace(/\/\/+/g,"/"),tse=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),nse=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,rse=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function ise(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 RG=["POST","PUT","PATCH","DELETE"];new Set(RG);var sse=["GET",...RG];new Set(sse);var qm=M.createContext(null);qm.displayName="DataRouter";var jS=M.createContext(null);jS.displayName="DataRouterState";M.createContext(!1);var DG=M.createContext({isTransitioning:!1});DG.displayName="ViewTransition";var ase=M.createContext(new Map);ase.displayName="Fetchers";var ose=M.createContext(null);ose.displayName="Await";var _l=M.createContext(null);_l.displayName="Navigation";var fb=M.createContext(null);fb.displayName="Location";var Bo=M.createContext({outlet:null,matches:[],isDataRoute:!1});Bo.displayName="Route";var MR=M.createContext(null);MR.displayName="RouteError";function lse(t,{relative:e}={}){yr(pb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=M.useContext(_l),{hash:i,pathname:s,search:a}=mb(t,{relative:e}),o=s;return n!=="/"&&(o=s==="/"?n:vc([n,s])),r.createHref({pathname:o,search:a,hash:i})}function pb(){return M.useContext(fb)!=null}function xd(){return yr(pb(),"useLocation() may be used only in the context of a <Router> component."),M.useContext(fb).location}var OG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function jG(t){M.useContext(_l).static||M.useLayoutEffect(t)}function AR(){let{isDataRoute:t}=M.useContext(Bo);return t?Sse():cse()}function cse(){yr(pb(),"useNavigate() may be used only in the context of a <Router> component.");let t=M.useContext(qm),{basename:e,navigator:n}=M.useContext(_l),{matches:r}=M.useContext(Bo),{pathname:i}=xd(),s=JSON.stringify(kG(r)),a=M.useRef(!1);return jG(()=>{a.current=!0}),M.useCallback((c,u={})=>{if(Uo(a.current,OG),!a.current)return;if(typeof c=="number"){n.go(c);return}let d=PG(c,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:vc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var use=M.createContext(null);function dse(t){let e=M.useContext(Bo).outlet;return M.useMemo(()=>e&&M.createElement(use.Provider,{value:t},e),[e,t])}function LG(){let{matches:t}=M.useContext(Bo),e=t[t.length-1];return e?e.params:{}}function mb(t,{relative:e}={}){let{matches:n}=M.useContext(Bo),{pathname:r}=xd(),i=JSON.stringify(kG(n));return M.useMemo(()=>PG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function hse(t,e){return IG(t,e)}function IG(t,e,n,r,i){yr(pb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=M.useContext(_l),{matches:a}=M.useContext(Bo),o=a[a.length-1],c=o?o.params:{},u=o?o.pathname:"/",d=o?o.pathnameBase:"/",f=o&&o.route;{let E=f&&f.path||"";UG(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=xd(),m;if(e){let E=typeof e=="string"?Wm(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=TG(t,{pathname:y});Uo(f||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Uo(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=xse(v&&v.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:vc([d,s.encodeLocation?s.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:vc([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(fb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},b):b}function fse(){let t=wse(),e=ise(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 pse=M.createElement(fse,null),mse=class extends M.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?M.createElement(Bo.Provider,{value:this.props.routeContext},M.createElement(MR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function gse({routeContext:t,match:e,children:n}){let r=M.useContext(qm);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),M.createElement(Bo.Provider,{value:t},n)}function xse(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,c=-1;if(n)for(let d=0;d<s.length;d++){let f=s[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=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,c>=0?s=s.slice(0,c+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||pse,o&&(c<0&&g===0?(UG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,v=null):c===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(gse,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:S})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?M.createElement(mse,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:E(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):E()},null)}function TR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bse(t){let e=M.useContext(qm);return yr(e,TR(t)),e}function vse(t){let e=M.useContext(jS);return yr(e,TR(t)),e}function yse(t){let e=M.useContext(Bo);return yr(e,TR(t)),e}function CR(t){let e=yse(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 _se(){return CR("useRouteId")}function wse(){let t=M.useContext(MR),e=vse("useRouteError"),n=CR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Sse(){let{router:t}=bse("useNavigate"),e=CR("useNavigate"),n=M.useRef(!1);return jG(()=>{n.current=!0}),M.useCallback(async(i,s={})=>{Uo(n.current,OG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var RU={};function UG(t,e,n){!e&&!RU[t]&&(RU[t]=!0,Uo(!1,n))}M.memo(Ese);function Ese({routes:t,future:e,state:n,unstable_onError:r}){return IG(t,void 0,n,r,e)}function Mse(t){return dse(t.context)}function fa(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 Ase({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1}){yr(!pb(),"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=Wm(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,m=M.useMemo(()=>{let x=Tc(c,a);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[a,c,u,d,f,g,r]);return Uo(m!=null,`<Router basename="${a}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:M.createElement(_l.Provider,{value:o},M.createElement(fb.Provider,{children:e,value:m}))}function Tse({children:t,location:e}){return hse(y3(t),e)}function y3(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,y3(r.props.children,s));return}yr(r.type===fa,`[${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=y3(r.props.children,s)),n.push(a)}),n}var Z_="get",Q_="application/x-www-form-urlencoded";function LS(t){return t!=null&&typeof t.tagName=="string"}function Cse(t){return LS(t)&&t.tagName.toLowerCase()==="button"}function Nse(t){return LS(t)&&t.tagName.toLowerCase()==="form"}function kse(t){return LS(t)&&t.tagName.toLowerCase()==="input"}function Pse(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Rse(t,e){return t.button===0&&(!e||e==="_self")&&!Pse(t)}var py=null;function Dse(){if(py===null)try{new FormData(document.createElement("form"),0),py=!1}catch{py=!0}return py}var Ose=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function kA(t){return t!=null&&!Ose.has(t)?(Uo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Q_}"`),null):t}function jse(t,e){let n,r,i,s,a;if(Nse(t)){let o=t.getAttribute("action");r=o?Tc(o,e):null,n=t.getAttribute("method")||Z_,i=kA(t.getAttribute("enctype"))||Q_,s=new FormData(t)}else if(Cse(t)||kse(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||o.getAttribute("action");if(r=c?Tc(c,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||Z_,i=kA(t.getAttribute("formenctype"))||kA(o.getAttribute("enctype"))||Q_,s=new FormData(o,t),!Dse()){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(LS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Z_,r=null,i=Q_,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 NR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Lse(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&&Tc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Ise(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 Use(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 Fse(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let a=await Ise(s,n);return a.links?a.links():[]}return[]}));return $se(r.flat(1).filter(Use).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function DU(t,e,n,r,i,s){let a=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,o=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return s==="assets"?e.filter((c,u)=>a(c,u)||o(c,u)):s==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(a(c,u)||o(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function zse(t,e,{includeHydrateFallback:n}={}){return Bse(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 Bse(t){return[...new Set(t)]}function Hse(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function $se(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(Hse(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function FG(){let t=M.useContext(qm);return NR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Vse(){let t=M.useContext(jS);return NR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var kR=M.createContext(void 0);kR.displayName="FrameworkContext";function zG(){let t=M.useContext(kR);return NR(t,"You must render this element inside a <HydratedRouter> element"),t}function Gse(t,e){let n=M.useContext(kR),[r,i]=M.useState(!1),[s,a]=M.useState(!1),{onFocus:o,onBlur:c,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:ax(o,m),onBlur:ax(c,x),onMouseEnter:ax(u,m),onMouseLeave:ax(d,x),onTouchStart:ax(f,m)}]:[!1,g,{}]}function ax(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Wse({page:t,...e}){let{router:n}=FG(),r=M.useMemo(()=>TG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?M.createElement(Kse,{page:t,matches:r,...e}):null}function qse(t){let{manifest:e,routeModules:n}=zG(),[r,i]=M.useState([]);return M.useEffect(()=>{let s=!1;return Fse(t,e,n).then(a=>{s||i(a)}),()=>{s=!0}},[t,e,n]),r}function Kse({page:t,matches:e,...n}){let r=xd(),{manifest:i,routeModules:s}=zG(),{basename:a}=FG(),{loaderData:o,matches:c}=Vse(),u=M.useMemo(()=>DU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=M.useMemo(()=>DU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=M.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,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=Lse(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(()=>zse(d,i),[d,i]),m=qse(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 Xse(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var BG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{BG&&(window.__reactRouterVersion="7.9.6")}catch{}function Yse({basename:t,children:e,window:n}){let r=M.useRef();r.current==null&&(r.current=Oie({window:n,v5Compat:!0}));let i=r.current,[s,a]=M.useState({action:i.action,location:i.location}),o=M.useCallback(c=>{M.startTransition(()=>a(c))},[a]);return M.useLayoutEffect(()=>i.listen(o),[i,o]),M.createElement(Ase,{basename:t,children:e,location:s.location,navigationType:s.action,navigator:i})}var HG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,IS=M.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:s,replace:a,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},m){let{basename:x}=M.useContext(_l),y=typeof u=="string"&&HG.test(u),v,b=!1;if(typeof u=="string"&&y&&(v=u,BG))try{let C=new URL(window.location.href),D=u.startsWith("//")?new URL(C.protocol+u):new URL(u),F=Tc(D.pathname,x);D.origin===C.origin&&F!=null?u=F+D.search+D.hash:b=!0}catch{Uo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=lse(u,{relative:i}),[S,A,T]=Gse(r,g),k=Jse(u,{replace:a,state:o,target:c,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:Xse(m,A),target:c,"data-discover":!y&&n==="render"?"true":void 0});return S&&!y?M.createElement(M.Fragment,null,I,M.createElement(Wse,{page:E})):I});IS.displayName="Link";var Rx=M.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:s,to:a,viewTransition:o,children:c,...u},d){let f=mb(a,{relative:u.relative}),g=xd(),m=M.useContext(jS),{navigator:x,basename:y}=M.useContext(_l),v=m!=null&&iae(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=Tc(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(IS,{...u,"aria-current":I,className:C,ref:d,style:D,to:a,viewTransition:o},typeof c=="function"?c(N):c)});Rx.displayName="NavLink";var Zse=M.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:a=Z_,action:o,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},m)=>{let x=nae(),y=rae(o,{relative:u}),v=a.toLowerCase()==="get"?"get":"post",b=typeof o=="string"&&HG.test(o),E=S=>{if(c&&c(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?c:E,...g,"data-discover":!b&&t==="render"?"true":void 0})});Zse.displayName="Form";function Qse(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $G(t){let e=M.useContext(qm);return yr(e,Qse(t)),e}function Jse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:a}={}){let o=AR(),c=xd(),u=mb(t,{relative:s});return M.useCallback(d=>{if(Rse(d,e)){d.preventDefault();let f=n!==void 0?n:m0(c)===m0(u);o(t,{replace:f,state:r,preventScrollReset:i,relative:s,viewTransition:a})}},[c,o,u,n,r,e,t,i,s,a])}var eae=0,tae=()=>`__${String(++eae)}__`;function nae(){let{router:t}=$G("useSubmit"),{basename:e}=M.useContext(_l),n=_se();return M.useCallback(async(r,i={})=>{let{action:s,method:a,encType:o,formData:c,body:u}=jse(r,e);if(i.navigate===!1){let d=i.fetcherKey||tae();await t.fetch(d,n,i.action||s,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||a,formEncType:i.encType||o,flushSync:i.flushSync})}else await t.navigate(i.action||s,{preventScrollReset:i.preventScrollReset,formData:c,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 rae(t,{relative:e}={}){let{basename:n}=M.useContext(_l),r=M.useContext(Bo);yr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...mb(t||".",{relative:e})},a=xd();if(t==null){s.search=a.search;let o=new URLSearchParams(s.search),c=o.getAll("index");if(c.some(d=>d==="")){o.delete("index"),c.filter(f=>f).forEach(f=>o.append("index",f));let d=o.toString();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:vc([n,s.pathname])),m0(s)}function iae(t,{relative:e}={}){let n=M.useContext(DG);yr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=$G("useViewTransitionState"),i=mb(t,{relative:e});if(!n.isTransitioning)return!1;let s=Tc(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=Tc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return E1(i.pathname,a)!=null||E1(i.pathname,s)!=null}var hc=gG();const sae=fo(hc);var Km=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},aae={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},oae=class{#e=aae;#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)}},hh=new oae;function lae(t){setTimeout(t,0)}var Uh=typeof window>"u"||"Deno"in globalThis;function Ss(){}function cae(t,e){return typeof t=="function"?t(e):t}function _3(t){return typeof t=="number"&&t>=0&&t!==1/0}function VG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Wu(t,e){return typeof t=="function"?t(e):t}function Wa(t,e){return typeof t=="function"?t(e):t}function OU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=t;if(a){if(r){if(e.queryHash!==PR(a,e.options))return!1}else if(!g0(e.queryKey,a))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||i&&i!==e.state.fetchStatus||s&&!s(e))}function jU(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(Fh(e.options.mutationKey)!==Fh(s))return!1}else if(!g0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function PR(t,e){return(e?.queryKeyHashFn||Fh)(t)}function Fh(t){return JSON.stringify(t,(e,n)=>w3(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function g0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>g0(t[n],e[n])):!1}var uae=Object.prototype.hasOwnProperty;function GG(t,e){if(t===e)return t;const n=LU(t)&&LU(e);if(!n&&!(w3(t)&&w3(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 c=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:uae.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[d]=g;continue}const m=GG(f,g);o[d]=m,m===f&&c++}return i===a&&c===i?t:o}function M1(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 LU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function w3(t){if(!IU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!IU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function IU(t){return Object.prototype.toString.call(t)==="[object Object]"}function dae(t){return new Promise(e=>{hh.setTimeout(e,t)})}function S3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?GG(t,e):e}function hae(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function fae(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var RR=Symbol();function WG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===RR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function qG(t,e){return typeof t=="function"?t(...e):!!t}var pae=class extends Km{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Uh&&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"}},DR=new pae;function E3(){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 mae=lae;function gae(){let t=[],e=0,n=o=>{o()},r=o=>{o()},i=mae;const s=o=>{e?t.push(o):i(()=>{n(o)})},a=()=>{const o=t;t=[],o.length&&i(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;e++;try{c=o()}finally{e--,e||a()}return c},batchCalls:o=>(...c)=>{s(()=>{o(...c)})},schedule:s,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var hi=gae(),xae=class extends Km{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Uh&&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}},A1=new xae;function bae(t){return Math.min(1e3*2**t,3e4)}function KG(t){return(t??"online")==="online"?A1.isOnline():!0}var M3=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function XG(t){let e=!1,n=0,r;const i=E3(),s=()=>i.status!=="pending",a=y=>{if(!s()){const v=new M3(y);g(v),t.onCancel?.(v)}},o=()=>{e=!0},c=()=>{e=!1},u=()=>DR.isFocused()&&(t.networkMode==="always"||A1.isOnline())&&t.canRun(),d=()=>KG(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??(Uh?0:3),S=t.retryDelay??bae,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),dae(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:c,canStart:d,start:()=>(d()?x():m().then(x),i)}}var YG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),_3(this.gcTime)&&(this.#e=hh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Uh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(hh.clearTimeout(this.#e),this.#e=void 0)}},vae=class extends YG{#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=FU(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=FU(this.options);e.data!==void 0&&(this.setState(UU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=S3(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(Ss).catch(Ss):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Wa(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===RR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Wu(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:!VG(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(c=>c.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=WG(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=XG({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof M3&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,c)=>{this.#s({type:"failed",failureCount:o,error:c})},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 M3){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,...ZG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...UU(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),hi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function ZG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:KG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function UU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function FU(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 yae=class extends Km{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#o=E3(),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),zU(this.#t,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return A3(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return A3(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 Wa(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&&!M1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&BU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Wa(this.options.enabled,this.#t)!==Wa(e.enabled,this.#t)||Wu(this.options.staleTime,this.#t)!==Wu(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Wa(this.options.enabled,this.#t)!==Wa(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 wae(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(Ss)),e}#g(){this.#y();const t=Wu(this.options.staleTime,this.#t);if(Uh||this.#i.isStale||!_3(t))return;const n=VG(this.#i.dataUpdatedAt,t)+1;this.#c=hh.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,!(Uh||Wa(this.options.enabled,this.#t)===!1||!_3(this.#l)||this.#l===0)&&(this.#u=hh.setInterval(()=>{(this.options.refetchIntervalInBackground||DR.isFocused())&&this.#d()},this.#l))}#v(){this.#g(),this.#b(this.#x())}#y(){this.#c&&(hh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(hh.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,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const I=this.hasListeners(),C=!I&&zU(t,e),D=I&&BU(t,n,e,r);(C||D)&&(d={...d,...ZG(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=S3(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=S3(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>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!E,isLoadingError:S&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:S&&T,isStale:OR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Wa(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=E3();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),M1(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){hi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function _ae(t,e){return Wa(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function zU(t,e){return _ae(t,e)||t.state.data!==void 0&&A3(t,e,e.refetchOnMount)}function A3(t,e,n){if(Wa(e.enabled,t)!==!1&&Wu(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&OR(t,e)}return!1}function BU(t,e,n,r){return(t!==e||Wa(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&OR(t,n)}function OR(t,e){return Wa(e.enabled,t)!==!1&&t.isStaleByTime(Wu(e.staleTime,t))}function wae(t,e){return!M1(t.getCurrentResult(),e)}function HU(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:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=WG(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?fae:hae;return{pages:T(x.pages,S,A),pageParams:T(x.pageParams,y,A)}};if(i&&s.length){const x=i==="backward",y=x?Sae:$U,v={pages:s,pageParams:a},b=y(r,v);o=await m(v,b,x)}else{const x=t??s.length;do{const y=c===0?a[0]??r.initialPageParam:$U(r,o);if(c>0&&y==null)break;o=await m(o,y),c++}while(c<x)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function $U(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 Sae(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Eae=class extends YG{#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||QG(),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=XG({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),hi.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function QG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Mae=class extends Km{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const r=new Eae({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=my(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=my(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=my(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=my(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){hi.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>jU(e,n))}findAll(t={}){return this.getAll().filter(e=>jU(t,e))}notify(t){hi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return hi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ss))))}};function my(t){return t.options.scope?.id}var Aae=class extends Km{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),M1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Fh(n.mutationKey)!==Fh(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??QG();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){hi.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},Tae=class extends Km{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??PR(r,e);let s=this.get(i);return s||(s=new vae({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(){hi.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>OU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>OU(t,n)):e}notify(t){hi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){hi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){hi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Cae=class{#e;#t;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#e=t.queryCache||new Tae,this.#t=t.mutationCache||new Mae,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=DR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=A1.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(Wu(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=cae(e,s);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(t,e,n){return hi.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;hi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return hi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=hi.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ss).catch(Ss)}invalidateQueries(t,e={}){return hi.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=hi.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Ss)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Ss)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Wu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ss).catch(Ss)}fetchInfiniteQuery(t){return t.behavior=HU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ss).catch(Ss)}ensureInfiniteQueryData(t){return t.behavior=HU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return A1.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(Fh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{g0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Fh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{g0(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=PR(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===RR&&(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()}},JG=M.createContext(void 0),Mn=t=>{const e=M.useContext(JG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Nae=({client:t,children:e})=>(M.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(JG.Provider,{value:t,children:e})),e7=M.createContext(!1),kae=()=>M.useContext(e7);e7.Provider;function Pae(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Rae=M.createContext(Pae()),Dae=()=>M.useContext(Rae),Oae=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},jae=t=>{M.useEffect(()=>{t.clearReset()},[t])},Lae=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||qG(n,[t.error,r])),Iae=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))}},Uae=(t,e)=>t.isLoading&&t.isFetching&&!e,Fae=(t,e)=>t?.suspense&&e.isPending,VU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function zae(t,e,n){const r=kae(),i=Dae(),s=Mn(),a=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=r?"isRestoring":"optimistic",Iae(a),Oae(a,i),jae(i);const o=!s.getQueryCache().get(a.queryHash),[c]=M.useState(()=>new e(s,a)),u=c.getOptimisticResult(a),d=!r&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(f=>{const g=d?c.subscribe(hi.batchCalls(f)):Ss;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),M.useEffect(()=>{c.setOptions(a)},[a,c]),Fae(a,u))throw VU(a,c,i);if(Lae({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&&!Uh&&Uae(u,r)&&(o?VU(a,c,i):s.getQueryCache().get(a.queryHash)?.promise)?.catch(Ss).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?u:c.trackResult(u)}function yt(t,e){return zae(t,yae)}function wt(t,e){const n=Mn(),[r]=M.useState(()=>new Aae(n,t));M.useEffect(()=>{r.setOptions(t)},[r,t]);const i=M.useSyncExternalStore(M.useCallback(a=>r.subscribe(hi.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=M.useCallback((a,o)=>{r.mutate(a,o).catch(Ss)},[r]);if(i.error&&qG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const Bae=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Hae=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),GU=t=>{const e=Hae(t);return e.charAt(0).toUpperCase()+e.slice(1)},t7=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),$ae=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Vae={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 Gae=M.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:a,...o},c)=>M.createElement("svg",{ref:c,...Vae,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:t7("lucide",i),...!s&&!$ae(o)&&{"aria-hidden":"true"},...o},[...a.map(([u,d])=>M.createElement(u,d)),...Array.isArray(s)?s:[s]]));const qe=(t,e)=>{const n=M.forwardRef(({className:r,...i},s)=>M.createElement(Gae,{ref:s,iconNode:e,className:t7(`lucide-${Bae(GU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=GU(t),n};const Wae=[["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"}]],_h=qe("archive",Wae);const qae=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],x0=qe("arrow-down",qae);const Kae=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],T3=qe("arrow-right",Kae);const Xae=[["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"}]],Yae=qe("arrow-up-down",Xae);const Zae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],hm=qe("arrow-up",Zae);const Qae=[["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"}]],wh=qe("bell",Qae);const Jae=[["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"}]],eoe=qe("bold",Jae);const toe=[["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"}]],noe=qe("book",toe);const roe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],ioe=qe("bookmark",roe);const soe=[["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"}]],fm=qe("box",soe);const aoe=[["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"}]],ooe=qe("cable",aoe);const loe=[["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"}]],coe=qe("calendar-days",loe);const uoe=[["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"}]],Zr=qe("calendar",uoe);const doe=[["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"}]],b0=qe("camera",doe);const hoe=[["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"}]],foe=qe("chart-column",hoe);const poe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],zh=qe("check",poe);const moe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],uf=qe("chevron-down",moe);const goe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],df=qe("chevron-right",goe);const xoe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bh=qe("chevron-left",xoe);const boe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],US=qe("chevron-up",boe);const voe=[["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"}]],lo=qe("circle-alert",voe);const yoe=[["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"}]],PA=qe("circle-arrow-up",yoe);const _oe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],fi=qe("circle-check-big",_oe);const woe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Soe=qe("circle-check",woe);const Eoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Moe=qe("circle-dot",Eoe);const Aoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Toe=qe("circle-stop",Aoe);const Coe=[["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"}]],ga=qe("circle-x",Coe);const Noe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_r=qe("clock",Noe);const koe=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],FS=qe("cloud",koe);const Poe=[["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"}]],Roe=qe("code-xml",Poe);const Doe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],n7=qe("code",Doe);const Ooe=[["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"}]],joe=qe("coffee",Ooe);const Loe=[["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"}]],Ioe=qe("cog",Loe);const Uoe=[["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"}]],Foe=qe("compass",Uoe);const zoe=[["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"}]],Hh=qe("copy",zoe);const Boe=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],gy=qe("cpu",Boe);const Hoe=[["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"}]],pm=qe("database",Hoe);const $oe=[["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"}]],C3=qe("dollar-sign",$oe);const Voe=[["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"}]],Ma=qe("download",Voe);const Goe=[["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"}]],jR=qe("droplet",Goe);const Woe=[["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"}]],r7=qe("droplets",Woe);const qoe=[["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"}]],i7=qe("ellipsis-vertical",qoe);const Koe=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],RA=qe("equal",Koe);const Xoe=[["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"}]],Aa=qe("external-link",Xoe);const Yoe=[["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"}]],LR=qe("eye-off",Yoe);const Zoe=[["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"}]],mm=qe("eye",Zoe);const Qoe=[["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"}]],Joe=qe("fan",Qoe);const ele=[["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"}]],tle=qe("file-box",ele);const nle=[["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"}]],WU=qe("file-code",nle);const rle=[["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"}]],ile=qe("file-exclamation-point",rle);const sle=[["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"}]],T1=qe("file-spreadsheet",sle);const ale=[["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"}]],to=qe("file-text",ale);const ole=[["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"}]],s7=qe("file",ole);const lle=[["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"}]],Zp=qe("film",lle);const cle=[["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"}]],ule=qe("flame",cle);const dle=[["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"}]],qu=qe("folder-kanban",dle);const hle=[["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"}]],fle=qe("folder-open",hle);const ple=[["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"}]],a7=qe("folder",ple);const mle=[["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"}]],IR=qe("funnel",mle);const gle=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],UR=qe("gauge",gle);const xle=[["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"}]],ble=qe("gift",xle);const vle=[["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"}]],Qp=qe("git-compare",vle);const yle=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],qU=qe("github",yle);const _le=[["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"}]],v0=qe("globe",_le);const wle=[["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"}]],y0=qe("grip-vertical",wle);const Sle=[["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"}]],FR=qe("hard-drive",Sle);const Ele=[["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"}]],Mle=qe("heart",Ele);const Ale=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],N3=qe("history",Ale);const Tle=[["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"}]],Cle=qe("house",Tle);const Nle=[["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"}]],gb=qe("image",Nle);const kle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],_0=qe("info",kle);const Ple=[["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"}]],Rle=qe("italic",Ple);const Dle=[["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"}]],Vp=qe("key",Dle);const Ole=[["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"}]],k3=qe("keyboard",Ole);const jle=[["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"}]],$h=qe("layers",jle);const Lle=[["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"}]],o7=qe("layout-grid",Lle);const Ile=[["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"}]],Ule=qe("layout-list",Ile);const Fle=[["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"}]],zle=qe("link-2-off",Fle);const Ble=[["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"}]],P3=qe("link-2",Ble);const Hle=[["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"}]],zS=qe("link",Hle);const $le=[["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"}]],l7=qe("list-ordered",$le);const Vle=[["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"}]],Gle=qe("list-todo",Vle);const Wle=[["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"}]],zR=qe("list",Wle);const qle=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],At=qe("loader-circle",qle);const Kle=[["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"}]],KU=qe("log-in",Kle);const Xle=[["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"}]],Yle=qe("log-out",Xle);const Zle=[["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"}]],Qle=qe("mail",Zle);const Jle=[["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"}]],ece=qe("map",Jle);const tce=[["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"}]],nce=qe("maximize-2",tce);const rce=[["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"}]],ice=qe("maximize",rce);const sce=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],ace=qe("memory-stick",sce);const oce=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],lce=qe("menu",oce);const cce=[["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"}]],uce=qe("minimize-2",cce);const dce=[["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"}]],hce=qe("minimize",dce);const fce=[["path",{d:"M5 12h14",key:"1ays0h"}]],R3=qe("minus",fce);const pce=[["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"}]],C1=qe("moon",pce);const mce=[["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"}]],gce=qe("music",mce);const xce=[["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"}]],w0=qe("package",xce);const bce=[["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"}]],c7=qe("palette",bce);const vce=[["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"}]],yce=qe("pause",vce);const _ce=[["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"}]],S0=qe("pen-line",_ce);const wce=[["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"}]],BR=qe("pen",wce);const Sce=[["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"}]],rd=qe("pencil",Sce);const Ece=[["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=qe("phone",Ece);const Ace=[["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"}]],BS=qe("play",Ace);const Tce=[["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"}]],Jp=qe("plug",Tce);const Cce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pr=qe("plus",Cce);const Nce=[["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"}]],HR=qe("power-off",Nce);const kce=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],bd=qe("power",kce);const Pce=[["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"}]],Ta=qe("printer",Pce);const Rce=[["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"}]],Dce=qe("qr-code",Rce);const Oce=[["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"}]],Cs=qe("refresh-cw",Oce);const jce=[["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"}]],Xm=qe("rotate-ccw",jce);const Lce=[["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"}]],Ice=qe("ruler",Lce);const Uce=[["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"}]],Ro=qe("save",Uce);const Fce=[["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"}]],zce=qe("scan-search",Fce);const Bce=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],id=qe("search",Bce);const Hce=[["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"}]],$R=qe("send",Hce);const $ce=[["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"}]],th=qe("server",$ce);const Vce=[["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"}]],HS=qe("settings-2",Vce);const Gce=[["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"}]],VR=qe("settings",Gce);const Wce=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],qce=qe("shield",Wce);const Kce=[["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"}]],Xce=qe("shopping-cart",Kce);const Yce=[["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=qe("signal",Yce);const Qce=[["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"}]],Jce=qe("skip-back",Qce);const eue=[["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"}]],N1=qe("skip-forward",eue);const tue=[["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"}]],XU=qe("sliders-vertical",tue);const nue=[["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"}]],E0=qe("sparkles",nue);const rue=[["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"}]],Vh=qe("square-check-big",rue);const iue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],gm=qe("square",iue);const sue=[["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"}]],xm=qe("star",sue);const aue=[["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"}]],u7=qe("sticky-note",aue);const oue=[["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"}]],YU=qe("sun",oue);const lue=[["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"}]],M0=qe("tag",lue);const cue=[["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"}]],d7=qe("target",cue);const uue=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],h7=qe("terminal",uue);const due=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],hue=qe("text-align-center",due);const fue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],pue=qe("text-align-end",fue);const mue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],gue=qe("text-align-start",mue);const xue=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Sh=qe("thermometer",xue);const bue=[["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"}]],Fu=qe("timer",bue);const vue=[["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"}]],Rn=qe("trash-2",vue);const yue=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],f7=qe("trending-down",yue);const _ue=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],p7=qe("trending-up",_ue);const wue=[["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"}]],ti=qe("triangle-alert",wue);const Sue=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Eue=qe("underline",Sue);const Mue=[["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"}]],m7=qe("unlink",Mue);const Aue=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ya=qe("upload",Aue);const Tue=[["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"}]],D3=qe("user",Tue);const Cue=[["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"}]],Nue=qe("users",Cue);const kue=[["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"}]],g7=qe("video",kue);const Pue=[["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"}]],GR=qe("wifi-off",Pue);const Rue=[["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"}]],x7=qe("wifi",Rue);const Due=[["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"}]],Oue=qe("wind",Due);const jue=[["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"}]],sd=qe("wrench",jue);const Lue=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=qe("x",Lue);const Iue=[["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"}]],Uue=qe("zoom-in",Iue);const Fue=[["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"}]],bm=qe("zap",Fue);const zue=[["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"}]],Bue=qe("zoom-out",zue),b7=M.createContext(void 0);function Hue({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 l.jsx(b7.Provider,{value:{theme:e,toggleTheme:r,setTheme:i},children:t})}function xb(){const t=M.useContext(b7);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function Nt({children:t,className:e="",onClick:n,onContextMenu:r}){return l.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:r,children:t})}function $s({children:t,className:e=""}){return l.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Rt({children:t,className:e=""}){return l.jsx("div",{className:`p-6 ${e}`,children:t})}function $ue(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 ZU({children:t}){return l.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function Vue({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Gm(),i=$ue(n,e,r);return M.useEffect(()=>{const s=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(k3,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(s=>l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:s.category}),l.jsx("div",{className:"space-y-2",children:s.items.map(a=>l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[a.description,a.isExternal&&l.jsx(Aa,{className:"w-3 h-3 text-bambu-gray"})]}),l.jsx("div",{className:"flex gap-1",children:a.keys.map(o=>l.jsx(ZU,{children:o},o))})]},a.description))})]},s.category))}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",l.jsx(ZU,{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 ke={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}`),getSystemInfo:()=>tt("/system/info")},v7=[{name:"globe",icon:v0},{name:"link",icon:zS},{name:"external-link",icon:Aa},{name:"book",icon:noe},{name:"file-text",icon:to},{name:"home",icon:Cle},{name:"star",icon:xm},{name:"heart",icon:Mle},{name:"bookmark",icon:ioe},{name:"shopping-cart",icon:Xce},{name:"music",icon:gce},{name:"video",icon:g7},{name:"image",icon:gb},{name:"camera",icon:b0},{name:"map",icon:ece},{name:"compass",icon:Foe},{name:"coffee",icon:joe},{name:"gift",icon:ble},{name:"wrench",icon:sd},{name:"zap",icon:bm},{name:"cloud",icon:FS},{name:"database",icon:pm},{name:"folder",icon:a7},{name:"mail",icon:Qle},{name:"phone",icon:Mce},{name:"user",icon:D3},{name:"users",icon:Nue},{name:"server",icon:th},{name:"terminal",icon:h7},{name:"code",icon:n7}];function $S(t){return v7.find(n=>n.name===t)?.icon||zS}function Gue({value:t,onChange:e}){const[n,r]=M.useState(!1),i=$S(t);return l.jsxs("div",{className:"relative",children:[l.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[l.jsx(i,{className:"w-5 h-5"}),l.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),l.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:l.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:v7.map(({name:s,icon:a})=>l.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:l.jsx(a,{className:"w-5 h-5"})},s))})})]})]})}const QU=768;function y7(){const[t,e]=M.useState(()=>typeof window<"u"?window.innerWidth<QU:!1);return M.useEffect(()=>{const n=window.matchMedia(`(max-width: ${QU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const A0=[{id:"printers",to:"/",icon:Ta,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:_h,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Zr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:foe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:FS,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:sd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:qu,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:VR,labelKey:"nav.settings"}];function Wue(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return A0.map(e=>e.id)}return A0.map(e=>e.id)}function que(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function DA(t){return t.startsWith("ext-")}function _7(){return localStorage.getItem("defaultView")||"/"}function Kue(t){localStorage.setItem("defaultView",t)}function Xue(){const t=AR(),e=xd(),{theme:n,toggleTheme:r}=xb(),{t:i}=Gm(),s=y7(),[a,o]=M.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=M.useState(!1),[d,f]=M.useState(!1),[g,m]=M.useState(Wue),[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:ke.getVersion,staleTime:1/0}),{data:k}=yt({queryKey:["settings"],queryFn:ke.getSettings,staleTime:300*1e3}),{data:N}=yt({queryKey:["updateCheck"],queryFn:ke.checkForUpdates,enabled:k?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:I}=yt({queryKey:["external-links"],queryFn:ke.getExternalLinks}),C=new Map(A0.map(Q=>[Q.id,Q])),D=new Map((I||[]).map(Q=>[`ext-${Q.id}`,Q])),F=(()=>{const Q=[],U=new Set;for(const z of g)(C.has(z)||D.has(z))&&(Q.push(z),U.add(z));for(const z of A0)U.has(z.id)||(Q.push(z.id),U.add(z.id));for(const z of I||[]){const J=`ext-${z.id}`;U.has(J)||(Q.push(J),U.add(J))}return Q})(),j=(Q,U)=>{y(U),Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("text/plain",U)},q=(Q,U)=>{Q.preventDefault(),Q.dataTransfer.dropEffect="move",b(U)},R=()=>{b(null)},W=(Q,U)=>{if(Q.preventDefault(),x===null||x===U){y(null),b(null);return}const z=[...F],J=z.indexOf(x),se=z.indexOf(U);if(J===-1||se===-1){y(null),b(null);return}z.splice(J,1),z.splice(se,0,x),m(z),que(z),y(null),b(null)},K=()=>{y(null),b(null)},V=N?.update_available&&N.latest_version&&N.latest_version!==S,ee=()=>{N?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",N.latest_version),A(N.latest_version))};M.useEffect(()=>{if(!E.current&&e.pathname==="/"){const Q=_7();Q!=="/"&&(E.current=!0,t(Q,{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(Q=>{const U=Q.target;if(!(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable)&&!Q.metaKey&&!Q.ctrlKey&&!Q.altKey){const z=parseInt(Q.key);if(z>=1&&z<=F.length&&z<=9){const J=F[z-1];if(Q.preventDefault(),DA(J)){const se=J.replace("ext-","");t(`/external/${se}`)}else{const se=C.get(J);se&&t(se.to)}return}switch(Q.key){case"?":Q.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,F,C]);return M.useEffect(()=>(document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)),[Y]),l.jsxs("div",{className:"flex min-h-screen",children:[s&&l.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[l.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:l.jsx(lce,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),s&&c&&l.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),l.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${s?`fixed inset-y-0 left-0 z-50 w-72 transform ${c?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${a?"w-64":"w-16"}`}`,children:[l.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||a?"p-4":"p-2"}`,children:l.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"})}),l.jsx("nav",{className:"flex-1 p-2",children:l.jsx("ul",{className:"space-y-2",children:F.map(Q=>{if(DA(Q)){const z=D.get(Q);if(!z)return null;const J=z.custom_icon?null:$S(z.icon);return l.jsx("li",{draggable:!0,onDragStart:se=>j(se,Q),onDragOver:se=>q(se,Q),onDragLeave:R,onDrop:se=>W(se,Q),onDragEnd:K,className:`relative ${x===Q?"opacity-50":""} ${v===Q&&x!==Q?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Rx,{to:`/external/${z.id}`,className:({isActive:se})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${se?"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&&l.jsx(y0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),z.custom_icon?l.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"}`}):J&&l.jsx(J,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&l.jsx("span",{children:z.name})]})},Q)}else{const z=C.get(Q);if(!z)return null;const{to:J,icon:se,labelKey:me}=z;return l.jsx("li",{draggable:!0,onDragStart:fe=>j(fe,Q),onDragOver:fe=>q(fe,Q),onDragLeave:R,onDrop:fe=>W(fe,Q),onDragEnd:K,className:`relative ${x===Q?"opacity-50":""} ${v===Q&&x!==Q?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:l.jsxs(Rx,{to:J,className:({isActive:fe})=>`flex items-center ${s||a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${fe?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!a?i(me):void 0,children:[a&&!s&&l.jsx(y0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),l.jsx(se,{className:"w-5 h-5 flex-shrink-0"}),(s||a)&&l.jsx("span",{children:i(me)})]})},Q)}})})}),!s&&l.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?l.jsx(Bh,{className:"w-5 h-5"}):l.jsx(df,{className:"w-5 h-5"})}),l.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||a?l.jsxs("div",{className:"flex items-center justify-between px-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),N?.update_available&&l.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:N.latest_version}),children:[l.jsx(PA,{className:"w-4 h-4"}),l.jsx("span",{children:i("nav.update")})]})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(Rx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(_0,{className:"w-5 h-5"})}),l.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:l.jsx(qU,{className:"w-5 h-5"})}),l.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:l.jsx(k3,{className:"w-5 h-5"})}),l.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?l.jsx(YU,{className:"w-5 h-5"}):l.jsx(C1,{className:"w-5 h-5"})})]})]}):l.jsxs("div",{className:"flex flex-col items-center gap-1",children:[N?.update_available&&l.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:N.latest_version}),children:l.jsx(PA,{className:"w-5 h-5"})}),l.jsx(Rx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:l.jsx(_0,{className:"w-5 h-5"})}),l.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:l.jsx(qU,{className:"w-5 h-5"})}),l.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:l.jsx(k3,{className:"w-5 h-5"})}),l.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?l.jsx(YU,{className:"w-5 h-5"}):l.jsx(C1,{className:"w-5 h-5"})})]})})]}),l.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":a?"ml-64":"ml-16"}`,children:[V&&l.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(PA,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{children:i("nav.updateAvailableBanner",{version:N?.latest_version,defaultValue:`Version ${N?.latest_version} is available!`})}),l.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),l.jsx("button",{onClick:ee,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsx(Mse,{})]}),d&&l.jsx(Vue,{onClose:()=>f(!1),sidebarItems:F.map(Q=>{if(DA(Q)){const U=D.get(Q);return U?{type:"external",label:U.name}:null}else{const U=C.get(Q);return U?{type:"nav",label:U.labelKey,labelKey:U.labelKey}:null}}).filter(Boolean)})]})}function Le({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 l.jsx("button",{className:`${s} ${a[t]} ${o[e]} ${n}`,...i,children:r})}function Qr({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 c={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-start gap-4",children:[l.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:l.jsx(ti,{className:"w-6 h-6"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),l.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),l.jsxs("div",{className:"flex gap-3 mt-6",children:[l.jsx(Le,{variant:"secondary",onClick:a,className:"flex-1",children:r}),l.jsx(Le,{onClick:s,className:`flex-1 ${c.button}`,children:n})]})]})})})}const w7=M.createContext(void 0);function si(){const t=M.useContext(w7);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Yue={success:l.jsx(fi,{className:"w-5 h-5 text-green-400"}),error:l.jsx(ga,{className:"w-5 h-5 text-red-400"}),warning:l.jsx(lo,{className:"w-5 h-5 text-yellow-400"}),info:l.jsx(_0,{className:"w-5 h-5 text-blue-400"}),loading:l.jsx(At,{className:"w-5 h-5 text-bambu-green animate-spin"})},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",loading:"bg-bambu-green/10 border-bambu-green/30"};function Que({children:t}){const[e,n]=M.useState([]),r=M.useCallback((a,o="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:a,type:o}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=M.useCallback((a,o,c="info")=>{n(u=>u.find(f=>f.id===a)?u.map(f=>f.id===a?{...f,message:o,type:c,persistent:!0}:f):[...u,{id:a,message:o,type:c,persistent:!0}])},[]),s=M.useCallback(a=>{n(o=>o.filter(c=>c.id!==a))},[]);return l.jsxs(w7.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:s},children:[t,l.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(a=>l.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Zue[a.type]}`,children:[Yue[a.type],l.jsx("span",{className:"text-white text-sm",children:a.message}),l.jsx("button",{onClick:()=>s(a.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]},a.id))})]})}function Jue(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 JU(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 ede(t,e){if(e)return a7;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return tle;case"gcode":return to;case"mp4":case"avi":return Zp;case"png":case"jpg":case"jpeg":return gb;default:return s7}}function tde({printerId:t,printerName:e,onClose:n}){const{showToast:r}=si(),i=Mn(),[s,a]=M.useState("/"),[o,c]=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:()=>ke.getPrinterFiles(t,s)}),{data:v}=yt({queryKey:["printerStorage",t],queryFn:()=>ke.getPrinterStorage(t),staleTime:3e4}),b=wt({mutationFn:N=>ke.deletePrinterFile(t,N),onSuccess:(N,I)=>{r(`Deleted: ${I.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:N=>{r(`Delete failed: ${N.message}`,"error")}}),E=N=>{a(N),c(null)},S=()=>{if(s==="/")return;const N=s.split("/").filter(Boolean);N.pop(),a(N.length?"/"+N.join("/"):"/"),c(null)},A=N=>{window.open(ke.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 l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[l.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:N=>N.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(FR,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[v&&(v.used_bytes!=null||v.free_bytes!=null)&&l.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[v.used_bytes!=null&&l.jsxs("span",{children:["Used: ",JU(v.used_bytes)]}),v.used_bytes!=null&&v.free_bytes!=null&&l.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),v.free_bytes!=null&&l.jsxs("span",{children:["Free: ",JU(v.free_bytes)]})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),l.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[k.map(N=>l.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)),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"relative",children:[l.jsx(id,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange: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"})]}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:x,children:l.jsx(Cs,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[l.jsx("button",{onClick:S,disabled:s==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:l.jsx(Bh,{className:"w-4 h-4"})}),l.jsx("span",{className:"text-bambu-gray font-mono",children:s})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?l.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=ede(N.name,N.is_directory),C=o===N.path;return l.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):c(C?null:N.path)},children:[l.jsx(I,{className:`w-5 h-5 flex-shrink-0 ${N.is_directory?"text-bambu-green":"text-bambu-gray"}`}),l.jsx("span",{className:"flex-1 text-white truncate",children:N.name}),!N.is_directory&&l.jsx("span",{className:"text-sm text-bambu-gray",children:Jue(N.size)}),N.is_directory&&l.jsx(Bh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${m?.files?.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{variant:"secondary",disabled:!o,onClick:()=>o&&A(o),children:[l.jsx(Ma,{className:"w-4 h-4"}),"Download"]}),l.jsxs(Le,{variant:"secondary",disabled:!o||b.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[b.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&l.jsx(Qr,{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 nde({printerId:t,printerName:e,onClose:n}){const r=Mn(),[i,s]=M.useState(!0),[a,o]=M.useState(new Set),[c,u]=M.useState(""),[d,f]=M.useState("all"),g=M.useRef(null),{data:m,isLoading:x,refetch:y}=yt({queryKey:["mqtt-logs",t],queryFn:()=>ke.getMQTTLogs(t),refetchInterval:1e3}),v=wt({mutationFn:()=>ke.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=wt({mutationFn:()=>ke.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=wt({mutationFn:()=>ke.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(c.trim()){const D=c.toLowerCase(),F=C.topic.toLowerCase().includes(D),q=JSON.stringify(C.payload).toLowerCase().includes(D);return F||q}return!0}),[N,c,d]);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[k?l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[l.jsx(gm,{className:"w-4 h-4"}),"Stop"]}):l.jsxs(Le,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[l.jsx(BS,{className:"w-4 h-4"}),"Start Logging"]}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||N.length===0,children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:l.jsx(Cs,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),l.jsx("div",{className:"flex-1"}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:i,onChange:C=>s(C.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:[I.length,"/",N.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(id,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange: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"}),c&&l.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),l.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[l.jsx(x0,{className:"w-3 h-3"}),"In"]}),l.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[l.jsx(hm,{className:"w-3 h-3"}),"Out"]})]})]})]}),l.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:N.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!k&&l.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):I.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[l.jsx("p",{className:"mb-2",children:"No messages match your filter"}),l.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):l.jsx("div",{className:"space-y-1",children:I.map((C,D)=>{const F=a.has(D),j=C.direction==="in";return l.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>S(D),children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx("span",{className:"text-bambu-gray shrink-0",children:A(C.timestamp)}),l.jsx("span",{className:`shrink-0 ${j?"text-blue-400":"text-green-400"}`,title:j?"Incoming":"Outgoing",children:j?l.jsx(x0,{className:"w-3 h-3"}):l.jsx(hm,{className:"w-3 h-3"})}),l.jsx("span",{className:"text-purple-400 shrink-0",children:C.topic})]}),F?l.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(C.payload,!0)}):l.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(C.payload,!1)})]},D)})})}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("div",{className:"text-sm text-bambu-gray",children:k?l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):l.jsx("span",{children:"Logging stopped"})}),l.jsx(Le,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const rde={"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 ide(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:ti};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:ti};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:lo};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:_0}}}function S7(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(),c=(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}_${c}${u}`}function sde(t,e,n){const r=S7(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${r}`}function ade({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]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ti,{className:"w-5 h-5 text-orange-400"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),l.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(lo,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{children:"No HMS errors"})]}):l.jsx("div",{className:"space-y-3",children:e.map((r,i)=>{const{label:s,color:a,bgColor:o,Icon:c}=ide(r.severity),u=parseInt(r.code.replace("0x",""),16)||0,d=S7(r.attr,u),f=rde[d]||"Unknown error. Click the link below for details.",g=sde(r.attr,u,t),m=`HMS_${d.replace(/_/g,"-")}`;return l.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(c,{className:`w-5 h-5 ${a} flex-shrink-0 mt-0.5`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx("span",{className:`font-mono text-sm ${a}`,children:m}),l.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${a}`,children:s})]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:f}),l.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[l.jsx(Aa,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${r.code}-${i}`)})})}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.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 ode(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 lde({printerId:t}){const{data:e}=yt({queryKey:["queue",t,"pending"],queryFn:()=>ke.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:l.jsx(IS,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx(Zr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),l.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[l.jsx(_r,{className:"w-3 h-3"}),ode(n?.scheduled_time||null)]}),r>1&&l.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),l.jsx(df,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function E7(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=E7(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function En(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=E7(t))&&(r&&(r+=" "),r+=e);return r}var cde=["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 WR(t){if(typeof t!="string")return!1;var e=cde;return e.includes(t)}var ude=["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"],dde=new Set(ude);function M7(t){return typeof t!="string"?!1:dde.has(t)}function A7(t){return typeof t=="string"&&t.startsWith("data-")}function Ns(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(M7(n)||A7(n))&&(e[n]=t[n]);return e}function Gh(t){if(t==null)return null;if(M.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ns(e)}return typeof t=="object"&&!Array.isArray(t)?Ns(t):null}function ns(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(M7(n)||A7(n)||WR(n))&&(e[n]=t[n]);return e}function hde(t){return t==null?null:M.isValidElement(t)?ns(t.props):typeof t=="object"&&!Array.isArray(t)?ns(t):null}var fde=["children","width","height","viewBox","className","style","title","desc"];function O3(){return O3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},O3.apply(null,arguments)}function pde(t,e){if(t==null)return{};var n,r,i=mde(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 mde(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 qR=M.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:a,style:o,title:c,desc:u}=t,d=pde(t,fde),f=s||{width:r,height:i,x:0,y:0},g=En("recharts-surface",a);return M.createElement("svg",O3({},ns(d),{className:g,width:r,height:i,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),M.createElement("title",null,c),M.createElement("desc",null,u),n)}),gde=["children","className"];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 xde(t,e){if(t==null)return{};var n,r,i=bde(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 bde(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 wr=M.forwardRef((t,e)=>{var{children:n,className:r}=t,i=xde(t,gde),s=En("recharts-layer",r);return M.createElement("g",j3({className:s},ns(i),{ref:e}),n)}),T7=M.createContext(null),vde=()=>M.useContext(T7);function ir(t){return function(){return t}}const C7=Math.cos,k1=Math.sin,Ho=Math.sqrt,P1=Math.PI,VS=2*P1,L3=Math.PI,I3=2*L3,nh=1e-6,yde=I3-nh;function N7(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function _de(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return N7;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 wde{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?N7:_de(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,c=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>nh)if(!(Math.abs(f*c-u*d)>nh)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-a,x=i-o,y=c*c+u*u,v=m*m+x*x,b=Math.sqrt(y),E=Math.sqrt(g),S=s*Math.tan((L3-Math.acos((y+g-v)/(2*b*E)))/2),A=S/E,T=S/b;Math.abs(A-1)>nh&&this._append`L${e+A*d},${n+A*f}`,this._append`A${s},${s},0,0,${+(f*m>d*x)},${this._x1=e+T*c},${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),c=r*Math.sin(i),u=e+o,d=n+c,f=1^a,g=a?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>nh||Math.abs(this._y1-d)>nh)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%I3+I3),g>yde?this._append`A${r},${r},0,1,${f},${e-o},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>nh&&this._append`A${r},${r},0,${+(g>=L3)},${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 KR(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 wde(e)}function XR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function k7(t){this._context=t}k7.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 GS(t){return new k7(t)}function P7(t){return t[0]}function R7(t){return t[1]}function D7(t,e){var n=ir(!0),r=null,i=GS,s=null,a=KR(o);t=typeof t=="function"?t:t===void 0?P7:ir(t),e=typeof e=="function"?e:e===void 0?R7:ir(e);function o(c){var u,d=(c=XR(c)).length,f,g=!1,m;for(r==null&&(s=i(m=a())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===g&&((g=!g)?s.lineStart():s.lineEnd()),g&&s.point(+t(f,u,c),+e(f,u,c));if(m)return s=null,m+""||null}return o.x=function(c){return arguments.length?(t=typeof c=="function"?c:ir(+c),o):t},o.y=function(c){return arguments.length?(e=typeof c=="function"?c:ir(+c),o):e},o.defined=function(c){return arguments.length?(n=typeof c=="function"?c:ir(!!c),o):n},o.curve=function(c){return arguments.length?(i=c,r!=null&&(s=i(r)),o):i},o.context=function(c){return arguments.length?(c==null?r=s=null:s=i(r=c),o):r},o}function xy(t,e,n){var r=null,i=ir(!0),s=null,a=GS,o=null,c=KR(u);t=typeof t=="function"?t:t===void 0?P7:ir(+t),e=typeof e=="function"?e:ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?R7:ir(+n);function u(f){var g,m,x,y=(f=XR(f)).length,v,b=!1,E,S=new Array(y),A=new Array(y);for(s==null&&(o=a(E=c())),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 D7().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 O7{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 Sde(t){return new O7(t,!0)}function Ede(t){return new O7(t,!1)}const YR={draw(t,e){const n=Ho(e/P1);t.moveTo(n,0),t.arc(0,0,n,0,VS)}},Mde={draw(t,e){const n=Ho(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},j7=Ho(1/3),Ade=j7*2,Tde={draw(t,e){const n=Ho(e/Ade),r=n*j7;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Cde={draw(t,e){const n=Ho(e),r=-n/2;t.rect(r,r,n,n)}},Nde=.8908130915292852,L7=k1(P1/10)/k1(7*P1/10),kde=k1(VS/10)*L7,Pde=-C7(VS/10)*L7,Rde={draw(t,e){const n=Ho(e*Nde),r=kde*n,i=Pde*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const a=VS*s/5,o=C7(a),c=k1(a);t.lineTo(c*n,-o*n),t.lineTo(o*r-c*i,c*r+o*i)}t.closePath()}},OA=Ho(3),Dde={draw(t,e){const n=-Ho(e/(OA*3));t.moveTo(0,n*2),t.lineTo(-OA*n,-n),t.lineTo(OA*n,-n),t.closePath()}},Ua=-.5,Fa=Ho(3)/2,U3=1/Ho(12),Ode=(U3/2+1)*3,jde={draw(t,e){const n=Ho(e/Ode),r=n/2,i=n*U3,s=r,a=n*U3+n,o=-s,c=a;t.moveTo(r,i),t.lineTo(s,a),t.lineTo(o,c),t.lineTo(Ua*r-Fa*i,Fa*r+Ua*i),t.lineTo(Ua*s-Fa*a,Fa*s+Ua*a),t.lineTo(Ua*o-Fa*c,Fa*o+Ua*c),t.lineTo(Ua*r+Fa*i,Ua*i-Fa*r),t.lineTo(Ua*s+Fa*a,Ua*a-Fa*s),t.lineTo(Ua*o+Fa*c,Ua*c-Fa*o),t.closePath()}};function Lde(t,e){let n=null,r=KR(i);t=typeof t=="function"?t:ir(t||YR),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 R1(){}function D1(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 I7(t){this._context=t}I7.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:D1(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:D1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Ide(t){return new I7(t)}function U7(t){this._context=t}U7.prototype={areaStart:R1,areaEnd:R1,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:D1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Ude(t){return new U7(t)}function F7(t){this._context=t}F7.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:D1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Fde(t){return new F7(t)}function z7(t){this._context=t}z7.prototype={areaStart:R1,areaEnd:R1,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 zde(t){return new z7(t)}function eF(t){return t<0?-1:1}function tF(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(eF(s)+eF(a))*Math.min(Math.abs(s),Math.abs(a),.5*Math.abs(o))||0}function nF(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function jA(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 O1(t){this._context=t}O1.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:jA(this,this._t0,nF(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,jA(this,nF(this,n=tF(this,t,e)),n);break;default:jA(this,this._t0,n=tF(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function B7(t){this._context=new H7(t)}(B7.prototype=Object.create(O1.prototype)).point=function(t,e){O1.prototype.point.call(this,e,t)};function H7(t){this._context=t}H7.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 Bde(t){return new O1(t)}function Hde(t){return new B7(t)}function $7(t){this._context=t}$7.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=rF(t),i=rF(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 rF(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 $de(t){return new $7(t)}function WS(t,e){this._context=t,this._t=e}WS.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 Vde(t){return new WS(t,.5)}function Gde(t){return new WS(t,0)}function Wde(t){return new WS(t,1)}function vm(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 F3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function qde(t,e){return t[e]}function Kde(t){const e=[];return e.key=t,e}function Xde(){var t=ir([]),e=F3,n=vm,r=qde;function i(s){var a=Array.from(t.apply(this,arguments),Kde),o,c=a.length,u=-1,d;for(const f of s)for(o=0,++u;o<c;++o)(a[o][u]=[0,+r(f,a[o].key,u,s)]).data=f;for(o=0,d=XR(e(a));o<c;++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?F3:typeof s=="function"?s:ir(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??vm,i):n},i}function Yde(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}vm(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}vm(t,e)}}function Qde(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,c=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}c+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,vm(t,e)}}var LA={},IA={},iF;function Jde(){return iF||(iF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(IA)),IA}var UA={},sF;function V7(){return sF||(sF=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})(UA)),UA}var FA={},aF;function ZR(){return aF||(aF=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})(FA)),FA}var zA={},BA={},oF;function ehe(){return oF||(oF=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})(BA)),BA}var lF;function QR(){return lF||(lF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ehe(),n=ZR();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,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(s.push(""),o++);o<a;){const f=i[o];u?f==="\\"&&o+1<a?(o++,c+=i[o]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,s.push(c),c=""):c+=f:f==="["?(d=!0,c&&(s.push(c),c="")):f==="."?c&&(s.push(c),c=""):c+=f,o++}return c&&s.push(c),s}t.toPath=r})(zA)),zA}var cF;function JR(){return cF||(cF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jde(),n=V7(),r=ZR(),i=QR();function s(o,c,u){if(o==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?n.isDeepKey(c)?s(o,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=o[c];return d===void 0?u:d}default:{if(Array.isArray(c))return a(o,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=o[c];return d===void 0?u:d}}}function a(o,c,u){if(c.length===0)return u;let d=o;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=s})(LA)),LA}var HA,uF;function the(){return uF||(uF=1,HA=JR().get),HA}var nhe=the();const Wh=fo(nhe);var Li=t=>t===0?0:t>0?1:-1,Qs=t=>typeof t=="number"&&t!=+t,Cc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Pt=t=>(typeof t=="number"||t instanceof Number)&&!Qs(t),co=t=>Pt(t)||typeof t=="string",rhe=0,T0=t=>{var e=++rhe;return"".concat(t||"").concat(e)},ms=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(!Pt(e)&&typeof e!="string")return r;var s;if(Cc(e)){if(n==null)return r;var a=e.indexOf("%");s=n*parseFloat(e.slice(0,a))/100}else s=+e;return Qs(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},G7=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 On(t,e,n){return Pt(t)&&Pt(e)?t+n*(e-t):e}function W7(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):Wh(r,e))===n)}var dr=t=>t===null||typeof t>"u",bb=t=>dr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function ihe(t){return t!=null}function vb(){}var she=["type","size","sizeType"];function z3(){return z3=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},z3.apply(null,arguments)}function dF(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 hF(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dF(Object(n),!0).forEach(function(r){ahe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dF(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 che(t,e){if(t==null)return{};var n,r,i=uhe(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 uhe(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 q7={symbolCircle:YR,symbolCross:Mde,symbolDiamond:Tde,symbolSquare:Cde,symbolStar:Rde,symbolTriangle:Dde,symbolWye:jde},dhe=Math.PI/180,hhe=t=>{var e="symbol".concat(bb(t));return q7[e]||YR},fhe=(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*dhe;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}},phe=(t,e)=>{q7["symbol".concat(bb(t))]=e},eD=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=che(t,she),s=hF(hF({},i),{},{type:e,size:n,sizeType:r}),a="circle";typeof e=="string"&&(a=e);var o=()=>{var g=hhe(a),m=Lde().type(g).size(fhe(n,r,a)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=s,f=ns(s);return Pt(u)&&Pt(d)&&Pt(n)?M.createElement("path",z3({},f,{className:En("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:o()})):null};eD.registerSymbol=phe;var K7=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,tD=(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=>{WR(i)&&(r[i]=(s=>n[i](n,s)))}),r},mhe=(t,e,n)=>r=>(t(e,n,r),null),yb=(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];WR(i)&&typeof s=="function"&&(r||(r={}),r[i]=mhe(s,e,n))}),r};function fF(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 ghe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fF(Object(n),!0).forEach(function(r){xhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fF(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xhe(t,e,n){return(e=bhe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bhe(t){var e=vhe(t,"string");return typeof e=="symbol"?e:e+""}function vhe(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 Sr(t,e){var n=ghe({},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 j1(){return j1=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},j1.apply(null,arguments)}function pF(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 yhe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pF(Object(n),!0).forEach(function(r){_he(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pF(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _he(t,e,n){return(e=whe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function whe(t){var e=She(t,"string");return typeof e=="symbol"?e:e+""}function She(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Va=32,Ehe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Mhe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Va/2,s=Va/6,a=Va/3,o=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return M.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Va,y2:i,className:"recharts-legend-icon"})}if(c==="line")return M.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(i,"h").concat(a,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(2*a,",").concat(i,`
- H`).concat(Va,"M").concat(2*a,",").concat(i,`
- A`).concat(s,",").concat(s,",0,1,1,").concat(a,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return M.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Va/8,"h").concat(Va,"v").concat(Va*3/4,"h").concat(-Va,"z"),className:"recharts-legend-icon"});if(M.isValidElement(e.legendIcon)){var d=yhe({},e);return delete d.legendIcon,M.cloneElement(e.legendIcon,d)}return M.createElement(eD,{fill:o,cx:i,cy:i,size:Va,sizeType:"diameter",type:c})}function Ahe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:a}=t,o={x:0,y:0,width:Va,height:Va},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,m=En({"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",j1({className:m,style:c,key:"legend-item-".concat(f)},yb(t,d,f)),M.createElement(qR,{width:n,height:n,viewBox:o,style:u,"aria-label":"".concat(y," legend icon")},M.createElement(Mhe,{data:d,iconType:a,inactiveColor:s})),M.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var The=t=>{var e=Sr(t,Ehe),{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(Ahe,j1({},e,{payload:n})))},$A={},VA={},mF;function Che(){return mF||(mF=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})(VA)),VA}var GA={},gF;function X7(){return gF||(gF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(GA)),GA}var WA={},qA={},KA={},xF;function Nhe(){return xF||(xF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(KA)),KA}var bF;function nD(){return bF||(bF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Nhe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(qA)),qA}var XA={},vF;function khe(){return vF||(vF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(XA)),XA}var yF;function Phe(){return yF||(yF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nD(),n=khe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(WA)),WA}var YA={},ZA={},_F;function Rhe(){return _F||(_F=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(ZA)),ZA}var QA={},JA={},eT={},tT={},wF;function Y7(){return wF||(wF=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})(tT)),tT}var nT={},SF;function Z7(){return SF||(SF=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})(nT)),nT}var rT={},EF;function Q7(){return EF||(EF=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})(rT)),rT}var MF;function Dhe(){return MF||(MF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Y7(),n=Z7(),r=Q7();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 c(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 c(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?c([...d],[...f],g,m):!1}t.isMatchWith=i,t.isSetMatch=u})(eT)),eT}var AF;function J7(){return AF||(AF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dhe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(JA)),JA}var iT={},sT={},aT={},TF;function Ohe(){return TF||(TF=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})(aT)),aT}var oT={},CF;function eW(){return CF||(CF=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})(oT)),oT}var lT={},NF;function tW(){return NF||(NF=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]",c="[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=c,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})(lT)),lT}var cT={},kF;function jhe(){return kF||(kF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(cT)),cT}var PF;function nW(){return PF||(PF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ohe(),n=eW(),r=tW(),i=Z7(),s=jhe();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),c(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),c(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),c(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,c(v,d,g,m,x),v}if(d instanceof Boolean){const v=new Boolean(d.valueOf());return m.set(d,v),c(v,d,g,m,x),v}if(d instanceof Number){const v=new Number(d.valueOf());return m.set(d,v),c(v,d,g,m,x),v}if(d instanceof String){const v=new String(d.valueOf());return m.set(d,v),c(v,d,g,m,x),v}if(typeof d=="object"&&u(d)){const v=Object.create(Object.getPrototypeOf(d));return m.set(d,v),c(v,d,g,m,x),v}return d}function c(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=c})(sT)),sT}var RF;function Lhe(){return RF||(RF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(iT)),iT}var DF;function Ihe(){return DF||(DF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=J7(),n=Lhe();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(QA)),QA}var uT={},dT={},hT={},OF;function Uhe(){return OF||(OF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nW(),n=tW();function r(i,s){return e.cloneDeepWith(i,(a,o,c,u)=>{const d=s?.(a,o,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(hT)),hT}var jF;function Fhe(){return jF||(jF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uhe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(dT)),dT}var fT={},pT={},LF;function rW(){return LF||(LF=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})(pT)),pT}var mT={},IF;function zhe(){return IF||(IF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(mT)),mT}var UF;function Bhe(){return UF||(UF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=V7(),n=rW(),r=zhe(),i=QR();function s(a,o){let c;if(Array.isArray(o)?c=o:typeof o=="string"&&e.isDeepKey(o)&&a?.[o]==null?c=i.toPath(o):c=[o],c.length===0)return!1;let u=a;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=s})(fT)),fT}var FF;function Hhe(){return FF||(FF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=J7(),n=ZR(),r=Fhe(),i=JR(),s=Bhe();function a(o,c){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,o);return d===void 0?s.has(u,o):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=a})(uT)),uT}var zF;function $he(){return zF||(zF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=X7(),n=Rhe(),r=Ihe(),i=Hhe();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})(YA)),YA}var BF;function Vhe(){return BF||(BF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Che(),n=X7(),r=Phe(),i=$he();function s(a,o=n.identity){return r.isArrayLikeObject(a)?e.uniqBy(Array.from(a),i.iteratee(o)):[]}t.uniqBy=s})($A)),$A}var gT,HF;function Ghe(){return HF||(HF=1,gT=Vhe().uniqBy),gT}var Whe=Ghe();const $F=fo(Whe);function iW(t,e,n){return e===!0?$F(t,n):typeof e=="function"?$F(t,e):t}var xT={exports:{}},bT={};var VF;function qhe(){if(VF)return bT;VF=1;var t=Vm(),e=SG();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,c=t.useDebugValue;return bT.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]),c(v),v},bT}var GF;function Khe(){return GF||(GF=1,xT.exports=qhe()),xT.exports}var sW=Khe(),rD=M.createContext(null),Xhe=t=>t,rr=()=>{var t=M.useContext(rD);return t?t.store.dispatch:Xhe},J_=()=>{},Yhe=()=>J_,Zhe=(t,e)=>t===e;function Ct(t){var e=M.useContext(rD);return sW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Yhe,e?e.store.getState:J_,e?e.store.getState:J_,e?t:J_,Zhe)}function Qhe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Jhe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function efe(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 WF=t=>Array.isArray(t)?t:[t];function tfe(t){const e=Array.isArray(t[0])?t[0]:t;return efe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function nfe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var rfe=class{constructor(t){this.value=t}deref(){return this.value}},ife=typeof WeakRef<"u"?WeakRef:rfe,sfe=0,qF=1;function by(){return{s:sfe,v:void 0,o:null,p:null}}function aW(t,e={}){let n=by();const{resultEqualityCheck:r}=e;let i,s=0;function a(){let o=n;const{length:c}=arguments;for(let f=0,g=c;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=by(),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=by(),x.set(m,o)):o=y}}const u=o;let d;if(o.s===qF)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 ife(d):d}return u.s=qF,u.v=d,d}return a.clearCache=()=>{n=by(),a.resetResultsCount()},a.resultsCount=()=>s,a.resetResultsCount=()=>{s=0},a}function afe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let s=0,a=0,o,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Qhe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:m=aW,argsMemoizeOptions:x=[]}=d,y=WF(g),v=WF(x),b=tfe(i),E=f(function(){return s++,u.apply(null,arguments)},...y),S=m(function(){a++;const T=nfe(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 Ge=afe(aW),ofe=Object.assign((t,e=Ge)=>{Jhe(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,c)=>(a[n[c]]=o,a),{}))},{withTypes:()=>ofe}),vT={},yT={},_T={},KF;function lfe(){return KF||(KF=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})(_T)),_T}var wT={},ST={},XF;function oW(){return XF||(XF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(ST)),ST}var YF;function cfe(){return YF||(YF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oW(),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})(wT)),wT}var ZF;function ufe(){return ZF||(ZF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lfe(),n=cfe(),r=QR();function i(s,a,o,c){if(s==null)return[];o=c?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})(yT)),yT}var ET={},QF;function dfe(){return QF||(QF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],s=Math.floor(r),a=(o,c)=>{for(let u=0;u<o.length;u++){const d=o[u];Array.isArray(d)&&c<s?a(d,c+1):i.push(d)}};return a(n,0),i}t.flatten=e})(ET)),ET}var MT={},JF;function lW(){return JF||(JF=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rW(),n=nD(),r=Y7(),i=Q7();function s(a,o,c){return r.isObject(c)&&(typeof o=="number"&&n.isArrayLike(c)&&e.isIndex(o)&&o<c.length||typeof o=="string"&&o in c)?i.eq(c[o],a):!1}t.isIterateeCall=s})(MT)),MT}var ez;function hfe(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ufe(),n=dfe(),r=lW();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})(vT)),vT}var AT,tz;function ffe(){return tz||(tz=1,AT=hfe().sortBy),AT}var pfe=ffe();const qS=fo(pfe);var cW=t=>t.legend.settings,mfe=t=>t.legend.size,gfe=t=>t.legend.payload,xfe=Ge([gfe,cW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?qS(r,n):r});function bfe(){return Ct(xfe)}var vy=1;function uW(){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)>vy||Math.abs(a.left-e.left)>vy||Math.abs(a.top-e.top)>vy||Math.abs(a.width-e.width)>vy)&&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 Xi(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var vfe=typeof Symbol=="function"&&Symbol.observable||"@@observable",nz=vfe,TT=()=>Math.random().toString(36).substring(7).split("").join("."),yfe={INIT:`@@redux/INIT${TT()}`,REPLACE:`@@redux/REPLACE${TT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${TT()}`},L1=yfe;function iD(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function dW(t,e,n){if(typeof t!="function")throw new Error(Xi(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Xi(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Xi(1));return n(dW)(t,e)}let r=t,i=e,s=new Map,a=s,o=0,c=!1;function u(){a===s&&(a=new Map,s.forEach((v,b)=>{a.set(b,v)}))}function d(){if(c)throw new Error(Xi(3));return i}function f(v){if(typeof v!="function")throw new Error(Xi(4));if(c)throw new Error(Xi(5));let b=!0;u();const E=o++;return a.set(E,v),function(){if(b){if(c)throw new Error(Xi(6));b=!1,u(),a.delete(E),s=null}}}function g(v){if(!iD(v))throw new Error(Xi(7));if(typeof v.type>"u")throw new Error(Xi(8));if(typeof v.type!="string")throw new Error(Xi(17));if(c)throw new Error(Xi(9));try{c=!0,i=r(i,v)}finally{c=!1}return(s=a).forEach(E=>{E()}),v}function m(v){if(typeof v!="function")throw new Error(Xi(10));r=v,g({type:L1.REPLACE})}function x(){const v=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(Xi(11));function E(){const A=b;A.next&&A.next(d())}return E(),{unsubscribe:v(E)}},[nz](){return this}}}return g({type:L1.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:m,[nz]:x}}function _fe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:L1.INIT})>"u")throw new Error(Xi(12));if(typeof n(void 0,{type:L1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Xi(13))})}function hW(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{_fe(n)}catch(s){i=s}return function(a={},o){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],m=a[f],x=g(m,o);if(typeof x>"u")throw o&&o.type,new Error(Xi(14));u[f]=x,c=c||x!==m}return c=c||r.length!==Object.keys(a).length,c?u:a}}function I1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function wfe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Xi(15))};const a={getState:i.getState,dispatch:(c,...u)=>s(c,...u)},o=t.map(c=>c(a));return s=I1(...o)(i.dispatch),{...i,dispatch:s}}}function fW(t){return iD(t)&&"type"in t&&typeof t.type=="string"}var pW=Symbol.for("immer-nothing"),rz=Symbol.for("immer-draftable"),ks=Symbol.for("immer-state");function To(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var va=Object,ym=va.getPrototypeOf,U1="constructor",KS="prototype",B3="configurable",F1="enumerable",e1="writable",C0="value",Nc=t=>!!t&&!!t[ks];function Fo(t){return t?mW(t)||XS(t)||!!t[rz]||!!t[U1]?.[rz]||YS(t)||ZS(t):!1}var Sfe=va[KS][U1].toString(),iz=new WeakMap;function mW(t){if(!t||!sD(t))return!1;const e=ym(t);if(e===null||e===va[KS])return!0;const n=va.hasOwnProperty.call(e,U1)&&e[U1];if(n===Object)return!0;if(!Up(n))return!1;let r=iz.get(n);return r===void 0&&(r=Function.toString.call(n),iz.set(n,r)),r===Sfe}function _b(t,e,n=!0){wb(t)===0?(n?Reflect.ownKeys(t):va.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function wb(t){const e=t[ks];return e?e.type_:XS(t)?1:YS(t)?2:ZS(t)?3:0}var sz=(t,e,n=wb(t))=>n===2?t.has(e):va[KS].hasOwnProperty.call(t,e),H3=(t,e,n=wb(t))=>n===2?t.get(e):t[e],z1=(t,e,n,r=wb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Efe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var XS=Array.isArray,YS=t=>t instanceof Map,ZS=t=>t instanceof Set,sD=t=>typeof t=="object",Up=t=>typeof t=="function",CT=t=>typeof t=="boolean",lc=t=>t.copy_||t.base_,aD=t=>t.modified_?t.copy_:t.base_;function $3(t,e){if(YS(t))return new Map(t);if(ZS(t))return new Set(t);if(XS(t))return Array[KS].slice.call(t);const n=mW(t);if(e===!0||e==="class_only"&&!n){const r=va.getOwnPropertyDescriptors(t);delete r[ks];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const a=i[s],o=r[a];o[e1]===!1&&(o[e1]=!0,o[B3]=!0),(o.get||o.set)&&(r[a]={[B3]:!0,[e1]:!0,[F1]:o[F1],[C0]:t[a]})}return va.create(ym(t),r)}else{const r=ym(t);if(r!==null&&n)return{...t};const i=va.create(r);return va.assign(i,t)}}function oD(t,e=!1){return QS(t)||Nc(t)||!Fo(t)||(wb(t)>1&&va.defineProperties(t,{set:yy,add:yy,clear:yy,delete:yy}),va.freeze(t),e&&_b(t,(n,r)=>{oD(r,!0)},!1)),t}function Mfe(){To(2)}var yy={[C0]:Mfe};function QS(t){return t===null||!sD(t)?!0:va.isFrozen(t)}var B1="MapSet",V3="Patches",gW={};function _m(t){const e=gW[t];return e||To(0,t),e}var Afe=t=>!!gW[t],N0,xW=()=>N0,Tfe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Afe(B1)?_m(B1):void 0});function az(t,e){e&&(t.patchPlugin_=_m(V3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function G3(t){W3(t),t.drafts_.forEach(Cfe),t.drafts_=null}function W3(t){t===N0&&(N0=t.parent_)}var oz=t=>N0=Tfe(N0,t);function Cfe(t){const e=t[ks];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function lz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[ks].modified_&&(G3(e),To(4)),Fo(t)&&(t=cz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[ks].base_,t,e)}else t=cz(e,n);return Nfe(e,t,!0),G3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==pW?t:void 0}function cz(t,e){if(QS(e))return e;const n=e[ks];if(!n)return lD(e,t.handledSet_,t);if(!JS(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);yW(n,t)}return n.copy_}function Nfe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&oD(e,n)}function bW(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var JS=(t,e)=>t.scope_===e,kfe=[];function vW(t,e,n,r){const i=lc(t),s=t.type_;if(r!==void 0&&H3(i,r,s)===e){z1(i,r,n,s);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;_b(i,(c,u)=>{if(Nc(u)){const d=o.get(u)||[];d.push(c),o.set(u,d)}})}const a=t.draftLocations_.get(e)??kfe;for(const o of a)z1(i,o,n,s)}function Pfe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!JS(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const a=aD(s);vW(t,s.draft_??s,a,n),yW(s,i)})}function yW(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)}bW(t)}}function Rfe(t,e,n){const{scope_:r}=t;if(Nc(n)){const i=n[ks];JS(i,r)&&i.callbacks_.push(function(){t1(t);const a=aD(i);vW(t,n,a,e)})}else Fo(n)&&t.callbacks_.push(function(){const s=lc(t);H3(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&lD(H3(t.copy_,e,t.type_),r.handledSet_,r)})}function lD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Nc(t)||e.has(t)||!Fo(t)||QS(t)||(e.add(t),_b(t,(r,i)=>{if(Nc(i)){const s=i[ks];if(JS(s,n)){const a=aD(s);z1(t,r,a,t.type_),bW(s)}}else Fo(i)&&lD(i,e,n)})),t}function Dfe(t,e){const n=XS(t),r={type_:n?1:0,scope_:e?e.scope_:xW(),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=cD;n&&(i=[r],s=k0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,[o,r]}var cD={get(t,e){if(e===ks)return t;const n=lc(t);if(!sz(n,e,t.type_))return Ofe(t,n,e);const r=n[e];if(t.finalized_||!Fo(r))return r;if(r===NT(t.base_,e)){t1(t);const i=t.type_===1?+e:e,s=K3(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in lc(t)},ownKeys(t){return Reflect.ownKeys(lc(t))},set(t,e,n){const r=_W(lc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=NT(lc(t),e),s=i?.[ks];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Efe(n,i)&&(n!==void 0||sz(t.base_,e,t.type_)))return!0;t1(t),q3(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),Rfe(t,e,n)),!0},deleteProperty(t,e){return t1(t),NT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),q3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=lc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[e1]:!0,[B3]:t.type_!==1||e!=="length",[F1]:r[F1],[C0]:n[e]}},defineProperty(){To(11)},getPrototypeOf(t){return ym(t.base_)},setPrototypeOf(){To(12)}},k0={};_b(cD,(t,e)=>{k0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});k0.deleteProperty=function(t,e){return k0.set.call(this,t,e,void 0)};k0.set=function(t,e,n){return cD.set.call(this,t[0],e,n,t[0])};function NT(t,e){const n=t[ks];return(n?lc(n):t)[e]}function Ofe(t,e,n){const r=_W(e,n);return r?C0 in r?r[C0]:r.get?.call(t.draft_):void 0}function _W(t,e){if(!(e in t))return;let n=ym(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=ym(n)}}function q3(t){t.modified_||(t.modified_=!0,t.parent_&&q3(t.parent_))}function t1(t){t.copy_||(t.assigned_=new Map,t.copy_=$3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var jfe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Up(n)&&!Up(r)){const a=r;r=n;const o=this;return function(u=a,...d){return o.produce(u,f=>r.call(this,f,...d))}}Up(r)||To(6),i!==void 0&&!Up(i)&&To(7);let s;if(Fo(n)){const a=oz(this),o=K3(a,n,void 0);let c=!0;try{s=r(o),c=!1}finally{c?G3(a):W3(a)}return az(a,i),lz(s,a)}else if(!n||!sD(n)){if(s=r(n),s===void 0&&(s=n),s===pW&&(s=void 0),this.autoFreeze_&&oD(s,!0),i){const a=[],o=[];_m(V3).generateReplacementPatches_(n,s,{patches_:a,inversePatches_:o}),i(a,o)}return s}else To(1,n)},this.produceWithPatches=(n,r)=>{if(Up(n))return(o,...c)=>this.produceWithPatches(o,u=>n(u,...c));let i,s;return[this.produce(n,r,(o,c)=>{i=o,s=c}),i,s]},CT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),CT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),CT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Fo(e)||To(8),Nc(e)&&(e=Lo(e));const n=oz(this),r=K3(n,e,void 0);return r[ks].isManual_=!0,W3(n),r}finishDraft(e,n){const r=e&&e[ks];(!r||!r.isManual_)&&To(9);const{scope_:i}=r;return az(i,n),lz(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=_m(V3).applyPatches_;return Nc(e)?i(e,n):this.produce(e,s=>i(s,n))}};function K3(t,e,n,r){const[i,s]=YS(e)?_m(B1).proxyMap_(e,n):ZS(e)?_m(B1).proxySet_(e,n):Dfe(e,n);return(n?.scope_??xW()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?Pfe(n,s,r):s.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:u}=c;s.modified_&&u&&u.generatePatches_(s,[],c)}),i}function Lo(t){return Nc(t)||To(10,t),wW(t)}function wW(t){if(!Fo(t)||QS(t))return t;const e=t[ks];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=$3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=$3(t,!0);return _b(n,(i,s)=>{z1(n,i,wW(s))},r),e&&(e.finalized_=!1),n}var Lfe=new jfe,SW=Lfe.produce;function EW(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var Ife=EW(),Ufe=EW,Ffe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?I1:I1.apply(null,arguments)};function uo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(_a(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=>fW(r)&&r.type===t,n}var MW=class Dx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Dx.prototype)}static get[Symbol.species](){return Dx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Dx(...e[0].concat(this)):new Dx(...e.concat(this))}};function uz(t){return Fo(t)?SW(t,()=>{}):t}function _y(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function zfe(t){return typeof t=="boolean"}var Bfe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let a=new MW;return n&&(zfe(n)?a.push(Ife):a.push(Ufe(n.extraArgument))),a},AW="RTK_autoBatch",fr=()=>t=>({payload:t,meta:{[AW]:!0}}),dz=t=>e=>{setTimeout(e,t)},TW=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,s=!1,a=!1;const o=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:dz(10):t.type==="callback"?t.queueNotification:dz(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?.[AW],s=!i,s&&(a||(a=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Hfe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new MW(t);return r&&i.push(TW(typeof r=="object"?r:void 0)),i};function $fe(t){const e=Bfe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:s=void 0,enhancers:a=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(iD(n))o=hW(n);else throw new Error(_a(1));let c;typeof r=="function"?c=r(e):c=e();let u=I1;i&&(u=Ffe({trace:!1,...typeof i=="object"&&i}));const d=wfe(...c),f=Hfe(d);let g=typeof a=="function"?a(f):f();const m=u(...g);return dW(o,s,m)}function CW(t){const e={},n=[];let r;const i={addCase(s,a){const o=typeof s=="string"?s:s.type;if(!o)throw new Error(_a(28));if(o in e)throw new Error(_a(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 Vfe(t){return typeof t=="function"}function Gfe(t,e){let[n,r,i]=CW(e),s;if(Vfe(t))s=()=>uz(t());else{const o=uz(t);s=()=>o}function a(o=s(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Nc(d)){const m=f(d,c);return m===void 0?d:m}else{if(Fo(d))return SW(d,g=>f(g,c));{const g=f(d,c);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},o)}return a.getInitialState=s,a}var Wfe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",qfe=(t=21)=>{let e="",n=t;for(;n--;)e+=Wfe[Math.random()*64|0];return e},Kfe=Symbol.for("rtk-slice-createasyncthunk");function Xfe(t,e){return`${t}/${e}`}function Yfe({creators:t}={}){const e=t?.asyncThunk?.[Kfe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(_a(11));const a=(typeof r.reducers=="function"?r.reducers(Qfe()):r.reducers)||{},o=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(S,A){const T=typeof S=="string"?S:S.type;if(!T)throw new Error(_a(12));if(T in c.sliceCaseReducersByType)throw new Error(_a(13));return c.sliceCaseReducersByType[T]=A,u},addMatcher(S,A){return c.sliceMatchers.push({matcher:S,reducer:A}),u},exposeAction(S,A){return c.actionCreators[S]=A,u},exposeCaseReducer(S,A){return c.sliceCaseReducersByName[S]=A,u}};o.forEach(S=>{const A=a[S],T={reducerName:S,type:Xfe(i,S),createNotation:typeof r.reducers=="function"};epe(A)?npe(T,A,u,e):Jfe(T,A,u)});function d(){const[S={},A=[],T=void 0]=typeof r.extraReducers=="function"?CW(r.extraReducers):[r.extraReducers],k={...S,...c.sliceCaseReducersByType};return Gfe(r.initialState,N=>{for(let I in k)N.addCase(I,k[I]);for(let I of c.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=_y(m,T,v)),I}function k(N=f){const I=_y(g,A,()=>new WeakMap);return _y(I,N,()=>{const C={};for(const[D,F]of Object.entries(r.selectors??{}))C[D]=Zfe(F,N,()=>_y(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:c.actionCreators,caseReducers:c.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 Js=Yfe();function Qfe(){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 Jfe({type:t,reducerName:e,createNotation:n},r,i){let s,a;if("reducer"in r){if(n&&!tpe(r))throw new Error(_a(17));s=r.reducer,a=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,a?uo(t,a):uo(t))}function epe(t){return t._reducerDefinitionType==="asyncThunk"}function tpe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function npe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(_a(18));const{payloadCreator:s,fulfilled:a,pending:o,rejected:c,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),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:a||wy,pending:o||wy,rejected:c||wy,settled:u||wy})}function wy(){}var rpe="task",NW="listener",kW="completed",uD="cancelled",ipe=`task-${uD}`,spe=`task-${kW}`,X3=`${NW}-${uD}`,ape=`${NW}-${kW}`,eE=class{constructor(t){this.code=t,this.message=`${rpe} ${uD} (reason: ${t})`}name="TaskAbortError";message},dD=(t,e)=>{if(typeof t!="function")throw new TypeError(_a(32))},H1=()=>{},PW=(t,e=H1)=>(t.catch(e),t),RW=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Eh=(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))},Mh=t=>{if(t.aborted){const{reason:e}=t;throw new eE(e)}};function DW(t,e){let n=H1;return new Promise((r,i)=>{const s=()=>i(new eE(t.reason));if(t.aborted){s();return}n=RW(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=H1})}var ope=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof eE?"cancelled":"rejected",error:n}}finally{e?.()}},$1=t=>e=>PW(DW(t,e).then(n=>(Mh(t),n))),OW=t=>{const e=$1(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:em}=Object,hz={},tE="listenerMiddleware",lpe=(t,e)=>{const n=r=>RW(t,()=>Eh(r,t.reason));return(r,i)=>{dD(r);const s=new AbortController;n(s);const a=ope(async()=>{Mh(t),Mh(s.signal);const o=await r({pause:$1(s.signal),delay:OW(s.signal),signal:s.signal});return Mh(s.signal),o},()=>Eh(s,spe));return i?.autoJoin&&e.push(a.catch(H1)),{result:$1(t)(a),cancel(){Eh(s,ipe)}}}},cpe=(t,e)=>{const n=async(r,i)=>{Mh(e);let s=()=>{};const o=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),c([f,g.getState(),g.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&o.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await DW(e,Promise.race(o));return Mh(e),c}finally{s()}};return(r,i)=>PW(n(r,i))},jW=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=uo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(_a(21));return dD(s),{predicate:i,type:e,effect:s}},LW=em(t=>{const{type:e,predicate:n,effect:r}=jW(t);return{id:qfe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(_a(22))}}},{withTypes:()=>LW}),fz=(t,e)=>{const{type:n,effect:r,predicate:i}=jW(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},Y3=t=>{t.pending.forEach(e=>{Eh(e,X3)})},upe=(t,e)=>()=>{for(const n of e.keys())Y3(n);t.clear()},pz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},IW=em(uo(`${tE}/add`),{withTypes:()=>IW}),dpe=uo(`${tE}/removeAll`),UW=em(uo(`${tE}/remove`),{withTypes:()=>UW}),hpe=(...t)=>{console.error(`${tE}/error`,...t)},Sb=(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=hpe}=t;dD(a);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&Y3(m)}),c=m=>{const x=fz(e,m)??LW(m);return o(x)};em(c,{withTypes:()=>c});const u=m=>{const x=fz(e,m);return x&&(x.unsubscribe(),m.cancelActive&&Y3(x)),!!x};em(u,{withTypes:()=>u});const d=async(m,x,y,v)=>{const b=new AbortController,E=cpe(c,b.signal),S=[];try{m.pending.add(b),r(m),await Promise.resolve(m.effect(x,em({},y,{getOriginalState:v,condition:(A,T)=>E(A,T).then(Boolean),take:E,delay:OW(b.signal),pause:$1(b.signal),extra:s,signal:b.signal,fork:lpe(b.signal,S),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((A,T,k)=>{A!==b&&(Eh(A,X3),k.delete(A))})},cancel:()=>{Eh(b,X3),m.pending.delete(b)},throwIfCancelled:()=>{Mh(b.signal)}})))}catch(A){A instanceof eE||pz(a,A,{raisedBy:"effect"})}finally{await Promise.all(S),Eh(b,ape),i(m),m.pending.delete(b)}},f=upe(e,n);return{middleware:m=>x=>y=>{if(!fW(y))return x(y);if(IW.match(y))return c(y.payload);if(dpe.match(y)){f();return}if(UW.match(y))return u(y.payload);let v=m.getState();const b=()=>{if(v===hz)throw new Error(_a(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,pz(a,N,{raisedBy:"predicate"})}k&&d(T,y,m,b)}}}finally{v=hz}return E},startListening:c,stopListening:u,clearListeners:f}};function _a(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 fpe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},FW=Js({name:"chartLayout",initialState:fpe,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:ppe,setLayout:mpe,setChartSize:gpe,setScale:xpe}=FW.actions,bpe=FW.reducer;function zW(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}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 Gp(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){vpe(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 vpe(t,e,n){return(e=ype(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ype(t){var e=_pe(t,"string");return typeof e=="symbol"?e:e+""}function _pe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bn(t,e,n){return dr(t)||dr(e)?n:co(e)?Wh(t,e,n):typeof e=="function"?e(t):n}var wpe=(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"&&Pt(t[s]))return Gp(Gp({},t),{},{[s]:t[s]+(r||0)});if((o==="horizontal"||o==="vertical"&&s==="center")&&a!=="middle"&&Pt(t[a]))return Gp(Gp({},t),{},{[a]:t[a]+(i||0)})}return t},wl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",BW=(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},HW=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:s,scale:a,realScaleType:o,isCategorical:c,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?Li(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=>!Qs(b.coordinate))}return c&&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}))},gz=1e-4,Spe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-gz,s=Math.max(r[0],r[1])+gz,a=t(e[0]),o=t(e[n-1]);(a<i||a>s||o<i||o>s)&&t.domain([e[0],e[n-1]])}},Epe=(t,e)=>{if(!e||e.length!==2||!Pt(e[0])||!Pt(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(!Pt(t[0])||t[0]<n)&&(i[0]=n),(!Pt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},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,a=0;a<e;++a){var o=Qs(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])}},Ape=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=Qs(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)}},Tpe={sign:Mpe,expand:Yde,none:vm,silhouette:Zde,wiggle:Qde,positive:Ape},Cpe=(t,e,n)=>{var r=Tpe[n],i=Xde().keys(e).value((s,a)=>Number(Bn(s,a,0))).order(F3).offset(r);return i(t)};function $W(t){return t==null?void 0:String(t)}function V1(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=W7(n,"value",i[e.dataKey]);if(o)return o.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var c=Bn(i,dr(a)?e.dataKey:a);return dr(c)?null:e.scale(c)}var xz=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=Bn(s,e.dataKey,e.scale.domain()[a]);return dr(o)?null:e.scale(o)-i/2+r},Npe=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]},kpe=t=>{var e=t.flat(2).filter(Pt);return[Math.min(...e),Math.max(...e)]},Ppe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Rpe=(t,e,n)=>{if(t!=null)return Ppe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:a}=s,o=a.reduce((c,u)=>{var d=zW(u,e,n),f=kpe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},bz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,vz=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,ad=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=qS(e,d=>d.coordinate),s=1/0,a=1,o=i.length;a<o;a++){var c=i[a],u=i[a-1];s=Math.min((c.coordinate||0)-(u.coordinate||0),s)}return s===1/0?0:s}return n?void 0:0};function yz(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return Gp(Gp({},e),{},{dataKey:n,payload:r,value:i,name:s})}function vd(t,e){if(t)return String(t);if(typeof e=="string")return e}var Dpe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Ope=(t,e)=>e==="centric"?t.angle:t.radius,Ic=t=>t.layout.width,Uc=t=>t.layout.height,jpe=t=>t.layout.scale,VW=t=>t.layout.margin,nE=Ge(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),rE=Ge(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),GW="data-recharts-item-index",WW="data-recharts-item-data-key",Eb=60;function _z(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_z(Object(n),!0).forEach(function(r){Lpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_z(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lpe(t,e,n){return(e=Ipe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ipe(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)}var Fpe=t=>t.brush.height;function zpe(t){var e=rE(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Eb;return n+i}return n},0)}function Bpe(t){var e=rE(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Eb;return n+i}return n},0)}function Hpe(t){var e=nE(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function $pe(t){var e=nE(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var bi=Ge([Ic,Uc,VW,Fpe,zpe,Bpe,Hpe,$pe,cW,mfe],(t,e,n,r,i,s,a,o,c,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=Sy(Sy({},f),d),m=g.bottom;g.bottom+=r,g=wpe(g,c,u);var x=t-g.left-g.right,y=e-g.top-g.bottom;return Sy(Sy({brushBottom:m},g),{},{width:Math.max(x,0),height:Math.max(y,0)})}),Vpe=Ge(bi,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),hD=Ge(Ic,Uc,(t,e)=>({x:0,y:0,width:t,height:e})),Gpe=M.createContext(null),vi=()=>M.useContext(Gpe)!=null,iE=t=>t.brush,sE=Ge([iE,bi,VW],(t,e,n)=>({height:t.height,x:Pt(t.x)?t.x:e.left,y:Pt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Pt(t.width)?t.width:e.width})),kT={},PT={},RT={},wz;function Wpe(){return wz||(wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:s}={}){let a,o=null;const c=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(),c&&S&&d()};return b.schedule=m,b.cancel=y,b.flush=v,i?.addEventListener("abort",y,{once:!0}),b}t.debounce=e})(RT)),RT}var Sz;function qpe(){return Sz||(Sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wpe();function n(r,i=0,s={}){typeof s!="object"&&(s={});const{leading:a=!1,trailing:o=!0,maxWait:c}=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 c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(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})(PT)),PT}var Ez;function Kpe(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qpe();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})(kT)),kT}var DT,Mz;function Xpe(){return Mz||(Mz=1,DT=Kpe().throttle),DT}var Ype=Xpe();const Zpe=fo(Ype);var G1=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++]))}},qW=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:s,maxHeight:a}=n,o=Cc(r)?t:Number(r),c=Cc(i)?e:Number(i);return s&&s>0&&(o?c=o/s:c&&(o=c*s),a&&c!=null&&c>a&&(c=a)),{calculatedWidth:o,calculatedHeight:c}},Qpe={width:0,height:0,overflow:"visible"},Jpe={width:0,overflowX:"visible"},eme={height:0,overflowY:"visible"},tme={},nme=t=>{var{width:e,height:n}=t,r=Cc(e),i=Cc(n);return r&&i?Qpe:r?Jpe:i?eme:tme};function rme(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 Hn(t){return Number.isFinite(t)}function hl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function Z3(){return Z3=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},Z3.apply(null,arguments)}function Az(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 Tz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Az(Object(n),!0).forEach(function(r){ime(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Az(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ime(t,e,n){return(e=sme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sme(t){var e=ame(t,"string");return typeof e=="symbol"?e:e+""}function ame(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 KW=M.createContext({width:-1,height:-1});function ome(t){return hl(t.width)&&hl(t.height)}function XW(t){var{children:e,width:n,height:r}=t,i=M.useMemo(()=>({width:n,height:r}),[n,r]);return ome(i)?M.createElement(KW.Provider,{value:i},e):null}var fD=()=>M.useContext(KW),lme=M.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:s,minWidth:a=0,minHeight:o,maxHeight:c,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 vb;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;G1(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:N}=qW(A,T,{width:i,height:s,aspect:n,maxHeight:c});return G1(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:En("recharts-responsive-container",g),style:Tz(Tz({},x),{},{width:i,height:s,minWidth:a,minHeight:o,maxHeight:c}),ref:y},M.createElement("div",{style:nme({width:i,height:s})},M.createElement(XW,{width:k,height:N},u)))}),n1=M.forwardRef((t,e)=>{var n=fD();if(hl(n.width)&&hl(n.height))return t.children;var{width:r,height:i}=rme({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:a}=qW(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Pt(s)&&Pt(a)?M.createElement(XW,{width:s,height:a},t.children):M.createElement(lme,Z3({},t,{width:r,height:i,ref:e}))});function YW(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 Mb=()=>{var t,e=vi(),n=Ct(Vpe),r=Ct(sE),i=(t=Ct(iE))===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}},cme={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},ZW=()=>{var t;return(t=Ct(bi))!==null&&t!==void 0?t:cme},pD=()=>Ct(Ic),mD=()=>Ct(Uc),ume=()=>Ct(t=>t.layout.margin),xn=t=>t.layout.layoutType,hf=()=>Ct(xn),dme=()=>{var t=hf();if(t==="horizontal"||t==="vertical")return t},hme=()=>{var t=hf();return t!==void 0},aE=t=>{var e=rr(),n=vi(),{width:r,height:i}=t,s=fD(),a=r,o=i;return s&&(a=s.width>0?s.width:r,o=s.height>0?s.height:i),M.useEffect(()=>{!n&&hl(a)&&hl(o)&&e(gpe({width:a,height:o}))},[e,n,a,o]),null},QW=Symbol.for("immer-nothing"),Cz=Symbol.for("immer-draftable"),Ca=Symbol.for("immer-state");function Co(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var P0=Object.getPrototypeOf;function wm(t){return!!t&&!!t[Ca]}function qh(t){return t?JW(t)||Array.isArray(t)||!!t[Cz]||!!t.constructor?.[Cz]||Ab(t)||lE(t):!1}var fme=Object.prototype.constructor.toString(),Nz=new WeakMap;function JW(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=Nz.get(n);return r===void 0&&(r=Function.toString.call(n),Nz.set(n,r)),r===fme}function W1(t,e,n=!0){oE(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 oE(t){const e=t[Ca];return e?e.type_:Array.isArray(t)?1:Ab(t)?2:lE(t)?3:0}function Q3(t,e){return oE(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function eq(t,e,n){const r=oE(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function pme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ab(t){return t instanceof Map}function lE(t){return t instanceof Set}function rh(t){return t.copy_||t.base_}function J3(t,e){if(Ab(t))return new Map(t);if(lE(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=JW(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Ca];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(P0(t),r)}else{const r=P0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function gD(t,e=!1){return cE(t)||wm(t)||!qh(t)||(oE(t)>1&&Object.defineProperties(t,{set:Ey,add:Ey,clear:Ey,delete:Ey}),Object.freeze(t),e&&Object.values(t).forEach(n=>gD(n,!0))),t}function mme(){Co(2)}var Ey={value:mme};function cE(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var gme={};function Kh(t){const e=gme[t];return e||Co(0,t),e}var R0;function tq(){return R0}function xme(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function kz(t,e){e&&(Kh("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function ek(t){tk(t),t.drafts_.forEach(bme),t.drafts_=null}function tk(t){t===R0&&(R0=t.parent_)}function Pz(t){return R0=xme(R0,t)}function bme(t){const e=t[Ca];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Rz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Ca].modified_&&(ek(e),Co(4)),qh(t)&&(t=q1(e,t),e.parent_||K1(e,t)),e.patches_&&Kh("Patches").generateReplacementPatches_(n[Ca].base_,t,e.patches_,e.inversePatches_)):t=q1(e,n,[]),ek(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==QW?t:void 0}function q1(t,e,n){if(cE(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Ca];if(!i)return W1(e,(s,a)=>Dz(t,i,e,s,a,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return K1(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),W1(a,(c,u)=>Dz(t,i,s,c,u,n,o),r),K1(t,s,!1),n&&t.patches_&&Kh("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function Dz(t,e,n,r,i,s,a){if(i==null||typeof i!="object"&&!a)return;const o=cE(i);if(!(o&&!a)){if(wm(i)){const c=s&&e&&e.type_!==3&&!Q3(e.assigned_,r)?s.concat(r):void 0,u=q1(t,i,c);if(eq(n,r,u),wm(u))t.canAutoFreeze_=!1;else return}else a&&n.add(i);if(qh(i)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&o)return;q1(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ab(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&K1(t,i)}}}function K1(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&gD(e,n)}function vme(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:tq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=xD;n&&(i=[r],s=D0);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}var xD={get(t,e){if(e===Ca)return t;const n=rh(t);if(!Q3(n,e))return yme(t,n,e);const r=n[e];return t.finalized_||!qh(r)?r:r===OT(t.base_,e)?(jT(t),t.copy_[e]=rk(r,t)):r},has(t,e){return e in rh(t)},ownKeys(t){return Reflect.ownKeys(rh(t))},set(t,e,n){const r=nq(rh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=OT(rh(t),e),s=i?.[Ca];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(pme(n,i)&&(n!==void 0||Q3(t.base_,e)))return!0;jT(t),nk(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 OT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,jT(t),nk(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=rh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Co(11)},getPrototypeOf(t){return P0(t.base_)},setPrototypeOf(){Co(12)}},D0={};W1(xD,(t,e)=>{D0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});D0.deleteProperty=function(t,e){return D0.set.call(this,t,e,void 0)};D0.set=function(t,e,n){return xD.set.call(this,t[0],e,n,t[0])};function OT(t,e){const n=t[Ca];return(n?rh(n):t)[e]}function yme(t,e,n){const r=nq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function nq(t,e){if(!(e in t))return;let n=P0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=P0(n)}}function nk(t){t.modified_||(t.modified_=!0,t.parent_&&nk(t.parent_))}function jT(t){t.copy_||(t.copy_=J3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var _me=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(c=s,...u){return a.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Co(6),r!==void 0&&typeof r!="function"&&Co(7);let i;if(qh(e)){const s=Pz(this),a=rk(e,void 0);let o=!0;try{i=n(a),o=!1}finally{o?ek(s):tk(s)}return kz(s,r),Rz(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===QW&&(i=void 0),this.autoFreeze_&&gD(i,!0),r){const s=[],a=[];Kh("Patches").generateReplacementPatches_(e,i,s,a),r(s,a)}return i}else Co(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,c=>e(c,...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){qh(t)||Co(8),wm(t)&&(t=wme(t));const e=Pz(this),n=rk(t,void 0);return n[Ca].isManual_=!0,tk(e),n}finishDraft(t,e){const n=t&&t[Ca];(!n||!n.isManual_)&&Co(9);const{scope_:r}=n;return kz(r,e),Rz(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=Kh("Patches").applyPatches_;return wm(t)?r(t,e):this.produce(t,i=>r(i,e))}};function rk(t,e){const n=Ab(t)?Kh("MapSet").proxyMap_(t,e):lE(t)?Kh("MapSet").proxySet_(t,e):vme(t,e);return(e?e.scope_:tq()).drafts_.push(n),n}function wme(t){return wm(t)||Co(10,t),rq(t)}function rq(t){if(!qh(t)||cE(t))return t;const e=t[Ca];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=J3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=J3(t,!0);return W1(n,(i,s)=>{eq(n,i,rq(s))},r),e&&(e.finalized_=!1),n}var Sme=new _me;Sme.produce;var Eme={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},iq=Js({name:"legend",initialState:Eme,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=Lo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:fr()},removeLegendPayload:{reducer(t,e){var n=Lo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:fr()}}}),{setLegendSize:Oz,setLegendSettings:Mme,addLegendPayload:sq,replaceLegendPayload:aq,removeLegendPayload:oq}=iq.actions,Ame=iq.reducer,Tme=["contextPayload"];function ik(){return ik=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},ik.apply(null,arguments)}function jz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jz(Object(n),!0).forEach(function(r){Cme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Cme(t,e,n){return(e=Nme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nme(t){var e=kme(t,"string");return typeof e=="symbol"?e:e+""}function kme(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 Pme(t,e){if(t==null)return{};var n,r,i=Rme(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 Rme(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 Dme(t){return t.value}function Ome(t){var{contextPayload:e}=t,n=Pme(t,Tme),r=iW(e,t.payloadUniqBy,Dme),i=Sm(Sm({},n),{},{payload:r});return M.isValidElement(t.content)?M.cloneElement(t.content,i):typeof t.content=="function"?M.createElement(t.content,i):M.createElement(The,i)}function jme(t,e,n,r,i,s){var{layout:a,align:o,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&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))&&(c==="middle"?d={top:((i||0)-s.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Sm(Sm({},u),d)}function Lme(t){var e=rr();return M.useEffect(()=>{e(Mme(t))},[e,t]),null}function Ime(t){var e=rr();return M.useEffect(()=>(e(Oz(t)),()=>{e(Oz({width:0,height:0}))}),[e,t]),null}function Ume(t,e,n,r){return t==="vertical"&&Pt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Fme={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function bD(t){var e=Sr(t,Fme),n=bfe(),r=vde(),i=ume(),{width:s,height:a,wrapperStyle:o,portal:c}=e,[u,d]=uW([n]),f=pD(),g=mD();if(f==null||g==null)return null;var m=f-(i?.left||0)-(i?.right||0),x=Ume(e.layout,a,s,m),y=c?o:Sm(Sm({position:"absolute",width:x?.width||s||"auto",height:x?.height||a||"auto"},jme(o,e,i,f,g,u)),o),v=c??r;if(v==null||n==null)return null;var b=M.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},M.createElement(Lme,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&M.createElement(Ime,{width:u.width,height:u.height}),M.createElement(Ome,ik({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return hc.createPortal(b,v)}bD.displayName="Legend";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)}function Lz(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 LT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Lz(Object(n),!0).forEach(function(r){zme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Lz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zme(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=Hme(t,"string");return typeof e=="symbol"?e:e+""}function Hme(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 $me(t){return Array.isArray(t)&&co(t[0])&&co(t[1])?t.join(" ~ "):t}var Vme=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:a,itemSorter:o,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,m=()=>{if(s&&s.length){var T={padding:0,margin:0},k=(o?qS(s,o):s).map((N,I)=>{if(N.type==="none")return null;var C=N.formatter||a||$me,{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=LT({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},co(q)?M.createElement("span",{className:"recharts-tooltip-item-name"},q):null,co(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=LT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=LT({margin:0},i),v=!dr(d),b=v?d:"",E=En("recharts-default-tooltip",c),S=En("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",sk({className:E,style:x},A),M.createElement("p",{className:S,style:y},M.isValidElement(b)?b:"".concat(b)),m())},ox="recharts-tooltip-wrapper",Gme={visibility:"hidden"};function Wme(t){var{coordinate:e,translateX:n,translateY:r}=t;return En(ox,{["".concat(ox,"-right")]:Pt(n)&&e&&Pt(e.x)&&n>=e.x,["".concat(ox,"-left")]:Pt(n)&&e&&Pt(e.x)&&n<e.x,["".concat(ox,"-bottom")]:Pt(r)&&e&&Pt(e.y)&&r>=e.y,["".concat(ox,"-top")]:Pt(r)&&e&&Pt(e.y)&&r<e.y})}function Iz(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:a,tooltipDimension:o,viewBox:c,viewBoxDimension:u}=t;if(s&&Pt(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=c[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 qme(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 Kme(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:a,useTranslate3d:o,viewBox:c}=t,u,d,f;return a.height>0&&a.width>0&&n?(d=Iz({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.width,viewBox:c,viewBoxDimension:c.width}),f=Iz({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:a.height,viewBox:c,viewBoxDimension:c.height}),u=qme({translateX:d,translateY:f,useTranslate3d:o})):u=Gme,{cssProperties:u,cssClasses:Wme({translateX:d,translateY:f,coordinate:n})}}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 My(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){ak(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 ak(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)}class Zme extends M.PureComponent{constructor(){super(...arguments),ak(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),ak(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:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:m,wrapperStyle:x,lastBoundingBox:y,innerRef:v,hasPortalFromProps:b}=this.props,{cssClasses:E,cssProperties:S}=Kme({allowEscapeViewBox:n,coordinate:a,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:m}),A=b?{}:My(My({transition:c&&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=My(My({},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 lq=()=>{var t;return(t=Ct(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function ok(){return ok=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},ok.apply(null,arguments)}function Fz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zz(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Fz(Object(n),!0).forEach(function(r){Qme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Fz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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=ege(t,"string");return typeof e=="symbol"?e:e+""}function ege(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 Bz={curveBasisClosed:Ude,curveBasisOpen:Fde,curveBasis:Ide,curveBumpX:Sde,curveBumpY:Ede,curveLinearClosed:zde,curveLinear:GS,curveMonotoneX:Bde,curveMonotoneY:Hde,curveNatural:$de,curveStep:Vde,curveStepAfter:Wde,curveStepBefore:Gde},X1=t=>Hn(t.x)&&Hn(t.y),Hz=t=>t.base!=null&&X1(t.base)&&X1(t),lx=t=>t.x,cx=t=>t.y,tge=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(bb(t));return(n==="curveMonotone"||n==="curveBump")&&e?Bz["".concat(n).concat(e==="vertical"?"Y":"X")]:Bz[n]||GS},nge=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,a=tge(e,i),o=s?n.filter(X1):n,c;if(Array.isArray(r)){var u=n.map((m,x)=>zz(zz({},m),{},{base:r[x]}));i==="vertical"?c=xy().y(cx).x1(lx).x0(m=>m.base.x):c=xy().x(lx).y1(cx).y0(m=>m.base.y);var d=c.defined(Hz).curve(a),f=s?u.filter(Hz):u;return d(f)}i==="vertical"&&Pt(r)?c=xy().y(cx).x1(lx).x0(r):Pt(r)?c=xy().x(lx).y1(cx).y0(r):c=D7().x(lx).y(cx);var g=c.defined(X1).curve(a);return g(o)},tm=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?nge(t):r;return M.createElement("path",ok({},Ns(t),tD(t),{className:En("recharts-curve",e),d:s===null?void 0:s,ref:i}))},rge=["x","y","top","left","width","height","className"];function lk(){return lk=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},lk.apply(null,arguments)}function $z(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ige(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$z(Object(n),!0).forEach(function(r){sge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$z(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sge(t,e,n){return(e=age(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function age(t){var e=oge(t,"string");return typeof e=="symbol"?e:e+""}function oge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function lge(t,e){if(t==null)return{};var n,r,i=cge(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 cge(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 uge=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),dge=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:a=0,className:o}=t,c=lge(t,rge),u=ige({x:e,y:n,top:r,left:i,width:s,height:a},c);return!Pt(e)||!Pt(n)||!Pt(s)||!Pt(a)||!Pt(r)||!Pt(i)?null:M.createElement("path",lk({},ns(u),{className:En("recharts-cross",o),d:uge(e,n,s,a,r,i)}))};function hge(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 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){fge(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 fge(t,e,n){return(e=pge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pge(t){var e=mge(t,"string");return typeof e=="symbol"?e:e+""}function mge(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 gge=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),cq=(t,e,n)=>t.map(r=>"".concat(gge(r)," ").concat(e,"ms ").concat(n)).join(","),xge=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),O0=(t,e)=>Object.keys(e).reduce((n,r)=>Gz(Gz({},n),{},{[r]:t(r,e[r])}),{});function Wz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ui(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Wz(Object(n),!0).forEach(function(r){bge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Wz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bge(t,e,n){return(e=vge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vge(t){var e=yge(t,"string");return typeof e=="symbol"?e:e+""}function yge(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 Y1=(t,e,n)=>t+(e-t)*n,ck=t=>{var{from:e,to:n}=t;return e!==n},uq=(t,e,n)=>{var r=O0((i,s)=>{if(ck(s)){var[a,o]=t(s.from,s.to,s.velocity);return ui(ui({},s),{},{from:a,velocity:o})}return s},e);return n<1?O0((i,s)=>ck(s)?ui(ui({},s),{},{velocity:Y1(s.velocity,r[i].velocity,n),from:Y1(s.from,r[i].from,n)}):s,e):uq(t,r,n-1)};function _ge(t,e,n,r,i,s){var a,o=r.reduce((g,m)=>ui(ui({},g),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>O0((g,m)=>m.from,o),u=()=>!Object.values(o).filter(ck).length,d=null,f=g=>{a||(a=g);var m=g-a,x=m/n.dt;o=uq(n,o,x),i(ui(ui(ui({},t),e),c())),a=g,u()||(d=s.setTimeout(f))};return()=>(d=s.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function wge(t,e,n,r,i,s,a){var o=null,c=i.reduce((f,g)=>ui(ui({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,m=O0((y,v)=>Y1(...v,n(g)),c);if(s(ui(ui(ui({},t),e),m)),g<1)o=a.setTimeout(d);else{var x=O0((y,v)=>Y1(...v,n(1)),c);s(ui(ui(ui({},t),e),x))}};return()=>(o=a.setTimeout(d),()=>{var f;(f=o)===null||f===void 0||f()})}const Sge=(t,e,n,r,i,s)=>{var a=xge(t,e);return n==null?()=>(i(ui(ui({},t),e)),()=>{}):n.isStepper===!0?_ge(t,e,n,a,i,s):wge(t,e,n,r,a,i,s)};var Z1=1e-4,dq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],hq=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),qz=(t,e)=>n=>{var r=dq(t,e);return hq(r,n)},Ege=(t,e)=>n=>{var r=dq(t,e),i=[...r.map((s,a)=>s*a).slice(1),0];return hq(i,n)},Mge=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]},Age=(t,e,n,r)=>{var i=qz(t,n),s=qz(e,r),a=Ege(t,n),o=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var m=i(f)-d,x=a(f);if(Math.abs(m-d)<Z1||x<Z1)return s(f);f=o(f-m/x)}return s(f)};return c.isStepper=!1,c},Kz=function(){return Age(...Mge(...arguments))},Tge=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,c)=>{var u=-(a-o)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+a;return Math.abs(g-o)<Z1&&Math.abs(f)<Z1?[o,0]:[g,f]};return s.isStepper=!0,s.dt=i,s},Cge=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return Kz(t);case"spring":return Tge();default:if(t.split("(")[0]==="cubic-bezier")return Kz(t)}return typeof t=="function"?t:null};function Nge(t){var e,n=()=>null,r=!1,i=null,s=a=>{if(!r){if(Array.isArray(a)){if(!a.length)return;var o=a,[c,...u]=o;if(typeof c=="number"){i=t.setTimeout(s.bind(null,u),c);return}s(c),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 kge{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 Pge(){return Nge(new kge)}var Rge=M.createContext(Pge);function Dge(t,e){var n=M.useContext(Rge);return M.useMemo(()=>e??n(t),[t,e,n])}var Oge=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Ym={devToolsEnabled:!1,isSsr:Oge()},jge={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},Xz={t:0},IT={t:1};function Zm(t){var e=Sr(t,jge),{isActive:n,canBegin:r,duration:i,easing:s,begin:a,onAnimationEnd:o,onAnimationStart:c,children:u}=e,d=n==="auto"?!Ym.isSsr:n,f=Dge(e.animationId,e.animationManager),[g,m]=M.useState(d?Xz:IT),x=M.useRef(null);return M.useEffect(()=>{d||m(IT)},[d]),M.useEffect(()=>{if(!d||!r)return vb;var y=Sge(Xz,IT,Cge(s),i,m,f.getTimeoutController()),v=()=>{x.current=y()};return f.start([c,a,v,i,o]),()=>{f.stop(),x.current&&x.current(),o()}},[d,r,i,s,a,c,o,f]),u(g.t)}function Qm(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=M.useRef(T0(e)),r=M.useRef(t);return r.current!==t&&(n.current=T0(e),r.current=t),n.current}var Lge=["radius"],Ige=["radius"];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 Zz(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){Uge(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 Uge(t,e,n){return(e=Fge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fge(t){var e=zge(t,"string");return typeof e=="symbol"?e:e+""}function zge(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 Q1(){return Q1=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},Q1.apply(null,arguments)}function Qz(t,e){if(t==null)return{};var n,r,i=Bge(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 Bge(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 Jz=(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,c=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(c,",").concat(t+o*d[0],",").concat(e)),u+="L ".concat(t+n-o*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).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(c,`,
- `).concat(t+n-o*d[2],",").concat(e+r)),u+="L ".concat(t+o*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).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(c,",").concat(t+o*m,",").concat(e,`
- L `).concat(t+n-o*m,",").concat(e,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+a*m,`
- L `).concat(t+n,",").concat(e+r-a*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-o*m,",").concat(e+r,`
- L `).concat(t+o*m,",").concat(e+r,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").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},eB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},fq=t=>{var e=Sr(t,eB),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:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:y}=e,v=M.useRef(o),b=M.useRef(c),E=M.useRef(s),S=M.useRef(a),A=M.useMemo(()=>({x:s,y:a,width:o,height:c,radius:u}),[s,a,o,c,u]),T=Qm(A,"rectangle-");if(s!==+s||a!==+a||o!==+o||c!==+c||o===0||c===0)return null;var k=En("recharts-rectangle",d);if(!y){var N=ns(e),{radius:I}=N,C=Qz(N,Lge);return M.createElement("path",Q1({},C,{radius:typeof u=="number"?u:void 0,className:k,d:Jz(s,a,o,c,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=cq(["strokeDasharray"],g,typeof f=="string"?f:eB.animationEasing);return M.createElement(Zm,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:y,begin:m},V=>{var ee=On(D,o,V),Y=On(F,c,V),Q=On(j,s,V),U=On(q,a,V);n.current&&(v.current=ee,b.current=Y,E.current=Q,S.current=U);var z;x?V>0?z={transition:K,strokeDasharray:W}:z={strokeDasharray:R}:z={strokeDasharray:W};var J=ns(e),{radius:se}=J,me=Qz(J,Ige);return M.createElement("path",Q1({},me,{radius:typeof u=="number"?u:void 0,className:k,d:Jz(Q,U,ee,Y,u),ref:n,style:Zz(Zz({},z),e.style)}))})};function tB(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 nB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tB(Object(n),!0).forEach(function(r){Hge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Hge(t,e,n){return(e=$ge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $ge(t){var e=Vge(t,"string");return typeof e=="symbol"?e:e+""}function Vge(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 J1=Math.PI/180,Gge=t=>t*180/Math.PI,Jr=(t,e,n,r)=>({x:t+Math.cos(-J1*r)*n,y:e+Math.sin(-J1*r)*n}),pq=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},Wge=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},qge=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,a=Wge({x:n,y:r},{x:i,y:s});if(a<=0)return{radius:a,angle:0};var o=(n-i)/a,c=Math.acos(o);return r>s&&(c=2*Math.PI-c),{radius:a,angle:Gge(c),angleInRadian:c}},Kge=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}},Xge=(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},Yge=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=qge({x:n,y:r},e),{innerRadius:a,outerRadius:o}=e;if(i<a||i>o||i===0)return null;var{startAngle:c,endAngle:u}=Kge(e),d=s,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?nB(nB({},e),{},{radius:i,angle:Xge(d,e)}):null};function mq(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,a=Jr(e,n,r,i),o=Jr(e,n,r,s);return{points:[a,o],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function uk(){return uk=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},uk.apply(null,arguments)}var Zge=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Ay=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:s,isExternal:a,cornerRadius:o,cornerIsExternal:c}=t,u=o*(a?1:-1)+r,d=Math.asin(o/u)/J1,f=c?i:i+s*d,g=Jr(e,n,u,f),m=Jr(e,n,r,f),x=c?i-s*d:i,y=Jr(e,n,u*Math.cos(d*J1),x);return{center:g,circleTangency:m,lineTangency:y,theta:d}},gq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:a}=t,o=Zge(s,a),c=s+o,u=Jr(e,n,i,s),d=Jr(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(s>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var g=Jr(e,n,r,s),m=Jr(e,n,r,c);f+="L ".concat(m.x,",").concat(m.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(s<=c),`,
- `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Qge=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:a,cornerIsExternal:o,startAngle:c,endAngle:u}=t,d=Li(u-c),{circleTangency:f,lineTangency:g,theta:m}=Ay({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:o}),{circleTangency:x,lineTangency:y,theta:v}=Ay({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:o}),b=o?Math.abs(c-u):Math.abs(c-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
- `):gq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,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}=Ay({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),{circleTangency:k,lineTangency:N,theta:I}=Ay({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:s,cornerIsExternal:o}),C=o?Math.abs(c-u):Math.abs(c-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},Jge={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},xq=t=>{var e=Sr(t,Jge),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(s<i||u===d)return null;var g=En("recharts-sector",f),m=s-i,x=ms(a,m,0,!0),y;return x>0&&Math.abs(u-d)<360?y=Qge({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,m/2),forceCornerRadius:o,cornerIsExternal:c,startAngle:u,endAngle:d}):y=gq({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),M.createElement("path",uk({},ns(e),{className:g,d:y}))};function exe(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(K7(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:a,angle:o}=e,c=Jr(r,i,s,o),u=Jr(r,i,a,o);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return mq(e)}}var UT={},FT={},zT={},rB;function txe(){return rB||(rB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(zT)),zT}var iB;function nxe(){return iB||(iB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=txe();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})(FT)),FT}var sB;function rxe(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lW(),n=nxe();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),c=new Array(o);for(let u=0;u<o;u++)c[u]=i,i+=a;return c}t.range=r})(UT)),UT}var BT,aB;function ixe(){return aB||(aB=1,BT=rxe().range),BT}var sxe=ixe();const bq=fo(sxe);function Ku(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function axe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function vD(t){let e,n,r;t.length!==2?(e=Ku,n=(o,c)=>Ku(t(o),c),r=(o,c)=>t(o)-c):(e=t===Ku||t===axe?t:oxe,n=t,r=t);function i(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<0?u=f+1:d=f}while(u<d)}return u}function s(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(o[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function a(o,c,u=0,d=o.length){const f=i(o,c,u,d-1);return f>u&&r(o[f-1],c)>-r(o[f],c)?f-1:f}return{left:i,center:a,right:s}}function oxe(){return 0}function vq(t){return t===null?NaN:+t}function*lxe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const cxe=vD(Ku),Tb=cxe.right;vD(vq).center;class oB extends Map{constructor(e,n=hxe){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(lB(this,e))}has(e){return super.has(lB(this,e))}set(e,n){return super.set(uxe(this,e),n)}delete(e){return super.delete(dxe(this,e))}}function lB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function uxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function dxe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function hxe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function fxe(t=Ku){if(t===Ku)return yq;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 yq(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const pxe=Math.sqrt(50),mxe=Math.sqrt(10),gxe=Math.sqrt(2);function ew(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>=pxe?10:s>=mxe?5:s>=gxe?2:1;let o,c,u;return i<0?(u=Math.pow(10,-i)/a,o=Math.round(t*u),c=Math.round(e*u),o/u<t&&++o,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*a,o=Math.round(t/u),c=Math.round(e/u),o*u<t&&++o,c*u>e&&--c),c<o&&.5<=n&&n<2?ew(t,e,n*2):[o,c,u]}function dk(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?ew(e,t,n):ew(t,e,n);if(!(s>=i))return[];const o=s-i+1,c=new Array(o);if(r)if(a<0)for(let u=0;u<o;++u)c[u]=(s-u)/-a;else for(let u=0;u<o;++u)c[u]=(s-u)*a;else if(a<0)for(let u=0;u<o;++u)c[u]=(i+u)/-a;else for(let u=0;u<o;++u)c[u]=(i+u)*a;return c}function hk(t,e,n){return e=+e,t=+t,n=+n,ew(t,e,n)[2]}function fk(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?hk(e,t,n):hk(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function cB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function uB(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function _q(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?yq:fxe(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*f/c+g)),x=Math.min(r,Math.floor(e+(c-u)*f/c+g));_q(t,e,m,x,i)}const s=t[e];let a=n,o=r;for(ux(t,n,e),i(t[r],s)>0&&ux(t,n,r);a<o;){for(ux(t,a,o),++a,--o;i(t[a],s)<0;)++a;for(;i(t[o],s)>0;)--o}i(t[n],s)===0?ux(t,n,o):(++o,ux(t,o,r)),o<=e&&(n=o+1),e<=o&&(r=o-1)}return t}function ux(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function xxe(t,e,n){if(t=Float64Array.from(lxe(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return uB(t);if(e>=1)return cB(t);var r,i=(r-1)*e,s=Math.floor(i),a=cB(_q(t,s).subarray(0,s+1)),o=uB(t.subarray(s+1));return a+(o-a)*(i-s)}}function bxe(t,e,n=vq){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 vxe(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 po(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Fc(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 pk=Symbol("implicit");function yD(){var t=new oB,e=[],n=[],r=pk;function i(s){let a=t.get(s);if(a===void 0){if(r!==pk)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 oB;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 yD(e,n).unknown(r)},po.apply(i,arguments),i}function _D(){var t=yD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,s,a,o=!1,c=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-c+u*2),o&&(s=Math.floor(s)),x+=(y-x-s*(g-c))*d,a=s*(1-c),o&&(x=Math.round(x),a=Math.round(a));var v=vxe(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?(c=Math.min(1,u=+g),f()):c},t.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),f()):c},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return _D(e(),[r,i]).round(o).paddingInner(c).paddingOuter(u).align(d)},po.apply(f(),arguments)}function wq(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return wq(e())},t}function yxe(){return wq(_D.apply(null,arguments).paddingInner(1))}function wD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function Sq(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Cb(){}var j0=.7,tw=1/j0,nm="\\s*([+-]?\\d+)\\s*",L0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",cl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",_xe=/^#([0-9a-f]{3,8})$/,wxe=new RegExp(`^rgb\\(${nm},${nm},${nm}\\)$`),Sxe=new RegExp(`^rgb\\(${cl},${cl},${cl}\\)$`),Exe=new RegExp(`^rgba\\(${nm},${nm},${nm},${L0}\\)$`),Mxe=new RegExp(`^rgba\\(${cl},${cl},${cl},${L0}\\)$`),Axe=new RegExp(`^hsl\\(${L0},${cl},${cl}\\)$`),Txe=new RegExp(`^hsla\\(${L0},${cl},${cl},${L0}\\)$`),dB={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};wD(Cb,I0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:hB,formatHex:hB,formatHex8:Cxe,formatHsl:Nxe,formatRgb:fB,toString:fB});function hB(){return this.rgb().formatHex()}function Cxe(){return this.rgb().formatHex8()}function Nxe(){return Eq(this).formatHsl()}function fB(){return this.rgb().formatRgb()}function I0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=_xe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?pB(e):n===3?new qs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Ty(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Ty(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=wxe.exec(t))?new qs(e[1],e[2],e[3],1):(e=Sxe.exec(t))?new qs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Exe.exec(t))?Ty(e[1],e[2],e[3],e[4]):(e=Mxe.exec(t))?Ty(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Axe.exec(t))?xB(e[1],e[2]/100,e[3]/100,1):(e=Txe.exec(t))?xB(e[1],e[2]/100,e[3]/100,e[4]):dB.hasOwnProperty(t)?pB(dB[t]):t==="transparent"?new qs(NaN,NaN,NaN,0):null}function pB(t){return new qs(t>>16&255,t>>8&255,t&255,1)}function Ty(t,e,n,r){return r<=0&&(t=e=n=NaN),new qs(t,e,n,r)}function kxe(t){return t instanceof Cb||(t=I0(t)),t?(t=t.rgb(),new qs(t.r,t.g,t.b,t.opacity)):new qs}function mk(t,e,n,r){return arguments.length===1?kxe(t):new qs(t,e,n,r??1)}function qs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}wD(qs,mk,Sq(Cb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new qs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?j0:Math.pow(j0,t),new qs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new qs(Ah(this.r),Ah(this.g),Ah(this.b),nw(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:mB,formatHex:mB,formatHex8:Pxe,formatRgb:gB,toString:gB}));function mB(){return`#${fh(this.r)}${fh(this.g)}${fh(this.b)}`}function Pxe(){return`#${fh(this.r)}${fh(this.g)}${fh(this.b)}${fh((isNaN(this.opacity)?1:this.opacity)*255)}`}function gB(){const t=nw(this.opacity);return`${t===1?"rgb(":"rgba("}${Ah(this.r)}, ${Ah(this.g)}, ${Ah(this.b)}${t===1?")":`, ${t})`}`}function nw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ah(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function fh(t){return t=Ah(t),(t<16?"0":"")+t.toString(16)}function xB(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new No(t,e,n,r)}function Eq(t){if(t instanceof No)return new No(t.h,t.s,t.l,t.opacity);if(t instanceof Cb||(t=I0(t)),!t)return new No;if(t instanceof No)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,c=(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/=c<.5?s+i:2-s-i,a*=60):o=c>0&&c<1?0:a,new No(a,o,c,t.opacity)}function Rxe(t,e,n,r){return arguments.length===1?Eq(t):new No(t,e,n,r??1)}function No(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}wD(No,Rxe,Sq(Cb,{brighter(t){return t=t==null?tw:Math.pow(tw,t),new No(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?j0:Math.pow(j0,t),new No(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 qs(HT(t>=240?t-240:t+120,i,r),HT(t,i,r),HT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new No(bB(this.h),Cy(this.s),Cy(this.l),nw(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=nw(this.opacity);return`${t===1?"hsl(":"hsla("}${bB(this.h)}, ${Cy(this.s)*100}%, ${Cy(this.l)*100}%${t===1?")":`, ${t})`}`}}));function bB(t){return t=(t||0)%360,t<0?t+360:t}function Cy(t){return Math.max(0,Math.min(1,t||0))}function HT(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 SD=t=>()=>t;function Dxe(t,e){return function(n){return t+n*e}}function Oxe(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 jxe(t){return(t=+t)==1?Mq:function(e,n){return n-e?Oxe(e,n,t):SD(isNaN(e)?n:e)}}function Mq(t,e){var n=e-t;return n?Dxe(t,n):SD(isNaN(t)?e:t)}const vB=(function t(e){var n=jxe(e);function r(i,s){var a=n((i=mk(i)).r,(s=mk(s)).r),o=n(i.g,s.g),c=n(i.b,s.b),u=Mq(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function Lxe(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 Ixe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Uxe(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]=Jm(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 Fxe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function rw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function zxe(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]=Jm(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var gk=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$T=new RegExp(gk.source,"g");function Bxe(t){return function(){return t}}function Hxe(t){return function(e){return t(e)+""}}function $xe(t,e){var n=gk.lastIndex=$T.lastIndex=0,r,i,s,a=-1,o=[],c=[];for(t=t+"",e=e+"";(r=gk.exec(t))&&(i=$T.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,c.push({i:a,x:rw(r,i)})),n=$T.lastIndex;return n<e.length&&(s=e.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?c[0]?Hxe(c[0].x):Bxe(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)o[(f=c[d]).i]=f.x(u);return o.join("")})}function Jm(t,e){var n=typeof e,r;return e==null||n==="boolean"?SD(e):(n==="number"?rw:n==="string"?(r=I0(e))?(e=r,vB):$xe:e instanceof I0?vB:e instanceof Date?Fxe:Ixe(e)?Lxe:Array.isArray(e)?Uxe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?zxe:rw)(t,e)}function ED(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Vxe(t,e){e===void 0&&(e=t,t=Jm);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 Gxe(t){return function(){return t}}function iw(t){return+t}var yB=[0,1];function Ms(t){return t}function xk(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Gxe(isNaN(e)?NaN:.5)}function Wxe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function qxe(t,e,n){var r=t[0],i=t[1],s=e[0],a=e[1];return i<r?(r=xk(i,r),s=n(a,s)):(r=xk(r,i),s=n(s,a)),function(o){return s(r(o))}}function Kxe(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]=xk(t[a],t[a+1]),s[a]=n(e[a],e[a+1]);return function(o){var c=Tb(t,o,1,r)-1;return s[c](i[c](o))}}function Nb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function uE(){var t=yB,e=yB,n=Jm,r,i,s,a=Ms,o,c,u;function d(){var g=Math.min(t.length,e.length);return a!==Ms&&(a=Wxe(t[0],t[g-1])),o=g>2?Kxe:qxe,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?s:(c||(c=o(t.map(r),e,n)))(r(a(g)))}return f.invert=function(g){return a(i((u||(u=o(e,t.map(r),rw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,iw),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=ED,d()},f.clamp=function(g){return arguments.length?(a=g?!0:Ms,d()):a!==Ms},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 MD(){return uE()(Ms,Ms)}function Xxe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function sw(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 Em(t){return t=sw(Math.abs(t)),t?t[1]:NaN}function Yxe(t,e){return function(n,r){for(var i=n.length,s=[],a=0,o=t[0],c=0;i>0&&o>0&&(c+o+1>r&&(o=Math.max(1,r-c)),s.push(n.substring(i-=o,i+o)),!((c+=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 Qxe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function U0(t){if(!(e=Qxe.exec(t)))throw new Error("invalid format: "+t);var e;return new AD({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}U0.prototype=AD.prototype;function AD(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+""}AD.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 Jxe(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 Aq;function e0e(t,e){var n=sw(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(Aq=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")+sw(t,Math.max(0,e+s-1))[0]}function _B(t,e){var n=sw(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 wB={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Xxe,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)=>_B(t*100,e),r:_B,s:e0e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function SB(t){return t}var EB=Array.prototype.map,MB=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function t0e(t){var e=t.grouping===void 0||t.thousands===void 0?SB:Yxe(EB.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?SB:Zxe(EB.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=U0(f);var g=f.fill,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"):wB[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=wB[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)?c:I(Math.abs(F),S),A&&(F=Jxe(F)),V&&+F==0&&x!=="+"&&(V=!1),j=(V?x==="("?x:o:x==="-"||x==="("?"":x)+j,q=(T==="s"?MB[8+Aq/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 ee=j.length+F.length+q.length,Y=ee<b?new Array(b-ee+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,ee=Y.length>>1)+j+F+q+Y.slice(ee);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=U0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Em(g)/3)))*3,y=Math.pow(10,-x),v=MB[8+x/3];return function(b){return m(y*b)+v}}return{format:u,formatPrefix:d}}var Ny,TD,Tq;n0e({thousands:",",grouping:[3],currency:["$",""]});function n0e(t){return Ny=t0e(t),TD=Ny.format,Tq=Ny.formatPrefix,Ny}function r0e(t){return Math.max(0,-Em(Math.abs(t)))}function i0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Em(e)/3)))*3-Em(Math.abs(t)))}function s0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Em(e)-Em(t))+1}function Cq(t,e,n,r){var i=fk(t,e,n),s;switch(r=U0(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=i0e(i,a))&&(r.precision=s),Tq(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=s0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=r0e(i))&&(r.precision=s-(r.type==="%")*2);break}}return TD(r)}function yd(t){var e=t.domain;return t.ticks=function(n){var r=e();return dk(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return Cq(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],c,u,d=10;for(o<a&&(u=a,a=o,o=u,u=i,i=s,s=u);d-- >0;){if(u=hk(a,o,n),u===c)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;c=u}return t},t}function Nq(){var t=MD();return t.copy=function(){return Nb(t,Nq())},po.apply(t,arguments),yd(t)}function kq(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,iw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return kq(t).unknown(e)},t=arguments.length?Array.from(t,iw):[0,1],yd(n)}function Pq(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 AB(t){return Math.log(t)}function TB(t){return Math.exp(t)}function a0e(t){return-Math.log(-t)}function o0e(t){return-Math.exp(-t)}function l0e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function c0e(t){return t===10?l0e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function u0e(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 CB(t){return(e,n)=>-t(-e,n)}function CD(t){const e=t(AB,TB),n=e.domain;let r=10,i,s;function a(){return i=u0e(r),s=c0e(r),n()[0]<0?(i=CB(i),s=CB(s),t(a0e,o0e)):t(AB,TB),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 c=n();let u=c[0],d=c[c.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=dk(u,d,v))}else b=dk(g,m,Math.min(m-g,v)).map(s);return f?b.reverse():b},e.tickFormat=(o,c)=>{if(o==null&&(o=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=U0(c)).precision==null&&(c.trim=!0),c=TD(c)),o===1/0)return c;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?c(d):""}},e.nice=()=>n(Pq(n(),{floor:o=>s(Math.floor(i(o))),ceil:o=>s(Math.ceil(i(o)))})),e}function Rq(){const t=CD(uE()).domain([1,10]);return t.copy=()=>Nb(t,Rq()).base(t.base()),po.apply(t,arguments),t}function NB(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function kB(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function ND(t){var e=1,n=t(NB(e),kB(e));return n.constant=function(r){return arguments.length?t(NB(e=+r),kB(e)):e},yd(n)}function Dq(){var t=ND(uE());return t.copy=function(){return Nb(t,Dq()).constant(t.constant())},po.apply(t,arguments)}function PB(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function d0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function h0e(t){return t<0?-t*t:t*t}function kD(t){var e=t(Ms,Ms),n=1;function r(){return n===1?t(Ms,Ms):n===.5?t(d0e,h0e):t(PB(n),PB(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},yd(e)}function PD(){var t=kD(uE());return t.copy=function(){return Nb(t,PD()).exponent(t.exponent())},po.apply(t,arguments),t}function f0e(){return PD.apply(null,arguments).exponent(.5)}function RB(t){return Math.sign(t)*t*t}function p0e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Oq(){var t=MD(),e=[0,1],n=!1,r;function i(s){var a=p0e(t(s));return isNaN(a)?r:n?Math.round(a):a}return i.invert=function(s){return t.invert(RB(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,iw)).map(RB)),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 Oq(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},po.apply(i,arguments),yd(i)}function jq(){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]=bxe(t,a/o);return s}function s(a){return a==null||isNaN(a=+a)?r:e[Tb(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(Ku),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 jq().domain(t).range(e).unknown(r)},po.apply(s,arguments)}function Lq(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function a(c){return c!=null&&c<=c?i[Tb(r,c,0,n)]:s}function o(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return a}return a.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,o()):[t,e]},a.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,o()):i.slice()},a.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},a.unknown=function(c){return arguments.length&&(s=c),a},a.thresholds=function(){return r.slice()},a.copy=function(){return Lq().domain([t,e]).range(i).unknown(s)},po.apply(yd(a),arguments)}function Iq(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Tb(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 Iq().domain(t).range(e).unknown(n)},po.apply(i,arguments)}const VT=new Date,GT=new Date;function yi(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 c=[];if(s=i.ceil(s),o=o==null?1:Math.floor(o),!(s<a)||!(o>0))return c;let u;do c.push(u=new Date(+s)),e(s,o),t(s);while(u<s&&s<a);return c},i.filter=s=>yi(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)=>(VT.setTime(+s),GT.setTime(+a),t(VT),t(GT),Math.floor(n(VT,GT))),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 aw=yi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);aw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?yi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):aw);aw.range;const fc=1e3,no=fc*60,pc=no*60,kc=pc*24,RD=kc*7,DB=kc*30,WT=kc*365,ph=yi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*fc)},(t,e)=>(e-t)/fc,t=>t.getUTCSeconds());ph.range;const DD=yi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fc)},(t,e)=>{t.setTime(+t+e*no)},(t,e)=>(e-t)/no,t=>t.getMinutes());DD.range;const OD=yi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*no)},(t,e)=>(e-t)/no,t=>t.getUTCMinutes());OD.range;const jD=yi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*fc-t.getMinutes()*no)},(t,e)=>{t.setTime(+t+e*pc)},(t,e)=>(e-t)/pc,t=>t.getHours());jD.range;const LD=yi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*pc)},(t,e)=>(e-t)/pc,t=>t.getUTCHours());LD.range;const kb=yi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*no)/kc,t=>t.getDate()-1);kb.range;const dE=yi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/kc,t=>t.getUTCDate()-1);dE.range;const Uq=yi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/kc,t=>Math.floor(t/kc));Uq.range;function ff(t){return yi(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())*no)/RD)}const hE=ff(0),ow=ff(1),m0e=ff(2),g0e=ff(3),Mm=ff(4),x0e=ff(5),b0e=ff(6);hE.range;ow.range;m0e.range;g0e.range;Mm.range;x0e.range;b0e.range;function pf(t){return yi(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)/RD)}const fE=pf(0),lw=pf(1),v0e=pf(2),y0e=pf(3),Am=pf(4),_0e=pf(5),w0e=pf(6);fE.range;lw.range;v0e.range;y0e.range;Am.range;_0e.range;w0e.range;const ID=yi(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());ID.range;const UD=yi(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());UD.range;const Pc=yi(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());Pc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:yi(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)});Pc.range;const Rc=yi(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());Rc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:yi(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)});Rc.range;function Fq(t,e,n,r,i,s){const a=[[ph,1,fc],[ph,5,5*fc],[ph,15,15*fc],[ph,30,30*fc],[s,1,no],[s,5,5*no],[s,15,15*no],[s,30,30*no],[i,1,pc],[i,3,3*pc],[i,6,6*pc],[i,12,12*pc],[r,1,kc],[r,2,2*kc],[n,1,RD],[e,1,DB],[e,3,3*DB],[t,1,WT]];function o(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const m=f&&typeof f.range=="function"?f:c(u,d,f),x=m?m.range(u,+d+1):[];return g?x.reverse():x}function c(u,d,f){const g=Math.abs(d-u)/f,m=vD(([,,v])=>v).right(a,g);if(m===a.length)return t.every(fk(u/WT,d/WT,f));if(m===0)return aw.every(Math.max(fk(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,c]}const[S0e,E0e]=Fq(Rc,UD,fE,Uq,LD,OD),[M0e,A0e]=Fq(Pc,ID,hE,kb,jD,DD);function qT(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function KT(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function dx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function T0e(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,s=t.days,a=t.shortDays,o=t.months,c=t.shortMonths,u=hx(i),d=fx(i),f=hx(s),g=fx(s),m=hx(a),x=fx(a),y=hx(o),v=fx(o),b=hx(c),E=fx(c),S={a:V,A:ee,b:Y,B:Q,c:null,d:FB,e:FB,f:Y0e,g:abe,G:lbe,H:q0e,I:K0e,j:X0e,L:zq,m:Z0e,M:Q0e,p:U,q:z,Q:HB,s:$B,S:J0e,u:ebe,U:tbe,V:nbe,w:rbe,W:ibe,x:null,X:null,y:sbe,Y:obe,Z:cbe,"%":BB},A={a:J,A:se,b:me,B:fe,c:null,d:zB,e:zB,f:fbe,g:Sbe,G:Mbe,H:ube,I:dbe,j:hbe,L:Hq,m:pbe,M:mbe,p:xe,q:Ee,Q:HB,s:$B,S:gbe,u:xbe,U:bbe,V:vbe,w:ybe,W:_be,x:null,X:null,y:wbe,Y:Ebe,Z:Abe,"%":BB},T={a:D,A:F,b:j,B:q,c:R,d:IB,e:IB,f:$0e,g:LB,G:jB,H:UB,I:UB,j:F0e,L:H0e,m:U0e,M:z0e,p:C,q:I0e,Q:G0e,s:W0e,S:B0e,u:R0e,U:D0e,V:O0e,w:P0e,W:j0e,x:W,X:K,y:LB,Y:jB,Z:L0e,"%":V0e};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,we){return function(Oe){var he=[],ht=-1,$=0,H=re.length,ne,G,Z;for(Oe instanceof Date||(Oe=new Date(+Oe));++ht<H;)re.charCodeAt(ht)===37&&(he.push(re.slice($,ht)),(G=OB[ne=re.charAt(++ht)])!=null?ne=re.charAt(++ht):G=ne==="e"?" ":"0",(Z=we[ne])&&(ne=Z(Oe,G)),he.push(ne),$=ht+1);return he.push(re.slice($,ht)),he.join("")}}function N(re,we){return function(Oe){var he=dx(1900,void 0,1),ht=I(he,re,Oe+="",0),$,H;if(ht!=Oe.length)return null;if("Q"in he)return new Date(he.Q);if("s"in he)return new Date(he.s*1e3+("L"in he?he.L:0));if(we&&!("Z"in he)&&(he.Z=0),"p"in he&&(he.H=he.H%12+he.p*12),he.m===void 0&&(he.m="q"in he?he.q:0),"V"in he){if(he.V<1||he.V>53)return null;"w"in he||(he.w=1),"Z"in he?($=KT(dx(he.y,0,1)),H=$.getUTCDay(),$=H>4||H===0?lw.ceil($):lw($),$=dE.offset($,(he.V-1)*7),he.y=$.getUTCFullYear(),he.m=$.getUTCMonth(),he.d=$.getUTCDate()+(he.w+6)%7):($=qT(dx(he.y,0,1)),H=$.getDay(),$=H>4||H===0?ow.ceil($):ow($),$=kb.offset($,(he.V-1)*7),he.y=$.getFullYear(),he.m=$.getMonth(),he.d=$.getDate()+(he.w+6)%7)}else("W"in he||"U"in he)&&("w"in he||(he.w="u"in he?he.u%7:"W"in he?1:0),H="Z"in he?KT(dx(he.y,0,1)).getUTCDay():qT(dx(he.y,0,1)).getDay(),he.m=0,he.d="W"in he?(he.w+6)%7+he.W*7-(H+5)%7:he.w+he.U*7-(H+6)%7);return"Z"in he?(he.H+=he.Z/100|0,he.M+=he.Z%100,KT(he)):qT(he)}}function I(re,we,Oe,he){for(var ht=0,$=we.length,H=Oe.length,ne,G;ht<$;){if(he>=H)return-1;if(ne=we.charCodeAt(ht++),ne===37){if(ne=we.charAt(ht++),G=T[ne in OB?we.charAt(ht++):ne],!G||(he=G(re,Oe,he))<0)return-1}else if(ne!=Oe.charCodeAt(he++))return-1}return he}function C(re,we,Oe){var he=u.exec(we.slice(Oe));return he?(re.p=d.get(he[0].toLowerCase()),Oe+he[0].length):-1}function D(re,we,Oe){var he=m.exec(we.slice(Oe));return he?(re.w=x.get(he[0].toLowerCase()),Oe+he[0].length):-1}function F(re,we,Oe){var he=f.exec(we.slice(Oe));return he?(re.w=g.get(he[0].toLowerCase()),Oe+he[0].length):-1}function j(re,we,Oe){var he=b.exec(we.slice(Oe));return he?(re.m=E.get(he[0].toLowerCase()),Oe+he[0].length):-1}function q(re,we,Oe){var he=y.exec(we.slice(Oe));return he?(re.m=v.get(he[0].toLowerCase()),Oe+he[0].length):-1}function R(re,we,Oe){return I(re,e,we,Oe)}function W(re,we,Oe){return I(re,n,we,Oe)}function K(re,we,Oe){return I(re,r,we,Oe)}function V(re){return a[re.getDay()]}function ee(re){return s[re.getDay()]}function Y(re){return c[re.getMonth()]}function Q(re){return o[re.getMonth()]}function U(re){return i[+(re.getHours()>=12)]}function z(re){return 1+~~(re.getMonth()/3)}function J(re){return a[re.getUTCDay()]}function se(re){return s[re.getUTCDay()]}function me(re){return c[re.getUTCMonth()]}function fe(re){return o[re.getUTCMonth()]}function xe(re){return i[+(re.getUTCHours()>=12)]}function Ee(re){return 1+~~(re.getUTCMonth()/3)}return{format:function(re){var we=k(re+="",S);return we.toString=function(){return re},we},parse:function(re){var we=N(re+="",!1);return we.toString=function(){return re},we},utcFormat:function(re){var we=k(re+="",A);return we.toString=function(){return re},we},utcParse:function(re){var we=N(re+="",!0);return we.toString=function(){return re},we}}}var OB={"-":"",_:" ",0:"0"},Fi=/^\s*\d+/,C0e=/^%/,N0e=/[\\^$*+?|[\]().{}]/g;function Nn(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 k0e(t){return t.replace(N0e,"\\$&")}function hx(t){return new RegExp("^(?:"+t.map(k0e).join("|")+")","i")}function fx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function P0e(t,e,n){var r=Fi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function R0e(t,e,n){var r=Fi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function D0e(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function O0e(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function j0e(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function jB(t,e,n){var r=Fi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function LB(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function L0e(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 I0e(t,e,n){var r=Fi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function U0e(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function IB(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function F0e(t,e,n){var r=Fi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function UB(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function z0e(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function B0e(t,e,n){var r=Fi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function H0e(t,e,n){var r=Fi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function $0e(t,e,n){var r=Fi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function V0e(t,e,n){var r=C0e.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function G0e(t,e,n){var r=Fi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function W0e(t,e,n){var r=Fi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function FB(t,e){return Nn(t.getDate(),e,2)}function q0e(t,e){return Nn(t.getHours(),e,2)}function K0e(t,e){return Nn(t.getHours()%12||12,e,2)}function X0e(t,e){return Nn(1+kb.count(Pc(t),t),e,3)}function zq(t,e){return Nn(t.getMilliseconds(),e,3)}function Y0e(t,e){return zq(t,e)+"000"}function Z0e(t,e){return Nn(t.getMonth()+1,e,2)}function Q0e(t,e){return Nn(t.getMinutes(),e,2)}function J0e(t,e){return Nn(t.getSeconds(),e,2)}function ebe(t){var e=t.getDay();return e===0?7:e}function tbe(t,e){return Nn(hE.count(Pc(t)-1,t),e,2)}function Bq(t){var e=t.getDay();return e>=4||e===0?Mm(t):Mm.ceil(t)}function nbe(t,e){return t=Bq(t),Nn(Mm.count(Pc(t),t)+(Pc(t).getDay()===4),e,2)}function rbe(t){return t.getDay()}function ibe(t,e){return Nn(ow.count(Pc(t)-1,t),e,2)}function sbe(t,e){return Nn(t.getFullYear()%100,e,2)}function abe(t,e){return t=Bq(t),Nn(t.getFullYear()%100,e,2)}function obe(t,e){return Nn(t.getFullYear()%1e4,e,4)}function lbe(t,e){var n=t.getDay();return t=n>=4||n===0?Mm(t):Mm.ceil(t),Nn(t.getFullYear()%1e4,e,4)}function cbe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Nn(e/60|0,"0",2)+Nn(e%60,"0",2)}function zB(t,e){return Nn(t.getUTCDate(),e,2)}function ube(t,e){return Nn(t.getUTCHours(),e,2)}function dbe(t,e){return Nn(t.getUTCHours()%12||12,e,2)}function hbe(t,e){return Nn(1+dE.count(Rc(t),t),e,3)}function Hq(t,e){return Nn(t.getUTCMilliseconds(),e,3)}function fbe(t,e){return Hq(t,e)+"000"}function pbe(t,e){return Nn(t.getUTCMonth()+1,e,2)}function mbe(t,e){return Nn(t.getUTCMinutes(),e,2)}function gbe(t,e){return Nn(t.getUTCSeconds(),e,2)}function xbe(t){var e=t.getUTCDay();return e===0?7:e}function bbe(t,e){return Nn(fE.count(Rc(t)-1,t),e,2)}function $q(t){var e=t.getUTCDay();return e>=4||e===0?Am(t):Am.ceil(t)}function vbe(t,e){return t=$q(t),Nn(Am.count(Rc(t),t)+(Rc(t).getUTCDay()===4),e,2)}function ybe(t){return t.getUTCDay()}function _be(t,e){return Nn(lw.count(Rc(t)-1,t),e,2)}function wbe(t,e){return Nn(t.getUTCFullYear()%100,e,2)}function Sbe(t,e){return t=$q(t),Nn(t.getUTCFullYear()%100,e,2)}function Ebe(t,e){return Nn(t.getUTCFullYear()%1e4,e,4)}function Mbe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Am(t):Am.ceil(t),Nn(t.getUTCFullYear()%1e4,e,4)}function Abe(){return"+0000"}function BB(){return"%"}function HB(t){return+t}function $B(t){return Math.floor(+t/1e3)}var Qf,Vq,Gq;Tbe({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 Tbe(t){return Qf=T0e(t),Vq=Qf.format,Qf.parse,Gq=Qf.utcFormat,Qf.utcParse,Qf}function Cbe(t){return new Date(t)}function Nbe(t){return t instanceof Date?+t:+new Date(+t)}function FD(t,e,n,r,i,s,a,o,c,u){var d=MD(),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(c(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,Nbe)):g().map(Cbe)},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(Pq(N,k)):d},d.copy=function(){return Nb(d,FD(t,e,n,r,i,s,a,o,c,u))},d}function kbe(){return po.apply(FD(M0e,A0e,Pc,ID,hE,kb,jD,DD,ph,Vq).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Pbe(){return po.apply(FD(S0e,E0e,Rc,UD,fE,dE,LD,OD,ph,Gq).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function pE(){var t=0,e=1,n,r,i,s,a=Ms,o=!1,c;function u(f){return f==null||isNaN(f=+f)?c: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(Jm),u.rangeRound=d(ED),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return s=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function _d(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function Wq(){var t=yd(pE()(Ms));return t.copy=function(){return _d(t,Wq())},Fc.apply(t,arguments)}function qq(){var t=CD(pE()).domain([1,10]);return t.copy=function(){return _d(t,qq()).base(t.base())},Fc.apply(t,arguments)}function Kq(){var t=ND(pE());return t.copy=function(){return _d(t,Kq()).constant(t.constant())},Fc.apply(t,arguments)}function zD(){var t=kD(pE());return t.copy=function(){return _d(t,zD()).exponent(t.exponent())},Fc.apply(t,arguments)}function Rbe(){return zD.apply(null,arguments).exponent(.5)}function Xq(){var t=[],e=Ms;function n(r){if(r!=null&&!isNaN(r=+r))return e((Tb(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(Ku),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)=>xxe(t,s/r))},n.copy=function(){return Xq(e).domain(t)},Fc.apply(n,arguments)}function mE(){var t=0,e=.5,n=1,r=1,i,s,a,o,c,u=Ms,d,f=!1,g;function m(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-s)*(r*y<r*s?o:c),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),c=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=Vxe(y,[b,E,S]),m):[u(0),u(.5),u(1)]}}return m.range=x(Jm),m.rangeRound=x(ED),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),c=s===a?0:.5/(a-s),r=s<i?-1:1,m}}function Yq(){var t=yd(mE()(Ms));return t.copy=function(){return _d(t,Yq())},Fc.apply(t,arguments)}function Zq(){var t=CD(mE()).domain([.1,1,10]);return t.copy=function(){return _d(t,Zq()).base(t.base())},Fc.apply(t,arguments)}function Qq(){var t=ND(mE());return t.copy=function(){return _d(t,Qq()).constant(t.constant())},Fc.apply(t,arguments)}function BD(){var t=kD(mE());return t.copy=function(){return _d(t,BD()).exponent(t.exponent())},Fc.apply(t,arguments)}function Dbe(){return BD.apply(null,arguments).exponent(.5)}const Ox=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:_D,scaleDiverging:Yq,scaleDivergingLog:Zq,scaleDivergingPow:BD,scaleDivergingSqrt:Dbe,scaleDivergingSymlog:Qq,scaleIdentity:kq,scaleImplicit:pk,scaleLinear:Nq,scaleLog:Rq,scaleOrdinal:yD,scalePoint:yxe,scalePow:PD,scaleQuantile:jq,scaleQuantize:Lq,scaleRadial:Oq,scaleSequential:Wq,scaleSequentialLog:qq,scaleSequentialPow:zD,scaleSequentialQuantile:Xq,scaleSequentialSqrt:Rbe,scaleSequentialSymlog:Kq,scaleSqrt:f0e,scaleSymlog:Dq,scaleThreshold:Iq,scaleTime:kbe,scaleUtc:Pbe,tickFormat:Cq},Symbol.toStringTag,{value:"Module"}));var wd=t=>t.chartData,HD=Ge([wd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Pb=(t,e,n,r)=>r?HD(t):wd(t);function od(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Hn(e)&&Hn(n))return!0}return!1}function VB(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function Jq(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(Hn(n))i=n;else if(typeof n=="function")return;if(Hn(r))s=r;else if(typeof r=="function")return;var a=[i,s];if(od(a))return a}}function Obe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(od(r))return VB(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(Pt(i))a=i;else if(typeof i=="function")try{e!=null&&(a=i(e?.[0]))}catch{}else if(typeof i=="string"&&bz.test(i)){var c=bz.exec(i);if(c==null||e==null)a=void 0;else{var u=+c[1];a=e[0]-u}}else a=e?.[0];if(s==="auto")e!=null&&(o=Math.max(...e));else if(Pt(s))o=s;else if(typeof s=="function")try{e!=null&&(o=s(e?.[1]))}catch{}else if(typeof s=="string"&&vz.test(s)){var d=vz.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(od(g))return e==null?g:VB(g,e,n)}}}var eg=1e9,jbe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},VD,gr=!0,ho="[DecimalError] ",Th=ho+"Invalid argument: ",$D=ho+"Exponent out of range: ",tg=Math.floor,ih=Math.pow,Lbe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,xa,Di=1e7,ur=7,eK=9007199254740991,cw=tg(eK/ur),Dt={};Dt.absoluteValue=Dt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Dt.comparedTo=Dt.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};Dt.decimalPlaces=Dt.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};Dt.dividedBy=Dt.div=function(t){return yc(this,new this.constructor(t))};Dt.dividedToIntegerBy=Dt.idiv=function(t){var e=this,n=e.constructor;return nr(yc(e,new n(t),0,1),n.precision)};Dt.equals=Dt.eq=function(t){return!this.cmp(t)};Dt.exponent=function(){return ni(this)};Dt.greaterThan=Dt.gt=function(t){return this.cmp(t)>0};Dt.greaterThanOrEqualTo=Dt.gte=function(t){return this.cmp(t)>=0};Dt.isInteger=Dt.isint=function(){return this.e>this.d.length-2};Dt.isNegative=Dt.isneg=function(){return this.s<0};Dt.isPositive=Dt.ispos=function(){return this.s>0};Dt.isZero=function(){return this.s===0};Dt.lessThan=Dt.lt=function(t){return this.cmp(t)<0};Dt.lessThanOrEqualTo=Dt.lte=function(t){return this.cmp(t)<1};Dt.logarithm=Dt.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(xa))throw Error(ho+"NaN");if(n.s<1)throw Error(ho+(n.s?"NaN":"-Infinity"));return n.eq(xa)?new r(0):(gr=!1,e=yc(F0(n,s),F0(t,s),s),gr=!0,nr(e,i))};Dt.minus=Dt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?rK(e,t):tK(e,(t.s=-t.s,t))};Dt.modulo=Dt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(ho+"NaN");return n.s?(gr=!1,e=yc(n,t,0,1).times(t),gr=!0,n.minus(e)):nr(new r(n),i)};Dt.naturalExponential=Dt.exp=function(){return nK(this)};Dt.naturalLogarithm=Dt.ln=function(){return F0(this)};Dt.negated=Dt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Dt.plus=Dt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?tK(e,t):rK(e,(t.s=-t.s,t))};Dt.precision=Dt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Th+t);if(e=ni(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};Dt.squareRoot=Dt.sqrt=function(){var t,e,n,r,i,s,a,o=this,c=o.constructor;if(o.s<1){if(!o.s)return new c(0);throw Error(ho+"NaN")}for(t=ni(o),gr=!1,i=Math.sqrt(+o),i==0||i==1/0?(e=al(o.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=tg((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=a=n+3;;)if(s=r,r=s.plus(yc(o,s,a+2)).times(.5),al(s.d).slice(0,a)===(e=al(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)};Dt.times=Dt.mul=function(t){var e,n,r,i,s,a,o,c,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,c=g.length,u=m.length,c<u&&(s=g,g=m,m=s,a=c,c=u,u=a),s=[],a=c+u,r=a;r--;)s.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)o=s[i]+m[r]*g[i-r-1]+e,s[i--]=o%Di|0,e=o/Di|0;s[i]=(s[i]+e)%Di|0}for(;!s[--a];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,gr?nr(t,f.precision):t};Dt.toDecimalPlaces=Dt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(fl(t,0,eg),e===void 0?e=r.rounding:fl(e,0,8),nr(n,t+ni(n)+1,e))};Dt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Xh(r,!0):(fl(t,0,eg),e===void 0?e=i.rounding:fl(e,0,8),r=nr(new i(r),t+1,e),n=Xh(r,!0,t+1)),n};Dt.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?Xh(i):(fl(t,0,eg),e===void 0?e=s.rounding:fl(e,0,8),r=nr(new s(i),t+ni(i)+1,e),n=Xh(r.abs(),!1,t+ni(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Dt.toInteger=Dt.toint=function(){var t=this,e=t.constructor;return nr(new e(t),ni(t)+1,e.rounding)};Dt.toNumber=function(){return+this};Dt.toPower=Dt.pow=function(t){var e,n,r,i,s,a,o=this,c=o.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(xa);if(o=new c(o),!o.s){if(t.s<1)throw Error(ho+"Infinity");return o}if(o.eq(xa))return o;if(r=c.precision,t.eq(xa))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)<=eK){for(i=new c(xa),e=Math.ceil(r/ur+4),gr=!1;n%2&&(i=i.times(o),WB(i.d,e)),n=tg(n/2),n!==0;)o=o.times(o),WB(o.d,e);return gr=!0,t.s<0?new c(xa).div(i):nr(i,r)}}else if(s<0)throw Error(ho+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,gr=!1,i=t.times(F0(o,r+u)),gr=!0,i=nK(i),i.s=s,i};Dt.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=ni(i),r=Xh(i,n<=s.toExpNeg||n>=s.toExpPos)):(fl(t,1,eg),e===void 0?e=s.rounding:fl(e,0,8),i=nr(new s(i),t,e),n=ni(i),r=Xh(i,t<=n||n<=s.toExpNeg,t)),r};Dt.toSignificantDigits=Dt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(fl(t,1,eg),e===void 0?e=r.rounding:fl(e,0,8)),nr(new r(n),t,e)};Dt.toString=Dt.valueOf=Dt.val=Dt.toJSON=Dt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=ni(t),n=t.constructor;return Xh(t,e<=n.toExpNeg||e>=n.toExpPos)};function tK(t,e){var n,r,i,s,a,o,c,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(c=t.d,u=e.d,a=t.e,i=e.e,c=c.slice(),s=a-i,s){for(s<0?(r=c,s=-s,o=u.length):(r=u,i=a,o=c.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=c.length,s=u.length,o-s<0&&(s=o,r=u,u=c,c=r),n=0;s;)n=(c[--s]=c[s]+u[s]+n)/Di|0,c[s]%=Di;for(n&&(c.unshift(n),++i),o=c.length;c[--o]==0;)c.pop();return e.d=c,e.e=i,gr?nr(e,f):e}function fl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Th+t)}function al(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+=Tu(n)),s+=r;a=t[e],r=a+"",n=ur-r.length,n&&(s+=Tu(n))}else if(a===0)return"0";for(;a%10===0;)a/=10;return s+a}var yc=(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%Di|0,a=s/Di|0;return a&&r.unshift(a),r}function e(r,i,s,a){var o,c;if(s!=a)c=s>a?1:-1;else for(o=c=0;o<s;o++)if(r[o]!=i[o]){c=r[o]>i[o]?1:-1;break}return c}function n(r,i,s){for(var a=0;s--;)r[s]-=a,a=r[s]<i[s]?1:0,r[s]=a*Di+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,a){var o,c,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(ho+"Division by zero");for(c=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)&&--c,s==null?E=s=C.precision:a?E=s+(ni(r)-ni(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*Di+(F[u]||0),x[u]=S/j|0,d=S%j|0;else{for(d=Di/(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]>=Di/2&&++k;do d=0,o=e(j,y,N,v),o<0?(b=y[0],N!=v&&(b=b*Di+(y[1]||0)),d=b/k|0,d>1?(d>=Di&&(d=Di-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=c,nr(m,a?s+ni(m)+1:s)}})();function nK(t,e){var n,r,i,s,a,o,c=0,u=0,d=t.constructor,f=d.precision;if(ni(t)>16)throw Error($D+ni(t));if(!t.s)return new d(xa);for(gr=!1,o=f,a=new d(.03125);t.abs().gte(.1);)t=t.times(a),u+=5;for(r=Math.log(ih(2,u))/Math.LN10*2+5|0,o+=r,n=i=s=new d(xa),d.precision=o;;){if(i=nr(i.times(t),o),n=n.times(++c),a=s.plus(yc(i,n,o)),al(a.d).slice(0,o)===al(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 ni(t){for(var e=t.e*ur,n=t.d[0];n>=10;n/=10)e++;return e}function XT(t,e,n){if(e>t.LN10.sd())throw gr=!0,n&&(t.precision=n),Error(ho+"LN10 precision limit exceeded");return nr(new t(t.LN10),e)}function Tu(t){for(var e="";t--;)e+="0";return e}function F0(t,e){var n,r,i,s,a,o,c,u,d,f=1,g=10,m=t,x=m.d,y=m.constructor,v=y.precision;if(m.s<1)throw Error(ho+(m.s?"NaN":"-Infinity"));if(m.eq(xa))return new y(0);if(e==null?(gr=!1,u=v):u=e,m.eq(10))return e==null&&(gr=!0),XT(y,u);if(u+=g,y.precision=u,n=al(x),r=n.charAt(0),s=ni(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=al(m.d),r=n.charAt(0),f++;s=ni(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return c=XT(y,u+2,v).times(s+""),m=F0(new y(r+"."+n.slice(1)),u-g).plus(c),y.precision=v,e==null?(gr=!0,nr(m,v)):m;for(o=a=m=yc(m.minus(xa),m.plus(xa),u),d=nr(m.times(m),u),i=3;;){if(a=nr(a.times(d),u),c=o.plus(yc(a,new y(i),u)),al(c.d).slice(0,u)===al(o.d).slice(0,u))return o=o.times(2),s!==0&&(o=o.plus(XT(y,u+2,v).times(s+""))),o=yc(o,new y(f),u),y.precision=v,e==null?(gr=!0,nr(o,v)):o;o=c,i+=2}}function GB(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=tg(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>cw||t.e<-cw))throw Error($D+n)}else t.s=0,t.e=0,t.d=[0];return t}function nr(t,e,n){var r,i,s,a,o,c,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=ih(10,a-i-1),o=u/s%10|0,c=e<0||f[d+1]!==void 0||u%s,c=n<4?(o||c)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||c||n==6&&(r>0?i>0?u/ih(10,a-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(s=ni(t),f.length=1,e=e-s-1,f[0]=ih(10,(ur-e%ur)%ur),t.e=tg(-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=ih(10,ur-r),f[d]=i>0?(u/ih(10,a-i)%ih(10,i)|0)*s:0),c)for(;;)if(d==0){(f[0]+=s)==Di&&(f[0]=1,++t.e);break}else{if(f[d]+=s,f[d]!=Di)break;f[d--]=0,s=1}for(r=f.length;f[--r]===0;)f.pop();if(gr&&(t.e>cw||t.e<-cw))throw Error($D+ni(t));return t}function rK(t,e){var n,r,i,s,a,o,c,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(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),a=u-r,a){for(d=a<0,d?(n=c,a=-a,o=f.length):(n=f,r=u,o=c.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=c.length,o=f.length,d=i<o,d&&(o=i),i=0;i<o;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}a=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),o=c.length,i=f.length-o;i>0;--i)c[o++]=0;for(i=f.length;i>a;){if(c[--i]<f[i]){for(s=i;s&&c[--s]===0;)c[s]=Di-1;--c[s],c[i]+=Di}c[i]-=f[i]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,gr?nr(e,m):e):new g(0)}function Xh(t,e,n){var r,i=ni(t),s=al(t.d),a=s.length;return e?(n&&(r=n-a)>0?s=s.charAt(0)+"."+s.slice(1)+Tu(r):a>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Tu(-i-1)+s,n&&(r=n-a)>0&&(s+=Tu(r))):i>=a?(s+=Tu(i+1-a),n&&(r=n-i-1)>0&&(s=s+"."+Tu(r))):((r=i+1)<a&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-a)>0&&(i+1===a&&(s+="."),s+=Tu(r))),t.s<0?"-"+s:s}function WB(t,e){if(t.length>e)return t.length=e,!0}function iK(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(Th+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 GB(a,s.toString())}else if(typeof s!="string")throw Error(Th+s);if(s.charCodeAt(0)===45?(s=s.slice(1),a.s=-1):a.s=1,Lbe.test(s))GB(a,s);else throw Error(Th+s)}if(i.prototype=Dt,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=iK,i.config=i.set=Ibe,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 Ibe(t){if(!t||typeof t!="object")throw Error(ho+"Object expected");var e,n,r,i=["precision",1,eg,"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(tg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Th+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Th+n+": "+r);return this}var VD=iK(jbe);xa=new VD(1);const zn=VD;var Ube=t=>t,sK={},aK=t=>t===sK,qB=t=>function e(){return arguments.length===0||arguments.length===1&&aK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},oK=(t,e)=>t===1?e:qB(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!==sK).length;return s>=t?e(...r):oK(t-s,qB(function(){for(var a=arguments.length,o=new Array(a),c=0;c<a;c++)o[c]=arguments[c];var u=r.map(d=>aK(d)?o.shift():d);return e(...u,...o)}))}),Fbe=t=>oK(t.length,t),bk=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},zbe=Fbe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Bbe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Ube;var i=n.reverse(),s=i[0],a=i.slice(1);return function(){return a.reduce((o,c)=>c(o),s(...arguments))}},vk=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function lK(t){var e;return t===0?e=1:e=Math.floor(new zn(t).abs().log(10).toNumber())+1,e}function cK(t,e,n){for(var r=new zn(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var uK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},dK=(t,e,n)=>{if(t.lte(0))return new zn(0);var r=lK(t.toNumber()),i=new zn(10).pow(r),s=t.div(i),a=r!==1?.05:.1,o=new zn(Math.ceil(s.div(a).toNumber())).add(n).mul(a),c=o.mul(i);return e?new zn(c.toNumber()):new zn(Math.ceil(c.toNumber()))},Hbe=(t,e,n)=>{var r=new zn(1),i=new zn(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new zn(10).pow(lK(t)-1),i=new zn(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new zn(Math.floor(t)))}else t===0?i=new zn(Math.floor((e-1)/2)):n||(i=new zn(Math.floor(t)));var a=Math.floor((e-1)/2),o=Bbe(zbe(c=>i.add(new zn(c-a).mul(r)).toNumber()),bk);return o(0,e)},hK=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 zn(0),tickMin:new zn(0),tickMax:new zn(0)};var a=dK(new zn(n).sub(e).div(r-1),i,s),o;e<=0&&n>=0?o=new zn(0):(o=new zn(e).add(n).div(2),o=o.sub(new zn(o).mod(a)));var c=Math.ceil(o.sub(e).div(a).toNumber()),u=Math.ceil(new zn(n).sub(o).div(a).toNumber()),d=c+u+1;return d>r?hK(e,n,r,i,s+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:a,tickMin:o.sub(new zn(c).mul(a)),tickMax:o.add(new zn(u).mul(a))})},$be=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,c]=uK([n,r]);if(o===-1/0||c===1/0){var u=c===1/0?[o,...bk(0,i-1).map(()=>1/0)]:[...bk(0,i-1).map(()=>-1/0),c];return n>r?vk(u):u}if(o===c)return Hbe(o,i,s);var{step:d,tickMin:f,tickMax:g}=hK(o,c,a,s,0),m=cK(f,g.add(new zn(.1).mul(d)),d);return n>r?vk(m):m},Vbe=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=uK([r,i]);if(a===-1/0||o===1/0)return[r,i];if(a===o)return[a];var c=Math.max(n,2),u=dK(new zn(o).sub(a).div(c-1),s,0),d=[...cK(new zn(a),new zn(o),u),o];return s===!1&&(d=d.map(f=>Math.round(f))),r>i?vk(d):d},fK=t=>t.rootProps.maxBarSize,Gbe=t=>t.rootProps.barGap,pK=t=>t.rootProps.barCategoryGap,Wbe=t=>t.rootProps.barSize,Rb=t=>t.rootProps.stackOffset,mK=t=>t.rootProps.reverseStackOrder,GD=t=>t.options.chartName,WD=t=>t.rootProps.syncId,gK=t=>t.rootProps.syncMethod,qD=t=>t.options.eventEmitter,qbe=t=>t.rootProps.baseValue,Rr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},cc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},pa={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},gE=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Kbe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:cc.angleAxisId,includeHidden:!1,name:void 0,reversed:cc.reversed,scale:cc.scale,tick:cc.tick,tickCount:void 0,ticks:void 0,type:cc.type,unit:void 0},Xbe={allowDataOverflow:pa.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:pa.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:pa.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:pa.scale,tick:pa.tick,tickCount:pa.tickCount,ticks:void 0,type:pa.type,unit:void 0},Ybe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:cc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:cc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:cc.scale,tick:cc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Zbe={allowDataOverflow:pa.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:pa.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:pa.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:pa.scale,tick:pa.tick,tickCount:pa.tickCount,ticks:void 0,type:"category",unit:void 0},KD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Ybe:Kbe,XD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Zbe:Xbe,xE=t=>t.polarOptions,YD=Ge([Ic,Uc,bi],pq),xK=Ge([xE,YD],(t,e)=>{if(t!=null)return ms(t.innerRadius,e,0)}),bK=Ge([xE,YD],(t,e)=>{if(t!=null)return ms(t.outerRadius,e,e*.8)}),Qbe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},vK=Ge([xE],Qbe);Ge([KD,vK],gE);var yK=Ge([YD,xK,bK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ge([XD,yK],gE);var _K=Ge([xn,xE,xK,bK,Ic,Uc],(t,e,n,r,i,s)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:a,cy:o,startAngle:c,endAngle:u}=e;return{cx:ms(a,i,i/2),cy:ms(o,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),xr=(t,e)=>e,Db=(t,e,n)=>n;function bE(t){return t?.id}function wK(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:s}=n,a=new Map;return t.forEach(o=>{var c,u=(c=o.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=bE(o);u.forEach((f,g)=>{var m=s==null||i?g:String(Bn(f,s,null)),x=Bn(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 vE(t){return t.stackId!=null&&t.dataKey!=null}var yE=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function _E(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Jbe(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var _i=t=>{var e=xn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},ng=t=>t.tooltip.settings.axisId;function KB(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 uw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KB(Object(n),!0).forEach(function(r){eve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eve(t,e,n){return(e=tve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tve(t){var e=nve(t,"string");return typeof e=="symbol"?e:e+""}function nve(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 yk=[0,"auto"],Pi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"bottom",padding:{left:0,right:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"category",unit:void 0},SK=(t,e)=>t.cartesianAxis.xAxis[e],Sl=(t,e)=>{var n=SK(t,e);return n??Pi},Ri={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:yk,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:Eb},EK=(t,e)=>t.cartesianAxis.yAxis[e],El=(t,e)=>{var n=EK(t,e);return n??Ri},rve={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:""},ZD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??rve},Er=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return El(t,n);case"zAxis":return ZD(t,n);case"angleAxis":return KD(t,n);case"radiusAxis":return XD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ive=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return El(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Ob=(t,e,n)=>{switch(e){case"xAxis":return Sl(t,n);case"yAxis":return El(t,n);case"angleAxis":return KD(t,n);case"radiusAxis":return XD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},MK=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function QD(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 jb=t=>t.graphicalItems.cartesianItems,sve=Ge([xr,Db],QD),JD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Lb=Ge([jb,Er,sve],JD,{memoizeOptions:{resultEqualityCheck:_E}}),AK=Ge([Lb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(vE)),TK=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),ave=Ge([Lb],TK),eO=t=>t.map(e=>e.data).filter(Boolean).flat(1),ove=Ge([Lb],eO,{memoizeOptions:{resultEqualityCheck:_E}}),tO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},nO=Ge([ove,Pb],tO),rO=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Bn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Bn(i,r)}))):t.map(r=>({value:r})),wE=Ge([nO,Er,Lb],rO);function CK(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function r1(t){if(co(t)||t instanceof Date){var e=Number(t);if(Hn(e))return e}}function XB(t){if(Array.isArray(t)){var e=[r1(t[0]),r1(t[1])];return od(e)?e:void 0}var n=r1(t);if(n!=null)return[n,n]}function Dc(t){return t.map(r1).filter(ihe)}function lve(t,e,n){return!n||typeof e!="number"||Qs(e)?[]:n.length?Dc(n.flatMap(r=>{var i=Bn(t,r.dataKey),s,a;if(Array.isArray(i)?[s,a]=i:s=a=i,!(!Hn(s)||!Hn(a)))return[e-s,e+a]})):[]}var wi=t=>{var e=_i(t),n=ng(t);return Ob(t,e,n)},Ib=Ge([wi],t=>t?.dataKey),cve=Ge([AK,Pb,wi],wK),NK=(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,c]=a,u=r?[...c].reverse():c,d=u.map(bE);return[o,{stackedData:Cpe(t,d,n),graphicalItems:u}]}))},z0=Ge([cve,AK,Rb,mK],NK),kK=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var a=Rpe(t,i,s);if(!(a!=null&&a[0]===0&&a[1]===0))return a}},uve=Ge([Er],t=>t.allowDataOverflow),iO=t=>{var e;if(t==null||!("domain"in t))return yk;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Dc(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:yk},sO=Ge([Er],iO),aO=Ge([sO,uve],Jq),dve=Ge([z0,wd,xr,aO],kK,{memoizeOptions:{resultEqualityCheck:yE}}),SE=t=>t.errorBars,hve=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>CK(n,r)),dw=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]}},oO=(t,e,n,r,i)=>{var s,a;if(n.length>0&&t.forEach(o=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(b=>CK(i,b)),g=Bn(o,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=lve(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=XB(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 c=XB(Bn(o,e.dataKey));c!=null&&(s=s==null?c[0]:Math.min(s,c[0]),a=a==null?c[1]:Math.max(a,c[1]))}),Hn(s)&&Hn(a))return[s,a]},fve=Ge([nO,Er,ave,SE,xr],oO,{memoizeOptions:{resultEqualityCheck:yE}});function pve(t){var{value:e}=t;if(co(e)||e instanceof Date)return e}var mve=(t,e,n)=>{var r=t.map(pve).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&G7(r))?bq(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},PK=t=>t.referenceElements.dots,rg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),gve=Ge([PK,xr,Db],rg),RK=t=>t.referenceElements.areas,xve=Ge([RK,xr,Db],rg),DK=t=>t.referenceElements.lines,bve=Ge([DK,xr,Db],rg),OK=(t,e)=>{var n=Dc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},vve=Ge(gve,xr,OK),jK=(t,e)=>{var n=Dc(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)]},yve=Ge([xve,xr],jK);function _ve(t){var e;if(t.x!=null)return Dc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Dc(n)}function wve(t){var e;if(t.y!=null)return Dc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Dc(n)}var LK=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?_ve(r):wve(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Sve=Ge([bve,xr],LK),Eve=Ge(vve,Sve,yve,(t,e,n)=>dw(t,n,e)),lO=(t,e,n,r,i,s,a,o)=>{if(n!=null)return n;var c=a==="vertical"&&o==="xAxis"||a==="horizontal"&&o==="yAxis",u=c?dw(r,s,i):dw(s,i);return Obe(e,u,t.allowDataOverflow)},Mve=Ge([Er,sO,aO,dve,fve,Eve,xn,xr],lO,{memoizeOptions:{resultEqualityCheck:yE}}),Ave=[0,1],cO=(t,e,n,r,i,s,a)=>{if(!((t==null||n==null||n.length===0)&&a===void 0)){var{dataKey:o,type:c}=t,u=wl(e,s);if(u&&o==null){var d;return bq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?mve(r,t,u):i==="expand"?Ave:a}},uO=Ge([Er,xn,nO,wE,Rb,xr,Mve],cO),IK=(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(bb(s));return o in Ox?o:"point"}}},ig=Ge([Er,xn,MK,GD,xr],IK);function Tve(t){if(t!=null){if(t in Ox)return Ox[t]();var e="scale".concat(bb(t));if(e in Ox)return Ox[e]()}}function dO(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=Tve(e);if(i!=null){var s=i.domain(n).range(r);return Spe(s),s}}}var hO=(t,e,n)=>{var r=iO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&od(t))return $be(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&od(t))return Vbe(t,e.tickCount,e.allowDecimals)}},fO=Ge([uO,Ob,ig],hO),pO=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&od(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},Cve=Ge([Er,uO,fO,xr],pO),Nve=Ge(wE,Er,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Dc(t.map(o=>o.value))).sort((o,c)=>o-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var s=0;s<r.length-1;s++){var a=r[s+1]-r[s];n=Math.min(n,a)}return n/i}}),UK=Ge(Nve,xn,pK,bi,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!Hn(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var a=ms(n,t*s),o=t*s/2;return o-a-(o-a)/s*a}return 0}),kve=(t,e)=>{var n=Sl(t,e);return n==null||typeof n.padding!="string"?0:UK(t,"xAxis",e,n.padding)},Pve=(t,e)=>{var n=El(t,e);return n==null||typeof n.padding!="string"?0:UK(t,"yAxis",e,n.padding)},Rve=Ge(Sl,kve,(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}}),Dve=Ge(El,Pve,(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}}),Ove=Ge([bi,Rve,sE,iE,(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]}),jve=Ge([bi,xn,Dve,sE,iE,(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]}),Ub=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Ove(t,n,r);case"yAxis":return jve(t,n,r);case"zAxis":return(i=ZD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return vK(t);case"radiusAxis":return yK(t,n);default:return}},FK=Ge([Er,Ub],gE),ld=Ge([Er,ig,Cve,FK],dO);Ge([Lb,SE,xr],hve);function zK(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var EE=(t,e)=>e,ME=(t,e,n)=>n,Lve=Ge(nE,EE,ME,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(zK)),Ive=Ge(rE,EE,ME,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(zK)),BK=(t,e)=>({width:t.width,height:e.height}),Uve=(t,e)=>{var n=typeof e.width=="number"?e.width:Eb;return{width:n,height:t.height}},HK=Ge(bi,Sl,BK),Fve=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},zve=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Bve=Ge(Uc,bi,Lve,EE,ME,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var c=BK(e,o);a==null&&(a=Fve(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;s[o.id]=a-Number(u)*c.height,a+=(u?-1:1)*c.height}),s}),Hve=Ge(Ic,bi,Ive,EE,ME,(t,e,n,r,i)=>{var s={},a;return n.forEach(o=>{var c=Uve(e,o);a==null&&(a=zve(e,r,t));var u=r==="left"&&!i||r==="right"&&i;s[o.id]=a-Number(u)*c.width,a+=(u?-1:1)*c.width}),s}),$ve=(t,e)=>{var n=Sl(t,e);if(n!=null)return Bve(t,n.orientation,n.mirror)},Vve=Ge([bi,Sl,$ve,(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}}}),Gve=(t,e)=>{var n=El(t,e);if(n!=null)return Hve(t,n.orientation,n.mirror)},Wve=Ge([bi,El,Gve,(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}}}),$K=Ge(bi,El,(t,e)=>{var n=typeof e.width=="number"?e.width:Eb;return{width:n,height:t.height}}),YB=(t,e,n)=>{switch(e){case"xAxis":return HK(t,n).width;case"yAxis":return $K(t,n).height;default:return}},VK=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:a}=n,o=wl(t,r),c=e.map(u=>u.value);if(a&&o&&s==="category"&&i&&G7(c))return c}},mO=Ge([xn,wE,Er,xr],VK),GK=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,a=wl(t,r);if(a&&(i==="number"||s!=="auto"))return e.map(o=>o.value)}},gO=Ge([xn,wE,Ob,xr],GK),ZB=Ge([xn,ive,ig,ld,mO,gO,Ub,fO,xr],(t,e,n,r,i,s,a,o,c)=>{if(e!=null){var u=wl(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:s,duplicateDomain:i,isCategorical:u,niceTicks:o,range:a,realScaleType:n,scale:r}}}),qve=(t,e,n,r,i,s,a,o,c)=>{if(!(e==null||r==null)){var u=wl(t,c),{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=c==="angleAxis"&&s!=null&&s.length>=2?Li(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=>Hn(b.coordinate))}return u&&o?o.map((b,E)=>({coordinate:r(b)+x,value:b,index:E,offset:x})).filter(b=>Hn(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}))}},WK=Ge([xn,Ob,ig,ld,fO,Ub,mO,gO,xr],qve),Kve=(t,e,n,r,i,s,a)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var o=wl(t,a),{tickCount:c}=e,u=0;return u=a==="angleAxis"&&r?.length>=2?Li(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(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},pl=Ge([xn,Ob,ld,Ub,mO,gO,xr],Kve),ml=Ge(Er,ld,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})}),Xve=Ge([Er,ig,uO,FK],dO);Ge((t,e,n)=>ZD(t,n),Xve,(t,e)=>{if(!(t==null||e==null))return uw(uw({},t),{},{scale:e})});var Yve=Ge([xn,nE,rE],(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}}),qK=t=>t.options.defaultTooltipEventType,KK=t=>t.options.validateTooltipEventTypes;function XK(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function xO(t,e){var n=qK(t),r=KK(t);return XK(e,n,r)}function Zve(t){return Ct(e=>xO(e,t))}var YK=(t,e)=>{var n,r=Number(e);if(!(Qs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},Qve=t=>t.tooltip.settings,ju={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},Jve={itemInteraction:{click:ju,hover:ju},axisInteraction:{click:ju,hover:ju},keyboardInteraction:ju,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}},ZK=Js({name:"tooltip",initialState:Jve,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:fr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:fr()},removeTooltipEntrySettings:{reducer(t,e){var n=Lo(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:eye,replaceTooltipEntrySettings:tye,removeTooltipEntrySettings:nye,setTooltipSettingsState:rye,setActiveMouseOverItemIndex:QK,mouseLeaveItem:iye,mouseLeaveChart:JK,setActiveClickItemIndex:sye,setMouseOverAxisIndex:eX,setMouseClickAxisIndex:aye,setSyncInteraction:_k,setKeyboardInteraction:wk}=ZK.actions,oye=ZK.reducer;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 ky(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){lye(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 lye(t,e,n){return(e=cye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cye(t){var e=uye(t,"string");return typeof e=="symbol"?e:e+""}function uye(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 dye(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function hye(t){return t.index!=null}var tX=(t,e,n,r)=>{if(e==null)return ju;var i=dye(t,e,n);if(i==null)return ju;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(hye(i)){if(s)return ky(ky({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return ky(ky({},ju),{},{coordinate:i.coordinate})};function fye(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 pye(t,e){var n=fye(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 mye(t,e,n){if(n==null||e==null)return!0;var r=Bn(t,e);return r==null||!od(n)?!0:pye(r,n)}var bO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!Hn(s))return i;var a=0,o=1/0;e.length>0&&(o=e.length-1);var c=Math.max(a,Math.min(s,o)),u=e[c];return u==null||mye(u,n,r)?String(c):null},nX=(t,e,n,r,i,s,a,o)=>{if(!(s==null||o==null)){var c=a[0],u=c==null?void 0:o(c.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}}}},rX=(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})},Fb=t=>t.options.tooltipPayloadSearcher,sg=t=>t.tooltip;function JB(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 e6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?JB(Object(n),!0).forEach(function(r){gye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):JB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gye(t,e,n){return(e=xye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xye(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)}function vye(t,e){return t??e}var iX=(t,e,n,r,i,s,a)=>{if(!(e==null||s==null)){var{chartData:o,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,m)=>{var x,{dataDefinedOnItem:y,settings:v}=m,b=vye(y,o),E=Array.isArray(b)?zW(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=W7(E,r,i):T=s(E,e,c,A),Array.isArray(T))T.forEach(N=>{var I=e6(e6({},v),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(yz({tooltipEntrySettings:I,dataKey:N.dataKey,payload:N.payload,value:Bn(N.payload,N.dataKey),name:N.name}))});else{var k;g.push(yz({tooltipEntrySettings:v,dataKey:S,payload:T,value:Bn(T,S),name:(k=Bn(T,A))!==null&&k!==void 0?k:v?.name}))}return g},f)}},vO=Ge([wi,xn,MK,GD,_i],IK),yye=Ge([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),_ye=Ge([_i,ng],QD),zb=Ge([yye,wi,_ye],JD,{memoizeOptions:{resultEqualityCheck:_E}}),wye=Ge([zb],t=>t.filter(vE)),Sye=Ge([zb],eO,{memoizeOptions:{resultEqualityCheck:_E}}),ag=Ge([Sye,wd],tO),Eye=Ge([wye,wd,wi],wK),yO=Ge([ag,wi,zb],rO),sX=Ge([wi],iO),Mye=Ge([wi],t=>t.allowDataOverflow),aX=Ge([sX,Mye],Jq),Aye=Ge([zb],t=>t.filter(vE)),Tye=Ge([Eye,Aye,Rb,mK],NK),Cye=Ge([Tye,wd,_i,aX],kK),Nye=Ge([zb],TK),kye=Ge([ag,wi,Nye,SE,_i],oO,{memoizeOptions:{resultEqualityCheck:yE}}),Pye=Ge([PK,_i,ng],rg),Rye=Ge([Pye,_i],OK),Dye=Ge([RK,_i,ng],rg),Oye=Ge([Dye,_i],jK),jye=Ge([DK,_i,ng],rg),Lye=Ge([jye,_i],LK),Iye=Ge([Rye,Lye,Oye],dw),Uye=Ge([wi,sX,aX,Cye,kye,Iye,xn,_i],lO),Bb=Ge([wi,xn,ag,yO,Rb,_i,Uye],cO),Fye=Ge([Bb,wi,vO],hO),zye=Ge([wi,Bb,Fye,_i],pO),oX=t=>{var e=_i(t),n=ng(t),r=!1;return Ub(t,e,n,r)},lX=Ge([wi,oX],gE),cX=Ge([wi,vO,zye,lX],dO),Bye=Ge([xn,yO,wi,_i],VK),Hye=Ge([xn,yO,wi,_i],GK),$ye=(t,e,n,r,i,s,a,o)=>{if(e){var{type:c}=e,u=wl(t,o);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=o==="angleAxis"&&i!=null&&i?.length>=2?Li(i[0]-i[1])*2*f:f,u&&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}))}}},zc=Ge([xn,wi,vO,cX,oX,Bye,Hye,_i],$ye),_O=Ge([qK,KK,Qve],(t,e,n)=>XK(n.shared,t,e)),uX=t=>t.tooltip.settings.trigger,wO=t=>t.tooltip.settings.defaultIndex,Hb=Ge([sg,_O,uX,wO],tX),cd=Ge([Hb,ag,Ib,Bb],bO),dX=Ge([zc,cd],YK),SO=Ge([Hb],t=>{if(t)return t.dataKey}),Vye=Ge([Hb],t=>{if(t)return t.graphicalItemId}),hX=Ge([sg,_O,uX,wO],rX),Gye=Ge([Ic,Uc,xn,bi,zc,wO,hX,Fb],nX),Wye=Ge([Hb,Gye],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),qye=Ge([Hb],t=>t.active),Kye=Ge([hX,cd,wd,Ib,dX,Fb,_O],iX),Xye=Ge([Kye],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function t6(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 n6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t6(Object(n),!0).forEach(function(r){Yye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Yye(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=Qye(t,"string");return typeof e=="symbol"?e:e+""}function Qye(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 Jye=()=>Ct(wi),e_e=()=>{var t=Jye(),e=Ct(zc),n=Ct(cX);return ad(!t||!n?void 0:n6(n6({},t),{},{scale:n}),e)};function r6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jf(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r6(Object(n),!0).forEach(function(r){t_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t_e(t,e,n){return(e=n_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n_e(t){var e=r_e(t,"string");return typeof e=="symbol"?e:e+""}function r_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 i_e=(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}},s_e=(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 Jf(Jf(Jf({},r),Jr(r.cx,r.cy,a,s)),{},{angle:s,radius:a})}var o=i.coordinate,{angle:c}=r;return Jf(Jf(Jf({},r),Jr(r.cx,r.cy,o,c)),{},{angle:c,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function a_e(t,e){var{chartX:n,chartY:r}=t;return n>=e.left&&n<=e.left+e.width&&r>=e.top&&r<=e.top+e.height}var fX=(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 c=0;c<o;c++){var u=c>0?n[c-1].coordinate:n[o-1].coordinate,d=n[c].coordinate,f=c>=o-1?n[0].coordinate:n[c+1].coordinate,g=void 0;if(Li(d-u)!==Li(f-d)){var m=[];if(Li(f-d)===Li(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[c]);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[c]);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},pX=()=>Ct(GD),EO=(t,e)=>e,mX=(t,e,n)=>n,MO=(t,e,n,r)=>r,o_e=Ge(zc,t=>qS(t,e=>e.coordinate)),AO=Ge([sg,EO,mX,MO],tX),TO=Ge([AO,ag,Ib,Bb],bO),l_e=(t,e,n)=>{if(e!=null){var r=sg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},gX=Ge([sg,EO,mX,MO],rX),hw=Ge([Ic,Uc,xn,bi,zc,MO,gX,Fb],nX),c_e=Ge([AO,hw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),xX=Ge([zc,TO],YK),u_e=Ge([gX,TO,wd,Ib,xX,Fb,EO],iX),d_e=Ge([AO,TO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),h_e=(t,e,n,r,i,s,a)=>{if(!(!t||!n||!r||!i)&&a_e(t,a)){var o=Dpe(t,e),c=fX(o,s,i,n,r),u=i_e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},f_e=(t,e,n,r,i,s,a)=>{if(!(!t||!r||!i||!s||!n)){var o=Yge(t,n);if(o){var c=Ope(o,e),u=fX(c,a,s,r,i),d=s_e(e,s,u,o);return{activeIndex:String(u),activeCoordinate:d}}}},p_e=(t,e,n,r,i,s,a,o)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?h_e(t,e,r,i,s,a,o):f_e(t,e,n,r,i,s,a)},m_e=Ge(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),g_e=Ge(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Rr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Jbe}});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 s6(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){x_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 x_e(t,e,n){return(e=b_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b_e(t){var e=v_e(t,"string");return typeof e=="symbol"?e:e+""}function v_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var y_e={},__e={zIndexMap:Object.values(Rr).reduce((t,e)=>s6(s6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),y_e)},w_e=new Set(Object.values(Rr));function S_e(t){return w_e.has(t)}var bX=Js({name:"zIndex",initialState:__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&&!S_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:E_e,unregisterZIndexPortal:M_e,registerZIndexPortalId:A_e,unregisterZIndexPortalId:T_e}=bX.actions,C_e=bX.reducer;function gs(t){var{zIndex:e,children:n}=t,r=hme(),i=r&&e!==void 0&&e!==0,s=vi(),a=rr();M.useLayoutEffect(()=>i?(a(E_e({zIndex:e})),()=>{a(M_e({zIndex:e}))}):vb,[a,e,i]);var o=Ct(u=>m_e(u,e,s));if(!i)return n;if(!o)return null;var c=document.getElementById(o);return c?hc.createPortal(n,c):null}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)}function a6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Py(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a6(Object(n),!0).forEach(function(r){N_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function N_e(t,e,n){return(e=k_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function k_e(t){var e=P_e(t,"string");return typeof e=="symbol"?e:e+""}function P_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 R_e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return M.isValidElement(e)?M.cloneElement(e,r):M.createElement(n,r)}function D_e(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:a,layout:o,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,m=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,v;if(d==="ScatterChart")x=f,y=dge,v=Rr.cursorLine;else if(d==="BarChart")x=hge(o,f,s,a),y=fq,v=Rr.cursorRectangle;else if(o==="radial"&&K7(f)){var{cx:b,cy:E,radius:S,startAngle:A,endAngle:T}=mq(f);x={cx:b,cy:E,startAngle:A,endAngle:T,innerRadius:S,outerRadius:S},y=xq,v=Rr.cursorLine}else x={points:exe(o,f,s)},y=tm,v=Rr.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,N=Py(Py(Py(Py({stroke:"#ccc",pointerEvents:"none"},s),x),Gh(c)),{},{payload:g,payloadIndex:m,className:En("recharts-tooltip-cursor",k)});return M.createElement(gs,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},M.createElement(R_e,{cursor:c,cursorComp:y,cursorProps:N}))}function O_e(t){var e=e_e(),n=ZW(),r=hf(),i=pX();return e==null||n==null||r==null||i==null?null:M.createElement(D_e,Sk({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var vX=M.createContext(null),j_e=()=>M.useContext(vX),YT={exports:{}},o6;function L_e(){return o6||(o6=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function s(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,f||c,g),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],m]:c._events[x].push(m):(c._events[x]=m,c._eventsCount++),c}function a(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,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})(YT)),YT.exports}var I_e=L_e();const U_e=fo(I_e);var B0=new U_e,Ek="recharts.syncEvent.tooltip",l6="recharts.syncEvent.brush";function AE(t,e){if(e){var n=Number.parseInt(e,10);if(!Qs(n))return t?.[n]}}var F_e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},yX=Js({name:"options",initialState:F_e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),z_e=yX.reducer,{createEventEmitter:B_e}=yX.actions;function H_e(t){return t.tooltip.syncInteraction}var $_e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},_X=Js({name:"chartData",initialState:$_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:c6,setDataStartEndIndexes:V_e,setComputedData:F7e}=_X.actions,G_e=_X.reducer,W_e=["x","y"];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 ep(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){q_e(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 q_e(t,e,n){return(e=K_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function K_e(t){var e=X_e(t,"string");return typeof e=="symbol"?e:e+""}function X_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 Y_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 Q_e(){var t=Ct(WD),e=Ct(qD),n=rr(),r=Ct(gK),i=Ct(zc),s=hf(),a=Mb(),o=Ct(c=>c.rootProps.className);M.useEffect(()=>{if(t==null)return vb;var c=(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=Y_e(m,W_e),{x:b,y:E,width:S,height:A}=d.payload.sourceViewBox,T=ep(ep({},v),{},{x:a.x+(S?(x-b)/S:0)*a.width,y:a.y+(A?(y-E)/A:0)*a.height});n(ep(ep({},d),{},{payload:ep(ep({},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(_k({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=_k({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 B0.on(Ek,c),()=>{B0.off(Ek,c)}},[o,n,e,t,r,i,s,a])}function J_e(){var t=Ct(WD),e=Ct(qD),n=rr();M.useEffect(()=>{if(t==null)return vb;var r=(i,s,a)=>{e!==a&&t===i&&n(V_e(s))};return B0.on(l6,r),()=>{B0.off(l6,r)}},[n,e,t])}function e1e(){var t=rr();M.useEffect(()=>{t(B_e())},[t]),Q_e(),J_e()}function t1e(t,e,n,r,i,s){var a=Ct(m=>l_e(m,t,e)),o=Ct(qD),c=Ct(WD),u=Ct(gK),d=Ct(H_e),f=d?.active,g=Mb();M.useEffect(()=>{if(!f&&c!=null&&o!=null){var m=_k({active:s,coordinate:n,dataKey:a,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});B0.emit(Ek,c,m,o)}},[f,n,a,i,r,o,c,u,s,g])}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 h6(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){n1e(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 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)}function s1e(t){return t.dataKey}function a1e(t,e){return M.isValidElement(t)?M.cloneElement(t,e):typeof t=="function"?M.createElement(t,e):M.createElement(Vme,e)}var f6=[],o1e={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 i1(t){var e,n,r=Sr(t,o1e),{active:i,allowEscapeViewBox:s,animationDuration:a,animationEasing:o,content:c,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(rye({shared:E,trigger:S,axisId:k,active:i,defaultIndex:I}))},[N,E,S,k,i,I]);var C=Mb(),D=lq(),F=Zve(E),{activeIndex:j,isActive:q}=(e=Ct(xe=>d_e(xe,F,S,I)))!==null&&e!==void 0?e:{},R=Ct(xe=>u_e(xe,F,S,I)),W=Ct(xe=>xX(xe,F,S,I)),K=Ct(xe=>c_e(xe,F,S,I)),V=R,ee=j_e(),Y=(n=i??q)!==null&&n!==void 0?n:!1,[Q,U]=uW([V,Y]),z=F==="axis"?W:void 0;t1e(F,S,K,z,j,Y);var J=T??ee;if(J==null||C==null||F==null)return null;var se=V??f6;Y||(se=f6),u&&se.length&&(se=iW(se.filter(xe=>xe.value!=null&&(xe.hide!==!0||r.includeHidden)),g,s1e));var me=se.length>0,fe=M.createElement(Zme,{allowEscapeViewBox:s,animationDuration:a,animationEasing:o,isAnimationActive:d,active:Y,coordinate:K,hasPayload:me,offset:f,position:m,reverseDirection:x,useTranslate3d:y,viewBox:C,wrapperStyle:v,lastBoundingBox:Q,innerRef:U,hasPortalFromProps:!!T},a1e(c,h6(h6({},r),{},{payload:se,label:z,active:Y,activeIndex:j,coordinate:K,accessibilityLayer:D})));return M.createElement(M.Fragment,null,hc.createPortal(fe,J),Y&&M.createElement(O_e,{cursor:b,tooltipEventType:F,coordinate:K,payload:se,index:j}))}var $b=t=>null;$b.displayName="Cell";function l1e(t,e,n){return(e=c1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c1e(t){var e=u1e(t,"string");return typeof e=="symbol"?e:e+""}function u1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class d1e{constructor(e){l1e(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 p6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function h1e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p6(Object(n),!0).forEach(function(r){f1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function f1e(t,e,n){return(e=p1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p1e(t){var e=m1e(t,"string");return typeof e=="symbol"?e:e+""}function m1e(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 g1e={cacheSize:2e3,enableCache:!0},wX=h1e({},g1e),m6=new d1e(wX.cacheSize),x1e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},g6="recharts_measurement_span";function b1e(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 x6=(t,e)=>{try{var n=document.getElementById(g6);n||(n=document.createElement("span"),n.setAttribute("id",g6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,x1e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},qx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Ym.isSsr)return{width:0,height:0};if(!wX.enableCache)return x6(e,n);var r=b1e(e,n),i=m6.get(r);if(i)return i;var s=x6(e,n);return m6.set(r,s),s},b6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,v6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,v1e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,y1e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,SX={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},_1e=Object.keys(SX),Wp="NaN";function w1e(t,e){return t*SX[e]}class Vs{static parse(e){var n,[,r,i]=(n=y1e.exec(e))!==null&&n!==void 0?n:[];return new Vs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Qs(e)&&(this.unit=""),n!==""&&!v1e.test(n)&&(this.num=NaN,this.unit=""),_1e.includes(n)&&(this.num=w1e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Vs(NaN,""):new Vs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Vs(NaN,""):new Vs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Vs(NaN,""):new Vs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Vs(NaN,""):new Vs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Qs(this.num)}}function EX(t){if(t.includes(Wp))return Wp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=b6.exec(e))!==null&&n!==void 0?n:[],a=Vs.parse(r??""),o=Vs.parse(s??""),c=i==="*"?a.multiply(o):a.divide(o);if(c.isNaN())return Wp;e=e.replace(b6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=v6.exec(e))!==null&&u!==void 0?u:[],m=Vs.parse(d??""),x=Vs.parse(g??""),y=f==="+"?m.add(x):m.subtract(x);if(y.isNaN())return Wp;e=e.replace(v6,y.toString())}return e}var y6=/\(([^()]*)\)/;function S1e(t){for(var e=t,n;(n=y6.exec(e))!=null;){var[,r]=n;e=e.replace(y6,EX(r))}return e}function E1e(t){var e=t.replace(/\s+/g,"");return e=S1e(e),e=EX(e),e}function M1e(t){try{return E1e(t)}catch{return Wp}}function ZT(t){var e=M1e(t.slice(5,-1));return e===Wp?"":e}var A1e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],T1e=["dx","dy","angle","className","breakAll"];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 _6(t,e){if(t==null)return{};var n,r,i=C1e(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 C1e(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 MX=/[ \f\n\r\t\v\u2028\u2029]+/,AX=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];dr(e)||(n?i=e.toString().split(""):i=e.toString().split(MX));var s=i.map(o=>({word:o,width:qx(o,r).width})),a=n?0:qx(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:a}}catch{return null}};function N1e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var TX=(t,e,n,r)=>t.reduce((i,s)=>{var{word:a,width:o}=s,c=i[i.length-1];if(c&&o!=null&&(e==null||r||c.width+o+n<Number(e)))c.words.push(a),c.width+=o+n;else{var u={words:[a],width:o};i.push(u)}return i},[]),CX=t=>t.reduce((e,n)=>e.width>n.width?e:n),k1e="…",w6=(t,e,n,r,i,s,a,o)=>{var c=t.slice(0,e),u=AX({breakAll:n,style:r,children:c+k1e});if(!u)return[!1,[]];var d=TX(u.wordsWithComputedWidth,s,a,o),f=d.length>i||CX(d).width>Number(s);return[f,d]},P1e=(t,e,n,r,i)=>{var{maxLines:s,children:a,style:o,breakAll:c}=t,u=Pt(s),d=String(a),f=TX(e,r,n,i);if(!u||i)return f;var g=f.length>s||CX(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]=w6(d,E,c,o,s,r,n,i),[T]=w6(d,b,c,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},S6=t=>{var e=dr(t)?[]:t.toString().split(MX);return[{words:e,width:void 0}]},R1e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:a}=t;if((e||n)&&!Ym.isSsr){var o,c,u=AX({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;o=d,c=f}else return S6(r);return P1e({breakAll:s,children:r,maxLines:a,style:i},o,c,e,!!n)}return S6(r)},NX="#808080",D1e={angle:0,breakAll:!1,capHeight:"0.71em",fill:NX,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},TE=M.forwardRef((t,e)=>{var n=Sr(t,D1e),{x:r,y:i,lineHeight:s,capHeight:a,fill:o,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=_6(n,A1e),g=M.useMemo(()=>R1e({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:m,dy:x,angle:y,className:v,breakAll:b}=f,E=_6(f,T1e);if(!co(r)||!co(i)||g.length===0)return null;var S=Number(r)+(Pt(m)?m:0),A=Number(i)+(Pt(x)?x:0);if(!Hn(S)||!Hn(A))return null;var T;switch(d){case"start":T=ZT("calc(".concat(a,")"));break;case"middle":T=ZT("calc(".concat((g.length-1)/2," * -").concat(s," + (").concat(a," / 2))"));break;default:T=ZT("calc(".concat(g.length-1," * -").concat(s,")"));break}var k=[];if(c){var N=g[0].width,{width:I}=f;k.push("scale(".concat(Pt(I)&&Pt(N)?I/N:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(S,", ").concat(A,")")),k.length&&(E.transform=k.join(" ")),M.createElement("text",Mk({},ns(E),{ref:e,x:S,y:A,className:En("recharts-text",v),textAnchor:u,fill:o.includes("url")?NX: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)}))});TE.displayName="Text";var O1e=["labelRef"];function j1e(t,e){if(t==null)return{};var n,r,i=L1e(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 L1e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function E6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Fr(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){I1e(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 I1e(t,e,n){return(e=U1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U1e(t){var e=F1e(t,"string");return typeof e=="symbol"?e:e+""}function F1e(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 uc(){return uc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},uc.apply(null,arguments)}var kX=M.createContext(null),PX=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a,children:o}=t,c=M.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:a}),[e,n,r,i,s,a]);return M.createElement(kX.Provider,{value:c},o)},RX=()=>{var t=M.useContext(kX),e=Mb();return t||YW(e)},z1e=M.createContext(null),B1e=()=>{var t=M.useContext(z1e),e=Ct(_K);return t||e},H1e=t=>{var{value:e,formatter:n}=t,r=dr(t.children)?e:t.children;return typeof n=="function"?n(r):r},CO=t=>t!=null&&typeof t=="function",$1e=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r},V1e=(t,e,n,r,i)=>{var{offset:s,className:a}=t,{cx:o,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:m}=i,x=(u+d)/2,y=$1e(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=Jr(o,c,x,b),A=Jr(o,c,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)?T0("recharts-radial-line-"):t.id;return M.createElement("text",uc({},r,{dominantBaseline:"central",className:En("recharts-radial-bar-label",a)}),M.createElement("defs",null,M.createElement("path",{id:k,d:T})),M.createElement("textPath",{xlinkHref:"#".concat(k)},n))},G1e=(t,e,n)=>{var{cx:r,cy:i,innerRadius:s,outerRadius:a,startAngle:o,endAngle:c}=t,u=(o+c)/2;if(n==="outside"){var{x:d,y:f}=Jr(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}=Jr(r,i,g,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},Ak=t=>"cx"in t&&Pt(t.cx),W1e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!Ak(n)&&(s=n);var{x:a,y:o,upperWidth:c,lowerWidth:u,height:d}=e,f=a,g=a+(c-u)/2,m=(f+g)/2,x=(c+u)/2,y=f+c/2,v=d>=0?1:-1,b=v*r,E=v>0?"end":"start",S=v>0?"start":"end",A=c>=0?1:-1,T=A*r,k=A>0?"end":"start",N=A>0?"start":"end";if(i==="top"){var I={x:f+c/2,y:o-b,textAnchor:"middle",verticalAnchor:E};return Fr(Fr({},I),s?{height:Math.max(o-s.y,0),width:c}:{})}if(i==="bottom"){var C={x:g+u/2,y:o+d+b,textAnchor:"middle",verticalAnchor:S};return Fr(Fr({},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 Fr(Fr({},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 Fr(Fr({},F),s?{width:Math.max(s.x+s.width-F.x,0),height:d}:{})}var j=s?{width:x,height:d}:{};return i==="insideLeft"?Fr({x:m+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"},j):i==="insideRight"?Fr({x:m+x-T,y:o+d/2,textAnchor:k,verticalAnchor:"middle"},j):i==="insideTop"?Fr({x:f+c/2,y:o+b,textAnchor:"middle",verticalAnchor:S},j):i==="insideBottom"?Fr({x:g+u/2,y:o+d-b,textAnchor:"middle",verticalAnchor:E},j):i==="insideTopLeft"?Fr({x:f+T,y:o+b,textAnchor:N,verticalAnchor:S},j):i==="insideTopRight"?Fr({x:f+c-T,y:o+b,textAnchor:k,verticalAnchor:S},j):i==="insideBottomLeft"?Fr({x:g+T,y:o+d-b,textAnchor:N,verticalAnchor:E},j):i==="insideBottomRight"?Fr({x:g+u-T,y:o+d-b,textAnchor:k,verticalAnchor:E},j):i&&typeof i=="object"&&(Pt(i.x)||Cc(i.x))&&(Pt(i.y)||Cc(i.y))?Fr({x:a+ms(i.x,x),y:o+ms(i.y,d),textAnchor:"end",verticalAnchor:"end"},j):Fr({x:y,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},j)},q1e={angle:0,offset:5,zIndex:Rr.label,position:"middle",textBreakAll:!1};function Cu(t){var e=Sr(t,q1e),{viewBox:n,position:r,value:i,children:s,content:a,className:o="",textBreakAll:c,labelRef:u}=e,d=B1e(),f=RX(),g=r==="center"?f:d??f,m,x,y;if(n==null?m=g:Ak(n)?m=n:m=YW(n),!m||dr(i)&&dr(s)&&!M.isValidElement(a)&&typeof a!="function")return null;var v=Fr(Fr({},e),{},{viewBox:m});if(M.isValidElement(a)){var{labelRef:b}=v,E=j1e(v,O1e);return M.cloneElement(a,E)}if(typeof a=="function"){if(x=M.createElement(a,v),M.isValidElement(x))return x}else x=H1e(e);var S=ns(e);if(Ak(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return V1e(e,r,x,S,m);y=G1e(m,e.offset,e.position)}else y=W1e(e,m);return M.createElement(gs,{zIndex:e.zIndex},M.createElement(TE,uc({ref:u,className:En("recharts-label",o)},S,y,{textAnchor:N1e(S.textAnchor)?S.textAnchor:y.textAnchor,breakAll:c}),x))}Cu.displayName="Label";var K1e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?M.createElement(Cu,uc({key:"label-implicit"},r)):co(t)?M.createElement(Cu,uc({key:"label-implicit",value:t},r)):M.isValidElement(t)?t.type===Cu?M.cloneElement(t,Fr({key:"label-implicit"},r)):M.createElement(Cu,uc({key:"label-implicit",content:t},r)):CO(t)?M.createElement(Cu,uc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?M.createElement(Cu,uc({},t,{key:"label-implicit"},r)):null};function DX(t){var{label:e,labelRef:n}=t,r=RX();return K1e(e,r,n)||null}var QT={},JT={},M6;function X1e(){return M6||(M6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(JT)),JT}var eC={},A6;function Y1e(){return A6||(A6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(eC)),eC}var T6;function Z1e(){return T6||(T6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=X1e(),n=Y1e(),r=nD();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(QT)),QT}var tC,C6;function Q1e(){return C6||(C6=1,tC=Z1e().last),tC}var J1e=Q1e();const ewe=fo(J1e);var twe=["valueAccessor"],nwe=["dataKey","clockWise","id","textBreakAll","zIndex"];function fw(){return fw=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},fw.apply(null,arguments)}function N6(t,e){if(t==null)return{};var n,r,i=rwe(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 rwe(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 iwe=t=>Array.isArray(t.value)?ewe(t.value):t.value,OX=M.createContext(void 0),NO=OX.Provider,jX=M.createContext(void 0),swe=jX.Provider;function awe(){return M.useContext(OX)}function owe(){return M.useContext(jX)}function s1(t){var{valueAccessor:e=iwe}=t,n=N6(t,twe),{dataKey:r,clockWise:i,id:s,textBreakAll:a,zIndex:o}=n,c=N6(n,nwe),u=awe(),d=owe(),f=u||d;return!f||!f.length?null:M.createElement(gs,{zIndex:o??Rr.label},M.createElement(wr,{className:"recharts-label-list"},f.map((g,m)=>{var x,y=dr(r)?e(g,m):Bn(g&&g.payload,r),v=dr(s)?{}:{id:"".concat(s,"-").concat(m)};return M.createElement(Cu,fw({key:"label-".concat(m)},ns(g),c,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}))})))}s1.displayName="LabelList";function CE(t){var{label:e}=t;return e?e===!0?M.createElement(s1,{key:"labelList-implicit"}):M.isValidElement(e)||CO(e)?M.createElement(s1,{key:"labelList-implicit",content:e}):typeof e=="object"?M.createElement(s1,fw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function Tk(){return Tk=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},Tk.apply(null,arguments)}var LX=t=>{var{cx:e,cy:n,r,className:i}=t,s=En("recharts-dot",i);return Pt(e)&&Pt(n)&&Pt(r)?M.createElement("circle",Tk({},Ns(t),tD(t),{className:s,cx:e,cy:n,r})):null},IX=t=>t.graphicalItems.polarItems,lwe=Ge([xr,Db],QD),NE=Ge([IX,Er,lwe],JD),cwe=Ge([NE],eO),kE=Ge([cwe,HD],tO),uwe=Ge([kE,Er,NE],rO);Ge([kE,Er,NE],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,a=Bn(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:a,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Bn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var k6=()=>{},dwe=Ge([kE,Er,NE,SE,xr],oO),hwe=Ge([Er,sO,aO,k6,dwe,k6,xn,xr],lO),UX=Ge([Er,xn,kE,uwe,Rb,xr,hwe],cO),fwe=Ge([UX,Er,ig],hO);Ge([Er,UX,fwe,xr],pO);var pwe={radiusAxis:{},angleAxis:{}},FX=Js({name:"polarAxis",initialState:pwe,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:z7e,removeRadiusAxis:B7e,addAngleAxis:H7e,removeAngleAxis:$7e}=FX.actions,mwe=FX.reducer;function P6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function R6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P6(Object(n),!0).forEach(function(r){gwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gwe(t,e,n){return(e=xwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xwe(t){var e=bwe(t,"string");return typeof e=="symbol"?e:e+""}function bwe(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 vwe=(t,e)=>e,kO=Ge([IX,vwe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),ywe=[],PO=(t,e,n)=>n?.length===0?ywe:n,zX=Ge([HD,kO,PO],(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=>R6(R6({},e.presentationProps),s.props))),i!=null)return i}}),_we=Ge([zX,kO,PO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,a=Bn(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:vd(a,e.dataKey),color:o,payload:r,type:e.legendType}})}),wwe=Ge([zX,kO,PO,bi],(t,e,n,r)=>{if(!(e==null||t==null))return SSe({offset:r,pieSettings:e,displayedData:t,cells:n})}),nC={exports:{}},Wn={};var D6;function Swe(){if(D6)return Wn;D6=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"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),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 c: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 Wn.ContextConsumer=s,Wn.ContextProvider=a,Wn.Element=t,Wn.ForwardRef=o,Wn.Fragment=n,Wn.Lazy=f,Wn.Memo=d,Wn.Portal=e,Wn.Profiler=i,Wn.StrictMode=r,Wn.Suspense=c,Wn.SuspenseList=u,Wn.isContextConsumer=function(y){return x(y)===s},Wn.isContextProvider=function(y){return x(y)===a},Wn.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Wn.isForwardRef=function(y){return x(y)===o},Wn.isFragment=function(y){return x(y)===n},Wn.isLazy=function(y){return x(y)===f},Wn.isMemo=function(y){return x(y)===d},Wn.isPortal=function(y){return x(y)===e},Wn.isProfiler=function(y){return x(y)===i},Wn.isStrictMode=function(y){return x(y)===r},Wn.isSuspense=function(y){return x(y)===c},Wn.isSuspenseList=function(y){return x(y)===u},Wn.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||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)},Wn.typeOf=x,Wn}var O6;function Ewe(){return O6||(O6=1,nC.exports=Swe()),nC.exports}var Mwe=Ewe(),j6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",L6=null,rC=null,BX=t=>{if(t===L6&&Array.isArray(rC))return rC;var e=[];return M.Children.forEach(t,n=>{dr(n)||(Mwe.isFragment(n)?e=e.concat(BX(n.props.children)):e.push(n))}),rC=e,L6=t,e};function RO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>j6(i)):r=[j6(e)],BX(t).forEach(i=>{var s=Wh(i,"type.displayName")||Wh(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var DO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,iC={},I6;function Awe(){return I6||(I6=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})(iC)),iC}var sC,U6;function Twe(){return U6||(U6=1,sC=Awe().isPlainObject),sC}var Cwe=Twe();const Nwe=fo(Cwe);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 z6(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){kwe(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 kwe(t,e,n){return(e=Pwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Pwe(t){var e=Rwe(t,"string");return typeof e=="symbol"?e:e+""}function Rwe(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 pw(){return pw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},pw.apply(null,arguments)}var B6=(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},Dwe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Owe=t=>{var e=Sr(t,Dwe),{x:n,y:r,upperWidth:i,lowerWidth:s,height:a,className:o}=e,{animationEasing:c,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=Qm(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=En("recharts-trapezoid",o);if(!f)return M.createElement("g",null,M.createElement("path",pw({},ns(e),{className:T,d:B6(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=cq(["strokeDasharray"],u,c);return M.createElement(Zm,{animationId:A,key:A,canBegin:m>0,duration:u,easing:c,isActive:f,begin:d},R=>{var W=On(k,i,R),K=On(N,s,R),V=On(I,a,R),ee=On(C,n,R),Y=On(D,r,R);g.current&&(y.current=W,v.current=K,b.current=V,E.current=ee,S.current=Y);var Q=R>0?{transition:q,strokeDasharray:j}:{strokeDasharray:F};return M.createElement("path",pw({},ns(e),{className:T,d:B6(ee,Y,W,K,V),ref:g,style:z6(z6({},Q),e.style)}))})},jwe=["option","shapeType","propTransformer","activeClassName"];function Lwe(t,e){if(t==null)return{};var n,r,i=Iwe(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 Iwe(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 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 mw(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){Uwe(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 Uwe(t,e,n){return(e=Fwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fwe(t){var e=zwe(t,"string");return typeof e=="symbol"?e:e+""}function zwe(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 Bwe(t,e){return mw(mw({},e),t)}function Hwe(t,e){return t==="symbols"}function $6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return M.createElement(fq,n);case"trapezoid":return M.createElement(Owe,n);case"sector":return M.createElement(xq,n);case"symbols":if(Hwe(e))return M.createElement(eD,n);break;case"curve":return M.createElement(tm,n);default:return null}}function $we(t){return M.isValidElement(t)?t.props:t}function OO(t){var{option:e,shapeType:n,propTransformer:r=Bwe,activeClassName:i="recharts-active-shape"}=t,s=Lwe(t,jwe),a;if(M.isValidElement(e))a=M.cloneElement(e,mw(mw({},s),$we(e)));else if(typeof e=="function")a=e(s,s.index);else if(Nwe(e)&&typeof e!="boolean"){var o=r(e,s);a=M.createElement($6,{shapeType:n,elementProps:o})}else{var c=s;a=M.createElement($6,{shapeType:n,elementProps:c})}return s.isActive?M.createElement(wr,{className:i},a):a}var jO=(t,e,n)=>{var r=rr();return(i,s)=>a=>{t?.(i,s,a),r(QK({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},LO=t=>{var e=rr();return(n,r)=>i=>{t?.(n,r,i),e(iye())}},IO=(t,e,n)=>{var r=rr();return(i,s)=>a=>{t?.(i,s,a),r(sye({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function PE(t){var{tooltipEntrySettings:e}=t,n=rr(),r=vi(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(eye(e)):i.current!==e&&n(tye({prev:i.current,next:e})),i.current=e)},[e,n,r]),M.useLayoutEffect(()=>()=>{i.current&&(n(nye(i.current)),i.current=null)},[n]),null}function UO(t){var{legendPayload:e}=t,n=rr(),r=vi(),i=M.useRef(null);return M.useLayoutEffect(()=>{r||(i.current===null?n(sq(e)):i.current!==e&&n(aq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(oq(i.current)),i.current=null)},[n]),null}function Vwe(t){var{legendPayload:e}=t,n=rr(),r=Ct(xn),i=M.useRef(null);return M.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(sq(e)):i.current!==e&&n(aq({prev:i.current,next:e})),i.current=e)},[n,r,e]),M.useLayoutEffect(()=>()=>{i.current&&(n(oq(i.current)),i.current=null)},[n]),null}var aC,Gwe=()=>{var[t]=M.useState(()=>T0("uid-"));return t},Wwe=(aC=Mre.useId)!==null&&aC!==void 0?aC:Gwe;function HX(t,e){var n=Wwe();return e||(t?"".concat(t,"-").concat(n):n)}var qwe=M.createContext(void 0),RE=t=>{var{id:e,type:n,children:r}=t,i=HX("recharts-".concat(n),e);return M.createElement(qwe.Provider,{value:i},r(i))},Kwe={cartesianItems:[],polarItems:[]},$X=Js({name:"graphicalItems",initialState:Kwe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:fr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Lo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Lo(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=Lo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:fr()}}}),{addCartesianGraphicalItem:Xwe,replaceCartesianGraphicalItem:Ywe,removeCartesianGraphicalItem:Zwe,addPolarGraphicalItem:Qwe,removePolarGraphicalItem:Jwe}=$X.actions,eSe=$X.reducer,tSe=t=>{var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(Xwe(t)):n.current!==t&&e(Ywe({prev:n.current,next:t})),n.current=t},[e,t]),M.useLayoutEffect(()=>()=>{n.current&&(e(Zwe(n.current)),n.current=null)},[e]),null},FO=M.memo(tSe);function nSe(t){var e=rr();return M.useLayoutEffect(()=>(e(Qwe(t)),()=>{e(Jwe(t))}),[e,t]),null}var rSe=["key"],iSe=["onMouseEnter","onClick","onMouseLeave"],sSe=["id"],aSe=["id"];function V6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V6(Object(n),!0).forEach(function(r){oSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function oSe(t,e,n){return(e=lSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lSe(t){var e=cSe(t,"string");return typeof e=="symbol"?e:e+""}function cSe(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 ud(){return ud=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},ud.apply(null,arguments)}function DE(t,e){if(t==null)return{};var n,r,i=uSe(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 uSe(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 dSe(t){var e=M.useMemo(()=>RO(t.children,$b),[t.children]),n=Ct(r=>_we(r,t.id,e));return n==null?null:M.createElement(Vwe,{legendPayload:n})}var hSe=M.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:s,fill:a,name:o,hide:c,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:vd(o,e),hide:c,type:u,color:a,unit:""}};return M.createElement(PE,{tooltipEntrySettings:d})}),fSe=(t,e)=>t>e?"start":t<e?"end":"middle",pSe=(t,e,n)=>ms(typeof e=="function"?e(t):e,n,n*.8),mSe=(t,e,n)=>{var{top:r,left:i,width:s,height:a}=e,o=pq(s,a),c=i+ms(t.cx,s,s/2),u=r+ms(t.cy,a,a/2),d=ms(t.innerRadius,o,0),f=pSe(n,t.outerRadius,o),g=t.maxRadius||Math.sqrt(s*s+a*a)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},gSe=(t,e)=>{var n=Li(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function xSe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var bSe=(t,e)=>{if(M.isValidElement(t))return M.cloneElement(t,e);if(typeof t=="function")return t(e);var n=En("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=DE(e,rSe);return M.createElement(tm,ud({},i,{type:"linear",className:n}))},vSe=(t,e,n)=>{if(M.isValidElement(t))return M.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),M.isValidElement(r)))return r;var i=En("recharts-pie-label-text",xSe(t));return M.createElement(TE,ud({},e,{alignmentBaseline:"middle",className:i}),r)};function ySe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:a}=n;if(!r||!i||!e)return null;var o=Ns(n),c=Gh(i),u=Gh(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=Jr(g.cx,g.cy,g.outerRadius+d,x),v=kr(kr(kr(kr({},o),g),{},{stroke:"none"},c),{},{index:m,textAnchor:fSe(y.x,g.cx)},y),b=kr(kr(kr(kr({},o),g),{},{fill:"none",stroke:g.fill},u),{},{index:m,points:[Jr(g.cx,g.cy,g.outerRadius,x),y],key:"line"});return M.createElement(gs,{zIndex:Rr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(m)},M.createElement(wr,null,s&&bSe(s,b),vSe(i,v,Bn(g,a))))});return M.createElement(wr,{className:"recharts-pie-labels"},f)}function _Se(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?M.createElement(CE,{label:i}):M.createElement(ySe,{sectors:e,props:n,showLabels:r})}function wSe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:a}=t,o=Ct(cd),c=Ct(SO),u=Ct(Vye),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,m=DE(i,iSe),x=jO(d,i.dataKey,a),y=LO(g),v=IO(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&&(c==null||i.dataKey===c)&&S,T=o?r:null,k=n&&A?n:T,N=kr(kr({},b),{},{stroke:b.stroke,tabIndex:-1,[GW]:E,[WW]:i.dataKey});return M.createElement(wr,ud({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},yb(m,b,E),{onMouseEnter:x(b,E),onMouseLeave:y(b,E),onClick:v(b,E)}),M.createElement(OO,ud({option:s??k,index:E,shapeType:"sector",isActive:A},N)))}))}function SSe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:a,startAngle:o,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),m=gSe(o,c),x=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(k=>Bn(k,u,0)!==0).length,b=(x>=360?v:v-1)*y,E=x-v*g-b,S=r.reduce((k,N)=>{var I=Bn(N,u,0);return k+(Pt(I)?I:0)},0),A;if(S>0){var T;A=r.map((k,N)=>{var I=Bn(k,u,0),C=Bn(k,d,N),D=mSe(n,s,k),F=(Pt(I)?I:0)/S,j,q=kr(kr({},k),i&&i[N]&&i[N].props);N?j=T.endAngle+Li(m)*y*(I!==0?1:0):j=o;var R=j+Li(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}],ee=Jr(D.cx,D.cy,K,W);return T=kr(kr(kr(kr({},n.presentationProps),{},{percent:F,cornerRadius:typeof a=="string"?parseFloat(a):a,name:C,tooltipPayload:V,midAngle:W,middleRadius:K,tooltipPosition:ee},q),D),{},{value:I,dataKey:u,startAngle:j,endAngle:R,payload:q,paddingAngle:Li(m)*y}),T})}return A}function ESe(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(swe,{value:e?i:void 0},r)}function MSe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,m=Qm(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(ESe,{showLabels:!y,sectors:i},M.createElement(Zm,{animationId:m,begin:a,duration:o,isActive:s,easing:c,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?Wh(N,"paddingAngle",0):0;if(C){var F=On(C.endAngle-C.startAngle,N.endAngle-N.startAngle,S),j=kr(kr({},N),{},{startAngle:k+D,endAngle:k+F+D});A.push(j),k=j.endAngle}else{var{endAngle:q,startAngle:R}=N,W=On(0,q-R,S),K=kr(kr({},N),{},{startAngle:k+D,endAngle:k+W+D});A.push(K),k=K.endAngle}}),n.current=A,M.createElement(wr,null,M.createElement(wSe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),M.createElement(_Se,{showLabels:!y,sectors:i,props:e}),e.children)}var ASe={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:Rr.area};function TSe(t){var{id:e}=t,n=DE(t,sSe),{hide:r,className:i,rootTabIndex:s}=t,a=M.useMemo(()=>RO(t.children,$b),[t.children]),o=Ct(d=>wwe(d,e,a)),c=M.useRef(null),u=En("recharts-pie",i);return r||o==null?(c.current=null,M.createElement(wr,{tabIndex:s,className:u})):M.createElement(gs,{zIndex:t.zIndex},M.createElement(hSe,{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(wr,{tabIndex:s,className:u},M.createElement(MSe,{props:kr(kr({},n),{},{sectors:o}),previousSectorsRef:c,id:e})))}function VX(t){var e=Sr(t,ASe),{id:n}=e,r=DE(e,aSe),i=Ns(r);return M.createElement(RE,{id:n,type:"pie"},s=>M.createElement(M.Fragment,null,M.createElement(nSe,{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(dSe,ud({},r,{id:s})),M.createElement(TSe,ud({},r,{id:s}))))}VX.displayName="Pie";var CSe=["points"];function G6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function oC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G6(Object(n),!0).forEach(function(r){NSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NSe(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=PSe(t,"string");return typeof e=="symbol"?e:e+""}function PSe(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(){return gw=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},gw.apply(null,arguments)}function RSe(t,e){if(t==null)return{};var n,r,i=DSe(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 DSe(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 OSe(t){var{option:e,dotProps:n,className:r}=t;if(M.isValidElement(e))return M.cloneElement(e,n);if(typeof e=="function")return e(n);var i=En(r,typeof e!="boolean"?e.className:""),s=n??{},{points:a}=s,o=RSe(s,CSe);return M.createElement(LX,gw({},o,{className:i}))}function jSe(t,e){return t==null?!1:e?!0:t.length===1}function GX(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:a,needClip:o,clipPathId:c,zIndex:u=Rr.scatter}=t;if(!jSe(e,n))return null;var d=DO(n),f=hde(n),g=e.map((x,y)=>{var v,b,E=oC(oC(oC({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(OSe,{key:"dot-".concat(y),option:n,dotProps:E,className:i})}),m={};return o&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),M.createElement(gs,{zIndex:u},M.createElement(wr,gw({className:r},m),g))}function W6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function q6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W6(Object(n),!0).forEach(function(r){LSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LSe(t,e,n){return(e=ISe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ISe(t){var e=USe(t,"string");return typeof e=="symbol"?e:e+""}function USe(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 FSe={xAxis:{},yAxis:{},zAxis:{}},WX=Js({name:"cartesianAxis",initialState:FSe,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]=q6(q6({},t.yAxis[n]),{},{width:r,widthHistory:a})}}}}),{addXAxis:zSe,replaceXAxis:BSe,removeXAxis:HSe,addYAxis:$Se,replaceYAxis:VSe,removeYAxis:GSe,addZAxis:V7e,replaceZAxis:G7e,removeZAxis:W7e,updateYAxisWidth:WSe}=WX.actions,qSe=WX.reducer,KSe=Ge([bi],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),XSe=Ge([KSe,Ic,Uc],(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)}}),OE=()=>Ct(XSe),YSe=()=>Ct(Xye);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 lC(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){ZSe(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 ZSe(t,e,n){return(e=QSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QSe(t){var e=JSe(t,"string");return typeof e=="symbol"?e:e+""}function JSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var eEe=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},c=lC(lC(lC({},o),Gh(i)),tD(i)),u;return M.isValidElement(i)?u=M.cloneElement(i,c):typeof i=="function"?u=i(c):u=M.createElement(LX,c),M.createElement(wr,{className:"recharts-active-dot",clipPath:a},u)};function Ck(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:a=Rr.activeDot}=t,o=Ct(cd),c=YSe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return dr(u)?null:M.createElement(gs,{zIndex:a},M.createElement(eEe,{point:u,childIndex:Number(o),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var tEe="Invariant failed";function nEe(t,e){throw new Error(tEe)}var rEe=["x","y"];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 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 px(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){iEe(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 iEe(t,e,n){return(e=sEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sEe(t){var e=aEe(t,"string");return typeof e=="symbol"?e:e+""}function aEe(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 oEe(t,e){if(t==null)return{};var n,r,i=lEe(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 lEe(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 cEe(t,e){var{x:n,y:r}=t,i=oEe(t,rEe),s="".concat(n),a=parseInt(s,10),o="".concat(r),c=parseInt(o,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return px(px(px(px(px({},e),i),a?{x:a}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function xw(t){return M.createElement(OO,Nk({shapeType:"rectangle",propTransformer:cEe,activeClassName:"recharts-active-bar"},t))}var uEe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Pt(e))return e;var s=Pt(r)||dr(r);return s?e(r,i):(s||nEe(),n)}},dEe={},qX=Js({name:"errorBars",initialState:dEe,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:q7e,replaceErrorBar:K7e,removeErrorBar:X7e}=qX.actions,hEe=qX.reducer,fEe=["children"];function pEe(t,e){if(t==null)return{};var n,r,i=mEe(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 mEe(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 gEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},xEe=M.createContext(gEe);function KX(t){var{children:e}=t,n=pEe(t,fEe);return M.createElement(xEe.Provider,{value:n},e)}function jE(t,e){var n,r,i=Ct(u=>Sl(u,t)),s=Ct(u=>El(u,e)),a=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Pi.allowDataOverflow,o=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:Ri.allowDataOverflow,c=a||o;return{needClip:c,needClipX:a,needClipY:o}}function zO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=OE(),{needClipX:s,needClipY:a,needClip:o}=jE(e,n);if(!o||!i)return null;var{x:c,y:u,width:d,height:f}=i;return M.createElement("clipPath",{id:"clipPath-".concat(r)},M.createElement("rect",{x:s?c:c-d/2,y:a?u:u-f/2,width:s?d:d*2,height:a?f:f*2}))}function bEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Hn(t.zIndex)?t.zIndex:e}var cC={exports:{}},uC={};var Y6;function vEe(){if(Y6)return uC;Y6=1;var t=Vm();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,o=t.useDebugValue;return uC.useSyncExternalStoreWithSelector=function(c,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(c,m[0],m[1]);return s(function(){x.hasValue=!0,x.value=y},[y]),o(y),y},uC}var Z6;function yEe(){return Z6||(Z6=1,cC.exports=vEe()),cC.exports}yEe();function _Ee(t){t()}function wEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){_Ee(()=>{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 Q6={notify(){},get:()=>[]};function SEe(t,e){let n,r=Q6,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 c(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(c),r=wEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=Q6)}function g(){s||(s=!0,d())}function m(){s&&(s=!1,f())}const x={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:m,getListeners:()=>r};return x}var EEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",MEe=EEe(),AEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",TEe=AEe(),CEe=()=>MEe||TEe?M.useLayoutEffect:M.useEffect,NEe=CEe();function J6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function kEe(t,e){if(J6(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])||!J6(t[n[i]],e[n[i]]))return!1;return!0}var PEe=Symbol.for("react-redux-context"),REe=typeof globalThis<"u"?globalThis:{};function DEe(){if(!M.createContext)return{};const t=REe[PEe]??=new Map;let e=t.get(M.createContext);return e||(e=M.createContext(null),t.set(M.createContext,e)),e}var OEe=DEe();function jEe(t){const{children:e,context:n,serverState:r,store:i}=t,s=M.useMemo(()=>{const c=SEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),a=M.useMemo(()=>i.getState(),[i]);NEe(()=>{const{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),a!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,a]);const o=n||OEe;return M.createElement(o.Provider,{value:s},e)}var LEe=jEe,IEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function UEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function Vb(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(IEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!kEe(t[r],e[r]))return!1}else if(!UEe(t[r],e[r]))return!1;return!0}var FEe=["onMouseEnter","onMouseLeave","onClick"],zEe=["value","background","tooltipPosition"],BEe=["id"],HEe=["onMouseEnter","onClick","onMouseLeave"];function Oc(){return Oc=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},Oc.apply(null,arguments)}function e8(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 Es(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e8(Object(n),!0).forEach(function(r){$Ee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Ee(t,e,n){return(e=VEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VEe(t){var e=GEe(t,"string");return typeof e=="symbol"?e:e+""}function GEe(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 bw(t,e){if(t==null)return{};var n,r,i=WEe(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 WEe(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 qEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:vd(n,e),payload:t}]},KEe=M.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:s,hide:a,unit:o,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:vd(s,e),hide:a,type:c,color:i,unit:o}};return M.createElement(PE,{tooltipEntrySettings:u})});function XEe(t){var e=Ct(cd),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:a,onMouseLeave:o,onClick:c}=s,u=bw(s,FEe),d=jO(a,r),f=LO(o),g=IO(c,r);if(!i||n==null)return null;var m=Gh(i);return M.createElement(gs,{zIndex:bEe(i,Rr.barBackground)},n.map((x,y)=>{var{value:v,background:b,tooltipPosition:E}=x,S=bw(x,zEe);if(!b)return null;var A=d(x,y),T=f(x,y),k=g(x,y),N=Es(Es(Es(Es(Es({option:i,isActive:String(y)===e},S),{},{fill:"#eee"},b),m),yb(u,x,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return M.createElement(xw,Oc({key:"background-bar-".concat(y)},N))}))}function YEe(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 Es(Es({},a),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:a,fill:s.fill})});return M.createElement(NO,{value:e?i:void 0},n)}function ZEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:a}=t,o=Ct(cd),c=Ct(SO),u=n&&String(s)===o&&(c==null||a===c),d=u?n:e;return u?M.createElement(gs,{zIndex:Rr.activeBar},M.createElement(xw,Oc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))):M.createElement(xw,Oc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:a}))}function QEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return M.createElement(xw,Oc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function JEe(t){var e,{data:n,props:r}=t,i=(e=Ns(r))!==null&&e!==void 0?e:{},{id:s}=i,a=bw(i,BEe),{shape:o,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,m=bw(r,HEe),x=jO(d,c),y=LO(g),v=IO(f,c);return n?M.createElement(M.Fragment,null,n.map((b,E)=>M.createElement(wr,Oc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(E),className:"recharts-bar-rectangle"},yb(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:c}):M.createElement(QEe,{shape:o,baseProps:a,entry:b,index:E,dataKey:c})))):null}function eMe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:a,animationDuration:o,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=Qm(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(YEe,{showLabels:y,rects:r},M.createElement(Zm,{animationId:g,begin:a,duration:o,isActive:s,easing:c,onAnimationEnd:v,onAnimationStart:b,key:g},E=>{var S=E===1?r:r?.map((A,T)=>{var k=f&&f[T];if(k)return Es(Es({},A),{},{x:On(k.x,A.x,E),y:On(k.y,A.y,E),width:On(k.width,A.width,E),height:On(k.height,A.height,E)});if(i==="horizontal"){var N=On(0,A.height,E),I=On(A.stackedBarStart,A.y,E);return Es(Es({},A),{},{y:I,height:N})}var C=On(0,A.width,E),D=On(A.stackedBarStart,A.x,E);return Es(Es({},A),{},{width:C,x:D})});return E>0&&(n.current=S??null),S==null?null:M.createElement(wr,null,M.createElement(JEe,{props:e,data:S}))}),M.createElement(CE,{label:e.label}),e.children)}function tMe(t){var e=M.useRef(null);return M.createElement(eMe,{previousRectanglesRef:e,props:t})}var XX=0,nMe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Bn(t,e)}};class rMe extends M.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:s,yAxisId:a,needClip:o,background:c,id:u}=this.props;if(e||n==null)return null;var d=En("recharts-bar",i),f=u;return M.createElement(wr,{className:d,id:u},o&&M.createElement("defs",null,M.createElement(zO,{clipPathId:f,xAxisId:s,yAxisId:a})),M.createElement(wr,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},M.createElement(XEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),M.createElement(tMe,this.props)))}}var iMe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:XX,xAxisId:0,yAxisId:0,zIndex:Rr.bar};function sMe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=jE(e,n),g=hf(),m=vi(),x=RO(t.children,$b),y=Ct(E=>DMe(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(KX,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:nMe,errorBarOffset:v},M.createElement(rMe,Oc({},t,{layout:g,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:a,animationBegin:o,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function aMe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:a,yAxis:o,xAxisTicks:c,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=Npe({numericAxis:v}),S=v.scale(E);return f.map((A,T)=>{var k,N,I,C,D,F;d?k=Epe(d[T+y],b):(k=Bn(A,n),Array.isArray(k)||(k=[E,k]));var j=uEe(r,XX)(k[1],T);if(e==="horizontal"){var q,[R,W]=[o.scale(k[0]),o.scale(k[1])];N=xz({axis:a,ticks:c,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=Qs(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=Li(D||j)*(Math.abs(j)-Math.abs(D));I-=V,D+=V}}else{var[ee,Y]=[a.scale(k[0]),a.scale(k[1])];if(N=ee,I=xz({axis:o,ticks:u,bandSize:s,offset:i.offset,entry:A,index:T}),C=Y-ee,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 Q=Li(C||j)*(Math.abs(j)-Math.abs(C));C+=Q}}if(N==null||I==null||C==null||D==null)return null;var U=Es(Es({},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 oMe(t){var e=Sr(t,iMe),n=vi();return M.createElement(RE,{id:e.id,type:"bar"},r=>M.createElement(M.Fragment,null,M.createElement(UO,{legendPayload:qEe(e)}),M.createElement(KEe,{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(FO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:$W(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),M.createElement(gs,{zIndex:e.zIndex},M.createElement(sMe,Oc({},e,{id:r})))))}var YX=M.memo(oMe,Vb);YX.displayName="Bar";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 Ry(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){lMe(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 lMe(t,e,n){return(e=cMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cMe(t){var e=uMe(t,"string");return typeof e=="symbol"?e:e+""}function uMe(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 dMe=(t,e)=>e,hMe=(t,e,n)=>n,fMe=(t,e,n,r)=>r,pMe=(t,e,n,r,i)=>i,Gb=Ge([jb,pMe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),mMe=Ge([Gb],t=>t?.maxBarSize),gMe=(t,e,n,r,i,s)=>s,n8=(t,e,n)=>{var r=n??t;if(!dr(r))return ms(r,e,0)},xMe=Ge([xn,jb,dMe,hMe,fMe],(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")),bMe=(t,e,n,r)=>{var i=xn(t);return i==="horizontal"?z0(t,"yAxis",n,r):z0(t,"xAxis",e,r)},vMe=(t,e,n)=>{var r=xn(t);return r==="horizontal"?YB(t,"xAxis",e):YB(t,"yAxis",n)},yMe=(t,e,n)=>{var r={},i=t.filter(vE),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=n8(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:m}}),c=s.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=n8(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...o,...c]},_Me=Ge([xMe,Wbe,vMe],yMe),wMe=(t,e,n,r,i)=>{var s,a,o=Gb(t,e,n,r,i);if(o!=null){var c=xn(t),u=fK(t),{maxBarSize:d}=o,f=dr(d)?u:d,g,m;return c==="horizontal"?(g=ml(t,"xAxis",e,r),m=pl(t,"xAxis",e,r)):(g=ml(t,"yAxis",n,r),m=pl(t,"yAxis",n,r)),(s=(a=ad(g,m,!0))!==null&&a!==void 0?a:f)!==null&&s!==void 0?s:0}},ZX=(t,e,n,r)=>{var i=xn(t),s,a;return i==="horizontal"?(s=ml(t,"xAxis",e,r),a=pl(t,"xAxis",e,r)):(s=ml(t,"yAxis",n,r),a=pl(t,"yAxis",n,r)),ad(s,a)};function SMe(t,e,n,r,i){var s=r.length;if(!(s<1)){var a=ms(t,n,0,!0),o,c=[];if(Hn(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},c)}else{var x=ms(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=Hn(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}}],c)}return o}}var EMe=(t,e,n,r,i,s,a)=>{var o=dr(a)?e:a,c=SMe(n,r,i!==s?i:s,t,o);return i!==s&&c!=null&&(c=c.map(u=>Ry(Ry({},u),{},{position:Ry(Ry({},u.position),{},{offset:u.position.offset-i/2})}))),c},MMe=Ge([_Me,fK,Gbe,pK,wMe,ZX,mMe],EMe),AMe=(t,e,n,r)=>ml(t,"xAxis",e,r),TMe=(t,e,n,r)=>ml(t,"yAxis",n,r),CMe=(t,e,n,r)=>pl(t,"xAxis",e,r),NMe=(t,e,n,r)=>pl(t,"yAxis",n,r),kMe=Ge([MMe,Gb],(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}}),PMe=(t,e)=>{var n=bE(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)}}}},RMe=Ge([bMe,Gb],PMe),DMe=Ge([bi,hD,AMe,TMe,CMe,NMe,kMe,xn,Pb,ZX,RMe,Gb,gMe],(t,e,n,r,i,s,a,o,c,u,d,f,g)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:y}=c;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 aMe({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})}}),QX=t=>{var{chartData:e}=t,n=rr(),r=vi();return M.useEffect(()=>r?()=>{}:(n(c6(e)),()=>{n(c6(void 0))}),[e,n,r]),null},r8={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},JX=Js({name:"brush",initialState:r8,reducers:{setBrushSettings(t,e){return e.payload==null?r8:e.payload}}}),{setBrushSettings:Y7e}=JX.actions,OMe=JX.reducer;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 Dy(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){eY(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 eY(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=LMe(t,"string");return typeof e=="symbol"?e:e+""}function LMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var IMe=(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)}},UMe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return IMe({x:e,y:n},{x:r,y:i})};class LE{static create(e){return new LE(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}}eY(LE,"EPS",1e-4);var FMe=t=>{var e=Object.keys(t).reduce((n,r)=>Dy(Dy({},n),{},{[r]:LE.create(t[r])}),{});return Dy(Dy({},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 zMe(t){return(t%180+180)%180}var BMe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=zMe(i),a=s*Math.PI/180,o=Math.atan(r/n),c=a>o&&a<Math.PI-o?r/Math.sin(a):n/Math.cos(a);return Math.abs(c)},HMe={dots:[],areas:[],lines:[]},tY=Js({name:"referenceElements",initialState:HMe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Lo(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=Lo(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=Lo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:Z7e,removeDot:Q7e,addArea:J7e,removeArea:eWe,addLine:$Me,removeLine:VMe}=tY.actions,GMe=tY.reducer,nY=M.createContext(void 0),WMe=t=>{var{children:e}=t,[n]=M.useState("".concat(T0("recharts"),"-clip")),r=OE();if(r==null)return null;var{x:i,y:s,width:a,height:o}=r;return M.createElement(nY.Provider,{value:n},M.createElement("defs",null,M.createElement("clipPath",{id:n},M.createElement("rect",{x:i,y:s,height:o,width:a}))),e)},qMe=()=>M.useContext(nY);function s8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function a8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s8(Object(n),!0).forEach(function(r){KMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 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 ZMe=(t,e)=>{var n;if(M.isValidElement(t))n=M.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Hn(e.x1)||!Hn(e.y1)||!Hn(e.x2)||!Hn(e.y2))return null;n=M.createElement("line",vw({},e,{className:"recharts-reference-line-line"}))}return n},QMe=(t,e,n,r,i,s)=>{var{x:a,width:o}=s,c=i.y.apply(t,{position:n});if(Qs(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:a+o,y:c},{x:a,y:c}];return r==="left"?u.reverse():u},JMe=(t,e,n,r,i,s)=>{var{y:a,height:o}=s,c=i.x.apply(t,{position:n});if(Qs(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:a+o},{x:c,y:a}];return r==="top"?u.reverse():u},e2e=(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},t2e=(t,e,n,r,i,s)=>{var{x:a,y:o,segment:c,ifOverflow:u}=s,d=co(a),f=co(o);return f?QMe(o,u,n,i,t,e):d?JMe(a,u,n,r,t,e):c!=null&&c.length===2?e2e(c,u,n,t):null};function n2e(t){var e=rr();return M.useEffect(()=>(e($Me(t)),()=>{e(VMe(t))})),null}function r2e(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,a=vi(),o=qMe(),c=Ct(k=>Sl(k,e)),u=Ct(k=>El(k,n)),d=Ct(k=>ld(k,"xAxis",e,a)),f=Ct(k=>ld(k,"yAxis",n,a)),g=Mb();if(!o||!g||c==null||u==null||d==null||f==null)return null;var m=FMe({x:d,y:f}),x=t2e(m,g,t.position,c.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=a8(a8({clipPath:S},ns(t)),{},{x1:y,y1:v,x2:b,y2:E}),T=UMe({x1:y,y1:v,x2:b,y2:E});return M.createElement(gs,{zIndex:t.zIndex},M.createElement(wr,{className:En("recharts-reference-line",i)},ZMe(r,A),M.createElement(PX,vw({},T,{lowerWidth:T.width,upperWidth:T.width}),M.createElement(DX,{label:t.label}),t.children)))}var i2e={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Rr.line};function jx(t){var e=Sr(t,i2e);return M.createElement(M.Fragment,null,M.createElement(n2e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),M.createElement(r2e,e))}jx.displayName="ReferenceLine";function rY(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 s2e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return BMe(r,n)}function a2e(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 yw(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 o2e(t,e){return rY(t,e+1)}function l2e(t,e,n,r,i){for(var s=(r||[]).slice(),{start:a,end:o}=e,c=0,u=1,d=a,f=function(){var x=r?.[c];if(x===void 0)return{v:rY(r,u)};var y=c,v,b=()=>(v===void 0&&(v=n(x,y)),v),E=x.coordinate,S=c===0||yw(t,E,b,d,o);S||(c=0,d=a,u+=1),S&&(d=E+t*(b()/2+i),c+=u)},g;u<=s.length;)if(g=f(),g)return g.v;return[]}function o8(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?o8(Object(n),!0).forEach(function(r){c2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function c2e(t,e,n){return(e=u2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u2e(t){var e=d2e(t,"string");return typeof e=="symbol"?e:e+""}function d2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function h2e(t,e,n,r,i){for(var s=(r||[]).slice(),a=s.length,{start:o}=e,{end:c}=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-c);s[g]=m=ds(ds({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else s[g]=m=ds(ds({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var b=yw(t,m.tickCoord,y,o,c);b&&(c=m.tickCoord-t*(y()/2+i),s[g]=ds(ds({},m),{},{isShow:!0}))}},d=a-1;d>=0;d--)u(d);return s}function f2e(t,e,n,r,i,s){var a=(r||[]).slice(),o=a.length,{start:c,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=ds(ds({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var m=yw(t,d.tickCoord,()=>f,c,u);m&&(u=d.tickCoord-t*(f/2+i),a[o-1]=ds(ds({},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-c);a[E]=S=ds(ds({},S),{},{tickCoord:k<0?S.coordinate-k*t:S.coordinate})}else a[E]=S=ds(ds({},S),{},{tickCoord:S.coordinate});if(S.tickCoord!=null){var N=yw(t,S.tickCoord,T,c,u);N&&(c=S.tickCoord+t*(T()/2+i),a[E]=ds(ds({},S),{},{isShow:!0}))}},v=0;v<x;v++)y(v);return a}function BO(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:a,orientation:o,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Pt(c)||Ym.isSsr){var g;return(g=o2e(i,Pt(c)?c:0))!==null&&g!==void 0?g:[]}var m=[],x=o==="top"||o==="bottom"?"width":"height",y=d&&x==="width"?qx(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"?s2e(qx(T,{fontSize:e,letterSpacing:n}),y,f):qx(T,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?Li(i[1].coordinate-i[0].coordinate):1,E=a2e(s,b,x);return c==="equidistantPreserveStart"?l2e(b,E,v,i,a):(c==="preserveStart"||c==="preserveStartEnd"?m=f2e(b,E,v,i,a,c==="preserveStartEnd"):m=h2e(b,E,v,i,a),m.filter(S=>S.isShow))}var p2e=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,c=i+s,u=a+c+o+(n?r:0);return Math.round(u)}return 0},m2e=["axisLine","width","height","className","hide","ticks","axisType"];function g2e(t,e){if(t==null)return{};var n,r,i=x2e(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 x2e(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 Yh(){return Yh=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},Yh.apply(null,arguments)}function l8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l8(Object(n),!0).forEach(function(r){b2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function b2e(t,e,n){return(e=v2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function v2e(t){var e=y2e(t,"string");return typeof e=="symbol"?e:e+""}function y2e(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={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:Rr.axis};function _2e(t){var{x:e,y:n,width:r,height:i,orientation:s,mirror:a,axisLine:o,otherSvgProps:c}=t;if(!o)return null;var u=Xr(Xr(Xr({},c),Ns(o)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!a||s==="bottom"&&a);u=Xr(Xr({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(s==="left"&&!a||s==="right"&&a);u=Xr(Xr({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return M.createElement("line",Yh({},u,{className:En("recharts-cartesian-axis-line",Wh(o,"className"))}))}function w2e(t,e,n,r,i,s,a,o,c){var u,d,f,g,m,x,y=o?-1:1,v=t.tickSize||a,b=Pt(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*c,m=b;break;case"left":f=g=t.coordinate,d=e+ +!o*r,u=d-y*v,m=u-y*c,x=b;break;case"right":f=g=t.coordinate,d=e+ +o*r,u=d+y*v,m=u+y*c,x=b;break;default:u=d=t.coordinate,g=n+ +o*i,f=g+y*v,x=f+y*c,m=b;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:m,y:x}}}function S2e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function E2e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function M2e(t){var{option:e,tickProps:n,value:r}=t,i,s=En(n.className,"recharts-cartesian-axis-tick-value");if(M.isValidElement(e))i=M.cloneElement(e,Xr(Xr({},n),{},{className:s}));else if(typeof e=="function")i=e(Xr(Xr({},n),{},{className:s}));else{var a="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(a=En(a,e?.className)),i=M.createElement(TE,Yh({},n,{className:a}),r)}return i}var A2e=M.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:a,unit:o,padding:c,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=BO(Xr(Xr({},A),{},{ticks:n}),E,S),I=S2e(d,f),C=E2e(d,f),D=Ns(A),F=Gh(r),j={};typeof i=="object"&&(j=i);var q=Xr(Xr({},D),{},{fill:"none"},j),R=N.map(V=>Xr({entry:V},w2e(V,g,m,x,y,d,v,f,b))),W=R.map(V=>{var{entry:ee,line:Y}=V;return M.createElement(wr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(ee.value,"-").concat(ee.coordinate,"-").concat(ee.tickCoord)},i&&M.createElement("line",Yh({},q,Y,{className:En("recharts-cartesian-axis-tick-line",Wh(i,"className"))})))}),K=R.map((V,ee)=>{var{entry:Y,tick:Q}=V,U=Xr(Xr(Xr(Xr({textAnchor:I,verticalAnchor:C},D),{},{stroke:"none",fill:s},F),Q),{},{index:ee,payload:Y,visibleTicksCount:N.length,tickFormatter:a,padding:c},u);return M.createElement(wr,Yh({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},yb(T,Y,ee)),r&&M.createElement(M2e,{option:r,tickProps:U,value:"".concat(typeof a=="function"?a(Y.value,ee):Y.value).concat(o||"")}))});return M.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(k,"-ticks")},K.length>0&&M.createElement(gs,{zIndex:Rr.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))}),T2e=M.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:a,ticks:o,axisType:c}=t,u=g2e(t,m2e),[d,f]=M.useState(""),[g,m]=M.useState(""),x=M.useRef(null);M.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return p2e({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(gs,{zIndex:t.zIndex},M.createElement(wr,{className:En("recharts-cartesian-axis",s)},M.createElement(_2e,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ns(t)}),M.createElement(A2e,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),M.createElement(PX,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},M.createElement(DX,{label:t.label,labelRef:t.labelRef}),t.children)))}),HO=M.forwardRef((t,e)=>{var n=Sr(t,_c);return M.createElement(T2e,Yh({},n,{ref:e}))});HO.displayName="CartesianAxis";var C2e=["x1","y1","x2","y2","key"],N2e=["offset"],k2e=["xAxisId","yAxisId"],P2e=["xAxisId","yAxisId"];function c8(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 fs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c8(Object(n),!0).forEach(function(r){R2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R2e(t,e,n){return(e=D2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D2e(t){var e=O2e(t,"string");return typeof e=="symbol"?e:e+""}function O2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function mh(){return mh=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},mh.apply(null,arguments)}function _w(t,e){if(t==null)return{};var n,r,i=j2e(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 j2e(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 L2e=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 iY(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:c,key:u}=n,d=_w(n,C2e),f=(i=Ns(d))!==null&&i!==void 0?i:{},{offset:g}=f,m=_w(f,N2e);r=M.createElement("line",mh({},m,{x1:s,y1:a,x2:o,y2:c,fill:"none",key:u}))}return r}function I2e(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=_w(t,k2e),c=i.map((u,d)=>{var f=fs(fs({},o),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return M.createElement(iY,{key:"line-".concat(d),option:r,lineItemProps:f})});return M.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function U2e(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=_w(t,P2e),c=i.map((u,d)=>{var f=fs(fs({},o),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return M.createElement(iY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return M.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function F2e(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:s,height:a,horizontalPoints:o,horizontal:c=!0}=t;if(!c||!e||!e.length||o==null)return null;var u=o.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var 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 z2e(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:s,width:a,height:o,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var 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 B2e=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return BW(BO(fs(fs(fs({},_c),n),{},{ticks:HW(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},H2e=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return BW(BO(fs(fs(fs({},_c),n),{},{ticks:HW(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},$2e={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Rr.grid};function ww(t){var e=pD(),n=mD(),r=ZW(),i=fs(fs({},Sr(t,$2e)),{},{x:Pt(t.x)?t.x:r.left,y:Pt(t.y)?t.y:r.top,width:Pt(t.width)?t.width:r.width,height:Pt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:a,x:o,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:m}=i,x=vi(),y=Ct(C=>ZB(C,"xAxis",s,x)),v=Ct(C=>ZB(C,"yAxis",a,x));if(!hl(u)||!hl(d)||!Pt(o)||!Pt(c))return null;var b=i.verticalCoordinatesGenerator||B2e,E=i.horizontalCoordinatesGenerator||H2e,{horizontalPoints:S,verticalPoints:A}=i;if((!S||!S.length)&&typeof E=="function"){var T=g&&g.length,k=E({yAxis:v?fs(fs({},v),{},{ticks:T?g:v.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);G1(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?fs(fs({},y),{},{ticks:N?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);G1(Array.isArray(I),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof I,"]")),Array.isArray(I)&&(A=I)}return M.createElement(gs,{zIndex:i.zIndex},M.createElement("g",{className:"recharts-cartesian-grid"},M.createElement(L2e,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),M.createElement(F2e,mh({},i,{horizontalPoints:S})),M.createElement(z2e,mh({},i,{verticalPoints:A})),M.createElement(I2e,mh({},i,{offset:r,horizontalPoints:S,xAxis:y,yAxis:v})),M.createElement(U2e,mh({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:v}))))}ww.displayName="CartesianGrid";var sY=(t,e,n,r)=>ml(t,"xAxis",e,r),aY=(t,e,n,r)=>pl(t,"xAxis",e,r),oY=(t,e,n,r)=>ml(t,"yAxis",n,r),lY=(t,e,n,r)=>pl(t,"yAxis",n,r),V2e=Ge([xn,sY,oY,aY,lY],(t,e,n,r,i)=>wl(t,"xAxis")?ad(e,r,!1):ad(n,i,!1)),G2e=(t,e,n,r,i)=>i;function W2e(t){return t.type==="line"}var q2e=Ge([jb,G2e],(t,e)=>t.filter(W2e).find(n=>n.id===e)),K2e=Ge([xn,sY,oY,aY,lY,q2e,V2e,Pb],(t,e,n,r,i,s,a,o)=>{var{chartData:c,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=c?.slice(u,d+1),m!=null)return pAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:a,displayedData:m})}});function cY(t){var e=Gh(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 X2e=["id"],Y2e=["type","layout","connectNulls","needClip","shape"],Z2e=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function H0(){return H0=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},H0.apply(null,arguments)}function u8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u8(Object(n),!0).forEach(function(r){Q2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q2e(t,e,n){return(e=J2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function J2e(t){var e=eAe(t,"string");return typeof e=="symbol"?e:e+""}function eAe(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 $O(t,e){if(t==null)return{};var n,r,i=tAe(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 tAe(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 nAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:vd(n,e),payload:t}]},rAe=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:vd(a,e),hide:o,type:u,color:r,unit:c}};return M.createElement(PE,{tooltipEntrySettings:d})}),uY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function iAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var sAe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return uY(e,t);for(var i=Math.floor(t/r),s=t%r,a=e-t,o=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>s){o=[...n.slice(0,c),s-u];break}var d=o.length%2===0?[0,a]:[a];return[...iAe(n,i),...o,...d].map(f=>"".concat(f,"px")).join(", ")};function aAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:a}=r,{id:o}=r,c=$O(r,X2e),u=Ns(c);return M.createElement(GX,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:a,clipPathId:e})}function oAe(t){var{showLabels:e,children:n,points:r}=t,i=M.useMemo(()=>r?.map(s=>{var a,o,c={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 tl(tl({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return M.createElement(NO,{value:e?i:void 0},n)}function d8(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:a,layout:o,connectNulls:c,needClip:u,shape:d}=s,f=$O(s,Y2e),g=tl(tl({},ns(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:a,layout:o,connectNulls:c,strokeDasharray:i??s.strokeDasharray});return M.createElement(M.Fragment,null,r?.length>1&&M.createElement(OO,H0({shapeType:"curve",option:d},g,{pathRef:n})),M.createElement(aAe,{points:r,clipPathId:e,props:s}))}function lAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function cAe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:a,strokeDasharray:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:m,height:x,onAnimationEnd:y,onAnimationStart:v}=n,b=i.current,E=Qm(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=lAe(r.current),D=M.useRef(0);S.current!==E&&(D.current=s.current,S.current=E);var F=D.current;return M.createElement(oAe,{points:a,showLabels:k},n.children,M.createElement(Zm,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:I,key:E},j=>{var q=On(F,C+F,j),R=Math.min(q,C),W;if(c)if(o){var K="".concat(o).split(/[,\s]+/gim).map(Y=>parseFloat(Y));W=sAe(R,C,K)}else W=uY(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,ee=j===1?a:a.map((Y,Q)=>{var U=Math.floor(Q*V);if(b[U]){var z=b[U];return tl(tl({},Y),{},{x:On(z.x,Y.x,j),y:On(z.y,Y.y,j)})}return g?tl(tl({},Y),{},{x:On(m*2,Y.x,j),y:On(x/2,Y.y,j)}):tl(tl({},Y),{},{x:Y.x,y:Y.y})});return i.current=ee,M.createElement(d8,{props:n,points:ee,clipPathId:e,pathRef:r,strokeDasharray:W})}return M.createElement(d8,{props:n,points:a,clipPathId:e,pathRef:r,strokeDasharray:W})}),M.createElement(CE,{label:n.label}))}function uAe(t){var{clipPathId:e,props:n}=t,r=M.useRef(null),i=M.useRef(0),s=M.useRef(null);return M.createElement(cAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var dAe=(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:Bn(t.payload,e)}};class hAe extends M.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:a,top:o,left:c,width:u,height:d,id:f,needClip:g,zIndex:m}=this.props;if(e)return null;var x=En("recharts-line",i),y=f,{r:v,strokeWidth:b}=cY(n),E=DO(n),S=v*2+b,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(y,")"):void 0;return M.createElement(gs,{zIndex:m},M.createElement(wr,{className:x},g&&M.createElement("defs",null,M.createElement(zO,{clipPathId:y,xAxisId:s,yAxisId:a}),!E&&M.createElement("clipPath",{id:"clipPath-dots-".concat(y)},M.createElement("rect",{x:c-S/2,y:o-S/2,width:u+S,height:d+S}))),M.createElement(KX,{xAxisId:s,yAxisId:a,data:r,dataPointFormatter:dAe,errorBarOffset:0},M.createElement(uAe,{props:this.props,clipPathId:y}))),M.createElement(Ck,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var dY={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:Rr.line,type:"linear"};function fAe(t){var e=Sr(t,dY),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:m,yAxisId:x,id:y}=e,v=$O(e,Z2e),{needClip:b}=jE(m,x),E=OE(),S=hf(),A=vi(),T=Ct(D=>K2e(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(hAe,H0({},v,{id:y,connectNulls:o,dot:c,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 pAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,dataKey:a,bandSize:o,displayedData:c}=t;return c.map((u,d)=>{var f=Bn(u,a);if(e==="horizontal"){var g=V1({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=V1({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 mAe(t){var e=Sr(t,dY),n=vi();return M.createElement(RE,{id:e.id,type:"line"},r=>M.createElement(M.Fragment,null,M.createElement(UO,{legendPayload:nAe(e)}),M.createElement(rAe,{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(FO,{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(fAe,H0({},e,{id:r}))))}var hY=M.memo(mAe,Vb);hY.displayName="Line";var fY=(t,e,n,r)=>ml(t,"xAxis",e,r),pY=(t,e,n,r)=>pl(t,"xAxis",e,r),mY=(t,e,n,r)=>ml(t,"yAxis",n,r),gY=(t,e,n,r)=>pl(t,"yAxis",n,r),gAe=Ge([xn,fY,mY,pY,gY],(t,e,n,r,i)=>wl(t,"xAxis")?ad(e,r,!1):ad(n,i,!1)),xAe=(t,e,n,r,i)=>i,xY=Ge([jb,xAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),bAe=(t,e,n,r,i)=>{var s,a=xY(t,e,n,r,i);if(a!=null){var o=xn(t),c=wl(o,"xAxis"),u;if(c?u=z0(t,"yAxis",n,r):u=z0(t,"xAxis",e,r),u!=null){var{stackId:d}=a,f=bE(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)}}}},vAe=Ge([xn,fY,mY,pY,gY,bAe,Pb,gAe,xY,qbe],(t,e,n,r,i,s,a,o,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=a;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null)){var{data:m}=c,x;if(m&&m.length>0?x=m:x=d?.slice(f,g+1),x!=null)return UAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:o})}}),yAe=["id"],_Ae=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Ch(){return Ch=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},Ch.apply(null,arguments)}function bY(t,e){if(t==null)return{};var n,r,i=wAe(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 wAe(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 h8(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 qp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h8(Object(n),!0).forEach(function(r){SAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SAe(t,e,n){return(e=EAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EAe(t){var e=MAe(t,"string");return typeof e=="symbol"?e:e+""}function MAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Sw(t,e){return t&&t!=="none"?t:e}var AAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:a}=t;return[{inactive:a,dataKey:e,type:s,color:Sw(r,i),value:vd(n,e),payload:t}]},TAe=M.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:s,name:a,hide:o,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:s,dataKey:e,nameKey:void 0,name:vd(a,e),hide:o,type:u,color:Sw(r,s),unit:c}};return M.createElement(PE,{tooltipEntrySettings:d})});function CAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:a}=r,o=Ns(r);return M.createElement(GX,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:a,baseProps:o,needClip:i,clipPathId:e})}function NAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(s=>{var a,o,c={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 qp(qp({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return M.createElement(NO,{value:e?i:void 0},n)}function f8(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:s}=t,{layout:a,type:o,stroke:c,connectNulls:u,isRange:d}=s,{id:f}=s,g=bY(s,yAe),m=Ns(g),x=ns(g);return M.createElement(M.Fragment,null,e?.length>1&&M.createElement(wr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},M.createElement(tm,Ch({},x,{id:f,points:e,connectNulls:u,type:o,baseLine:n,layout:a,stroke:"none",className:"recharts-area-area"})),c!=="none"&&M.createElement(tm,Ch({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&M.createElement(tm,Ch({},m,{className:"recharts-area-curve",layout:a,type:o,connectNulls:u,fill:"none",points:n}))),M.createElement(CAe,{points:e,props:g,clipPathId:i}))}function kAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,a=r[r.length-1].y;if(!Hn(s)||!Hn(a))return null;var o=e*Math.abs(s-a),c=Math.max(...r.map(u=>u.x||0));return Pt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Pt(c)?M.createElement("rect",{x:0,y:s<a?s:s-o,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(o)}):null}function PAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,a=r[r.length-1].x;if(!Hn(s)||!Hn(a))return null;var o=e*Math.abs(s-a),c=Math.max(...r.map(u=>u.y||0));return Pt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Pt(c)?M.createElement("rect",{x:s<a?s:s-o,y:0,width:o,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function RAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?M.createElement(kAe,{alpha:e,points:r,baseLine:i,strokeWidth:s}):M.createElement(PAe,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function DAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:a,baseLine:o,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:m}=r,x=M.useMemo(()=>({points:a,baseLine:o}),[a,o]),y=Qm(x,"recharts-area-"),v=dme(),[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(NAe,{showLabels:S,points:a},r.children,M.createElement(Zm,{animationId:y,begin:u,duration:d,isActive:c,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 qp(qp({},j),{},{x:On(W.x,j.x,I),y:On(W.y,j.y,I)})}return j}),F;return Pt(o)?F=On(N,o,I):dr(o)||Qs(o)?F=On(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 qp(qp({},j),{},{x:On(W.x,j.x,I),y:On(W.y,j.y,I)})}return j}),I>0&&(i.current=D,s.current=F),M.createElement(f8,{points:D,baseLine:F,needClip:e,clipPathId:n,props:r})}return I>0&&(i.current=a,s.current=o),M.createElement(wr,null,c&&M.createElement("defs",null,M.createElement("clipPath",{id:"animationClipPath-".concat(n)},M.createElement(RAe,{alpha:I,points:a,baseLine:o,layout:v,strokeWidth:r.strokeWidth}))),M.createElement(wr,{clipPath:"url(#animationClipPath-".concat(n,")")},M.createElement(f8,{points:a,baseLine:o,needClip:e,clipPathId:n,props:r})))}),M.createElement(CE,{label:r.label}))}function OAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=M.useRef(null),s=M.useRef();return M.createElement(DAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class jAe extends M.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:a,needClip:o,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:m,zIndex:x}=this.props;if(e)return null;var y=En("recharts-area",i),v=g,{r:b,strokeWidth:E}=cY(n),S=DO(n),A=b*2+E,T=o?"url(#clipPath-".concat(S?"":"dots-").concat(v,")"):void 0;return M.createElement(gs,{zIndex:x},M.createElement(wr,{className:y},o&&M.createElement("defs",null,M.createElement(zO,{clipPathId:v,xAxisId:c,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(OAe,{needClip:o,clipPathId:v,props:this.props})),M.createElement(Ck,{points:r,mainColor:Sw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&M.createElement(Ck,{points:m,mainColor:Sw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var vY={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:Rr.area};function LAe(t){var e,n=Sr(t,vY),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,connectNulls:o,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:m,stroke:x,xAxisId:y,yAxisId:v}=n,b=bY(n,_Ae),E=hf(),S=pX(),{needClip:A}=jE(y,v),T=vi(),{points:k,isRange:N,baseLine:I}=(e=Ct(R=>vAe(R,y,v,T,t.id)))!==null&&e!==void 0?e:{},C=OE();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(jAe,Ch({},b,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:a,baseLine:I,connectNulls:o,dot:c,fill:u,fillOpacity:d,height:D,hide:f,layout:E,isAnimationActive:g==="auto"?!Ym.isSsr:g,isRange:N,legendType:m,needClip:A,points:k,stroke:x,width:F,left:j,top:q,xAxisId:y,yAxisId:v}))}var IAe=(t,e,n,r,i)=>{var s=n??e;if(Pt(s))return s;var a=t==="horizontal"?i:r,o=a.scale.domain();if(a.type==="number"){var c=Math.max(o[0],o[1]),u=Math.min(o[0],o[1]);return s==="dataMin"?u:s==="dataMax"||c<0?c:Math.max(Math.min(o[0],o[1]),0)}return s==="dataMin"?o[0]:s==="dataMax"?o[1]:o[0]};function UAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:a,xAxis:o,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:m}=t,x=i&&i.length,y=IAe(s,a,n,o,c),v=s==="horizontal",b=!1,E=u.map((A,T)=>{var k;x?k=i[d+T]:(k=Bn(A,r),Array.isArray(k)?b=!0:k=[y,k]);var N=k[1]==null||x&&!e&&Bn(A,r)==null;return v?{x:V1({axis:o,ticks:f,bandSize:m,entry:A,index:T}),y:N?null:c.scale(k[1]),value:k,payload:A}:{x:N?null:o.scale(k[1]),y:V1({axis:c,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?c.scale(T):null,payload:A.payload}:{x:T!=null?o.scale(T):null,y:A.y,payload:A.payload}}):S=v?c.scale(y):o.scale(y),{points:E,baseLine:S,isRange:b}}function FAe(t){var e=Sr(t,vY),n=vi();return M.createElement(RE,{id:e.id,type:"area"},r=>M.createElement(M.Fragment,null,M.createElement(UO,{legendPayload:AAe(e)}),M.createElement(TAe,{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(FO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:$W(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),M.createElement(LAe,Ch({},e,{id:r}))))}var yY=M.memo(FAe,Vb);yY.displayName="Area";var zAe=["domain","range"],BAe=["domain","range"];function p8(t,e){if(t==null)return{};var n,r,i=HAe(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 HAe(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 m8(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 _Y(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=p8(t,zAe),{domain:s,range:a}=e,o=p8(e,BAe);return!m8(n,s)||!m8(r,a)?!1:Vb(i,o)}var $Ae=["dangerouslySetInnerHTML","ticks"],VAe=["id"];function kk(){return kk=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},kk.apply(null,arguments)}function g8(t,e){if(t==null)return{};var n,r,i=GAe(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 GAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function WAe(t){var e=rr(),n=M.useRef(null);return M.useLayoutEffect(()=>{n.current===null?e(zSe(t)):n.current!==t&&e(BSe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(HSe(n.current)),n.current=null)},[e]),null}var qAe=t=>{var{xAxisId:e,className:n}=t,r=Ct(hD),i=vi(),s="xAxis",a=Ct(v=>ld(v,s,e,i)),o=Ct(v=>WK(v,s,e,i)),c=Ct(v=>HK(v,e)),u=Ct(v=>Vve(v,e)),d=Ct(v=>SK(v,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,m=g8(t,$Ae),{id:x}=d,y=g8(d,VAe);return M.createElement(HO,kk({},m,y,{scale:a,x:u.x,y:u.y,width:c.width,height:c.height,className:En("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:o,axisType:s}))},KAe={allowDataOverflow:Pi.allowDataOverflow,allowDecimals:Pi.allowDecimals,allowDuplicatedCategory:Pi.allowDuplicatedCategory,angle:Pi.angle,axisLine:_c.axisLine,height:Pi.height,hide:!1,includeHidden:Pi.includeHidden,interval:Pi.interval,minTickGap:Pi.minTickGap,mirror:Pi.mirror,orientation:Pi.orientation,padding:Pi.padding,reversed:Pi.reversed,scale:Pi.scale,tick:Pi.tick,tickCount:Pi.tickCount,tickLine:_c.tickLine,tickSize:_c.tickSize,type:Pi.type,xAxisId:0},XAe=t=>{var e=Sr(t,KAe);return M.createElement(M.Fragment,null,M.createElement(WAe,{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(qAe,e))},Ew=M.memo(XAe,_Y);Ew.displayName="XAxis";var YAe=["dangerouslySetInnerHTML","ticks"],ZAe=["id"];function Pk(){return Pk=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},Pk.apply(null,arguments)}function x8(t,e){if(t==null)return{};var n,r,i=QAe(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 QAe(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($Se(t)):n.current!==t&&e(VSe({prev:n.current,next:t})),n.current=t},[t,e]),M.useLayoutEffect(()=>()=>{n.current&&(e(GSe(n.current)),n.current=null)},[e]),null}var eTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=M.useRef(null),a=M.useRef(null),o=Ct(hD),c=vi(),u=rr(),d="yAxis",f=Ct(T=>ld(T,d,e,c)),g=Ct(T=>$K(T,e)),m=Ct(T=>Wve(T,e)),x=Ct(T=>WK(T,d,e,c)),y=Ct(T=>EK(T,e));if(M.useLayoutEffect(()=>{if(!(r!=="auto"||!g||CO(i)||M.isValidElement(i)||y==null)){var T=s.current;if(T){var k=T.getCalculatedWidth();Math.round(g.width)!==Math.round(k)&&u(WSe({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=x8(t,YAe),{id:S}=y,A=x8(y,ZAe);return M.createElement(HO,Pk({},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:En("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:x,axisType:d}))},tTe={allowDataOverflow:Ri.allowDataOverflow,allowDecimals:Ri.allowDecimals,allowDuplicatedCategory:Ri.allowDuplicatedCategory,angle:Ri.angle,axisLine:_c.axisLine,hide:!1,includeHidden:Ri.includeHidden,interval:Ri.interval,minTickGap:Ri.minTickGap,mirror:Ri.mirror,orientation:Ri.orientation,padding:Ri.padding,reversed:Ri.reversed,scale:Ri.scale,tick:Ri.tick,tickCount:Ri.tickCount,tickLine:_c.tickLine,tickSize:_c.tickSize,type:Ri.type,width:Ri.width,yAxisId:0},nTe=t=>{var e=Sr(t,tTe);return M.createElement(M.Fragment,null,M.createElement(JAe,{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(eTe,e))},Mw=M.memo(nTe,_Y);Mw.displayName="YAxis";var rTe=(t,e)=>e,VO=Ge([rTe,xn,_K,_i,lX,zc,o_e,bi],p_e),GO=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)}},wY=uo("mouseClick"),SY=Sb();SY.startListening({actionCreator:wY,effect:(t,e)=>{var n=t.payload,r=VO(e.getState(),GO(n));r?.activeIndex!=null&&e.dispatch(aye({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var Rk=uo("mouseMove"),EY=Sb(),Oy=null;EY.startListening({actionCreator:Rk,effect:(t,e)=>{var n=t.payload;Oy!==null&&cancelAnimationFrame(Oy);var r=GO(n);Oy=requestAnimationFrame(()=>{var i=e.getState(),s=xO(i,i.tooltip.settings.shared);if(s==="axis"){var a=VO(i,r);a?.activeIndex!=null?e.dispatch(eX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate})):e.dispatch(JK())}Oy=null})}});var b8={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},MY=Js({name:"rootProps",initialState:b8,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:b8.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}}}),iTe=MY.reducer,{updateOptions:sTe}=MY.actions,AY=Js({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:aTe}=AY.actions,oTe=AY.reducer,TY=uo("keyDown"),CY=uo("focus"),WO=Sb();WO.startListening({actionCreator:TY,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=bO(i,ag(n),Ib(n),Bb(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var c=zc(n);if(s==="Enter"){var u=hw(n,"axis","hover",String(i.index));e.dispatch(wk({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=Yve(n),f=d==="left-to-right"?1:-1,g=s==="ArrowRight"?1:-1,m=o+g*f;if(!(c==null||m>=c.length||m<0)){var x=hw(n,"axis","hover",String(m));e.dispatch(wk({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});WO.startListening({actionCreator:CY,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=hw(n,"axis","hover",String(s));e.dispatch(wk({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:a}))}}}});var $a=uo("externalEvent"),NY=Sb(),dC=new Map;NY.startListening({actionCreator:$a,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=dC.get(i);s!==void 0&&cancelAnimationFrame(s);var a=requestAnimationFrame(()=>{try{var o=e.getState(),c={activeCoordinate:Wye(o),activeDataKey:SO(o),activeIndex:cd(o),activeLabel:dX(o),activeTooltipIndex:cd(o),isTooltipActive:qye(o)};n(c,r)}finally{dC.delete(i)}});dC.set(i,a)}}});var lTe=Ge([sg],t=>t.tooltipItemPayloads),cTe=Ge([lTe,Fb,(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}}}),kY=uo("touchMove"),PY=Sb();PY.startListening({actionCreator:kY,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=xO(r,r.tooltip.settings.shared);if(i==="axis"){var s=VO(r,GO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(eX({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 c=document.elementFromPoint(o.clientX,o.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(GW),d=(a=c.getAttribute(WW))!==null&&a!==void 0?a:void 0,f=cTe(e.getState(),u,d);e.dispatch(QK({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var uTe=hW({brush:OMe,cartesianAxis:qSe,chartData:G_e,errorBars:hEe,graphicalItems:eSe,layout:bpe,legend:Ame,options:z_e,polarAxis:mwe,polarOptions:oTe,referenceElements:GMe,rootProps:iTe,tooltip:oye,zIndex:C_e}),dTe=function(e){return $fe({reducer:uTe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([SY.middleware,EY.middleware,WO.middleware,NY.middleware,PY.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(TW({type:"raf"}))},devTools:Ym.devToolsEnabled})};function RY(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=vi(),s=M.useRef(null);if(i)return n;s.current==null&&(s.current=dTe(e));var a=rD;return M.createElement(LEe,{context:a,store:s.current},n)}function hTe(t){var{layout:e,margin:n}=t,r=rr(),i=vi();return M.useEffect(()=>{i||(r(mpe(e)),r(ppe(n)))},[r,i,e,n]),null}var DY=M.memo(hTe,Vb);function OY(t){var e=rr();return M.useEffect(()=>{e(sTe(t))},[e,t]),null}function v8(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=HX("".concat(r).concat(e)),s=rr();return M.useLayoutEffect(()=>(s(A_e({zIndex:e,elementId:i,isPanorama:n})),()=>{s(T_e({zIndex:e,isPanorama:n}))}),[s,e,i,n]),M.createElement("g",{tabIndex:-1,id:i})}function y8(t){var{children:e,isPanorama:n}=t,r=Ct(g_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(v8,{key:a,zIndex:a,isPanorama:n})),e,s.map(a=>M.createElement(v8,{key:a,zIndex:a,isPanorama:n})))}var fTe=["children"];function pTe(t,e){if(t==null)return{};var n,r,i=mTe(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 mTe(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 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)}var gTe={width:"100%",height:"100%",display:"block"},xTe=M.forwardRef((t,e)=>{var n=pD(),r=mD(),i=lq();if(!hl(n)||!hl(r))return null;var{children:s,otherAttributes:a,title:o,desc:c}=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(qR,Aw({},a,{title:o,desc:c,role:d,tabIndex:u,width:n,height:r,style:gTe,ref:e}),s)}),bTe=t=>{var{children:e}=t,n=Ct(sE);if(!n)return null;var{width:r,height:i,y:s,x:a}=n;return M.createElement(qR,{width:r,height:i,x:a,y:s},e)},_8=M.forwardRef((t,e)=>{var{children:n}=t,r=pTe(t,fTe),i=vi();return i?M.createElement(bTe,null,M.createElement(y8,{isPanorama:!0},n)):M.createElement(xTe,Aw({ref:e},r),M.createElement(y8,{isPanorama:!1},n))});function vTe(){var t=rr(),[e,n]=M.useState(null),r=Ct(jpe);return M.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;Hn(s)&&s!==r&&t(xpe(s))}},[e,t,r]),n}function w8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yTe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w8(Object(n),!0).forEach(function(r){_Te(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _Te(t,e,n){return(e=wTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wTe(t){var e=STe(t,"string");return typeof e=="symbol"?e:e+""}function STe(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 Zh(){return Zh=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},Zh.apply(null,arguments)}var ETe=()=>(e1e(),null);function Tw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var MTe=M.forwardRef((t,e)=>{var n,r,i=M.useRef(null),[s,a]=M.useState({containerWidth:Tw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:Tw((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}})},[]),c=M.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();o(d,f);var g=x=>{var{width: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(aE,{width:s.containerWidth,height:s.containerHeight}),M.createElement("div",Zh({ref:c},t)))}),ATe=M.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=M.useState({containerWidth:Tw(n),containerHeight:Tw(r)}),a=M.useCallback((c,u)=>{s(d=>{var f=Math.round(c),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),o=M.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();a(u,d)}},[e,a]);return M.createElement(M.Fragment,null,M.createElement(aE,{width:i.containerWidth,height:i.containerHeight}),M.createElement("div",Zh({ref:o},t)))}),TTe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return M.createElement(M.Fragment,null,M.createElement(aE,{width:n,height:r}),M.createElement("div",Zh({ref:e},t)))}),CTe=M.forwardRef((t,e)=>{var{width:n,height:r}=t;return Cc(n)||Cc(r)?M.createElement(ATe,Zh({},t,{ref:e})):M.createElement(TTe,Zh({},t,{ref:e}))});function NTe(t){return t===!0?MTe:CTe}var kTe=M.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:a,onDoubleClick:o,onMouseDown:c,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=vTe(),F=fD(),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(wY(re)),T($a({handler:s,reactEvent:re}))},[T,s]),K=M.useCallback(re=>{T(Rk(re)),T($a({handler:u,reactEvent:re}))},[T,u]),V=M.useCallback(re=>{T(JK()),T($a({handler:d,reactEvent:re}))},[T,d]),ee=M.useCallback(re=>{T(Rk(re)),T($a({handler:f,reactEvent:re}))},[T,f]),Y=M.useCallback(()=>{T(CY())},[T]),Q=M.useCallback(re=>{T(TY(re.key))},[T]),U=M.useCallback(re=>{T($a({handler:a,reactEvent:re}))},[T,a]),z=M.useCallback(re=>{T($a({handler:o,reactEvent:re}))},[T,o]),J=M.useCallback(re=>{T($a({handler:c,reactEvent:re}))},[T,c]),se=M.useCallback(re=>{T($a({handler:g,reactEvent:re}))},[T,g]),me=M.useCallback(re=>{T($a({handler:y,reactEvent:re}))},[T,y]),fe=M.useCallback(re=>{S&&T(kY(re)),T($a({handler:x,reactEvent:re}))},[T,S,x]),xe=M.useCallback(re=>{T($a({handler:m,reactEvent:re}))},[T,m]),Ee=NTe(E);return M.createElement(vX.Provider,{value:k},M.createElement(T7.Provider,{value:I},M.createElement(Ee,{width:j??v?.width,height:q??v?.height,className:En("recharts-wrapper",r),style:yTe({position:"relative",cursor:"default",width:j,height:q},v),onClick:W,onContextMenu:U,onDoubleClick:z,onFocus:Y,onKeyDown:Q,onMouseDown:J,onMouseEnter:K,onMouseLeave:V,onMouseMove:ee,onMouseUp:se,onTouchEnd:xe,onTouchMove:fe,onTouchStart:me,ref:R},M.createElement(ETe,null),n)))}),PTe=["width","height","responsive","children","className","style","compact","title","desc"];function RTe(t,e){if(t==null)return{};var n,r,i=DTe(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 DTe(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 jY=M.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:a,style:o,compact:c,title:u,desc:d}=t,f=RTe(t,PTe),g=Ns(f);return c?M.createElement(M.Fragment,null,M.createElement(aE,{width:n,height:r}),M.createElement(_8,{otherAttributes:g,title:u,desc:d},s)):M.createElement(kTe,{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(_8,{otherAttributes:g,title:u,desc:d,ref:e},M.createElement(WMe,null,s)))});function Dk(){return Dk=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},Dk.apply(null,arguments)}var OTe={top:5,right:5,bottom:5,left:5},jTe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:OTe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},qO=M.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,jTe),{chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:a,validateTooltipEventTypes:o,tooltipPayloadSearcher:c,eventEmitter:void 0};return M.createElement(RY,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},M.createElement(QX,{chartData:u.data}),M.createElement(DY,{layout:i.layout,margin:i.margin}),M.createElement(OY,{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(jY,Dk({},i,{ref:n})))}),LTe=["axis"],ITe=M.forwardRef((t,e)=>M.createElement(qO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:LTe,tooltipPayloadSearcher:AE,categoricalChartProps:t,ref:e})),UTe=["axis","item"],FTe=M.forwardRef((t,e)=>M.createElement(qO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:UTe,tooltipPayloadSearcher:AE,categoricalChartProps:t,ref:e}));function zTe(t){var e=rr();return M.useEffect(()=>{e(aTe(t))},[e,t]),null}var BTe=["layout"];function Ok(){return Ok=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},Ok.apply(null,arguments)}function HTe(t,e){if(t==null)return{};var n,r,i=$Te(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 $Te(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 VTe={top:5,right:5,bottom:5,left:5},LY={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:VTe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},GTe=M.forwardRef(function(e,n){var r,i=Sr(e.categoricalChartProps,LY),{layout:s}=i,a=HTe(i,BTe),{chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:o,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return M.createElement(RY,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:o},M.createElement(QX,{chartData:i.data}),M.createElement(DY,{layout:s,margin:i.margin}),M.createElement(OY,{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(zTe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),M.createElement(jY,Ok({},a,{ref:n})))});function S8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function E8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S8(Object(n),!0).forEach(function(r){WTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WTe(t,e,n){return(e=qTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qTe(t){var e=KTe(t,"string");return typeof e=="symbol"?e:e+""}function KTe(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 XTe=["item"],YTe=E8(E8({},LY),{},{layout:"centric",startAngle:0,endAngle:360}),ZTe=M.forwardRef((t,e)=>{var n=Sr(t,YTe);return M.createElement(GTe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:XTe,tooltipPayloadSearcher:AE,categoricalChartProps:n,ref:e})}),QTe=["axis"],JTe=M.forwardRef((t,e)=>M.createElement(qO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:QTe,tooltipPayloadSearcher:AE,categoricalChartProps:t,ref:e}));const M8=[{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 eCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:a="humidity",thresholds:o}){const{t:c}=Gm(),{theme:u}=xb(),[d,f]=M.useState("24h"),[g,m]=M.useState(a),x=u==="dark";M.useEffect(()=>{if(!t)return;const z=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t,e]);const y=M8.find(z=>z.value===d)?.hours||24,{data:v,isLoading:b,error:E}=yt({queryKey:["ams-history",n,i,y],queryFn:()=>ke.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 J=z.filter(re=>re!=null);if(J.length<4)return"stable";const se=J.slice(0,Math.floor(J.length/4)),me=J.slice(-Math.floor(J.length/4)),fe=se.reduce((re,we)=>re+we,0)/se.length,Ee=me.reduce((re,we)=>re+we,0)/me.length-fe;return Math.abs(Ee)<2?"stable":Ee>0?"up":"down"},j=F(S.map(z=>z.humidity)),q=F(S.map(z=>z.temperature)),R=({trend:z})=>z==="up"?l.jsx(p7,{className:"w-4 h-4 text-red-400"}):z==="down"?l.jsx(f7,{className:"w-4 h-4 text-green-400"}):l.jsx(R3,{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",ee=x?"#1d1d1d":"#f3f4f6",Y=x?"#3d3d3d":"#e5e7eb",Q=x?"#ffffff":"#111827",U=x?"#9ca3af":"#4b5563";return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:V},onClick:z=>z.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:Y},children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold",style:{color:Q},children:[s," ",c("common.history","History")]}),l.jsx("p",{className:"text-sm",style:{color:U},children:r})]}),l.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:U},children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ee},children:[l.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:[l.jsx(r7,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),l.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:[l.jsx(Sh,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),l.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:ee},children:M8.map(z=>l.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))})]}),l.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:W(C)},children:C!=null?`${C}%`:"—"}),l.jsx(R,{trend:j})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:v?.avg_humidity!=null?`${v.avg_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-green-500",children:v?.min_humidity!=null?`${v.min_humidity}%`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_humidity!=null?`${v.max_humidity}%`:"—"})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.current","Current")}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-2xl font-bold",style:{color:K(D)},children:D!=null?`${D}°C`:"—"}),l.jsx(R,{trend:q})]})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.average","Average")}),l.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:v?.avg_temperature!=null?`${v.avg_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.min","Min")}),l.jsx("p",{className:"text-2xl font-bold text-blue-500",children:v?.min_temperature!=null?`${v.min_temperature}°C`:"—"})]}),l.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:[l.jsx("p",{className:"text-xs",style:{color:U},children:c("common.max","Max")}),l.jsx("p",{className:"text-2xl font-bold text-red-500",children:v?.max_temperature!=null?`${v.max_temperature}°C`:"—"})]})]})}),l.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:ee},children:b?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.loading","Loading...")}):E?l.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):S.length===0?l.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:U},children:c("common.noData","No data available for this time range")}):l.jsx(n1,{width:"100%",height:300,children:l.jsxs(ITe,{data:S,children:[l.jsx(ww,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),l.jsx(Ew,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:z=>{const J=new Date(z);return y>24?J.toLocaleDateString([],{day:"numeric",month:"short"}):J.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),l.jsx(Mw,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:z=>g==="humidity"?`${z}%`:`${z}°C`}),l.jsx(i1,{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"]}),l.jsx(bD,{}),g==="humidity"?l.jsxs(l.Fragment,{children:[l.jsx(jx,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(jx,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):l.jsxs(l.Fragment,{children:[l.jsx(jx,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),l.jsx(jx,{y:N,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),l.jsx(hY,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),l.jsx("div",{className:"text-xs text-center",style:{color:U},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function tCe({side:t}){const{theme:e}=xb(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return l.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function nCe({colors:t,className:e}){const n=[{x:9.5,cx:12.5},{x:18.5,cx:21.5},{x:27.5,cx:30.5},{x:36.5,cx:39.5}];return l.jsxs("svg",{className:e,width:"56",height:"34",viewBox:"0 0 52 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4 0C1.79086 0 0 1.79086 0 4V28C0 30.2091 1.79086 32 4 32H48C50.2091 32 52 30.2091 52 28V4C52 1.79086 50.2091 0 48 0H4ZM44 8H8V24H44V8Z",fill:"#2F2E33"}),n.map((r,i)=>t[i]?l.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:t[i]},i):l.jsxs("g",{children:[l.jsx("rect",{x:r.x,y:"8",width:"6",height:"16",fill:"#ffffff"}),l.jsx("line",{x1:r.x,y1:"8",x2:r.x+6,y2:"24",stroke:"#555555",strokeWidth:"1.5"})]},i)),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M36.5 16H33.5V18.2617C33.5 19.9186 32.1569 21.2617 30.5 21.2617C28.8431 21.2617 27.5 19.9186 27.5 18.2617V16H24.5V18.2617C24.5 19.9186 23.1569 21.2617 21.5 21.2617C19.8431 21.2617 18.5 19.9186 18.5 18.2617V16H15.5V18.2617C15.5 19.9186 14.1569 21.2617 12.5 21.2617C10.8432 21.2617 9.5 19.9186 9.5 18.2617V16H4V28H48V16H42.5V18.2617C42.5 19.9186 41.1569 21.2617 39.5 21.2617C37.8431 21.2617 36.5 19.9186 36.5 18.2617V16Z",fill:"#767676"}),l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6 9.18382C6 6.32088 8.32088 4 11.1838 4H40.8162C43.6791 4 46 6.32088 46 9.18382V16H42.5V12.2617C42.5 10.6049 41.1569 9.26172 39.5 9.26172C37.8431 9.26172 36.5 10.6049 36.5 12.2617V16H33.5V12.2617C33.5 10.6049 32.1569 9.26172 30.5 9.26172C28.8431 9.26172 27.5 10.6049 27.5 12.2617V16H24.5V12.2617C24.5 10.6049 23.1569 9.26172 21.5 9.26172C19.8431 9.26172 18.5 10.6049 18.5 12.2617V16H15.5V12.2617C15.5 10.6049 14.1569 9.26172 12.5 9.26172C10.8432 9.26172 9.5 10.6049 9.5 12.2617V16H6V9.18382Z",fill:"#BFBFBF"})]})}function rCe({color:t,className:e}){return l.jsxs("svg",{className:e,width:"56",height:"56",viewBox:"0 0 21 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t?l.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:t,rx:"0.3"}):l.jsxs("g",{children:[l.jsx("rect",{x:"8.3",y:"5.2",width:"3.8",height:"5.1",fill:"#ffffff",rx:"0.3"}),l.jsx("line",{x1:"8.3",y1:"5.2",x2:"12.1",y2:"10.3",stroke:"#555555",strokeWidth:"0.8"})]}),l.jsx("path",{d:"M5.88312 4.68555C5.88312 4.13326 6.33083 3.68555 6.88312 3.68555H13.5059C14.0582 3.68555 14.5059 4.13326 14.5059 4.68555V10.3887H5.88312V4.68555Z",stroke:"#6B6B6B"}),l.jsx("rect",{x:"3.8725",y:"10.3887",width:"12.7037",height:"7.55371",rx:"1.2",stroke:"#6B6B6B"}),l.jsx("path",{d:"M8.21991 5.65234C8.21991 5.3762 8.44377 5.15234 8.71991 5.15234H11.7288C12.005 5.15234 12.2288 5.3762 12.2288 5.65234V10.3887H8.21991V5.65234Z",stroke:"#6B6B6B"})]})}function A8({className:t}){return l.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function iCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),l.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function sCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),l.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function aCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),l.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function oCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),l.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function lCe({className:t}){return l.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[l.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),l.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),l.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function cCe({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,c;isNaN(i)?(o="#C3C2C1",c="Unknown"):i<=s?(o="#22a352",c="Good"):i<=a?(o="#d4a017",c="Fair"):(o="#c62828",c="Bad");let u;return isNaN(i)||i<=s?u=A8:i<=a?u=iCe:u=sCe,l.jsxs("button",{type:"button",onClick:r,className:`flex items-center justify-end gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${i}% - ${c}${r?" (click for history)":""}`,children:[l.jsx(u,{className:"w-3 h-4"}),l.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:o},children:[i,"%"]})]})}function uCe({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,c;return t<=i?(a="#22a352",o="Good",c=aCe):t<=s?(a="#d4a017",o="Fair",c=oCe):(a="#c62828",o="Bad",c=lCe),l.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${o}${r?" (click for history)":""}`,children:[l.jsx(c,{className:"w-3 h-4"}),l.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:a},children:[t,"°C"]})]})}function hC(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 dCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function hCe(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 fCe(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 pCe(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 mCe({url:t,printName:e}){const[n,r]=M.useState(!1),[i,s]=M.useState(!1),[a,o]=M.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&o(!0),children:t&&!i?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>s(!0)}),!n&&l.jsx(fm,{className:"w-8 h-8 text-bambu-gray"})]}):l.jsx(fm,{className:"w-8 h-8 text-bambu-gray"})}),a&&t&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:l.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[l.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&l.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function gCe({printers:t}){const e=Mn(),n=M.useMemo(()=>{let i=0,s=0,a=0,o=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.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(()=>{let i=!1;const s=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(a=>a+1),i=!1}))});return()=>s()},[e]),t?.length?l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),l.jsxs("span",{className:"text-bambu-gray",children:[l.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function T8({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i}){const s=Mn(),a=AR(),[o,c]=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:()=>ke.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:()=>ke.getSmartPlugByPrinter(t.id)}),{data:ee}=yt({queryKey:["smartPlugStatus",V?.id],queryFn:()=>V?ke.getSmartPlugStatus(V.id):null,enabled:!!V,refetchInterval:1e4}),{data:Y}=yt({queryKey:["queue",t.id,"pending"],queryFn:()=>ke.getQueue(t.id,"pending")}),Q=Y?.length||0,{data:U}=yt({queryKey:["archives",t.id,"last"],queryFn:()=>ke.getArchives(t.id,1,0),enabled:C?.connected&&C?.state!=="RUNNING"}),z=U?.[0],J=e&&C&&!C.connected,se=wt({mutationFn:()=>ke.deletePrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printers"]})}}),me=wt({mutationFn:()=>ke.connectPrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printerStatus",t.id]})}}),fe=wt({mutationFn:Ee=>V?ke.controlSmartPlug(V.id,Ee):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugStatus",V?.id]})}}),xe=wt({mutationFn:Ee=>V?ke.updateSmartPlug(V.id,{auto_off:Ee}):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),s.invalidateQueries({queryKey:["smart-plugs"]})}});return J?null:l.jsxs(Nt,{className:"relative",children:[l.jsxs(Rt,{children:[l.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsx("img",{src:fCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${r==="compact"?"w-10 h-10":"w-14 h-14"}`}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&l.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${C?.connected?"bg-bambu-green":"bg-red-500"}`,title:C?.connected?"Connected":"Offline"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&C?.nozzles&&C.nozzles[0]?.nozzle_diameter&&l.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&&l.jsxs("span",{className:"ml-2 text-bambu-gray",children:[l.jsx(_r,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),l.jsxs("div",{className:"relative flex-shrink-0",children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>c(!o),children:l.jsx(i7,{className:"w-4 h-4"})}),o&&l.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{g(!0),c(!1)},children:[l.jsx(rd,{className:"w-4 h-4"}),"Edit"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{me.mutate(),c(!1)},children:[l.jsx(Cs,{className:"w-4 h-4"}),"Reconnect"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{v(!0),c(!1)},children:[l.jsx(h7,{className:"w-4 h-4"}),"MQTT Debug"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{d(!0),c(!1)},children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&l.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[l.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${C?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[C?.connected?l.jsx(zS,{className:"w-3 h-3"}):l.jsx(m7,{className:"w-3 h-3"}),C?.connected?"Connected":"Offline"]}),C?.connected&&j!=null&&l.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 - ${pCe(j).label}`,children:[l.jsx(Zce,{className:"w-3 h-3"}),j,"dBm"]}),C?.connected&&l.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(Ee=>Ee.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[l.jsx(ti,{className:"w-3 h-3"}),C.hms_errors&&C.hms_errors.length>0?C.hms_errors.length:"OK"]}),n&&l.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:[l.jsx(sd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Q>0&&l.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:`${Q} print${Q>1?"s":""} in queue`,children:[l.jsx($h,{className:"w-3 h-3"}),Q]})]})]}),u&&l.jsx(Qr,{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:()=>{se.mutate(),d(!1)},onCancel:()=>d(!1)}),C?.connected&&l.jsxs(l.Fragment,{children:[r==="compact"?l.jsx("div",{className:"mt-2",children:C.state==="RUNNING"?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:l.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),l.jsxs("span",{className:"text-xs text-white",children:[Math.round(C.progress||0),"%"]})]}):l.jsx("p",{className:"text-xs text-bambu-gray capitalize",children:C.state?.toLowerCase()||"Idle"})}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex gap-3",children:[l.jsx(mCe,{url:C.state==="RUNNING"?C.cover_url:null,printName:C.state==="RUNNING"&&(C.subtask_name||C.current_print)||void 0}),l.jsx("div",{className:"flex-1 min-w-0",children:C.current_print&&C.state==="RUNNING"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),l.jsx("p",{className:"text-white text-sm mb-2 truncate",children:C.subtask_name||C.current_print}),l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:l.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${C.progress||0}%`}})}),l.jsxs("span",{className:"text-white",children:[Math.round(C.progress||0),"%"]})]}),l.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[C.remaining_time!=null&&C.remaining_time>0&&l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx(_r,{className:"w-3 h-3"}),dCe(C.remaining_time*60)]}),l.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",hCe(C.remaining_time)]})]}),C.layer_num!=null&&C.total_layers!=null&&C.total_layers>0&&l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx($h,{className:"w-3 h-3"}),C.layer_num,"/",C.total_layers]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),l.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:C.state?.toLowerCase()||"Idle"}),l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:l.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),l.jsx("span",{className:"text-bambu-gray",children:"—"})]}),z?l.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&&l.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(z.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):l.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),C.state!=="RUNNING"&&l.jsx(lde,{printerId:t.id})]}),C.temperatures&&r==="expanded"&&l.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(Sh,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),C.temperatures.nozzle_2!==void 0?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C / ",Math.round(C.temperatures.nozzle_2||0),"°C"]})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.nozzle||0),"°C"]})]})]}),l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(Sh,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.bed||0),"°C"]})]}),C.temperatures.chamber!==void 0&&l.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[l.jsx(Sh,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),l.jsxs("p",{className:"text-sm text-white",children:[Math.round(C.temperatures.chamber||0),"°C"]})]})]}),K&&K.length>0&&r==="expanded"&&l.jsxs("div",{className:"mt-3 space-y-2",children:[K.map(Ee=>{const re=R[String(Ee.id)],we=Ee.id>=128?Ee.id-128:Ee.id,Oe=re!==void 0?re:we,he=t.nozzle_count===2||C?.temperatures?.nozzle_2!==void 0,ht=Oe===1,$=Oe===0,H=Ee.tray.map(G=>G.tray_color?`#${G.tray_color}`:G.tray_type?"#333":null),ne=Ee.tray.length===1;return l.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[he&&(ht||$)&&l.jsx(tCe,{side:ht?"L":"R"}),ne?l.jsx(rCe,{color:H[0],className:"flex-shrink-0"}):l.jsx(nCe,{colors:H,className:"flex-shrink-0"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:hC(Ee.id,Ee.tray.length)}),l.jsx("div",{className:"mt-0.5 text-[10px] flex items-start",children:Ee.tray.map((G,Z)=>l.jsxs("div",{className:"flex items-start",children:[l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-bambu-gray/70 truncate",children:G.tray_type?G.tray_sub_brands||G.tray_type:"—"}),l.jsx("span",{className:"text-bambu-gray/50 truncate",children:G.tray_type&&G.remain>=0?`${G.remain}%`:"—"})]}),Z<Ee.tray.length-1&&l.jsxs("span",{className:"text-bambu-gray/50 mx-1 flex flex-col",children:[l.jsx("span",{children:"·"}),l.jsx("span",{children:"·"})]})]},Z))})]}),(Ee.humidity!=null||Ee.temp!=null)&&l.jsxs("div",{className:"flex items-center gap-2 text-xs flex-shrink-0",children:[Ee.humidity!=null&&l.jsx(cCe,{humidity:Ee.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>I({amsId:Ee.id,amsLabel:hC(Ee.id,Ee.tray.length),mode:"humidity"})}),Ee.temp!=null&&l.jsx(uCe,{temp:Ee.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>I({amsId:Ee.id,amsLabel:hC(Ee.id,Ee.tray.length),mode:"temperature"})})]})]})},Ee.id)}),C.vt_tray&&C.vt_tray.tray_type&&l.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-white/20 flex-shrink-0",style:{backgroundColor:C.vt_tray.tray_color?`#${C.vt_tray.tray_color}`:"#333"}}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray font-medium",children:"External"}),l.jsx("p",{className:"text-[10px] text-bambu-gray/70",children:C.vt_tray.tray_sub_brands||C.vt_tray.tray_type||"Spool"})]})]})})]})]}),V&&r==="expanded"&&l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(bm,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"text-sm text-white truncate",children:V.name}),ee&&l.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${ee.state==="ON"?"bg-bambu-green/20 text-bambu-green":ee.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:ee.state||"?"}),ee?.energy?.power!=null&&ee.state==="ON"&&l.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[ee.energy.power,"W"]})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("button",{onClick:()=>E(!0),disabled:fe.isPending||ee?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${ee?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[l.jsx(bd,{className:"w-3 h-3"}),"On"]}),l.jsxs("button",{onClick:()=>A(!0),disabled:fe.isPending||ee?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${ee?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[l.jsx(HR,{className:"w-3 h-3"}),"Off"]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx("span",{className:`text-xs hidden sm:inline ${V.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:V.auto_off_executed?"Auto-off done":"Auto-off"}),l.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:l.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"&&l.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"text-xs text-bambu-gray",children:[l.jsx("p",{children:t.ip_address}),l.jsx("p",{className:"truncate",children:t.serial_number})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Le,{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:l.jsx(g7,{className:"w-4 h-4"})}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>x(!0),title:"Browse printer files",children:[l.jsx(FR,{className:"w-4 h-4"}),"Files"]})]})]})]}),m&&l.jsx(tde,{printerId:t.id,printerName:t.name,onClose:()=>x(!1)}),y&&l.jsx(nde,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),b&&V&&l.jsx(Qr,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{fe.mutate("on"),E(!1)},onCancel:()=>E(!1)}),S&&V&&l.jsx(Qr,{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:()=>{fe.mutate("off"),A(!1)},onCancel:()=>A(!1)}),T&&l.jsx(ade,{printerName:t.name,errors:C?.hms_errors||[],onClose:()=>k(!1)}),N&&l.jsx(eCe,{isOpen:!!N,onClose:()=>I(null),printerId:t.id,printerName:t.name,amsId:N.amsId,amsLabel:N.amsLabel,initialMode:N.mode,thresholds:i}),f&&l.jsx(bCe,{printer:t,onClose:()=>g(!1)})]})}function xCe({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]),l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:l.jsxs(Rt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),l.jsxs("form",{onSubmit:i=>{i.preventDefault(),e(n)},className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.name,onChange:i=>r({...n,name:i.target.value}),placeholder:"My Printer"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.ip_address,onChange:i=>r({...n,ip_address:i.target.value}),placeholder:"192.168.1.100"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.serial_number,onChange:i=>r({...n,serial_number:i.target.value}),placeholder:"01P00A000000000"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.access_code,onChange:i=>r({...n,access_code:i.target.value}),placeholder:"From printer settings"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.model||"",onChange:i=>r({...n,model:i.target.value}),children:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"auto_archive",checked: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"}),l.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function bCe({printer:t,onClose:e}){const n=Mn(),[r,i]=M.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),s=wt({mutationFn:o=>ke.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});M.useEffect(()=>{const o=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const a=o=>{o.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),s.mutate(c)};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:l.jsxs(Rt,{children:[l.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),l.jsxs("form",{onSubmit:a,className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:o=>i({...r,name:o.target.value}),placeholder:"My Printer"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),l.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:o=>i({...r,ip_address:o.target.value}),placeholder:"192.168.1.100"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),l.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),l.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:o=>i({...r,access_code:o.target.value}),placeholder:"Leave empty to keep current"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:o=>i({...r,model:o.target.value}),children:[l.jsx("option",{value:"",children:"Select model..."}),l.jsxs("optgroup",{label:"H2 Series",children:[l.jsx("option",{value:"H2C",children:"H2C"}),l.jsx("option",{value:"H2D",children:"H2D"}),l.jsx("option",{value:"H2S",children:"H2S"})]}),l.jsxs("optgroup",{label:"X1 Series",children:[l.jsx("option",{value:"X1E",children:"X1E"}),l.jsx("option",{value:"X1C",children:"X1 Carbon"}),l.jsx("option",{value:"X1",children:"X1"})]}),l.jsxs("optgroup",{label:"P Series",children:[l.jsx("option",{value:"P2S",children:"P2S"}),l.jsx("option",{value:"P1S",children:"P1S"}),l.jsx("option",{value:"P1P",children:"P1P"})]}),l.jsxs("optgroup",{label:"A1 Series",children:[l.jsx("option",{value:"A1",children:"A1"}),l.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),l.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:o=>i({...r,location:o.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:o=>i({...r,auto_archive:o.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),l.jsxs("div",{className:"flex gap-3 pt-4",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Saving...":"Save Changes"})]})]})]})})})}function vCe(t){const{data:e}=yt({queryKey:["printerStatus",t],queryFn:()=>ke.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function yCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=vCe(t.id),{data:s}=yt({queryKey:["smartPlugStatus",e.id],queryFn:()=>ke.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?l.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),s&&l.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||"?"})]}),l.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:[l.jsx(bd,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function _Ce(){const[t,e]=M.useState(!1),[n,r]=M.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,s]=M.useState(!1),[a,o]=M.useState(null),[c,u]=M.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=M.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,m]=M.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),x=Mn(),{data:y,isLoading:v}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:b}=yt({queryKey:["settings"],queryFn:ke.getSettings}),{data:E}=yt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:S}=yt({queryKey:["maintenanceOverview"],queryFn:ke.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=wt({mutationFn:ke.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),N=wt({mutationFn:R=>ke.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(c){case"name":R.sort((W,K)=>W.name.localeCompare(K.name));break;case"model":R.sort((W,K)=>(W.model||"").localeCompare(K.model||""));break;case"location":R.sort((W,K)=>{const V=W.location||"",ee=K.location||"";return!V&&ee?1:V&&!ee?-1:V.localeCompare(ee)||W.name.localeCompare(K.name)});break;case"status":R.sort((W,K)=>{const V=x.getQueryData(["printerStatus",W.id]),ee=x.getQueryData(["printerStatus",K.id]),Y=Q=>Q?.connected?Q.state==="RUNNING"?0:1:2;return Y(V)-Y(ee)});break}return d||R.reverse(),R},[y,c,d,x]),q=M.useMemo(()=>{if(c!=="location")return null;const R={};return j.forEach(W=>{const K=W.location||"Ungrouped";R[K]||(R[K]=[]),R[K].push(W)}),R},[c,j]);return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),l.jsx(gCe,{printers:y})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsxs("select",{value:c,onChange:R=>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:[l.jsx("option",{value:"name",children:"Name"}),l.jsx("option",{value:"status",children:"Status"}),l.jsx("option",{value:"model",children:"Model"}),l.jsx("option",{value:"location",children:"Location"})]}),l.jsx("button",{onClick:D,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?l.jsx(hm,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(x0,{className:"w-4 h-4 text-bambu-gray"})})]}),l.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"?l.jsx(Ule,{className:"w-5 h-5 text-bambu-gray"}):l.jsx(o7,{className:"w-5 h-5 text-bambu-gray"})}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:n,onChange: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&&l.jsxs("div",{className:"relative",children:[l.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:[l.jsx(bd,{className:"w-4 h-4"}),"Power On",l.jsx(uf,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),l.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[l.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),y?.filter(R=>T[R.id]).map(R=>l.jsx(yCe,{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&&l.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),l.jsxs(Le,{onClick:()=>e(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):y?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),l.jsxs(Le,{onClick:()=>e(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?l.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([R,W])=>l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[l.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),R,l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.length,")"]})]}),l.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:W.map(K=>l.jsx(T8,{printer:K,hideIfDisconnected:n,maintenanceInfo:A[K.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},K.id))})]},R))}):l.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:j.map(R=>l.jsx(T8,{printer:R,hideIfDisconnected:n,maintenanceInfo:A[R.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},R.id))}),t&&l.jsx(xCe,{onClose:()=>e(!1),onAdd:R=>k.mutate(R)})]})}const KO="181",rm={ROTATE:0,DOLLY:1,PAN:2},Kp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wCe=0,C8=1,SCe=2,IY=1,ECe=2,ic=3,dd=0,Ks=1,rl=2,wc=0,im=1,N8=2,k8=3,P8=4,MCe=5,ah=100,ACe=101,TCe=102,CCe=103,NCe=104,kCe=200,PCe=201,RCe=202,DCe=203,jk=204,Lk=205,OCe=206,jCe=207,LCe=208,ICe=209,UCe=210,FCe=211,zCe=212,BCe=213,HCe=214,Ik=0,Uk=1,Fk=2,Tm=3,zk=4,Bk=5,Hk=6,$k=7,XO=0,$Ce=1,VCe=2,Xu=0,GCe=1,WCe=2,qCe=3,KCe=4,XCe=5,YCe=6,ZCe=7,UY=300,Cm=301,Nm=302,Vk=303,Gk=304,IE=306,Wk=1e3,mc=1001,qk=1002,wa=1003,QCe=1004,jy=1005,ro=1006,fC=1007,gh=1008,gl=1009,FY=1010,zY=1011,$0=1012,YO=1013,Qh=1014,gc=1015,og=1016,ZO=1017,QO=1018,V0=1020,BY=35902,HY=35899,$Y=1021,VY=1022,Do=1023,G0=1026,W0=1027,GY=1028,JO=1029,ej=1030,tj=1031,nj=1033,a1=33776,o1=33777,l1=33778,c1=33779,Kk=35840,Xk=35841,Yk=35842,Zk=35843,Qk=36196,Jk=37492,eP=37496,tP=37808,nP=37809,rP=37810,iP=37811,sP=37812,aP=37813,oP=37814,lP=37815,cP=37816,uP=37817,dP=37818,hP=37819,fP=37820,pP=37821,mP=36492,gP=36494,xP=36495,bP=36283,vP=36284,yP=36285,_P=36286,JCe=3200,eNe=3201,WY=0,tNe=1,Lu="",qa="srgb",km="srgb-linear",Cw="linear",qn="srgb",tp=7680,R8=519,nNe=512,rNe=513,iNe=514,qY=515,sNe=516,aNe=517,oNe=518,lNe=519,D8=35044,O8="300 es",ol=2e3,Nw=2001;function KY(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function kw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function cNe(){const t=kw("canvas");return t.style.display="block",t}const j8={};function L8(...t){const e="THREE."+t.shift();console.log(e,...t)}function Yt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function zr(...t){const e="THREE."+t.shift();console.error(e,...t)}function q0(...t){const e=t.join(" ");e in j8||(j8[e]=!0,Yt(...t))}function uNe(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 mf=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 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"],u1=Math.PI/180,wP=180/Math.PI;function Wb(){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 gn(t,e,n){return Math.max(e,Math.min(n,t))}function dNe(t,e){return(t%e+e)%e}function pC(t,e,n){return(1-n)*t+n*e}function mx(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 Bs(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 hNe={DEG2RAD:u1};let cn=class XY{constructor(e=0,n=0){XY.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(gn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),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}},Jh=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 c=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]=c,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||c!==g||u!==m||d!==x){let v=c*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,c=c*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+y*o}else{c=c*b+g*o,u=u*b+m*o,d=d*b+x*o,f=f*b+y*o;const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],c=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+c*m-u*g,e[n+1]=c*x+d*g+u*f-o*m,e[n+2]=u*x+d*m+o*g-c*f,e[n+3]=d*x-o*f-c*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,c=Math.sin,u=o(r/2),d=o(i/2),f=o(s/2),g=c(r/2),m=c(i/2),x=c(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:Yt("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],c=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-c)*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-c)/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=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(a-i)/m,this._x=(s+u)/m,this._y=(c+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(gn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+a*o+i*u-s*c,this._y=i*d+a*c+s*o-r*u,this._z=s*d+a*u+r*c-i*o,this._w=a*d-r*o-i*c-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 c=1-n;if(o<.9995){const u=Math.acos(o),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+a*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+s*n,this._w=this._w*c+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}},Qe=class YY{constructor(e=0,n=0,r=0){YY.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(I8.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(I8.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,c=e.w,u=2*(a*i-o*r),d=2*(o*n-s*i),f=2*(s*r-a*n);return this.x=n+c*u+a*f-o*d,this.y=r+c*d+o*u-s*f,this.z=i+c*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=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,s=e.z,a=n.x,o=n.y,c=n.z;return this.x=i*c-s*o,this.y=s*a-r*c,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 mC.copy(this).projectOnVector(e),this.sub(mC)}reflect(e){return this.sub(mC.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(gn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const mC=new Qe,I8=new Jh;let dn=class ZY{constructor(e,n,r,i,s,a,o,c,u){ZY.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,c,u)}set(e,n,r,i,s,a,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=c,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],c=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+c*T,s[3]=a*v+o*S+c*k,s[6]=a*b+o*A+c*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],c=e[6],u=e[7],d=e[8];return n*a*d-n*o*u-r*s*d+r*o*c+i*s*u-i*a*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*a-o*u,g=o*c-d*s,m=u*s-a*c,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*c)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*c-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 c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*a+u*o)+a+e,-i*u,i*c,-i*(-u*a+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(gC.makeScale(e,n)),this}rotate(e){return this.premultiply(gC.makeRotation(-e)),this}translate(e,n){return this.premultiply(gC.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 gC=new dn,U8=new dn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),F8=new dn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function fNe(){const t={enabled:!0,workingColorSpace:km,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===qn&&(i.r=Sc(i.r),i.g=Sc(i.g),i.b=Sc(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===qn&&(i.r=sm(i.r),i.g=sm(i.g),i.b=sm(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===Lu?Cw: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 q0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return q0("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({[km]:{primaries:e,whitePoint:r,transfer:Cw,toXYZ:U8,fromXYZ:F8,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:qa},outputColorSpaceConfig:{drawingBufferColorSpace:qa}},[qa]:{primaries:e,whitePoint:r,transfer:qn,toXYZ:U8,fromXYZ:F8,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:qa}}}),t}const Cn=fNe();function Sc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function sm(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let np,pNe=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{np===void 0&&(np=kw("canvas")),np.width=e.width,np.height=e.height;const i=np.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=np}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=kw("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]=Sc(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(Sc(n[r]/255)*255):n[r]=Sc(n[r]);return{data:n,width:e.width,height:e.height}}else return Yt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},mNe=0,rj=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:mNe++}),this.uuid=Wb(),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(xC(i[a].image)):s.push(xC(i[a]))}else s=xC(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function xC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?pNe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(Yt("Texture: Unable to serialize Texture."),{})}let gNe=0;const bC=new Qe;let $o=class d1 extends mf{constructor(e=d1.DEFAULT_IMAGE,n=d1.DEFAULT_MAPPING,r=mc,i=mc,s=ro,a=gh,o=Do,c=gl,u=d1.DEFAULT_ANISOTROPY,d=Lu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:gNe++}),this.uuid=Wb(),this.name="",this.source=new rj(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=c,this.offset=new cn(0,0),this.repeat=new cn(1,1),this.center=new cn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(bC).x}get height(){return this.source.getSize(bC).y}get depth(){return this.source.getSize(bC).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){Yt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==UY)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Wk:e.x=e.x-Math.floor(e.x);break;case mc:e.x=e.x<0?0:1;break;case qk: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 Wk:e.y=e.y-Math.floor(e.y);break;case mc:e.y=e.y<0?0:1;break;case qk:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};$o.DEFAULT_IMAGE=null;$o.DEFAULT_MAPPING=UY;$o.DEFAULT_ANISOTROPY=1;let Yr=class QY{constructor(e=0,n=0,r=0,i=1){QY.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 c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],m=c[5],x=c[9],y=c[2],v=c[6],b=c[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=gn(this.x,e.x,n.x),this.y=gn(this.y,e.y,n.y),this.z=gn(this.z,e.z,n.z),this.w=gn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=gn(this.x,e,n),this.y=gn(this.y,e,n),this.z=gn(this.z,e,n),this.w=gn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(gn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},xNe=class extends mf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ro,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 Yr(0,0,e,n),this.scissorTest=!1,this.viewport=new Yr(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new $o(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:ro,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 rj(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"})}},ef=class extends xNe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},JY=class extends $o{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=wa,this.minFilter=wa,this.wrapR=mc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},bNe=class extends $o{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=wa,this.minFilter=wa,this.wrapR=mc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},tf=class{constructor(e=new Qe(1/0,1/0,1/0),n=new Qe(-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(yo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(yo.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=yo.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,yo):yo.fromBufferAttribute(s,a),yo.applyMatrix4(e.matrixWorld),this.expandByPoint(yo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Ly.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Ly.copy(r.boundingBox)),Ly.applyMatrix4(e.matrixWorld),this.union(Ly)}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,yo),yo.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(gx),Iy.subVectors(this.max,gx),rp.subVectors(e.a,gx),ip.subVectors(e.b,gx),sp.subVectors(e.c,gx),hu.subVectors(ip,rp),fu.subVectors(sp,ip),Hd.subVectors(rp,sp);let n=[0,-hu.z,hu.y,0,-fu.z,fu.y,0,-Hd.z,Hd.y,hu.z,0,-hu.x,fu.z,0,-fu.x,Hd.z,0,-Hd.x,-hu.y,hu.x,0,-fu.y,fu.x,0,-Hd.y,Hd.x,0];return!vC(n,rp,ip,sp,Iy)||(n=[1,0,0,0,1,0,0,0,1],!vC(n,rp,ip,sp,Iy))?!1:(Uy.crossVectors(hu,fu),n=[Uy.x,Uy.y,Uy.z],vC(n,rp,ip,sp,Iy))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,yo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(yo).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:(Vl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Vl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Vl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Vl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Vl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Vl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Vl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Vl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Vl),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 Vl=[new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe],yo=new Qe,Ly=new tf,rp=new Qe,ip=new Qe,sp=new Qe,hu=new Qe,fu=new Qe,Hd=new Qe,gx=new Qe,Iy=new Qe,Uy=new Qe,$d=new Qe;function vC(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){$d.fromArray(t,s);const o=i.x*Math.abs($d.x)+i.y*Math.abs($d.y)+i.z*Math.abs($d.z),c=e.dot($d),u=n.dot($d),d=r.dot($d);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>o)return!1}return!0}const vNe=new tf,xx=new Qe,yC=new Qe;let UE=class{constructor(e=new Qe,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):vNe.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;xx.subVectors(e,this.center);const n=xx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(xx,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):(yC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xx.copy(e.center).add(yC)),this.expandByPoint(xx.copy(e.center).sub(yC))),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 Gl=new Qe,_C=new Qe,Fy=new Qe,pu=new Qe,wC=new Qe,zy=new Qe,SC=new Qe;let ij=class{constructor(e=new Qe,n=new Qe(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,Gl)),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=Gl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Gl.copy(this.origin).addScaledVector(this.direction,n),Gl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){_C.copy(e).add(n).multiplyScalar(.5),Fy.copy(n).sub(e).normalize(),pu.copy(this.origin).sub(_C);const s=e.distanceTo(n)*.5,a=-this.direction.dot(Fy),o=pu.dot(this.direction),c=-pu.dot(Fy),u=pu.lengthSq(),d=Math.abs(1-a*a);let f,g,m,x;if(d>0)if(f=a*c-o,g=a*o-c,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*c)+u}else g=s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*c)+u;else g=-s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-a*s+o)),g=f>0?-s:Math.min(Math.max(-s,-c),s),m=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-s,-c),s),m=g*(g+2*c)+u):(f=Math.max(0,-(a*s+o)),g=f>0?s:Math.min(Math.max(-s,-c),s),m=-f*f+g*(g+2*c)+u);else g=a>0?-s:s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(_C).addScaledVector(Fy,g),m}intersectSphere(e,n){Gl.subVectors(e.center,this.origin);const r=Gl.dot(this.direction),i=Gl.dot(Gl)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,c=r+a;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(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,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Gl)!==null}intersectTriangle(e,n,r,i,s){wC.subVectors(n,e),zy.subVectors(r,e),SC.crossVectors(wC,zy);let a=this.direction.dot(SC),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;pu.subVectors(this.origin,e);const c=o*this.direction.dot(zy.crossVectors(pu,zy));if(c<0)return null;const u=o*this.direction.dot(wC.cross(pu));if(u<0||c+u>a)return null;const d=-o*pu.dot(SC);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)}},ri=class SP{constructor(e,n,r,i,s,a,o,c,u,d,f,g,m,x,y,v){SP.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,c,u,d,f,g,m,x,y,v)}set(e,n,r,i,s,a,o,c,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]=c,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 SP().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/ap.setFromMatrixColumn(e,0).length(),s=1/ap.setFromMatrixColumn(e,1).length(),a=1/ap.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),c=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]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=g-y*u,n[9]=-o*c,n[2]=y-g*u,n[6]=x+m*u,n[10]=a*c}else if(e.order==="YXZ"){const g=c*d,m=c*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*c}else if(e.order==="ZXY"){const g=c*d,m=c*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*c}else if(e.order==="ZYX"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=c*d,n[4]=x*u-m,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*c,n[10]=a*c}else if(e.order==="YZX"){const g=a*c,m=a*u,x=o*c,y=o*u;n[0]=c*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*c,m=a*u,x=o*c,y=o*u;n[0]=c*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(yNe,e,_Ne)}lookAt(e,n,r){const i=this.elements;return ca.subVectors(e,n),ca.lengthSq()===0&&(ca.z=1),ca.normalize(),mu.crossVectors(r,ca),mu.lengthSq()===0&&(Math.abs(r.z)===1?ca.x+=1e-4:ca.z+=1e-4,ca.normalize(),mu.crossVectors(r,ca)),mu.normalize(),By.crossVectors(ca,mu),i[0]=mu.x,i[4]=By.x,i[8]=ca.x,i[1]=mu.y,i[5]=By.y,i[9]=ca.y,i[2]=mu.z,i[6]=By.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],c=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],ee=i[3],Y=i[7],Q=i[11],U=i[15];return s[0]=a*k+o*D+c*R+u*ee,s[4]=a*N+o*F+c*W+u*Y,s[8]=a*I+o*j+c*K+u*Q,s[12]=a*C+o*q+c*V+u*U,s[1]=d*k+f*D+g*R+m*ee,s[5]=d*N+f*F+g*W+m*Y,s[9]=d*I+f*j+g*K+m*Q,s[13]=d*C+f*q+g*V+m*U,s[2]=x*k+y*D+v*R+b*ee,s[6]=x*N+y*F+v*W+b*Y,s[10]=x*I+y*j+v*K+b*Q,s[14]=x*C+y*q+v*V+b*U,s[3]=E*k+S*D+A*R+T*ee,s[7]=E*N+S*F+A*W+T*Y,s[11]=E*I+S*j+A*K+T*Q,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],c=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*c*f-i*u*f-s*o*g+r*u*g+i*o*m-r*c*m)+y*(+n*c*m-n*u*g+s*a*g-i*a*m+i*u*d-s*c*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*c*f+n*o*g+i*a*f-r*a*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=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*c*m-o*v*m-f*c*b+o*g*b,S=x*g*u-d*v*u-x*c*m+a*v*m+d*c*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*c-d*y*c-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*c*s+y*i*u-r*v*u-o*i*b+r*c*b)*N,e[3]=(f*c*s-o*g*s-f*i*u+r*g*u+o*i*m-r*c*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*c*s-a*v*s-x*i*u+n*v*u+a*i*b-n*c*b)*N,e[7]=(a*g*s-d*c*s+d*i*u-n*g*u-a*i*m+n*c*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*c+n*y*c+a*r*v-n*o*v)*N,e[15]=(a*f*i-d*o*i+d*r*c-n*f*c-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,c=e.z,u=s*a,d=s*o;return this.set(u*a+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*a,0,u*c-i*o,d*c+i*a,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,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,c=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=c*u,S=c*d,A=c*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=ap.set(i[0],i[1],i[2]).length();const a=ap.set(i[4],i[5],i[6]).length(),o=ap.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],_o.copy(this);const u=1/s,d=1/a,f=1/o;return _o.elements[0]*=u,_o.elements[1]*=u,_o.elements[2]*=u,_o.elements[4]*=d,_o.elements[5]*=d,_o.elements[6]*=d,_o.elements[8]*=f,_o.elements[9]*=f,_o.elements[10]*=f,n.setFromRotationMatrix(_o),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=ol,c=!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(c)x=s/(a-s),y=a*s/(a-s);else if(o===ol)x=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===Nw)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=ol,c=!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(c)x=1/(a-s),y=a/(a-s);else if(o===ol)x=-2/(a-s),y=-(a+s)/(a-s);else if(o===Nw)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 ap=new Qe,_o=new ri,yNe=new Qe(0,0,0),_Ne=new Qe(1,1,1),mu=new Qe,By=new Qe,ca=new Qe,z8=new ri,B8=new Jh;let hd=class eZ{constructor(e=0,n=0,r=0,i=eZ.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],c=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(gn(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(-gn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(gn(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(c,s));break;case"ZYX":this._y=Math.asin(-gn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(gn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-gn(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:Yt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return z8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(z8,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return B8.setFromEuler(this),this.setFromQuaternion(B8,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}};hd.DEFAULT_ORDER="XYZ";let tZ=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}},wNe=0;const H8=new Qe,op=new Jh,Wl=new ri,Hy=new Qe,bx=new Qe,SNe=new Qe,ENe=new Jh,$8=new Qe(1,0,0),V8=new Qe(0,1,0),G8=new Qe(0,0,1),W8={type:"added"},MNe={type:"removed"},lp={type:"childadded",child:null},EC={type:"childremoved",child:null};let Na=class h1 extends mf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:wNe++}),this.uuid=Wb(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=h1.DEFAULT_UP.clone();const e=new Qe,n=new hd,r=new Jh,i=new Qe(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 ri},normalMatrix:{value:new dn}}),this.matrix=new ri,this.matrixWorld=new ri,this.matrixAutoUpdate=h1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=h1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new tZ,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 op.setFromAxisAngle(e,n),this.quaternion.multiply(op),this}rotateOnWorldAxis(e,n){return op.setFromAxisAngle(e,n),this.quaternion.premultiply(op),this}rotateX(e){return this.rotateOnAxis($8,e)}rotateY(e){return this.rotateOnAxis(V8,e)}rotateZ(e){return this.rotateOnAxis(G8,e)}translateOnAxis(e,n){return H8.copy(e).applyQuaternion(this.quaternion),this.position.add(H8.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis($8,e)}translateY(e){return this.translateOnAxis(V8,e)}translateZ(e){return this.translateOnAxis(G8,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Wl.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?Hy.copy(e):Hy.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),bx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Wl.lookAt(bx,Hy,this.up):Wl.lookAt(Hy,bx,this.up),this.quaternion.setFromRotationMatrix(Wl),i&&(Wl.extractRotation(i.matrixWorld),op.setFromRotationMatrix(Wl),this.quaternion.premultiply(op.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(zr("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(W8),lp.child=e,this.dispatchEvent(lp),lp.child=null):zr("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(MNe),EC.child=e,this.dispatchEvent(EC),EC.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),Wl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Wl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Wl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(W8),lp.child=e,this.dispatchEvent(lp),lp.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(bx,e,SNe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bx,ENe,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,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];s(e.shapes,f)}else s(e.shapes,c)}}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 c=0,u=this.material.length;c<u;c++)o.push(s(e.materials,this.material[c]));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 c=this.animations[o];i.animations.push(s(e.animations,c))}}if(n){const o=a(e.geometries),c=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),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function a(o){const c=[];for(const u in o){const d=o[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Na.DEFAULT_UP=new Qe(0,1,0);Na.DEFAULT_MATRIX_AUTO_UPDATE=!0;Na.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const wo=new Qe,ql=new Qe,MC=new Qe,Kl=new Qe,cp=new Qe,up=new Qe,q8=new Qe,AC=new Qe,TC=new Qe,CC=new Qe,NC=new Yr,kC=new Yr,PC=new Yr;let vx=class Fp{constructor(e=new Qe,n=new Qe,r=new Qe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),wo.subVectors(e,n),i.cross(wo);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){wo.subVectors(i,n),ql.subVectors(r,n),MC.subVectors(e,n);const a=wo.dot(wo),o=wo.dot(ql),c=wo.dot(MC),u=ql.dot(ql),d=ql.dot(MC),f=a*u-o*o;if(f===0)return s.set(0,0,0),null;const g=1/f,m=(u*c-o*d)*g,x=(a*d-o*c)*g;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Kl)===null?!1:Kl.x>=0&&Kl.y>=0&&Kl.x+Kl.y<=1}static getInterpolation(e,n,r,i,s,a,o,c){return this.getBarycoord(e,n,r,i,Kl)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Kl.x),c.addScaledVector(a,Kl.y),c.addScaledVector(o,Kl.z),c)}static getInterpolatedAttribute(e,n,r,i,s,a){return NC.setScalar(0),kC.setScalar(0),PC.setScalar(0),NC.fromBufferAttribute(e,n),kC.fromBufferAttribute(e,r),PC.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(NC,s.x),a.addScaledVector(kC,s.y),a.addScaledVector(PC,s.z),a}static isFrontFacing(e,n,r,i){return wo.subVectors(r,n),ql.subVectors(e,n),wo.cross(ql).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 wo.subVectors(this.c,this.b),ql.subVectors(this.a,this.b),wo.cross(ql).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Fp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Fp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return Fp.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Fp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Fp.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;cp.subVectors(i,r),up.subVectors(s,r),AC.subVectors(e,r);const c=cp.dot(AC),u=up.dot(AC);if(c<=0&&u<=0)return n.copy(r);TC.subVectors(e,i);const d=cp.dot(TC),f=up.dot(TC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return a=c/(c-d),n.copy(r).addScaledVector(cp,a);CC.subVectors(e,s);const m=cp.dot(CC),x=up.dot(CC);if(x>=0&&m<=x)return n.copy(s);const y=m*u-c*x;if(y<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(up,o);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return q8.subVectors(s,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(q8,o);const b=1/(v+y+g);return a=y*b,o=g*b,n.copy(r).addScaledVector(cp,a).addScaledVector(up,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const nZ={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},gu={h:0,s:0,l:0},$y={h:0,s:0,l:0};function RC(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let _n=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=qa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Cn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Cn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Cn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Cn.workingColorSpace){if(e=dNe(e,1),n=gn(n,0,1),r=gn(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=RC(a,s,e+1/3),this.g=RC(a,s,e),this.b=RC(a,s,e-1/3)}return Cn.colorSpaceToWorking(this,i),this}setStyle(e,n=qa){function r(s){s!==void 0&&parseFloat(s)<1&&Yt("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:Yt("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);Yt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=qa){const r=nZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):Yt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Sc(e.r),this.g=Sc(e.g),this.b=Sc(e.b),this}copyLinearToSRGB(e){return this.r=sm(e.r),this.g=sm(e.g),this.b=sm(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=qa){return Cn.workingToColorSpace(as.copy(this),e),Math.round(gn(as.r*255,0,255))*65536+Math.round(gn(as.g*255,0,255))*256+Math.round(gn(as.b*255,0,255))}getHexString(e=qa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Cn.workingColorSpace){Cn.workingToColorSpace(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 c,u;const d=(o+a)/2;if(o===a)c=0,u=0;else{const f=a-o;switch(u=d<=.5?f/(a+o):f/(2-a-o),a){case r:c=(i-s)/f+(i<s?6:0);break;case i:c=(s-r)/f+2;break;case s:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Cn.workingColorSpace){return Cn.workingToColorSpace(as.copy(this),n),e.r=as.r,e.g=as.g,e.b=as.b,e}getStyle(e=qa){Cn.workingToColorSpace(as.copy(this),e);const n=as.r,r=as.g,i=as.b;return e!==qa?`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(gu),this.setHSL(gu.h+e,gu.s+n,gu.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(gu),e.getHSL($y);const r=pC(gu.h,$y.h,n),i=pC(gu.s,$y.s,n),s=pC(gu.l,$y.l,n);return this.setHSL(r,i,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*n+s[3]*r+s[6]*i,this.g=s[1]*n+s[4]*r+s[7]*i,this.b=s[2]*n+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const as=new _n;_n.NAMES=nZ;let ANe=0,lg=class extends mf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ANe++}),this.uuid=Wb(),this.name="",this.type="Material",this.blending=im,this.side=dd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=jk,this.blendDst=Lk,this.blendEquation=ah,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _n(0,0,0),this.blendAlpha=0,this.depthFunc=Tm,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=R8,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=tp,this.stencilZFail=tp,this.stencilZPass=tp,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){Yt(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){Yt(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==im&&(r.blending=this.blending),this.side!==dd&&(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!==jk&&(r.blendSrc=this.blendSrc),this.blendDst!==Lk&&(r.blendDst=this.blendDst),this.blendEquation!==ah&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Tm&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==R8&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==tp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==tp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==tp&&(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 c=s[o];delete c.metadata,a.push(c)}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++}},sj=class extends lg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _n(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hd,this.combine=XO,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 qr=new Qe,Vy=new cn;let TNe=0,io=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:TNe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=D8,this.updateRanges=[],this.gpuType=gc,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++)Vy.fromBufferAttribute(this,n),Vy.applyMatrix3(e),this.setXY(n,Vy.x,Vy.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyMatrix3(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyMatrix4(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.applyNormalMatrix(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)qr.fromBufferAttribute(this,n),qr.transformDirection(e),this.setXYZ(n,qr.x,qr.y,qr.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=mx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Bs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=mx(n,this.array)),n}setX(e,n){return this.normalized&&(n=Bs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=mx(n,this.array)),n}setY(e,n){return this.normalized&&(n=Bs(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=mx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Bs(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=mx(n,this.array)),n}setW(e,n){return this.normalized&&(n=Bs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Bs(n,this.array),r=Bs(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=Bs(n,this.array),r=Bs(r,this.array),i=Bs(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=Bs(n,this.array),r=Bs(r,this.array),i=Bs(i,this.array),s=Bs(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!==D8&&(e.usage=this.usage),e}},rZ=class extends io{constructor(e,n,r){super(new Uint16Array(e),n,r)}},iZ=class extends io{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Io=class extends io{constructor(e,n,r){super(new Float32Array(e),n,r)}},CNe=0;const za=new ri,DC=new Na,dp=new Qe,ua=new tf,yx=new tf,Ni=new Qe;let Ml=class sZ extends mf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:CNe++}),this.uuid=Wb(),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(KY(e)?iZ:rZ)(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 dn().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 za.makeRotationFromQuaternion(e),this.applyMatrix4(za),this}rotateX(e){return za.makeRotationX(e),this.applyMatrix4(za),this}rotateY(e){return za.makeRotationY(e),this.applyMatrix4(za),this}rotateZ(e){return za.makeRotationZ(e),this.applyMatrix4(za),this}translate(e,n,r){return za.makeTranslation(e,n,r),this.applyMatrix4(za),this}scale(e,n,r){return za.makeScale(e,n,r),this.applyMatrix4(za),this}lookAt(e){return DC.lookAt(e),DC.updateMatrix(),this.applyMatrix4(DC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(dp).negate(),this.translate(dp.x,dp.y,dp.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 Io(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&&Yt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new tf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Qe(-1/0,-1/0,-1/0),new Qe(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?(Ni.addVectors(this.boundingBox.min,ua.min),this.boundingBox.expandByPoint(Ni),Ni.addVectors(this.boundingBox.max,ua.max),this.boundingBox.expandByPoint(Ni)):(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))&&zr('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 UE);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){zr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Qe,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];yx.setFromBufferAttribute(o),this.morphTargetsRelative?(Ni.addVectors(ua.min,yx.min),ua.expandByPoint(Ni),Ni.addVectors(ua.max,yx.max),ua.expandByPoint(Ni)):(ua.expandByPoint(yx.min),ua.expandByPoint(yx.max))}ua.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)Ni.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(Ni));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)Ni.fromBufferAttribute(o,u),c&&(dp.fromBufferAttribute(e,u),Ni.add(dp)),i=Math.max(i,r.distanceToSquared(Ni))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zr('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){zr("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 io(new Float32Array(4*r.count),4));const a=this.getAttribute("tangent"),o=[],c=[];for(let I=0;I<r.count;I++)o[I]=new Qe,c[I]=new Qe;const u=new Qe,d=new Qe,f=new Qe,g=new cn,m=new cn,x=new cn,y=new Qe,v=new Qe;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),c[I].add(v),c[C].add(v),c[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 Qe,A=new Qe,T=new Qe,k=new Qe;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(c[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 io(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 Qe,s=new Qe,a=new Qe,o=new Qe,c=new Qe,u=new Qe,d=new Qe,f=new Qe;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),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),c.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(y,c.x,c.y,c.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++)Ni.fromBufferAttribute(e,n),Ni.normalize(),e.setXYZ(n,Ni.x,Ni.y,Ni.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let m=0,x=0;for(let y=0,v=c.length;y<v;y++){o.isInterleavedBufferAttribute?m=c[y]*o.data.stride+o.offset:m=c[y]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new io(g,d,f)}if(this.index===null)return Yt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new sZ,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const c=[],u=s[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);c.push(m)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;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 c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],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[c]=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 c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const K8=new ri,Vd=new ij,Gy=new UE,X8=new Qe,Wy=new Qe,qy=new Qe,Ky=new Qe,OC=new Qe,Xy=new Qe,Y8=new Qe,Yy=new Qe;let xl=class extends Na{constructor(e=new Ml,n=new sj){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){Xy.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=o[c],f=s[c];d!==0&&(OC.fromBufferAttribute(f,e),a?Xy.addScaledVector(OC,d):Xy.addScaledVector(OC.sub(n),d))}n.add(Xy)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),Gy.copy(r.boundingSphere),Gy.applyMatrix4(s),Vd.copy(e.ray).recast(e.near),!(Gy.containsPoint(Vd.origin)===!1&&(Vd.intersectSphere(Gy,X8)===null||Vd.origin.distanceToSquared(X8)>(e.far-e.near)**2))&&(K8.copy(s).invert(),Vd.copy(e.ray).applyMatrix4(K8),!(r.boundingBox!==null&&Vd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Vd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,c=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=Zy(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=Zy(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==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(c.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=Zy(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(c.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=Zy(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function NNe(t,e,n,r,i,s,a,o){let c;if(e.side===Ks?c=r.intersectTriangle(a,s,i,!0,o):c=r.intersectTriangle(i,s,a,e.side===dd,o),c===null)return null;Yy.copy(o),Yy.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Yy);return u<n.near||u>n.far?null:{distance:u,point:Yy.clone(),object:t}}function Zy(t,e,n,r,i,s,a,o,c,u){t.getVertexPosition(o,Wy),t.getVertexPosition(c,qy),t.getVertexPosition(u,Ky);const d=NNe(t,e,n,r,Wy,qy,Ky,Y8);if(d){const f=new Qe;vx.getBarycoord(Y8,Wy,qy,Ky,f),i&&(d.uv=vx.getInterpolatedAttribute(i,o,c,u,f,new cn)),s&&(d.uv1=vx.getInterpolatedAttribute(s,o,c,u,f,new cn)),a&&(d.normal=vx.getInterpolatedAttribute(a,o,c,u,f,new Qe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:o,b:c,c:u,normal:new Qe,materialIndex:0};vx.getNormal(Wy,qy,Ky,g.normal),d.face=g,d.barycoord=f}return d}let aj=class aZ extends Ml{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 c=[],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(c),this.setAttribute("position",new Io(u,3)),this.setAttribute("normal",new Io(d,3)),this.setAttribute("uv",new Io(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,ee=0;const Y=new Qe;for(let Q=0;Q<K;Q++){const U=Q*F-q;for(let z=0;z<W;z++){const J=z*D-j;Y[y]=J*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-Q/I),V+=1}}for(let Q=0;Q<I;Q++)for(let U=0;U<N;U++){const z=g+U+W*Q,J=g+U+W*(Q+1),se=g+(U+1)+W*(Q+1),me=g+(U+1)+W*Q;c.push(z,J,me),c.push(J,se,me),ee+=6}o.addGroup(m,ee,C),m+=ee,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new aZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Pm(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(Yt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function _s(t){const e={};for(let n=0;n<t.length;n++){const r=Pm(t[n]);for(const i in r)e[i]=r[i]}return e}function kNe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function oZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Cn.workingColorSpace}const PNe={clone:Pm,merge:_s};var RNe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,DNe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let jc=class extends lg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=RNe,this.fragmentShader=DNe,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=Pm(e.uniforms),this.uniformsGroups=kNe(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}},lZ=class extends Na{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ri,this.projectionMatrix=new ri,this.projectionMatrixInverse=new ri,this.coordinateSystem=ol,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const xu=new Qe,Z8=new cn,Q8=new cn;let Ya=class extends lZ{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=wP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(u1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return wP*2*Math.atan(Math.tan(u1*.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){xu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(xu.x,xu.y).multiplyScalar(-e/xu.z),xu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(xu.x,xu.y).multiplyScalar(-e/xu.z)}getViewSize(e,n){return this.getViewBounds(e,Z8,Q8),n.subVectors(Q8,Z8)}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(u1*.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 c=a.fullWidth,u=a.fullHeight;s+=a.offsetX*i/c,n-=a.offsetY*r/u,i*=a.width/c,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 hp=-90,fp=1;let ONe=class extends Na{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ya(hp,fp,e,n);i.layers=this.layers,this.add(i);const s=new Ya(hp,fp,e,n);s.layers=this.layers,this.add(s);const a=new Ya(hp,fp,e,n);a.layers=this.layers,this.add(a);const o=new Ya(hp,fp,e,n);o.layers=this.layers,this.add(o);const c=new Ya(hp,fp,e,n);c.layers=this.layers,this.add(c);const u=new Ya(hp,fp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,c]=n;for(const u of n)this.remove(u);if(e===ol)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),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),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Nw)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),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,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,c),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}},cZ=class extends $o{constructor(e=[],n=Cm,r,i,s,a,o,c,u,d){super(e,n,r,i,s,a,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},jNe=class extends ef{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 cZ(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 aj(5,5,5),s=new jc({name:"CubemapFromEquirect",uniforms:Pm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ks,blending:wc});s.uniforms.tEquirect.value=n;const a=new xl(i,s),o=n.minFilter;return n.minFilter===gh&&(n.minFilter=ro),new ONe(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)}},Lx=class extends Na{constructor(){super(),this.isGroup=!0,this.type="Group"}};const LNe={type:"move"};let jC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lx,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Lx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Qe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Qe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Qe),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,c=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 c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.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(LNe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Lx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},INe=class extends Na{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 hd,this.environmentIntensity=1,this.environmentRotation=new hd,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}},UNe=class extends $o{constructor(e=null,n=1,r=1,i,s,a,o,c,u=wa,d=wa,f,g){super(null,a,o,c,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 LC=new Qe,FNe=new Qe,zNe=new dn;let Nu=class{constructor(e=new Qe(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=LC.subVectors(r,n).cross(FNe.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(LC),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||zNe.getNormalMatrix(e),i=this.coplanarPoint(LC).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 Gd=new UE,BNe=new cn(.5,.5),Qy=new Qe;let oj=class{constructor(e=new Nu,n=new Nu,r=new Nu,i=new Nu,s=new Nu,a=new Nu){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=ol,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],c=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(c,g,v,A).normalize(),i[5].setComponents(u-c,m-g,b-v,T-A).normalize();else if(i[4].setComponents(u-c,m-g,b-v,T-A).normalize(),n===ol)i[5].setComponents(u+c,m+g,b+v,T+A).normalize();else if(n===Nw)i[5].setComponents(c,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(),Gd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Gd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Gd)}intersectsSprite(e){Gd.center.set(0,0,0);const n=BNe.distanceTo(e.center);return Gd.radius=.7071067811865476+n,Gd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Gd)}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(Qy.x=i.normal.x>0?e.max.x:e.min.x,Qy.y=i.normal.y>0?e.max.y:e.min.y,Qy.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Qy)<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)}},uZ=class extends lg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _n(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const Pw=new Qe,Rw=new Qe,J8=new ri,_x=new ij,Jy=new UE,IC=new Qe,eH=new Qe;let HNe=class extends Na{constructor(e=new Ml,n=new uZ){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++)Pw.fromBufferAttribute(n,i-1),Rw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Pw.distanceTo(Rw);e.setAttribute("lineDistance",new Io(r,1))}else Yt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,a=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),Jy.copy(r.boundingSphere),Jy.applyMatrix4(i),Jy.radius+=s,e.ray.intersectsSphere(Jy)===!1)return;J8.copy(i).invert(),_x.copy(e.ray).applyMatrix4(J8);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const 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=e_(this,e,_x,c,b,E,y);S&&n.push(S)}if(this.isLineLoop){const y=d.getX(x-1),v=d.getX(m),b=e_(this,e,_x,c,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=e_(this,e,_x,c,y,y+1,y);b&&n.push(b)}if(this.isLineLoop){const y=e_(this,e,_x,c,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 e_(t,e,n,r,i,s,a){const o=t.geometry.attributes.position;if(Pw.fromBufferAttribute(o,i),Rw.fromBufferAttribute(o,s),n.distanceSqToSegment(Pw,Rw,IC,eH)>r)return;IC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(IC);if(!(u<e.near||u>e.far))return{distance:u,point:eH.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}const tH=new Qe,nH=new Qe;let $Ne=class extends HNe{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)tH.fromBufferAttribute(n,i),nH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+tH.distanceTo(nH);e.setAttribute("lineDistance",new Io(r,1))}else Yt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},dZ=class extends $o{constructor(e,n,r=Qh,i,s,a,o=wa,c=wa,u,d=G0,f=1){if(d!==G0&&d!==W0)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,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new rj(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 hZ extends $o{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let lj=class fZ extends Ml{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),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,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/c)}}for(let b=0;b<c;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 Io(x,3)),this.setAttribute("normal",new Io(y,3)),this.setAttribute("uv",new Io(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class VNe extends lg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _n(16777215),this.specular=new _n(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _n(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=WY,this.normalScale=new cn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new hd,this.combine=XO,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 GNe=class extends lg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=JCe,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}},WNe=class extends lg{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}},pZ=class extends Na{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new _n(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const UC=new ri,rH=new Qe,iH=new Qe;let qNe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new cn(512,512),this.mapType=gl,this.map=null,this.mapPass=null,this.matrix=new ri,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new oj,this._frameExtents=new cn(1,1),this._viewportCount=1,this._viewports=[new Yr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;rH.setFromMatrixPosition(e.matrixWorld),n.position.copy(rH),iH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(iH),n.updateMatrixWorld(),UC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(UC,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(UC)}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}},mZ=class extends lZ{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,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,a=s+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class KNe extends qNe{constructor(){super(new mZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class sH extends pZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Na.DEFAULT_UP),this.updateMatrix(),this.target=new Na,this.shadow=new KNe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let XNe=class extends pZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},YNe=class extends Ya{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},aH=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=gn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(gn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class ZNe extends $Ne{constructor(e=10,n=10,r=4473924,i=8947848){r=new _n(r),i=new _n(i);const s=n/2,a=e/n,o=e/2,c=[],u=[];for(let g=0,m=0,x=-o;g<=n;g++,x+=a){c.push(-o,0,x,o,0,x),c.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 Ml;d.setAttribute("position",new Io(c,3)),d.setAttribute("color",new Io(u,3));const f=new uZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class QNe extends mf{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Yt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function oH(t,e,n,r){const i=JNe(r);switch(n){case $Y:return t*e;case GY:return t*e/i.components*i.byteLength;case JO:return t*e/i.components*i.byteLength;case ej:return t*e*2/i.components*i.byteLength;case tj:return t*e*2/i.components*i.byteLength;case VY:return t*e*3/i.components*i.byteLength;case Do:return t*e*4/i.components*i.byteLength;case nj:return t*e*4/i.components*i.byteLength;case a1:case o1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case l1:case c1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Xk:case Zk:return Math.max(t,16)*Math.max(e,8)/4;case Kk:case Yk:return Math.max(t,8)*Math.max(e,8)/2;case Qk:case Jk:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case eP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case tP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case nP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case rP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case iP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case sP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case aP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case oP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case lP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case cP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case uP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case dP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case hP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case fP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case pP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case mP:case gP:case xP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case bP:case vP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case yP:case _P:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function JNe(t){switch(t){case gl:case FY:return{byteLength:1,components:1};case $0:case zY:case og:return{byteLength:2,components:1};case ZO:case QO:return{byteLength:2,components:4};case Qh:case YO:case gc:return{byteLength:4,components:1};case BY:case HY:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:KO}}));typeof window<"u"&&(window.__THREE__?Yt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=KO);function gZ(){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 e3e(t){const e=new WeakMap;function n(o,c){const u=o.array,d=o.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(c,g),t.bufferData(c,u,d),o.onUploadCallback();let 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,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,o),f.length===0)t.bufferSubData(u,0,d);else{f.sort((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)}c.clearUpdateRanges()}c.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(t.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const u=e.get(o);if(u===void 0)e.set(o,n(o,c));else if(u.version<o.version){if(u.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,o,c),u.version=o.version}}return{get:i,remove:s,update:a}}var t3e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,n3e=`#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`,r3e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,i3e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,s3e=`#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`,a3e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,o3e=`#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`,l3e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,c3e=`#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`,u3e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,d3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,h3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,f3e=`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`,p3e=`#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`,m3e=`#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`,g3e=`#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`,x3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,b3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,v3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,y3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,_3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,w3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,S3e=`#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`,E3e=`#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`,M3e=`#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`,A3e=`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`,T3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,C3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,N3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,k3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,P3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",R3e=`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 );
- }`,D3e=`#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`,O3e=`#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`,j3e=`#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`,L3e=`#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`,I3e=`#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`,U3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,F3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,z3e=`#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`,B3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,H3e=`#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
- }`,$3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,V3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,G3e=`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`,W3e=`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`,q3e=`#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`,K3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,X3e=`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`,Y3e=`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`,Q3e=`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`,J3e=`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 );
- }`,eke=`
- 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`,tke=`#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`,nke=`#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`,rke=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,ike=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,ske=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,ake=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,oke=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,lke=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,cke=`#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`,uke=`#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`,dke=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,hke=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,fke=`#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`,pke=`#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`,mke=`#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`,gke=`#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`,xke=`#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`,bke=`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;`,vke=`#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`,yke=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,_ke=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,wke=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Ske=`#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`,Eke=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Mke=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Ake=`#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`,Tke=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Cke=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Nke=`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 );
- }`,kke=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,Pke=`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;`,Rke=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,Dke=`#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`,Oke=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,jke=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Lke=`#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`,Ike=`#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`,Uke=`#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`,Fke=`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;
- }`,zke=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,Bke=`#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`,Hke=`#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`,$ke=`#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`,Vke=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,Gke=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,Wke=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,qke=`#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; }`,Kke=`#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`,Xke=`#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`,Yke=`#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`,Qke=`#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`,Jke=`#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 ePe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,tPe=`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>
- }`,nPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,rPe=`#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>
- }`,iPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,sPe=`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>
- }`,aPe=`#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;
- }`,oPe=`#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
- }`,lPe=`#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;
- }`,cPe=`#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 );
- }`,uPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,dPe=`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>
- }`,hPe=`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>
- }`,fPe=`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>
- }`,pPe=`#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>
- }`,mPe=`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>
- }`,gPe=`#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>
- }`,xPe=`#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>
- }`,bPe=`#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;
- }`,vPe=`#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>
- }`,yPe=`#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
- }`,_Pe=`#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
- }`,wPe=`#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>
- }`,SPe=`#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>
- }`,EPe=`#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
- }`,MPe=`#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>
- }`,APe=`#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>
- }`,TPe=`#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>
- }`,CPe=`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>
- }`,NPe=`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>
- }`,kPe=`#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>
- }`,PPe=`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>
- }`,RPe=`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>
- }`,DPe=`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>
- }`,on={alphahash_fragment:t3e,alphahash_pars_fragment:n3e,alphamap_fragment:r3e,alphamap_pars_fragment:i3e,alphatest_fragment:s3e,alphatest_pars_fragment:a3e,aomap_fragment:o3e,aomap_pars_fragment:l3e,batching_pars_vertex:c3e,batching_vertex:u3e,begin_vertex:d3e,beginnormal_vertex:h3e,bsdfs:f3e,iridescence_fragment:p3e,bumpmap_pars_fragment:m3e,clipping_planes_fragment:g3e,clipping_planes_pars_fragment:x3e,clipping_planes_pars_vertex:b3e,clipping_planes_vertex:v3e,color_fragment:y3e,color_pars_fragment:_3e,color_pars_vertex:w3e,color_vertex:S3e,common:E3e,cube_uv_reflection_fragment:M3e,defaultnormal_vertex:A3e,displacementmap_pars_vertex:T3e,displacementmap_vertex:C3e,emissivemap_fragment:N3e,emissivemap_pars_fragment:k3e,colorspace_fragment:P3e,colorspace_pars_fragment:R3e,envmap_fragment:D3e,envmap_common_pars_fragment:O3e,envmap_pars_fragment:j3e,envmap_pars_vertex:L3e,envmap_physical_pars_fragment:q3e,envmap_vertex:I3e,fog_vertex:U3e,fog_pars_vertex:F3e,fog_fragment:z3e,fog_pars_fragment:B3e,gradientmap_pars_fragment:H3e,lightmap_pars_fragment:$3e,lights_lambert_fragment:V3e,lights_lambert_pars_fragment:G3e,lights_pars_begin:W3e,lights_toon_fragment:K3e,lights_toon_pars_fragment:X3e,lights_phong_fragment:Y3e,lights_phong_pars_fragment:Z3e,lights_physical_fragment:Q3e,lights_physical_pars_fragment:J3e,lights_fragment_begin:eke,lights_fragment_maps:tke,lights_fragment_end:nke,logdepthbuf_fragment:rke,logdepthbuf_pars_fragment:ike,logdepthbuf_pars_vertex:ske,logdepthbuf_vertex:ake,map_fragment:oke,map_pars_fragment:lke,map_particle_fragment:cke,map_particle_pars_fragment:uke,metalnessmap_fragment:dke,metalnessmap_pars_fragment:hke,morphinstance_vertex:fke,morphcolor_vertex:pke,morphnormal_vertex:mke,morphtarget_pars_vertex:gke,morphtarget_vertex:xke,normal_fragment_begin:bke,normal_fragment_maps:vke,normal_pars_fragment:yke,normal_pars_vertex:_ke,normal_vertex:wke,normalmap_pars_fragment:Ske,clearcoat_normal_fragment_begin:Eke,clearcoat_normal_fragment_maps:Mke,clearcoat_pars_fragment:Ake,iridescence_pars_fragment:Tke,opaque_fragment:Cke,packing:Nke,premultiplied_alpha_fragment:kke,project_vertex:Pke,dithering_fragment:Rke,dithering_pars_fragment:Dke,roughnessmap_fragment:Oke,roughnessmap_pars_fragment:jke,shadowmap_pars_fragment:Lke,shadowmap_pars_vertex:Ike,shadowmap_vertex:Uke,shadowmask_pars_fragment:Fke,skinbase_vertex:zke,skinning_pars_vertex:Bke,skinning_vertex:Hke,skinnormal_vertex:$ke,specularmap_fragment:Vke,specularmap_pars_fragment:Gke,tonemapping_fragment:Wke,tonemapping_pars_fragment:qke,transmission_fragment:Kke,transmission_pars_fragment:Xke,uv_pars_fragment:Yke,uv_pars_vertex:Zke,uv_vertex:Qke,worldpos_vertex:Jke,background_vert:ePe,background_frag:tPe,backgroundCube_vert:nPe,backgroundCube_frag:rPe,cube_vert:iPe,cube_frag:sPe,depth_vert:aPe,depth_frag:oPe,distanceRGBA_vert:lPe,distanceRGBA_frag:cPe,equirect_vert:uPe,equirect_frag:dPe,linedashed_vert:hPe,linedashed_frag:fPe,meshbasic_vert:pPe,meshbasic_frag:mPe,meshlambert_vert:gPe,meshlambert_frag:xPe,meshmatcap_vert:bPe,meshmatcap_frag:vPe,meshnormal_vert:yPe,meshnormal_frag:_Pe,meshphong_vert:wPe,meshphong_frag:SPe,meshphysical_vert:EPe,meshphysical_frag:MPe,meshtoon_vert:APe,meshtoon_frag:TPe,points_vert:CPe,points_frag:NPe,shadow_vert:kPe,shadow_frag:PPe,sprite_vert:RPe,sprite_frag:DPe},Mt={common:{diffuse:{value:new _n(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new dn}},envmap:{envMap:{value:null},envMapRotation:{value:new dn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new dn},normalScale:{value:new cn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new dn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new dn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new dn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new dn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _n(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new _n(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0},uvTransform:{value:new dn}},sprite:{diffuse:{value:new _n(16777215)},opacity:{value:1},center:{value:new cn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}}},nl={basic:{uniforms:_s([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.fog]),vertexShader:on.meshbasic_vert,fragmentShader:on.meshbasic_frag},lambert:{uniforms:_s([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,Mt.lights,{emissive:{value:new _n(0)}}]),vertexShader:on.meshlambert_vert,fragmentShader:on.meshlambert_frag},phong:{uniforms:_s([Mt.common,Mt.specularmap,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,Mt.lights,{emissive:{value:new _n(0)},specular:{value:new _n(1118481)},shininess:{value:30}}]),vertexShader:on.meshphong_vert,fragmentShader:on.meshphong_frag},standard:{uniforms:_s([Mt.common,Mt.envmap,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.roughnessmap,Mt.metalnessmap,Mt.fog,Mt.lights,{emissive:{value:new _n(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag},toon:{uniforms:_s([Mt.common,Mt.aomap,Mt.lightmap,Mt.emissivemap,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.gradientmap,Mt.fog,Mt.lights,{emissive:{value:new _n(0)}}]),vertexShader:on.meshtoon_vert,fragmentShader:on.meshtoon_frag},matcap:{uniforms:_s([Mt.common,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,Mt.fog,{matcap:{value:null}}]),vertexShader:on.meshmatcap_vert,fragmentShader:on.meshmatcap_frag},points:{uniforms:_s([Mt.points,Mt.fog]),vertexShader:on.points_vert,fragmentShader:on.points_frag},dashed:{uniforms:_s([Mt.common,Mt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:on.linedashed_vert,fragmentShader:on.linedashed_frag},depth:{uniforms:_s([Mt.common,Mt.displacementmap]),vertexShader:on.depth_vert,fragmentShader:on.depth_frag},normal:{uniforms:_s([Mt.common,Mt.bumpmap,Mt.normalmap,Mt.displacementmap,{opacity:{value:1}}]),vertexShader:on.meshnormal_vert,fragmentShader:on.meshnormal_frag},sprite:{uniforms:_s([Mt.sprite,Mt.fog]),vertexShader:on.sprite_vert,fragmentShader:on.sprite_frag},background:{uniforms:{uvTransform:{value:new dn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:on.background_vert,fragmentShader:on.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new dn}},vertexShader:on.backgroundCube_vert,fragmentShader:on.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:on.cube_vert,fragmentShader:on.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:on.equirect_vert,fragmentShader:on.equirect_frag},distanceRGBA:{uniforms:_s([Mt.common,Mt.displacementmap,{referencePosition:{value:new Qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:on.distanceRGBA_vert,fragmentShader:on.distanceRGBA_frag},shadow:{uniforms:_s([Mt.lights,Mt.fog,{color:{value:new _n(0)},opacity:{value:1}}]),vertexShader:on.shadow_vert,fragmentShader:on.shadow_frag}};nl.physical={uniforms:_s([nl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new dn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new dn},clearcoatNormalScale:{value:new cn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new dn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new dn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new dn},sheen:{value:0},sheenColor:{value:new _n(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new dn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new dn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new dn},transmissionSamplerSize:{value:new cn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new dn},attenuationDistance:{value:0},attenuationColor:{value:new _n(0)},specularColor:{value:new _n(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new dn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new dn},anisotropyVector:{value:new cn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new dn}}]),vertexShader:on.meshphysical_vert,fragmentShader:on.meshphysical_frag};const t_={r:0,b:0,g:0},Wd=new hd,OPe=new ri;function jPe(t,e,n,r,i,s,a){const o=new _n(0);let c=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,c):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===IE)?(d===void 0&&(d=new xl(new aj(1,1,1),new jc({name:"BackgroundCubeMaterial",uniforms:Pm(nl.backgroundCube.uniforms),vertexShader:nl.backgroundCube.vertexShader,fragmentShader:nl.backgroundCube.fragmentShader,side:Ks,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)),Wd.copy(A.backgroundRotation),Wd.x*=-1,Wd.y*=-1,Wd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Wd.y*=-1,Wd.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(OPe.makeRotationFromEuler(Wd)),d.material.toneMapped=Cn.getTransfer(T.colorSpace)!==qn,(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 xl(new lj(2,2),new jc({name:"BackgroundMaterial",uniforms:Pm(nl.background.uniforms),vertexShader:nl.background.vertexShader,fragmentShader:nl.background.fragmentShader,side:dd,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=Cn.getTransfer(T.colorSpace)!==qn,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(t_,oZ(t)),r.buffers.color.setClear(t_.r,t_.g,t_.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),c=A,b(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(S){c=S,b(o,c)},render:y,addToRenderList:v,dispose:E}}function LPe(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 c(){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(c()),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 ee in V)if(V[ee].location>=0){const Q=R[ee];let U=W[ee];if(U===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(U=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(U=D.instanceColor)),Q===void 0||Q.attribute!==U||U&&Q.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 ee in V)if(V[ee].location>=0){let Q=W[ee];Q===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(Q=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(Q=D.instanceColor));const U={};U.attribute=Q,Q&&Q.data&&(U.data=Q.data),R[ee]=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 ee=W[V];if(ee.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 Q=Y.normalized,U=Y.itemSize,z=e.get(Y);if(z===void 0)continue;const J=z.buffer,se=z.type,me=z.bytesPerElement,fe=se===t.INT||se===t.UNSIGNED_INT||Y.gpuType===YO;if(Y.isInterleavedBufferAttribute){const xe=Y.data,Ee=xe.stride,re=Y.offset;if(xe.isInstancedInterleavedBuffer){for(let we=0;we<ee.locationSize;we++)b(ee.location+we,xe.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let we=0;we<ee.locationSize;we++)v(ee.location+we);t.bindBuffer(t.ARRAY_BUFFER,J);for(let we=0;we<ee.locationSize;we++)S(ee.location+we,U/ee.locationSize,se,Q,Ee*me,(re+U/ee.locationSize*we)*me,fe)}else{if(Y.isInstancedBufferAttribute){for(let xe=0;xe<ee.locationSize;xe++)b(ee.location+xe,Y.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let xe=0;xe<ee.locationSize;xe++)v(ee.location+xe);t.bindBuffer(t.ARRAY_BUFFER,J);for(let xe=0;xe<ee.locationSize;xe++)S(ee.location+xe,U/ee.locationSize,se,Q,U*me,U/ee.locationSize*xe*me,fe)}}else if(K!==void 0){const Q=K[V];if(Q!==void 0)switch(Q.length){case 2:t.vertexAttrib2fv(ee.location,Q);break;case 3:t.vertexAttrib3fv(ee.location,Q);break;case 4:t.vertexAttrib4fv(ee.location,Q);break;default:t.vertexAttrib1fv(ee.location,Q)}}}}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 IPe(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 c(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=c}function UPe(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!==Do&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(N){const I=N===og&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==gl&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==gc&&!I)}function c(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=c(u);d!==u&&(Yt("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),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:c,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 FPe(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new Nu,o=new dn,c={value:null,needsUpdate:!1};this.uniform=c,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;c.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(){c.value!==n&&(c.value=n,c.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=c.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}c.value=v,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function zPe(t){let e=new WeakMap;function n(a,o){return o===Vk?a.mapping=Cm:o===Gk&&(a.mapping=Nm),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===Vk||o===Gk)if(e.has(a)){const c=e.get(a).texture;return n(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const u=new jNe(c.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 c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}const zu=4,lH=[.125,.215,.35,.446,.526,.582],oh=20,BPe=256,wx=new mZ,cH=new _n;let FC=null,zC=0,BC=0,HC=!1;const HPe=new Qe;let uH=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=HPe}=s;FC=this._renderer.getRenderTarget(),zC=this._renderer.getActiveCubeFace(),BC=this._renderer.getActiveMipmapLevel(),HC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,o),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=fH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=hH(),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(FC,zC,BC),this._renderer.xr.enabled=HC,e.scissorTest=!1,pp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Cm||e.mapping===Nm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),FC=this._renderer.getRenderTarget(),zC=this._renderer.getActiveCubeFace(),BC=this._renderer.getActiveMipmapLevel(),HC=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:ro,minFilter:ro,generateMipmaps:!1,type:og,format:Do,colorSpace:km,depthBuffer:!1},i=dH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=dH(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=$Pe(s)),this._blurMaterial=GPe(s,e,n),this._ggxMaterial=VPe(s,e,n)}return i}_compileMaterial(e){const n=new xl(new Ml,e);this._renderer.compile(n,wx)}_sceneToCubeUV(e,n,r,i,s){const c=new Ya(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(cH),f.toneMapping=Xu,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new xl(new aj,new sj({name:"PMREM.Background",side:Ks,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(cH),b=!0);for(let S=0;S<6;S++){const A=S%3;A===0?(c.up.set(0,u[S],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[S],s.y,s.z)):A===1?(c.up.set(0,0,u[S]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[S],s.z)):(c.up.set(0,u[S],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[S]));const T=this._cubeSize;pp(i,A*T,S>2?T:0,T,T),f.setRenderTarget(i),b&&f.render(y,c),f.render(e,c)}f.toneMapping=m,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Cm||e.mapping===Nm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=fH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=hH());const s=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;pp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(a,wx)}_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 c=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-zu?r-x+zu:0),b=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=x-n,pp(s,v,b,3*y,2*y),i.setRenderTarget(s),i.render(o,wx),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-r,pp(e,v,b,3*y,2*y),i.setRenderTarget(e),i.render(o,wx)}_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 c=this._renderer,u=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&zr("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*oh-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):oh;v>oh&&Yt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${oh}`);const b=[];let E=0;for(let N=0;N<oh;++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-zu?i-S+zu:0),k=4*(this._cubeSize-A);pp(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,wx)}};function $Pe(t){const e=[],n=[],r=[];let i=t;const s=t-zu+1+lH.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);e.push(o);let c=1/o;a>t-zu?c=lH[a-t+zu-1]:a===0&&(c=0),n.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],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 Ml;T.setAttribute("position",new io(E,y)),T.setAttribute("uv",new io(S,v)),T.setAttribute("faceIndex",new io(A,b)),r.push(new xl(T,null)),i>zu&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function dH(t,e,n){const r=new ef(t,e,n);return r.texture.mapping=IE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function pp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function VPe(t,e,n){return new jc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:BPe,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:FE(),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:wc,depthTest:!1,depthWrite:!1})}function GPe(t,e,n){const r=new Float32Array(oh),i=new Qe(0,1,0);return new jc({name:"SphericalGaussianBlur",defines:{n:oh,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:FE(),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:wc,depthTest:!1,depthWrite:!1})}function hH(){return new jc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:FE(),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:wc,depthTest:!1,depthWrite:!1})}function fH(){return new jc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:FE(),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:wc,depthTest:!1,depthWrite:!1})}function FE(){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 WPe(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===Vk||c===Gk,d=c===Cm||c===Nm;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 uH(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 uH(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 c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function s(o){const c=o.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function qPe(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&&q0("WebGLRenderer: "+r+" extension not supported."),i}}}function KPe(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 c(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(KY(g)?iZ:rZ)(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:c,getWireframeAttribute:d}}function XPe(t,e,n){let r;function i(g){r=g}let s,a;function o(g){s=g.type,a=g.bytesPerElement}function c(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=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function YPe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(s,a,o){switch(n.calls++,a){case t.TRIANGLES:n.triangles+=o*(s/3);break;case t.LINES:n.lines+=o*(s/2);break;case t.LINE_STRIP:n.lines+=o*(s-1);break;case t.LINE_LOOP:n.lines+=o*s;break;case t.POINTS:n.points+=o*s;break;default:zr("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 Yr;function s(a,o,c){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 JY(N,T,k,f);I.type=gc,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 cn(T,k)},r.set(o,g),o.addEventListener("dispose",D)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.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;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:s}}function QPe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function a(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:a}}const xZ=new $o,pH=new dZ(1,1),bZ=new JY,vZ=new bNe,yZ=new cZ,mH=[],gH=[],xH=new Float32Array(16),bH=new Float32Array(9),vH=new Float32Array(4);function cg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=mH[i];if(s===void 0&&(s=new Float32Array(i),mH[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 zE(t,e){let n=gH[e];n===void 0&&(n=new Int32Array(e),gH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function JPe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(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.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 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.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 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.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 rRe(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;vH.set(r),t.uniformMatrix2fv(this.addr,!1,vH),mi(n,r)}}function iRe(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;bH.set(r),t.uniformMatrix3fv(this.addr,!1,bH),mi(n,r)}}function sRe(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;xH.set(r),t.uniformMatrix4fv(this.addr,!1,xH),mi(n,r)}}function aRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function oRe(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 lRe(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 cRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.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 uRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function dRe(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 hRe(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 fRe(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 pRe(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?(pH.compareFunction=qY,s=pH):s=xZ,n.setTexture2D(e||s,i)}function mRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||vZ,i)}function gRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||yZ,i)}function xRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||bZ,i)}function bRe(t){switch(t){case 5126:return JPe;case 35664:return eRe;case 35665:return tRe;case 35666:return nRe;case 35674:return rRe;case 35675:return iRe;case 35676:return sRe;case 5124:case 35670:return aRe;case 35667:case 35671:return oRe;case 35668:case 35672:return lRe;case 35669:case 35673:return cRe;case 5125:return uRe;case 36294:return dRe;case 36295:return hRe;case 36296:return fRe;case 35678:case 36198:case 36298:case 36306:case 35682:return pRe;case 35679:case 36299:case 36307:return mRe;case 35680:case 36300:case 36308:case 36293:return gRe;case 36289:case 36303:case 36311:case 36292:return xRe}}function vRe(t,e){t.uniform1fv(this.addr,e)}function yRe(t,e){const n=cg(e,this.size,2);t.uniform2fv(this.addr,n)}function _Re(t,e){const n=cg(e,this.size,3);t.uniform3fv(this.addr,n)}function wRe(t,e){const n=cg(e,this.size,4);t.uniform4fv(this.addr,n)}function SRe(t,e){const n=cg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ERe(t,e){const n=cg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function MRe(t,e){const n=cg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function ARe(t,e){t.uniform1iv(this.addr,e)}function TRe(t,e){t.uniform2iv(this.addr,e)}function CRe(t,e){t.uniform3iv(this.addr,e)}function NRe(t,e){t.uniform4iv(this.addr,e)}function kRe(t,e){t.uniform1uiv(this.addr,e)}function PRe(t,e){t.uniform2uiv(this.addr,e)}function RRe(t,e){t.uniform3uiv(this.addr,e)}function DRe(t,e){t.uniform4uiv(this.addr,e)}function ORe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||xZ,s[a])}function jRe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||vZ,s[a])}function LRe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||yZ,s[a])}function IRe(t,e,n){const r=this.cache,i=e.length,s=zE(n,i);pi(r,s)||(t.uniform1iv(this.addr,s),mi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||bZ,s[a])}function URe(t){switch(t){case 5126:return vRe;case 35664:return yRe;case 35665:return _Re;case 35666:return wRe;case 35674:return SRe;case 35675:return ERe;case 35676:return MRe;case 5124:case 35670:return ARe;case 35667:case 35671:return TRe;case 35668:case 35672:return CRe;case 35669:case 35673:return NRe;case 5125:return kRe;case 36294:return PRe;case 36295:return RRe;case 36296:return DRe;case 35678:case 36198:case 36298:case 36306:case 35682:return ORe;case 35679:case 36299:case 36307:return jRe;case 35680:case 36300:case 36308:case 36293:return LRe;case 36289:case 36303:case 36311:case 36292:return IRe}}let FRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=bRe(n.type)}},zRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=URe(n.type)}},BRe=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 $C=/(\w+)(\])?(\[|\.)?/g;function yH(t,e){t.seq.push(e),t.map[e.id]=e}function HRe(t,e,n){const r=t.name,i=r.length;for($C.lastIndex=0;;){const s=$C.exec(r),a=$C.lastIndex;let o=s[1];const c=s[2]==="]",u=s[3];if(c&&(o=o|0),u===void 0||u==="["&&a+2===i){yH(n,u===void 0?new FRe(o,t,e):new zRe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new BRe(o),yH(n,f)),n=f}}}let f1=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);HRe(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],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.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 $Re=37297;let VRe=0;function GRe(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 wH=new dn;function WRe(t){Cn._getMatrix(wH,Cn.workingColorSpace,t);const e=`mat3( ${wH.elements.map(n=>n.toFixed(4))} )`;switch(Cn.getTransfer(t)){case Cw:return[e,"LinearTransferOETF"];case qn:return[e,"sRGBTransferOETF"];default:return Yt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function SH(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+`
- `+GRe(t.getShaderSource(e),o)}else return s}function qRe(t,e){const n=WRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function KRe(t,e){let n;switch(e){case GCe:n="Linear";break;case WCe:n="Reinhard";break;case qCe:n="Cineon";break;case KCe:n="ACESFilmic";break;case YCe:n="AgX";break;case ZCe:n="Neutral";break;case XCe:n="Custom";break;default:Yt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const n_=new Qe;function XRe(){Cn.getLuminanceCoefficients(n_);const t=n_.x.toFixed(4),e=n_.y.toFixed(4),n=n_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function YRe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ix).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 QRe(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 Ix(t){return t!==""}function EH(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 MH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const JRe=/^[ \t]*#include +<([\w\d./]+)>/gm;function EP(t){return t.replace(JRe,tDe)}const eDe=new Map;function tDe(t,e){let n=on[e];if(n===void 0){const r=eDe.get(e);if(r!==void 0)n=on[r],Yt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return EP(n)}const nDe=/#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 AH(t){return t.replace(nDe,rDe)}function rDe(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 TH(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 iDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===IY?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===ECe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===ic&&(e="SHADOWMAP_TYPE_VSM"),e}function sDe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Cm:case Nm:e="ENVMAP_TYPE_CUBE";break;case IE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function aDe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Nm:e="ENVMAP_MODE_REFRACTION";break}return e}function oDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case XO:e="ENVMAP_BLENDING_MULTIPLY";break;case $Ce:e="ENVMAP_BLENDING_MIX";break;case VCe:e="ENVMAP_BLENDING_ADD";break}return e}function lDe(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 cDe(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const c=iDe(n),u=sDe(n),d=aDe(n),f=oDe(n),g=lDe(n),m=YRe(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(Ix).join(`
- `),v.length>0&&(v+=`
- `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ix).join(`
- `),b.length>0&&(b+=`
- `)):(v=[TH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Ix).join(`
- `),b=[TH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Xu?"#define TONE_MAPPING":"",n.toneMapping!==Xu?on.tonemapping_pars_fragment:"",n.toneMapping!==Xu?KRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",on.colorspace_pars_fragment,qRe("linearToOutputTexel",n.outputColorSpace),XRe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Ix).join(`
- `)),a=EP(a),a=EH(a,n),a=MH(a,n),o=EP(o),o=EH(o,n),o=MH(o,n),a=AH(a),o=AH(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===O8?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===O8?"":"#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)||"",q=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(k)||"",W=j.trim(),K=q.trim(),V=R.trim();let ee=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(ee=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,T,k);else{const Q=SH(i,T,"vertex"),U=SH(i,k,"fragment");zr("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+`
- `+Q+`
- `+U)}else W!==""?Yt("WebGLProgram: Program Info Log:",W):(K===""||V==="")&&(Y=!1);Y&&(F.diagnostics={runnable:ee,programLog:W,vertexShader:{log:K,prefix:v},fragmentShader:{log:V,prefix:b}})}i.deleteShader(T),i.deleteShader(k),I=new f1(i,y),C=QRe(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,$Re)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=VRe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let uDe=0,dDe=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 hDe(e),n.set(e,r)),r}},hDe=class{constructor(e){this.id=uDe++,this.code=e,this.usedTimes=0}};function fDe(t,e,n,r,i,s,a){const o=new tZ,c=new dDe,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),ee=V&&V.mapping===IE?V.image.height:null,Y=x[C.type];C.precision!==null&&(m=i.getMaxPrecision(C.precision),m!==C.precision&&Yt("WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Q!==void 0?Q.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 J,se,me,fe;if(Y){const St=nl[Y];J=St.vertexShader,se=St.fragmentShader}else J=C.vertexShader,se=C.fragmentShader,c.update(C),me=c.getVertexShaderID(C),fe=c.getFragmentShaderID(C);const xe=t.getRenderTarget(),Ee=t.state.buffers.depth.getReversed(),re=q.isInstancedMesh===!0,we=q.isBatchedMesh===!0,Oe=!!C.map,he=!!C.matcap,ht=!!V,$=!!C.aoMap,H=!!C.lightMap,ne=!!C.bumpMap,G=!!C.normalMap,Z=!!C.displacementMap,oe=!!C.emissiveMap,Ne=!!C.metalnessMap,Pe=!!C.roughnessMap,Se=C.anisotropy>0,B=C.clearcoat>0,L=C.dispersion>0,te=C.iridescence>0,ve=C.sheen>0,_e=C.transmission>0,be=Se&&!!C.anisotropyMap,nt=B&&!!C.clearcoatMap,Be=B&&!!C.clearcoatNormalMap,ue=B&&!!C.clearcoatRoughnessMap,Ve=te&&!!C.iridescenceMap,Ue=te&&!!C.iridescenceThicknessMap,ae=ve&&!!C.sheenColorMap,Je=ve&&!!C.sheenRoughnessMap,He=!!C.specularMap,Ke=!!C.specularColorMap,ct=!!C.specularIntensityMap,de=_e&&!!C.transmissionMap,Ye=_e&&!!C.thicknessMap,ge=!!C.gradientMap,Fe=!!C.alphaMap,Ce=C.alphaTest>0,ye=!!C.alphaHash,ce=!!C.extensions;let at=Xu;C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(at=t.toneMapping);const xt={shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:J,fragmentShader:se,defines:C.defines,customVertexShaderID:me,customFragmentShaderID:fe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:we,batchingColor:we&&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:km,alphaToCoverage:!!C.alphaToCoverage,map:Oe,matcap:he,envMap:ht,envMapMode:ht&&V.mapping,envMapCubeUVHeight:ee,aoMap:$,lightMap:H,bumpMap:ne,normalMap:G,displacementMap:g&&Z,emissiveMap:oe,normalMapObjectSpace:G&&C.normalMapType===tNe,normalMapTangentSpace:G&&C.normalMapType===WY,metalnessMap:Ne,roughnessMap:Pe,anisotropy:Se,anisotropyMap:be,clearcoat:B,clearcoatMap:nt,clearcoatNormalMap:Be,clearcoatRoughnessMap:ue,dispersion:L,iridescence:te,iridescenceMap:Ve,iridescenceThicknessMap:Ue,sheen:ve,sheenColorMap:ae,sheenRoughnessMap:Je,specularMap:He,specularColorMap:Ke,specularIntensityMap:ct,transmission:_e,transmissionMap:de,thicknessMap:Ye,gradientMap:ge,opaque:C.transparent===!1&&C.blending===im&&C.alphaToCoverage===!1,alphaMap:Fe,alphaTest:Ce,alphaHash:ye,combine:C.combine,mapUv:Oe&&y(C.map.channel),aoMapUv:$&&y(C.aoMap.channel),lightMapUv:H&&y(C.lightMap.channel),bumpMapUv:ne&&y(C.bumpMap.channel),normalMapUv:G&&y(C.normalMap.channel),displacementMapUv:Z&&y(C.displacementMap.channel),emissiveMapUv:oe&&y(C.emissiveMap.channel),metalnessMapUv:Ne&&y(C.metalnessMap.channel),roughnessMapUv:Pe&&y(C.roughnessMap.channel),anisotropyMapUv:be&&y(C.anisotropyMap.channel),clearcoatMapUv:nt&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:Be&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ue&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Ue&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Je&&y(C.sheenRoughnessMap.channel),specularMapUv:He&&y(C.specularMap.channel),specularColorMapUv:Ke&&y(C.specularColorMap.channel),specularIntensityMapUv:ct&&y(C.specularIntensityMap.channel),transmissionMapUv:de&&y(C.transmissionMap.channel),thicknessMapUv:Ye&&y(C.thicknessMap.channel),alphaMapUv:Fe&&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&&(Oe||Fe),fog:!!R,useFog:C.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ee,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:at,decodeVideoTexture:Oe&&C.map.isVideoTexture===!0&&Cn.getTransfer(C.map.colorSpace)===qn,decodeVideoTextureEmissive:oe&&C.emissiveMap.isVideoTexture===!0&&Cn.getTransfer(C.emissiveMap.colorSpace)===qn,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===rl,flipSided:C.side===Ks,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:ce&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ce&&C.extensions.multiDraw===!0||we)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return xt.vertexUv1s=u.has(1),xt.vertexUv2s=u.has(2),xt.vertexUv3s=u.has(3),u.clear(),xt}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=nl[D];F=PNe.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 cDe(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){c.remove(C)}function I(){c.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:d,dispose:I}}function pDe(){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,c){t.get(a)[o]=c}function s(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:s}}function mDe(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 CH(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 NH(){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 c(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||mDe),r.length>1&&r.sort(g||CH),i.length>1&&i.sort(g||CH)}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:c,finish:d,sort:u}}function gDe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new NH,t.set(r,[a])):i>=s.length?(a=new NH,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function xDe(){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 Qe,color:new _n};break;case"SpotLight":n={position:new Qe,direction:new Qe,color:new _n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Qe,color:new _n,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Qe,skyColor:new _n,groundColor:new _n};break;case"RectAreaLight":n={color:new _n,position:new Qe,halfWidth:new Qe,halfHeight:new Qe};break}return t[e.id]=n,n}}}function bDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new cn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let vDe=0;function yDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function _De(t){const e=new xDe,n=bDe(),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 Qe);const i=new Qe,s=new ri,a=new ri;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(yDe);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,ee=n.get(F);ee.shadowIntensity=V.intensity,ee.shadowBias=V.bias,ee.shadowNormalBias=V.normalBias,ee.shadowRadius=V.radius,ee.shadowMapSize=V.mapSize,r.directionalShadow[m]=ee,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 ee=n.get(F);ee.shadowIntensity=V.intensity,ee.shadowBias=V.bias,ee.shadowNormalBias=V.normalBias,ee.shadowRadius=V.radius,ee.shadowMapSize=V.mapSize,r.spotShadow[y]=ee,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,ee=n.get(F);ee.shadowIntensity=V.intensity,ee.shadowBias=V.bias,ee.shadowNormalBias=V.normalBias,ee.shadowRadius=V.radius,ee.shadowMapSize=V.mapSize,ee.shadowCameraNear=V.camera.near,ee.shadowCameraFar=V.camera.far,r.pointShadow[x]=ee,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=Mt.LTC_FLOAT_1,r.rectAreaLTC2=Mt.LTC_FLOAT_2):(r.rectAreaLTC1=Mt.LTC_HALF_1,r.rectAreaLTC2=Mt.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=vDe++)}function c(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:c,state:r}}function kH(t){const e=new _De(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 c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:o,setupLightsView:c,pushLight:s,pushShadow:a}}function wDe(t){let e=new WeakMap;function n(i,s=0){const a=e.get(i);let o;return a===void 0?(o=new kH(t),e.set(i,[o])):s>=a.length?(o=new kH(t),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:n,dispose:r}}const SDe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,EDe=`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 MDe(t,e,n){let r=new oj;const i=new cn,s=new cn,a=new Yr,o=new GNe({depthPacking:eNe}),c=new WNe,u={},d=n.maxTextureSize,f={[dd]:Ks,[Ks]:dd,[rl]:rl},g=new jc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new cn},radius:{value:4}},vertexShader:SDe,fragmentShader:EDe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new Ml;x.setAttribute("position",new io(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new xl(x,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=IY;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(wc),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!==ic&&this.type===ic,R=b===ic&&this.type!==ic;for(let W=0,K=k.length;W<K;W++){const V=k[W],ee=V.shadow;if(ee===void 0){Yt("WebGLShadowMap:",V,"has no shadow.");continue}if(ee.autoUpdate===!1&&ee.needsUpdate===!1)continue;i.copy(ee.mapSize);const Y=ee.getFrameExtents();if(i.multiply(Y),s.copy(ee.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Y.x),i.x=s.x*Y.x,ee.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Y.y),i.y=s.y*Y.y,ee.mapSize.y=s.y)),ee.map===null||q===!0||R===!0){const U=this.type!==ic?{minFilter:wa,magFilter:wa}:{};ee.map!==null&&ee.map.dispose(),ee.map=new ef(i.x,i.y,U),ee.map.texture.name=V.name+".shadowMap",ee.camera.updateProjectionMatrix()}t.setRenderTarget(ee.map),t.clear();const Q=ee.getViewportCount();for(let U=0;U<Q;U++){const z=ee.getViewport(U);a.set(s.x*z.x,s.y*z.y,s.x*z.z,s.y*z.w),j.viewport(a),ee.updateMatrices(V,U),r=ee.getFrustum(),A(N,I,ee.camera,V,this.type)}ee.isPointLightShadow!==!0&&this.type===ic&&E(ee,I),ee.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 ef(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?c: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===ic?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===ic)&&(!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 ee=W[K],Y=R[ee.materialIndex];if(Y&&Y.visible){const Q=S(k,Y,C,D);k.onBeforeShadow(t,k,N,I,q,Q,ee),t.renderBufferDirect(I,null,q,Q,k,ee),k.onAfterShadow(t,k,N,I,q,Q,ee)}}}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 ADe={[Ik]:Uk,[Fk]:Hk,[zk]:$k,[Tm]:Bk,[Uk]:Ik,[Hk]:Fk,[$k]:zk,[Bk]:Tm};function TDe(t,e){function n(){let de=!1;const Ye=new Yr;let ge=null;const Fe=new Yr(0,0,0,0);return{setMask:function(Ce){ge!==Ce&&!de&&(t.colorMask(Ce,Ce,Ce,Ce),ge=Ce)},setLocked:function(Ce){de=Ce},setClear:function(Ce,ye,ce,at,xt){xt===!0&&(Ce*=at,ye*=at,ce*=at),Ye.set(Ce,ye,ce,at),Fe.equals(Ye)===!1&&(t.clearColor(Ce,ye,ce,at),Fe.copy(Ye))},reset:function(){de=!1,ge=null,Fe.set(-1,0,0,0)}}}function r(){let de=!1,Ye=!1,ge=null,Fe=null,Ce=null;return{setReversed:function(ye){if(Ye!==ye){const ce=e.get("EXT_clip_control");ye?ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.ZERO_TO_ONE_EXT):ce.clipControlEXT(ce.LOWER_LEFT_EXT,ce.NEGATIVE_ONE_TO_ONE_EXT),Ye=ye;const at=Ce;Ce=null,this.setClear(at)}},getReversed:function(){return Ye},setTest:function(ye){ye?xe(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(ye){ge!==ye&&!de&&(t.depthMask(ye),ge=ye)},setFunc:function(ye){if(Ye&&(ye=ADe[ye]),Fe!==ye){switch(ye){case Ik:t.depthFunc(t.NEVER);break;case Uk:t.depthFunc(t.ALWAYS);break;case Fk:t.depthFunc(t.LESS);break;case Tm:t.depthFunc(t.LEQUAL);break;case zk:t.depthFunc(t.EQUAL);break;case Bk:t.depthFunc(t.GEQUAL);break;case Hk:t.depthFunc(t.GREATER);break;case $k:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Fe=ye}},setLocked:function(ye){de=ye},setClear:function(ye){Ce!==ye&&(Ye&&(ye=1-ye),t.clearDepth(ye),Ce=ye)},reset:function(){de=!1,ge=null,Fe=null,Ce=null,Ye=!1}}}function i(){let de=!1,Ye=null,ge=null,Fe=null,Ce=null,ye=null,ce=null,at=null,xt=null;return{setTest:function(St){de||(St?xe(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(St){Ye!==St&&!de&&(t.stencilMask(St),Ye=St)},setFunc:function(St,Qt,jt){(ge!==St||Fe!==Qt||Ce!==jt)&&(t.stencilFunc(St,Qt,jt),ge=St,Fe=Qt,Ce=jt)},setOp:function(St,Qt,jt){(ye!==St||ce!==Qt||at!==jt)&&(t.stencilOp(St,Qt,jt),ye=St,ce=Qt,at=jt)},setLocked:function(St){de=St},setClear:function(St){xt!==St&&(t.clearStencil(St),xt=St)},reset:function(){de=!1,Ye=null,ge=null,Fe=null,Ce=null,ye=null,ce=null,at=null,xt=null}}}const s=new n,a=new r,o=new i,c=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 _n(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 ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(ee)[1]),K=V>=1):ee.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),K=V>=2);let Y=null,Q={};const U=t.getParameter(t.SCISSOR_BOX),z=t.getParameter(t.VIEWPORT),J=new Yr().fromArray(U),se=new Yr().fromArray(z);function me(de,Ye,ge,Fe){const Ce=new Uint8Array(4),ye=t.createTexture();t.bindTexture(de,ye),t.texParameteri(de,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(de,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let ce=0;ce<ge;ce++)de===t.TEXTURE_3D||de===t.TEXTURE_2D_ARRAY?t.texImage3D(Ye,0,t.RGBA,1,1,Fe,0,t.RGBA,t.UNSIGNED_BYTE,Ce):t.texImage2D(Ye+ce,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ce);return ye}const fe={};fe[t.TEXTURE_2D]=me(t.TEXTURE_2D,t.TEXTURE_2D,1),fe[t.TEXTURE_CUBE_MAP]=me(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[t.TEXTURE_2D_ARRAY]=me(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),fe[t.TEXTURE_3D]=me(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(Tm),ne(!1),G(C8),xe(t.CULL_FACE),$(wc);function xe(de){d[de]!==!0&&(t.enable(de),d[de]=!0)}function Ee(de){d[de]!==!1&&(t.disable(de),d[de]=!1)}function re(de,Ye){return f[de]!==Ye?(t.bindFramebuffer(de,Ye),f[de]=Ye,de===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Ye),de===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Ye),!0):!1}function we(de,Ye){let ge=m,Fe=!1;if(de){ge=g.get(Ye),ge===void 0&&(ge=[],g.set(Ye,ge));const Ce=de.textures;if(ge.length!==Ce.length||ge[0]!==t.COLOR_ATTACHMENT0){for(let ye=0,ce=Ce.length;ye<ce;ye++)ge[ye]=t.COLOR_ATTACHMENT0+ye;ge.length=Ce.length,Fe=!0}}else ge[0]!==t.BACK&&(ge[0]=t.BACK,Fe=!0);Fe&&t.drawBuffers(ge)}function Oe(de){return x!==de?(t.useProgram(de),x=de,!0):!1}const he={[ah]:t.FUNC_ADD,[ACe]:t.FUNC_SUBTRACT,[TCe]:t.FUNC_REVERSE_SUBTRACT};he[CCe]=t.MIN,he[NCe]=t.MAX;const ht={[kCe]:t.ZERO,[PCe]:t.ONE,[RCe]:t.SRC_COLOR,[jk]:t.SRC_ALPHA,[UCe]:t.SRC_ALPHA_SATURATE,[LCe]:t.DST_COLOR,[OCe]:t.DST_ALPHA,[DCe]:t.ONE_MINUS_SRC_COLOR,[Lk]:t.ONE_MINUS_SRC_ALPHA,[ICe]:t.ONE_MINUS_DST_COLOR,[jCe]:t.ONE_MINUS_DST_ALPHA,[FCe]:t.CONSTANT_COLOR,[zCe]:t.ONE_MINUS_CONSTANT_COLOR,[BCe]:t.CONSTANT_ALPHA,[HCe]:t.ONE_MINUS_CONSTANT_ALPHA};function $(de,Ye,ge,Fe,Ce,ye,ce,at,xt,St){if(de===wc){y===!0&&(Ee(t.BLEND),y=!1);return}if(y===!1&&(xe(t.BLEND),y=!0),de!==MCe){if(de!==v||St!==C){if((b!==ah||A!==ah)&&(t.blendEquation(t.FUNC_ADD),b=ah,A=ah),St)switch(de){case im:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case N8:t.blendFunc(t.ONE,t.ONE);break;case k8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case P8:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:zr("WebGLState: Invalid blending: ",de);break}else switch(de){case im:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case N8:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case k8:zr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case P8:zr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zr("WebGLState: Invalid blending: ",de);break}E=null,S=null,T=null,k=null,N.set(0,0,0),I=0,v=de,C=St}return}Ce=Ce||Ye,ye=ye||ge,ce=ce||Fe,(Ye!==b||Ce!==A)&&(t.blendEquationSeparate(he[Ye],he[Ce]),b=Ye,A=Ce),(ge!==E||Fe!==S||ye!==T||ce!==k)&&(t.blendFuncSeparate(ht[ge],ht[Fe],ht[ye],ht[ce]),E=ge,S=Fe,T=ye,k=ce),(at.equals(N)===!1||xt!==I)&&(t.blendColor(at.r,at.g,at.b,xt),N.copy(at),I=xt),v=de,C=!1}function H(de,Ye){de.side===rl?Ee(t.CULL_FACE):xe(t.CULL_FACE);let ge=de.side===Ks;Ye&&(ge=!ge),ne(ge),de.blending===im&&de.transparent===!1?$(wc):$(de.blending,de.blendEquation,de.blendSrc,de.blendDst,de.blendEquationAlpha,de.blendSrcAlpha,de.blendDstAlpha,de.blendColor,de.blendAlpha,de.premultipliedAlpha),a.setFunc(de.depthFunc),a.setTest(de.depthTest),a.setMask(de.depthWrite),s.setMask(de.colorWrite);const Fe=de.stencilWrite;o.setTest(Fe),Fe&&(o.setMask(de.stencilWriteMask),o.setFunc(de.stencilFunc,de.stencilRef,de.stencilFuncMask),o.setOp(de.stencilFail,de.stencilZFail,de.stencilZPass)),oe(de.polygonOffset,de.polygonOffsetFactor,de.polygonOffsetUnits),de.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function ne(de){D!==de&&(de?t.frontFace(t.CW):t.frontFace(t.CCW),D=de)}function G(de){de!==wCe?(xe(t.CULL_FACE),de!==F&&(de===C8?t.cullFace(t.BACK):de===SCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),F=de}function Z(de){de!==j&&(K&&t.lineWidth(de),j=de)}function oe(de,Ye,ge){de?(xe(t.POLYGON_OFFSET_FILL),(q!==Ye||R!==ge)&&(t.polygonOffset(Ye,ge),q=Ye,R=ge)):Ee(t.POLYGON_OFFSET_FILL)}function Ne(de){de?xe(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function Pe(de){de===void 0&&(de=t.TEXTURE0+W-1),Y!==de&&(t.activeTexture(de),Y=de)}function Se(de,Ye,ge){ge===void 0&&(Y===null?ge=t.TEXTURE0+W-1:ge=Y);let Fe=Q[ge];Fe===void 0&&(Fe={type:void 0,texture:void 0},Q[ge]=Fe),(Fe.type!==de||Fe.texture!==Ye)&&(Y!==ge&&(t.activeTexture(ge),Y=ge),t.bindTexture(de,Ye||fe[de]),Fe.type=de,Fe.texture=Ye)}function B(){const de=Q[Y];de!==void 0&&de.type!==void 0&&(t.bindTexture(de.type,null),de.type=void 0,de.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function te(){try{t.compressedTexImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ve(){try{t.texSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function _e(){try{t.texSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function be(){try{t.compressedTexSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function nt(){try{t.compressedTexSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Be(){try{t.texStorage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ue(){try{t.texStorage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Ve(){try{t.texImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Ue(){try{t.texImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function ae(de){J.equals(de)===!1&&(t.scissor(de.x,de.y,de.z,de.w),J.copy(de))}function Je(de){se.equals(de)===!1&&(t.viewport(de.x,de.y,de.z,de.w),se.copy(de))}function He(de,Ye){let ge=u.get(Ye);ge===void 0&&(ge=new WeakMap,u.set(Ye,ge));let Fe=ge.get(de);Fe===void 0&&(Fe=t.getUniformBlockIndex(Ye,de.name),ge.set(de,Fe))}function Ke(de,Ye){const Fe=u.get(Ye).get(de);c.get(Ye)!==Fe&&(t.uniformBlockBinding(Ye,Fe,de.__bindingPointIndex),c.set(Ye,Fe))}function ct(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),a.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Y=null,Q={},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 _n(0,0,0),I=0,C=!1,D=null,F=null,j=null,q=null,R=null,J.set(0,0,t.canvas.width,t.canvas.height),se.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:Ee,bindFramebuffer:re,drawBuffers:we,useProgram:Oe,setBlending:$,setMaterial:H,setFlipSided:ne,setCullFace:G,setLineWidth:Z,setPolygonOffset:oe,setScissorTest:Ne,activeTexture:Pe,bindTexture:Se,unbindTexture:B,compressedTexImage2D:L,compressedTexImage3D:te,texImage2D:Ve,texImage3D:Ue,updateUBOMapping:He,uniformBlockBinding:Ke,texStorage2D:Be,texStorage3D:ue,texSubImage2D:ve,texSubImage3D:_e,compressedTexSubImage2D:be,compressedTexSubImage3D:nt,scissor:ae,viewport:Je,reset:ct}}function CDe(t,e,n,r,i,s,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new cn,d=new WeakMap;let f;const g=new WeakMap;let 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):kw("canvas")}function y(B,L,te){let ve=1;const _e=Se(B);if((_e.width>te||_e.height>te)&&(ve=te/Math.max(_e.width,_e.height)),ve<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 be=Math.floor(ve*_e.width),nt=Math.floor(ve*_e.height);f===void 0&&(f=x(be,nt));const Be=L?x(be,nt):f;return Be.width=be,Be.height=nt,Be.getContext("2d").drawImage(B,0,0,be,nt),Yt("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+be+"x"+nt+")."),Be}else return"data"in B&&Yt("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.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,te,ve,_e=!1){if(B!==null){if(t[B]!==void 0)return t[B];Yt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let be=L;if(L===t.RED&&(te===t.FLOAT&&(be=t.R32F),te===t.HALF_FLOAT&&(be=t.R16F),te===t.UNSIGNED_BYTE&&(be=t.R8)),L===t.RED_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.R8UI),te===t.UNSIGNED_SHORT&&(be=t.R16UI),te===t.UNSIGNED_INT&&(be=t.R32UI),te===t.BYTE&&(be=t.R8I),te===t.SHORT&&(be=t.R16I),te===t.INT&&(be=t.R32I)),L===t.RG&&(te===t.FLOAT&&(be=t.RG32F),te===t.HALF_FLOAT&&(be=t.RG16F),te===t.UNSIGNED_BYTE&&(be=t.RG8)),L===t.RG_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.RG8UI),te===t.UNSIGNED_SHORT&&(be=t.RG16UI),te===t.UNSIGNED_INT&&(be=t.RG32UI),te===t.BYTE&&(be=t.RG8I),te===t.SHORT&&(be=t.RG16I),te===t.INT&&(be=t.RG32I)),L===t.RGB_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.RGB8UI),te===t.UNSIGNED_SHORT&&(be=t.RGB16UI),te===t.UNSIGNED_INT&&(be=t.RGB32UI),te===t.BYTE&&(be=t.RGB8I),te===t.SHORT&&(be=t.RGB16I),te===t.INT&&(be=t.RGB32I)),L===t.RGBA_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.RGBA8UI),te===t.UNSIGNED_SHORT&&(be=t.RGBA16UI),te===t.UNSIGNED_INT&&(be=t.RGBA32UI),te===t.BYTE&&(be=t.RGBA8I),te===t.SHORT&&(be=t.RGBA16I),te===t.INT&&(be=t.RGBA32I)),L===t.RGB&&(te===t.UNSIGNED_INT_5_9_9_9_REV&&(be=t.RGB9_E5),te===t.UNSIGNED_INT_10F_11F_11F_REV&&(be=t.R11F_G11F_B10F)),L===t.RGBA){const nt=_e?Cw:Cn.getTransfer(ve);te===t.FLOAT&&(be=t.RGBA32F),te===t.HALF_FLOAT&&(be=t.RGBA16F),te===t.UNSIGNED_BYTE&&(be=nt===qn?t.SRGB8_ALPHA8:t.RGBA8),te===t.UNSIGNED_SHORT_4_4_4_4&&(be=t.RGBA4),te===t.UNSIGNED_SHORT_5_5_5_1&&(be=t.RGB5_A1)}return(be===t.R16F||be===t.R32F||be===t.RG16F||be===t.RG32F||be===t.RGBA16F||be===t.RGBA32F)&&e.get("EXT_color_buffer_float"),be}function A(B,L){let te;return B?L===null||L===Qh||L===V0?te=t.DEPTH24_STENCIL8:L===gc?te=t.DEPTH32F_STENCIL8:L===$0&&(te=t.DEPTH24_STENCIL8,Yt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===Qh||L===V0?te=t.DEPTH_COMPONENT24:L===gc?te=t.DEPTH_COMPONENT32F:L===$0&&(te=t.DEPTH_COMPONENT16),te}function T(B,L){return v(B)===!0||B.isFramebufferTexture&&B.minFilter!==wa&&B.minFilter!==ro?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 te=B.source,ve=g.get(te);if(ve){const _e=ve[L.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&C(B),Object.keys(ve).length===0&&g.delete(te)}r.remove(B)}function C(B){const L=r.get(B);t.deleteTexture(L.__webglTexture);const te=B.source,ve=g.get(te);delete ve[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 ve=0;ve<6;ve++){if(Array.isArray(L.__webglFramebuffer[ve]))for(let _e=0;_e<L.__webglFramebuffer[ve].length;_e++)t.deleteFramebuffer(L.__webglFramebuffer[ve][_e]);else t.deleteFramebuffer(L.__webglFramebuffer[ve]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ve])}else{if(Array.isArray(L.__webglFramebuffer))for(let ve=0;ve<L.__webglFramebuffer.length;ve++)t.deleteFramebuffer(L.__webglFramebuffer[ve]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ve=0;ve<L.__webglColorRenderbuffer.length;ve++)L.__webglColorRenderbuffer[ve]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ve]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const te=B.textures;for(let ve=0,_e=te.length;ve<_e;ve++){const be=r.get(te[ve]);be.__webglTexture&&(t.deleteTexture(be.__webglTexture),a.memory.textures--),r.remove(te[ve])}r.remove(B)}let F=0;function j(){F=0}function q(){const B=F;return B>=i.maxTextures&&Yt("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 te=r.get(B);if(B.isVideoTexture&&Ne(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&te.__version!==B.version){const ve=B.image;if(ve===null)Yt("WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)Yt("WebGLRenderer: Texture marked for update but image is incomplete");else{fe(te,B,L);return}}else B.isExternalTexture&&(te.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,te.__webglTexture,t.TEXTURE0+L)}function K(B,L){const te=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&te.__version!==B.version){fe(te,B,L);return}else B.isExternalTexture&&(te.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,te.__webglTexture,t.TEXTURE0+L)}function V(B,L){const te=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&te.__version!==B.version){fe(te,B,L);return}n.bindTexture(t.TEXTURE_3D,te.__webglTexture,t.TEXTURE0+L)}function ee(B,L){const te=r.get(B);if(B.version>0&&te.__version!==B.version){xe(te,B,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture,t.TEXTURE0+L)}const Y={[Wk]:t.REPEAT,[mc]:t.CLAMP_TO_EDGE,[qk]:t.MIRRORED_REPEAT},Q={[wa]:t.NEAREST,[QCe]:t.NEAREST_MIPMAP_NEAREST,[jy]:t.NEAREST_MIPMAP_LINEAR,[ro]:t.LINEAR,[fC]:t.LINEAR_MIPMAP_NEAREST,[gh]:t.LINEAR_MIPMAP_LINEAR},U={[nNe]:t.NEVER,[lNe]:t.ALWAYS,[rNe]:t.LESS,[qY]:t.LEQUAL,[iNe]:t.EQUAL,[oNe]:t.GEQUAL,[sNe]:t.GREATER,[aNe]:t.NOTEQUAL};function z(B,L){if(L.type===gc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===ro||L.magFilter===fC||L.magFilter===jy||L.magFilter===gh||L.minFilter===ro||L.minFilter===fC||L.minFilter===jy||L.minFilter===gh)&&Yt("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,Q[L.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,Q[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===wa||L.minFilter!==jy&&L.minFilter!==gh||L.type===gc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const te=e.get("EXT_texture_filter_anisotropic");t.texParameterf(B,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function J(B,L){let te=!1;B.__webglInit===void 0&&(B.__webglInit=!0,L.addEventListener("dispose",k));const ve=L.source;let _e=g.get(ve);_e===void 0&&(_e={},g.set(ve,_e));const be=R(L);if(be!==B.__cacheKey){_e[be]===void 0&&(_e[be]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,te=!0),_e[be].usedTimes++;const nt=_e[B.__cacheKey];nt!==void 0&&(_e[B.__cacheKey].usedTimes--,nt.usedTimes===0&&C(L)),B.__cacheKey=be,B.__webglTexture=_e[be].texture}return te}function se(B,L,te){return Math.floor(Math.floor(B/te)/L)}function me(B,L,te,ve){const be=B.updateRanges;if(be.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,te,ve,L.data);else{be.sort((Ue,ae)=>Ue.start-ae.start);let nt=0;for(let Ue=1;Ue<be.length;Ue++){const ae=be[nt],Je=be[Ue],He=ae.start+ae.count,Ke=se(Je.start,L.width,4),ct=se(ae.start,L.width,4);Je.start<=He+1&&Ke===ct&&se(Je.start+Je.count-1,L.width,4)===Ke?ae.count=Math.max(ae.count,Je.start+Je.count-ae.start):(++nt,be[nt]=Je)}be.length=nt+1;const Be=t.getParameter(t.UNPACK_ROW_LENGTH),ue=t.getParameter(t.UNPACK_SKIP_PIXELS),Ve=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Ue=0,ae=be.length;Ue<ae;Ue++){const Je=be[Ue],He=Math.floor(Je.start/4),Ke=Math.ceil(Je.count/4),ct=He%L.width,de=Math.floor(He/L.width),Ye=Ke,ge=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ct),t.pixelStorei(t.UNPACK_SKIP_ROWS,de),n.texSubImage2D(t.TEXTURE_2D,0,ct,de,Ye,ge,te,ve,L.data)}B.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Be),t.pixelStorei(t.UNPACK_SKIP_PIXELS,ue),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ve)}}function fe(B,L,te){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const _e=J(B,L),be=L.source;n.bindTexture(ve,B.__webglTexture,t.TEXTURE0+te);const nt=r.get(be);if(be.version!==nt.__version||_e===!0){n.activeTexture(t.TEXTURE0+te);const Be=Cn.getPrimaries(Cn.workingColorSpace),ue=L.colorSpace===Lu?null:Cn.getPrimaries(L.colorSpace),Ve=L.colorSpace===Lu||Be===ue?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,Ve);let Ue=y(L.image,!1,i.maxTextureSize);Ue=Pe(L,Ue);const ae=s.convert(L.format,L.colorSpace),Je=s.convert(L.type);let He=S(L.internalFormat,ae,Je,L.colorSpace,L.isVideoTexture);z(ve,L);let Ke;const ct=L.mipmaps,de=L.isVideoTexture!==!0,Ye=nt.__version===void 0||_e===!0,ge=be.dataReady,Fe=T(L,Ue);if(L.isDepthTexture)He=A(L.format===W0,L.type),Ye&&(de?n.texStorage2D(t.TEXTURE_2D,1,He,Ue.width,Ue.height):n.texImage2D(t.TEXTURE_2D,0,He,Ue.width,Ue.height,0,ae,Je,null));else if(L.isDataTexture)if(ct.length>0){de&&Ye&&n.texStorage2D(t.TEXTURE_2D,Fe,He,ct[0].width,ct[0].height);for(let Ce=0,ye=ct.length;Ce<ye;Ce++)Ke=ct[Ce],de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,ae,Je,Ke.data):n.texImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,ae,Je,Ke.data);L.generateMipmaps=!1}else de?(Ye&&n.texStorage2D(t.TEXTURE_2D,Fe,He,Ue.width,Ue.height),ge&&me(L,Ue,ae,Je)):n.texImage2D(t.TEXTURE_2D,0,He,Ue.width,Ue.height,0,ae,Je,Ue.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){de&&Ye&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Fe,He,ct[0].width,ct[0].height,Ue.depth);for(let Ce=0,ye=ct.length;Ce<ye;Ce++)if(Ke=ct[Ce],L.format!==Do)if(ae!==null)if(de){if(ge)if(L.layerUpdates.size>0){const ce=oH(Ke.width,Ke.height,L.format,L.type);for(const at of L.layerUpdates){const xt=Ke.data.subarray(at*ce/Ke.data.BYTES_PER_ELEMENT,(at+1)*ce/Ke.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,at,Ke.width,Ke.height,1,ae,xt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ke.width,Ke.height,Ue.depth,ae,Ke.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ce,He,Ke.width,Ke.height,Ue.depth,0,Ke.data,0,0);else Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else de?ge&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ce,0,0,0,Ke.width,Ke.height,Ue.depth,ae,Je,Ke.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ce,He,Ke.width,Ke.height,Ue.depth,0,ae,Je,Ke.data)}else{de&&Ye&&n.texStorage2D(t.TEXTURE_2D,Fe,He,ct[0].width,ct[0].height);for(let Ce=0,ye=ct.length;Ce<ye;Ce++)Ke=ct[Ce],L.format!==Do?ae!==null?de?ge&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,ae,Ke.data):n.compressedTexImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,Ke.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,Ke.width,Ke.height,ae,Je,Ke.data):n.texImage2D(t.TEXTURE_2D,Ce,He,Ke.width,Ke.height,0,ae,Je,Ke.data)}else if(L.isDataArrayTexture)if(de){if(Ye&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Fe,He,Ue.width,Ue.height,Ue.depth),ge)if(L.layerUpdates.size>0){const Ce=oH(Ue.width,Ue.height,L.format,L.type);for(const ye of L.layerUpdates){const ce=Ue.data.subarray(ye*Ce/Ue.data.BYTES_PER_ELEMENT,(ye+1)*Ce/Ue.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ye,Ue.width,Ue.height,1,ae,Je,ce)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ue.width,Ue.height,Ue.depth,ae,Je,Ue.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,He,Ue.width,Ue.height,Ue.depth,0,ae,Je,Ue.data);else if(L.isData3DTexture)de?(Ye&&n.texStorage3D(t.TEXTURE_3D,Fe,He,Ue.width,Ue.height,Ue.depth),ge&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ue.width,Ue.height,Ue.depth,ae,Je,Ue.data)):n.texImage3D(t.TEXTURE_3D,0,He,Ue.width,Ue.height,Ue.depth,0,ae,Je,Ue.data);else if(L.isFramebufferTexture){if(Ye)if(de)n.texStorage2D(t.TEXTURE_2D,Fe,He,Ue.width,Ue.height);else{let Ce=Ue.width,ye=Ue.height;for(let ce=0;ce<Fe;ce++)n.texImage2D(t.TEXTURE_2D,ce,He,Ce,ye,0,ae,Je,null),Ce>>=1,ye>>=1}}else if(ct.length>0){if(de&&Ye){const Ce=Se(ct[0]);n.texStorage2D(t.TEXTURE_2D,Fe,He,Ce.width,Ce.height)}for(let Ce=0,ye=ct.length;Ce<ye;Ce++)Ke=ct[Ce],de?ge&&n.texSubImage2D(t.TEXTURE_2D,Ce,0,0,ae,Je,Ke):n.texImage2D(t.TEXTURE_2D,Ce,He,ae,Je,Ke);L.generateMipmaps=!1}else if(de){if(Ye){const Ce=Se(Ue);n.texStorage2D(t.TEXTURE_2D,Fe,He,Ce.width,Ce.height)}ge&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae,Je,Ue)}else n.texImage2D(t.TEXTURE_2D,0,He,ae,Je,Ue);v(L)&&b(ve),nt.__version=be.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function xe(B,L,te){if(L.image.length!==6)return;const ve=J(B,L),_e=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+te);const be=r.get(_e);if(_e.version!==be.__version||ve===!0){n.activeTexture(t.TEXTURE0+te);const nt=Cn.getPrimaries(Cn.workingColorSpace),Be=L.colorSpace===Lu?null:Cn.getPrimaries(L.colorSpace),ue=L.colorSpace===Lu||nt===Be?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,ue);const Ve=L.isCompressedTexture||L.image[0].isCompressedTexture,Ue=L.image[0]&&L.image[0].isDataTexture,ae=[];for(let ye=0;ye<6;ye++)!Ve&&!Ue?ae[ye]=y(L.image[ye],!0,i.maxCubemapSize):ae[ye]=Ue?L.image[ye].image:L.image[ye],ae[ye]=Pe(L,ae[ye]);const Je=ae[0],He=s.convert(L.format,L.colorSpace),Ke=s.convert(L.type),ct=S(L.internalFormat,He,Ke,L.colorSpace),de=L.isVideoTexture!==!0,Ye=be.__version===void 0||ve===!0,ge=_e.dataReady;let Fe=T(L,Je);z(t.TEXTURE_CUBE_MAP,L);let Ce;if(Ve){de&&Ye&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,ct,Je.width,Je.height);for(let ye=0;ye<6;ye++){Ce=ae[ye].mipmaps;for(let ce=0;ce<Ce.length;ce++){const at=Ce[ce];L.format!==Do?He!==null?de?ge&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,0,0,at.width,at.height,He,at.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,ct,at.width,at.height,0,at.data):Yt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,0,0,at.width,at.height,He,Ke,at.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,ct,at.width,at.height,0,He,Ke,at.data)}}}else{if(Ce=L.mipmaps,de&&Ye){Ce.length>0&&Fe++;const ye=Se(ae[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,ct,ye.width,ye.height)}for(let ye=0;ye<6;ye++)if(Ue){de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,ae[ye].width,ae[ye].height,He,Ke,ae[ye].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,ct,ae[ye].width,ae[ye].height,0,He,Ke,ae[ye].data);for(let ce=0;ce<Ce.length;ce++){const xt=Ce[ce].image[ye].image;de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,0,0,xt.width,xt.height,He,Ke,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,ct,xt.width,xt.height,0,He,Ke,xt.data)}}else{de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,He,Ke,ae[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,ct,He,Ke,ae[ye]);for(let ce=0;ce<Ce.length;ce++){const at=Ce[ce];de?ge&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,0,0,He,Ke,at.image[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,ct,He,Ke,at.image[ye])}}}v(L)&&b(t.TEXTURE_CUBE_MAP),be.__version=_e.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function Ee(B,L,te,ve,_e,be){const nt=s.convert(te.format,te.colorSpace),Be=s.convert(te.type),ue=S(te.internalFormat,nt,Be,te.colorSpace),Ve=r.get(L),Ue=r.get(te);if(Ue.__renderTarget=L,!Ve.__hasExternalTextures){const ae=Math.max(1,L.width>>be),Je=Math.max(1,L.height>>be);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,be,ue,ae,Je,L.depth,0,nt,Be,null):n.texImage2D(_e,be,ue,ae,Je,0,nt,Be,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),oe(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,_e,Ue.__webglTexture,0,Z(L)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,_e,Ue.__webglTexture,be),n.bindFramebuffer(t.FRAMEBUFFER,null)}function re(B,L,te){if(t.bindRenderbuffer(t.RENDERBUFFER,B),L.depthBuffer){const ve=L.depthTexture,_e=ve&&ve.isDepthTexture?ve.type:null,be=A(L.stencilBuffer,_e),nt=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Be=Z(L);oe(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Be,be,L.width,L.height):te?t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,be,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,be,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,nt,t.RENDERBUFFER,B)}else{const ve=L.textures;for(let _e=0;_e<ve.length;_e++){const be=ve[_e],nt=s.convert(be.format,be.colorSpace),Be=s.convert(be.type),ue=S(be.internalFormat,nt,Be,be.colorSpace),Ve=Z(L);te&&oe(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,ue,L.width,L.height):oe(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,ue,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ue,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function we(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 ve=r.get(L.depthTexture);ve.__renderTarget=L,(!ve.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),W(L.depthTexture,0);const _e=ve.__webglTexture,be=Z(L);if(L.depthTexture.format===G0)oe(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0,be):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0);else if(L.depthTexture.format===W0)oe(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0,be):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0);else throw new Error("Unknown depthTexture format")}function Oe(B){const L=r.get(B),te=B.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==B.depthTexture){const ve=B.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ve){const _e=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ve.removeEventListener("dispose",_e)};ve.addEventListener("dispose",_e),L.__depthDisposeCallback=_e}L.__boundDepthTexture=ve}if(B.depthTexture&&!L.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");const ve=B.texture.mipmaps;ve&&ve.length>0?we(L.__webglFramebuffer[0],B):we(L.__webglFramebuffer,B)}else if(te){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]===void 0)L.__webglDepthbuffer[ve]=t.createRenderbuffer(),re(L.__webglDepthbuffer[ve],B,!1);else{const _e=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,be=L.__webglDepthbuffer[ve];t.bindRenderbuffer(t.RENDERBUFFER,be),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,be)}}else{const ve=B.texture.mipmaps;if(ve&&ve.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),re(L.__webglDepthbuffer,B,!1);else{const _e=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,be=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,be),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,be)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(B,L,te){const ve=r.get(B);L!==void 0&&Ee(ve.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),te!==void 0&&Oe(B)}function ht(B){const L=B.texture,te=r.get(B),ve=r.get(L);B.addEventListener("dispose",N);const _e=B.textures,be=B.isWebGLCubeRenderTarget===!0,nt=_e.length>1;if(nt||(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,a.memory.textures++),be){te.__webglFramebuffer=[];for(let Be=0;Be<6;Be++)if(L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer[Be]=[];for(let ue=0;ue<L.mipmaps.length;ue++)te.__webglFramebuffer[Be][ue]=t.createFramebuffer()}else te.__webglFramebuffer[Be]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer=[];for(let Be=0;Be<L.mipmaps.length;Be++)te.__webglFramebuffer[Be]=t.createFramebuffer()}else te.__webglFramebuffer=t.createFramebuffer();if(nt)for(let Be=0,ue=_e.length;Be<ue;Be++){const Ve=r.get(_e[Be]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),a.memory.textures++)}if(B.samples>0&&oe(B)===!1){te.__webglMultisampledFramebuffer=t.createFramebuffer(),te.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let Be=0;Be<_e.length;Be++){const ue=_e[Be];te.__webglColorRenderbuffer[Be]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,te.__webglColorRenderbuffer[Be]);const Ve=s.convert(ue.format,ue.colorSpace),Ue=s.convert(ue.type),ae=S(ue.internalFormat,Ve,Ue,ue.colorSpace,B.isXRRenderTarget===!0),Je=Z(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,Je,ae,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Be,t.RENDERBUFFER,te.__webglColorRenderbuffer[Be])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(te.__webglDepthRenderbuffer=t.createRenderbuffer(),re(te.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(be){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),z(t.TEXTURE_CUBE_MAP,L);for(let Be=0;Be<6;Be++)if(L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Ee(te.__webglFramebuffer[Be][ue],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,ue);else Ee(te.__webglFramebuffer[Be],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0);v(L)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(nt){for(let Be=0,ue=_e.length;Be<ue;Be++){const Ve=_e[Be],Ue=r.get(Ve);let ae=t.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(ae=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ae,Ue.__webglTexture),z(ae,Ve),Ee(te.__webglFramebuffer,B,Ve,t.COLOR_ATTACHMENT0+Be,ae,0),v(Ve)&&b(ae)}n.unbindTexture()}else{let Be=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(Be=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Be,ve.__webglTexture),z(Be,L),L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Ee(te.__webglFramebuffer[ue],B,L,t.COLOR_ATTACHMENT0,Be,ue);else Ee(te.__webglFramebuffer,B,L,t.COLOR_ATTACHMENT0,Be,0);v(L)&&b(Be),n.unbindTexture()}B.depthBuffer&&Oe(B)}function $(B){const L=B.textures;for(let te=0,ve=L.length;te<ve;te++){const _e=L[te];if(v(_e)){const be=E(B),nt=r.get(_e).__webglTexture;n.bindTexture(be,nt),b(be),n.unbindTexture()}}}const H=[],ne=[];function G(B){if(B.samples>0){if(oe(B)===!1){const L=B.textures,te=B.width,ve=B.height;let _e=t.COLOR_BUFFER_BIT;const be=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,nt=r.get(B),Be=L.length>1;if(Be)for(let Ve=0;Ve<L.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,nt.__webglMultisampledFramebuffer);const ue=B.texture.mipmaps;ue&&ue.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglFramebuffer);for(let Ve=0;Ve<L.length;Ve++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Be){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,nt.__webglColorRenderbuffer[Ve]);const Ue=r.get(L[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ue,0)}t.blitFramebuffer(0,0,te,ve,0,0,te,ve,_e,t.NEAREST),c===!0&&(H.length=0,ne.length=0,H.push(t.COLOR_ATTACHMENT0+Ve),B.depthBuffer&&B.resolveDepthBuffer===!1&&(H.push(be),ne.push(be),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ne)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Be)for(let Ve=0;Ve<L.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,nt.__webglColorRenderbuffer[Ve]);const Ue=r.get(L[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,nt.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,Ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,nt.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&c){const L=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function Z(B){return Math.min(i.maxSamples,B.samples)}function oe(B){const L=r.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ne(B){const L=a.render.frame;d.get(B)!==L&&(d.set(B,L),B.update())}function Pe(B,L){const te=B.colorSpace,ve=B.format,_e=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||te!==km&&te!==Lu&&(Cn.getTransfer(te)===qn?(ve!==Do||_e!==gl)&&Yt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zr("WebGLTextures: Unsupported texture color space:",te)),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=ee,this.rebindTextures=he,this.setupRenderTarget=ht,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=G,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=oe}function NDe(t,e){function n(r,i=Lu){let s;const a=Cn.getTransfer(i);if(r===gl)return t.UNSIGNED_BYTE;if(r===ZO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===QO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===BY)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===HY)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===FY)return t.BYTE;if(r===zY)return t.SHORT;if(r===$0)return t.UNSIGNED_SHORT;if(r===YO)return t.INT;if(r===Qh)return t.UNSIGNED_INT;if(r===gc)return t.FLOAT;if(r===og)return t.HALF_FLOAT;if(r===$Y)return t.ALPHA;if(r===VY)return t.RGB;if(r===Do)return t.RGBA;if(r===G0)return t.DEPTH_COMPONENT;if(r===W0)return t.DEPTH_STENCIL;if(r===GY)return t.RED;if(r===JO)return t.RED_INTEGER;if(r===ej)return t.RG;if(r===tj)return t.RG_INTEGER;if(r===nj)return t.RGBA_INTEGER;if(r===a1||r===o1||r===l1||r===c1)if(a===qn)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===a1)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===o1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===l1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===c1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===a1)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===o1)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===l1)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===c1)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Kk||r===Xk||r===Yk||r===Zk)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===Kk)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Xk)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Yk)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Zk)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Qk||r===Jk||r===eP)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===Qk||r===Jk)return a===qn?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===eP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===tP||r===nP||r===rP||r===iP||r===sP||r===aP||r===oP||r===lP||r===cP||r===uP||r===dP||r===hP||r===fP||r===pP)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===tP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===nP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===rP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===iP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===sP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===aP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===oP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===lP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===cP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===uP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===dP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===hP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===fP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===pP)return a===qn?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===mP||r===gP||r===xP)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===mP)return a===qn?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===gP)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===xP)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===bP||r===vP||r===yP||r===_P)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===bP)return s.COMPRESSED_RED_RGTC1_EXT;if(r===vP)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===yP)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===_P)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===V0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const kDe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,PDe=`
- 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 RDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new hZ(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 jc({vertexShader:kDe,fragmentShader:PDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new xl(new lj(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let DDe=class extends mf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",c=1,u=null,d=null,f=null,g=null,m=null,x=null;const y=typeof XRWebGLBinding<"u",v=new RDe,b={},E=n.getContextAttributes();let S=null,A=null;const T=[],k=[],N=new cn;let I=null;const C=new Ya;C.viewport=new Yr;const D=new Ya;D.viewport=new Yr;const F=[C,D],j=new YNe;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(fe){let xe=T[fe];return xe===void 0&&(xe=new jC,T[fe]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(fe){let xe=T[fe];return xe===void 0&&(xe=new jC,T[fe]=xe),xe.getGripSpace()},this.getHand=function(fe){let xe=T[fe];return xe===void 0&&(xe=new jC,T[fe]=xe),xe.getHandSpace()};function W(fe){const xe=k.indexOf(fe.inputSource);if(xe===-1)return;const Ee=T[xe];Ee!==void 0&&(Ee.update(fe.inputSource,fe.frame,u||a),Ee.dispatchEvent({type:fe.type,data:fe.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 fe=0;fe<T.length;fe++){const xe=k[fe];xe!==null&&(k[fe]=null,T[fe].disconnect(xe))}q=null,R=null,v.reset();for(const fe in b)delete b[fe];e.setRenderTarget(S),m=null,g=null,f=null,i=null,A=null,me.stop(),r.isPresenting=!1,e.setPixelRatio(I),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(fe){s=fe,r.isPresenting===!0&&Yt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(fe){o=fe,r.isPresenting===!0&&Yt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(fe){u=fe},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(fe){if(i=fe,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 Ee=null,re=null,we=null;E.depth&&(we=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ee=E.stencil?W0:G0,re=E.stencil?V0:Qh);const Oe={colorFormat:n.RGBA8,depthFormat:we,scaleFactor:s};f=this.getBinding(),g=f.createProjectionLayer(Oe),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new ef(g.textureWidth,g.textureHeight,{format:Do,type:gl,depthTexture:new dZ(g.textureWidth,g.textureHeight,re,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Ee={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,Ee),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),A=new ef(m.framebufferWidth,m.framebufferHeight,{format:Do,type:gl,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,a=await i.requestReferenceSpace(o),me.setContext(i),me.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(fe){for(let xe=0;xe<fe.removed.length;xe++){const Ee=fe.removed[xe],re=k.indexOf(Ee);re>=0&&(k[re]=null,T[re].disconnect(Ee))}for(let xe=0;xe<fe.added.length;xe++){const Ee=fe.added[xe];let re=k.indexOf(Ee);if(re===-1){for(let Oe=0;Oe<T.length;Oe++)if(Oe>=k.length){k.push(Ee),re=Oe;break}else if(k[Oe]===null){k[Oe]=Ee,re=Oe;break}if(re===-1)break}const we=T[re];we&&we.connect(Ee)}}const ee=new Qe,Y=new Qe;function Q(fe,xe,Ee){ee.setFromMatrixPosition(xe.matrixWorld),Y.setFromMatrixPosition(Ee.matrixWorld);const re=ee.distanceTo(Y),we=xe.projectionMatrix.elements,Oe=Ee.projectionMatrix.elements,he=we[14]/(we[10]-1),ht=we[14]/(we[10]+1),$=(we[9]+1)/we[5],H=(we[9]-1)/we[5],ne=(we[8]-1)/we[0],G=(Oe[8]+1)/Oe[0],Z=he*ne,oe=he*G,Ne=re/(-ne+G),Pe=Ne*-ne;if(xe.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),fe.translateX(Pe),fe.translateZ(Ne),fe.matrixWorld.compose(fe.position,fe.quaternion,fe.scale),fe.matrixWorldInverse.copy(fe.matrixWorld).invert(),we[10]===-1)fe.projectionMatrix.copy(xe.projectionMatrix),fe.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const Se=he+Ne,B=ht+Ne,L=Z-Pe,te=oe+(re-Pe),ve=$*ht/B*Se,_e=H*ht/B*Se;fe.projectionMatrix.makePerspective(L,te,ve,_e,Se,B),fe.projectionMatrixInverse.copy(fe.projectionMatrix).invert()}}function U(fe,xe){xe===null?fe.matrixWorld.copy(fe.matrix):fe.matrixWorld.multiplyMatrices(xe.matrixWorld,fe.matrix),fe.matrixWorldInverse.copy(fe.matrixWorld).invert()}this.updateCamera=function(fe){if(i===null)return;let xe=fe.near,Ee=fe.far;v.texture!==null&&(v.depthNear>0&&(xe=v.depthNear),v.depthFar>0&&(Ee=v.depthFar)),j.near=D.near=C.near=xe,j.far=D.far=C.far=Ee,(q!==j.near||R!==j.far)&&(i.updateRenderState({depthNear:j.near,depthFar:j.far}),q=j.near,R=j.far),j.layers.mask=fe.layers.mask|6,C.layers.mask=j.layers.mask&3,D.layers.mask=j.layers.mask&5;const re=fe.parent,we=j.cameras;U(j,re);for(let Oe=0;Oe<we.length;Oe++)U(we[Oe],re);we.length===2?Q(j,C,D):j.projectionMatrix.copy(C.projectionMatrix),z(fe,j,re)};function z(fe,xe,Ee){Ee===null?fe.matrix.copy(xe.matrixWorld):(fe.matrix.copy(Ee.matrixWorld),fe.matrix.invert(),fe.matrix.multiply(xe.matrixWorld)),fe.matrix.decompose(fe.position,fe.quaternion,fe.scale),fe.updateMatrixWorld(!0),fe.projectionMatrix.copy(xe.projectionMatrix),fe.projectionMatrixInverse.copy(xe.projectionMatrixInverse),fe.isPerspectiveCamera&&(fe.fov=wP*2*Math.atan(1/fe.projectionMatrix.elements[5]),fe.zoom=1)}this.getCamera=function(){return j},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(fe){c=fe,g!==null&&(g.fixedFoveation=fe),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=fe)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(j)},this.getCameraTexture=function(fe){return b[fe]};let J=null;function se(fe,xe){if(d=xe.getViewerPose(u||a),x=xe,d!==null){const Ee=d.views;m!==null&&(e.setRenderTargetFramebuffer(A,m.framebuffer),e.setRenderTarget(A));let re=!1;Ee.length!==j.cameras.length&&(j.cameras.length=0,re=!0);for(let ht=0;ht<Ee.length;ht++){const $=Ee[ht];let H=null;if(m!==null)H=m.getViewport($);else{const G=f.getViewSubImage(g,$);H=G.viewport,ht===0&&(e.setRenderTargetTextures(A,G.colorTexture,G.depthStencilTexture),e.setRenderTarget(A))}let ne=F[ht];ne===void 0&&(ne=new Ya,ne.layers.enable(ht),ne.viewport=new Yr,F[ht]=ne),ne.matrix.fromArray($.transform.matrix),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.projectionMatrix.fromArray($.projectionMatrix),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert(),ne.viewport.set(H.x,H.y,H.width,H.height),ht===0&&(j.matrix.copy(ne.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale)),re===!0&&j.cameras.push(ne)}const we=i.enabledFeatures;if(we&&we.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const ht=f.getDepthInformation(Ee[0]);ht&&ht.isValid&&ht.texture&&v.init(ht,i.renderState)}if(we&&we.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let ht=0;ht<Ee.length;ht++){const $=Ee[ht].camera;if($){let H=b[$];H||(H=new hZ,b[$]=H);const ne=f.getCameraImage($);H.sourceTexture=ne}}}}for(let Ee=0;Ee<T.length;Ee++){const re=k[Ee],we=T[Ee];re!==null&&we!==void 0&&we.update(re,xe,u||a)}J&&J(fe,xe),xe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:xe}),x=null}const me=new gZ;me.setAnimationLoop(se),this.setAnimationLoop=function(fe){J=fe},this.dispose=function(){}}};const qd=new hd,ODe=new ri;function jDe(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,oZ(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?c(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===Ks&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===Ks&&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,qd.copy(A),qd.x*=-1,qd.y*=-1,qd.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(qd.y*=-1,qd.z*=-1),v.envMapRotation.value.setFromMatrix4(ODe.makeRotationFromEuler(qd)),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 c(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===Ks&&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 LDe(t,e,n,r){let i={},s={},a=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(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 zr("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),ee=A%T,Y=ee%V.boundary,Q=ee+Y;A+=Y,Q!==0&&T-Q<V.storage&&(A+=T-Q),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?Yt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Yt("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:c,update:u,dispose:b}}const IDe=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 Xl=null;function UDe(){return Xl===null&&(Xl=new UNe(IDe,32,32,ej,og),Xl.minFilter=ro,Xl.magFilter=ro,Xl.wrapS=mc,Xl.wrapT=mc,Xl.generateMipmaps=!1,Xl.needsUpdate=!0),Xl}let FDe=class{constructor(e={}){const{canvas:n=cNe(),context:r=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!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([nj,tj,JO]),y=new Set([gl,Qh,$0,V0,ZO,QO]),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=Xu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const k=this;let N=!1;this._outputColorSpace=qa;let I=0,C=0,D=null,F=-1,j=null;const q=new Yr,R=new Yr;let W=null;const K=new _n(0);let V=0,ee=n.width,Y=n.height,Q=1,U=null,z=null;const J=new Yr(0,0,ee,Y),se=new Yr(0,0,ee,Y);let me=!1;const fe=new oj;let xe=!1,Ee=!1;const re=new ri,we=new Qe,Oe=new Yr,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ht=!1;function $(){return D===null?Q:1}let H=r;function ne(ie,Me){return n.getContext(ie,Me)}try{const ie={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${KO}`),n.addEventListener("webglcontextlost",Ce,!1),n.addEventListener("webglcontextrestored",ye,!1),n.addEventListener("webglcontextcreationerror",ce,!1),H===null){const Me="webgl2";if(H=ne(Me,ie),H===null)throw ne(Me)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ie){throw ie("WebGLRenderer: "+ie.message),ie}let G,Z,oe,Ne,Pe,Se,B,L,te,ve,_e,be,nt,Be,ue,Ve,Ue,ae,Je,He,Ke,ct,de,Ye;function ge(){G=new qPe(H),G.init(),ct=new NDe(H,G),Z=new UPe(H,G,e,ct),oe=new TDe(H,G),Z.reversedDepthBuffer&&g&&oe.buffers.depth.setReversed(!0),Ne=new YPe(H),Pe=new pDe,Se=new CDe(H,G,oe,Pe,Z,ct,Ne),B=new zPe(k),L=new WPe(k),te=new e3e(H),de=new LPe(H,te),ve=new KPe(H,te,Ne,de),_e=new QPe(H,ve,te,Ne),Je=new ZPe(H,Z,Se),Ve=new FPe(Pe),be=new fDe(k,B,L,G,Z,de,Ve),nt=new jDe(k,Pe),Be=new gDe,ue=new wDe(G),ae=new jPe(k,B,L,oe,_e,m,c),Ue=new MDe(k,_e,Z),Ye=new LDe(H,Ne,Z,oe),He=new IPe(H,G,Ne),Ke=new XPe(H,G,Ne),Ne.programs=be.programs,k.capabilities=Z,k.extensions=G,k.properties=Pe,k.renderLists=Be,k.shadowMap=Ue,k.state=oe,k.info=Ne}ge();const Fe=new DDe(k,H);this.xr=Fe,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const ie=G.get("WEBGL_lose_context");ie&&ie.loseContext()},this.forceContextRestore=function(){const ie=G.get("WEBGL_lose_context");ie&&ie.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(ie){ie!==void 0&&(Q=ie,this.setSize(ee,Y,!1))},this.getSize=function(ie){return ie.set(ee,Y)},this.setSize=function(ie,Me,Ie=!0){if(Fe.isPresenting){Yt("WebGLRenderer: Can't change size while VR device is presenting.");return}ee=ie,Y=Me,n.width=Math.floor(ie*Q),n.height=Math.floor(Me*Q),Ie===!0&&(n.style.width=ie+"px",n.style.height=Me+"px"),this.setViewport(0,0,ie,Me)},this.getDrawingBufferSize=function(ie){return ie.set(ee*Q,Y*Q).floor()},this.setDrawingBufferSize=function(ie,Me,Ie){ee=ie,Y=Me,Q=Ie,n.width=Math.floor(ie*Ie),n.height=Math.floor(Me*Ie),this.setViewport(0,0,ie,Me)},this.getCurrentViewport=function(ie){return ie.copy(q)},this.getViewport=function(ie){return ie.copy(J)},this.setViewport=function(ie,Me,Ie,je){ie.isVector4?J.set(ie.x,ie.y,ie.z,ie.w):J.set(ie,Me,Ie,je),oe.viewport(q.copy(J).multiplyScalar(Q).round())},this.getScissor=function(ie){return ie.copy(se)},this.setScissor=function(ie,Me,Ie,je){ie.isVector4?se.set(ie.x,ie.y,ie.z,ie.w):se.set(ie,Me,Ie,je),oe.scissor(R.copy(se).multiplyScalar(Q).round())},this.getScissorTest=function(){return me},this.setScissorTest=function(ie){oe.setScissorTest(me=ie)},this.setOpaqueSort=function(ie){U=ie},this.setTransparentSort=function(ie){z=ie},this.getClearColor=function(ie){return ie.copy(ae.getClearColor())},this.setClearColor=function(){ae.setClearColor(...arguments)},this.getClearAlpha=function(){return ae.getClearAlpha()},this.setClearAlpha=function(){ae.setClearAlpha(...arguments)},this.clear=function(ie=!0,Me=!0,Ie=!0){let je=0;if(ie){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),vt=ae.getClearColor(),bt=ae.getClearAlpha(),Lt=vt.r,Tt=vt.g,mt=vt.b;ft?(v[0]=Lt,v[1]=Tt,v[2]=mt,v[3]=bt,H.clearBufferuiv(H.COLOR,0,v)):(b[0]=Lt,b[1]=Tt,b[2]=mt,b[3]=bt,H.clearBufferiv(H.COLOR,0,b))}else je|=H.COLOR_BUFFER_BIT}Me&&(je|=H.DEPTH_BUFFER_BIT),Ie&&(je|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(je)},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",ye,!1),n.removeEventListener("webglcontextcreationerror",ce,!1),ae.dispose(),Be.dispose(),ue.dispose(),Pe.dispose(),B.dispose(),L.dispose(),_e.dispose(),de.dispose(),Ye.dispose(),be.dispose(),Fe.dispose(),Fe.removeEventListener("sessionstart",jn),Fe.removeEventListener("sessionend",Ei),ai.stop()};function Ce(ie){ie.preventDefault(),L8("WebGLRenderer: Context Lost."),N=!0}function ye(){L8("WebGLRenderer: Context Restored."),N=!1;const ie=Ne.autoReset,Me=Ue.enabled,Ie=Ue.autoUpdate,je=Ue.needsUpdate,Te=Ue.type;ge(),Ne.autoReset=ie,Ue.enabled=Me,Ue.autoUpdate=Ie,Ue.needsUpdate=je,Ue.type=Te}function ce(ie){zr("WebGLRenderer: A WebGL context could not be created. Reason: ",ie.statusMessage)}function at(ie){const Me=ie.target;Me.removeEventListener("dispose",at),xt(Me)}function xt(ie){St(ie),Pe.remove(ie)}function St(ie){const Me=Pe.get(ie).programs;Me!==void 0&&(Me.forEach(function(Ie){be.releaseProgram(Ie)}),ie.isShaderMaterial&&be.releaseShaderCache(ie))}this.renderBufferDirect=function(ie,Me,Ie,je,Te,ot){Me===null&&(Me=he);const ft=Te.isMesh&&Te.matrixWorld.determinant()<0,vt=pe(ie,Me,Ie,je,Te);oe.setMaterial(je,ft);let bt=Ie.index,Lt=1;if(je.wireframe===!0){if(bt=ve.getWireframeAttribute(Ie),bt===void 0)return;Lt=2}const Tt=Ie.drawRange,mt=Ie.attributes.position;let Xt=Tt.start*Lt,Ft=(Tt.start+Tt.count)*Lt;ot!==null&&(Xt=Math.max(Xt,ot.start*Lt),Ft=Math.min(Ft,(ot.start+ot.count)*Lt)),bt!==null?(Xt=Math.max(Xt,0),Ft=Math.min(Ft,bt.count)):mt!=null&&(Xt=Math.max(Xt,0),Ft=Math.min(Ft,mt.count));const sn=Ft-Xt;if(sn<0||sn===1/0)return;de.setup(Te,je,vt,Ie,bt);let hn,bn=He;if(bt!==null&&(hn=te.get(bt),bn=Ke,bn.setIndex(hn)),Te.isMesh)je.wireframe===!0?(oe.setLineWidth(je.wireframeLinewidth*$()),bn.setMode(H.LINES)):bn.setMode(H.TRIANGLES);else if(Te.isLine){let Ut=je.linewidth;Ut===void 0&&(Ut=1),oe.setLineWidth(Ut*$()),Te.isLineSegments?bn.setMode(H.LINES):Te.isLineLoop?bn.setMode(H.LINE_LOOP):bn.setMode(H.LINE_STRIP)}else Te.isPoints?bn.setMode(H.POINTS):Te.isSprite&&bn.setMode(H.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)q0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),bn.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(G.get("WEBGL_multi_draw"))bn.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const Ut=Te._multiDrawStarts,Jt=Te._multiDrawCounts,tn=Te._multiDrawCount,Ar=bt?te.get(bt).bytesPerElement:1,jr=Pe.get(je).currentProgram.getUniforms();for(let Dn=0;Dn<tn;Dn++)jr.setValue(H,"_gl_DrawID",Dn),bn.render(Ut[Dn]/Ar,Jt[Dn])}else if(Te.isInstancedMesh)bn.renderInstances(Xt,sn,Te.count);else if(Ie.isInstancedBufferGeometry){const Ut=Ie._maxInstanceCount!==void 0?Ie._maxInstanceCount:1/0,Jt=Math.min(Ie.instanceCount,Ut);bn.renderInstances(Xt,sn,Jt)}else bn.render(Xt,sn)};function Qt(ie,Me,Ie){ie.transparent===!0&&ie.side===rl&&ie.forceSinglePass===!1?(ie.side=Ks,ie.needsUpdate=!0,Or(ie,Me,Ie),ie.side=dd,ie.needsUpdate=!0,Or(ie,Me,Ie),ie.side=rl):Or(ie,Me,Ie)}this.compile=function(ie,Me,Ie=null){Ie===null&&(Ie=ie),S=ue.get(Ie),S.init(Me),T.push(S),Ie.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Me.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),ie!==Ie&&ie.traverseVisible(function(Te){Te.isLight&&Te.layers.test(Me.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),S.setupLights();const je=new Set;return ie.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 vt=ot[ft];Qt(vt,Ie,Te),je.add(vt)}else Qt(ot,Ie,Te),je.add(ot)}),S=T.pop(),je},this.compileAsync=function(ie,Me,Ie=null){const je=this.compile(ie,Me,Ie);return new Promise(Te=>{function ot(){if(je.forEach(function(ft){Pe.get(ft).currentProgram.isReady()&&je.delete(ft)}),je.size===0){Te(ie);return}setTimeout(ot,10)}G.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let jt=null;function Vt(ie){jt&&jt(ie)}function jn(){ai.stop()}function Ei(){ai.start()}const ai=new gZ;ai.setAnimationLoop(Vt),typeof self<"u"&&ai.setContext(self),this.setAnimationLoop=function(ie){jt=ie,Fe.setAnimationLoop(ie),ie===null?ai.stop():ai.start()},Fe.addEventListener("sessionstart",jn),Fe.addEventListener("sessionend",Ei),this.render=function(ie,Me){if(Me!==void 0&&Me.isCamera!==!0){zr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(ie.matrixWorldAutoUpdate===!0&&ie.updateMatrixWorld(),Me.parent===null&&Me.matrixWorldAutoUpdate===!0&&Me.updateMatrixWorld(),Fe.enabled===!0&&Fe.isPresenting===!0&&(Fe.cameraAutoUpdate===!0&&Fe.updateCamera(Me),Me=Fe.getCamera()),ie.isScene===!0&&ie.onBeforeRender(k,ie,Me,D),S=ue.get(ie,T.length),S.init(Me),T.push(S),re.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),fe.setFromProjectionMatrix(re,ol,Me.reversedDepth),Ee=this.localClippingEnabled,xe=Ve.init(this.clippingPlanes,Ee),E=Be.get(ie,A.length),E.init(),A.push(E),Fe.enabled===!0&&Fe.isPresenting===!0){const ot=k.xr.getDepthSensingMesh();ot!==null&&Mi(ot,Me,-1/0,k.sortObjects)}Mi(ie,Me,0,k.sortObjects),E.finish(),k.sortObjects===!0&&E.sort(U,z),ht=Fe.enabled===!1||Fe.isPresenting===!1||Fe.hasDepthSensing()===!1,ht&&ae.addToRenderList(E,ie),this.info.render.frame++,xe===!0&&Ve.beginShadows();const Ie=S.state.shadowsArray;Ue.render(Ie,ie,Me),xe===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const je=E.opaque,Te=E.transmissive;if(S.setupLights(),Me.isArrayCamera){const ot=Me.cameras;if(Te.length>0)for(let ft=0,vt=ot.length;ft<vt;ft++){const bt=ot[ft];rs(je,Te,ie,bt)}ht&&ae.render(ie);for(let ft=0,vt=ot.length;ft<vt;ft++){const bt=ot[ft];zi(E,ie,bt,bt.viewport)}}else Te.length>0&&rs(je,Te,ie,Me),ht&&ae.render(ie),zi(E,ie,Me);D!==null&&C===0&&(Se.updateMultisampleRenderTarget(D),Se.updateRenderTargetMipmap(D)),ie.isScene===!0&&ie.onAfterRender(k,ie,Me),de.resetDefaultState(),F=-1,j=null,T.pop(),T.length>0?(S=T[T.length-1],xe===!0&&Ve.setGlobalState(k.clippingPlanes,S.state.camera)):S=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Mi(ie,Me,Ie,je){if(ie.visible===!1)return;if(ie.layers.test(Me.layers)){if(ie.isGroup)Ie=ie.renderOrder;else if(ie.isLOD)ie.autoUpdate===!0&&ie.update(Me);else if(ie.isLight)S.pushLight(ie),ie.castShadow&&S.pushShadow(ie);else if(ie.isSprite){if(!ie.frustumCulled||fe.intersectsSprite(ie)){je&&Oe.setFromMatrixPosition(ie.matrixWorld).applyMatrix4(re);const ft=_e.update(ie),vt=ie.material;vt.visible&&E.push(ie,ft,vt,Ie,Oe.z,null)}}else if((ie.isMesh||ie.isLine||ie.isPoints)&&(!ie.frustumCulled||fe.intersectsObject(ie))){const ft=_e.update(ie),vt=ie.material;if(je&&(ie.boundingSphere!==void 0?(ie.boundingSphere===null&&ie.computeBoundingSphere(),Oe.copy(ie.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),Oe.copy(ft.boundingSphere.center)),Oe.applyMatrix4(ie.matrixWorld).applyMatrix4(re)),Array.isArray(vt)){const bt=ft.groups;for(let Lt=0,Tt=bt.length;Lt<Tt;Lt++){const mt=bt[Lt],Xt=vt[mt.materialIndex];Xt&&Xt.visible&&E.push(ie,ft,Xt,Ie,Oe.z,mt)}}else vt.visible&&E.push(ie,ft,vt,Ie,Oe.z,null)}}const ot=ie.children;for(let ft=0,vt=ot.length;ft<vt;ft++)Mi(ot[ft],Me,Ie,je)}function zi(ie,Me,Ie,je){const{opaque:Te,transmissive:ot,transparent:ft}=ie;S.setupLightsView(Ie),xe===!0&&Ve.setGlobalState(k.clippingPlanes,Ie),je&&oe.viewport(q.copy(je)),Te.length>0&&Hr(Te,Me,Ie),ot.length>0&&Hr(ot,Me,Ie),ft.length>0&&Hr(ft,Me,Ie),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function rs(ie,Me,Ie,je){if((Ie.isScene===!0?Ie.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[je.id]===void 0&&(S.state.transmissionRenderTarget[je.id]=new ef(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")||G.has("EXT_color_buffer_float")?og:gl,minFilter:gh,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Cn.workingColorSpace}));const ot=S.state.transmissionRenderTarget[je.id],ft=je.viewport||q;ot.setSize(ft.z*k.transmissionResolutionScale,ft.w*k.transmissionResolutionScale);const vt=k.getRenderTarget(),bt=k.getActiveCubeFace(),Lt=k.getActiveMipmapLevel();k.setRenderTarget(ot),k.getClearColor(K),V=k.getClearAlpha(),V<1&&k.setClearColor(16777215,.5),k.clear(),ht&&ae.render(Ie);const Tt=k.toneMapping;k.toneMapping=Xu;const mt=je.viewport;if(je.viewport!==void 0&&(je.viewport=void 0),S.setupLightsView(je),xe===!0&&Ve.setGlobalState(k.clippingPlanes,je),Hr(ie,Ie,je),Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot),G.has("WEBGL_multisampled_render_to_texture")===!1){let Xt=!1;for(let Ft=0,sn=Me.length;Ft<sn;Ft++){const hn=Me[Ft],{object:bn,geometry:Ut,material:Jt,group:tn}=hn;if(Jt.side===rl&&bn.layers.test(je.layers)){const Ar=Jt.side;Jt.side=Ks,Jt.needsUpdate=!0,br(bn,Ie,je,Ut,Jt,tn),Jt.side=Ar,Jt.needsUpdate=!0,Xt=!0}}Xt===!0&&(Se.updateMultisampleRenderTarget(ot),Se.updateRenderTargetMipmap(ot))}k.setRenderTarget(vt,bt,Lt),k.setClearColor(K,V),mt!==void 0&&(je.viewport=mt),k.toneMapping=Tt}function Hr(ie,Me,Ie){const je=Me.isScene===!0?Me.overrideMaterial:null;for(let Te=0,ot=ie.length;Te<ot;Te++){const ft=ie[Te],{object:vt,geometry:bt,group:Lt}=ft;let Tt=ft.material;Tt.allowOverride===!0&&je!==null&&(Tt=je),vt.layers.test(Ie.layers)&&br(vt,Me,Ie,bt,Tt,Lt)}}function br(ie,Me,Ie,je,Te,ot){ie.onBeforeRender(k,Me,Ie,je,Te,ot),ie.modelViewMatrix.multiplyMatrices(Ie.matrixWorldInverse,ie.matrixWorld),ie.normalMatrix.getNormalMatrix(ie.modelViewMatrix),Te.onBeforeRender(k,Me,Ie,je,ie,ot),Te.transparent===!0&&Te.side===rl&&Te.forceSinglePass===!1?(Te.side=Ks,Te.needsUpdate=!0,k.renderBufferDirect(Ie,Me,je,Te,ie,ot),Te.side=dd,Te.needsUpdate=!0,k.renderBufferDirect(Ie,Me,je,Te,ie,ot),Te.side=rl):k.renderBufferDirect(Ie,Me,je,Te,ie,ot),ie.onAfterRender(k,Me,Ie,je,Te,ot)}function Or(ie,Me,Ie){Me.isScene!==!0&&(Me=he);const je=Pe.get(ie),Te=S.state.lights,ot=S.state.shadowsArray,ft=Te.state.version,vt=be.getParameters(ie,Te.state,ot,Me,Ie),bt=be.getProgramCacheKey(vt);let Lt=je.programs;je.environment=ie.isMeshStandardMaterial?Me.environment:null,je.fog=Me.fog,je.envMap=(ie.isMeshStandardMaterial?L:B).get(ie.envMap||je.environment),je.envMapRotation=je.environment!==null&&ie.envMap===null?Me.environmentRotation:ie.envMapRotation,Lt===void 0&&(ie.addEventListener("dispose",at),Lt=new Map,je.programs=Lt);let Tt=Lt.get(bt);if(Tt!==void 0){if(je.currentProgram===Tt&&je.lightsStateVersion===ft)return Hc(ie,vt),Tt}else vt.uniforms=be.getUniforms(ie),ie.onBeforeCompile(vt,k),Tt=be.acquireProgram(vt,bt),Lt.set(bt,Tt),je.uniforms=vt.uniforms;const mt=je.uniforms;return(!ie.isShaderMaterial&&!ie.isRawShaderMaterial||ie.clipping===!0)&&(mt.clippingPlanes=Ve.uniform),Hc(ie,vt),je.needsLights=rt(ie),je.lightsStateVersion=ft,je.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),je.currentProgram=Tt,je.uniformsList=null,Tt}function mo(ie){if(ie.uniformsList===null){const Me=ie.currentProgram.getUniforms();ie.uniformsList=f1.seqWithValue(Me.seq,ie.uniforms)}return ie.uniformsList}function Hc(ie,Me){const Ie=Pe.get(ie);Ie.outputColorSpace=Me.outputColorSpace,Ie.batching=Me.batching,Ie.batchingColor=Me.batchingColor,Ie.instancing=Me.instancing,Ie.instancingColor=Me.instancingColor,Ie.instancingMorph=Me.instancingMorph,Ie.skinning=Me.skinning,Ie.morphTargets=Me.morphTargets,Ie.morphNormals=Me.morphNormals,Ie.morphColors=Me.morphColors,Ie.morphTargetsCount=Me.morphTargetsCount,Ie.numClippingPlanes=Me.numClippingPlanes,Ie.numIntersection=Me.numClipIntersection,Ie.vertexAlphas=Me.vertexAlphas,Ie.vertexTangents=Me.vertexTangents,Ie.toneMapping=Me.toneMapping}function pe(ie,Me,Ie,je,Te){Me.isScene!==!0&&(Me=he),Se.resetTextureUnits();const ot=Me.fog,ft=je.isMeshStandardMaterial?Me.environment:null,vt=D===null?k.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:km,bt=(je.isMeshStandardMaterial?L:B).get(je.envMap||ft),Lt=je.vertexColors===!0&&!!Ie.attributes.color&&Ie.attributes.color.itemSize===4,Tt=!!Ie.attributes.tangent&&(!!je.normalMap||je.anisotropy>0),mt=!!Ie.morphAttributes.position,Xt=!!Ie.morphAttributes.normal,Ft=!!Ie.morphAttributes.color;let sn=Xu;je.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(sn=k.toneMapping);const hn=Ie.morphAttributes.position||Ie.morphAttributes.normal||Ie.morphAttributes.color,bn=hn!==void 0?hn.length:0,Ut=Pe.get(je),Jt=S.state.lights;if(xe===!0&&(Ee===!0||ie!==j)){const Ti=ie===j&&je.id===F;Ve.setState(je,ie,Ti)}let tn=!1;je.version===Ut.__version?(Ut.needsLights&&Ut.lightsStateVersion!==Jt.state.version||Ut.outputColorSpace!==vt||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!==bt||je.fog===!0&&Ut.fog!==ot||Ut.numClippingPlanes!==void 0&&(Ut.numClippingPlanes!==Ve.numPlanes||Ut.numIntersection!==Ve.numIntersection)||Ut.vertexAlphas!==Lt||Ut.vertexTangents!==Tt||Ut.morphTargets!==mt||Ut.morphNormals!==Xt||Ut.morphColors!==Ft||Ut.toneMapping!==sn||Ut.morphTargetsCount!==bn)&&(tn=!0):(tn=!0,Ut.__version=je.version);let Ar=Ut.currentProgram;tn===!0&&(Ar=Or(je,Me,Te));let jr=!1,Dn=!1,go=!1;const Ln=Ar.getUniforms(),Ai=Ut.uniforms;if(oe.useProgram(Ar.program)&&(jr=!0,Dn=!0,go=!0),je.id!==F&&(F=je.id,Dn=!0),jr||j!==ie){oe.buffers.depth.getReversed()&&ie.reversedDepth!==!0&&(ie._reversedDepth=!0,ie.updateProjectionMatrix()),Ln.setValue(H,"projectionMatrix",ie.projectionMatrix),Ln.setValue(H,"viewMatrix",ie.matrixWorldInverse);const Bi=Ln.map.cameraPosition;Bi!==void 0&&Bi.setValue(H,we.setFromMatrixPosition(ie.matrixWorld)),Z.logarithmicDepthBuffer&&Ln.setValue(H,"logDepthBufFC",2/(Math.log(ie.far+1)/Math.LN2)),(je.isMeshPhongMaterial||je.isMeshToonMaterial||je.isMeshLambertMaterial||je.isMeshBasicMaterial||je.isMeshStandardMaterial||je.isShaderMaterial)&&Ln.setValue(H,"isOrthographic",ie.isOrthographicCamera===!0),j!==ie&&(j=ie,Dn=!0,go=!0)}if(Te.isSkinnedMesh){Ln.setOptional(H,Te,"bindMatrix"),Ln.setOptional(H,Te,"bindMatrixInverse");const Ti=Te.skeleton;Ti&&(Ti.boneTexture===null&&Ti.computeBoneTexture(),Ln.setValue(H,"boneTexture",Ti.boneTexture,Se))}Te.isBatchedMesh&&(Ln.setOptional(H,Te,"batchingTexture"),Ln.setValue(H,"batchingTexture",Te._matricesTexture,Se),Ln.setOptional(H,Te,"batchingIdTexture"),Ln.setValue(H,"batchingIdTexture",Te._indirectTexture,Se),Ln.setOptional(H,Te,"batchingColorTexture"),Te._colorsTexture!==null&&Ln.setValue(H,"batchingColorTexture",Te._colorsTexture,Se));const oi=Ie.morphAttributes;if((oi.position!==void 0||oi.normal!==void 0||oi.color!==void 0)&&Je.update(Te,Ie,Ar),(Dn||Ut.receiveShadow!==Te.receiveShadow)&&(Ut.receiveShadow=Te.receiveShadow,Ln.setValue(H,"receiveShadow",Te.receiveShadow)),je.isMeshGouraudMaterial&&je.envMap!==null&&(Ai.envMap.value=bt,Ai.flipEnvMap.value=bt.isCubeTexture&&bt.isRenderTargetTexture===!1?-1:1),je.isMeshStandardMaterial&&je.envMap===null&&Me.environment!==null&&(Ai.envMapIntensity.value=Me.environmentIntensity),Ai.dfgLUT!==void 0&&(Ai.dfgLUT.value=UDe()),Dn&&(Ln.setValue(H,"toneMappingExposure",k.toneMappingExposure),Ut.needsLights&&$e(Ai,go),ot&&je.fog===!0&&nt.refreshFogUniforms(Ai,ot),nt.refreshMaterialUniforms(Ai,je,Q,Y,S.state.transmissionRenderTarget[ie.id]),f1.upload(H,mo(Ut),Ai,Se)),je.isShaderMaterial&&je.uniformsNeedUpdate===!0&&(f1.upload(H,mo(Ut),Ai,Se),je.uniformsNeedUpdate=!1),je.isSpriteMaterial&&Ln.setValue(H,"center",Te.center),Ln.setValue(H,"modelViewMatrix",Te.modelViewMatrix),Ln.setValue(H,"normalMatrix",Te.normalMatrix),Ln.setValue(H,"modelMatrix",Te.matrixWorld),je.isShaderMaterial||je.isRawShaderMaterial){const Ti=je.uniformsGroups;for(let Bi=0,Vo=Ti.length;Bi<Vo;Bi++){const Al=Ti[Bi];Ye.update(Al,Ar),Ye.bind(Al,Ar)}}return Ar}function $e(ie,Me){ie.ambientLightColor.needsUpdate=Me,ie.lightProbe.needsUpdate=Me,ie.directionalLights.needsUpdate=Me,ie.directionalLightShadows.needsUpdate=Me,ie.pointLights.needsUpdate=Me,ie.pointLightShadows.needsUpdate=Me,ie.spotLights.needsUpdate=Me,ie.spotLightShadows.needsUpdate=Me,ie.rectAreaLights.needsUpdate=Me,ie.hemisphereLights.needsUpdate=Me}function rt(ie){return ie.isMeshLambertMaterial||ie.isMeshToonMaterial||ie.isMeshPhongMaterial||ie.isMeshStandardMaterial||ie.isShadowMaterial||ie.isShaderMaterial&&ie.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(ie,Me,Ie){const je=Pe.get(ie);je.__autoAllocateDepthBuffer=ie.resolveDepthBuffer===!1,je.__autoAllocateDepthBuffer===!1&&(je.__useRenderToTexture=!1),Pe.get(ie.texture).__webglTexture=Me,Pe.get(ie.depthTexture).__webglTexture=je.__autoAllocateDepthBuffer?void 0:Ie,je.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ie,Me){const Ie=Pe.get(ie);Ie.__webglFramebuffer=Me,Ie.__useDefaultFramebuffer=Me===void 0};const it=H.createFramebuffer();this.setRenderTarget=function(ie,Me=0,Ie=0){D=ie,I=Me,C=Ie;let je=!0,Te=null,ot=!1,ft=!1;if(ie){const bt=Pe.get(ie);if(bt.__useDefaultFramebuffer!==void 0)oe.bindFramebuffer(H.FRAMEBUFFER,null),je=!1;else if(bt.__webglFramebuffer===void 0)Se.setupRenderTarget(ie);else if(bt.__hasExternalTextures)Se.rebindTextures(ie,Pe.get(ie.texture).__webglTexture,Pe.get(ie.depthTexture).__webglTexture);else if(ie.depthBuffer){const mt=ie.depthTexture;if(bt.__boundDepthTexture!==mt){if(mt!==null&&Pe.has(mt)&&(ie.width!==mt.image.width||ie.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(ie)}}const Lt=ie.texture;(Lt.isData3DTexture||Lt.isDataArrayTexture||Lt.isCompressedArrayTexture)&&(ft=!0);const Tt=Pe.get(ie).__webglFramebuffer;ie.isWebGLCubeRenderTarget?(Array.isArray(Tt[Me])?Te=Tt[Me][Ie]:Te=Tt[Me],ot=!0):ie.samples>0&&Se.useMultisampledRTT(ie)===!1?Te=Pe.get(ie).__webglMultisampledFramebuffer:Array.isArray(Tt)?Te=Tt[Ie]:Te=Tt,q.copy(ie.viewport),R.copy(ie.scissor),W=ie.scissorTest}else q.copy(J).multiplyScalar(Q).floor(),R.copy(se).multiplyScalar(Q).floor(),W=me;if(Ie!==0&&(Te=it),oe.bindFramebuffer(H.FRAMEBUFFER,Te)&&je&&oe.drawBuffers(ie,Te),oe.viewport(q),oe.scissor(R),oe.setScissorTest(W),ot){const bt=Pe.get(ie.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Me,bt.__webglTexture,Ie)}else if(ft){const bt=Me;for(let Lt=0;Lt<ie.textures.length;Lt++){const Tt=Pe.get(ie.textures[Lt]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+Lt,Tt.__webglTexture,Ie,bt)}}else if(ie!==null&&Ie!==0){const bt=Pe.get(ie.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,bt.__webglTexture,Ie)}F=-1},this.readRenderTargetPixels=function(ie,Me,Ie,je,Te,ot,ft,vt=0){if(!(ie&&ie.isWebGLRenderTarget)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=Pe.get(ie).__webglFramebuffer;if(ie.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt){oe.bindFramebuffer(H.FRAMEBUFFER,bt);try{const Lt=ie.textures[vt],Tt=Lt.format,mt=Lt.type;if(!Z.textureFormatReadable(Tt)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Z.textureTypeReadable(mt)){zr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Me>=0&&Me<=ie.width-je&&Ie>=0&&Ie<=ie.height-Te&&(ie.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+vt),H.readPixels(Me,Ie,je,Te,ct.convert(Tt),ct.convert(mt),ot))}finally{const Lt=D!==null?Pe.get(D).__webglFramebuffer:null;oe.bindFramebuffer(H.FRAMEBUFFER,Lt)}}},this.readRenderTargetPixelsAsync=async function(ie,Me,Ie,je,Te,ot,ft,vt=0){if(!(ie&&ie.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=Pe.get(ie).__webglFramebuffer;if(ie.isWebGLCubeRenderTarget&&ft!==void 0&&(bt=bt[ft]),bt)if(Me>=0&&Me<=ie.width-je&&Ie>=0&&Ie<=ie.height-Te){oe.bindFramebuffer(H.FRAMEBUFFER,bt);const Lt=ie.textures[vt],Tt=Lt.format,mt=Lt.type;if(!Z.textureFormatReadable(Tt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Xt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,Xt),H.bufferData(H.PIXEL_PACK_BUFFER,ot.byteLength,H.STREAM_READ),ie.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+vt),H.readPixels(Me,Ie,je,Te,ct.convert(Tt),ct.convert(mt),0);const Ft=D!==null?Pe.get(D).__webglFramebuffer:null;oe.bindFramebuffer(H.FRAMEBUFFER,Ft);const sn=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await uNe(H,sn,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,Xt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,ot),H.deleteBuffer(Xt),H.deleteSync(sn),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ie,Me=null,Ie=0){const je=Math.pow(2,-Ie),Te=Math.floor(ie.image.width*je),ot=Math.floor(ie.image.height*je),ft=Me!==null?Me.x:0,vt=Me!==null?Me.y:0;Se.setTexture2D(ie,0),H.copyTexSubImage2D(H.TEXTURE_2D,Ie,0,0,ft,vt,Te,ot),oe.unbindTexture()};const et=H.createFramebuffer(),Et=H.createFramebuffer();this.copyTextureToTexture=function(ie,Me,Ie=null,je=null,Te=0,ot=null){ot===null&&(Te!==0?(q0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ot=Te,Te=0):ot=0);let ft,vt,bt,Lt,Tt,mt,Xt,Ft,sn;const hn=ie.isCompressedTexture?ie.mipmaps[ot]:ie.image;if(Ie!==null)ft=Ie.max.x-Ie.min.x,vt=Ie.max.y-Ie.min.y,bt=Ie.isBox3?Ie.max.z-Ie.min.z:1,Lt=Ie.min.x,Tt=Ie.min.y,mt=Ie.isBox3?Ie.min.z:0;else{const oi=Math.pow(2,-Te);ft=Math.floor(hn.width*oi),vt=Math.floor(hn.height*oi),ie.isDataArrayTexture?bt=hn.depth:ie.isData3DTexture?bt=Math.floor(hn.depth*oi):bt=1,Lt=0,Tt=0,mt=0}je!==null?(Xt=je.x,Ft=je.y,sn=je.z):(Xt=0,Ft=0,sn=0);const bn=ct.convert(Me.format),Ut=ct.convert(Me.type);let Jt;Me.isData3DTexture?(Se.setTexture3D(Me,0),Jt=H.TEXTURE_3D):Me.isDataArrayTexture||Me.isCompressedArrayTexture?(Se.setTexture2DArray(Me,0),Jt=H.TEXTURE_2D_ARRAY):(Se.setTexture2D(Me,0),Jt=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Me.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Me.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Me.unpackAlignment);const tn=H.getParameter(H.UNPACK_ROW_LENGTH),Ar=H.getParameter(H.UNPACK_IMAGE_HEIGHT),jr=H.getParameter(H.UNPACK_SKIP_PIXELS),Dn=H.getParameter(H.UNPACK_SKIP_ROWS),go=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,hn.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,hn.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Lt),H.pixelStorei(H.UNPACK_SKIP_ROWS,Tt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,mt);const Ln=ie.isDataArrayTexture||ie.isData3DTexture,Ai=Me.isDataArrayTexture||Me.isData3DTexture;if(ie.isDepthTexture){const oi=Pe.get(ie),Ti=Pe.get(Me),Bi=Pe.get(oi.__renderTarget),Vo=Pe.get(Ti.__renderTarget);oe.bindFramebuffer(H.READ_FRAMEBUFFER,Bi.__webglFramebuffer),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,Vo.__webglFramebuffer);for(let Al=0;Al<bt;Al++)Ln&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Pe.get(ie).__webglTexture,Te,mt+Al),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Pe.get(Me).__webglTexture,ot,sn+Al)),H.blitFramebuffer(Lt,Tt,ft,vt,Xt,Ft,ft,vt,H.DEPTH_BUFFER_BIT,H.NEAREST);oe.bindFramebuffer(H.READ_FRAMEBUFFER,null),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(Te!==0||ie.isRenderTargetTexture||Pe.has(ie)){const oi=Pe.get(ie),Ti=Pe.get(Me);oe.bindFramebuffer(H.READ_FRAMEBUFFER,et),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,Et);for(let Bi=0;Bi<bt;Bi++)Ln?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,oi.__webglTexture,Te,mt+Bi):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,oi.__webglTexture,Te),Ai?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ti.__webglTexture,ot,sn+Bi):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Ti.__webglTexture,ot),Te!==0?H.blitFramebuffer(Lt,Tt,ft,vt,Xt,Ft,ft,vt,H.COLOR_BUFFER_BIT,H.NEAREST):Ai?H.copyTexSubImage3D(Jt,ot,Xt,Ft,sn+Bi,Lt,Tt,ft,vt):H.copyTexSubImage2D(Jt,ot,Xt,Ft,Lt,Tt,ft,vt);oe.bindFramebuffer(H.READ_FRAMEBUFFER,null),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Ai?ie.isDataTexture||ie.isData3DTexture?H.texSubImage3D(Jt,ot,Xt,Ft,sn,ft,vt,bt,bn,Ut,hn.data):Me.isCompressedArrayTexture?H.compressedTexSubImage3D(Jt,ot,Xt,Ft,sn,ft,vt,bt,bn,hn.data):H.texSubImage3D(Jt,ot,Xt,Ft,sn,ft,vt,bt,bn,Ut,hn):ie.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,ot,Xt,Ft,ft,vt,bn,Ut,hn.data):ie.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,ot,Xt,Ft,hn.width,hn.height,bn,hn.data):H.texSubImage2D(H.TEXTURE_2D,ot,Xt,Ft,ft,vt,bn,Ut,hn);H.pixelStorei(H.UNPACK_ROW_LENGTH,tn),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Ar),H.pixelStorei(H.UNPACK_SKIP_PIXELS,jr),H.pixelStorei(H.UNPACK_SKIP_ROWS,Dn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,go),ot===0&&Me.generateMipmaps&&H.generateMipmap(Jt),oe.unbindTexture()},this.initRenderTarget=function(ie){Pe.get(ie).__webglFramebuffer===void 0&&Se.setupRenderTarget(ie)},this.initTexture=function(ie){ie.isCubeTexture?Se.setTextureCube(ie,0):ie.isData3DTexture?Se.setTexture3D(ie,0):ie.isDataArrayTexture||ie.isCompressedArrayTexture?Se.setTexture2DArray(ie,0):Se.setTexture2D(ie,0),oe.unbindTexture()},this.resetState=function(){I=0,C=0,D=null,oe.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ol}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Cn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Cn._getUnpackColorSpace()}};const PH={type:"change"},cj={type:"start"},_Z={type:"end"},r_=new ij,RH=new Nu,zDe=Math.cos(70*hNe.DEG2RAD),ci=new Qe,Hs=2*Math.PI,Yn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},VC=1e-6;class BDe extends QNe{constructor(e,n=null){super(e,n),this.state=Yn.NONE,this.target=new Qe,this.cursor=new Qe,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:rm.ROTATE,MIDDLE:rm.DOLLY,RIGHT:rm.PAN},this.touches={ONE:Kp.ROTATE,TWO:Kp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Qe,this._lastQuaternion=new Jh,this._lastTargetPosition=new Qe,this._quat=new Jh().setFromUnitVectors(e.up,new Qe(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new aH,this._sphericalDelta=new aH,this._scale=1,this._panOffset=new Qe,this._rotateStart=new cn,this._rotateEnd=new cn,this._rotateDelta=new cn,this._panStart=new cn,this._panEnd=new cn,this._panDelta=new cn,this._dollyStart=new cn,this._dollyEnd=new cn,this._dollyDelta=new cn,this._dollyDirection=new Qe,this._mouse=new cn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=$De.bind(this),this._onPointerDown=HDe.bind(this),this._onPointerUp=VDe.bind(this),this._onContextMenu=ZDe.bind(this),this._onMouseWheel=qDe.bind(this),this._onKeyDown=KDe.bind(this),this._onTouchStart=XDe.bind(this),this._onTouchMove=YDe.bind(this),this._onMouseDown=GDe.bind(this),this._onMouseMove=WDe.bind(this),this._interceptControlDown=QDe.bind(this),this._interceptControlUp=JDe.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(PH),this.update(),this.state=Yn.NONE}update(e=null){const n=this.object.position;ci.copy(n).sub(this.target),ci.applyQuaternion(this._quat),this._spherical.setFromVector3(ci),this.autoRotate&&this.state===Yn.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+=Hs:r>Math.PI&&(r-=Hs),i<-Math.PI?i+=Hs:i>Math.PI&&(i-=Hs),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(ci.setFromSpherical(this._spherical),ci.applyQuaternion(this._quatInverse),n.copy(this.target).add(ci),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=ci.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const o=new Qe(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const u=new Qe(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(o),this.object.updateMatrixWorld(),a=ci.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):(r_.origin.copy(this.object.position),r_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(r_.direction))<zDe?this.object.lookAt(this.target):(RH.setFromNormalAndCoplanarPoint(this.object.up,this.target),r_.intersectPlane(RH,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)>VC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>VC||this._lastTargetPosition.distanceToSquared(this.target)>VC?(this.dispatchEvent(PH),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Hs/60*this.autoRotateSpeed*e:Hs/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){ci.setFromMatrixColumn(n,0),ci.multiplyScalar(-e),this._panOffset.add(ci)}_panUp(e,n){this.screenSpacePanning===!0?ci.setFromMatrixColumn(n,1):(ci.setFromMatrixColumn(n,0),ci.crossVectors(this.object.up,ci)),ci.multiplyScalar(e),this._panOffset.add(ci)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ci.copy(i).sub(this.target);let s=ci.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(Hs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Hs*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(Hs*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(-Hs*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(Hs*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(-Hs*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(Hs*this._rotateDelta.x/n.clientHeight),this._rotateUp(Hs*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 cn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function HDe(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 $De(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function VDe(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(_Z),this.state=Yn.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 GDe(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 rm.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Yn.DOLLY;break;case rm.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Yn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Yn.ROTATE}break;case rm.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Yn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Yn.PAN}break;default:this.state=Yn.NONE}this.state!==Yn.NONE&&this.dispatchEvent(cj)}function WDe(t){switch(this.state){case Yn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Yn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Yn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function qDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Yn.NONE||(t.preventDefault(),this.dispatchEvent(cj),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(_Z))}function KDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function XDe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case Kp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Yn.TOUCH_ROTATE;break;case Kp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Yn.TOUCH_PAN;break;default:this.state=Yn.NONE}break;case 2:switch(this.touches.TWO){case Kp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Yn.TOUCH_DOLLY_PAN;break;case Kp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Yn.TOUCH_DOLLY_ROTATE;break;default:this.state=Yn.NONE}break;default:this.state=Yn.NONE}this.state!==Yn.NONE&&this.dispatchEvent(cj)}function YDe(t){switch(this._trackPointer(t),this.state){case Yn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Yn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Yn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Yn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Yn.NONE}}function ZDe(t){this.enabled!==!1&&t.preventDefault()}function QDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function JDe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function eOe(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,c=new Ml;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;c.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}c.setIndex(f)}for(const d in s){const f=DH(s[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in a){const f=a[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.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=DH(m);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function DH(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 io(a,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let g=0,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,c);c+=d.count*n}return i!==void 0&&(o.gpuType=i),o}function i_(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 GC={exports:{}};var OH;function tOe(){return OH||(OH=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 i_=="function"&&i_;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 i_=="function"&&i_,c=0;c<s.length;c++)a(s[c]);return a})({1:[function(n,r,i){var s=n("./utils"),a=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,m,x,y,v=[],b=0,E=c.length,S=E,A=s.getTypeOf(c)!=="string";b<c.length;)S=E-b,f=A?(u=c[b++],d=b<E?c[b++]:0,b<E?c[b++]:0):(u=c.charCodeAt(b++),d=b<E?c.charCodeAt(b++):0,b<E?c.charCodeAt(b++):0),g=u>>2,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(c){var u,d,f,g,m,x,y=0,v=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var E,S=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&S--,c.charAt(c.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<c.length;)u=o.indexOf(c.charAt(y++))<<2|(g=o.indexOf(c.charAt(y++)))>>4,d=(15&g)<<4|(m=o.indexOf(c.charAt(y++)))>>2,f=(3&m)<<6|(x=o.indexOf(c.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"),c=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 c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new 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 c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var 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,c=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;c[u]=o}return c})();r.exports=function(o,c){return o!==void 0&&o.length?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|c,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|c,o,o.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var 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"),c=n("./stream/GenericWorker"),u=s?"uint8array":"array";function d(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",o.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new 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="",ee=T.dir,Y=T.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(Q.crc32=m.crc32,Q.compressedSize=m.compressedSize,Q.uncompressedSize=m.uncompressedSize);var U=0;x&&(U|=8),N||!q&&!R||(U|=2048);var z=0,J=0;ee&&(z|=16),b==="UNIX"?(J=798,z|=(function(me,fe){var xe=me;return me||(xe=fe?16893:33204),(65535&xe)<<16})(T.unixPermissions,ee)):(J=20,z|=(function(me){return 63&(me||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 se="";return se+=`
- \0`,se+=s(U,2),se+=k.magic,se+=s(S,2),se+=s(A,2),se+=s(Q.crc32,4),se+=s(Q.compressedSize,4),se+=s(Q.uncompressedSize,4),se+=s(I.length,2),se+=s(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+se+I+W,dirRecord:f.CENTRAL_FILE_HEADER+s(J,2)+se+s(F.length,2)+"\0\0\0\0"+s(z,4)+s(v,4)+I+W+F}}var o=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(m,x,y,v){c.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,c),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,c.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!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(m){var x=this._sources;if(!c.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(){c.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,c,u){var d=new a(c.streamFiles,u,c.platform,c.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,c.compression),y=m.options.compressionOptions||c.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"),c=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 c(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(c,u){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}s.inherits(o,a),o.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},o.prototype.pause=function(){return!!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,c,u){s.call(this,c),this._helper=o;var d=this;o.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(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 c?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"),c=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 c("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 c=0;c<this.data.length;c++)o[c]=255&o[c]}n("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),g=this.readData(4);return c===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=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 c,u=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=o,u},readString:function(o){return 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 c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},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 c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},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 c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},r.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var s=n("../utils"),a=n("../support"),o=n("./ArrayReader"),c=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 c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var s=n("./GenericWorker"),a=n("../utils");function o(c){s.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(o,s),o.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.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(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}s.inherits(o,a),o.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}a.prototype.processChunk.call(this,c)},r.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var s=n("../utils"),a=n("./GenericWorker");function o(c){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=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 c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function 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 c=0;c<this._listeners[a].length;c++)this._listeners[a][c].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(c){o.processChunk(c)}),a.on("end",function(){o.end()}),a.on("error",function(c){o.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var 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"),c=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 c.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"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}i.utf8encode=function(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,c),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,c),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"),c=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 c.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 c.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):c.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"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+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 c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===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"),c=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||c(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||c(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"),c=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 c.Utf8EncodeWorker)),!E&&b&&(y=y.pipe(new c.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 c.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,c=s.MutationObserver||s.WebKitMutationObserver;if(c){var u=0,d=new c(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 hy<"u"?hy:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var s=n("immediate");function a(){}var o={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==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===c)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=c,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"),c=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(c[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(c[S]);this._dict_set=!0}}function v(b,E){var S=new y(E);if(S.push(b,!0),S.err)throw S.msg||c[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"),c=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!==c.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?c.Z_FINISH:c.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,c.Z_NO_FLUSH))===c.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===c.Z_BUF_ERROR&&D===!0&&(b=c.Z_OK,D=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&b!==c.Z_STREAM_END&&(N.avail_in!==0||E!==c.Z_FINISH&&E!==c.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!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(b=s.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):E!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(N.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===c.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(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var a={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var m=0;m<f;m++)c[g+m]=u[d+m]},flattenChunks:function(c){var u,d,f,g,m,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)m=c[u],x.set(m,g),g+=m.length;return x}},o={arraySet:function(c,u,d,f,g){for(var m=0;m<f;m++)c[g+m]=u[d+m]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(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 c=new s.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&o||!f.subarray&&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}c[254]=c[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=c[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+c[f[m]]>g?m:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(s,a,o,c){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[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var s=(function(){for(var a,o=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;o[c]=a}return o})();r.exports=function(a,o,c,u){var d=s,f=u+c;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"),c=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 ee($,H){return $.msg=d[H],H}function Y($){return($<<1)-(4<$?9:0)}function Q($){for(var H=$.length;0<=--H;)$[H]=0}function U($){var H=$.state,ne=H.pending;ne>$.avail_out&&(ne=$.avail_out),ne!==0&&(a.arraySet($.output,H.pending_buf,H.pending_out,ne,$.next_out),$.next_out+=ne,H.pending_out+=ne,$.total_out+=ne,$.avail_out-=ne,H.pending-=ne,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 J($,H){$.pending_buf[$.pending++]=H}function se($,H){$.pending_buf[$.pending++]=H>>>8&255,$.pending_buf[$.pending++]=255&H}function me($,H){var ne,G,Z=$.max_chain_length,oe=$.strstart,Ne=$.prev_length,Pe=$.nice_match,Se=$.strstart>$.w_size-F?$.strstart-($.w_size-F):0,B=$.window,L=$.w_mask,te=$.prev,ve=$.strstart+D,_e=B[oe+Ne-1],be=B[oe+Ne];$.prev_length>=$.good_match&&(Z>>=2),Pe>$.lookahead&&(Pe=$.lookahead);do if(B[(ne=H)+Ne]===be&&B[ne+Ne-1]===_e&&B[ne]===B[oe]&&B[++ne]===B[oe+1]){oe+=2,ne++;do;while(B[++oe]===B[++ne]&&B[++oe]===B[++ne]&&B[++oe]===B[++ne]&&B[++oe]===B[++ne]&&B[++oe]===B[++ne]&&B[++oe]===B[++ne]&&B[++oe]===B[++ne]&&B[++oe]===B[++ne]&&oe<ve);if(G=D-(ve-oe),oe=ve-D,Ne<G){if($.match_start=H,Pe<=(Ne=G))break;_e=B[oe+Ne-1],be=B[oe+Ne]}}while((H=te[H&L])>Se&&--Z!=0);return Ne<=$.lookahead?Ne:$.lookahead}function fe($){var H,ne,G,Z,oe,Ne,Pe,Se,B,L,te=$.w_size;do{if(Z=$.window_size-$.lookahead-$.strstart,$.strstart>=te+(te-F)){for(a.arraySet($.window,$.window,te,te,0),$.match_start-=te,$.strstart-=te,$.block_start-=te,H=ne=$.hash_size;G=$.head[--H],$.head[H]=te<=G?G-te:0,--ne;);for(H=ne=te;G=$.prev[--H],$.prev[H]=te<=G?G-te:0,--ne;);Z+=te}if($.strm.avail_in===0)break;if(Ne=$.strm,Pe=$.window,Se=$.strstart+$.lookahead,B=Z,L=void 0,L=Ne.avail_in,B<L&&(L=B),ne=L===0?0:(Ne.avail_in-=L,a.arraySet(Pe,Ne.input,Ne.next_in,L,Se),Ne.state.wrap===1?Ne.adler=c(Ne.adler,Pe,L,Se):Ne.state.wrap===2&&(Ne.adler=u(Ne.adler,Pe,L,Se)),Ne.next_in+=L,Ne.total_in+=L,L),$.lookahead+=ne,$.lookahead+$.insert>=C)for(oe=$.strstart-$.insert,$.ins_h=$.window[oe],$.ins_h=($.ins_h<<$.hash_shift^$.window[oe+1])&$.hash_mask;$.insert&&($.ins_h=($.ins_h<<$.hash_shift^$.window[oe+C-1])&$.hash_mask,$.prev[oe&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=oe,oe++,$.insert--,!($.lookahead+$.insert<C)););}while($.lookahead<F&&$.strm.avail_in!==0)}function xe($,H){for(var ne,G;;){if($.lookahead<F){if(fe($),$.lookahead<F&&H===f)return R;if($.lookahead===0)break}if(ne=0,$.lookahead>=C&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ne=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),ne!==0&&$.strstart-ne<=$.w_size-F&&($.match_length=me($,ne)),$.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,ne=$.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 Ee($,H){for(var ne,G,Z;;){if($.lookahead<F){if(fe($),$.lookahead<F&&H===f)return R;if($.lookahead===0)break}if(ne=0,$.lookahead>=C&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ne=$.prev[$.strstart&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=$.strstart),$.prev_length=$.match_length,$.prev_match=$.match_start,$.match_length=C-1,ne!==0&&$.prev_length<$.max_lazy_match&&$.strstart-ne<=$.w_size-F&&($.match_length=me($,ne),$.match_length<=5&&($.strategy===1||$.match_length===C&&4096<$.strstart-$.match_start)&&($.match_length=C-1)),$.prev_length>=C&&$.match_length<=$.prev_length){for(Z=$.strstart+$.lookahead-C,G=o._tr_tally($,$.strstart-1-$.prev_match,$.prev_length-C),$.lookahead-=$.prev_length-1,$.prev_length-=2;++$.strstart<=Z&&($.ins_h=($.ins_h<<$.hash_shift^$.window[$.strstart+C-1])&$.hash_mask,ne=$.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,ne,G,Z){this.good_length=$,this.max_lazy=H,this.nice_length=ne,this.max_chain=G,this.func=Z}function we(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=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)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(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),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*A+1),Q(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 Oe($){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):ee($,x)}function he($){var H=Oe($);return H===m&&(function(ne){ne.window_size=2*ne.w_size,Q(ne.head),ne.max_lazy_match=s[ne.level].max_lazy,ne.good_match=s[ne.level].good_length,ne.nice_match=s[ne.level].nice_length,ne.max_chain_length=s[ne.level].max_chain,ne.strstart=0,ne.block_start=0,ne.lookahead=0,ne.insert=0,ne.match_length=ne.prev_length=C-1,ne.match_available=0,ne.ins_h=0})($.state),H}function ht($,H,ne,G,Z,oe){if(!$)return x;var Ne=1;if(H===y&&(H=6),G<0?(Ne=0,G=-G):15<G&&(Ne=2,G-=16),Z<1||S<Z||ne!==E||G<8||15<G||H<0||9<H||oe<0||v<oe)return ee($,x);G===8&&(G=9);var Pe=new we;return($.state=Pe).strm=$,Pe.wrap=Ne,Pe.gzhead=null,Pe.w_bits=G,Pe.w_size=1<<Pe.w_bits,Pe.w_mask=Pe.w_size-1,Pe.hash_bits=Z+7,Pe.hash_size=1<<Pe.hash_bits,Pe.hash_mask=Pe.hash_size-1,Pe.hash_shift=~~((Pe.hash_bits+C-1)/C),Pe.window=new a.Buf8(2*Pe.w_size),Pe.head=new a.Buf16(Pe.hash_size),Pe.prev=new a.Buf16(Pe.w_size),Pe.lit_bufsize=1<<Z+6,Pe.pending_buf_size=4*Pe.lit_bufsize,Pe.pending_buf=new a.Buf8(Pe.pending_buf_size),Pe.d_buf=1*Pe.lit_bufsize,Pe.l_buf=3*Pe.lit_bufsize,Pe.level=H,Pe.strategy=oe,Pe.method=ne,he($)}s=[new re(0,0,0,0,function($,H){var ne=65535;for(ne>$.pending_buf_size-5&&(ne=$.pending_buf_size-5);;){if($.lookahead<=1){if(fe($),$.lookahead===0&&H===f)return R;if($.lookahead===0)break}$.strstart+=$.lookahead,$.lookahead=0;var G=$.block_start+ne;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,Ee),new re(8,16,32,32,Ee),new re(8,16,128,128,Ee),new re(8,32,128,256,Ee),new re(32,128,258,1024,Ee),new re(32,258,258,4096,Ee)],i.deflateInit=function($,H){return ht($,H,E,15,8,0)},i.deflateInit2=ht,i.deflateReset=he,i.deflateResetKeep=Oe,i.deflateSetHeader=function($,H){return $&&$.state?$.state.wrap!==2?x:($.state.gzhead=H,m):x},i.deflate=function($,H){var ne,G,Z,oe;if(!$||!$.state||5<H||H<0)return $?ee($,x):x;if(G=$.state,!$.output||!$.input&&$.avail_in!==0||G.status===666&&H!==g)return ee($,$.avail_out===0?-5:x);if(G.strm=$,ne=G.last_flush,G.last_flush=H,G.status===j)if(G.wrap===2)$.adler=0,J(G,31),J(G,139),J(G,8),G.gzhead?(J(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)),J(G,255&G.gzhead.time),J(G,G.gzhead.time>>8&255),J(G,G.gzhead.time>>16&255),J(G,G.gzhead.time>>24&255),J(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),J(G,255&G.gzhead.os),G.gzhead.extra&&G.gzhead.extra.length&&(J(G,255&G.gzhead.extra.length),J(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):(J(G,0),J(G,0),J(G,0),J(G,0),J(G,0),J(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),J(G,3),G.status=q);else{var Ne=E+(G.w_bits-8<<4)<<8;Ne|=(2<=G.strategy||G.level<2?0:G.level<6?1:G.level===6?2:3)<<6,G.strstart!==0&&(Ne|=32),Ne+=31-Ne%31,G.status=q,se(G,Ne),G.strstart!==0&&(se(G,$.adler>>>16),se(G,65535&$.adler)),$.adler=1}if(G.status===69)if(G.gzhead.extra){for(Z=G.pending;G.gzindex<(65535&G.gzhead.extra.length)&&(G.pending!==G.pending_buf_size||(G.gzhead.hcrc&&G.pending>Z&&($.adler=u($.adler,G.pending_buf,G.pending-Z,Z)),U($),Z=G.pending,G.pending!==G.pending_buf_size));)J(G,255&G.gzhead.extra[G.gzindex]),G.gzindex++;G.gzhead.hcrc&&G.pending>Z&&($.adler=u($.adler,G.pending_buf,G.pending-Z,Z)),G.gzindex===G.gzhead.extra.length&&(G.gzindex=0,G.status=73)}else G.status=73;if(G.status===73)if(G.gzhead.name){Z=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>Z&&($.adler=u($.adler,G.pending_buf,G.pending-Z,Z)),U($),Z=G.pending,G.pending===G.pending_buf_size)){oe=1;break}oe=G.gzindex<G.gzhead.name.length?255&G.gzhead.name.charCodeAt(G.gzindex++):0,J(G,oe)}while(oe!==0);G.gzhead.hcrc&&G.pending>Z&&($.adler=u($.adler,G.pending_buf,G.pending-Z,Z)),oe===0&&(G.gzindex=0,G.status=91)}else G.status=91;if(G.status===91)if(G.gzhead.comment){Z=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>Z&&($.adler=u($.adler,G.pending_buf,G.pending-Z,Z)),U($),Z=G.pending,G.pending===G.pending_buf_size)){oe=1;break}oe=G.gzindex<G.gzhead.comment.length?255&G.gzhead.comment.charCodeAt(G.gzindex++):0,J(G,oe)}while(oe!==0);G.gzhead.hcrc&&G.pending>Z&&($.adler=u($.adler,G.pending_buf,G.pending-Z,Z)),oe===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&&(J(G,255&$.adler),J(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(ne)&&H!==g)return ee($,-5);if(G.status===666&&$.avail_in!==0)return ee($,-5);if($.avail_in!==0||G.lookahead!==0||H!==f&&G.status!==666){var Pe=G.strategy===2?(function(Se,B){for(var L;;){if(Se.lookahead===0&&(fe(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,te,ve,_e,be=Se.window;;){if(Se.lookahead<=D){if(fe(Se),Se.lookahead<=D&&B===f)return R;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=C&&0<Se.strstart&&(te=be[ve=Se.strstart-1])===be[++ve]&&te===be[++ve]&&te===be[++ve]){_e=Se.strstart+D;do;while(te===be[++ve]&&te===be[++ve]&&te===be[++ve]&&te===be[++ve]&&te===be[++ve]&&te===be[++ve]&&te===be[++ve]&&te===be[++ve]&&ve<_e);Se.match_length=D-(_e-ve),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(Pe!==K&&Pe!==V||(G.status=666),Pe===R||Pe===K)return $.avail_out===0&&(G.last_flush=-1),m;if(Pe===W&&(H===1?o._tr_align(G):H!==5&&(o._tr_stored_block(G,0,0,!1),H===3&&(Q(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?(J(G,255&$.adler),J(G,$.adler>>8&255),J(G,$.adler>>16&255),J(G,$.adler>>24&255),J(G,255&$.total_in),J(G,$.total_in>>8&255),J(G,$.total_in>>16&255),J(G,$.total_in>>24&255)):(se(G,$.adler>>>16),se(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?ee($,x):($.state=null,H===q?ee($,-3):m):x},i.deflateSetDictionary=function($,H){var ne,G,Z,oe,Ne,Pe,Se,B,L=H.length;if(!$||!$.state||(oe=(ne=$.state).wrap)===2||oe===1&&ne.status!==j||ne.lookahead)return x;for(oe===1&&($.adler=c($.adler,H,L,0)),ne.wrap=0,L>=ne.w_size&&(oe===0&&(Q(ne.head),ne.strstart=0,ne.block_start=0,ne.insert=0),B=new a.Buf8(ne.w_size),a.arraySet(B,H,L-ne.w_size,ne.w_size,0),H=B,L=ne.w_size),Ne=$.avail_in,Pe=$.next_in,Se=$.input,$.avail_in=L,$.next_in=0,$.input=H,fe(ne);ne.lookahead>=C;){for(G=ne.strstart,Z=ne.lookahead-(C-1);ne.ins_h=(ne.ins_h<<ne.hash_shift^ne.window[G+C-1])&ne.hash_mask,ne.prev[G&ne.w_mask]=ne.head[ne.ins_h],ne.head[ne.ins_h]=G,G++,--Z;);ne.strstart=G,ne.lookahead=C-1,fe(ne)}return ne.strstart+=ne.lookahead,ne.block_start=ne.strstart,ne.insert=ne.lookahead,ne.lookahead=0,ne.match_length=ne.prev_length=C-1,ne.match_available=0,$.next_in=Pe,$.input=Se,$.avail_in=Ne,ne.wrap=oe,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,c,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,c=s.next_in,R=s.input,u=c+(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[c++]<<S,S+=8,E+=R[c++]<<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[c++]<<S,S+=8),D+=E&(1<<C)-1,E>>>=C,S-=C),S<15&&(E+=R[c++]<<S,S+=8,E+=R[c++]<<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[c++]<<S,(S+=8)<C&&(E+=R[c++]<<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(c<u&&d<g);c-=D=S>>3,E&=(1<<(S-=D<<3))-1,s.next_in=c,s.next_out=d,s.avail_in=c<u?u-c+5:5-(c-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"),c=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,ee,Y,Q,U,z,J,se,me,fe,xe,Ee,re,we,Oe,he,ht,$,H,ne,G,Z=0,oe=new s.Buf8(4),Ne=[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),ee=j.next_out,K=j.output,Q=j.avail_out,V=j.next_in,W=j.input,Y=j.avail_in,U=R.hold,z=R.bits,J=Y,se=Q,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){oe[R.check=0]=255&U,oe[1]=U>>>8&255,R.check=o(R.check,oe,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&&(oe[0]=255&U,oe[1]=U>>>8&255,R.check=o(R.check,oe,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&&(oe[0]=255&U,oe[1]=U>>>8&255,oe[2]=U>>>16&255,oe[3]=U>>>24&255,R.check=o(R.check,oe,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&&(oe[0]=255&U,oe[1]=U>>>8&255,R.check=o(R.check,oe,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&&(oe[0]=255&U,oe[1]=U>>>8&255,R.check=o(R.check,oe,2,0)),z=U=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Y<(me=R.length)&&(me=Y),me&&(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,me,$)),512&R.flags&&(R.check=o(R.check,W,me,V)),Y-=me,V+=me,R.length-=me),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Y===0)break e;for(me=0;$=W[V+me++],R.head&&$&&R.length<65536&&(R.head.name+=String.fromCharCode($)),$&&me<Y;);if(512&R.flags&&(R.check=o(R.check,W,me,V)),Y-=me,V+=me,$)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(me=0;$=W[V+me++],R.head&&$&&R.length<65536&&(R.head.comment+=String.fromCharCode($)),$&&me<Y;);if(512&R.flags&&(R.check=o(R.check,W,me,V)),Y-=me,V+=me,$)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=ee,j.avail_out=Q,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(me=R.length){if(Y<me&&(me=Y),Q<me&&(me=Q),me===0)break e;s.arraySet(K,W,V,me,ee),Y-=me,V+=me,Q-=me,ee+=me,R.length-=me;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[Ne[R.have++]]=7&U,U>>>=3,z-=3}for(;R.have<19;)R.lens[Ne[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ne={bits:R.lenbits},H=u(0,R.lens,0,19,R.lencode,0,R.work,ne),R.lenbits=ne.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=(Z=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,we=65535&Z,!((Ee=Z>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(we<16)U>>>=Ee,z-=Ee,R.lens[R.have++]=we;else{if(we===16){for(G=Ee+2;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(U>>>=Ee,z-=Ee,R.have===0){j.msg="invalid bit length repeat",R.mode=30;break}$=R.lens[R.have-1],me=3+(3&U),U>>>=2,z-=2}else if(we===17){for(G=Ee+3;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}z-=Ee,$=0,me=3+(7&(U>>>=Ee)),U>>>=3,z-=3}else{for(G=Ee+7;z<G;){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}z-=Ee,$=0,me=11+(127&(U>>>=Ee)),U>>>=7,z-=7}if(R.have+me>R.nlen+R.ndist){j.msg="invalid bit length repeat",R.mode=30;break}for(;me--;)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,ne={bits:R.lenbits},H=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,ne),R.lenbits=ne.bits,H){j.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ne={bits:R.distbits},H=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ne),R.distbits=ne.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<=Q){j.next_out=ee,j.avail_out=Q,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,c(j,se),ee=j.next_out,K=j.output,Q=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=(Z=R.lencode[U&(1<<R.lenbits)-1])>>>16&255,we=65535&Z,!((Ee=Z>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if(re&&(240&re)==0){for(Oe=Ee,he=re,ht=we;re=(Z=R.lencode[ht+((U&(1<<Oe+he)-1)>>Oe)])>>>16&255,we=65535&Z,!(Oe+(Ee=Z>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}U>>>=Oe,z-=Oe,R.back+=Oe}if(U>>>=Ee,z-=Ee,R.back+=Ee,R.length=we,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=(Z=R.distcode[U&(1<<R.distbits)-1])>>>16&255,we=65535&Z,!((Ee=Z>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}if((240&re)==0){for(Oe=Ee,he=re,ht=we;re=(Z=R.distcode[ht+((U&(1<<Oe+he)-1)>>Oe)])>>>16&255,we=65535&Z,!(Oe+(Ee=Z>>>24)<=z);){if(Y===0)break e;Y--,U+=W[V++]<<z,z+=8}U>>>=Oe,z-=Oe,R.back+=Oe}if(U>>>=Ee,z-=Ee,R.back+=Ee,64&re){j.msg="invalid distance code",R.mode=30;break}R.offset=we,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(Q===0)break e;if(me=se-Q,R.offset>me){if((me=R.offset-me)>R.whave&&R.sane){j.msg="invalid distance too far back",R.mode=30;break}fe=me>R.wnext?(me-=R.wnext,R.wsize-me):R.wnext-me,me>R.length&&(me=R.length),xe=R.window}else xe=K,fe=ee-R.offset,me=R.length;for(Q<me&&(me=Q),Q-=me,R.length-=me;K[ee++]=xe[fe++],--me;);R.length===0&&(R.mode=21);break;case 26:if(Q===0)break e;K[ee++]=R.length,Q--,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(se-=Q,j.total_out+=se,R.total+=se,se&&(j.adler=R.check=R.flags?o(R.check,K,se,ee-se):a(R.check,K,se,ee-se)),se=Q,(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=ee,j.avail_out=Q,j.next_in=V,j.avail_in=Y,R.hold=U,R.bits=z,(R.wsize||se!==j.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&F(j,j.output,j.next_out,se-j.avail_out)?(R.mode=31,-4):(J-=j.avail_in,se-=j.avail_out,j.total_in+=J,j.total_out+=se,R.total+=se,R.wrap&&se&&(j.adler=R.check=R.flags?o(R.check,K,se,j.next_out-se):a(R.check,K,se,j.next_out-se)),j.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(J==0&&se===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],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,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,ee=0,Y=0,Q=0,U=0,z=null,J=0,se=new s.Buf16(16),me=new s.Buf16(16),fe=null,xe=0;for(j=0;j<=15;j++)se[j]=0;for(q=0;q<m;q++)se[f[g+q]]++;for(K=F,W=15;1<=W&&se[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&&se[R]===0;R++);for(K<R&&(K=R),j=Y=1;j<=15;j++)if(Y<<=1,(Y-=se[j])<0)return-1;if(0<Y&&(d===0||W!==1))return-1;for(me[1]=0,j=1;j<15;j++)me[j+1]=me[j]+se[j];for(q=0;q<m;q++)f[g+q]!==0&&(v[me[f[g+q]]++]=q);if(N=d===0?(z=fe=v,19):d===1?(z=a,J-=257,fe=o,xe-=257,256):(z=c,fe=u,-1),j=R,k=y,ee=q=U=0,A=-1,T=(Q=1<<(V=K))-1,d===1&&852<Q||d===2&&592<Q)return 1;for(;;){for(I=j-ee,D=v[q]<N?(C=0,v[q]):v[q]>N?(C=fe[xe+v[q]],z[J+v[q]]):(C=96,0),E=1<<j-ee,R=S=1<<V;x[k+(U>>ee)+(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++,--se[j]==0){if(j===W)break;j=f[g+v[q]]}if(K<j&&(U&T)!==A){for(ee===0&&(ee=K),k+=R,Y=1<<(V=j-ee);V+ee<W&&!((Y-=se[V+ee])<=0);)V++,Y<<=1;if(Q+=1<<V,d===1&&852<Q||d===2&&592<Q)return 1;x[A=U&T]=K<<24|V<<16|k-y|0}}return U!==0&&(x[k+U]=j-ee<<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 c(Z){for(var oe=Z.length;0<=--oe;)Z[oe]=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));c(F);var j=new Array(2*m);c(j);var q=new Array(512);c(q);var R=new Array(256);c(R);var W=new Array(d);c(W);var K,V,ee,Y=new Array(m);function Q(Z,oe,Ne,Pe,Se){this.static_tree=Z,this.extra_bits=oe,this.extra_base=Ne,this.elems=Pe,this.max_length=Se,this.has_stree=Z&&Z.length}function U(Z,oe){this.dyn_tree=Z,this.max_code=0,this.stat_desc=oe}function z(Z){return Z<256?q[Z]:q[256+(Z>>>7)]}function J(Z,oe){Z.pending_buf[Z.pending++]=255&oe,Z.pending_buf[Z.pending++]=oe>>>8&255}function se(Z,oe,Ne){Z.bi_valid>b-Ne?(Z.bi_buf|=oe<<Z.bi_valid&65535,J(Z,Z.bi_buf),Z.bi_buf=oe>>b-Z.bi_valid,Z.bi_valid+=Ne-b):(Z.bi_buf|=oe<<Z.bi_valid&65535,Z.bi_valid+=Ne)}function me(Z,oe,Ne){se(Z,Ne[2*oe],Ne[2*oe+1])}function fe(Z,oe){for(var Ne=0;Ne|=1&Z,Z>>>=1,Ne<<=1,0<--oe;);return Ne>>>1}function xe(Z,oe,Ne){var Pe,Se,B=new Array(v+1),L=0;for(Pe=1;Pe<=v;Pe++)B[Pe]=L=L+Ne[Pe-1]<<1;for(Se=0;Se<=oe;Se++){var te=Z[2*Se+1];te!==0&&(Z[2*Se]=fe(B[te]++,te))}}function Ee(Z){var oe;for(oe=0;oe<g;oe++)Z.dyn_ltree[2*oe]=0;for(oe=0;oe<m;oe++)Z.dyn_dtree[2*oe]=0;for(oe=0;oe<x;oe++)Z.bl_tree[2*oe]=0;Z.dyn_ltree[2*S]=1,Z.opt_len=Z.static_len=0,Z.last_lit=Z.matches=0}function re(Z){8<Z.bi_valid?J(Z,Z.bi_buf):0<Z.bi_valid&&(Z.pending_buf[Z.pending++]=Z.bi_buf),Z.bi_buf=0,Z.bi_valid=0}function we(Z,oe,Ne,Pe){var Se=2*oe,B=2*Ne;return Z[Se]<Z[B]||Z[Se]===Z[B]&&Pe[oe]<=Pe[Ne]}function Oe(Z,oe,Ne){for(var Pe=Z.heap[Ne],Se=Ne<<1;Se<=Z.heap_len&&(Se<Z.heap_len&&we(oe,Z.heap[Se+1],Z.heap[Se],Z.depth)&&Se++,!we(oe,Pe,Z.heap[Se],Z.depth));)Z.heap[Ne]=Z.heap[Se],Ne=Se,Se<<=1;Z.heap[Ne]=Pe}function he(Z,oe,Ne){var Pe,Se,B,L,te=0;if(Z.last_lit!==0)for(;Pe=Z.pending_buf[Z.d_buf+2*te]<<8|Z.pending_buf[Z.d_buf+2*te+1],Se=Z.pending_buf[Z.l_buf+te],te++,Pe===0?me(Z,Se,oe):(me(Z,(B=R[Se])+f+1,oe),(L=N[B])!==0&&se(Z,Se-=W[B],L),me(Z,B=z(--Pe),Ne),(L=I[B])!==0&&se(Z,Pe-=Y[B],L)),te<Z.last_lit;);me(Z,S,oe)}function ht(Z,oe){var Ne,Pe,Se,B=oe.dyn_tree,L=oe.stat_desc.static_tree,te=oe.stat_desc.has_stree,ve=oe.stat_desc.elems,_e=-1;for(Z.heap_len=0,Z.heap_max=y,Ne=0;Ne<ve;Ne++)B[2*Ne]!==0?(Z.heap[++Z.heap_len]=_e=Ne,Z.depth[Ne]=0):B[2*Ne+1]=0;for(;Z.heap_len<2;)B[2*(Se=Z.heap[++Z.heap_len]=_e<2?++_e:0)]=1,Z.depth[Se]=0,Z.opt_len--,te&&(Z.static_len-=L[2*Se+1]);for(oe.max_code=_e,Ne=Z.heap_len>>1;1<=Ne;Ne--)Oe(Z,B,Ne);for(Se=ve;Ne=Z.heap[1],Z.heap[1]=Z.heap[Z.heap_len--],Oe(Z,B,1),Pe=Z.heap[1],Z.heap[--Z.heap_max]=Ne,Z.heap[--Z.heap_max]=Pe,B[2*Se]=B[2*Ne]+B[2*Pe],Z.depth[Se]=(Z.depth[Ne]>=Z.depth[Pe]?Z.depth[Ne]:Z.depth[Pe])+1,B[2*Ne+1]=B[2*Pe+1]=Se,Z.heap[1]=Se++,Oe(Z,B,1),2<=Z.heap_len;);Z.heap[--Z.heap_max]=Z.heap[1],(function(be,nt){var Be,ue,Ve,Ue,ae,Je,He=nt.dyn_tree,Ke=nt.max_code,ct=nt.stat_desc.static_tree,de=nt.stat_desc.has_stree,Ye=nt.stat_desc.extra_bits,ge=nt.stat_desc.extra_base,Fe=nt.stat_desc.max_length,Ce=0;for(Ue=0;Ue<=v;Ue++)be.bl_count[Ue]=0;for(He[2*be.heap[be.heap_max]+1]=0,Be=be.heap_max+1;Be<y;Be++)Fe<(Ue=He[2*He[2*(ue=be.heap[Be])+1]+1]+1)&&(Ue=Fe,Ce++),He[2*ue+1]=Ue,Ke<ue||(be.bl_count[Ue]++,ae=0,ge<=ue&&(ae=Ye[ue-ge]),Je=He[2*ue],be.opt_len+=Je*(Ue+ae),de&&(be.static_len+=Je*(ct[2*ue+1]+ae)));if(Ce!==0){do{for(Ue=Fe-1;be.bl_count[Ue]===0;)Ue--;be.bl_count[Ue]--,be.bl_count[Ue+1]+=2,be.bl_count[Fe]--,Ce-=2}while(0<Ce);for(Ue=Fe;Ue!==0;Ue--)for(ue=be.bl_count[Ue];ue!==0;)Ke<(Ve=be.heap[--Be])||(He[2*Ve+1]!==Ue&&(be.opt_len+=(Ue-He[2*Ve+1])*He[2*Ve],He[2*Ve+1]=Ue),ue--)}})(Z,oe),xe(B,_e,Z.bl_count)}function $(Z,oe,Ne){var Pe,Se,B=-1,L=oe[1],te=0,ve=7,_e=4;for(L===0&&(ve=138,_e=3),oe[2*(Ne+1)+1]=65535,Pe=0;Pe<=Ne;Pe++)Se=L,L=oe[2*(Pe+1)+1],++te<ve&&Se===L||(te<_e?Z.bl_tree[2*Se]+=te:Se!==0?(Se!==B&&Z.bl_tree[2*Se]++,Z.bl_tree[2*A]++):te<=10?Z.bl_tree[2*T]++:Z.bl_tree[2*k]++,B=Se,_e=(te=0)===L?(ve=138,3):Se===L?(ve=6,3):(ve=7,4))}function H(Z,oe,Ne){var Pe,Se,B=-1,L=oe[1],te=0,ve=7,_e=4;for(L===0&&(ve=138,_e=3),Pe=0;Pe<=Ne;Pe++)if(Se=L,L=oe[2*(Pe+1)+1],!(++te<ve&&Se===L)){if(te<_e)for(;me(Z,Se,Z.bl_tree),--te!=0;);else Se!==0?(Se!==B&&(me(Z,Se,Z.bl_tree),te--),me(Z,A,Z.bl_tree),se(Z,te-3,2)):te<=10?(me(Z,T,Z.bl_tree),se(Z,te-3,3)):(me(Z,k,Z.bl_tree),se(Z,te-11,7));B=Se,_e=(te=0)===L?(ve=138,3):Se===L?(ve=6,3):(ve=7,4)}}c(Y);var ne=!1;function G(Z,oe,Ne,Pe){se(Z,(u<<1)+(Pe?1:0),3),(function(Se,B,L,te){re(Se),J(Se,L),J(Se,~L),s.arraySet(Se.pending_buf,Se.window,B,L,Se.pending),Se.pending+=L})(Z,oe,Ne)}i._tr_init=function(Z){ne||((function(){var oe,Ne,Pe,Se,B,L=new Array(v+1);for(Se=Pe=0;Se<d-1;Se++)for(W[Se]=Pe,oe=0;oe<1<<N[Se];oe++)R[Pe++]=Se;for(R[Pe-1]=Se,Se=B=0;Se<16;Se++)for(Y[Se]=B,oe=0;oe<1<<I[Se];oe++)q[B++]=Se;for(B>>=7;Se<m;Se++)for(Y[Se]=B<<7,oe=0;oe<1<<I[Se]-7;oe++)q[256+B++]=Se;for(Ne=0;Ne<=v;Ne++)L[Ne]=0;for(oe=0;oe<=143;)F[2*oe+1]=8,oe++,L[8]++;for(;oe<=255;)F[2*oe+1]=9,oe++,L[9]++;for(;oe<=279;)F[2*oe+1]=7,oe++,L[7]++;for(;oe<=287;)F[2*oe+1]=8,oe++,L[8]++;for(xe(F,g+1,L),oe=0;oe<m;oe++)j[2*oe+1]=5,j[2*oe]=fe(oe,5);K=new Q(F,N,f+1,g,v),V=new Q(j,I,0,m,v),ee=new Q(new Array(0),C,0,x,E)})(),ne=!0),Z.l_desc=new U(Z.dyn_ltree,K),Z.d_desc=new U(Z.dyn_dtree,V),Z.bl_desc=new U(Z.bl_tree,ee),Z.bi_buf=0,Z.bi_valid=0,Ee(Z)},i._tr_stored_block=G,i._tr_flush_block=function(Z,oe,Ne,Pe){var Se,B,L=0;0<Z.level?(Z.strm.data_type===2&&(Z.strm.data_type=(function(te){var ve,_e=4093624447;for(ve=0;ve<=31;ve++,_e>>>=1)if(1&_e&&te.dyn_ltree[2*ve]!==0)return a;if(te.dyn_ltree[18]!==0||te.dyn_ltree[20]!==0||te.dyn_ltree[26]!==0)return o;for(ve=32;ve<f;ve++)if(te.dyn_ltree[2*ve]!==0)return o;return a})(Z)),ht(Z,Z.l_desc),ht(Z,Z.d_desc),L=(function(te){var ve;for($(te,te.dyn_ltree,te.l_desc.max_code),$(te,te.dyn_dtree,te.d_desc.max_code),ht(te,te.bl_desc),ve=x-1;3<=ve&&te.bl_tree[2*D[ve]+1]===0;ve--);return te.opt_len+=3*(ve+1)+5+5+4,ve})(Z),Se=Z.opt_len+3+7>>>3,(B=Z.static_len+3+7>>>3)<=Se&&(Se=B)):Se=B=Ne+5,Ne+4<=Se&&oe!==-1?G(Z,oe,Ne,Pe):Z.strategy===4||B===Se?(se(Z,2+(Pe?1:0),3),he(Z,F,j)):(se(Z,4+(Pe?1:0),3),(function(te,ve,_e,be){var nt;for(se(te,ve-257,5),se(te,_e-1,5),se(te,be-4,4),nt=0;nt<be;nt++)se(te,te.bl_tree[2*D[nt]+1],3);H(te,te.dyn_ltree,ve-1),H(te,te.dyn_dtree,_e-1)})(Z,Z.l_desc.max_code+1,Z.d_desc.max_code+1,L+1),he(Z,Z.dyn_ltree,Z.dyn_dtree)),Ee(Z),Pe&&re(Z)},i._tr_tally=function(Z,oe,Ne){return Z.pending_buf[Z.d_buf+2*Z.last_lit]=oe>>>8&255,Z.pending_buf[Z.d_buf+2*Z.last_lit+1]=255&oe,Z.pending_buf[Z.l_buf+Z.last_lit]=255&Ne,Z.last_lit++,oe===0?Z.dyn_ltree[2*Ne]++:(Z.matches++,oe--,Z.dyn_ltree[2*(R[Ne]+f+1)]++,Z.dyn_dtree[2*z(oe)]++),Z.last_lit===Z.lit_bufsize-1},i._tr_align=function(Z){se(Z,2,3),me(Z,S,F),(function(oe){oe.bi_valid===16?(J(oe,oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0):8<=oe.bi_valid&&(oe.pending_buf[oe.pending++]=255&oe.bi_buf,oe.bi_buf>>=8,oe.bi_valid-=8)})(Z)}},{"../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 c,u,d,f,g=1,m={},x=!1,y=a.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(a);v=v&&v.setTimeout?v:a,c={}.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,c(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 hy<"u"?hy:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(GC)),GC.exports}var nOe=tOe();const rOe=fo(nOe);function iOe(t){const e=new ri;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 jH=iOe;async function LH(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 c=i.getElementsByTagName("triangle");for(let u=0;u<c.length;u++){const d=c[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 sOe(t){const e=await rOe.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 LH(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 c=o.getElementsByTagName("object");for(let d=0;d<c.length;d++){const f=c[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 LH(S),T=b.getAttribute("transform"),k=jH(T);for(const N of A)if(T){const I=[];for(let C=0;C<N.vertices.length;C+=3){const D=new Qe(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=jH(g.getAttribute("transform"));r.push({objectId:m,transform:x})}}return{objects:n,buildItems:r}}function IH(t){const e=new Ml,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 io(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function aOe({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),[c,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 INe;b.background=new _n(1710618),s.current=b;const E=new Ya(45,y/v,.1,1e4);E.position.set(150,150,150),a.current=E;const S=new FDe({antialias:!0});S.setSize(y,v),S.setPixelRatio(window.devicePixelRatio),x.appendChild(S.domElement),i.current=S;const A=new BDe(E,S.domElement);A.enableDamping=!0,A.dampingFactor=.05,o.current=A;const T=new XNe(16777215,.6);b.add(T);const k=new sH(16777215,.8);k.position.set(100,100,100),b.add(k);const N=new sH(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 lj(e.x,e.y),j=new sj({color:44610,transparent:!0,opacity:.15,side:rl}),q=new xl(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(sOe).then(({objects:V,buildItems:ee})=>{if(V.size===0)throw new Error("No meshes found in 3MF file");const Y=new VNe({color:44610,shininess:30,flatShading:!1}),Q=new Lx,U=[];if(ee.length>0)for(const re of ee){const we=V.get(re.objectId);if(we)for(const Oe of we.meshes){const he=[];for(let $=0;$<Oe.vertices.length;$+=3){const H=new Qe(Oe.vertices[$],Oe.vertices[$+1],Oe.vertices[$+2]);H.applyMatrix4(re.transform),he.push(H.x,H.y,H.z)}const ht=IH({vertices:he,triangles:Oe.triangles});U.push(ht)}}else for(const re of V.values())for(const we of re.meshes){const Oe=IH(we);U.push(Oe)}if(U.length>0){const re=U.length===1?U[0]:eOe(U,!1);if(re){const we=new xl(re,Y);Q.add(we)}if(U.length>1)for(const we of U)we.dispose()}const z=new tf().setFromObject(Q),J=z.getCenter(new Qe);Q.position.y=-z.min.y,ee.length===0&&(Q.position.x=-J.x,Q.position.z=-J.z),b.add(Q);const se=new tf().setFromObject(Q),me=se.getCenter(new Qe),fe=se.getSize(new Qe),Ee=Math.max(fe.x,fe.y,fe.z)*1.8;E.position.set(me.x+Ee*.7,me.y+Ee*.5,me.z+Ee*.7),A.target.copy(me),A.update(),u(!1)}).catch(V=>{f(V.message),u(!1)});const K=()=>{if(!x)return;const V=x.clientWidth,ee=x.clientHeight;E.aspect=V/ee,E.updateProjectionMatrix(),S.setSize(V,ee)};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 l.jsxs("div",{className:`relative ${n}`,children:[l.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),c&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx("p",{className:"text-red-400",children:d})}),!c&&!d&&l.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:l.jsx(Uue,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:l.jsx(Bue,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:g,children:l.jsx(Xm,{className:"w-4 h-4"})})]})]})}const BE="159",mp={ROTATE:0,DOLLY:1,PAN:2},gp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},oOe=0,UH=1,lOe=2,wZ=1,cOe=2,sc=3,fd=0,Xs=1,dc=2,Yu=0,am=1,FH=2,zH=3,BH=4,uOe=5,lh=100,dOe=101,hOe=102,HH=103,$H=104,fOe=200,pOe=201,mOe=202,gOe=203,MP=204,AP=205,xOe=206,bOe=207,vOe=208,yOe=209,_Oe=210,wOe=211,SOe=212,EOe=213,MOe=214,AOe=0,TOe=1,COe=2,Dw=3,NOe=4,kOe=5,POe=6,ROe=7,uj=0,DOe=1,OOe=2,Zu=0,jOe=1,LOe=2,IOe=3,UOe=4,FOe=5,SZ=300,Rm=301,Dm=302,TP=303,CP=304,HE=306,NP=1e3,ko=1001,kP=1002,Zi=1003,VH=1004,WC=1005,Za=1006,zOe=1007,K0=1008,Qu=1009,BOe=1010,HOe=1011,dj=1012,EZ=1013,Bu=1014,xc=1015,X0=1016,MZ=1017,AZ=1018,Nh=1020,$Oe=1021,Qa=1023,VOe=1024,GOe=1025,kh=1026,Om=1027,WOe=1028,TZ=1029,qOe=1030,CZ=1031,NZ=1033,qC=33776,KC=33777,XC=33778,YC=33779,GH=35840,WH=35841,qH=35842,KH=35843,kZ=36196,XH=37492,YH=37496,ZH=37808,QH=37809,JH=37810,e$=37811,t$=37812,n$=37813,r$=37814,i$=37815,s$=37816,a$=37817,o$=37818,l$=37819,c$=37820,u$=37821,ZC=36492,d$=36494,h$=36495,KOe=36283,f$=36284,p$=36285,m$=36286,PZ=3e3,Ph=3001,XOe=3200,YOe=3201,RZ=0,ZOe=1,Ja="",Qi="srgb",Lc="srgb-linear",hj="display-p3",$E="display-p3-linear",Ow="linear",lr="srgb",jw="rec709",Lw="p3",xp=7680,g$=519,QOe=512,JOe=513,eje=514,DZ=515,tje=516,nje=517,rje=518,ije=519,PP=35044,x$="300 es",RP=1035,ll=2e3,Y0=2001;class gf{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 ls=["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 b$=1234567;const Kx=Math.PI/180,Z0=180/Math.PI;function Ec(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ls[t&255]+ls[t>>8&255]+ls[t>>16&255]+ls[t>>24&255]+"-"+ls[e&255]+ls[e>>8&255]+"-"+ls[e>>16&15|64]+ls[e>>24&255]+"-"+ls[n&63|128]+ls[n>>8&255]+"-"+ls[n>>16&255]+ls[n>>24&255]+ls[r&255]+ls[r>>8&255]+ls[r>>16&255]+ls[r>>24&255]).toLowerCase()}function Ji(t,e,n){return Math.max(e,Math.min(n,t))}function fj(t,e){return(t%e+e)%e}function sje(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function aje(t,e,n){return t!==e?(n-t)/(e-t):0}function Xx(t,e,n){return(1-n)*t+n*e}function oje(t,e,n,r){return Xx(t,e,1-Math.exp(-n*r))}function lje(t,e=1){return e-Math.abs(fj(t,e*2)-e)}function cje(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function uje(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function dje(t,e){return t+Math.floor(Math.random()*(e-t+1))}function hje(t,e){return t+Math.random()*(e-t)}function fje(t){return t*(.5-Math.random())}function pje(t){t!==void 0&&(b$=t);let e=b$+=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 mje(t){return t*Kx}function gje(t){return t*Z0}function DP(t){return(t&t-1)===0&&t!==0}function xje(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Iw(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function bje(t,e,n,r,i){const s=Math.cos,a=Math.sin,o=s(n/2),c=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,c*f,c*g,o*u);break;case"YZY":t.set(c*g,o*d,c*f,o*u);break;case"ZXZ":t.set(c*f,c*g,o*d,o*u);break;case"XZX":t.set(o*d,c*x,c*m,o*u);break;case"YXY":t.set(c*m,o*d,c*x,o*u);break;case"ZYZ":t.set(c*x,c*m,o*d,o*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function il(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Kn(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 OZ={DEG2RAD:Kx,RAD2DEG:Z0,generateUUID:Ec,clamp:Ji,euclideanModulo:fj,mapLinear:sje,inverseLerp:aje,lerp:Xx,damp:oje,pingpong:lje,smoothstep:cje,smootherstep:uje,randInt:dje,randFloat:hje,randFloatSpread:fje,seededRandom:pje,degToRad:mje,radToDeg:gje,isPowerOfTwo:DP,ceilPowerOfTwo:xje,floorPowerOfTwo:Iw,setQuaternionFromProperEuler:bje,normalize:Kn,denormalize:il};class Zt{constructor(e=0,n=0){Zt.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ji(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,n,r,i,s,a,o,c,u){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,s,a,o,c,u)}set(e,n,r,i,s,a,o,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=o,d[3]=n,d[4]=s,d[5]=c,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],c=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+c*T,s[3]=a*v+o*S+c*k,s[6]=a*b+o*A+c*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],c=e[6],u=e[7],d=e[8];return n*a*d-n*o*u-r*s*d+r*o*c+i*s*u-i*a*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=d*a-o*u,g=o*c-d*s,m=u*s-a*c,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*c)*y,e[5]=(i*s-o*n)*y,e[6]=m*y,e[7]=(r*c-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 c=Math.cos(s),u=Math.sin(s);return this.set(r*c,r*u,-r*(c*a+u*o)+a+e,-i*u,i*c,-i*(-u*a+c*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(QC.makeScale(e,n)),this}rotate(e){return this.premultiply(QC.makeRotation(-e)),this}translate(e,n){return this.premultiply(QC.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 QC=new fn;function jZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Uw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function vje(){const t=Uw("canvas");return t.style.display="block",t}const v$={};function Yx(t){t in v$||(v$[t]=!0,console.warn(t))}const y$=new fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),_$=new fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),s_={[Lc]:{transfer:Ow,primaries:jw,toReference:t=>t,fromReference:t=>t},[Qi]:{transfer:lr,primaries:jw,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[$E]:{transfer:Ow,primaries:Lw,toReference:t=>t.applyMatrix3(_$),fromReference:t=>t.applyMatrix3(y$)},[hj]:{transfer:lr,primaries:Lw,toReference:t=>t.convertSRGBToLinear().applyMatrix3(_$),fromReference:t=>t.applyMatrix3(y$).convertLinearToSRGB()}},yje=new Set([Lc,$E]),Xn={enabled:!0,_workingColorSpace:Lc,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(!yje.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=s_[e].toReference,i=s_[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 s_[t].primaries},getTransfer:function(t){return t===Ja?Ow:s_[t].transfer}};function om(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function JC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let bp;class LZ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{bp===void 0&&(bp=Uw("canvas")),bp.width=e.width,bp.height=e.height;const r=bp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=bp}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=Uw("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]=om(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(om(n[r]/255)*255):n[r]=om(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 _je=0;class IZ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:_je++}),this.uuid=Ec(),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(eN(i[a].image)):s.push(eN(i[a]))}else s=eN(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function eN(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?LZ.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 wje=0;class Ys extends gf{constructor(e=Ys.DEFAULT_IMAGE,n=Ys.DEFAULT_MAPPING,r=ko,i=ko,s=Za,a=K0,o=Qa,c=Qu,u=Ys.DEFAULT_ANISOTROPY,d=Ja){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wje++}),this.uuid=Ec(),this.name="",this.source=new IZ(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=c,this.offset=new Zt(0,0),this.repeat=new Zt(1,1),this.center=new Zt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new fn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Ph?Qi:Ja),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!==SZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case NP:e.x=e.x-Math.floor(e.x);break;case ko:e.x=e.x<0?0:1;break;case kP: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 NP:e.y=e.y-Math.floor(e.y);break;case ko:e.y=e.y<0?0:1;break;case kP: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 Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Qi?Ph:PZ}set encoding(e){Yx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ph?Qi:Ja}}Ys.DEFAULT_IMAGE=null;Ys.DEFAULT_MAPPING=SZ;Ys.DEFAULT_ANISOTROPY=1;class Zn{constructor(e=0,n=0,r=0,i=1){Zn.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 c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],m=c[5],x=c[9],y=c[2],v=c[6],b=c[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 Sje extends gf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Zn(0,0,e,n),this.scissorTest=!1,this.viewport=new Zn(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Yx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Ph?Qi:Ja),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Za,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Ys(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 IZ(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 nf extends Sje{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class UZ extends Ys{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Zi,this.minFilter=Zi,this.wrapR=ko,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Eje extends Ys{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Zi,this.minFilter=Zi,this.wrapR=ko,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class rf{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 c=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]=c,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||c!==g||u!==m||d!==x){let v=1-o;const b=c*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(c=c*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(c*c+u*u+d*d+f*f);c*=T,u*=T,d*=T,f*=T}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,s,a){const o=r[i],c=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+c*m-u*g,e[n+1]=c*x+d*g+u*f-o*m,e[n+2]=u*x+d*m+o*g-c*f,e[n+3]=d*x-o*f-c*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,c=Math.sin,u=o(r/2),d=o(i/2),f=o(s/2),g=c(r/2),m=c(i/2),x=c(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],c=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-c)*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-c)/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=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-o);this._w=(a-i)/m,this._x=(s+u)/m,this._y=(c+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(Ji(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,s=e._z,a=e._w,o=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+a*o+i*u-s*c,this._y=i*d+a*c+s*o-r*u,this._z=s*d+a*u+r*c-i*o,this._w=a*d-r*o-i*c-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 c=1-o*o;if(c<=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(c),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(w$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(w$.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,c=e.w,u=2*(a*i-o*r),d=2*(o*n-s*i),f=2*(s*r-a*n);return this.x=n+c*u+a*f-o*d,this.y=r+c*d+o*u-s*f,this.z=i+c*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,c=n.z;return this.x=i*c-s*o,this.y=s*a-r*c,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 tN.copy(this).projectOnVector(e),this.sub(tN)}reflect(e){return this.sub(tN.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ji(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const tN=new De,w$=new rf;class so{constructor(e=new De(1/0,1/0,1/0),n=new De(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(So.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(So.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=So.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,So):So.fromBufferAttribute(s,a),So.applyMatrix4(e.matrixWorld),this.expandByPoint(So);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),a_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),a_.copy(r.boundingBox)),a_.applyMatrix4(e.matrixWorld),this.union(a_)}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,So),So.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(Sx),o_.subVectors(this.max,Sx),vp.subVectors(e.a,Sx),yp.subVectors(e.b,Sx),_p.subVectors(e.c,Sx),bu.subVectors(yp,vp),vu.subVectors(_p,yp),Kd.subVectors(vp,_p);let n=[0,-bu.z,bu.y,0,-vu.z,vu.y,0,-Kd.z,Kd.y,bu.z,0,-bu.x,vu.z,0,-vu.x,Kd.z,0,-Kd.x,-bu.y,bu.x,0,-vu.y,vu.x,0,-Kd.y,Kd.x,0];return!nN(n,vp,yp,_p,o_)||(n=[1,0,0,0,1,0,0,0,1],!nN(n,vp,yp,_p,o_))?!1:(l_.crossVectors(bu,vu),n=[l_.x,l_.y,l_.z],nN(n,vp,yp,_p,o_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,So).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(So).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:(Yl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Yl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Yl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Yl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Yl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Yl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Yl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Yl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Yl),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 Yl=[new De,new De,new De,new De,new De,new De,new De,new De],So=new De,a_=new so,vp=new De,yp=new De,_p=new De,bu=new De,vu=new De,Kd=new De,Sx=new De,o_=new De,l_=new De,Xd=new De;function nN(t,e,n,r,i){for(let s=0,a=t.length-3;s<=a;s+=3){Xd.fromArray(t,s);const o=i.x*Math.abs(Xd.x)+i.y*Math.abs(Xd.y)+i.z*Math.abs(Xd.z),c=e.dot(Xd),u=n.dot(Xd),d=r.dot(Xd);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>o)return!1}return!0}const Mje=new so,Ex=new De,rN=new De;class ul{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):Mje.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;Ex.subVectors(e,this.center);const n=Ex.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Ex,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):(rN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ex.copy(e.center).add(rN)),this.expandByPoint(Ex.copy(e.center).sub(rN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Zl=new De,iN=new De,c_=new De,yu=new De,sN=new De,u_=new De,aN=new De;class pj{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,Zl)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Zl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Zl.copy(this.origin).addScaledVector(this.direction,n),Zl.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){iN.copy(e).add(n).multiplyScalar(.5),c_.copy(n).sub(e).normalize(),yu.copy(this.origin).sub(iN);const s=e.distanceTo(n)*.5,a=-this.direction.dot(c_),o=yu.dot(this.direction),c=-yu.dot(c_),u=yu.lengthSq(),d=Math.abs(1-a*a);let f,g,m,x;if(d>0)if(f=a*c-o,g=a*o-c,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*c)+u}else g=s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*c)+u;else g=-s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-a*s+o)),g=f>0?-s:Math.min(Math.max(-s,-c),s),m=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-s,-c),s),m=g*(g+2*c)+u):(f=Math.max(0,-(a*s+o)),g=f>0?s:Math.min(Math.max(-s,-c),s),m=-f*f+g*(g+2*c)+u);else g=a>0?-s:s,f=Math.max(0,-(a*g+o)),m=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(iN).addScaledVector(c_,g),m}intersectSphere(e,n){Zl.subVectors(e.center,this.origin);const r=Zl.dot(this.direction),i=Zl.dot(Zl)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,c=r+a;return c<0?null:o<0?this.at(c,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,s,a,o,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(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,c=(e.max.z-g.z)*f):(o=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||o>i)||((o>r||r!==r)&&(r=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Zl)!==null}intersectTriangle(e,n,r,i,s){sN.subVectors(n,e),u_.subVectors(r,e),aN.crossVectors(sN,u_);let a=this.direction.dot(aN),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;yu.subVectors(this.origin,e);const c=o*this.direction.dot(u_.crossVectors(yu,u_));if(c<0)return null;const u=o*this.direction.dot(sN.cross(yu));if(u<0||c+u>a)return null;const d=-o*yu.dot(aN);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,c,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,c,u,d,f,g,m,x,y,v)}set(e,n,r,i,s,a,o,c,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]=c,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/wp.setFromMatrixColumn(e,0).length(),s=1/wp.setFromMatrixColumn(e,1).length(),a=1/wp.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),c=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]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=g-y*u,n[9]=-o*c,n[2]=y-g*u,n[6]=x+m*u,n[10]=a*c}else if(e.order==="YXZ"){const g=c*d,m=c*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*c}else if(e.order==="ZXY"){const g=c*d,m=c*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*c}else if(e.order==="ZYX"){const g=a*d,m=a*f,x=o*d,y=o*f;n[0]=c*d,n[4]=x*u-m,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=m*u-x,n[2]=-u,n[6]=o*c,n[10]=a*c}else if(e.order==="YZX"){const g=a*c,m=a*u,x=o*c,y=o*u;n[0]=c*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*c,m=a*u,x=o*c,y=o*u;n[0]=c*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(Aje,e,Tje)}lookAt(e,n,r){const i=this.elements;return da.subVectors(e,n),da.lengthSq()===0&&(da.z=1),da.normalize(),_u.crossVectors(r,da),_u.lengthSq()===0&&(Math.abs(r.z)===1?da.x+=1e-4:da.z+=1e-4,da.normalize(),_u.crossVectors(r,da)),_u.normalize(),d_.crossVectors(da,_u),i[0]=_u.x,i[4]=d_.x,i[8]=da.x,i[1]=_u.y,i[5]=d_.y,i[9]=da.y,i[2]=_u.z,i[6]=d_.z,i[10]=da.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],c=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],ee=i[3],Y=i[7],Q=i[11],U=i[15];return s[0]=a*k+o*D+c*R+u*ee,s[4]=a*N+o*F+c*W+u*Y,s[8]=a*I+o*j+c*K+u*Q,s[12]=a*C+o*q+c*V+u*U,s[1]=d*k+f*D+g*R+m*ee,s[5]=d*N+f*F+g*W+m*Y,s[9]=d*I+f*j+g*K+m*Q,s[13]=d*C+f*q+g*V+m*U,s[2]=x*k+y*D+v*R+b*ee,s[6]=x*N+y*F+v*W+b*Y,s[10]=x*I+y*j+v*K+b*Q,s[14]=x*C+y*q+v*V+b*U,s[3]=E*k+S*D+A*R+T*ee,s[7]=E*N+S*F+A*W+T*Y,s[11]=E*I+S*j+A*K+T*Q,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],c=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*c*f-i*u*f-s*o*g+r*u*g+i*o*m-r*c*m)+y*(+n*c*m-n*u*g+s*a*g-i*a*m+i*u*d-s*c*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*c*f+n*o*g+i*a*f-r*a*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=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*c*m-o*v*m-f*c*b+o*g*b,S=x*g*u-d*v*u-x*c*m+a*v*m+d*c*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*c-d*y*c-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*c*s+y*i*u-r*v*u-o*i*b+r*c*b)*N,e[3]=(f*c*s-o*g*s-f*i*u+r*g*u+o*i*m-r*c*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*c*s-a*v*s-x*i*u+n*v*u+a*i*b-n*c*b)*N,e[7]=(a*g*s-d*c*s+d*i*u-n*g*u-a*i*m+n*c*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*c+n*y*c+a*r*v-n*o*v)*N,e[15]=(a*f*i-d*o*i+d*r*c-n*f*c-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,c=e.z,u=s*a,d=s*o;return this.set(u*a+r,u*o-i*c,u*c+i*o,0,u*o+i*c,d*o+r,d*c-i*a,0,u*c-i*o,d*c+i*a,s*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,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,c=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=c*u,S=c*d,A=c*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=wp.set(i[0],i[1],i[2]).length();const a=wp.set(i[4],i[5],i[6]).length(),o=wp.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],Eo.copy(this);const u=1/s,d=1/a,f=1/o;return Eo.elements[0]*=u,Eo.elements[1]*=u,Eo.elements[2]*=u,Eo.elements[4]*=d,Eo.elements[5]*=d,Eo.elements[6]*=d,Eo.elements[8]*=f,Eo.elements[9]*=f,Eo.elements[10]*=f,n.setFromRotationMatrix(Eo),r.x=s,r.y=a,r.z=o,this}makePerspective(e,n,r,i,s,a,o=ll){const c=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===ll)m=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===Y0)m=-a/(a-s),x=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,a,o=ll){const c=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===ll)x=(a+s)*f,y=-2*f;else if(o===Y0)x=s*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-g,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=y,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const wp=new De,Eo=new sr,Aje=new De(0,0,0),Tje=new De(1,1,1),_u=new De,d_=new De,da=new De,S$=new sr,E$=new rf;class qb{constructor(e=0,n=0,r=0,i=qb.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],c=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(Ji(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(-Ji(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ji(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(c,s));break;case"ZYX":this._y=Math.asin(-Ji(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(Ji(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Ji(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 S$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(S$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return E$.setFromEuler(this),this.setFromQuaternion(E$,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}}qb.DEFAULT_ORDER="XYZ";class FZ{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 Cje=0;const M$=new De,Sp=new rf,Ql=new sr,h_=new De,Mx=new De,Nje=new De,kje=new rf,A$=new De(1,0,0),T$=new De(0,1,0),C$=new De(0,0,1),Pje={type:"added"},Rje={type:"removed"};class Ts extends gf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Cje++}),this.uuid=Ec(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ts.DEFAULT_UP.clone();const e=new De,n=new qb,r=new rf,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 fn}}),this.matrix=new sr,this.matrixWorld=new sr,this.matrixAutoUpdate=Ts.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ts.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new FZ,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 Sp.setFromAxisAngle(e,n),this.quaternion.multiply(Sp),this}rotateOnWorldAxis(e,n){return Sp.setFromAxisAngle(e,n),this.quaternion.premultiply(Sp),this}rotateX(e){return this.rotateOnAxis(A$,e)}rotateY(e){return this.rotateOnAxis(T$,e)}rotateZ(e){return this.rotateOnAxis(C$,e)}translateOnAxis(e,n){return M$.copy(e).applyQuaternion(this.quaternion),this.position.add(M$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(A$,e)}translateY(e){return this.translateOnAxis(T$,e)}translateZ(e){return this.translateOnAxis(C$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ql.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?h_.copy(e):h_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Mx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ql.lookAt(Mx,h_,this.up):Ql.lookAt(h_,Mx,this.up),this.quaternion.setFromRotationMatrix(Ql),i&&(Ql.extractRotation(i.matrixWorld),Sp.setFromRotationMatrix(Ql),this.quaternion.premultiply(Sp.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(Pje)):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(Rje)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ql.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ql.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ql),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(Mx,e,Nje),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Mx,kje,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,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];s(e.shapes,f)}else s(e.shapes,c)}}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 c=0,u=this.material.length;c<u;c++)o.push(s(e.materials,this.material[c]));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 c=this.animations[o];i.animations.push(s(e.animations,c))}}if(n){const o=a(e.geometries),c=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),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),m.length>0&&(r.animations=m),x.length>0&&(r.nodes=x)}return r.object=i,r;function a(o){const c=[];for(const u in o){const d=o[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Ts.DEFAULT_UP=new De(0,1,0);Ts.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ts.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Mo=new De,Jl=new De,oN=new De,ec=new De,Ep=new De,Mp=new De,N$=new De,lN=new De,cN=new De,uN=new De;let f_=!1;class Ao{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),Mo.subVectors(e,n),i.cross(Mo);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){Mo.subVectors(i,n),Jl.subVectors(r,n),oN.subVectors(e,n);const a=Mo.dot(Mo),o=Mo.dot(Jl),c=Mo.dot(oN),u=Jl.dot(Jl),d=Jl.dot(oN),f=a*u-o*o;if(f===0)return s.set(-2,-1,-1);const g=1/f,m=(u*c-o*d)*g,x=(a*d-o*c)*g;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,ec),ec.x>=0&&ec.y>=0&&ec.x+ec.y<=1}static getUV(e,n,r,i,s,a,o,c){return f_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),f_=!0),this.getInterpolation(e,n,r,i,s,a,o,c)}static getInterpolation(e,n,r,i,s,a,o,c){return this.getBarycoord(e,n,r,i,ec),c.setScalar(0),c.addScaledVector(s,ec.x),c.addScaledVector(a,ec.y),c.addScaledVector(o,ec.z),c}static isFrontFacing(e,n,r,i){return Mo.subVectors(r,n),Jl.subVectors(e,n),Mo.cross(Jl).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Mo.subVectors(this.c,this.b),Jl.subVectors(this.a,this.b),Mo.cross(Jl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ao.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ao.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return f_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),f_=!0),Ao.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return Ao.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Ao.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ao.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;Ep.subVectors(i,r),Mp.subVectors(s,r),lN.subVectors(e,r);const c=Ep.dot(lN),u=Mp.dot(lN);if(c<=0&&u<=0)return n.copy(r);cN.subVectors(e,i);const d=Ep.dot(cN),f=Mp.dot(cN);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return a=c/(c-d),n.copy(r).addScaledVector(Ep,a);uN.subVectors(e,s);const m=Ep.dot(uN),x=Mp.dot(uN);if(x>=0&&m<=x)return n.copy(s);const y=m*u-c*x;if(y<=0&&u>=0&&x<=0)return o=u/(u-x),n.copy(r).addScaledVector(Mp,o);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return N$.subVectors(s,i),o=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(N$,o);const b=1/(v+y+g);return a=y*b,o=g*b,n.copy(r).addScaledVector(Ep,a).addScaledVector(Mp,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const zZ={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},wu={h:0,s:0,l:0},p_={h:0,s:0,l:0};function dN(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let $t=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Qi){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Xn.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Xn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Xn.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Xn.workingColorSpace){if(e=fj(e,1),n=Ji(n,0,1),r=Ji(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=dN(a,s,e+1/3),this.g=dN(a,s,e),this.b=dN(a,s,e-1/3)}return Xn.toWorkingColorSpace(this,i),this}setStyle(e,n=Qi){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,n);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,n);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,n);if(a===6)return this.setHex(parseInt(s,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Qi){const r=zZ[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=om(e.r),this.g=om(e.g),this.b=om(e.b),this}copyLinearToSRGB(e){return this.r=JC(e.r),this.g=JC(e.g),this.b=JC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Qi){return Xn.fromWorkingColorSpace(cs.copy(this),e),Math.round(Ji(cs.r*255,0,255))*65536+Math.round(Ji(cs.g*255,0,255))*256+Math.round(Ji(cs.b*255,0,255))}getHexString(e=Qi){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Xn.workingColorSpace){Xn.fromWorkingColorSpace(cs.copy(this),n);const r=cs.r,i=cs.g,s=cs.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let c,u;const d=(o+a)/2;if(o===a)c=0,u=0;else{const f=a-o;switch(u=d<=.5?f/(a+o):f/(2-a-o),a){case r:c=(i-s)/f+(i<s?6:0);break;case i:c=(s-r)/f+2;break;case s:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Xn.workingColorSpace){return Xn.fromWorkingColorSpace(cs.copy(this),n),e.r=cs.r,e.g=cs.g,e.b=cs.b,e}getStyle(e=Qi){Xn.fromWorkingColorSpace(cs.copy(this),e);const n=cs.r,r=cs.g,i=cs.b;return e!==Qi?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(wu),this.setHSL(wu.h+e,wu.s+n,wu.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(wu),e.getHSL(p_);const r=Xx(wu.h,p_.h,n),i=Xx(wu.s,p_.s,n),s=Xx(wu.l,p_.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 cs=new $t;$t.NAMES=zZ;let Dje=0;class ug extends gf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Dje++}),this.uuid=Ec(),this.name="",this.type="Material",this.blending=am,this.side=fd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=MP,this.blendDst=AP,this.blendEquation=lh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new $t(0,0,0),this.blendAlpha=0,this.depthFunc=Dw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=g$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=xp,this.stencilZFail=xp,this.stencilZPass=xp,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!==am&&(r.blending=this.blending),this.side!==fd&&(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!==MP&&(r.blendSrc=this.blendSrc),this.blendDst!==AP&&(r.blendDst=this.blendDst),this.blendEquation!==lh&&(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!==Dw&&(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!==g$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==xp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==xp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==xp&&(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 c=s[o];delete c.metadata,a.push(c)}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 BZ extends ug{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=uj,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 Kr=new De,m_=new Zt;class Sa{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=PP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=xc,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++)m_.fromBufferAttribute(this,n),m_.applyMatrix3(e),this.setXY(n,m_.x,m_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyMatrix3(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyMatrix4(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.applyNormalMatrix(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Kr.fromBufferAttribute(this,n),Kr.transformDirection(e),this.setXYZ(n,Kr.x,Kr.y,Kr.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=il(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Kn(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=il(n,this.array)),n}setX(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=il(n,this.array)),n}setY(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=il(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=il(n,this.array)),n}setW(e,n){return this.normalized&&(n=Kn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Kn(n,this.array),r=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array),s=Kn(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!==PP&&(e.usage=this.usage),e}}class HZ extends Sa{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class $Z extends Sa{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Br extends Sa{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Oje=0;const Ba=new sr,hN=new Ts,Ap=new De,ha=new so,Ax=new so,ki=new De;class xs extends gf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Oje++}),this.uuid=Ec(),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(jZ(e)?$Z:HZ)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new fn().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ba.makeRotationFromQuaternion(e),this.applyMatrix4(Ba),this}rotateX(e){return Ba.makeRotationX(e),this.applyMatrix4(Ba),this}rotateY(e){return Ba.makeRotationY(e),this.applyMatrix4(Ba),this}rotateZ(e){return Ba.makeRotationZ(e),this.applyMatrix4(Ba),this}translate(e,n,r){return Ba.makeTranslation(e,n,r),this.applyMatrix4(Ba),this}scale(e,n,r){return Ba.makeScale(e,n,r),this.applyMatrix4(Ba),this}lookAt(e){return hN.lookAt(e),hN.updateMatrix(),this.applyMatrix4(hN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ap).negate(),this.translate(Ap.x,Ap.y,Ap.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 Br(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new so);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new De(-1/0,-1/0,-1/0),new De(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];ha.setFromBufferAttribute(s),this.morphTargetsRelative?(ki.addVectors(this.boundingBox.min,ha.min),this.boundingBox.expandByPoint(ki),ki.addVectors(this.boundingBox.max,ha.max),this.boundingBox.expandByPoint(ki)):(this.boundingBox.expandByPoint(ha.min),this.boundingBox.expandByPoint(ha.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 ul);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(ha.setFromBufferAttribute(e),n)for(let s=0,a=n.length;s<a;s++){const o=n[s];Ax.setFromBufferAttribute(o),this.morphTargetsRelative?(ki.addVectors(ha.min,Ax.min),ha.expandByPoint(ki),ki.addVectors(ha.max,Ax.max),ha.expandByPoint(ki)):(ha.expandByPoint(Ax.min),ha.expandByPoint(Ax.max))}ha.getCenter(r);let i=0;for(let s=0,a=e.count;s<a;s++)ki.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(ki));if(n)for(let s=0,a=n.length;s<a;s++){const o=n[s],c=this.morphTargetsRelative;for(let u=0,d=o.count;u<d;u++)ki.fromBufferAttribute(o,u),c&&(Ap.fromBufferAttribute(e,u),ki.add(Ap)),i=Math.max(i,r.distanceToSquared(ki))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,s=n.normal.array,a=n.uv.array,o=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Sa(new Float32Array(4*o),4));const c=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 Zt,y=new Zt,v=new Zt,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;c[D*4]=T.x,c[D*4+1]=T.y,c[D*4+2]=T.z,c[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 Sa(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,c=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),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),o.add(d),c.add(d),u.add(d),r.setXYZ(x,o.x,o.y,o.z),r.setXYZ(y,c.x,c.y,c.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++)ki.fromBufferAttribute(e,n),ki.normalize(),e.setXYZ(n,ki.x,ki.y,ki.z)}toNonIndexed(){function e(o,c){const u=o.array,d=o.itemSize,f=o.normalized,g=new u.constructor(c.length*d);let m=0,x=0;for(let y=0,v=c.length;y<v;y++){o.isInterleavedBufferAttribute?m=c[y]*o.data.stride+o.offset:m=c[y]*d;for(let b=0;b<d;b++)g[x++]=u[m++]}return new Sa(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new xs,r=this.index.array,i=this.attributes;for(const o in i){const c=i[o],u=e(c,r);n.setAttribute(o,u)}const s=this.morphAttributes;for(const o in s){const c=[],u=s[o];for(let d=0,f=u.length;d<f;d++){const g=u[d],m=e(g,r);c.push(m)}n.morphAttributes[o]=c}n.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;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 c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let s=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],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[c]=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 c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const k$=new sr,Yd=new pj,g_=new ul,P$=new De,Tp=new De,Cp=new De,Np=new De,fN=new De,x_=new De,b_=new Zt,v_=new Zt,y_=new Zt,R$=new De,D$=new De,O$=new De,__=new De,w_=new De;class Oo extends Ts{constructor(e=new xs,n=new BZ){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){x_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=o[c],f=s[c];d!==0&&(fN.fromBufferAttribute(f,e),a?x_.addScaledVector(fN,d):x_.addScaledVector(fN.sub(n),d))}n.add(x_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),g_.copy(r.boundingSphere),g_.applyMatrix4(s),Yd.copy(e.ray).recast(e.near),!(g_.containsPoint(Yd.origin)===!1&&(Yd.intersectSphere(g_,P$)===null||Yd.origin.distanceToSquared(P$)>(e.far-e.near)**2))&&(k$.copy(s).invert(),Yd.copy(e.ray).applyMatrix4(k$),!(r.boundingBox!==null&&Yd.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Yd)))}_computeIntersections(e,n,r){let i;const s=this.geometry,a=this.material,o=s.index,c=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=S_(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=S_(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==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(c.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=S_(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(c.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=S_(this,a,e,r,u,d,f,E,S,A),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function jje(t,e,n,r,i,s,a,o){let c;if(e.side===Xs?c=r.intersectTriangle(a,s,i,!0,o):c=r.intersectTriangle(i,s,a,e.side===fd,o),c===null)return null;w_.copy(o),w_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(w_);return u<n.near||u>n.far?null:{distance:u,point:w_.clone(),object:t}}function S_(t,e,n,r,i,s,a,o,c,u){t.getVertexPosition(o,Tp),t.getVertexPosition(c,Cp),t.getVertexPosition(u,Np);const d=jje(t,e,n,r,Tp,Cp,Np,__);if(d){i&&(b_.fromBufferAttribute(i,o),v_.fromBufferAttribute(i,c),y_.fromBufferAttribute(i,u),d.uv=Ao.getInterpolation(__,Tp,Cp,Np,b_,v_,y_,new Zt)),s&&(b_.fromBufferAttribute(s,o),v_.fromBufferAttribute(s,c),y_.fromBufferAttribute(s,u),d.uv1=Ao.getInterpolation(__,Tp,Cp,Np,b_,v_,y_,new Zt),d.uv2=d.uv1),a&&(R$.fromBufferAttribute(a,o),D$.fromBufferAttribute(a,c),O$.fromBufferAttribute(a,u),d.normal=Ao.getInterpolation(__,Tp,Cp,Np,R$,D$,O$,new De),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:o,b:c,c:u,normal:new De,materialIndex:0};Ao.getNormal(Tp,Cp,Np,f.normal),d.face=f}return d}class Kb extends xs{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 c=[],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(c),this.setAttribute("position",new Br(u,3)),this.setAttribute("normal",new Br(d,3)),this.setAttribute("uv",new Br(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,ee=0;const Y=new De;for(let Q=0;Q<K;Q++){const U=Q*F-q;for(let z=0;z<W;z++){const J=z*D-j;Y[y]=J*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-Q/I),V+=1}}for(let Q=0;Q<I;Q++)for(let U=0;U<N;U++){const z=g+U+W*Q,J=g+U+W*(Q+1),se=g+(U+1)+W*(Q+1),me=g+(U+1)+W*Q;c.push(z,J,me),c.push(J,se,me),ee+=6}o.addGroup(m,ee,C),m+=ee,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kb(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function jm(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 ws(t){const e={};for(let n=0;n<t.length;n++){const r=jm(t[n]);for(const i in r)e[i]=r[i]}return e}function Lje(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function VZ(t){return t.getRenderTarget()===null?t.outputColorSpace:Xn.workingColorSpace}const mj={clone:jm,merge:ws};var Ije=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Uje=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class pd extends ug{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ije,this.fragmentShader=Uje,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=jm(e.uniforms),this.uniformsGroups=Lje(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 GZ extends Ts{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new sr,this.projectionMatrix=new sr,this.projectionMatrixInverse=new sr,this.coordinateSystem=ll}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class ma extends GZ{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=Z0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Kx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Z0*2*Math.atan(Math.tan(Kx*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,s,a){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Kx*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,u=a.fullHeight;s+=a.offsetX*i/c,n-=a.offsetY*r/u,i*=a.width/c,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 kp=-90,Pp=1;class Fje extends Ts{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ma(kp,Pp,e,n);i.layers=this.layers,this.add(i);const s=new ma(kp,Pp,e,n);s.layers=this.layers,this.add(s);const a=new ma(kp,Pp,e,n);a.layers=this.layers,this.add(a);const o=new ma(kp,Pp,e,n);o.layers=this.layers,this.add(o);const c=new ma(kp,Pp,e,n);c.layers=this.layers,this.add(c);const u=new ma(kp,Pp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,s,a,o,c]=n;for(const u of n)this.remove(u);if(e===ll)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),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),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Y0)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),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,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,c),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 WZ extends Ys{constructor(e,n,r,i,s,a,o,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Rm,super(e,n,r,i,s,a,o,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class zje extends nf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(Yx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Ph?Qi:Ja),this.texture=new WZ(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:Za}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 Kb(5,5,5),s=new pd({name:"CubemapFromEquirect",uniforms:jm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Xs,blending:Yu});s.uniforms.tEquirect.value=n;const a=new Oo(i,s),o=n.minFilter;return n.minFilter===K0&&(n.minFilter=Za),new Fje(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 pN=new De,Bje=new De,Hje=new fn;class ku{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=pN.subVectors(r,n).cross(Bje.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(pN),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||Hje.getNormalMatrix(e),i=this.coplanarPoint(pN).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Zd=new ul,E_=new De;class VE{constructor(e=new ku,n=new ku,r=new ku,i=new ku,s=new ku,a=new ku){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=ll){const r=this.planes,i=e.elements,s=i[0],a=i[1],o=i[2],c=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(c-s,g-u,v-m,A-b).normalize(),r[1].setComponents(c+s,g+u,v+m,A+b).normalize(),r[2].setComponents(c+a,g+d,v+x,A+E).normalize(),r[3].setComponents(c-a,g-d,v-x,A-E).normalize(),r[4].setComponents(c-o,g-f,v-y,A-S).normalize(),n===ll)r[5].setComponents(c+o,g+f,v+y,A+S).normalize();else if(n===Y0)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(),Zd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Zd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zd)}intersectsSprite(e){return Zd.center.set(0,0,0),Zd.radius=.7071067811865476,Zd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zd)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(n[s].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(E_.x=i.normal.x>0?e.max.x:e.min.x,E_.y=i.normal.y>0?e.max.y:e.min.y,E_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(E_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function qZ(){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 $je(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 c(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");s(f.buffer,u,d),f.version=u.version}}return{get:a,remove:o,update:c}}class gj extends xs{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),c=Math.floor(i),u=o+1,d=c+1,f=e/o,g=n/c,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/c)}}for(let b=0;b<c;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 Br(x,3)),this.setAttribute("normal",new Br(y,3)),this.setAttribute("uv",new Br(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gj(e.width,e.height,e.widthSegments,e.heightSegments)}}var Vje=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Gje=`#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`,Wje=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,qje=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Kje=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,Xje=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Yje=`#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`,Qje=`#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`,Jje=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,eLe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,tLe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,nLe=`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`,rLe=`#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`,iLe=`#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`,sLe=`#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`,aLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,oLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,lLe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,cLe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,uLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,dLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,hLe=`#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`,fLe=`#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`,pLe=`#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`,mLe=`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`,gLe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,xLe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,bLe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,vLe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,yLe="gl_FragColor = linearToOutputTexel( gl_FragColor );",_Le=`
- 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 );
- }`,wLe=`#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`,SLe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,ELe=`#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`,MLe=`#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`,ALe=`#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`,TLe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,CLe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,NLe=`#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`,kLe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,PLe=`#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
- }`,RLe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,DLe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,OLe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,jLe=`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`,LLe=`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`,ILe=`#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`,ULe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,FLe=`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`,zLe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,BLe=`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`,HLe=`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`,$Le=`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 );
- }`,VLe=`
- 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`,GLe=`#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`,WLe=`#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`,qLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,KLe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,XLe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,YLe=`#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`,QLe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,JLe=`#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`,eIe=`#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`,tIe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,nIe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,rIe=`#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`,iIe=`#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`,sIe=`#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`,aIe=`#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`,oIe=`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;`,lIe=`#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`,cIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,uIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,dIe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,hIe=`#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`,fIe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,pIe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,mIe=`#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`,gIe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,xIe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,bIe=`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 );
- }`,vIe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,yIe=`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;`,_Ie=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,wIe=`#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`,SIe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,EIe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,MIe=`#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`,AIe=`#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`,TIe=`#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`,CIe=`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;
- }`,NIe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,kIe=`#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`,PIe=`#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`,RIe=`#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`,DIe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,OIe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,jIe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,LIe=`#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; }`,IIe=`#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`,UIe=`#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`,FIe=`#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`,zIe=`#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`,BIe=`#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`,HIe=`#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 $Ie=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,VIe=`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>
- }`,GIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,WIe=`#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>
- }`,qIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,KIe=`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>
- }`,XIe=`#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;
- }`,YIe=`#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;
- }`,QIe=`#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 );
- }`,JIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,e4e=`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>
- }`,t4e=`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>
- }`,n4e=`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>
- }`,r4e=`#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>
- }`,i4e=`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>
- }`,s4e=`#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>
- }`,a4e=`#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>
- }`,o4e=`#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;
- }`,l4e=`#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>
- }`,c4e=`#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
- }`,u4e=`#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
- }`,d4e=`#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>
- }`,h4e=`#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>
- }`,f4e=`#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
- }`,p4e=`#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>
- }`,m4e=`#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>
- }`,g4e=`#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>
- }`,x4e=`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>
- }`,b4e=`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>
- }`,v4e=`#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>
- }`,y4e=`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>
- }`,_4e=`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>
- }`,w4e=`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>
- }`,ln={alphahash_fragment:Vje,alphahash_pars_fragment:Gje,alphamap_fragment:Wje,alphamap_pars_fragment:qje,alphatest_fragment:Kje,alphatest_pars_fragment:Xje,aomap_fragment:Yje,aomap_pars_fragment:Zje,batching_pars_vertex:Qje,batching_vertex:Jje,begin_vertex:eLe,beginnormal_vertex:tLe,bsdfs:nLe,iridescence_fragment:rLe,bumpmap_pars_fragment:iLe,clipping_planes_fragment:sLe,clipping_planes_pars_fragment:aLe,clipping_planes_pars_vertex:oLe,clipping_planes_vertex:lLe,color_fragment:cLe,color_pars_fragment:uLe,color_pars_vertex:dLe,color_vertex:hLe,common:fLe,cube_uv_reflection_fragment:pLe,defaultnormal_vertex:mLe,displacementmap_pars_vertex:gLe,displacementmap_vertex:xLe,emissivemap_fragment:bLe,emissivemap_pars_fragment:vLe,colorspace_fragment:yLe,colorspace_pars_fragment:_Le,envmap_fragment:wLe,envmap_common_pars_fragment:SLe,envmap_pars_fragment:ELe,envmap_pars_vertex:MLe,envmap_physical_pars_fragment:ILe,envmap_vertex:ALe,fog_vertex:TLe,fog_pars_vertex:CLe,fog_fragment:NLe,fog_pars_fragment:kLe,gradientmap_pars_fragment:PLe,lightmap_fragment:RLe,lightmap_pars_fragment:DLe,lights_lambert_fragment:OLe,lights_lambert_pars_fragment:jLe,lights_pars_begin:LLe,lights_toon_fragment:ULe,lights_toon_pars_fragment:FLe,lights_phong_fragment:zLe,lights_phong_pars_fragment:BLe,lights_physical_fragment:HLe,lights_physical_pars_fragment:$Le,lights_fragment_begin:VLe,lights_fragment_maps:GLe,lights_fragment_end:WLe,logdepthbuf_fragment:qLe,logdepthbuf_pars_fragment:KLe,logdepthbuf_pars_vertex:XLe,logdepthbuf_vertex:YLe,map_fragment:ZLe,map_pars_fragment:QLe,map_particle_fragment:JLe,map_particle_pars_fragment:eIe,metalnessmap_fragment:tIe,metalnessmap_pars_fragment:nIe,morphcolor_vertex:rIe,morphnormal_vertex:iIe,morphtarget_pars_vertex:sIe,morphtarget_vertex:aIe,normal_fragment_begin:oIe,normal_fragment_maps:lIe,normal_pars_fragment:cIe,normal_pars_vertex:uIe,normal_vertex:dIe,normalmap_pars_fragment:hIe,clearcoat_normal_fragment_begin:fIe,clearcoat_normal_fragment_maps:pIe,clearcoat_pars_fragment:mIe,iridescence_pars_fragment:gIe,opaque_fragment:xIe,packing:bIe,premultiplied_alpha_fragment:vIe,project_vertex:yIe,dithering_fragment:_Ie,dithering_pars_fragment:wIe,roughnessmap_fragment:SIe,roughnessmap_pars_fragment:EIe,shadowmap_pars_fragment:MIe,shadowmap_pars_vertex:AIe,shadowmap_vertex:TIe,shadowmask_pars_fragment:CIe,skinbase_vertex:NIe,skinning_pars_vertex:kIe,skinning_vertex:PIe,skinnormal_vertex:RIe,specularmap_fragment:DIe,specularmap_pars_fragment:OIe,tonemapping_fragment:jIe,tonemapping_pars_fragment:LIe,transmission_fragment:IIe,transmission_pars_fragment:UIe,uv_pars_fragment:FIe,uv_pars_vertex:zIe,uv_vertex:BIe,worldpos_vertex:HIe,background_vert:$Ie,background_frag:VIe,backgroundCube_vert:GIe,backgroundCube_frag:WIe,cube_vert:qIe,cube_frag:KIe,depth_vert:XIe,depth_frag:YIe,distanceRGBA_vert:ZIe,distanceRGBA_frag:QIe,equirect_vert:JIe,equirect_frag:e4e,linedashed_vert:t4e,linedashed_frag:n4e,meshbasic_vert:r4e,meshbasic_frag:i4e,meshlambert_vert:s4e,meshlambert_frag:a4e,meshmatcap_vert:o4e,meshmatcap_frag:l4e,meshnormal_vert:c4e,meshnormal_frag:u4e,meshphong_vert:d4e,meshphong_frag:h4e,meshphysical_vert:f4e,meshphysical_frag:p4e,meshtoon_vert:m4e,meshtoon_frag:g4e,points_vert:x4e,points_frag:b4e,shadow_vert:v4e,shadow_frag:y4e,sprite_vert:_4e,sprite_frag:w4e},_t={common:{diffuse:{value:new $t(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new Zt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $t(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new $t(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0},uvTransform:{value:new fn}},sprite:{diffuse:{value:new $t(16777215)},opacity:{value:1},center:{value:new Zt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},Gs={basic:{uniforms:ws([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.fog]),vertexShader:ln.meshbasic_vert,fragmentShader:ln.meshbasic_frag},lambert:{uniforms:ws([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new $t(0)}}]),vertexShader:ln.meshlambert_vert,fragmentShader:ln.meshlambert_frag},phong:{uniforms:ws([_t.common,_t.specularmap,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,_t.lights,{emissive:{value:new $t(0)},specular:{value:new $t(1118481)},shininess:{value:30}}]),vertexShader:ln.meshphong_vert,fragmentShader:ln.meshphong_frag},standard:{uniforms:ws([_t.common,_t.envmap,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.roughnessmap,_t.metalnessmap,_t.fog,_t.lights,{emissive:{value:new $t(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag},toon:{uniforms:ws([_t.common,_t.aomap,_t.lightmap,_t.emissivemap,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.gradientmap,_t.fog,_t.lights,{emissive:{value:new $t(0)}}]),vertexShader:ln.meshtoon_vert,fragmentShader:ln.meshtoon_frag},matcap:{uniforms:ws([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,_t.fog,{matcap:{value:null}}]),vertexShader:ln.meshmatcap_vert,fragmentShader:ln.meshmatcap_frag},points:{uniforms:ws([_t.points,_t.fog]),vertexShader:ln.points_vert,fragmentShader:ln.points_frag},dashed:{uniforms:ws([_t.common,_t.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ln.linedashed_vert,fragmentShader:ln.linedashed_frag},depth:{uniforms:ws([_t.common,_t.displacementmap]),vertexShader:ln.depth_vert,fragmentShader:ln.depth_frag},normal:{uniforms:ws([_t.common,_t.bumpmap,_t.normalmap,_t.displacementmap,{opacity:{value:1}}]),vertexShader:ln.meshnormal_vert,fragmentShader:ln.meshnormal_frag},sprite:{uniforms:ws([_t.sprite,_t.fog]),vertexShader:ln.sprite_vert,fragmentShader:ln.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ln.background_vert,fragmentShader:ln.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:ln.backgroundCube_vert,fragmentShader:ln.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ln.cube_vert,fragmentShader:ln.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ln.equirect_vert,fragmentShader:ln.equirect_frag},distanceRGBA:{uniforms:ws([_t.common,_t.displacementmap,{referencePosition:{value:new De},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ln.distanceRGBA_vert,fragmentShader:ln.distanceRGBA_frag},shadow:{uniforms:ws([_t.lights,_t.fog,{color:{value:new $t(0)},opacity:{value:1}}]),vertexShader:ln.shadow_vert,fragmentShader:ln.shadow_frag}};Gs.physical={uniforms:ws([Gs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new Zt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new $t(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fn},transmissionSamplerSize:{value:new Zt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new $t(0)},specularColor:{value:new $t(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new Zt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:ln.meshphysical_vert,fragmentShader:ln.meshphysical_frag};const M_={r:0,b:0,g:0};function S4e(t,e,n,r,i,s,a){const o=new $t(0);let c=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,c):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===HE)?(d===void 0&&(d=new Oo(new Kb(1,1,1),new pd({name:"BackgroundCubeMaterial",uniforms:jm(Gs.backgroundCube.uniforms),vertexShader:Gs.backgroundCube.vertexShader,fragmentShader:Gs.backgroundCube.fragmentShader,side:Xs,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=Xn.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 Oo(new gj(2,2),new pd({name:"BackgroundMaterial",uniforms:jm(Gs.background.uniforms),vertexShader:Gs.background.vertexShader,fragmentShader:Gs.background.fragmentShader,side:fd,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=Xn.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(M_,VZ(t)),r.buffers.color.setClear(M_.r,M_.g,M_.b,b,a)}return{getClearColor:function(){return o},setClearColor:function(v,b=1){o.set(v),c=b,y(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(v){c=v,y(o,c)},render:x}}function E4e(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={},c=v(null);let u=c,d=!1;function f(R,W,K,V,ee){let Y=!1;if(a){const Q=y(V,K,W);u!==Q&&(u=Q,m(u.object)),Y=b(R,V,K,ee),Y&&E(R,V,K,ee)}else{const Q=W.wireframe===!0;(u.geometry!==V.id||u.program!==K.id||u.wireframe!==Q)&&(u.geometry=V.id,u.program=K.id,u.wireframe=Q,Y=!0)}ee!==null&&n.update(ee,t.ELEMENT_ARRAY_BUFFER),(Y||d)&&(d=!1,I(R,W,K,V),ee!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(ee).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 ee=o[R.id];ee===void 0&&(ee={},o[R.id]=ee);let Y=ee[W.id];Y===void 0&&(Y={},ee[W.id]=Y);let Q=Y[V];return Q===void 0&&(Q=v(g()),Y[V]=Q),Q}function v(R){const W=[],K=[],V=[];for(let ee=0;ee<i;ee++)W[ee]=0,K[ee]=0,V[ee]=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 ee=u.attributes,Y=W.attributes;let Q=0;const U=K.getAttributes();for(const z in U)if(U[z].location>=0){const se=ee[z];let me=Y[z];if(me===void 0&&(z==="instanceMatrix"&&R.instanceMatrix&&(me=R.instanceMatrix),z==="instanceColor"&&R.instanceColor&&(me=R.instanceColor)),se===void 0||se.attribute!==me||me&&se.data!==me.data)return!0;Q++}return u.attributesNum!==Q||u.index!==V}function E(R,W,K,V){const ee={},Y=W.attributes;let Q=0;const U=K.getAttributes();for(const z in U)if(U[z].location>=0){let se=Y[z];se===void 0&&(z==="instanceMatrix"&&R.instanceMatrix&&(se=R.instanceMatrix),z==="instanceColor"&&R.instanceColor&&(se=R.instanceColor));const me={};me.attribute=se,se&&se.data&&(me.data=se.data),ee[z]=me,Q++}u.attributes=ee,u.attributesNum=Q,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,ee=u.attributeDivisors;K[R]=1,V[R]===0&&(t.enableVertexAttribArray(R),V[R]=1),ee[R]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,W),ee[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,ee,Y,Q){Q===!0?t.vertexAttribIPointer(R,W,K,ee,Y):t.vertexAttribPointer(R,W,K,V,ee,Y)}function I(R,W,K,V){if(r.isWebGL2===!1&&(R.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;S();const ee=V.attributes,Y=K.getAttributes(),Q=W.defaultAttributeValues;for(const U in Y){const z=Y[U];if(z.location>=0){let J=ee[U];if(J===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(J=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(J=R.instanceColor)),J!==void 0){const se=J.normalized,me=J.itemSize,fe=n.get(J);if(fe===void 0)continue;const xe=fe.buffer,Ee=fe.type,re=fe.bytesPerElement,we=r.isWebGL2===!0&&(Ee===t.INT||Ee===t.UNSIGNED_INT||J.gpuType===EZ);if(J.isInterleavedBufferAttribute){const Oe=J.data,he=Oe.stride,ht=J.offset;if(Oe.isInstancedInterleavedBuffer){for(let $=0;$<z.locationSize;$++)T(z.location+$,Oe.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Oe.meshPerAttribute*Oe.count)}else for(let $=0;$<z.locationSize;$++)A(z.location+$);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let $=0;$<z.locationSize;$++)N(z.location+$,me/z.locationSize,Ee,se,he*re,(ht+me/z.locationSize*$)*re,we)}else{if(J.isInstancedBufferAttribute){for(let Oe=0;Oe<z.locationSize;Oe++)T(z.location+Oe,J.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let Oe=0;Oe<z.locationSize;Oe++)A(z.location+Oe);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let Oe=0;Oe<z.locationSize;Oe++)N(z.location+Oe,me/z.locationSize,Ee,se,me*re,me/z.locationSize*Oe*re,we)}}else if(Q!==void 0){const se=Q[U];if(se!==void 0)switch(se.length){case 2:t.vertexAttrib2fv(z.location,se);break;case 3:t.vertexAttrib3fv(z.location,se);break;case 4:t.vertexAttrib4fv(z.location,se);break;default:t.vertexAttrib1fv(z.location,se)}}}}k()}function C(){j();for(const R in o){const W=o[R];for(const K in W){const V=W[K];for(const ee in V)x(V[ee].object),delete V[ee];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 ee in V)x(V[ee].object),delete V[ee];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 ee in V)x(V[ee].object),delete V[ee];delete K[R.id]}}function j(){q(),d=!0,u!==c&&(u=c,m(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:j,resetDefaultState:q,dispose:C,releaseStatesOfGeometry:D,releaseStatesOfProgram:F,initAttributes:S,enableAttribute:A,disableUnusedAttributes:k}}function M4e(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 c(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=c,this.renderMultiDraw=u}function A4e(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 c=s(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);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 T4e(t){const e=this;let n=null,r=0,i=!1,s=!1;const a=new ku,o=new fn,c={value:null,needsUpdate:!1};this.uniform=c,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;c.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(){c.value!==n&&(c.value=n,c.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=c.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}c.value=v,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function C4e(t){let e=new WeakMap;function n(a,o){return o===TP?a.mapping=Rm:o===CP&&(a.mapping=Dm),a}function r(a){if(a&&a.isTexture){const o=a.mapping;if(o===TP||o===CP)if(e.has(a)){const c=e.get(a).texture;return n(c,a.mapping)}else{const c=a.image;if(c&&c.height>0){const u=new zje(c.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 c=e.get(o);c!==void 0&&(e.delete(o),c.dispose())}function s(){e=new WeakMap}return{get:r,dispose:s}}class N4e extends GZ{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,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,a=s+u*this.view.width,o-=d*this.view.offsetY,c=o-d*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Xp=4,j$=[.125,.215,.35,.446,.526,.582],ch=20,mN=new N4e,L$=new $t;let gN=null,xN=0,bN=0;const sh=(1+Math.sqrt(5))/2,Rp=1/sh,I$=[new De(1,1,1),new De(-1,1,1),new De(1,1,-1),new De(-1,1,-1),new De(0,sh,Rp),new De(0,sh,-Rp),new De(Rp,0,sh),new De(-Rp,0,sh),new De(sh,Rp,0),new De(-sh,Rp,0)];class U${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){gN=this._renderer.getRenderTarget(),xN=this._renderer.getActiveCubeFace(),bN=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=B$(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=z$(),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(gN,xN,bN),e.scissorTest=!1,A_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Rm||e.mapping===Dm?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),gN=this._renderer.getRenderTarget(),xN=this._renderer.getActiveCubeFace(),bN=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:Za,minFilter:Za,generateMipmaps:!1,type:X0,format:Qa,colorSpace:Lc,depthBuffer:!1},i=F$(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=F$(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=k4e(s)),this._blurMaterial=P4e(s,e,n)}return i}_compileMaterial(e){const n=new Oo(this._lodPlanes[0],e);this._renderer.compile(n,mN)}_sceneToCubeUV(e,n,r,i){const o=new ma(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,g=d.toneMapping;d.getClearColor(L$),d.toneMapping=Zu,d.autoClear=!1;const m=new BZ({name:"PMREM.Background",side:Xs,depthWrite:!1,depthTest:!1}),x=new Oo(new Kb,m);let y=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,y=!0):(m.color.copy(L$),y=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(o.up.set(0,c[b],0),o.lookAt(u[b],0,0)):E===1?(o.up.set(0,0,c[b]),o.lookAt(0,u[b],0)):(o.up.set(0,c[b],0),o.lookAt(0,0,u[b]));const S=this._cubeSize;A_(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===Rm||e.mapping===Dm;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=B$()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=z$());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new Oo(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;A_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(a,mN)}_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=I$[(i-1)%I$.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 c=this._renderer,u=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Oo(this._lodPlanes[i],u),g=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*ch-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):ch;v>ch&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${ch}`);const b=[];let E=0;for(let N=0;N<ch;++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-Xp?i-S+Xp:0),k=4*(this._cubeSize-A);A_(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,mN)}}function k4e(t){const e=[],n=[],r=[];let i=t;const s=t-Xp+1+j$.length;for(let a=0;a<s;a++){const o=Math.pow(2,i);n.push(o);let c=1/o;a>t-Xp?c=j$[a-t+Xp-1]:a===0&&(c=0),r.push(c);const u=1/(o-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],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 xs;T.setAttribute("position",new Sa(E,y)),T.setAttribute("uv",new Sa(S,v)),T.setAttribute("faceIndex",new Sa(A,b)),e.push(T),i>Xp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function F$(t,e,n){const r=new nf(t,e,n);return r.texture.mapping=HE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function A_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function P4e(t,e,n){const r=new Float32Array(ch),i=new De(0,1,0);return new pd({name:"SphericalGaussianBlur",defines:{n:ch,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:xj(),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:Yu,depthTest:!1,depthWrite:!1})}function z$(){return new pd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:xj(),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:Yu,depthTest:!1,depthWrite:!1})}function B$(){return new pd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:xj(),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:Yu,depthTest:!1,depthWrite:!1})}function xj(){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 R4e(t){let e=new WeakMap,n=null;function r(o){if(o&&o.isTexture){const c=o.mapping,u=c===TP||c===CP,d=c===Rm||c===Dm;if(u||d)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new U$(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 U$(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 c=0;const u=6;for(let d=0;d<u;d++)o[d]!==void 0&&c++;return c===u}function s(o){const c=o.target;c.removeEventListener("dispose",s);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function a(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:a}}function D4e(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 O4e(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 c(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(jZ(g)?$Z:HZ)(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:c,getWireframeAttribute:d}}function j4e(t,e,n,r){const i=r.isWebGL2;let s;function a(m){s=m}let o,c;function u(m){o=m.type,c=m.bytesPerElement}function d(m,x){t.drawElements(s,x,o,m*c),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*c,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]/c,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 L4e(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 I4e(t,e){return t[0]-e[0]}function U4e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function F4e(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,a=new Zn,o=[];for(let u=0;u<8;u++)o[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,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 UZ(j,D,F,y);q.type=xc,q.needsUpdate=!0;const R=C*4;for(let K=0;K<y;K++){const V=k[K],ee=N[K],Y=I[K],Q=D*F*4*K;for(let U=0;U<V.count;U++){const z=U*R;S===!0&&(a.fromBufferAttribute(V,U),j[Q+z+0]=a.x,j[Q+z+1]=a.y,j[Q+z+2]=a.z,j[Q+z+3]=0),A===!0&&(a.fromBufferAttribute(ee,U),j[Q+z+4]=a.x,j[Q+z+5]=a.y,j[Q+z+6]=a.z,j[Q+z+7]=0),T===!0&&(a.fromBufferAttribute(Y,U),j[Q+z+8]=a.x,j[Q+z+9]=a.y,j[Q+z+10]=a.z,j[Q+z+11]=Y.itemSize===4?a.w:1)}}v={count:y,texture:q,size:new Zt(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(U4e);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(I4e);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:c}}function z4e(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function a(){i=new WeakMap}function o(c){const u=c.target;u.removeEventListener("dispose",o),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:s,dispose:a}}class KZ extends Ys{constructor(e,n,r,i,s,a,o,c,u,d){if(d=d!==void 0?d:kh,d!==kh&&d!==Om)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===kh&&(r=Bu),r===void 0&&d===Om&&(r=Nh),super(null,i,s,a,o,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Zi,this.minFilter=c!==void 0?c:Zi,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}const XZ=new Ys,YZ=new KZ(1,1);YZ.compareFunction=DZ;const ZZ=new UZ,QZ=new Eje,JZ=new WZ,H$=[],$$=[],V$=new Float32Array(16),G$=new Float32Array(9),W$=new Float32Array(4);function dg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=H$[i];if(s===void 0&&(s=new Float32Array(i),H$[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 gi(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function xi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function GE(t,e){let n=$$[e];n===void 0&&(n=new Int32Array(e),$$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function B4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(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.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2fv(this.addr,e),xi(n,e)}}function $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.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(gi(n,e))return;t.uniform3fv(this.addr,e),xi(n,e)}}function 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.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4fv(this.addr,e),xi(n,e)}}function G4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;W$.set(r),t.uniformMatrix2fv(this.addr,!1,W$),xi(n,r)}}function W4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;G$.set(r),t.uniformMatrix3fv(this.addr,!1,G$),xi(n,r)}}function q4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(gi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),xi(n,e)}else{if(gi(n,r))return;V$.set(r),t.uniformMatrix4fv(this.addr,!1,V$),xi(n,r)}}function K4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function X4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2iv(this.addr,e),xi(n,e)}}function Y4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(gi(n,e))return;t.uniform3iv(this.addr,e),xi(n,e)}}function 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(gi(n,e))return;t.uniform4iv(this.addr,e),xi(n,e)}}function Q4e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function J4e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(gi(n,e))return;t.uniform2uiv(this.addr,e),xi(n,e)}}function e5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(gi(n,e))return;t.uniform3uiv(this.addr,e),xi(n,e)}}function t5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(gi(n,e))return;t.uniform4uiv(this.addr,e),xi(n,e)}}function n5e(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?YZ:XZ;n.setTexture2D(e||s,i)}function r5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||QZ,i)}function i5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||JZ,i)}function s5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||ZZ,i)}function a5e(t){switch(t){case 5126:return B4e;case 35664:return H4e;case 35665:return $4e;case 35666:return V4e;case 35674:return G4e;case 35675:return W4e;case 35676:return q4e;case 5124:case 35670:return K4e;case 35667:case 35671:return X4e;case 35668:case 35672:return Y4e;case 35669:case 35673:return Z4e;case 5125:return Q4e;case 36294:return J4e;case 36295:return e5e;case 36296:return t5e;case 35678:case 36198:case 36298:case 36306:case 35682:return n5e;case 35679:case 36299:case 36307:return r5e;case 35680:case 36300:case 36308:case 36293:return i5e;case 36289:case 36303:case 36311:case 36292:return s5e}}function o5e(t,e){t.uniform1fv(this.addr,e)}function l5e(t,e){const n=dg(e,this.size,2);t.uniform2fv(this.addr,n)}function c5e(t,e){const n=dg(e,this.size,3);t.uniform3fv(this.addr,n)}function u5e(t,e){const n=dg(e,this.size,4);t.uniform4fv(this.addr,n)}function d5e(t,e){const n=dg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function h5e(t,e){const n=dg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function f5e(t,e){const n=dg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function p5e(t,e){t.uniform1iv(this.addr,e)}function m5e(t,e){t.uniform2iv(this.addr,e)}function g5e(t,e){t.uniform3iv(this.addr,e)}function x5e(t,e){t.uniform4iv(this.addr,e)}function b5e(t,e){t.uniform1uiv(this.addr,e)}function v5e(t,e){t.uniform2uiv(this.addr,e)}function y5e(t,e){t.uniform3uiv(this.addr,e)}function _5e(t,e){t.uniform4uiv(this.addr,e)}function w5e(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),xi(r,s));for(let a=0;a!==i;++a)n.setTexture2D(e[a]||XZ,s[a])}function S5e(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),xi(r,s));for(let a=0;a!==i;++a)n.setTexture3D(e[a]||QZ,s[a])}function E5e(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),xi(r,s));for(let a=0;a!==i;++a)n.setTextureCube(e[a]||JZ,s[a])}function M5e(t,e,n){const r=this.cache,i=e.length,s=GE(n,i);gi(r,s)||(t.uniform1iv(this.addr,s),xi(r,s));for(let a=0;a!==i;++a)n.setTexture2DArray(e[a]||ZZ,s[a])}function A5e(t){switch(t){case 5126:return o5e;case 35664:return l5e;case 35665:return c5e;case 35666:return u5e;case 35674:return d5e;case 35675:return h5e;case 35676:return f5e;case 5124:case 35670:return p5e;case 35667:case 35671:return m5e;case 35668:case 35672:return g5e;case 35669:case 35673:return x5e;case 5125:return b5e;case 36294:return v5e;case 36295:return y5e;case 36296:return _5e;case 35678:case 36198:case 36298:case 36306:case 35682:return w5e;case 35679:case 36299:case 36307:return S5e;case 35680:case 36300:case 36308:case 36293:return E5e;case 36289:case 36303:case 36311:case 36292:return M5e}}class T5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=a5e(n.type)}}class C5e{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=A5e(n.type)}}class N5e{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 vN=/(\w+)(\])?(\[|\.)?/g;function q$(t,e){t.seq.push(e),t.map[e.id]=e}function k5e(t,e,n){const r=t.name,i=r.length;for(vN.lastIndex=0;;){const s=vN.exec(r),a=vN.lastIndex;let o=s[1];const c=s[2]==="]",u=s[3];if(c&&(o=o|0),u===void 0||u==="["&&a+2===i){q$(n,u===void 0?new T5e(o,t,e):new C5e(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new N5e(o),q$(n,f)),n=f}}}class p1{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);k5e(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],c=r[o.id];c.needsUpdate!==!1&&o.setValue(e,c.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 K$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const P5e=37297;let R5e=0;function D5e(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 O5e(t){const e=Xn.getPrimaries(Xn.workingColorSpace),n=Xn.getPrimaries(t);let r;switch(e===n?r="":e===Lw&&n===jw?r="LinearDisplayP3ToLinearSRGB":e===jw&&n===Lw&&(r="LinearSRGBToLinearDisplayP3"),t){case Lc:case $E:return[r,"LinearTransferOETF"];case Qi:case hj:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function X$(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+`
- `+D5e(t.getShaderSource(e),a)}else return i}function j5e(t,e){const n=O5e(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function L5e(t,e){let n;switch(e){case jOe:n="Linear";break;case LOe:n="Reinhard";break;case IOe:n="OptimizedCineon";break;case UOe:n="ACESFilmic";break;case FOe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function I5e(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(Ux).join(`
- `)}function U5e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function F5e(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 Ux(t){return t!==""}function Y$(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 Z$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const z5e=/^[ \t]*#include +<([\w\d./]+)>/gm;function OP(t){return t.replace(z5e,H5e)}const B5e=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function H5e(t,e){let n=ln[e];if(n===void 0){const r=B5e.get(e);if(r!==void 0)n=ln[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return OP(n)}const $5e=/#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 Q$(t){return t.replace($5e,V5e)}function V5e(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 J$(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 G5e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===wZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===cOe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===sc&&(e="SHADOWMAP_TYPE_VSM"),e}function W5e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Rm:case Dm:e="ENVMAP_TYPE_CUBE";break;case HE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function q5e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Dm:e="ENVMAP_MODE_REFRACTION";break}return e}function K5e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case uj:e="ENVMAP_BLENDING_MULTIPLY";break;case DOe:e="ENVMAP_BLENDING_MIX";break;case OOe:e="ENVMAP_BLENDING_ADD";break}return e}function X5e(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 Y5e(t,e,n,r){const i=t.getContext(),s=n.defines;let a=n.vertexShader,o=n.fragmentShader;const c=G5e(n),u=W5e(n),d=q5e(n),f=K5e(n),g=X5e(n),m=n.isWebGL2?"":I5e(n),x=U5e(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(Ux).join(`
- `),v.length>0&&(v+=`
- `),b=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Ux).join(`
- `),b.length>0&&(b+=`
- `)):(v=[J$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Ux).join(`
- `),b=[m,J$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Zu?"#define TONE_MAPPING":"",n.toneMapping!==Zu?ln.tonemapping_pars_fragment:"",n.toneMapping!==Zu?L5e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",ln.colorspace_pars_fragment,j5e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Ux).join(`
- `)),a=OP(a),a=Y$(a,n),a=Z$(a,n),o=OP(o),o=Y$(o,n),o=Z$(o,n),a=Q$(a),o=Q$(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===x$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===x$?"":"#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=K$(i,i.VERTEX_SHADER,S),k=K$(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=X$(i,T,"vertex"),ee=X$(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+j+`
- `+V+`
- `+ee)}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 p1(i,y),C=F5e(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,P5e)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=R5e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=k,this}let Z5e=0;class Q5e{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 J5e(e),n.set(e,r)),r}}class J5e{constructor(e){this.id=Z5e++,this.code=e,this.usedTimes=0}}function eUe(t,e,n,r,i,s,a){const o=new FZ,c=new Q5e,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),ee=V&&V.mapping===HE?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 Q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,U=Q!==void 0?Q.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 J,se,me,fe;if(Y){const Qt=Gs[Y];J=Qt.vertexShader,se=Qt.fragmentShader}else J=C.vertexShader,se=C.fragmentShader,c.update(C),me=c.getVertexShaderID(C),fe=c.getFragmentShaderID(C);const xe=t.getRenderTarget(),Ee=q.isInstancedMesh===!0,re=q.isBatchedMesh===!0,we=!!C.map,Oe=!!C.matcap,he=!!V,ht=!!C.aoMap,$=!!C.lightMap,H=!!C.bumpMap,ne=!!C.normalMap,G=!!C.displacementMap,Z=!!C.emissiveMap,oe=!!C.metalnessMap,Ne=!!C.roughnessMap,Pe=C.anisotropy>0,Se=C.clearcoat>0,B=C.iridescence>0,L=C.sheen>0,te=C.transmission>0,ve=Pe&&!!C.anisotropyMap,_e=Se&&!!C.clearcoatMap,be=Se&&!!C.clearcoatNormalMap,nt=Se&&!!C.clearcoatRoughnessMap,Be=B&&!!C.iridescenceMap,ue=B&&!!C.iridescenceThicknessMap,Ve=L&&!!C.sheenColorMap,Ue=L&&!!C.sheenRoughnessMap,ae=!!C.specularMap,Je=!!C.specularColorMap,He=!!C.specularIntensityMap,Ke=te&&!!C.transmissionMap,ct=te&&!!C.thicknessMap,de=!!C.gradientMap,Ye=!!C.alphaMap,ge=C.alphaTest>0,Fe=!!C.alphaHash,Ce=!!C.extensions,ye=!!W.attributes.uv1,ce=!!W.attributes.uv2,at=!!W.attributes.uv3;let xt=Zu;return C.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(xt=t.toneMapping),{isWebGL2:d,shaderID:Y,shaderType:C.type,shaderName:C.name,vertexShader:J,fragmentShader:se,defines:C.defines,customVertexShaderID:me,customFragmentShaderID:fe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:re,instancing:Ee,instancingColor:Ee&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Lc,map:we,matcap:Oe,envMap:he,envMapMode:he&&V.mapping,envMapCubeUVHeight:ee,aoMap:ht,lightMap:$,bumpMap:H,normalMap:ne,displacementMap:g&&G,emissiveMap:Z,normalMapObjectSpace:ne&&C.normalMapType===ZOe,normalMapTangentSpace:ne&&C.normalMapType===RZ,metalnessMap:oe,roughnessMap:Ne,anisotropy:Pe,anisotropyMap:ve,clearcoat:Se,clearcoatMap:_e,clearcoatNormalMap:be,clearcoatRoughnessMap:nt,iridescence:B,iridescenceMap:Be,iridescenceThicknessMap:ue,sheen:L,sheenColorMap:Ve,sheenRoughnessMap:Ue,specularMap:ae,specularColorMap:Je,specularIntensityMap:He,transmission:te,transmissionMap:Ke,thicknessMap:ct,gradientMap:de,opaque:C.transparent===!1&&C.blending===am,alphaMap:Ye,alphaTest:ge,alphaHash:Fe,combine:C.combine,mapUv:we&&y(C.map.channel),aoMapUv:ht&&y(C.aoMap.channel),lightMapUv:$&&y(C.lightMap.channel),bumpMapUv:H&&y(C.bumpMap.channel),normalMapUv:ne&&y(C.normalMap.channel),displacementMapUv:G&&y(C.displacementMap.channel),emissiveMapUv:Z&&y(C.emissiveMap.channel),metalnessMapUv:oe&&y(C.metalnessMap.channel),roughnessMapUv:Ne&&y(C.roughnessMap.channel),anisotropyMapUv:ve&&y(C.anisotropyMap.channel),clearcoatMapUv:_e&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:be&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:nt&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Be&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:ue&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Ue&&y(C.sheenRoughnessMap.channel),specularMapUv:ae&&y(C.specularMap.channel),specularColorMapUv:Je&&y(C.specularColorMap.channel),specularIntensityMapUv:He&&y(C.specularIntensityMap.channel),transmissionMapUv:Ke&&y(C.transmissionMap.channel),thicknessMapUv:ct&&y(C.thicknessMap.channel),alphaMapUv:Ye&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ne||Pe),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:ye,vertexUv2s:ce,vertexUv3s:at,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(we||Ye),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:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:we&&C.map.isVideoTexture===!0&&Xn.getTransfer(C.map.colorSpace)===lr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===dc,flipSided:C.side===Xs,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=Gs[D];F=mj.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 Y5e(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){c.remove(C)}function I(){c.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:N,programs:u,dispose:I}}function tUe(){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 nUe(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 eV(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 tV(){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 c(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||nUe),r.length>1&&r.sort(g||eV),i.length>1&&i.sort(g||eV)}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:c,finish:d,sort:u}}function rUe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let a;return s===void 0?(a=new tV,t.set(r,[a])):i>=s.length?(a=new tV,s.push(a)):a=s[i],a}function n(){t=new WeakMap}return{get:e,dispose:n}}function iUe(){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 sUe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Zt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let aUe=0;function oUe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function lUe(t,e){const n=new iUe,r=sUe(),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 c(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(oUe);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,ee=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 Q=R.shadow,U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,i.directionalShadow[y]=U,i.directionalShadowMap[y]=ee,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 Q=R.shadow;if(R.map&&(i.spotLightMap[N]=R.map,N++,Q.updateMatrices(R),R.castShadow&&I++),i.spotLightMatrix[b]=Q.matrix,R.castShadow){const U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,i.spotShadow[b]=U,i.spotShadowMap[b]=ee,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 Q=R.shadow,U=r.get(R);U.shadowBias=Q.bias,U.shadowNormalBias=Q.normalBias,U.shadowRadius=Q.radius,U.shadowMapSize=Q.mapSize,U.shadowCameraNear=Q.camera.near,U.shadowCameraFar=Q.camera.far,i.pointShadow[v]=U,i.pointShadowMap[v]=ee,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=_t.LTC_FLOAT_1,i.rectAreaLTC2=_t.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=_t.LTC_HALF_1,i.rectAreaLTC2=_t.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=aUe++)}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:c,setupView:u,state:i}}function nV(t,e){const n=new lUe(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 c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o}}function cUe(t,e){let n=new WeakMap;function r(s,a=0){const o=n.get(s);let c;return o===void 0?(c=new nV(t,e),n.set(s,[c])):a>=o.length?(c=new nV(t,e),o.push(c)):c=o[a],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class uUe extends ug{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=XOe,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 dUe extends ug{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 hUe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,fUe=`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 pUe(t,e,n){let r=new VE;const i=new Zt,s=new Zt,a=new Zn,o=new uUe({depthPacking:YOe}),c=new dUe,u={},d=n.maxTextureSize,f={[fd]:Xs,[Xs]:fd,[dc]:dc},g=new pd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Zt},radius:{value:4}},vertexShader:hUe,fragmentShader:fUe}),m=g.clone();m.defines.HORIZONTAL_PASS=1;const x=new xs;x.setAttribute("position",new Sa(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Oo(x,g),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=wZ;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(Yu),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const j=b!==sc&&this.type===sc,q=b===sc&&this.type!==sc;for(let R=0,W=T.length;R<W;R++){const K=T[R],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 ee=V.getFrameExtents();if(i.multiply(ee),s.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/ee.x),i.x=s.x*ee.x,V.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/ee.y),i.y=s.y*ee.y,V.mapSize.y=s.y)),V.map===null||j===!0||q===!0){const Q=this.type!==sc?{minFilter:Zi,magFilter:Zi}:{};V.map!==null&&V.map.dispose(),V.map=new nf(i.x,i.y,Q),V.map.texture.name=K.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const Y=V.getViewportCount();for(let Q=0;Q<Y;Q++){const U=V.getViewport(Q);a.set(s.x*U.x,s.y*U.y,s.x*U.z,s.y*U.w),F.viewport(a),V.updateMatrices(K,Q),r=V.getFrustum(),A(k,N,V.camera,K,this.type)}V.isPointLightShadow!==!0&&this.type===sc&&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 nf(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?c:o,t.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0){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===sc?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===sc)&&(!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],ee=q[V.materialIndex];if(ee&&ee.visible){const Y=S(T,ee,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 mUe(t,e,n){const r=n.isWebGL2;function i(){let ge=!1;const Fe=new Zn;let Ce=null;const ye=new Zn(0,0,0,0);return{setMask:function(ce){Ce!==ce&&!ge&&(t.colorMask(ce,ce,ce,ce),Ce=ce)},setLocked:function(ce){ge=ce},setClear:function(ce,at,xt,St,Qt){Qt===!0&&(ce*=St,at*=St,xt*=St),Fe.set(ce,at,xt,St),ye.equals(Fe)===!1&&(t.clearColor(ce,at,xt,St),ye.copy(Fe))},reset:function(){ge=!1,Ce=null,ye.set(-1,0,0,0)}}}function s(){let ge=!1,Fe=null,Ce=null,ye=null;return{setTest:function(ce){ce?re(t.DEPTH_TEST):we(t.DEPTH_TEST)},setMask:function(ce){Fe!==ce&&!ge&&(t.depthMask(ce),Fe=ce)},setFunc:function(ce){if(Ce!==ce){switch(ce){case AOe:t.depthFunc(t.NEVER);break;case TOe:t.depthFunc(t.ALWAYS);break;case COe:t.depthFunc(t.LESS);break;case Dw:t.depthFunc(t.LEQUAL);break;case NOe:t.depthFunc(t.EQUAL);break;case kOe:t.depthFunc(t.GEQUAL);break;case POe:t.depthFunc(t.GREATER);break;case ROe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ce=ce}},setLocked:function(ce){ge=ce},setClear:function(ce){ye!==ce&&(t.clearDepth(ce),ye=ce)},reset:function(){ge=!1,Fe=null,Ce=null,ye=null}}}function a(){let ge=!1,Fe=null,Ce=null,ye=null,ce=null,at=null,xt=null,St=null,Qt=null;return{setTest:function(jt){ge||(jt?re(t.STENCIL_TEST):we(t.STENCIL_TEST))},setMask:function(jt){Fe!==jt&&!ge&&(t.stencilMask(jt),Fe=jt)},setFunc:function(jt,Vt,jn){(Ce!==jt||ye!==Vt||ce!==jn)&&(t.stencilFunc(jt,Vt,jn),Ce=jt,ye=Vt,ce=jn)},setOp:function(jt,Vt,jn){(at!==jt||xt!==Vt||St!==jn)&&(t.stencilOp(jt,Vt,jn),at=jt,xt=Vt,St=jn)},setLocked:function(jt){ge=jt},setClear:function(jt){Qt!==jt&&(t.clearStencil(jt),Qt=jt)},reset:function(){ge=!1,Fe=null,Ce=null,ye=null,ce=null,at=null,xt=null,St=null,Qt=null}}}const o=new i,c=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 ee=!1,Y=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(Q)[1]),ee=Y>=1):Q.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),ee=Y>=2);let U=null,z={};const J=t.getParameter(t.SCISSOR_BOX),se=t.getParameter(t.VIEWPORT),me=new Zn().fromArray(J),fe=new Zn().fromArray(se);function xe(ge,Fe,Ce,ye){const ce=new Uint8Array(4),at=t.createTexture();t.bindTexture(ge,at),t.texParameteri(ge,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ge,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let xt=0;xt<Ce;xt++)r&&(ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY)?t.texImage3D(Fe,0,t.RGBA,1,1,ye,0,t.RGBA,t.UNSIGNED_BYTE,ce):t.texImage2D(Fe+xt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ce);return at}const Ee={};Ee[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),Ee[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ee[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ee[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),u.setClear(0),re(t.DEPTH_TEST),c.setFunc(Dw),Z(!1),oe(UH),re(t.CULL_FACE),ne(Yu);function re(ge){g[ge]!==!0&&(t.enable(ge),g[ge]=!0)}function we(ge){g[ge]!==!1&&(t.disable(ge),g[ge]=!1)}function Oe(ge,Fe){return m[ge]!==Fe?(t.bindFramebuffer(ge,Fe),m[ge]=Fe,r&&(ge===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Fe),ge===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Fe)),!0):!1}function he(ge,Fe){let Ce=y,ye=!1;if(ge)if(Ce=x.get(Fe),Ce===void 0&&(Ce=[],x.set(Fe,Ce)),ge.isWebGLMultipleRenderTargets){const ce=ge.texture;if(Ce.length!==ce.length||Ce[0]!==t.COLOR_ATTACHMENT0){for(let at=0,xt=ce.length;at<xt;at++)Ce[at]=t.COLOR_ATTACHMENT0+at;Ce.length=ce.length,ye=!0}}else Ce[0]!==t.COLOR_ATTACHMENT0&&(Ce[0]=t.COLOR_ATTACHMENT0,ye=!0);else Ce[0]!==t.BACK&&(Ce[0]=t.BACK,ye=!0);ye&&(n.isWebGL2?t.drawBuffers(Ce):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ce))}function ht(ge){return v!==ge?(t.useProgram(ge),v=ge,!0):!1}const $={[lh]:t.FUNC_ADD,[dOe]:t.FUNC_SUBTRACT,[hOe]:t.FUNC_REVERSE_SUBTRACT};if(r)$[HH]=t.MIN,$[$H]=t.MAX;else{const ge=e.get("EXT_blend_minmax");ge!==null&&($[HH]=ge.MIN_EXT,$[$H]=ge.MAX_EXT)}const H={[fOe]:t.ZERO,[pOe]:t.ONE,[mOe]:t.SRC_COLOR,[MP]:t.SRC_ALPHA,[_Oe]:t.SRC_ALPHA_SATURATE,[vOe]:t.DST_COLOR,[xOe]:t.DST_ALPHA,[gOe]:t.ONE_MINUS_SRC_COLOR,[AP]:t.ONE_MINUS_SRC_ALPHA,[yOe]:t.ONE_MINUS_DST_COLOR,[bOe]:t.ONE_MINUS_DST_ALPHA,[wOe]:t.CONSTANT_COLOR,[SOe]:t.ONE_MINUS_CONSTANT_COLOR,[EOe]:t.CONSTANT_ALPHA,[MOe]:t.ONE_MINUS_CONSTANT_ALPHA};function ne(ge,Fe,Ce,ye,ce,at,xt,St,Qt,jt){if(ge===Yu){b===!0&&(we(t.BLEND),b=!1);return}if(b===!1&&(re(t.BLEND),b=!0),ge!==uOe){if(ge!==E||jt!==F){if((S!==lh||k!==lh)&&(t.blendEquation(t.FUNC_ADD),S=lh,k=lh),jt)switch(ge){case am:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case FH:t.blendFunc(t.ONE,t.ONE);break;case zH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case BH:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}else switch(ge){case am:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case FH:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case zH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case BH:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}A=null,T=null,N=null,I=null,C.set(0,0,0),D=0,E=ge,F=jt}return}ce=ce||Fe,at=at||Ce,xt=xt||ye,(Fe!==S||ce!==k)&&(t.blendEquationSeparate($[Fe],$[ce]),S=Fe,k=ce),(Ce!==A||ye!==T||at!==N||xt!==I)&&(t.blendFuncSeparate(H[Ce],H[ye],H[at],H[xt]),A=Ce,T=ye,N=at,I=xt),(St.equals(C)===!1||Qt!==D)&&(t.blendColor(St.r,St.g,St.b,Qt),C.copy(St),D=Qt),E=ge,F=!1}function G(ge,Fe){ge.side===dc?we(t.CULL_FACE):re(t.CULL_FACE);let Ce=ge.side===Xs;Fe&&(Ce=!Ce),Z(Ce),ge.blending===am&&ge.transparent===!1?ne(Yu):ne(ge.blending,ge.blendEquation,ge.blendSrc,ge.blendDst,ge.blendEquationAlpha,ge.blendSrcAlpha,ge.blendDstAlpha,ge.blendColor,ge.blendAlpha,ge.premultipliedAlpha),c.setFunc(ge.depthFunc),c.setTest(ge.depthTest),c.setMask(ge.depthWrite),o.setMask(ge.colorWrite);const ye=ge.stencilWrite;u.setTest(ye),ye&&(u.setMask(ge.stencilWriteMask),u.setFunc(ge.stencilFunc,ge.stencilRef,ge.stencilFuncMask),u.setOp(ge.stencilFail,ge.stencilZFail,ge.stencilZPass)),Pe(ge.polygonOffset,ge.polygonOffsetFactor,ge.polygonOffsetUnits),ge.alphaToCoverage===!0?re(t.SAMPLE_ALPHA_TO_COVERAGE):we(t.SAMPLE_ALPHA_TO_COVERAGE)}function Z(ge){j!==ge&&(ge?t.frontFace(t.CW):t.frontFace(t.CCW),j=ge)}function oe(ge){ge!==oOe?(re(t.CULL_FACE),ge!==q&&(ge===UH?t.cullFace(t.BACK):ge===lOe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):we(t.CULL_FACE),q=ge}function Ne(ge){ge!==R&&(ee&&t.lineWidth(ge),R=ge)}function Pe(ge,Fe,Ce){ge?(re(t.POLYGON_OFFSET_FILL),(W!==Fe||K!==Ce)&&(t.polygonOffset(Fe,Ce),W=Fe,K=Ce)):we(t.POLYGON_OFFSET_FILL)}function Se(ge){ge?re(t.SCISSOR_TEST):we(t.SCISSOR_TEST)}function B(ge){ge===void 0&&(ge=t.TEXTURE0+V-1),U!==ge&&(t.activeTexture(ge),U=ge)}function L(ge,Fe,Ce){Ce===void 0&&(U===null?Ce=t.TEXTURE0+V-1:Ce=U);let ye=z[Ce];ye===void 0&&(ye={type:void 0,texture:void 0},z[Ce]=ye),(ye.type!==ge||ye.texture!==Fe)&&(U!==Ce&&(t.activeTexture(Ce),U=Ce),t.bindTexture(ge,Fe||Ee[ge]),ye.type=ge,ye.texture=Fe)}function te(){const ge=z[U];ge!==void 0&&ge.type!==void 0&&(t.bindTexture(ge.type,null),ge.type=void 0,ge.texture=void 0)}function ve(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function be(){try{t.texSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function nt(){try{t.texSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Be(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ue(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ve(){try{t.texStorage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ue(){try{t.texStorage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ae(){try{t.texImage2D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Je(){try{t.texImage3D.apply(t,arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function He(ge){me.equals(ge)===!1&&(t.scissor(ge.x,ge.y,ge.z,ge.w),me.copy(ge))}function Ke(ge){fe.equals(ge)===!1&&(t.viewport(ge.x,ge.y,ge.z,ge.w),fe.copy(ge))}function ct(ge,Fe){let Ce=f.get(Fe);Ce===void 0&&(Ce=new WeakMap,f.set(Fe,Ce));let ye=Ce.get(ge);ye===void 0&&(ye=t.getUniformBlockIndex(Fe,ge.name),Ce.set(ge,ye))}function de(ge,Fe){const ye=f.get(Fe).get(ge);d.get(Fe)!==ye&&(t.uniformBlockBinding(Fe,ye,ge.__bindingPointIndex),d.set(Fe,ye))}function Ye(){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,me.set(0,0,t.canvas.width,t.canvas.height),fe.set(0,0,t.canvas.width,t.canvas.height),o.reset(),c.reset(),u.reset()}return{buffers:{color:o,depth:c,stencil:u},enable:re,disable:we,bindFramebuffer:Oe,drawBuffers:he,useProgram:ht,setBlending:ne,setMaterial:G,setFlipSided:Z,setCullFace:oe,setLineWidth:Ne,setPolygonOffset:Pe,setScissorTest:Se,activeTexture:B,bindTexture:L,unbindTexture:te,compressedTexImage2D:ve,compressedTexImage3D:_e,texImage2D:ae,texImage3D:Je,updateUBOMapping:ct,uniformBlockBinding:de,texStorage2D:Ve,texStorage3D:Ue,texSubImage2D:be,texSubImage3D:nt,compressedTexSubImage2D:Be,compressedTexSubImage3D:ue,scissor:He,viewport:Ke,reset:Ye}}function gUe(t,e,n,r,i,s,a){const o=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,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):Uw("canvas")}function S(B,L,te,ve){let _e=1;if((B.width>ve||B.height>ve)&&(_e=ve/Math.max(B.width,B.height)),_e<1||L===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){const be=L?Iw:Math.floor,nt=be(_e*B.width),Be=be(_e*B.height);y===void 0&&(y=E(nt,Be));const ue=te?E(nt,Be):y;return ue.width=nt,ue.height=Be,ue.getContext("2d").drawImage(B,0,0,nt,Be),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+nt+"x"+Be+")."),ue}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 DP(B.width)&&DP(B.height)}function T(B){return o?!1:B.wrapS!==ko||B.wrapT!==ko||B.minFilter!==Zi&&B.minFilter!==Za}function k(B,L){return B.generateMipmaps&&L&&B.minFilter!==Zi&&B.minFilter!==Za}function N(B){t.generateMipmap(B)}function I(B,L,te,ve,_e=!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 be=L;if(L===t.RED&&(te===t.FLOAT&&(be=t.R32F),te===t.HALF_FLOAT&&(be=t.R16F),te===t.UNSIGNED_BYTE&&(be=t.R8)),L===t.RED_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.R8UI),te===t.UNSIGNED_SHORT&&(be=t.R16UI),te===t.UNSIGNED_INT&&(be=t.R32UI),te===t.BYTE&&(be=t.R8I),te===t.SHORT&&(be=t.R16I),te===t.INT&&(be=t.R32I)),L===t.RG&&(te===t.FLOAT&&(be=t.RG32F),te===t.HALF_FLOAT&&(be=t.RG16F),te===t.UNSIGNED_BYTE&&(be=t.RG8)),L===t.RGBA){const nt=_e?Ow:Xn.getTransfer(ve);te===t.FLOAT&&(be=t.RGBA32F),te===t.HALF_FLOAT&&(be=t.RGBA16F),te===t.UNSIGNED_BYTE&&(be=nt===lr?t.SRGB8_ALPHA8:t.RGBA8),te===t.UNSIGNED_SHORT_4_4_4_4&&(be=t.RGBA4),te===t.UNSIGNED_SHORT_5_5_5_1&&(be=t.RGB5_A1)}return(be===t.R16F||be===t.R32F||be===t.RG16F||be===t.RG32F||be===t.RGBA16F||be===t.RGBA32F)&&e.get("EXT_color_buffer_float"),be}function C(B,L,te){return k(B,te)===!0||B.isFramebufferTexture&&B.minFilter!==Zi&&B.minFilter!==Za?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===Zi||B===VH||B===WC?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 te=B.source,ve=v.get(te);if(ve){const _e=ve[L.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&R(B),Object.keys(ve).length===0&&v.delete(te)}r.remove(B)}function R(B){const L=r.get(B);t.deleteTexture(L.__webglTexture);const te=B.source,ve=v.get(te);delete ve[L.__cacheKey],a.memory.textures--}function W(B){const L=B.texture,te=r.get(B),ve=r.get(L);if(ve.__webglTexture!==void 0&&(t.deleteTexture(ve.__webglTexture),a.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(te.__webglFramebuffer[_e]))for(let be=0;be<te.__webglFramebuffer[_e].length;be++)t.deleteFramebuffer(te.__webglFramebuffer[_e][be]);else t.deleteFramebuffer(te.__webglFramebuffer[_e]);te.__webglDepthbuffer&&t.deleteRenderbuffer(te.__webglDepthbuffer[_e])}else{if(Array.isArray(te.__webglFramebuffer))for(let _e=0;_e<te.__webglFramebuffer.length;_e++)t.deleteFramebuffer(te.__webglFramebuffer[_e]);else t.deleteFramebuffer(te.__webglFramebuffer);if(te.__webglDepthbuffer&&t.deleteRenderbuffer(te.__webglDepthbuffer),te.__webglMultisampledFramebuffer&&t.deleteFramebuffer(te.__webglMultisampledFramebuffer),te.__webglColorRenderbuffer)for(let _e=0;_e<te.__webglColorRenderbuffer.length;_e++)te.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(te.__webglColorRenderbuffer[_e]);te.__webglDepthRenderbuffer&&t.deleteRenderbuffer(te.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let _e=0,be=L.length;_e<be;_e++){const nt=r.get(L[_e]);nt.__webglTexture&&(t.deleteTexture(nt.__webglTexture),a.memory.textures--),r.remove(L[_e])}r.remove(L),r.remove(B)}let K=0;function V(){K=0}function ee(){const B=K;return B>=c&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+c),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 Q(B,L){const te=r.get(B);if(B.isVideoTexture&&Pe(B),B.isRenderTargetTexture===!1&&B.version>0&&te.__version!==B.version){const ve=B.image;if(ve===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{re(te,B,L);return}}n.bindTexture(t.TEXTURE_2D,te.__webglTexture,t.TEXTURE0+L)}function U(B,L){const te=r.get(B);if(B.version>0&&te.__version!==B.version){re(te,B,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,te.__webglTexture,t.TEXTURE0+L)}function z(B,L){const te=r.get(B);if(B.version>0&&te.__version!==B.version){re(te,B,L);return}n.bindTexture(t.TEXTURE_3D,te.__webglTexture,t.TEXTURE0+L)}function J(B,L){const te=r.get(B);if(B.version>0&&te.__version!==B.version){we(te,B,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture,t.TEXTURE0+L)}const se={[NP]:t.REPEAT,[ko]:t.CLAMP_TO_EDGE,[kP]:t.MIRRORED_REPEAT},me={[Zi]:t.NEAREST,[VH]:t.NEAREST_MIPMAP_NEAREST,[WC]:t.NEAREST_MIPMAP_LINEAR,[Za]:t.LINEAR,[zOe]:t.LINEAR_MIPMAP_NEAREST,[K0]:t.LINEAR_MIPMAP_LINEAR},fe={[QOe]:t.NEVER,[ije]:t.ALWAYS,[JOe]:t.LESS,[DZ]:t.LEQUAL,[eje]:t.EQUAL,[rje]:t.GEQUAL,[tje]:t.GREATER,[nje]:t.NOTEQUAL};function xe(B,L,te){if(te?(t.texParameteri(B,t.TEXTURE_WRAP_S,se[L.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,se[L.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,se[L.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,me[L.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,me[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!==ko||L.wrapT!==ko)&&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!==Zi&&L.minFilter!==Za&&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,fe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ve=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Zi||L.minFilter!==WC&&L.minFilter!==K0||L.type===xc&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===X0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(B,ve.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ee(B,L){let te=!1;B.__webglInit===void 0&&(B.__webglInit=!0,L.addEventListener("dispose",F));const ve=L.source;let _e=v.get(ve);_e===void 0&&(_e={},v.set(ve,_e));const be=Y(L);if(be!==B.__cacheKey){_e[be]===void 0&&(_e[be]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,te=!0),_e[be].usedTimes++;const nt=_e[B.__cacheKey];nt!==void 0&&(_e[B.__cacheKey].usedTimes--,nt.usedTimes===0&&R(L)),B.__cacheKey=be,B.__webglTexture=_e[be].texture}return te}function re(B,L,te){let ve=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ve=t.TEXTURE_3D);const _e=Ee(B,L),be=L.source;n.bindTexture(ve,B.__webglTexture,t.TEXTURE0+te);const nt=r.get(be);if(be.version!==nt.__version||_e===!0){n.activeTexture(t.TEXTURE0+te);const Be=Xn.getPrimaries(Xn.workingColorSpace),ue=L.colorSpace===Ja?null:Xn.getPrimaries(L.colorSpace),Ve=L.colorSpace===Ja||Be===ue?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,Ve);const Ue=T(L)&&A(L.image)===!1;let ae=S(L.image,Ue,!1,d);ae=Se(L,ae);const Je=A(ae)||o,He=s.convert(L.format,L.colorSpace);let Ke=s.convert(L.type),ct=I(L.internalFormat,He,Ke,L.colorSpace,L.isVideoTexture);xe(ve,L,Je);let de;const Ye=L.mipmaps,ge=o&&L.isVideoTexture!==!0&&ct!==kZ,Fe=nt.__version===void 0||_e===!0,Ce=C(L,ae,Je);if(L.isDepthTexture)ct=t.DEPTH_COMPONENT,o?L.type===xc?ct=t.DEPTH_COMPONENT32F:L.type===Bu?ct=t.DEPTH_COMPONENT24:L.type===Nh?ct=t.DEPTH24_STENCIL8:ct=t.DEPTH_COMPONENT16:L.type===xc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===kh&&ct===t.DEPTH_COMPONENT&&L.type!==dj&&L.type!==Bu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Bu,Ke=s.convert(L.type)),L.format===Om&&ct===t.DEPTH_COMPONENT&&(ct=t.DEPTH_STENCIL,L.type!==Nh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Nh,Ke=s.convert(L.type))),Fe&&(ge?n.texStorage2D(t.TEXTURE_2D,1,ct,ae.width,ae.height):n.texImage2D(t.TEXTURE_2D,0,ct,ae.width,ae.height,0,He,Ke,null));else if(L.isDataTexture)if(Ye.length>0&&Je){ge&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let ye=0,ce=Ye.length;ye<ce;ye++)de=Ye[ye],ge?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,de.width,de.height,He,Ke,de.data):n.texImage2D(t.TEXTURE_2D,ye,ct,de.width,de.height,0,He,Ke,de.data);L.generateMipmaps=!1}else ge?(Fe&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae.width,ae.height,He,Ke,ae.data)):n.texImage2D(t.TEXTURE_2D,0,ct,ae.width,ae.height,0,He,Ke,ae.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ge&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,ct,Ye[0].width,Ye[0].height,ae.depth);for(let ye=0,ce=Ye.length;ye<ce;ye++)de=Ye[ye],L.format!==Qa?He!==null?ge?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ye,0,0,0,de.width,de.height,ae.depth,He,de.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ye,ct,de.width,de.height,ae.depth,0,de.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage3D(t.TEXTURE_2D_ARRAY,ye,0,0,0,de.width,de.height,ae.depth,He,Ke,de.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ye,ct,de.width,de.height,ae.depth,0,He,Ke,de.data)}else{ge&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let ye=0,ce=Ye.length;ye<ce;ye++)de=Ye[ye],L.format!==Qa?He!==null?ge?n.compressedTexSubImage2D(t.TEXTURE_2D,ye,0,0,de.width,de.height,He,de.data):n.compressedTexImage2D(t.TEXTURE_2D,ye,ct,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,de.width,de.height,He,Ke,de.data):n.texImage2D(t.TEXTURE_2D,ye,ct,de.width,de.height,0,He,Ke,de.data)}else if(L.isDataArrayTexture)ge?(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ce,ct,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ae.width,ae.height,ae.depth,He,Ke,ae.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ct,ae.width,ae.height,ae.depth,0,He,Ke,ae.data);else if(L.isData3DTexture)ge?(Fe&&n.texStorage3D(t.TEXTURE_3D,Ce,ct,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ae.width,ae.height,ae.depth,He,Ke,ae.data)):n.texImage3D(t.TEXTURE_3D,0,ct,ae.width,ae.height,ae.depth,0,He,Ke,ae.data);else if(L.isFramebufferTexture){if(Fe)if(ge)n.texStorage2D(t.TEXTURE_2D,Ce,ct,ae.width,ae.height);else{let ye=ae.width,ce=ae.height;for(let at=0;at<Ce;at++)n.texImage2D(t.TEXTURE_2D,at,ct,ye,ce,0,He,Ke,null),ye>>=1,ce>>=1}}else if(Ye.length>0&&Je){ge&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,Ye[0].width,Ye[0].height);for(let ye=0,ce=Ye.length;ye<ce;ye++)de=Ye[ye],ge?n.texSubImage2D(t.TEXTURE_2D,ye,0,0,He,Ke,de):n.texImage2D(t.TEXTURE_2D,ye,ct,He,Ke,de);L.generateMipmaps=!1}else ge?(Fe&&n.texStorage2D(t.TEXTURE_2D,Ce,ct,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,He,Ke,ae)):n.texImage2D(t.TEXTURE_2D,0,ct,He,Ke,ae);k(L,Je)&&N(ve),nt.__version=be.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function we(B,L,te){if(L.image.length!==6)return;const ve=Ee(B,L),_e=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+te);const be=r.get(_e);if(_e.version!==be.__version||ve===!0){n.activeTexture(t.TEXTURE0+te);const nt=Xn.getPrimaries(Xn.workingColorSpace),Be=L.colorSpace===Ja?null:Xn.getPrimaries(L.colorSpace),ue=L.colorSpace===Ja||nt===Be?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,ue);const Ve=L.isCompressedTexture||L.image[0].isCompressedTexture,Ue=L.image[0]&&L.image[0].isDataTexture,ae=[];for(let ye=0;ye<6;ye++)!Ve&&!Ue?ae[ye]=S(L.image[ye],!1,!0,u):ae[ye]=Ue?L.image[ye].image:L.image[ye],ae[ye]=Se(L,ae[ye]);const Je=ae[0],He=A(Je)||o,Ke=s.convert(L.format,L.colorSpace),ct=s.convert(L.type),de=I(L.internalFormat,Ke,ct,L.colorSpace),Ye=o&&L.isVideoTexture!==!0,ge=be.__version===void 0||ve===!0;let Fe=C(L,Je,He);xe(t.TEXTURE_CUBE_MAP,L,He);let Ce;if(Ve){Ye&&ge&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,de,Je.width,Je.height);for(let ye=0;ye<6;ye++){Ce=ae[ye].mipmaps;for(let ce=0;ce<Ce.length;ce++){const at=Ce[ce];L.format!==Qa?Ke!==null?Ye?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,0,0,at.width,at.height,Ke,at.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,de,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,0,0,at.width,at.height,Ke,ct,at.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce,de,at.width,at.height,0,Ke,ct,at.data)}}}else{Ce=L.mipmaps,Ye&&ge&&(Ce.length>0&&Fe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,de,ae[0].width,ae[0].height));for(let ye=0;ye<6;ye++)if(Ue){Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,ae[ye].width,ae[ye].height,Ke,ct,ae[ye].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,de,ae[ye].width,ae[ye].height,0,Ke,ct,ae[ye].data);for(let ce=0;ce<Ce.length;ce++){const xt=Ce[ce].image[ye].image;Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,0,0,xt.width,xt.height,Ke,ct,xt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,de,xt.width,xt.height,0,Ke,ct,xt.data)}}else{Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,Ke,ct,ae[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,de,Ke,ct,ae[ye]);for(let ce=0;ce<Ce.length;ce++){const at=Ce[ce];Ye?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,0,0,Ke,ct,at.image[ye]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,ce+1,de,Ke,ct,at.image[ye])}}}k(L,He)&&N(t.TEXTURE_CUBE_MAP),be.__version=_e.version,L.onUpdate&&L.onUpdate(L)}B.__version=L.version}function Oe(B,L,te,ve,_e,be){const nt=s.convert(te.format,te.colorSpace),Be=s.convert(te.type),ue=I(te.internalFormat,nt,Be,te.colorSpace);if(!r.get(L).__hasExternalTextures){const Ue=Math.max(1,L.width>>be),ae=Math.max(1,L.height>>be);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,be,ue,Ue,ae,L.depth,0,nt,Be,null):n.texImage2D(_e,be,ue,Ue,ae,0,nt,Be,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),Ne(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,_e,r.get(te).__webglTexture,0,oe(L)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,_e,r.get(te).__webglTexture,be),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(B,L,te){if(t.bindRenderbuffer(t.RENDERBUFFER,B),L.depthBuffer&&!L.stencilBuffer){let ve=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(te||Ne(L)){const _e=L.depthTexture;_e&&_e.isDepthTexture&&(_e.type===xc?ve=t.DEPTH_COMPONENT32F:_e.type===Bu&&(ve=t.DEPTH_COMPONENT24));const be=oe(L);Ne(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,ve,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,be,ve,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ve,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,B)}else if(L.depthBuffer&&L.stencilBuffer){const ve=oe(L);te&&Ne(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,L.width,L.height):Ne(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,B)}else{const ve=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let _e=0;_e<ve.length;_e++){const be=ve[_e],nt=s.convert(be.format,be.colorSpace),Be=s.convert(be.type),ue=I(be.internalFormat,nt,Be,be.colorSpace),Ve=oe(L);te&&Ne(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,ue,L.width,L.height):Ne(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,ue,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,ue,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ht(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),Q(L.depthTexture,0);const ve=r.get(L.depthTexture).__webglTexture,_e=oe(L);if(L.depthTexture.format===kh)Ne(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0);else if(L.depthTexture.format===Om)Ne(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function $(B){const L=r.get(B),te=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!L.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");ht(L.__webglFramebuffer,B)}else if(te){L.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ve]),L.__webglDepthbuffer[ve]=t.createRenderbuffer(),he(L.__webglDepthbuffer[ve],B,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,B,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H(B,L,te){const ve=r.get(B);L!==void 0&&Oe(ve.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),te!==void 0&&$(B)}function ne(B){const L=B.texture,te=r.get(B),ve=r.get(L);B.addEventListener("dispose",j),B.isWebGLMultipleRenderTargets!==!0&&(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=L.version,a.memory.textures++);const _e=B.isWebGLCubeRenderTarget===!0,be=B.isWebGLMultipleRenderTargets===!0,nt=A(B)||o;if(_e){te.__webglFramebuffer=[];for(let Be=0;Be<6;Be++)if(o&&L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer[Be]=[];for(let ue=0;ue<L.mipmaps.length;ue++)te.__webglFramebuffer[Be][ue]=t.createFramebuffer()}else te.__webglFramebuffer[Be]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer=[];for(let Be=0;Be<L.mipmaps.length;Be++)te.__webglFramebuffer[Be]=t.createFramebuffer()}else te.__webglFramebuffer=t.createFramebuffer();if(be)if(i.drawBuffers){const Be=B.texture;for(let ue=0,Ve=Be.length;ue<Ve;ue++){const Ue=r.get(Be[ue]);Ue.__webglTexture===void 0&&(Ue.__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&&Ne(B)===!1){const Be=be?L:[L];te.__webglMultisampledFramebuffer=t.createFramebuffer(),te.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let ue=0;ue<Be.length;ue++){const Ve=Be[ue];te.__webglColorRenderbuffer[ue]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,te.__webglColorRenderbuffer[ue]);const Ue=s.convert(Ve.format,Ve.colorSpace),ae=s.convert(Ve.type),Je=I(Ve.internalFormat,Ue,ae,Ve.colorSpace,B.isXRRenderTarget===!0),He=oe(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,He,Je,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ue,t.RENDERBUFFER,te.__webglColorRenderbuffer[ue])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(te.__webglDepthRenderbuffer=t.createRenderbuffer(),he(te.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),xe(t.TEXTURE_CUBE_MAP,L,nt);for(let Be=0;Be<6;Be++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Oe(te.__webglFramebuffer[Be][ue],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,ue);else Oe(te.__webglFramebuffer[Be],B,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Be,0);k(L,nt)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(be){const Be=B.texture;for(let ue=0,Ve=Be.length;ue<Ve;ue++){const Ue=Be[ue],ae=r.get(Ue);n.bindTexture(t.TEXTURE_2D,ae.__webglTexture),xe(t.TEXTURE_2D,Ue,nt),Oe(te.__webglFramebuffer,B,Ue,t.COLOR_ATTACHMENT0+ue,t.TEXTURE_2D,0),k(Ue,nt)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Be=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(o?Be=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Be,ve.__webglTexture),xe(Be,L,nt),o&&L.mipmaps&&L.mipmaps.length>0)for(let ue=0;ue<L.mipmaps.length;ue++)Oe(te.__webglFramebuffer[ue],B,L,t.COLOR_ATTACHMENT0,Be,ue);else Oe(te.__webglFramebuffer,B,L,t.COLOR_ATTACHMENT0,Be,0);k(L,nt)&&N(Be),n.unbindTexture()}B.depthBuffer&&$(B)}function G(B){const L=A(B)||o,te=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let ve=0,_e=te.length;ve<_e;ve++){const be=te[ve];if(k(be,L)){const nt=B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Be=r.get(be).__webglTexture;n.bindTexture(nt,Be),N(nt),n.unbindTexture()}}}function Z(B){if(o&&B.samples>0&&Ne(B)===!1){const L=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],te=B.width,ve=B.height;let _e=t.COLOR_BUFFER_BIT;const be=[],nt=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Be=r.get(B),ue=B.isWebGLMultipleRenderTargets===!0;if(ue)for(let Ve=0;Ve<L.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Be.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglFramebuffer);for(let Ve=0;Ve<L.length;Ve++){be.push(t.COLOR_ATTACHMENT0+Ve),B.depthBuffer&&be.push(nt);const Ue=Be.__ignoreDepthValues!==void 0?Be.__ignoreDepthValues:!1;if(Ue===!1&&(B.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),ue&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Be.__webglColorRenderbuffer[Ve]),Ue===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[nt]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[nt])),ue){const ae=r.get(L[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ae,0)}t.blitFramebuffer(0,0,te,ve,0,0,te,ve,_e,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,be)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),ue)for(let Ve=0;Ve<L.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,Be.__webglColorRenderbuffer[Ve]);const Ue=r.get(L[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,Ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglMultisampledFramebuffer)}}function oe(B){return Math.min(f,B.samples)}function Ne(B){const L=r.get(B);return o&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Pe(B){const L=a.render.frame;x.get(B)!==L&&(x.set(B,L),B.update())}function Se(B,L){const te=B.colorSpace,ve=B.format,_e=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===RP||te!==Lc&&te!==Ja&&(Xn.getTransfer(te)===lr?o===!1?e.has("EXT_sRGB")===!0&&ve===Qa?(B.format=RP,B.minFilter=Za,B.generateMipmaps=!1):L=LZ.sRGBToLinear(L):(ve!==Qa||_e!==Qu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",te)),L}this.allocateTextureUnit=ee,this.resetTextureUnits=V,this.setTexture2D=Q,this.setTexture2DArray=U,this.setTexture3D=z,this.setTextureCube=J,this.rebindTextures=H,this.setupRenderTarget=ne,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=Z,this.setupDepthRenderbuffer=$,this.setupFrameBufferTexture=Oe,this.useMultisampledRTT=Ne}function xUe(t,e,n){const r=n.isWebGL2;function i(s,a=Ja){let o;const c=Xn.getTransfer(a);if(s===Qu)return t.UNSIGNED_BYTE;if(s===MZ)return t.UNSIGNED_SHORT_4_4_4_4;if(s===AZ)return t.UNSIGNED_SHORT_5_5_5_1;if(s===BOe)return t.BYTE;if(s===HOe)return t.SHORT;if(s===dj)return t.UNSIGNED_SHORT;if(s===EZ)return t.INT;if(s===Bu)return t.UNSIGNED_INT;if(s===xc)return t.FLOAT;if(s===X0)return r?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===$Oe)return t.ALPHA;if(s===Qa)return t.RGBA;if(s===VOe)return t.LUMINANCE;if(s===GOe)return t.LUMINANCE_ALPHA;if(s===kh)return t.DEPTH_COMPONENT;if(s===Om)return t.DEPTH_STENCIL;if(s===RP)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(s===WOe)return t.RED;if(s===TZ)return t.RED_INTEGER;if(s===qOe)return t.RG;if(s===CZ)return t.RG_INTEGER;if(s===NZ)return t.RGBA_INTEGER;if(s===qC||s===KC||s===XC||s===YC)if(c===lr)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(s===qC)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===KC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===XC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===YC)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===qC)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===KC)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===XC)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===YC)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===GH||s===WH||s===qH||s===KH)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===GH)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===WH)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===qH)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===KH)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===kZ)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===XH||s===YH)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(s===XH)return c===lr?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(s===YH)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===ZH||s===QH||s===JH||s===e$||s===t$||s===n$||s===r$||s===i$||s===s$||s===a$||s===o$||s===l$||s===c$||s===u$)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(s===ZH)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===QH)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===JH)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===e$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===t$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===n$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===r$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===i$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===s$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===a$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===o$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===l$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===c$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===u$)return c===lr?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===ZC||s===d$||s===h$)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(s===ZC)return c===lr?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===d$)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===h$)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===KOe||s===f$||s===p$||s===m$)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(s===ZC)return o.COMPRESSED_RED_RGTC1_EXT;if(s===f$)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===p$)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===m$)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===Nh?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 bUe extends ma{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Fx extends Ts{constructor(){super(),this.isGroup=!0,this.type="Group"}}const vUe={type:"move"};class yN{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Fx,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Fx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new De,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new De),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Fx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new 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,c=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 c!==null&&e.gripSpace&&(s=n.getPose(e.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.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(vUe)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=s!==null),u!==null&&(u.visible=a!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Fx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class yUe extends gf{constructor(e,n){super();const r=this;let i=null,s=1,a=null,o="local-floor",c=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 Zt;let T=null;const k=new ma;k.layers.enable(1),k.viewport=new Zn;const N=new ma;N.layers.enable(2),N.viewport=new Zn;const I=[k,N],C=new bUe;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(J){let se=E[J];return se===void 0&&(se=new yN,E[J]=se),se.getTargetRaySpace()},this.getControllerGrip=function(J){let se=E[J];return se===void 0&&(se=new yN,E[J]=se),se.getGripSpace()},this.getHand=function(J){let se=E[J];return se===void 0&&(se=new yN,E[J]=se),se.getHandSpace()};function j(J){const se=S.indexOf(J.inputSource);if(se===-1)return;const me=E[se];me!==void 0&&(me.update(J.inputSource,J.frame,u||a),me.dispatchEvent({type:J.type,data:J.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 J=0;J<E.length;J++){const se=S[J];se!==null&&(S[J]=null,E[J].disconnect(se))}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(J){s=J,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(J){o=J,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||a},this.setReferenceSpace=function(J){u=J},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(J){if(i=J,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 se={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,se),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new nf(m.framebufferWidth,m.framebufferHeight,{format:Qa,type:Qu,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let se=null,me=null,fe=null;y.depth&&(fe=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,se=y.stencil?Om:kh,me=y.stencil?Nh:Bu);const xe={colorFormat:n.RGBA8,depthFormat:fe,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 nf(g.textureWidth,g.textureHeight,{format:Qa,type:Qu,depthTexture:new KZ(g.textureWidth,g.textureHeight,me,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Ee=e.properties.get(b);Ee.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(c),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(J){for(let se=0;se<J.removed.length;se++){const me=J.removed[se],fe=S.indexOf(me);fe>=0&&(S[fe]=null,E[fe].disconnect(me))}for(let se=0;se<J.added.length;se++){const me=J.added[se];let fe=S.indexOf(me);if(fe===-1){for(let Ee=0;Ee<E.length;Ee++)if(Ee>=S.length){S.push(me),fe=Ee;break}else if(S[Ee]===null){S[Ee]=me,fe=Ee;break}if(fe===-1)break}const xe=E[fe];xe&&xe.connect(me)}}const W=new De,K=new De;function V(J,se,me){W.setFromMatrixPosition(se.matrixWorld),K.setFromMatrixPosition(me.matrixWorld);const fe=W.distanceTo(K),xe=se.projectionMatrix.elements,Ee=me.projectionMatrix.elements,re=xe[14]/(xe[10]-1),we=xe[14]/(xe[10]+1),Oe=(xe[9]+1)/xe[5],he=(xe[9]-1)/xe[5],ht=(xe[8]-1)/xe[0],$=(Ee[8]+1)/Ee[0],H=re*ht,ne=re*$,G=fe/(-ht+$),Z=G*-ht;se.matrixWorld.decompose(J.position,J.quaternion,J.scale),J.translateX(Z),J.translateZ(G),J.matrixWorld.compose(J.position,J.quaternion,J.scale),J.matrixWorldInverse.copy(J.matrixWorld).invert();const oe=re+G,Ne=we+G,Pe=H-Z,Se=ne+(fe-Z),B=Oe*we/Ne*oe,L=he*we/Ne*oe;J.projectionMatrix.makePerspective(Pe,Se,B,L,oe,Ne),J.projectionMatrixInverse.copy(J.projectionMatrix).invert()}function ee(J,se){se===null?J.matrixWorld.copy(J.matrix):J.matrixWorld.multiplyMatrices(se.matrixWorld,J.matrix),J.matrixWorldInverse.copy(J.matrixWorld).invert()}this.updateCamera=function(J){if(i===null)return;C.near=N.near=k.near=J.near,C.far=N.far=k.far=J.far,(D!==C.near||F!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),D=C.near,F=C.far);const se=J.parent,me=C.cameras;ee(C,se);for(let fe=0;fe<me.length;fe++)ee(me[fe],se);me.length===2?V(C,k,N):C.projectionMatrix.copy(k.projectionMatrix),Y(J,C,se)};function Y(J,se,me){me===null?J.matrix.copy(se.matrixWorld):(J.matrix.copy(me.matrixWorld),J.matrix.invert(),J.matrix.multiply(se.matrixWorld)),J.matrix.decompose(J.position,J.quaternion,J.scale),J.updateMatrixWorld(!0),J.projectionMatrix.copy(se.projectionMatrix),J.projectionMatrixInverse.copy(se.projectionMatrixInverse),J.isPerspectiveCamera&&(J.fov=Z0*2*Math.atan(1/J.projectionMatrix.elements[5]),J.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(g===null&&m===null))return c},this.setFoveation=function(J){c=J,g!==null&&(g.fixedFoveation=J),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=J)};let Q=null;function U(J,se){if(d=se.getViewerPose(u||a),x=se,d!==null){const me=d.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let fe=!1;me.length!==C.cameras.length&&(C.cameras.length=0,fe=!0);for(let xe=0;xe<me.length;xe++){const Ee=me[xe];let re=null;if(m!==null)re=m.getViewport(Ee);else{const Oe=f.getViewSubImage(g,Ee);re=Oe.viewport,xe===0&&(e.setRenderTargetTextures(b,Oe.colorTexture,g.ignoreDepthValues?void 0:Oe.depthStencilTexture),e.setRenderTarget(b))}let we=I[xe];we===void 0&&(we=new ma,we.layers.enable(xe),we.viewport=new Zn,I[xe]=we),we.matrix.fromArray(Ee.transform.matrix),we.matrix.decompose(we.position,we.quaternion,we.scale),we.projectionMatrix.fromArray(Ee.projectionMatrix),we.projectionMatrixInverse.copy(we.projectionMatrix).invert(),we.viewport.set(re.x,re.y,re.width,re.height),xe===0&&(C.matrix.copy(we.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),fe===!0&&C.cameras.push(we)}}for(let me=0;me<E.length;me++){const fe=S[me],xe=E[me];fe!==null&&xe!==void 0&&xe.update(fe,se,u||a)}Q&&Q(J,se),se.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:se}),x=null}const z=new qZ;z.setAnimationLoop(U),this.setAnimationLoop=function(J){Q=J},this.dispose=function(){}}}function _Ue(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,VZ(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?c(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===Xs&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===Xs&&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 c(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===Xs&&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 wUe(t,e,n,r){let i={},s={},a=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(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:c,update:u,dispose:b}}class jP{constructor(e={}){const{canvas:n=vje(),context:r=null,depth:i=!0,stencil:s=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=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=Qi,this._useLegacyLights=!1,this.toneMapping=Zu,this.toneMappingExposure=1;const S=this;let A=!1,T=0,k=0,N=null,I=-1,C=null;const D=new Zn,F=new Zn;let j=null;const q=new $t(0);let R=0,W=n.width,K=n.height,V=1,ee=null,Y=null;const Q=new Zn(0,0,W,K),U=new Zn(0,0,W,K);let z=!1;const J=new VE;let se=!1,me=!1,fe=null;const xe=new sr,Ee=new Zt,re=new De,we={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Oe(){return N===null?V:1}let he=r;function ht(pe,$e){for(let rt=0;rt<pe.length;rt++){const it=pe[rt],et=n.getContext(it,$e);if(et!==null)return et}return null}try{const pe={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${BE}`),n.addEventListener("webglcontextlost",Ye,!1),n.addEventListener("webglcontextrestored",ge,!1),n.addEventListener("webglcontextcreationerror",Fe,!1),he===null){const $e=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&$e.shift(),he=ht($e,pe),he===null)throw ht($e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&he instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),he.getShaderPrecisionFormat===void 0&&(he.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(pe){throw console.error("THREE.WebGLRenderer: "+pe.message),pe}let $,H,ne,G,Z,oe,Ne,Pe,Se,B,L,te,ve,_e,be,nt,Be,ue,Ve,Ue,ae,Je,He,Ke;function ct(){$=new D4e(he),H=new A4e(he,$,e),$.init(H),Je=new xUe(he,$,H),ne=new mUe(he,$,H),G=new L4e(he),Z=new tUe,oe=new gUe(he,$,ne,Z,H,Je,G),Ne=new C4e(S),Pe=new R4e(S),Se=new $je(he,H),He=new E4e(he,$,Se,H),B=new O4e(he,Se,G,He),L=new z4e(he,B,Se,G),Ve=new F4e(he,H,oe),nt=new T4e(Z),te=new eUe(S,Ne,Pe,$,H,He,nt),ve=new _Ue(S,Z),_e=new rUe,be=new cUe($,H),ue=new S4e(S,Ne,Pe,ne,L,g,c),Be=new pUe(S,L,H),Ke=new wUe(he,G,H,ne),Ue=new M4e(he,$,G,H),ae=new j4e(he,$,G,H),G.programs=te.programs,S.capabilities=H,S.extensions=$,S.properties=Z,S.renderLists=_e,S.shadowMap=Be,S.state=ne,S.info=G}ct();const de=new yUe(S,he);this.xr=de,this.getContext=function(){return he},this.getContextAttributes=function(){return he.getContextAttributes()},this.forceContextLoss=function(){const pe=$.get("WEBGL_lose_context");pe&&pe.loseContext()},this.forceContextRestore=function(){const pe=$.get("WEBGL_lose_context");pe&&pe.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(pe){pe!==void 0&&(V=pe,this.setSize(W,K,!1))},this.getSize=function(pe){return pe.set(W,K)},this.setSize=function(pe,$e,rt=!0){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=pe,K=$e,n.width=Math.floor(pe*V),n.height=Math.floor($e*V),rt===!0&&(n.style.width=pe+"px",n.style.height=$e+"px"),this.setViewport(0,0,pe,$e)},this.getDrawingBufferSize=function(pe){return pe.set(W*V,K*V).floor()},this.setDrawingBufferSize=function(pe,$e,rt){W=pe,K=$e,V=rt,n.width=Math.floor(pe*rt),n.height=Math.floor($e*rt),this.setViewport(0,0,pe,$e)},this.getCurrentViewport=function(pe){return pe.copy(D)},this.getViewport=function(pe){return pe.copy(Q)},this.setViewport=function(pe,$e,rt,it){pe.isVector4?Q.set(pe.x,pe.y,pe.z,pe.w):Q.set(pe,$e,rt,it),ne.viewport(D.copy(Q).multiplyScalar(V).floor())},this.getScissor=function(pe){return pe.copy(U)},this.setScissor=function(pe,$e,rt,it){pe.isVector4?U.set(pe.x,pe.y,pe.z,pe.w):U.set(pe,$e,rt,it),ne.scissor(F.copy(U).multiplyScalar(V).floor())},this.getScissorTest=function(){return z},this.setScissorTest=function(pe){ne.setScissorTest(z=pe)},this.setOpaqueSort=function(pe){ee=pe},this.setTransparentSort=function(pe){Y=pe},this.getClearColor=function(pe){return pe.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(pe=!0,$e=!0,rt=!0){let it=0;if(pe){let et=!1;if(N!==null){const Et=N.texture.format;et=Et===NZ||Et===CZ||Et===TZ}if(et){const Et=N.texture.type,ie=Et===Qu||Et===Bu||Et===dj||Et===Nh||Et===MZ||Et===AZ,Me=ue.getClearColor(),Ie=ue.getClearAlpha(),je=Me.r,Te=Me.g,ot=Me.b;ie?(m[0]=je,m[1]=Te,m[2]=ot,m[3]=Ie,he.clearBufferuiv(he.COLOR,0,m)):(x[0]=je,x[1]=Te,x[2]=ot,x[3]=Ie,he.clearBufferiv(he.COLOR,0,x))}else it|=he.COLOR_BUFFER_BIT}$e&&(it|=he.DEPTH_BUFFER_BIT),rt&&(it|=he.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),he.clear(it)},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",Ye,!1),n.removeEventListener("webglcontextrestored",ge,!1),n.removeEventListener("webglcontextcreationerror",Fe,!1),_e.dispose(),be.dispose(),Z.dispose(),Ne.dispose(),Pe.dispose(),L.dispose(),He.dispose(),Ke.dispose(),te.dispose(),de.dispose(),de.removeEventListener("sessionstart",Qt),de.removeEventListener("sessionend",jt),fe&&(fe.dispose(),fe=null),Vt.stop()};function Ye(pe){pe.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ge(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const pe=G.autoReset,$e=Be.enabled,rt=Be.autoUpdate,it=Be.needsUpdate,et=Be.type;ct(),G.autoReset=pe,Be.enabled=$e,Be.autoUpdate=rt,Be.needsUpdate=it,Be.type=et}function Fe(pe){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",pe.statusMessage)}function Ce(pe){const $e=pe.target;$e.removeEventListener("dispose",Ce),ye($e)}function ye(pe){ce(pe),Z.remove(pe)}function ce(pe){const $e=Z.get(pe).programs;$e!==void 0&&($e.forEach(function(rt){te.releaseProgram(rt)}),pe.isShaderMaterial&&te.releaseShaderCache(pe))}this.renderBufferDirect=function(pe,$e,rt,it,et,Et){$e===null&&($e=we);const ie=et.isMesh&&et.matrixWorld.determinant()<0,Me=Or(pe,$e,rt,it,et);ne.setMaterial(it,ie);let Ie=rt.index,je=1;if(it.wireframe===!0){if(Ie=B.getWireframeAttribute(rt),Ie===void 0)return;je=2}const Te=rt.drawRange,ot=rt.attributes.position;let ft=Te.start*je,vt=(Te.start+Te.count)*je;Et!==null&&(ft=Math.max(ft,Et.start*je),vt=Math.min(vt,(Et.start+Et.count)*je)),Ie!==null?(ft=Math.max(ft,0),vt=Math.min(vt,Ie.count)):ot!=null&&(ft=Math.max(ft,0),vt=Math.min(vt,ot.count));const bt=vt-ft;if(bt<0||bt===1/0)return;He.setup(et,it,Me,rt,Ie);let Lt,Tt=Ue;if(Ie!==null&&(Lt=Se.get(Ie),Tt=ae,Tt.setIndex(Lt)),et.isMesh)it.wireframe===!0?(ne.setLineWidth(it.wireframeLinewidth*Oe()),Tt.setMode(he.LINES)):Tt.setMode(he.TRIANGLES);else if(et.isLine){let mt=it.linewidth;mt===void 0&&(mt=1),ne.setLineWidth(mt*Oe()),et.isLineSegments?Tt.setMode(he.LINES):et.isLineLoop?Tt.setMode(he.LINE_LOOP):Tt.setMode(he.LINE_STRIP)}else et.isPoints?Tt.setMode(he.POINTS):et.isSprite&&Tt.setMode(he.TRIANGLES);if(et.isBatchedMesh)Tt.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)Tt.renderInstances(ft,bt,et.count);else if(rt.isInstancedBufferGeometry){const mt=rt._maxInstanceCount!==void 0?rt._maxInstanceCount:1/0,Xt=Math.min(rt.instanceCount,mt);Tt.renderInstances(ft,bt,Xt)}else Tt.render(ft,bt)};function at(pe,$e,rt){pe.transparent===!0&&pe.side===dc&&pe.forceSinglePass===!1?(pe.side=Xs,pe.needsUpdate=!0,rs(pe,$e,rt),pe.side=fd,pe.needsUpdate=!0,rs(pe,$e,rt),pe.side=dc):rs(pe,$e,rt)}this.compile=function(pe,$e,rt=null){rt===null&&(rt=pe),v=be.get(rt),v.init(),E.push(v),rt.traverseVisible(function(et){et.isLight&&et.layers.test($e.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),pe!==rt&&pe.traverseVisible(function(et){et.isLight&&et.layers.test($e.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),v.setupLights(S._useLegacyLights);const it=new Set;return pe.traverse(function(et){const Et=et.material;if(Et)if(Array.isArray(Et))for(let ie=0;ie<Et.length;ie++){const Me=Et[ie];at(Me,rt,et),it.add(Me)}else at(Et,rt,et),it.add(Et)}),E.pop(),v=null,it},this.compileAsync=function(pe,$e,rt=null){const it=this.compile(pe,$e,rt);return new Promise(et=>{function Et(){if(it.forEach(function(ie){Z.get(ie).currentProgram.isReady()&&it.delete(ie)}),it.size===0){et(pe);return}setTimeout(Et,10)}$.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let xt=null;function St(pe){xt&&xt(pe)}function Qt(){Vt.stop()}function jt(){Vt.start()}const Vt=new qZ;Vt.setAnimationLoop(St),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(pe){xt=pe,de.setAnimationLoop(pe),pe===null?Vt.stop():Vt.start()},de.addEventListener("sessionstart",Qt),de.addEventListener("sessionend",jt),this.render=function(pe,$e){if($e!==void 0&&$e.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;pe.matrixWorldAutoUpdate===!0&&pe.updateMatrixWorld(),$e.parent===null&&$e.matrixWorldAutoUpdate===!0&&$e.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(de.cameraAutoUpdate===!0&&de.updateCamera($e),$e=de.getCamera()),pe.isScene===!0&&pe.onBeforeRender(S,pe,$e,N),v=be.get(pe,E.length),v.init(),E.push(v),xe.multiplyMatrices($e.projectionMatrix,$e.matrixWorldInverse),J.setFromProjectionMatrix(xe),me=this.localClippingEnabled,se=nt.init(this.clippingPlanes,me),y=_e.get(pe,b.length),y.init(),b.push(y),jn(pe,$e,0,S.sortObjects),y.finish(),S.sortObjects===!0&&y.sort(ee,Y),this.info.render.frame++,se===!0&&nt.beginShadows();const rt=v.state.shadowsArray;if(Be.render(rt,pe,$e),se===!0&&nt.endShadows(),this.info.autoReset===!0&&this.info.reset(),ue.render(y,pe),v.setupLights(S._useLegacyLights),$e.isArrayCamera){const it=$e.cameras;for(let et=0,Et=it.length;et<Et;et++){const ie=it[et];Ei(y,pe,ie,ie.viewport)}}else Ei(y,pe,$e);N!==null&&(oe.updateMultisampleRenderTarget(N),oe.updateRenderTargetMipmap(N)),pe.isScene===!0&&pe.onAfterRender(S,pe,$e),He.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 jn(pe,$e,rt,it){if(pe.visible===!1)return;if(pe.layers.test($e.layers)){if(pe.isGroup)rt=pe.renderOrder;else if(pe.isLOD)pe.autoUpdate===!0&&pe.update($e);else if(pe.isLight)v.pushLight(pe),pe.castShadow&&v.pushShadow(pe);else if(pe.isSprite){if(!pe.frustumCulled||J.intersectsSprite(pe)){it&&re.setFromMatrixPosition(pe.matrixWorld).applyMatrix4(xe);const ie=L.update(pe),Me=pe.material;Me.visible&&y.push(pe,ie,Me,rt,re.z,null)}}else if((pe.isMesh||pe.isLine||pe.isPoints)&&(!pe.frustumCulled||J.intersectsObject(pe))){const ie=L.update(pe),Me=pe.material;if(it&&(pe.boundingSphere!==void 0?(pe.boundingSphere===null&&pe.computeBoundingSphere(),re.copy(pe.boundingSphere.center)):(ie.boundingSphere===null&&ie.computeBoundingSphere(),re.copy(ie.boundingSphere.center)),re.applyMatrix4(pe.matrixWorld).applyMatrix4(xe)),Array.isArray(Me)){const Ie=ie.groups;for(let je=0,Te=Ie.length;je<Te;je++){const ot=Ie[je],ft=Me[ot.materialIndex];ft&&ft.visible&&y.push(pe,ie,ft,rt,re.z,ot)}}else Me.visible&&y.push(pe,ie,Me,rt,re.z,null)}}const Et=pe.children;for(let ie=0,Me=Et.length;ie<Me;ie++)jn(Et[ie],$e,rt,it)}function Ei(pe,$e,rt,it){const et=pe.opaque,Et=pe.transmissive,ie=pe.transparent;v.setupLightsView(rt),se===!0&&nt.setGlobalState(S.clippingPlanes,rt),Et.length>0&&ai(et,Et,$e,rt),it&&ne.viewport(D.copy(it)),et.length>0&&Mi(et,$e,rt),Et.length>0&&Mi(Et,$e,rt),ie.length>0&&Mi(ie,$e,rt),ne.buffers.depth.setTest(!0),ne.buffers.depth.setMask(!0),ne.buffers.color.setMask(!0),ne.setPolygonOffset(!1)}function ai(pe,$e,rt,it){if((rt.isScene===!0?rt.overrideMaterial:null)!==null)return;const Et=H.isWebGL2;fe===null&&(fe=new nf(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")?X0:Qu,minFilter:K0,samples:Et?4:0})),S.getDrawingBufferSize(Ee),Et?fe.setSize(Ee.x,Ee.y):fe.setSize(Iw(Ee.x),Iw(Ee.y));const ie=S.getRenderTarget();S.setRenderTarget(fe),S.getClearColor(q),R=S.getClearAlpha(),R<1&&S.setClearColor(16777215,.5),S.clear();const Me=S.toneMapping;S.toneMapping=Zu,Mi(pe,rt,it),oe.updateMultisampleRenderTarget(fe),oe.updateRenderTargetMipmap(fe);let Ie=!1;for(let je=0,Te=$e.length;je<Te;je++){const ot=$e[je],ft=ot.object,vt=ot.geometry,bt=ot.material,Lt=ot.group;if(bt.side===dc&&ft.layers.test(it.layers)){const Tt=bt.side;bt.side=Xs,bt.needsUpdate=!0,zi(ft,rt,it,vt,bt,Lt),bt.side=Tt,bt.needsUpdate=!0,Ie=!0}}Ie===!0&&(oe.updateMultisampleRenderTarget(fe),oe.updateRenderTargetMipmap(fe)),S.setRenderTarget(ie),S.setClearColor(q,R),S.toneMapping=Me}function Mi(pe,$e,rt){const it=$e.isScene===!0?$e.overrideMaterial:null;for(let et=0,Et=pe.length;et<Et;et++){const ie=pe[et],Me=ie.object,Ie=ie.geometry,je=it===null?ie.material:it,Te=ie.group;Me.layers.test(rt.layers)&&zi(Me,$e,rt,Ie,je,Te)}}function zi(pe,$e,rt,it,et,Et){pe.onBeforeRender(S,$e,rt,it,et,Et),pe.modelViewMatrix.multiplyMatrices(rt.matrixWorldInverse,pe.matrixWorld),pe.normalMatrix.getNormalMatrix(pe.modelViewMatrix),et.onBeforeRender(S,$e,rt,it,pe,Et),et.transparent===!0&&et.side===dc&&et.forceSinglePass===!1?(et.side=Xs,et.needsUpdate=!0,S.renderBufferDirect(rt,$e,it,et,pe,Et),et.side=fd,et.needsUpdate=!0,S.renderBufferDirect(rt,$e,it,et,pe,Et),et.side=dc):S.renderBufferDirect(rt,$e,it,et,pe,Et),pe.onAfterRender(S,$e,rt,it,et,Et)}function rs(pe,$e,rt){$e.isScene!==!0&&($e=we);const it=Z.get(pe),et=v.state.lights,Et=v.state.shadowsArray,ie=et.state.version,Me=te.getParameters(pe,et.state,Et,$e,rt),Ie=te.getProgramCacheKey(Me);let je=it.programs;it.environment=pe.isMeshStandardMaterial?$e.environment:null,it.fog=$e.fog,it.envMap=(pe.isMeshStandardMaterial?Pe:Ne).get(pe.envMap||it.environment),je===void 0&&(pe.addEventListener("dispose",Ce),je=new Map,it.programs=je);let Te=je.get(Ie);if(Te!==void 0){if(it.currentProgram===Te&&it.lightsStateVersion===ie)return br(pe,Me),Te}else Me.uniforms=te.getUniforms(pe),pe.onBuild(rt,Me,S),pe.onBeforeCompile(Me,S),Te=te.acquireProgram(Me,Ie),je.set(Ie,Te),it.uniforms=Me.uniforms;const ot=it.uniforms;return(!pe.isShaderMaterial&&!pe.isRawShaderMaterial||pe.clipping===!0)&&(ot.clippingPlanes=nt.uniform),br(pe,Me),it.needsLights=Hc(pe),it.lightsStateVersion=ie,it.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),it.currentProgram=Te,it.uniformsList=null,Te}function Hr(pe){if(pe.uniformsList===null){const $e=pe.currentProgram.getUniforms();pe.uniformsList=p1.seqWithValue($e.seq,pe.uniforms)}return pe.uniformsList}function br(pe,$e){const rt=Z.get(pe);rt.outputColorSpace=$e.outputColorSpace,rt.batching=$e.batching,rt.instancing=$e.instancing,rt.instancingColor=$e.instancingColor,rt.skinning=$e.skinning,rt.morphTargets=$e.morphTargets,rt.morphNormals=$e.morphNormals,rt.morphColors=$e.morphColors,rt.morphTargetsCount=$e.morphTargetsCount,rt.numClippingPlanes=$e.numClippingPlanes,rt.numIntersection=$e.numClipIntersection,rt.vertexAlphas=$e.vertexAlphas,rt.vertexTangents=$e.vertexTangents,rt.toneMapping=$e.toneMapping}function Or(pe,$e,rt,it,et){$e.isScene!==!0&&($e=we),oe.resetTextureUnits();const Et=$e.fog,ie=it.isMeshStandardMaterial?$e.environment:null,Me=N===null?S.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Lc,Ie=(it.isMeshStandardMaterial?Pe:Ne).get(it.envMap||ie),je=it.vertexColors===!0&&!!rt.attributes.color&&rt.attributes.color.itemSize===4,Te=!!rt.attributes.tangent&&(!!it.normalMap||it.anisotropy>0),ot=!!rt.morphAttributes.position,ft=!!rt.morphAttributes.normal,vt=!!rt.morphAttributes.color;let bt=Zu;it.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(bt=S.toneMapping);const Lt=rt.morphAttributes.position||rt.morphAttributes.normal||rt.morphAttributes.color,Tt=Lt!==void 0?Lt.length:0,mt=Z.get(it),Xt=v.state.lights;if(se===!0&&(me===!0||pe!==C)){const jr=pe===C&&it.id===I;nt.setState(it,pe,jr)}let Ft=!1;it.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Xt.state.version||mt.outputColorSpace!==Me||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!==Ie||it.fog===!0&&mt.fog!==Et||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==nt.numPlanes||mt.numIntersection!==nt.numIntersection)||mt.vertexAlphas!==je||mt.vertexTangents!==Te||mt.morphTargets!==ot||mt.morphNormals!==ft||mt.morphColors!==vt||mt.toneMapping!==bt||H.isWebGL2===!0&&mt.morphTargetsCount!==Tt)&&(Ft=!0):(Ft=!0,mt.__version=it.version);let sn=mt.currentProgram;Ft===!0&&(sn=rs(it,$e,et));let hn=!1,bn=!1,Ut=!1;const Jt=sn.getUniforms(),tn=mt.uniforms;if(ne.useProgram(sn.program)&&(hn=!0,bn=!0,Ut=!0),it.id!==I&&(I=it.id,bn=!0),hn||C!==pe){Jt.setValue(he,"projectionMatrix",pe.projectionMatrix),Jt.setValue(he,"viewMatrix",pe.matrixWorldInverse);const jr=Jt.map.cameraPosition;jr!==void 0&&jr.setValue(he,re.setFromMatrixPosition(pe.matrixWorld)),H.logarithmicDepthBuffer&&Jt.setValue(he,"logDepthBufFC",2/(Math.log(pe.far+1)/Math.LN2)),(it.isMeshPhongMaterial||it.isMeshToonMaterial||it.isMeshLambertMaterial||it.isMeshBasicMaterial||it.isMeshStandardMaterial||it.isShaderMaterial)&&Jt.setValue(he,"isOrthographic",pe.isOrthographicCamera===!0),C!==pe&&(C=pe,bn=!0,Ut=!0)}if(et.isSkinnedMesh){Jt.setOptional(he,et,"bindMatrix"),Jt.setOptional(he,et,"bindMatrixInverse");const jr=et.skeleton;jr&&(H.floatVertexTextures?(jr.boneTexture===null&&jr.computeBoneTexture(),Jt.setValue(he,"boneTexture",jr.boneTexture,oe)):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&&(Jt.setOptional(he,et,"batchingTexture"),Jt.setValue(he,"batchingTexture",et._matricesTexture,oe));const Ar=rt.morphAttributes;if((Ar.position!==void 0||Ar.normal!==void 0||Ar.color!==void 0&&H.isWebGL2===!0)&&Ve.update(et,rt,sn),(bn||mt.receiveShadow!==et.receiveShadow)&&(mt.receiveShadow=et.receiveShadow,Jt.setValue(he,"receiveShadow",et.receiveShadow)),it.isMeshGouraudMaterial&&it.envMap!==null&&(tn.envMap.value=Ie,tn.flipEnvMap.value=Ie.isCubeTexture&&Ie.isRenderTargetTexture===!1?-1:1),bn&&(Jt.setValue(he,"toneMappingExposure",S.toneMappingExposure),mt.needsLights&&mo(tn,Ut),Et&&it.fog===!0&&ve.refreshFogUniforms(tn,Et),ve.refreshMaterialUniforms(tn,it,V,K,fe),p1.upload(he,Hr(mt),tn,oe)),it.isShaderMaterial&&it.uniformsNeedUpdate===!0&&(p1.upload(he,Hr(mt),tn,oe),it.uniformsNeedUpdate=!1),it.isSpriteMaterial&&Jt.setValue(he,"center",et.center),Jt.setValue(he,"modelViewMatrix",et.modelViewMatrix),Jt.setValue(he,"normalMatrix",et.normalMatrix),Jt.setValue(he,"modelMatrix",et.matrixWorld),it.isShaderMaterial||it.isRawShaderMaterial){const jr=it.uniformsGroups;for(let Dn=0,go=jr.length;Dn<go;Dn++)if(H.isWebGL2){const Ln=jr[Dn];Ke.update(Ln,sn),Ke.bind(Ln,sn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return sn}function mo(pe,$e){pe.ambientLightColor.needsUpdate=$e,pe.lightProbe.needsUpdate=$e,pe.directionalLights.needsUpdate=$e,pe.directionalLightShadows.needsUpdate=$e,pe.pointLights.needsUpdate=$e,pe.pointLightShadows.needsUpdate=$e,pe.spotLights.needsUpdate=$e,pe.spotLightShadows.needsUpdate=$e,pe.rectAreaLights.needsUpdate=$e,pe.hemisphereLights.needsUpdate=$e}function Hc(pe){return pe.isMeshLambertMaterial||pe.isMeshToonMaterial||pe.isMeshPhongMaterial||pe.isMeshStandardMaterial||pe.isShadowMaterial||pe.isShaderMaterial&&pe.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(pe,$e,rt){Z.get(pe.texture).__webglTexture=$e,Z.get(pe.depthTexture).__webglTexture=rt;const it=Z.get(pe);it.__hasExternalTextures=!0,it.__hasExternalTextures&&(it.__autoAllocateDepthBuffer=rt===void 0,it.__autoAllocateDepthBuffer||$.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),it.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(pe,$e){const rt=Z.get(pe);rt.__webglFramebuffer=$e,rt.__useDefaultFramebuffer=$e===void 0},this.setRenderTarget=function(pe,$e=0,rt=0){N=pe,T=$e,k=rt;let it=!0,et=null,Et=!1,ie=!1;if(pe){const Ie=Z.get(pe);Ie.__useDefaultFramebuffer!==void 0?(ne.bindFramebuffer(he.FRAMEBUFFER,null),it=!1):Ie.__webglFramebuffer===void 0?oe.setupRenderTarget(pe):Ie.__hasExternalTextures&&oe.rebindTextures(pe,Z.get(pe.texture).__webglTexture,Z.get(pe.depthTexture).__webglTexture);const je=pe.texture;(je.isData3DTexture||je.isDataArrayTexture||je.isCompressedArrayTexture)&&(ie=!0);const Te=Z.get(pe).__webglFramebuffer;pe.isWebGLCubeRenderTarget?(Array.isArray(Te[$e])?et=Te[$e][rt]:et=Te[$e],Et=!0):H.isWebGL2&&pe.samples>0&&oe.useMultisampledRTT(pe)===!1?et=Z.get(pe).__webglMultisampledFramebuffer:Array.isArray(Te)?et=Te[rt]:et=Te,D.copy(pe.viewport),F.copy(pe.scissor),j=pe.scissorTest}else D.copy(Q).multiplyScalar(V).floor(),F.copy(U).multiplyScalar(V).floor(),j=z;if(ne.bindFramebuffer(he.FRAMEBUFFER,et)&&H.drawBuffers&&it&&ne.drawBuffers(pe,et),ne.viewport(D),ne.scissor(F),ne.setScissorTest(j),Et){const Ie=Z.get(pe.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Ie.__webglTexture,rt)}else if(ie){const Ie=Z.get(pe.texture),je=$e||0;he.framebufferTextureLayer(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,Ie.__webglTexture,rt||0,je)}I=-1},this.readRenderTargetPixels=function(pe,$e,rt,it,et,Et,ie){if(!(pe&&pe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Me=Z.get(pe).__webglFramebuffer;if(pe.isWebGLCubeRenderTarget&&ie!==void 0&&(Me=Me[ie]),Me){ne.bindFramebuffer(he.FRAMEBUFFER,Me);try{const Ie=pe.texture,je=Ie.format,Te=Ie.type;if(je!==Qa&&Je.convert(je)!==he.getParameter(he.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ot=Te===X0&&($.has("EXT_color_buffer_half_float")||H.isWebGL2&&$.has("EXT_color_buffer_float"));if(Te!==Qu&&Je.convert(Te)!==he.getParameter(he.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Te===xc&&(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}$e>=0&&$e<=pe.width-it&&rt>=0&&rt<=pe.height-et&&he.readPixels($e,rt,it,et,Je.convert(je),Je.convert(Te),Et)}finally{const Ie=N!==null?Z.get(N).__webglFramebuffer:null;ne.bindFramebuffer(he.FRAMEBUFFER,Ie)}}},this.copyFramebufferToTexture=function(pe,$e,rt=0){const it=Math.pow(2,-rt),et=Math.floor($e.image.width*it),Et=Math.floor($e.image.height*it);oe.setTexture2D($e,0),he.copyTexSubImage2D(he.TEXTURE_2D,rt,0,0,pe.x,pe.y,et,Et),ne.unbindTexture()},this.copyTextureToTexture=function(pe,$e,rt,it=0){const et=$e.image.width,Et=$e.image.height,ie=Je.convert(rt.format),Me=Je.convert(rt.type);oe.setTexture2D(rt,0),he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,rt.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,rt.unpackAlignment),$e.isDataTexture?he.texSubImage2D(he.TEXTURE_2D,it,pe.x,pe.y,et,Et,ie,Me,$e.image.data):$e.isCompressedTexture?he.compressedTexSubImage2D(he.TEXTURE_2D,it,pe.x,pe.y,$e.mipmaps[0].width,$e.mipmaps[0].height,ie,$e.mipmaps[0].data):he.texSubImage2D(he.TEXTURE_2D,it,pe.x,pe.y,ie,Me,$e.image),it===0&&rt.generateMipmaps&&he.generateMipmap(he.TEXTURE_2D),ne.unbindTexture()},this.copyTextureToTexture3D=function(pe,$e,rt,it,et=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Et=pe.max.x-pe.min.x+1,ie=pe.max.y-pe.min.y+1,Me=pe.max.z-pe.min.z+1,Ie=Je.convert(it.format),je=Je.convert(it.type);let Te;if(it.isData3DTexture)oe.setTexture3D(it,0),Te=he.TEXTURE_3D;else if(it.isDataArrayTexture)oe.setTexture2DArray(it,0),Te=he.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,it.flipY),he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,it.premultiplyAlpha),he.pixelStorei(he.UNPACK_ALIGNMENT,it.unpackAlignment);const ot=he.getParameter(he.UNPACK_ROW_LENGTH),ft=he.getParameter(he.UNPACK_IMAGE_HEIGHT),vt=he.getParameter(he.UNPACK_SKIP_PIXELS),bt=he.getParameter(he.UNPACK_SKIP_ROWS),Lt=he.getParameter(he.UNPACK_SKIP_IMAGES),Tt=rt.isCompressedTexture?rt.mipmaps[0]:rt.image;he.pixelStorei(he.UNPACK_ROW_LENGTH,Tt.width),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,Tt.height),he.pixelStorei(he.UNPACK_SKIP_PIXELS,pe.min.x),he.pixelStorei(he.UNPACK_SKIP_ROWS,pe.min.y),he.pixelStorei(he.UNPACK_SKIP_IMAGES,pe.min.z),rt.isDataTexture||rt.isData3DTexture?he.texSubImage3D(Te,et,$e.x,$e.y,$e.z,Et,ie,Me,Ie,je,Tt.data):rt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),he.compressedTexSubImage3D(Te,et,$e.x,$e.y,$e.z,Et,ie,Me,Ie,Tt.data)):he.texSubImage3D(Te,et,$e.x,$e.y,$e.z,Et,ie,Me,Ie,je,Tt),he.pixelStorei(he.UNPACK_ROW_LENGTH,ot),he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,ft),he.pixelStorei(he.UNPACK_SKIP_PIXELS,vt),he.pixelStorei(he.UNPACK_SKIP_ROWS,bt),he.pixelStorei(he.UNPACK_SKIP_IMAGES,Lt),et===0&&it.generateMipmaps&&he.generateMipmap(Te),ne.unbindTexture()},this.initTexture=function(pe){pe.isCubeTexture?oe.setTextureCube(pe,0):pe.isData3DTexture?oe.setTexture3D(pe,0):pe.isDataArrayTexture||pe.isCompressedArrayTexture?oe.setTexture2DArray(pe,0):oe.setTexture2D(pe,0),ne.unbindTexture()},this.resetState=function(){T=0,k=0,N=null,ne.reset(),He.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ll}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===hj?"display-p3":"srgb",n.unpackColorSpace=Xn.workingColorSpace===$E?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Qi?Ph:PZ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ph?Qi:Lc}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 SUe extends jP{}SUe.prototype.isWebGL1Renderer=!0;class bj{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 bj(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class EUe extends Ts{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 MUe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=PP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Ec()}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=Ec()),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=Ec()),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 ys=new De;class Hu{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++)ys.fromBufferAttribute(this,n),ys.applyMatrix4(e),this.setXYZ(n,ys.x,ys.y,ys.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ys.fromBufferAttribute(this,n),ys.applyNormalMatrix(e),this.setXYZ(n,ys.x,ys.y,ys.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ys.fromBufferAttribute(this,n),ys.transformDirection(e),this.setXYZ(n,ys.x,ys.y,ys.z);return this}setX(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Kn(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=il(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=il(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=il(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=il(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=Kn(n,this.array),r=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(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=Kn(n,this.array),r=Kn(r,this.array),i=Kn(i,this.array),s=Kn(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 Sa(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 Hu(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 AUe extends Ys{constructor(e=null,n=1,r=1,i,s,a,o,c,u=Zi,d=Zi,f,g){super(null,a,o,c,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 TUe(t,e){return t.z-e.z}function CUe(t,e){return e.z-t.z}class NUe{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 Dp="batchId",Su=new sr,rV=new sr,kUe=new sr,iV=new sr,_N=new VE,T_=new so,Qd=new ul,Tx=new De,wN=new NUe,us=new Oo,C_=[];function PUe(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 RUe extends Oo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new xs,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 AUe(n,e,e,Qa,xc);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 c=e.getAttribute(o),{array:u,itemSize:d,normalized:f}=c,g=new u.constructor(r*d),m=new c.constructor(g,d,f);m.setUsage(c.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new Sa(o,1))}const a=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Dp,new Sa(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Dp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Dp}"`);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===Dp)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 so);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Su),this.getBoundingBoxAt(i,T_).applyMatrix4(Su),n.union(T_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ul);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,Su),this.getBoundingSphereAt(i,Qd).applyMatrix4(Su),n.union(Qd))}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,c=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++,kUe.toArray(x,y*16),m.needsUpdate=!0,a.push(i),o.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new so,sphereInitialized:!1,sphere:new ul});const v=this.geometry.getAttribute(Dp);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 c=o.vertexStart,u=o.vertexCount;for(const m in r.attributes){if(m===Dp)continue;const x=n.getAttribute(m),y=r.getAttribute(m);PUe(x,y,c);const v=x.itemSize;for(let b=x.count,E=u;b<E;b++){const S=c+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,c+a.getX(x));for(let x=a.count,y=o.indexCount;x<y;x++)s.setX(m+x,c);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,c=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(Tx.fromBufferAttribute(c,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,T_),T_.getCenter(s.center);const o=a.index,c=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)),Tx.fromBufferAttribute(c,m),d=Math.max(d,s.center.distanceToSquared(Tx))}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,c=this.geometry;us.material=this.material,us.geometry.index=c.index,us.geometry.attributes=c.attributes,us.geometry.boundingBox===null&&(us.geometry.boundingBox=new so),us.geometry.boundingSphere===null&&(us.geometry.boundingSphere=new ul);for(let u=0;u<a;u++){if(!r[u]||!i[u])continue;const d=s[u];us.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,us.matrixWorld).premultiply(o),this.getBoundingBoxAt(u,us.geometry.boundingBox),this.getBoundingSphereAt(u,us.geometry.boundingSphere),us.raycast(e,C_);for(let f=0,g=C_.length;f<g;f++){const m=C_[f];m.object=this,m.batchId=u,n.push(m)}C_.length=0}us.material=null,us.geometry.index=null,us.geometry.attributes={},us.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,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(iV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),_N.setFromProjectionMatrix(iV,e.isWebGPURenderer?Y0:ll));let m=0;if(this.sortObjects){rV.copy(this.matrixWorld).invert(),Tx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(rV);for(let v=0,b=c.length;v<b;v++)if(c[v]){this.getMatrixAt(v,Su),this.getBoundingSphereAt(v,Qd).applyMatrix4(Su);let E=!1;if(g&&(E=!_N.intersectsSphere(Qd)),!E){const S=Tx.distanceTo(Qd.center);wN.push(f[v],S)}}const x=wN.list,y=this.customSort;y===null?x.sort(s.transparent?CUe:TUe):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++}wN.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let v=!1;if(g&&(this.getMatrixAt(x,Su),this.getBoundingSphereAt(x,Qd).applyMatrix4(Su),v=!_N.intersectsSphere(Qd)),!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 Xb extends ug{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 sV=new De,aV=new De,oV=new sr,SN=new pj,N_=new ul;class DUe extends Ts{constructor(e=new xs,n=new Xb){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++)sV.fromBufferAttribute(n,i-1),aV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=sV.distanceTo(aV);e.setAttribute("lineDistance",new Br(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(),N_.copy(r.boundingSphere),N_.applyMatrix4(i),N_.radius+=s,e.ray.intersectsSphere(N_)===!1)return;oV.copy(i).invert(),SN.copy(e.ray).applyMatrix4(oV);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,u=new De,d=new De,f=new De,g=new De,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),SN.distanceSqToSegment(u,d,g,f)>c)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),SN.distanceSqToSegment(u,d,g,f)>c)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 lV=new De,cV=new De;class WE extends DUe{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)lV.fromBufferAttribute(n,i),cV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+lV.distanceTo(cV);e.setAttribute("lineDistance",new Br(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class OUe extends xs{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 c=e.groups;c.length===0&&(c=[{start:0,count:o.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,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),uV(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,c=a.count/3;o<c;o++)for(let u=0;u<3;u++){const d=3*o+u,f=3*o+(u+1)%3;i.fromBufferAttribute(a,d),s.fromBufferAttribute(a,f),uV(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Br(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function uV(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 jUe extends ug{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=RZ,this.normalScale=new Zt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=uj,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 LUe extends Xb{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 eQ extends Ts{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 EN=new sr,dV=new De,hV=new De;class IUe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Zt(512,512),this.map=null,this.mapPass=null,this.matrix=new sr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new VE,this._frameExtents=new Zt(1,1),this._viewportCount=1,this._viewports=[new Zn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;dV.setFromMatrixPosition(e.matrixWorld),n.position.copy(dV),hV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(hV),n.updateMatrixWorld(),EN.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(EN),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(EN)}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 fV=new sr,Cx=new De,MN=new De;class UUe extends IUe{constructor(){super(new ma(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Zt(4,2),this._viewportCount=6,this._viewports=[new Zn(2,1,1,1),new Zn(0,1,1,1),new Zn(3,1,1,1),new Zn(1,1,1,1),new Zn(3,0,1,1),new Zn(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()),Cx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Cx),MN.copy(r.position),MN.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(MN),r.updateMatrixWorld(),i.makeTranslation(-Cx.x,-Cx.y,-Cx.z),fV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fV)}}class FUe extends eQ{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 UUe}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 zUe extends eQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class BUe extends xs{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 LP extends MUe{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 pV{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Ji(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const mV=new De,k_=new De;class HUe{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){mV.subVectors(e,this.start),k_.subVectors(this.end,this.start);const r=k_.dot(k_);let s=k_.dot(mV)/r;return n&&(s=Ji(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 $Ue extends WE{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 xs;i.setAttribute("position",new Br(n,3)),i.setAttribute("color",new Br(r,3));const s=new Xb({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:BE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=BE);class dl{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"),dl.nextNameID=dl.nextNameID||0,this.$name.id=`lil-gui-name-${++dl.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 VUe extends dl{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 IP(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 GUe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:IP,toHexString:IP},Q0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},WUe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=Q0.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 Q0.toHexString(i)}},qUe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=Q0.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 Q0.toHexString(i)}},KUe=[GUe,Q0,WUe,qUe];function XUe(t){return KUe.find(e=>e.match(t))}class YUe extends dl{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=XUe(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=IP(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 AN extends dl{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 ZUe extends dl{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,c,u,d,f;const g=5,m=E=>{o=E.clientX,c=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-c;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,c;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,c=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-c;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 QUe extends dl{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 JUe extends dl{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 eFe=`.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 tFe(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 gV=!1;class Fw{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:s="Controls",closeFolders:a=!1,injectStyles:o=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(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"),c&&this.domElement.classList.add("allow-touch-styles"),!gV&&o&&(tFe(eFe),gV=!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 QUe(this,e,n,r);const a=e[n];switch(typeof a){case"number":return new ZUe(this,e,n,r,i,s);case"boolean":return new VUe(this,e,n);case"string":return new JUe(this,e,n);case"function":return new AN(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,a)}addColor(e,n,r=1){return new YUe(this,e,n,r)}addFolder(e){const n=new Fw({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof AN||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 AN)){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 TN(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(u){try{c(r.next(u))}catch(d){s(d)}}function o(u){try{c(r.throw(u))}catch(d){s(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(a,o)}c((r=r.apply(t,[])).next())}))}class vj{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 vj(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 yj{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class xV extends yj{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Eu extends yj{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class bV{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class zw{constructor(e){this.lines=[],this.preamble=new bV(-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())),c=o.length?`${(r=o[0])===null||r===void 0?void 0:r.toLowerCase()}${o[1]}`:"",u=this.parseParams(o.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new xV(e,c,u,a);case"t0":return new Eu(e,c,a,0);case"t1":return new Eu(e,c,a,1);case"t2":return new Eu(e,c,a,2);case"t3":return new Eu(e,c,a,3);case"t4":return new Eu(e,c,a,4);case"t5":return new Eu(e,c,a,5);case"t6":return new Eu(e,c,a,6);case"t7":return new Eu(e,c,a,7);default:return new yj(e,c,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 xV){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 bV(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=vj.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}}}zw.prototype.parseGcode=zw.prototype.parseGCode;const vV={type:"change"},CN={type:"start"},yV={type:"end"},P_=new pj,_V=new ku,nFe=Math.cos(70*OZ.DEG2RAD);class rFe extends gf{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:mp.ROTATE,MIDDLE:mp.DOLLY,RIGHT:mp.PAN},this.touches={ONE:gp.ROTATE,TWO:gp.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",Oe),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Oe),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(vV),r.update(),s=i.NONE},this.update=(function(){const H=new De,ne=new rf().setFromUnitVectors(e.up,new De(0,1,0)),G=ne.clone().invert(),Z=new De,oe=new rf,Ne=new De,Pe=2*Math.PI;return function(Se=null){const B=r.object.position;H.copy(B).sub(r.target),H.applyQuaternion(ne),o.setFromVector3(H),r.autoRotate&&s===i.NONE&&D((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(Se)),r.enableDamping?(o.theta+=c.theta*r.dampingFactor,o.phi+=c.phi*r.dampingFactor):(o.theta+=c.theta,o.phi+=c.phi);let L=r.minAzimuthAngle,te=r.maxAzimuthAngle;isFinite(L)&&isFinite(te)&&(L<-Math.PI?L+=Pe:L>Math.PI&&(L-=Pe),te<-Math.PI?te+=Pe:te>Math.PI&&(te-=Pe),o.theta=L<=te?Math.max(L,Math.min(te,o.theta)):o.theta>(L+te)/2?Math.max(L,o.theta):Math.min(te,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=ee(o.radius):o.radius=ee(o.radius*u),H.setFromSpherical(o),H.applyQuaternion(G),B.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ve=!1;if(r.zoomToCursor&&k){let _e=null;if(r.object.isPerspectiveCamera){const be=H.length();_e=ee(be*u);const nt=be-_e;r.object.position.addScaledVector(A,nt),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const be=new De(T.x,T.y,0);be.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0;const nt=new De(T.x,T.y,0);nt.unproject(r.object),r.object.position.sub(nt).add(be),r.object.updateMatrixWorld(),_e=H.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(P_.origin.copy(r.object.position),P_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(P_.direction))<nFe?e.lookAt(r.target):(_V.setFromNormalAndCoplanarPoint(r.object.up,r.target),P_.intersectPlane(_V,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0);return u=1,k=!1,!!(ve||Z.distanceToSquared(r.object.position)>a||8*(1-oe.dot(r.object.quaternion))>a||Ne.distanceToSquared(r.target)>0)&&(r.dispatchEvent(vV),Z.copy(r.object.position),oe.copy(r.object.quaternion),Ne.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",he),r.domElement.removeEventListener("pointerdown",xe),r.domElement.removeEventListener("pointercancel",re),r.domElement.removeEventListener("wheel",we),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",re),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Oe),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 pV,c=new pV;let u=1;const d=new De,f=new Zt,g=new Zt,m=new Zt,x=new Zt,y=new Zt,v=new Zt,b=new Zt,E=new Zt,S=new Zt,A=new De,T=new Zt;let k=!1;const N=[],I={};function C(){return Math.pow(.95,r.zoomSpeed)}function D(H){c.theta-=H}function F(H){c.phi-=H}const j=(function(){const H=new De;return function(ne,G){H.setFromMatrixColumn(G,0),H.multiplyScalar(-ne),d.add(H)}})(),q=(function(){const H=new De;return function(ne,G){r.screenSpacePanning===!0?H.setFromMatrixColumn(G,1):(H.setFromMatrixColumn(G,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(ne),d.add(H)}})(),R=(function(){const H=new De;return function(ne,G){const Z=r.domElement;if(r.object.isPerspectiveCamera){const oe=r.object.position;H.copy(oe).sub(r.target);let Ne=H.length();Ne*=Math.tan(r.object.fov/2*Math.PI/180),j(2*ne*Ne/Z.clientHeight,r.object.matrix),q(2*G*Ne/Z.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(j(ne*(r.object.right-r.object.left)/r.object.zoom/Z.clientWidth,r.object.matrix),q(G*(r.object.top-r.object.bottom)/r.object.zoom/Z.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 ne=r.domElement.getBoundingClientRect(),G=H.clientX-ne.left,Z=H.clientY-ne.top,oe=ne.width,Ne=ne.height;T.x=G/oe*2-1,T.y=-Z/Ne*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function ee(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function Y(H){f.set(H.clientX,H.clientY)}function Q(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),ne=.5*(N[0].pageY+N[1].pageY);f.set(H,ne)}}function z(){if(N.length===1)x.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),ne=.5*(N[0].pageY+N[1].pageY);x.set(H,ne)}}function J(){const H=N[0].pageX-N[1].pageX,ne=N[0].pageY-N[1].pageY,G=Math.sqrt(H*H+ne*ne);b.set(0,G)}function se(H){if(N.length==1)g.set(H.pageX,H.pageY);else{const G=$(H),Z=.5*(H.pageX+G.x),oe=.5*(H.pageY+G.y);g.set(Z,oe)}m.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ne=r.domElement;D(2*Math.PI*m.x/ne.clientHeight),F(2*Math.PI*m.y/ne.clientHeight),f.copy(g)}function me(H){if(N.length===1)y.set(H.pageX,H.pageY);else{const ne=$(H),G=.5*(H.pageX+ne.x),Z=.5*(H.pageY+ne.y);y.set(G,Z)}v.subVectors(y,x).multiplyScalar(r.panSpeed),R(v.x,v.y),x.copy(y)}function fe(H){const ne=$(H),G=H.pageX-ne.x,Z=H.pageY-ne.y,oe=Math.sqrt(G*G+Z*Z);E.set(0,oe),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",Ee),r.domElement.addEventListener("pointerup",re)),(function(ne){N.push(ne)})(H),H.pointerType==="touch"?(function(ne){switch(ht(ne),N.length){case 1:switch(r.touches.ONE){case gp.ROTATE:if(r.enableRotate===!1)return;U(),s=i.TOUCH_ROTATE;break;case gp.PAN:if(r.enablePan===!1)return;z(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case gp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&J(),r.enablePan&&z(),s=i.TOUCH_DOLLY_PAN;break;case gp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&J(),r.enableRotate&&U(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(CN)})(H):(function(ne){let G;switch(ne.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 mp.DOLLY:if(r.enableZoom===!1)return;(function(Z){V(Z),b.set(Z.clientX,Z.clientY)})(ne),s=i.DOLLY;break;case mp.ROTATE:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(r.enablePan===!1)return;Q(ne),s=i.PAN}else{if(r.enableRotate===!1)return;Y(ne),s=i.ROTATE}break;case mp.PAN:if(ne.ctrlKey||ne.metaKey||ne.shiftKey){if(r.enableRotate===!1)return;Y(ne),s=i.ROTATE}else{if(r.enablePan===!1)return;Q(ne),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(CN)})(H))}function Ee(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(ne){switch(ht(ne),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;se(ne),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;me(ne),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(G){r.enableZoom&&fe(G),r.enablePan&&me(G)})(ne),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(G){r.enableZoom&&fe(G),r.enableRotate&&se(G)})(ne),r.update();break;default:s=i.NONE}})(H):(function(ne){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 Z=r.domElement;D(2*Math.PI*m.x/Z.clientHeight),F(2*Math.PI*m.y/Z.clientHeight),f.copy(g),r.update()})(ne);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()})(ne);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()})(ne)}})(H))}function re(H){(function(ne){delete I[ne.pointerId];for(let G=0;G<N.length;G++)if(N[G].pointerId==ne.pointerId)return void N.splice(G,1)})(H),N.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",re)),r.dispatchEvent(yV),s=i.NONE}function we(H){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(H.preventDefault(),r.dispatchEvent(CN),(function(ne){V(ne),ne.deltaY<0?K(C()):ne.deltaY>0&&W(C()),r.update()})(H),r.dispatchEvent(yV))}function Oe(H){r.enabled!==!1&&r.enablePan!==!1&&(function(ne){let G=!1;switch(ne.code){case r.keys.UP:ne.ctrlKey||ne.metaKey||ne.shiftKey?F(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),G=!0;break;case r.keys.BOTTOM:ne.ctrlKey||ne.metaKey||ne.shiftKey?F(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),G=!0;break;case r.keys.LEFT:ne.ctrlKey||ne.metaKey||ne.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),G=!0;break;case r.keys.RIGHT:ne.ctrlKey||ne.metaKey||ne.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),G=!0}G&&(ne.preventDefault(),r.update())})(H)}function he(H){r.enabled!==!1&&H.preventDefault()}function ht(H){let ne=I[H.pointerId];ne===void 0&&(ne=new Zt,I[H.pointerId]=ne),ne.set(H.pageX,H.pageY)}function $(H){const ne=H.pointerId===N[0].pointerId?N[1]:N[0];return I[ne.pointerId]}r.domElement.addEventListener("contextmenu",he),r.domElement.addEventListener("pointerdown",xe),r.domElement.addEventListener("pointercancel",re),r.domElement.addEventListener("wheel",we,{passive:!1}),this.update()}}_t.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Zt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Gs.line={uniforms:mj.merge([_t.common,_t.fog,_t.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 tQ extends pd{constructor(e){super({type:"LineMaterial",uniforms:mj.clone(Gs.line.uniforms),vertexShader:Gs.line.vertexShader,fragmentShader:Gs.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 wV=new so,R_=new De;class nQ extends BUe{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 Br([-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 Br([-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 LP(n,6,1);return this.setAttribute("instanceStart",new Hu(r,3,0)),this.setAttribute("instanceEnd",new Hu(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 LP(n,6,1);return this.setAttribute("instanceColorStart",new Hu(r,3,0)),this.setAttribute("instanceColorEnd",new Hu(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 OUe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new so);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),wV.setFromBufferAttribute(n),this.boundingBox.union(wV))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ul),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++)R_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(R_)),R_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(R_));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 SV=new De,EV=new De,Wi=new Zn,qi=new Zn,Xo=new Zn,NN=new De,kN=new sr,Ki=new HUe,MV=new De,D_=new so,O_=new ul,Yo=new Zn;let Zo,uh;function AV(t,e,n){return Yo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Yo.multiplyScalar(1/Yo.w),Yo.x=uh/n.width,Yo.y=uh/n.height,Yo.applyMatrix4(t.projectionMatrixInverse),Yo.multiplyScalar(1/Yo.w),Math.abs(Math.max(Yo.x,Yo.y))}class iFe extends Oo{constructor(e=new nQ,n=new tQ({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,c=n.count;a<c;a++,o+=2)SV.fromBufferAttribute(n,a),EV.fromBufferAttribute(r,a),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+SV.distanceTo(EV);const s=new LP(i,2,1);return e.setAttribute("instanceDistanceStart",new Hu(s,1,0)),e.setAttribute("instanceDistanceEnd",new Hu(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;Zo=e.ray;const a=this.matrixWorld,o=this.geometry,c=this.material;let u,d;uh=c.linewidth+s,o.boundingSphere===null&&o.computeBoundingSphere(),O_.copy(o.boundingSphere).applyMatrix4(a),r?u=.5*uh:u=AV(i,Math.max(i.near,O_.distanceToPoint(Zo.origin)),c.resolution),O_.radius+=u,Zo.intersectsSphere(O_)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),D_.copy(o.boundingBox).applyMatrix4(a),r?d=.5*uh:d=AV(i,Math.max(i.near,D_.distanceToPoint(Zo.origin)),c.resolution),D_.expandByScalar(d),Zo.intersectsBox(D_)!==!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++){Ki.start.fromBufferAttribute(y,b),Ki.end.fromBufferAttribute(v,b),Ki.applyMatrix4(m);const S=new De,A=new De;Zo.distanceSqToSegment(Ki.start,Ki.end,A,S),A.distanceTo(S)<.5*uh&&g.push({point:A,pointOnLine:S,distance:Zo.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;Zo.at(1,Xo),Xo.w=1,Xo.applyMatrix4(g.matrixWorldInverse),Xo.applyMatrix4(x),Xo.multiplyScalar(1/Xo.w),Xo.x*=y.x/2,Xo.y*=y.y/2,Xo.z=0,NN.copy(Xo),kN.multiplyMatrices(g.matrixWorldInverse,v);for(let k=0,N=A;k<N;k++){if(Wi.fromBufferAttribute(E,k),qi.fromBufferAttribute(S,k),Wi.w=1,qi.w=1,Wi.applyMatrix4(kN),qi.applyMatrix4(kN),Wi.z>T&&qi.z>T)continue;if(Wi.z>T){const j=Wi.z-qi.z,q=(Wi.z-T)/j;Wi.lerp(qi,q)}else if(qi.z>T){const j=qi.z-Wi.z,q=(qi.z-T)/j;qi.lerp(Wi,q)}Wi.applyMatrix4(x),qi.applyMatrix4(x),Wi.multiplyScalar(1/Wi.w),qi.multiplyScalar(1/qi.w),Wi.x*=y.x/2,Wi.y*=y.y/2,qi.x*=y.x/2,qi.y*=y.y/2,Ki.start.copy(Wi),Ki.start.z=0,Ki.end.copy(qi),Ki.end.z=0;const I=Ki.closestPointToPointParameter(NN,!0);Ki.at(I,MV);const C=OZ.lerp(Wi.z,qi.z,I),D=C>=-1&&C<=1,F=NN.distanceTo(MV)<.5*uh;if(D&&F){Ki.start.fromBufferAttribute(E,k),Ki.end.fromBufferAttribute(S,k),Ki.start.applyMatrix4(v),Ki.end.applyMatrix4(v);const j=new De,q=new De;Zo.distanceSqToSegment(Ki.start,Ki.end,q,j),m.push({point:q,pointOnLine:j,distance:Zo.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class sFe extends WE{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 c=[],u=[];let d=0;for(let g=-1*(e=o*n/2);g<=e;g+=n){c.push(g,0,-1*r,g,0,r);const 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){c.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 xs;f.setAttribute("position",new Br(c,3)),f.setAttribute("color",new Br(u,3)),super(f,new Xb({vertexColors:!0,toneMapped:!1}))}}function aFe(t,e,n,r){const i=(function(a,o,c){a*=.5,o*=.5,c*=.5;const u=new xs,d=[];return d.push(-a,-o,-c,-a,o,-c,-a,o,-c,a,o,-c,a,o,-c,a,-o,-c,a,-o,-c,-a,-o,-c,-a,-o,c,-a,o,c,-a,o,c,a,o,c,a,o,c,a,-o,c,a,-o,c,-a,-o,c,-a,-o,-c,-a,-o,c,-a,o,-c,-a,o,c,a,o,-c,a,o,c,a,-o,-c,a,-o,c),u.setAttribute("position",new Br(d,3)),u})(t,e,n),s=new WE(i,new LUe({color:new $t(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var Zx=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 Zx.Panel("FPS","#0ff","#002")),c=n(new Zx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Zx.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(c.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}};Zx.Panel=function(t,e,n){var r=1/0,i=0,s=Math.round,a=s(window.devicePixelRatio||1),o=80*a,c=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=c,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,c),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 oFe=Zx;class TV{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new Fw,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 Fw,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 lFe extends xs{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 Zt,c=[],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,c.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 Br(c,3)),this.setAttribute("normal",new Br(u,3)),this.setAttribute("uv",new Br(d,2))}}class Qx{static get initial(){const e=new Qx;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const PN={h:0,s:0,l:0};class lm{constructor(e){var n,r,i,s,a,o,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Qx.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=lm.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 zw(this.minLayerThreshold),this.scene=new EUe,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=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new oFe: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"+BE),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 jP({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 jP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ma(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 bj(this._backgroundColor,g,f),this.resize(),this.controls=new rFe(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?lm.defaultExtrusionColor:this._extrusionColor instanceof $t?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:lm.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 $Ue(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 zUe(13421772,.3*Math.PI),n=new FUe(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 Fx;return n.name=e,n.quaternion.setFromEuler(new qb(-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=Qx.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 TN(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,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const 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:(c=m.params.j)!==null&&c!==void 0?c: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(PN),s=new $t().setHSL(PN.h,PN.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,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,a.getHex(),e.height),this.addTubeLine([...u,...c],o.getHex(),e.height)):(this.addLine(e.extrusion,a.getHex()),this.addLine([...u,...c],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 sFe(this.buildVolume.x,10,this.buildVolume.y,10));const e=aFe(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 zw(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Qx.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,c=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-c,V=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));m=Math.max(m,V);const ee=Math.pow(W,2)+Math.pow(K,2),Y=Math.pow(m,2)-ee/4;let Q=Math.sqrt(Y/ee);(s&&m<0||!s&&m>0)&&(Q=-Q),x=W/2+K*Q,y=K/2-W*Q}const v=o==d&&c==f,b=o+x,E=c+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:c,z:u});const D=(u-g)/N;let F=o,j=c,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 xs;i.setAttribute("position",new Br(e,3)),this.disposables.push(i);const s=new Xb({color:n});this.disposables.push(s);const a=new WE(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),c=new De(o[0],o[1],o[2]),u=new De(o[3],o[4],o[5]),d=new De(o[6],o[7],o[8]);i.push(c),u.equals(d)||(i.push(u),s.push(i),i=[])}s.forEach((a=>{var o;const c=new lFe(a,this.extrusionWidth,this.lineHeight||r,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new nQ;this.disposables.push(i);const s=new tQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const a=new iFe(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=>TN(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 jUe({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((o,c)=>3*c.attributes.position.count+o),0),a=new RUe(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 TN(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=(c=s.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(a+f),a=u.slice(d)}while(!s.done);var c;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new TV(this):typeof this.devMode=="object"&&(this.devGui=new TV(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())}}lm.defaultExtrusionColor=new $t("hotpink");const cFe=function(t){return new lm(t)};function uFe({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,c]=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=cFe({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),c(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=>{c(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 l.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[l.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[l.jsx("canvas",{ref:r,className:"w-full h-full"}),s&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsxs("div",{className:"text-center",children:[l.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),l.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),u&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsxs("div",{className:"text-center max-w-sm px-4",children:[l.jsx(ile,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),l.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),l.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing the model in Bambu Studio or Orca Slicer."})]})}),o&&!u&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:l.jsx("div",{className:"text-center text-red-400",children:l.jsx("p",{className:"text-sm",children:o})})})]}),!s&&!o&&!u&&m>0&&l.jsx("div",{className:"mt-4 px-2",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx($h,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),l.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:l.jsx(Bh,{className:"w-4 h-4"})}),l.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"}),l.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:l.jsx(df,{className:"w-4 h-4"})}),l.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[f," / ",m]})]})})]})}function dFe({archiveId:t,title:e,onClose:n}){const[r,i]=M.useState(null),[s,a]=M.useState(null),[o,c]=M.useState(!0);M.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),M.useEffect(()=>{ke.getArchiveCapabilities(t).then(d=>{a(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{a({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${ke.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:u,children:[l.jsx(Aa,{className:"w-4 h-4"}),"Open in Slicer"]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),s&&l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.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:[l.jsx(fm,{className:"w-4 h-4"}),"3D Model",!s.has_model&&l.jsx("span",{className:"text-xs",children:"(not available)"})]}),l.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:[l.jsx(Roe,{className:"w-4 h-4"}),"G-code Preview",!s.has_gcode&&l.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),l.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&s?l.jsx(aOe,{url:ke.getArchiveDownload(t),buildVolume:s.build_volume,className:"w-full h-full"}):r==="gcode"&&s?l.jsx(uFe,{gcodeUrl:ke.getArchiveGcode(t),buildVolume:s.build_volume,className:"w-full h-full"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function hFe({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:ke.getPrinters}),c=wt({mutationFn:()=>{if(!i)throw new Error("No printer selected");return ke.reprintArchive(t,i)},onSuccess:()=>{r(),n()}}),u=a?.filter(d=>d.is_active)||[];return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",l.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u.length===0?l.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):l.jsx("div",{className:"space-y-2 mb-6",children:u.map(d=>l.jsxs("button",{onClick:()=>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:[l.jsx("div",{className:`p-2 rounded-lg ${i===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:l.jsx(Ta,{className:`w-5 h-5 ${i===d.id?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-white font-medium",children:d.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),c.isError&&l.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:c.error.message||"Failed to start print"}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{onClick:()=>c.mutate(),disabled:!i||c.isPending,className:"flex-1",children:c.isPending?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Ta,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function fFe({onClose:t,initialFiles:e}){const n=Mn(),{showToast:r}=si(),i=M.useRef(null),[s,a]=M.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[o,c]=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:ke.getPrinters}),x=wt({mutationFn:N=>ke.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(),c(!0)},[]),v=M.useCallback(N=>{N.preventDefault(),c(!1)},[]),b=M.useCallback(N=>{N.preventDefault(),c(!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 l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"p-4",children:l.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:v,onDrop:b,children:[l.jsx(ya,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),l.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),l.jsx(Le,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),l.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),l.jsxs("div",{className:"px-4 pb-4",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:N=>d(N.target.value?Number(N.target.value):void 0),disabled:k,children:[l.jsx("option",{value:"",children:"No printer"}),m?.map(N=>l.jsx("option",{value:N.id,children:N.name},N.id))]})]}),s.length>0&&l.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:l.jsx("div",{className:"space-y-2",children:s.map((N,I)=>l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[l.jsx(s7,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),l.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&l.jsx("button",{onClick:()=>S(I),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:l.jsx(Wt,{className:"w-4 h-4"})}),N.status==="uploading"&&l.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs text-red-400",children:N.error}),l.jsx(lo,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${I}`))})}),f&&l.jsx("div",{className:"px-4 pb-4",children:l.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:l.jsxs("p",{className:"text-sm text-white",children:[l.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&l.jsxs(l.Fragment,{children:[", ",l.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&l.jsx(Le,{onClick:A,disabled:T===0||k,className:"flex-1",children:k?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):l.jsxs(l.Fragment,{children:[l.jsx(ya,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const pFe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function mFe({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=Mn(),[i,s]=M.useState(t.print_name||""),[a,o]=M.useState(t.printer_id),[c,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:ke.getPrinters}),{data:D}=yt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),{data:F}=yt({queryKey:["archives"],queryFn:()=>ke.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(J=>J!==U).join(", ");m(z)},V=wt({mutationFn:U=>ke.updateArchive(t.id,U),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ee=async U=>{const z=U.target.files?.[0];if(z){S(!0);try{const J=await ke.uploadArchivePhoto(t.id,z);b(J.photos),r.invalidateQueries({queryKey:["archives"]})}catch(J){console.error("Failed to upload photo:",J)}finally{S(!1),N.current&&(N.current.value="")}}},Y=async U=>{try{const z=await ke.deleteArchivePhoto(t.id,U);b(z.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(z){console.error("Failed to delete photo:",z)}},Q=U=>{U.preventDefault(),V.mutate({print_name:i||void 0,printer_id:a,project_id:c,notes:d||void 0,tags:g||void 0,failure_reason:(t.status==="failed"||t.status==="aborted")&&x||void 0})};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:U=>U.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Q,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),l.jsx("input",{type:"text",value:i,onChange: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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),l.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:[l.jsx("option",{value:"",children:"No printer"}),C?.map(U=>l.jsx("option",{value:U.id,children:U.name},U.id))]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(qu,{className:"w-4 h-4 inline mr-1"}),"Project"]}),l.jsxs("select",{value:c??"",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:[l.jsx("option",{value:"",children:"No project"}),D?.map(U=>l.jsx("option",{value:U.id,children:U.name},U.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),l.jsx("textarea",{value:d,onChange: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..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),q.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:q.map(U=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[l.jsx(M0,{className:"w-3 h-3"}),U,l.jsx("button",{type:"button",onClick:()=>K(U),className:"ml-0.5 text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},U))}),l.jsxs("div",{className:"relative",children:[l.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&&l.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[l.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),l.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:R.map(U=>l.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"||t.status==="aborted")&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),l.jsxs("select",{value:x,onChange: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:[l.jsx("option",{value:"",children:"Select reason..."}),pFe.map(U=>l.jsx("option",{value:U,children:U},U))]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(b0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[v.map(U=>l.jsxs("div",{className:"relative group",children:[l.jsx("img",{src:ke.getArchivePhotoUrl(t.id,U),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),l.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:l.jsx(Rn,{className:"w-3 h-3 text-white"})})]},U)),l.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[l.jsx("input",{ref:N,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:ee,className:"hidden",disabled:E}),E?l.jsx(At,{className:"w-6 h-6 text-bambu-gray animate-spin"}):l.jsx(pr,{className:"w-6 h-6 text-bambu-gray"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:V.isPending,className:"flex-1",children:[l.jsx(Ro,{className:"w-4 h-4"}),V.isPending?"Saving...":"Save"]})]})]})]})})}function gFe({x:t,y:e,items:n,onClose:r}){const i=M.useRef(null),[s,a]=M.useState(null),o=M.useRef(null),[c,u]=M.useState({x:t,y:e,visible:!1}),[d,f]=M.useState(!1);M.useEffect(()=>{const x=b=>{i.current&&!i.current.contains(b.target)&&r()},y=b=>{b.key==="Escape"&&r()},v=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),document.addEventListener("scroll",v,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y),document.removeEventListener("scroll",v,!0),o.current&&clearTimeout(o.current)}},[r]),M.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),y=window.innerWidth,v=window.innerHeight,b=8;let E=t,S=e;t+x.width>y-b&&(E=Math.max(b,y-x.width-b)),E<b&&(E=b),e+x.height>v-b&&(S=Math.max(b,v-x.height-b)),S<b&&(S=b);const A=180,T=y-E-x.width,k=E;f(T<A&&k>A),u({x:E,y:S,visible:!0})}},[t,e]);const g=x=>{o.current&&(clearTimeout(o.current),o.current=null),a(x)},m=()=>{o.current=window.setTimeout(()=>{a(null)},150)};return l.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,y)=>{if(x.divider)return l.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const v=x.submenu&&x.submenu.length>0;return l.jsxs("div",{className:"relative",onMouseEnter:()=>v&&g(y),onMouseLeave:()=>v&&m(),children:[l.jsxs("button",{onClick:()=>{v?a(s===y?null:y):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${v&&s===y?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),l.jsx("span",{className:"flex-1",children:x.label}),v&&l.jsx(df,{className:"w-4 h-4 text-bambu-gray"})]}),v&&s===y&&l.jsx("div",{className:`absolute top-0 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"}`,onMouseEnter:()=>{o.current&&(clearTimeout(o.current),o.current=null)},onMouseLeave:()=>m(),children:x.submenu.map((b,E)=>l.jsxs("button",{onClick:()=>{b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[b.icon&&l.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),b.label]},E))})]},y)})})}function xFe({selectedIds:t,existingTags:e,onClose:n}){const r=Mn(),{showToast:i}=si(),[s,a]=M.useState(""),[o,c]=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=wt({mutationFn:async()=>{const y=Array.from(o);let v=0;for(const b of t)try{const E=await ke.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 ke.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=>{c(v=>{const b=new Set(v);return b.has(y)?b.delete(y):b.add(y),b})},m=()=>{s.trim()&&!o.has(s.trim())&&(c(y=>new Set([...y,s.trim()])),a(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(M0,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),l.jsx(Le,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:s,onChange:y=>a(y.target.value),onKeyDown:x}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:l.jsx(pr,{className:"w-4 h-4"})})]}),e.length>0&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>l.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&&l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(y=>l.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,l.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:l.jsx(Wt,{className:"w-3 h-3"})})]},y))})]})]}),l.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):l.jsxs(l.Fragment,{children:[l.jsx(M0,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function bFe(t,e){return new Date(t,e+1,0).getDate()}function vFe(t,e){return new Date(t,e,1).getDay()}const yFe=["January","February","March","April","May","June","July","August","September","October","November","December"],_Fe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function wFe({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=M.useState(n.getMonth()),[s,a]=M.useState(n.getFullYear()),[o,c]=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=bFe(s,r),f=vFe(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 l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Bh,{className:"w-5 h-5 text-bambu-gray"})}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:[yFe[r]," ",s]}),l.jsx("button",{onClick:x,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),l.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(df,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:_Fe.map(b=>l.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:b},b))}),l.jsx("div",{className:"grid grid-cols-7 gap-1",children:y.map((b,E)=>{if(b===null)return l.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 l.jsxs("button",{onClick:()=>c(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:[l.jsx("span",{className:`text-sm font-medium ${k&&!N?"text-bambu-green":""}`,children:b}),T&&l.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[l.jsx("div",{className:`w-2 h-2 rounded-full ${C>0&&I===0?"bg-red-400":C>0?"bg-yellow-400":"bg-green-400"}`}),l.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},b)})}),l.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s&&b.status==="completed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===s&&b.status==="failed"}).length}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),l.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(o+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),v.length>0?l.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(b=>l.jsxs("button",{onClick:()=>e?.(b),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[b.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(b.id),alt:"",className:"w-12 h-12 rounded object-cover"}):l.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:l.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-white truncate",children:b.print_name||b.filename}),l.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[l.jsx("span",{className:b.status==="failed"?"text-red-400":"text-green-400",children:b.status==="failed"?"Failed":"Completed"}),b.filament_color&&l.jsx("div",{className:"flex gap-0.5",children:b.filament_color.split(",").map((E,S)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},S))})]})]})]},b.id))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):l.jsx("div",{className:"text-center py-8",children:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function SFe({archiveId:t,archiveName:e,onClose:n}){const r=ke.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 l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:s=>s.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"p-6 flex flex-col items-center",children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),l.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:l.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),l.jsxs(Le,{onClick:i,className:"w-full",children:[l.jsx(Ma,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function EFe({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,a]=M.useState(0),[o,c]=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=ke.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${s+1}.jpg`,m.click()},g=()=>{i&&c(!0)};return l.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[l.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",s+1," of ",n.length]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:f,children:[l.jsx(Ma,{className:"w-4 h-4"}),"Download"]}),i&&l.jsx(Le,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})}),l.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-6 h-6"})})]})]}),l.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[s>0&&l.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:l.jsx(Bh,{className:"w-8 h-8 text-white"})}),l.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&&l.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:l.jsx(df,{className:"w-8 h-8 text-white"})})]}),n.length>1&&l.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,x)=>l.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:l.jsx("img",{src:ke.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&l.jsx(Qr,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Yi(t){this.content=t}Yi.prototype={constructor:Yi,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Yi(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 Yi(n)},addToStart:function(t,e){return new Yi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Yi(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Yi(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Yi.from(t),t.size?new Yi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Yi.from(t),t.size?new Yi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Yi.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Yi.from=function(t){if(t instanceof Yi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Yi(e)};function rQ(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=rQ(i.content,s.content,n+1);if(a!=null)return a}n+=i.nodeSize}}function iQ(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),c=a.nodeSize;if(a==o){n-=c,r-=c;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=iQ(a.content,o.content,n-1,r-1);if(u)return u}n-=c,r-=c}}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 c=this.content[a],u=o+c.nodeSize;if(u>e&&r(c,i+o,s||null,a)!==!1&&c.content.size){let d=o+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",a=!0;return this.nodesBetween(e,n,(o,c)=>{let u=o.isText?o.text.slice(Math.max(e,c)-c,n-c):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(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],c=a+o.nodeSize;c>e&&((a<e||c>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=c}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 rQ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return iQ(this,e,n,r)}findIndex(e){if(e==0)return j_(0,e);if(e==this.size)return j_(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?j_(n+1,s):j_(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 RN={index:0,offset:0};function j_(t,e){return RN.index=t,RN.offset=e,RN}function Bw(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(!Bw(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Bw(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let tr=class UP{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&&Bw(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 UP.none;if(e instanceof UP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};tr.none=[];class Hw extends Error{}class kt{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=aQ(this.content,e+this.openStart,n);return r&&new kt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new kt(sQ(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 kt.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 kt(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 kt(e,r,i)}}kt.empty=new kt(pt.empty,0,0);function sQ(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(sQ(s.content,e-i-1,n-i-1)))}function aQ(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=aQ(a.content,e-s-1,n,a);return o&&t.replaceChild(i,a.copy(o))}function MFe(t,e,n){if(n.openStart>t.depth)throw new Hw("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Hw("Inconsistent open depths");return oQ(t,e,n,0)}function oQ(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=oQ(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 Dh(a,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:a,end:o}=AFe(n,t);return Dh(s,cQ(t,a,o,e,r))}else return Dh(s,$w(t,e,r))}function lQ(t,e){if(!e.type.compatibleContent(t.type))throw new Hw("Cannot join "+e.type.name+" onto "+t.type.name)}function FP(t,e,n){let r=t.node(n);return lQ(r,e.node(n)),r}function Rh(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 Jx(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&&(Rh(t.nodeAfter,r),s++));for(let o=s;o<a;o++)Rh(i.child(o),r);e&&e.depth==n&&e.textOffset&&Rh(e.nodeBefore,r)}function Dh(t,e){return t.type.checkContent(e),t.copy(e)}function cQ(t,e,n,r,i){let s=t.depth>i&&FP(t,e,i+1),a=r.depth>i&&FP(n,r,i+1),o=[];return Jx(null,t,i,o),s&&a&&e.index(i)==n.index(i)?(lQ(s,a),Rh(Dh(s,cQ(t,e,n,r,i+1)),o)):(s&&Rh(Dh(s,$w(t,e,i+1)),o),Jx(e,n,i,o),a&&Rh(Dh(a,$w(n,r,i+1)),o)),Jx(r,null,i,o),new pt(o)}function $w(t,e,n){let r=[];if(Jx(null,t,n,r),t.depth>n){let i=FP(t,e,n+1);Rh(Dh(i,$w(t,e,n+1)),r)}return Jx(e,null,n,r),new pt(r)}function AFe(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 J0{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 Vw(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:c}=a.content.findIndex(s),u=s-c;if(r.push(a,o,i+c),!u||(a=a.child(o),a.isText))break;s=u-1,i+=c+1}return new J0(n,r,s)}static resolveCached(e,n){let r=CV.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 CV.set(e,r=new TFe);let i=r.elts[r.i]=J0.resolve(e,n);return r.i=(r.i+1)%CFe,i}}class TFe{constructor(){this.elts=[],this.i=0}}const CFe=12,CV=new WeakMap;class Vw{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 NFe=Object.create(null);let Ju=class zP{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&&Bw(this.attrs,n||e.defaultAttrs||NFe)&&tr.sameSet(this.marks,r||tr.none)}copy(e=null){return e==this.content?this:new zP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new zP(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 kt.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 kt(u,i.depth-a,s.depth-a)}replace(e,n,r){return MFe(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 J0.resolveCached(this,e)}resolveNoCache(e){return J0.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()+")"),uQ(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 c=i;c<s;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let 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}};Ju.prototype.text=void 0;class Gw extends Ju{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):uQ(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 Gw(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Gw(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 uQ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class sf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new kFe(e,n);if(r.next==null)return sf.empty;let i=dQ(r);r.next&&r.err("Unexpected trailing text");let s=IFe(LFe(i));return UFe(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 c=a.matchFragment(e,r);if(c&&(!n||c.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:c}=s.next[a];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||c.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let 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(`
- `)}}sf.empty=new sf(!0);class kFe{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 dQ(t){let e=[];do e.push(PFe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function PFe(t){let e=[];do e.push(RFe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function RFe(t){let e=jFe(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=DFe(t,e);else break;return e}function NV(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function DFe(t,e){let n=NV(t),r=n;return t.eat(",")&&(t.next!="}"?r=NV(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function OFe(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 jFe(t){if(t.eat("(")){let e=dQ(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=OFe(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 LFe(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(a,o,c){let u={term:c,to:o};return e[a].push(u),u}function i(a,o){a.forEach(c=>c.to=o)}function s(a,o){if(a.type=="choice")return a.exprs.reduce((c,u)=>c.concat(s(u,o)),[]);if(a.type=="seq")for(let c=0;;c++){let u=s(a.exprs[c],o);if(c==a.exprs.length-1)return u;i(u,o=n())}else if(a.type=="star"){let c=n();return r(o,c),i(s(a.expr,c),c),[r(c)]}else if(a.type=="plus"){let c=n();return i(s(a.expr,o),c),i(s(a.expr,c),c),[r(c)]}else{if(a.type=="opt")return[r(o)].concat(s(a.expr,o));if(a.type=="range"){let c=o;for(let u=0;u<a.min;u++){let d=n();i(s(a.expr,c),d),c=d}if(a.max==-1)i(s(a.expr,c),c);else for(let u=a.min;u<a.max;u++){let d=n();r(c,d),i(s(a.expr,c),d),c=d}return[r(c)]}else{if(a.type=="name")return[r(o,void 0,a.value)];throw new Error("Unknown expr type")}}}}function hQ(t,e){return e-t}function kV(t,e){let n=[];return r(e),n.sort(hQ);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:c}=s[a];!o&&n.indexOf(c)==-1&&r(c)}}}function IFe(t){let e=Object.create(null);return n(kV(t,0));function n(r){let i=[];r.forEach(a=>{t[a].forEach(({term:o,to:c})=>{if(!o)return;let u;for(let d=0;d<i.length;d++)i[d][0]==o&&(u=i[d][1]);kV(t,c).forEach(d=>{u||i.push([o,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new sf(r.indexOf(t.length-1)>-1);for(let a=0;a<i.length;a++){let o=i[a][1].sort(hQ);s.next.push({type:i[a][0],next:e[o.join(",")]||n(o)})}return s}}function UFe(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:c,next:u}=i.next[o];a.push(c.name),s&&!(c.isText||c.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 fQ(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 pQ(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 mQ(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 gQ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new zFe(t,r,e[r]);return n}let PV=class xQ{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=gQ(e,r.attrs),this.defaultAttrs=fQ(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==sf.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:pQ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ju(this,this.computeAttrs(e),pt.from(n),tr.setFrom(r))}createChecked(e=null,n,r){return n=pt.from(n),this.checkContent(n),new Ju(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 Ju(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){mQ(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 xQ(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 FFe(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 zFe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?FFe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class qE{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=gQ(e,i.attrs),this.excluded=null;let s=fQ(this.attrs);this.instance=s?new tr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new tr(this,pQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,a)=>r[s]=new qE(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){mQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class bQ{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Yi.from(e.nodes),n.marks=Yi.from(e.marks||{}),this.nodes=PV.compile(this.spec.nodes,this),this.marks=qE.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]=sf.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?RV(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==""?[]:RV(this,a.split(" "))}this.nodeFromJSON=i=>Ju.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 PV){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 Gw(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 RV(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 c=t.marks[o];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function BFe(t){return t.tag!=null}function HFe(t){return t.style!=null}let e0=class BP{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(BFe(i))this.tags.push(i);else if(HFe(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 OV(this,n,!1);return r.addAll(e,tr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new OV(this,n,!0);return r.addAll(e,tr.none,n.from,n.to),kt.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(GFe(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 c=a.getAttrs(n);if(c===!1)continue;a.attrs=c||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=jV(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=jV(a)),a.node||a.ignore||a.mark||(a.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new BP(e,BP.schemaRules(e)))}};const vQ={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},$Fe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},yQ={ol:!0,ul:!0},eb=1,HP=2,t0=4;function DV(t,e,n){return e!=null?(e?eb:0)|(e==="full"?HP:0):t&&t.whitespace=="pre"?eb|HP:n&~t0}class L_{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&t0?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&eb)){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&&!vQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class OV{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=DV(null,n.preserveWhitespace,0)|(r?t0:0);i?s=new L_(i.type,i.attrs,tr.none,!0,n.topMatch||i.type.contentMatch,a):r?s=new L_(null,null,tr.none,!0,null,a):s=new L_(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&HP?"full":this.localPreserveWS||(i.options&eb)>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 c=0;c<o.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(a.text(o[c]),n,!/\S/.test(o[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],c=e.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(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;yQ.hasOwnProperty(a)&&this.parser.normalizeLists&&VFe(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(c?c.ignore:$Fe.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(vQ.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=c&&c.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,c,u,c.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),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 c=this.parser.matchStyle(s,a,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return n}addElementByRule(e,n,r,i){let 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 c=this.enter(a,n.attrs||null,r,n.preserveWhitespace);c&&(s=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.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(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}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 c=this.nodes[a],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,s=c,!u.length))break;if(c.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):LV(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=DV(e,s,a.options);a.options&t0&&a.content.length==0&&(o|=t0);let c=tr.none;return r=r.filter(u=>(a.type?a.type.allowsMarkType(u.type):LV(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new L_(e,n,c,i,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=eb)}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,c)=>{for(;o>=0;o--){let u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;c>=s;c--)if(a(o-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=s?r.node(c-s).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}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 VFe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&yQ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function GFe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function jV(t){let e={};for(let n in t)e[n]=t[n];return e}function LV(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 c=0;c<o.edgeCount;c++){let{type:u,next:d}=o.edge(c);if(u==e||s.indexOf(d)<0&&a(d))return!0}};if(a(i.contentMatch))return!0}}class xf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=DN(n).createDocumentFragment());let i=r,s=[];return e.forEach(a=>{if(s.length||a.marks.length){let o=0,c=0;for(;o<s.length&&c<a.marks.length;){let u=a.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(s[o][0])||u.type.spec.spanning===!1)break;o++,c++}for(;o<s.length;)i=s.pop()[1];for(;c<a.marks.length;){let u=a.marks[c++],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}=m1(DN(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&&m1(DN(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return m1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new xf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=IV(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return IV(e.marks)}}function IV(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function DN(t){return t.document||window.document}const UV=new WeakMap;function WFe(t){let e=UV.get(t);return e===void 0&&UV.set(t,e=qFe(t)),e}function qFe(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 m1(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=WFe(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,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:x}=m1(t,g,n,r);if(c.appendChild(m),x){if(o)throw new RangeError("Multiple content holes");o=x}}}return{dom:c,contentDOM:o}}const _Q=65535,wQ=Math.pow(2,16);function KFe(t,e){return t+e*wQ}function FV(t){return t&_Q}function XFe(t){return(t-(t&_Q))/wQ}const SQ=1,EQ=2,g1=4,MQ=8;class $P{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&MQ)>0}get deletedBefore(){return(this.delInfo&(SQ|g1))>0}get deletedAfter(){return(this.delInfo&(EQ|g1))>0}get deletedAcross(){return(this.delInfo&g1)>0}}class ba{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ba.empty)return ba.empty}recover(e){let n=0,r=FV(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+XFe(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 c=this.ranges[o]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[o+s],d=this.ranges[o+a],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,m=c+i+(g<0?0:d);if(r)return m;let x=e==(n<0?c:f)?null:KFe(o/3,e-c),y=e==c?EQ:e==f?SQ:g1;return(n<0?e!=c:e!=f)&&(y|=MQ),new $P(m,y,x)}i+=d-u}return r?e+i:new $P(e+i,0,null)}touches(e,n){let r=0,i=FV(n),s=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[o+s],d=c+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),c=a+(this.inverted?0:s),u=this.ranges[i+n],d=this.ranges[i+r];e(o,o+u,c,c+d),s+=d-u}}invert(){return new ba(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ba.empty:new ba(e<0?[0,-e,0]:[0,0,e])}}ba.empty=new ba([]);class tb{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 tb(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 tb;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 c=this.getMirror(s);if(c!=null&&c>s&&c<this.to){s=c,e=this._maps[c].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new $P(e,i,null)}}const ON=Object.create(null);class bs{getMap(){return ba.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ON[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 ON)throw new RangeError("Duplicate use of step JSON ID "+e);return ON[e]=n,n.prototype.jsonID=e,n}}class ei{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ei(e,null)}static fail(e){return new ei(null,e)}static fromReplace(e,n,r,i){try{return ei.ok(e.replace(n,r,i))}catch(s){if(s instanceof Hw)return ei.fail(s.message);throw s}}}function _j(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(_j(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return pt.fromArray(r)}class $u extends bs{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 kt(_j(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 ei.fromReplace(e,this.from,this.to,s)}invert(){return new jo(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 $u(n.pos,r.pos,this.mark)}merge(e){return e instanceof $u&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new $u(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 $u(n.from,n.to,e.markFromJSON(n.mark))}}bs.jsonID("addMark",$u);class jo extends bs{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 kt(_j(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ei.fromReplace(e,this.from,this.to,r)}invert(){return new $u(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 jo(n.pos,r.pos,this.mark)}merge(e){return e instanceof jo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jo(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 jo(n.from,n.to,e.markFromJSON(n.mark))}}bs.jsonID("removeMark",jo);class Vu extends bs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ei.fromReplace(e,this.pos,this.pos+1,new kt(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 Vu(this.pos,n.marks[i]);return new Vu(this.pos,this.mark)}}return new af(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Vu(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 Vu(n.pos,e.markFromJSON(n.mark))}}bs.jsonID("addNodeMark",Vu);class af extends bs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ei.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ei.fromReplace(e,this.pos,this.pos+1,new kt(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 Vu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new af(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 af(n.pos,e.markFromJSON(n.mark))}}bs.jsonID("removeNodeMark",af);class ji extends bs{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&VP(e,this.from,this.to)?ei.fail("Structure replace would overwrite content"):ei.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ba([this.from,this.to-this.from,this.slice.size])}invert(e){return new ji(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 ji(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ji)||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?kt.empty:new kt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ji(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?kt.empty:new kt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ji(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 ji(n.from,n.to,kt.fromJSON(e,n.slice),!!n.structure)}}bs.jsonID("replace",ji);class Ii extends bs{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&&(VP(e,this.from,this.gapFrom)||VP(e,this.gapTo,this.to)))return ei.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ei.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ei.fromReplace(e,this.from,this.to,r):ei.fail("Content does not fit in gap")}getMap(){return new ba([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ii(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),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 Ii(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 Ii(n.from,n.to,n.gapFrom,n.gapTo,kt.fromJSON(e,n.slice),n.insert,!!n.structure)}}bs.jsonID("replaceAround",Ii);function VP(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 YFe(t,e,n,r){let i=[],s=[],a,o;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),m=Math.min(u+c.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 jo(g,m,f[y])));o&&o.to==g?o.to=m:s.push(o=new $u(g,m,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function ZFe(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(a,o)=>{if(!a.isInline)return;s++;let c=null;if(r instanceof qE){let u=a.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(a.marks)&&(c=[r]):c=a.marks;if(c&&c.length){let u=Math.min(o+a.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[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 jo(a.from,a.to,a.style)))}function wj(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),a=[],o=e+1;for(let c=0;c<s.childCount;c++){let u=s.child(c),d=o+u.nodeSize,f=r.matchType(u.type);if(!f)a.push(new ji(o,d,kt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new jo(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 kt(pt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),a.push(new ji(o+g.index,o+g.index+g[0].length,x))}}o=d}if(!r.validEnd){let c=r.fillBefore(pt.empty,!0);t.replace(o,o,new kt(c,0,0))}for(let c=a.length-1;c>=0;c--)t.step(a[c])}function QFe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hg(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,c=t.$to.indexAfter(r)-s;if(r<t.depth&&a.canReplace(o,c,n))return r;if(r==0||a.type.spec.isolating||!QFe(a,o,c))break;o&&(i=1),c<a.childCount&&(s=1)}return null}function JFe(t,e,n){let{$from:r,$to:i,depth:s}=e,a=r.before(s+1),o=i.after(s+1),c=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++):c--;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 Ii(c,u,a,o,new kt(d.append(g),f,m),d.size-f,!0))}function Sj(t,e,n=null,r=t){let i=eze(t,e),s=i&&tze(r,e);return s?i.map(zV).concat({type:e,attrs:n}).concat(s.map(zV)):null}function zV(t){return{type:t,attrs:null}}function eze(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 tze(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 c=(a.length?a[a.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:a}function nze(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 Ii(i,s,i,s,new kt(r,0,0),n.length,!0))}function rze(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 c=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(r,c)&&ize(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&&TQ(t,a,o,s),wj(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 Ii(f,g,f+1,g-1,new kt(pt.from(r.create(c,null,a.marks)),0,0),1,!0)),u===!0&&AQ(t,a,o,s),!1}})}function AQ(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 c=t.mapping.slice(r).map(n+1+s+a.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function TQ(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 ize(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function sze(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 Ii(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new kt(pt.from(a),0,0),1,!0))}function Mc(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),c=r&&r[0];return i.node(s).canReplaceWith(o,o,c?c.type:i.node(s+1).type)}function aze(t,e,n=1,r){let i=t.doc.resolve(e),s=pt.empty,a=pt.empty;for(let o=i.depth,c=i.depth-n,u=n-1;o>c;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 ji(e,e,new kt(s.append(a),n,n),!0))}function Sd(t,e){let n=t.resolve(e),r=n.index();return CQ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function oze(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 CQ(t,e){return!!(t&&e&&!t.isLeaf&&oze(t,e))}function KE(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&&CQ(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 lze(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);TQ(t,d.node(),d.before(),o)}a.inlineContent&&wj(t,e+n-1,a,s.node().contentMatchAt(s.index()),r==null);let c=t.mapping.slice(o),u=c.map(e-n);if(t.step(new ji(u,c.map(e+n,-1),kt.empty,!0)),r===!0){let d=t.doc.resolve(u);AQ(t,d.node(),d.before(),t.steps.length)}return t}function cze(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 NQ(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,c=r.index(a)+(o>0?1:0),u=r.node(a),d=!1;if(s==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return o==0?r.pos:o<0?r.before(a+1):r.after(a+1)}return null}function XE(t,e,n=e,r=kt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return kQ(i,s,r)?new ji(e,n,r):new uze(i,s,r).fit()}function kQ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class uze{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 c=new kt(s,a,o);return e>-1?new Ii(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new ji(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let 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=jN(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:c,match:u}=this.frontier[o],d,f=null;if(n==1&&(a?u.matchType(a.type)||(f=u.fillBefore(pt.from(a),!1)):s&&c.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=jN(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new kt(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=jN(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new kt(zx(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new kt(zx(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,c=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||c==0||y.content.size)&&(f=v,d.push(PQ(y.mark(g.allowedMarks(y.marks)),u==1?c:0,u==o.childCount?m:-1)))}let x=u==o.childCount;x||(m=-1),this.placed=Bx(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?kt.empty:new kt(zx(a.content,e-1,1),e-1,m<0?a.openEnd:e-1):new kt(zx(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||!LN(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=LN(e,n,i,r,s);if(a){for(let o=n-1;o>=0;o--){let{match:c,type:u}=this.frontier[o],d=LN(e,o,u,c,!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=Bx(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=Bx(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=Bx(this.placed,this.frontier.length,n))}}function zx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(zx(t.firstChild.content,e-1,n)))}function Bx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Bx(t.lastChild.content,e-1,n)))}function jN(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function PQ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,PQ(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 LN(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&&!dze(n,s.content,a)?o:null}function dze(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function hze(t){return t.spec.defining||t.spec.definingForContent}function fze(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(kQ(i,s,r))return t.step(new ji(e,n,r));let a=DQ(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 c=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=hze(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+c)%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 kt(RQ(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 RQ(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(RQ(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 pze(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=cze(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new kt(pt.from(r),0,0))}function mze(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=DQ(r,i);for(let a=0;a<s.length;a++){let o=s[a],c=a==s.length-1;if(c&&o==0||r.node(o).type.contentMatch.validEnd)return t.delete(r.start(o),i.end(o));if(o>0&&(c||r.node(o-1).canReplace(r.index(o-1),i.indexAfter(o-1))))return t.delete(r.before(o),i.after(o))}for(let 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 DQ(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 cm extends bs{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 ei.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 ei.fromReplace(e,this.pos,this.pos+1,new kt(pt.from(i),0,n.isLeaf?0:1))}getMap(){return ba.empty}invert(e){return new cm(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 cm(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 cm(n.pos,n.attr,n.value)}}bs.jsonID("attr",cm);class nb extends bs{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 ei.ok(r)}getMap(){return ba.empty}invert(e){return new nb(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 nb(n.attr,n.value)}}bs.jsonID("docAttr",nb);let Lm=class extends Error{};Lm=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Lm.prototype=Object.create(Error.prototype);Lm.prototype.constructor=Lm;Lm.prototype.name="TransformError";class OQ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Lm(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=kt.empty){let i=XE(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new kt(pt.from(r),0,0))}delete(e,n){return this.replace(e,n,kt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return fze(this,e,n,r),this}replaceRangeWith(e,n,r){return pze(this,e,n,r),this}deleteRange(e,n){return mze(this,e,n),this}lift(e,n){return JFe(this,e,n),this}join(e,n=1){return lze(this,e,n),this}wrap(e,n){return nze(this,e,n),this}setBlockType(e,n=e,r,i=null){return rze(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return sze(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new cm(e,n,r)),this}setDocAttribute(e,n){return this.step(new nb(e,n)),this}addNodeMark(e,n){return this.step(new Vu(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 af(e,n));else{let i=r.marks,s,a=[];for(;s=n.isInSet(i);)a.push(new af(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 aze(this,e,n,r),this}addMark(e,n,r){return YFe(this,e,n,r),this}removeMark(e,n,r){return ZFe(this,e,n,r),this}clearIncompatible(e,n,r){return wj(this,e,n,r),this}}const IN=Object.create(null);class un{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new gze(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=kt.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:c,$to:u}=a[o],d=e.mapping.slice(s);e.replaceRange(d.map(c.pos),d.map(u.pos),o?kt.empty:n),o==0&&$V(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],c=e.mapping.slice(r),u=c.map(a.pos),d=c.map(o.pos);s?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),$V(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Kt(e):zp(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?zp(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):zp(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 Ea(e.node(0))}static atStart(e){return zp(e,e,0,0,1)||new Ea(e)}static atEnd(e){return zp(e,e,e.content.size,e.childCount,-1)||new Ea(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=IN[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 IN)throw new RangeError("Duplicate use of selection JSON ID "+e);return IN[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Kt.between(this.$anchor,this.$head).getBookmark()}}un.prototype.visible=!0;class gze{constructor(e,n){this.$from=e,this.$to=n}}let BV=!1;function HV(t){!BV&&!t.parent.inlineContent&&(BV=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Kt extends un{constructor(e,n=e){HV(e),HV(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return un.near(r);let i=e.resolve(n.map(this.anchor));return new Kt(i.parent.inlineContent?i:r,r)}replace(e,n=kt.empty){if(super.replace(e,n),n==kt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Kt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new YE(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Kt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=un.findFrom(n,r,!0)||un.findFrom(n,-r,!0);if(s)n=s.$head;else return un.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(un.findFrom(e,-r,!0)||un.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Kt(e,n)}}un.jsonID("text",Kt);class YE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new YE(e.map(this.anchor),e.map(this.head))}resolve(e){return Kt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ht extends un{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?un.near(s):new Ht(s)}content(){return new kt(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 Ej(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ht(e.resolve(n.anchor))}static create(e,n){return new Ht(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ht.prototype.visible=!1;un.jsonID("node",Ht);class Ej{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new YE(r,r):new Ej(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ht.isSelectable(r)?new Ht(n):un.near(n)}}class Ea extends un{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=kt.empty){if(n==kt.empty){e.delete(0,e.doc.content.size);let r=un.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ea(e)}map(e){return new Ea(e)}eq(e){return e instanceof Ea}getBookmark(){return xze}}un.jsonID("all",Ea);const xze={map(){return this},resolve(t){return new Ea(t)}};function zp(t,e,n,r,i,s=!1){if(e.inlineContent)return Kt.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 c=zp(t,o,n+i,i<0?o.childCount:0,i,s);if(c)return c}n+=o.nodeSize*i}return null}function $V(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ji||i instanceof Ii))return;let s=t.mapping.maps[r],a;s.forEach((o,c,u,d)=>{a==null&&(a=d)}),t.setSelection(un.near(t.doc.resolve(a),n))}const VV=1,I_=2,GV=4;class bze extends OQ{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|VV)&~I_,this.storedMarks=null,this}get selectionSet(){return(this.updated&VV)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=I_,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&I_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~I_,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(un.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=GV,this}get scrolledIntoView(){return(this.updated&GV)>0}}function WV(t,e){return!e||!t?t:t.bind(e)}class Hx{constructor(e,n,r){this.name=e,this.init=WV(n.init,r),this.apply=WV(n.apply,r)}}const vze=[new Hx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Hx("selection",{init(t,e){return t.selection||un.atStart(e.doc)},apply(t){return t.selection}}),new Hx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Hx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class UN{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vze.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 Hx(r.key,r.spec.state,r))})}}class Yp{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 c=i?i[a].n:0,u=i?i[a].state:this,d=c<n.length&&o.spec.appendTransaction.call(o,c?n.slice(c):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 Yp(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 bze(this)}static create(e){let n=new UN(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Yp(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 UN(this.schema,e.plugins),r=n.fields,i=new Yp(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 UN(e.schema,e.plugins),s=new Yp(i);return i.fields.forEach(a=>{if(a.name=="doc")s.doc=Ju.fromJSON(e.schema,n.doc);else if(a.name=="selection")s.selection=un.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 c=r[o],u=c.spec.state;if(c.key==a.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){s[a.name]=u.fromJSON.call(c,e,n[o],s);return}}s[a.name]=a.init(e,s)}}),s}}function jQ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=jQ(i,e,{})),n[r]=i}return n}class Mr{constructor(e){this.spec=e,this.props={},e.props&&jQ(e.props,this,this.props),this.key=e.key?e.key.key:LQ("plugin")}getState(e){return e[this.key]}}const FN=Object.create(null);function LQ(t){return t in FN?t+"$"+ ++FN[t]:(FN[t]=0,t+"$")}class Si{constructor(e="key"){this.key=LQ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Mj=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function IQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const UQ=(t,e,n)=>{let r=IQ(t,n);if(!r)return!1;let i=Aj(r);if(!i){let a=r.blockRange(),o=a&&hg(a);return o==null?!1:(e&&e(t.tr.lift(a,o).scrollIntoView()),!0)}let s=i.nodeBefore;if(qQ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Im(s,"end")||Ht.isSelectable(s)))for(let a=r.depth;;a--){let o=XE(t.doc,r.before(a),r.after(a),kt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(Im(s,"end")?un.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Ht.create(c.doc,i.pos-s.nodeSize)),e(c.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},yze=(t,e,n)=>{let r=IQ(t,n);if(!r)return!1;let i=Aj(r);return i?FQ(t,i,e):!1},_ze=(t,e,n)=>{let r=BQ(t,n);if(!r)return!1;let i=Tj(r);return i?FQ(t,i,e):!1};function FQ(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,c=e.pos+1;for(;!o.isTextblock;c++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let u=XE(t.doc,s,c,kt.empty);if(!u||u.from!=s||u instanceof ji&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(Kt.create(d.doc,s)),n(d.scrollIntoView())}return!0}function Im(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 zQ=(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=Aj(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 Aj(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 BQ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const HQ=(t,e,n)=>{let r=BQ(t,n);if(!r)return!1;let i=Tj(r);if(!i)return!1;let s=i.nodeAfter;if(qQ(t,i,e,1))return!0;if(r.parent.content.size==0&&(Im(s,"start")||Ht.isSelectable(s))){let a=XE(t.doc,r.before(),r.after(),kt.empty);if(a&&a.slice.size<a.to-a.from){if(e){let o=t.tr.step(a);o.setSelection(Im(s,"start")?un.findFrom(o.doc.resolve(o.mapping.map(i.pos)),1):Ht.create(o.doc,o.mapping.map(i.pos))),e(o.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},$Q=(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=Tj(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 Tj(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 wze=(t,e)=>{let n=t.selection,r=n instanceof Ht,i;if(r){if(n.node.isTextblock||!Sd(t.doc,n.from))return!1;i=n.from}else if(i=KE(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},Sze=(t,e)=>{let n=t.selection,r;if(n instanceof Ht){if(n.node.isTextblock||!Sd(t.doc,n.to))return!1;r=n.to}else if(r=KE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Eze=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&hg(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},VQ=(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 Cj(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 Mze=(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=Cj(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(e){let o=n.after(),c=t.tr.replaceWith(o,o,a.createAndFill());c.setSelection(un.near(c.doc.resolve(o),1)),e(c.scrollIntoView())}return!0},GQ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ea||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Cj(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(Kt.create(o.doc,a+1)),e(o.scrollIntoView())}return!0},WQ=(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(Mc(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&hg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Aze(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ht&&e.selection.node.isBlock)return!r.parentOffset||!Mc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],a,o,c=!1,u=!1;for(let m=r.depth;;m--)if(r.node(m).isBlock){c=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),o=Cj(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(c&&o?{type:o}:null),a=m;break}else{if(m==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof Kt||e.selection instanceof Ea)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Mc(d.doc,f,s.length,s);if(g||(s[0]=o?{type:o}:null,g=Mc(d.doc,f,s.length,s)),!g)return!1;if(d.split(f,s.length,s),!c&&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 Tze=Aze(),Cze=(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 Nze(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||Sd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function qQ(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,a,o,c=i.type.spec.isolating||s.type.spec.isolating;if(!c&&Nze(t,e,n))return!0;let u=!c&&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 Ii(e.pos-1,m,e.pos,m,new kt(x,1,0),a.length,!0)),v=y.doc.resolve(m+2*a.length);v.nodeAfter&&v.nodeAfter.type==i.type&&Sd(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:un.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&hg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&Im(s,"start",!0)&&Im(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 Ii(e.pos-x.length,e.pos+s.nodeSize,e.pos+v,e.pos+s.nodeSize-v,new kt(b,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function KQ(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(Kt.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const kze=KQ(-1),Pze=KQ(1);function Rze(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,a=i.blockRange(s),o=a&&Sj(a,t,e);return o?(r&&r(n.tr.wrap(a,o).scrollIntoView()),!0):!1}}function qV(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,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let a=0;a<n.selection.ranges.length;a++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[a];s.setBlockType(o,c,t,e)}r(s.scrollIntoView())}return!0}}function Nj(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Nj(Mj,UQ,zQ);Nj(Mj,HQ,$Q);Nj(VQ,GQ,WQ,Tze);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Dze(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 Oze(o,a,t,e)?(r&&r(o.scrollIntoView()),!0):!1}}function Oze(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 c=a.resolve(e.start-2);s=new Vw(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new Vw(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let o=Sj(s,n,r,e);return o?(t&&jze(t,e,o,i,n),!0):!1}function jze(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 Ii(e.start-(r?2:0),e.end,e.start,e.end,new kt(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,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&Mc(t.doc,c,o)&&(t.split(c,o),c+=2*o),c+=u.child(d).nodeSize;return t}function Lze(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?Ize(e,n,t,s):Uze(e,n,s):!0:!1}}function Ize(t,e,n,r){let i=t.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new Ii(s-1,a,s,a,new kt(pt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Vw(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));const o=hg(r);if(o==null)return!1;i.lift(r,o);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return Sd(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function Uze(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,c=n.endIndex==i.childCount,u=s.node(-1),d=s.index(-1);if(!u.canReplace(d+(o?0:1),d+1,a.content.append(c?pt.empty:pt.from(i))))return!1;let f=s.pos,g=f+a.nodeSize;return r.step(new Ii(f-(o?1:0),g+(c?1:0),f+1,g-1,new kt((o?pt.empty:pt.from(i.copy(pt.empty))).append(c?pt.empty:pt.from(i.copy(pt.empty))),o?0:1,c?0:1),o?0:1)),e(r.scrollIntoView()),!0}function Fze(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,c=o.child(a-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==o.type,d=pt.from(u?t.create():null),f=new kt(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 Ii(g-(u?3:1),m,g,m,f,1,!0)).scrollIntoView())}return!0}}const es=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Um=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let GP=null;const oc=function(t,e,n){let r=GP||(GP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},zze=function(){GP=null},of=function(t,e,n,r){return n&&(KV(t,e,n,r,-1)||KV(t,e,n,r,1))},Bze=/^(img|br|input|textarea|hr)$/i;function KV(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:eo(t))){let a=t.parentNode;if(!a||a.nodeType!=1||Yb(t)||Bze.test(t.nodeName)||t.contentEditable=="false")return!1;e=es(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?eo(t):0}else return!1}}function eo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Hze(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=eo(t)}else if(t.parentNode&&!Yb(t))e=es(t),t=t.parentNode;else return null}}function $ze(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&&!Yb(t))e=es(t)+1,t=t.parentNode;else return null}}function Vze(t,e,n){for(let r=e==0,i=e==eo(t);r||i;){if(t==n)return!0;let s=es(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==eo(t)}}function Yb(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 ZE=function(t){return t.focusNode&&of(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function dh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Gze(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Wze(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(eo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(eo(r.startContainer),r.startOffset)}}}const bl=typeof navigator<"u"?navigator:null,XV=typeof document<"u"?document:null,Ed=bl&&bl.userAgent||"",WP=/Edge\/(\d+)/.exec(Ed),XQ=/MSIE \d/.exec(Ed),qP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ed),Zs=!!(XQ||qP||WP),ed=XQ?document.documentMode:qP?+qP[1]:WP?+WP[1]:0,ao=!Zs&&/gecko\/(\d+)/i.test(Ed);ao&&+(/Firefox\/(\d+)/.exec(Ed)||[0,0])[1];const KP=!Zs&&/Chrome\/(\d+)/.exec(Ed),ps=!!KP,YQ=KP?+KP[1]:0,Ps=!Zs&&!!bl&&/Apple Computer/.test(bl.vendor),Fm=Ps&&(/Mobile\/\w+/.test(Ed)||!!bl&&bl.maxTouchPoints>2),Ka=Fm||(bl?/Mac/.test(bl.platform):!1),qze=bl?/Win/.test(bl.platform):!1,bc=/Android \d/.test(Ed),Zb=!!XV&&"webkitFontSmoothing"in XV.documentElement.style,Kze=Zb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Xze(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 tc(t,e){return typeof t=="number"?t:t[e]}function Yze(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 YV(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=Um(a);continue}let o=a,c=o==s.body,u=c?Xze(s):Yze(o),d=0,f=0;if(e.top<u.top+tc(r,"top")?f=-(u.top-e.top+tc(i,"top")):e.bottom>u.bottom-tc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+tc(i,"top")-u.top:e.bottom-u.bottom+tc(i,"bottom")),e.left<u.left+tc(r,"left")?d=-(u.left-e.left+tc(i,"left")):e.right>u.right-tc(r,"right")&&(d=e.right-u.right+tc(i,"right")),d||f)if(c)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=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(g))break;a=g=="absolute"?a.offsetParent:Um(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 c=o.getBoundingClientRect();if(c.top>=n-20){r=o,i=c.top;break}}return{refDOM:r,refTop:i,stack:ZQ(t.dom)}}function ZQ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Um(r));return e}function Qze({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;QQ(n,r==0?0:r-e)}function QQ(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 Op=null;function Jze(t){if(t.setActive)return t.setActive();if(Op)return t.focus(Op);let e=ZQ(t);t.focus(Op==null?{get preventScroll(){return Op={preventScroll:!0},!0}}:void 0),Op||(Op=!1,QQ(e,0))}function JQ(t,e){let n,r=2e8,i,s=0,a=e.top,o=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=oc(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&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?eBe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:JQ(n,i)}function eBe(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=Au(r,1);if(s.top!=s.bottom&&kj(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function kj(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function tBe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function nBe(t,e,n){let{node:r,offset:i}=JQ(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 rBe(t,e,n,r){let i=-1;for(let s=e,a=!1;s!=t.dom;){let o=t.docView.nearestDesc(s,!0),c;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((c=o.dom.getBoundingClientRect()).width||c.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!a&&c.left>r.left||c.top>r.top?i=o.posBefore:(!a&&c.right<r.left||c.bottom<r.top)&&(i=o.posAfter),a=!0),!o.contentDOM&&i<0&&!o.node.isText))return(o.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?o.posBefore:o.posAfter;s=o.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function eJ(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 c=0;c<o.length;c++){let u=o[c];if(kj(e,u))return eJ(a,e,u)}}if((s=(s+1)%r)==i)break}return t}function iBe(t,e){let n=t.dom.ownerDocument,r,i=0,s=Wze(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(!kj(e,u)||(a=eJ(t.dom,e,u),!a))return null}if(Ps)for(let u=a;r&&u;u=Um(u))u.draggable&&(r=void 0);if(a=tBe(a,e),r){if(ao&&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;Zb&&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=rBe(t,r,i,e))}o==null&&(o=nBe(t,a,e));let c=t.docView.nearestDesc(a,!0);return{pos:o,inside:c?c.posAtStart-c.border:-1}}function ZV(t){return t.top<t.bottom||t.left<t.right}function Au(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(ZV(r))return r}return Array.prototype.find.call(n,ZV)||t.getBoundingClientRect()}const sBe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function tJ(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),a=Zb||ao;if(r.nodeType==3)if(a&&(sBe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Au(oc(r,i,i),n);if(ao&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Au(oc(r,i-1,i-1),-1);if(u.top==c.top){let d=Au(oc(r,i,i+1),-1);if(d.top!=c.top)return Nx(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,Nx(Au(oc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==eo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return zN(c.getBoundingClientRect(),!1)}if(s==null&&i<eo(r)){let c=r.childNodes[i];if(c.nodeType==1)return zN(c.getBoundingClientRect(),!0)}return zN(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==eo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?oc(c,eo(c)-(a?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Nx(Au(u,1),!1)}if(s==null&&i<eo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?oc(c,0,a?0:1):c.nodeType==1?c:null:null;if(u)return Nx(Au(u,-1),!0)}return Nx(Au(r.nodeType==3?oc(r):r,-n),n>=0)}function Nx(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 zN(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 nJ(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 aBe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return nJ(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=tJ(t,i.pos,1);for(let o=s.firstChild;o;o=o.nextSibling){let c;if(o.nodeType==1)c=o.getClientRects();else if(o.nodeType==3)c=oc(o,0,o.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?a.top-d.top>(d.bottom-a.top)*2:d.bottom-a.bottom>(a.bottom-d.top)*2))return!1}}return!0})}const oBe=/[\u0590-\u08ac]/;function lBe(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?!oBe.test(r.parent.textContent)||!o.modify?n=="left"||n=="backward"?s:a:nJ(t,e,()=>{let{focusNode:c,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)||c==x&&u==y;try{o.collapse(d,f),c&&(c!=d||u!=f)&&o.extend&&o.extend(c,u)}catch{}return g!=null&&(o.caretBidiLevel=g),v}):r.pos==r.start()||r.pos==r.end()}let QV=null,JV=null,e9=!1;function cBe(t,e,n){return QV==e&&JV==n?e9:(QV=e,JV=n,e9=n=="up"||n=="down"?aBe(t,e,n):lBe(t,e,n))}const oo=0,t9=1,xh=2,vl=3;class Qb{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=oo,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>es(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 iJ){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 rJ&&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?es(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?es(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 c=this.children[o],u=a+c.size;if(i==-1&&e<=u){let d=a+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=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=es(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=es(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),c=n==e?o:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((ao||Ps)&&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=c={node:v.parentNode,offset:es(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(ao&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ps)&&of(o.node,o.offset,d.anchorNode,d.anchorOffset)&&of(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&ao)){u.collapse(o.node,o.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let x=o;o=c,c=x}let m=document.createRange();m.setEnd(c.node,c.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,c=a-s.border;if(e>=o&&n<=c){this.dirty=e==r||n==a?xh:t9,e==o&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=vl:s.markDirty(e-o,n-o);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?xh:vl}r=a}this.dirty=xh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?xh:t9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class rJ extends Qb{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==oo&&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 uBe extends Qb{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 lf extends Qb{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=xf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new lf(e,n,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&vl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=vl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=oo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=oo}}slice(e,n,r){let i=lf.create(this.parent,this.mark,!0,r),s=this.children,a=this.size;n<a&&(s=YP(s,n,a,r)),e>0&&(s=YP(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 td extends Qb{constructor(e,n,r,i,s,a,o,c,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],c,u=o&&o(n,s,()=>{if(!c)return a;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=xf.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=oJ(d,r,n),u?c=new dBe(e,n,r,i,d,f||null,g,u,s,a+1):n.isText?new QE(e,n,r,i,d,g,s):new td(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==oo&&e.eq(this.node)&&Ww(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,c=new fBe(this,a&&a.node,e);gBe(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?tr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,g)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,f,g)||o&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(u,d,f,m,e)||c.updateNextNode(u,d,f,e,g,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==xh)&&(a&&this.protectLocalComposition(e,a),sJ(this.contentDOM,this.children,e),Fm&&xBe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Kt)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,o=bBe(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 uBe(this,s,n,i);e.input.compositionNodes.push(a),this.children=YP(this.children,r,r+i.length,e,a)}update(e,n,r,i){return this.dirty==vl||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=oo}updateOuterDeco(e){if(Ww(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=aJ(this.dom,this.nodeDOM,XP(this.outerDeco,this.node,n),XP(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 n9(t,e,n,r,i){oJ(r,e,t);let s=new td(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class QE extends td{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==vl||this.dirty!=oo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=oo||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=oo,!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 QE(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=vl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class iJ extends Qb{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==oo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class dBe extends td{constructor(e,n,r,i,s,a,o,c,u,d){super(e,n,r,i,s,a,o,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==vl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let 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 sJ(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=r9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(o,r);if(a instanceof lf){let c=r?r.previousSibling:t.lastChild;sJ(a.contentDOM,a.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=r9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const n0=function(t){t&&(this.nodeName=t)};n0.prototype=Object.create(null);const bh=[new n0];function XP(t,e,n){if(t.length==0)return bh;let r=n?bh[0]:new n0,i=[r];for(let s=0;s<t.length;s++){let a=t[s].type.attrs;if(a){a.nodeName&&i.push(r=new n0(a.nodeName));for(let o in a){let c=a[o];c!=null&&(n&&i.length==1&&i.push(r=new n0(e.isInline?"span":"div")),o=="class"?r.class=(r.class?r.class+" ":"")+c:o=="style"?r.style=(r.style?r.style+";":"")+c:o!="nodeName"&&(r[o]=c))}}}return i}function aJ(t,e,n,r){if(n==bh&&r==bh)return e;let i=e;for(let s=0;s<r.length;s++){let a=r[s],o=n[s];if(s){let c;o&&o.nodeName==a.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||(c=document.createElement(a.nodeName),c.pmIsDeco=!0,c.appendChild(i),o=bh[0]),i=c}hBe(i,o||bh[0],a)}return i}function hBe(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 oJ(t,e,n){return aJ(t,t,bh,XP(e,n,t.nodeType!=1))}function Ww(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 r9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fBe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=pBe(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=oo,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 c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){o=c;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let c=lf.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,c),this.top=c,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,c=Math.min(this.top.children.length,o+5);o<c;o++){let u=this.top.children[o];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){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==vl&&a.dom==a.contentDOM&&(a.dirty=xh),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 c=this.top.children[o];if(c instanceof td){let u=this.preMatch.matched.get(c);if(u!=null&&u!=s)return!1;let d=c.dom,f,g=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=vl&&Ww(n,c.outerDeco));if(!g&&c.update(e,n,r,i))return this.destroyBetween(this.index,o),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(c,e,n,r,i,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=xh,f.updateChildren(i,a+1),f.dirty=oo),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)||!Ww(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let o=td.create(this.top,n,r,i,s,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let c of o.children)c.parent=o}return e.destroy(),o}addNode(e,n,r,i,s){let a=td.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 rJ(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 lf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof QE)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ps||ps)&&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 iJ(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 pBe(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 lf)n=u,r=u.children.length;else{o=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=o.node;if(c){if(c!=t.child(i-1))break;--i,s.set(o,i),a.push(o)}}return{index:i,matched:s,matches:a.reverse()}}function mBe(t,e){return t.type.side-e.type.side}function gBe(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=[],c=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(mBe);for(let v=0;v<f.length;v++)n(f[v],u,!!c)}else n(d,u,!!c);let g,m;if(c)m=-1,g=c,c=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&&(c=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 xBe(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 bBe(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 c=a.text;for(;i<t.childCount;){let u=t.child(i++);if(s+=u.nodeSize,!u.isText)break;c+=u.text}if(s>=n){if(s>=r&&c.slice(r-e.length-o,r-o)==e)return r-e.length;let u=o<r?c.lastIndexOf(e,r-o-1):-1;if(u>=0&&u+e.length+o>=n)return o+u;if(n==r&&c.length>=r+e.length-o&&c.slice(r-o,r-o+e.length)==e)return r}}return-1}function YP(t,e,n,r,i){let s=[];for(let a=0,o=0;a<t.length;a++){let c=t[a],u=o,d=o+=c.size;u>=n||d<=e?s.push(c):(u<e&&s.push(c.slice(0,e-u,r)),i&&(s.push(i),i=void 0),d>n&&s.push(c.slice(n-u,c.size,r)))}return s}function Pj(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),c,u;if(ZE(n)){for(c=a;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Ht.isSelectable(f)&&i.parent&&!(f.isInline&&Vze(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;[c,a]=g==t.state.selection.anchor?[g,f]:[f,g],o=r.resolve(a)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;u=Rj(t,d,o,f)}return u}function lJ(t){return t.editable?t.hasFocus():uJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ac(t,e=!1){let n=t.state.selection;if(cJ(t,n),!!lJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ps){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&of(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)yBe(t);else{let{anchor:r,head:i}=n,s,a;i9&&!(n instanceof Kt)&&(n.$from.parent.inlineContent||(s=s9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(a=s9(t,n.to))),t.docView.setSelection(r,i,t,e),i9&&(s&&a9(s),a&&a9(a)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&vBe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const i9=Ps||ps&&YQ<63;function s9(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(Ps&&i&&i.contentEditable=="false")return BN(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return BN(i);if(s)return BN(s)}}function BN(t){return t.contentEditable="true",Ps&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function a9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function vBe(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(()=>{(!lJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function yBe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,es(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Zs&&ed<=11&&(n.disabled=!0,n.disabled=!1)}function cJ(t,e){if(e instanceof Ht){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(o9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else o9(t)}function o9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Rj(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Kt.between(e,n,r)}function l9(t){return t.editable&&!t.hasFocus()?!1:uJ(t)}function uJ(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 _Be(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return of(e.node,e.offset,n.anchorNode,n.anchorOffset)}function ZP(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&&un.findFrom(s,e)}function Pu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function c9(t,e,n){let r=t.state.selection;if(r instanceof Kt)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 Pu(t,new Kt(r.$anchor,a))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=ZP(t.state,e);return i&&i instanceof Ht?Pu(t,i):!1}else if(!(Ka&&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)?Pu(t,new Ht(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Zb?Pu(t,new Kt(t.state.doc.resolve(e<0?o:o+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ht&&r.node.isInline)return Pu(t,new Kt(e>0?r.$to:r.$from));{let i=ZP(t.state,e);return i?Pu(t,i):!1}}}function qw(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function r0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function jp(t,e){return e<0?wBe(t):SBe(t)}function wBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,a=!1;for(ao&&n.nodeType==1&&r<qw(n)&&r0(n.childNodes[r],-1)&&(a=!0);;)if(r>0){if(n.nodeType!=1)break;{let o=n.childNodes[r-1];if(r0(o,-1))i=n,s=--r;else if(o.nodeType==3)n=o,r=n.nodeValue.length;else break}}else{if(dJ(n))break;{let o=n.previousSibling;for(;o&&r0(o,-1);)i=n.parentNode,s=es(o),o=o.previousSibling;if(o)n=o,r=qw(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}a?QP(t,n,r):i&&QP(t,i,s)}function SBe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=qw(n),s,a;for(;;)if(r<i){if(n.nodeType!=1)break;let o=n.childNodes[r];if(r0(o,1))s=n,a=++r;else break}else{if(dJ(n))break;{let o=n.nextSibling;for(;o&&r0(o,1);)s=o.parentNode,a=es(o)+1,o=o.nextSibling;if(o)n=o,r=0,i=qw(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&QP(t,s,a)}function dJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function EBe(t,e){for(;t&&e==t.childNodes.length&&!Yb(t);)e=es(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 MBe(t,e){for(;t&&!e&&!Yb(t);)e=es(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=EBe(e,n))?(e=a,n=0):(s=MBe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(ZE(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&&Ac(t)},50)}function u9(t,e){let n=t.state.doc.resolve(e);if(!(ps||qze)&&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 d9(t,e,n){let r=t.state.selection;if(r instanceof Kt&&!r.empty||n.indexOf("s")>-1||Ka&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let a=ZP(t.state,e);if(a&&a instanceof Ht)return Pu(t,a)}if(!i.parent.inlineContent){let a=e<0?i:s,o=r instanceof Ea?un.near(a,e):un.findFrom(a,e);return o?Pu(t,o):!1}return!1}function h9(t,e){if(!(t.state.selection instanceof Kt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let 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 f9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ABe(t){if(!Ps||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;f9(t,r,"true"),setTimeout(()=>f9(t,r,"false"),20)}return!1}function TBe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function CBe(t,e){let n=e.keyCode,r=TBe(e);if(n==8||Ka&&n==72&&r=="c")return h9(t,-1)||jp(t,-1);if(n==46&&!e.shiftKey||Ka&&n==68&&r=="c")return h9(t,1)||jp(t,1);if(n==13||n==27)return!0;if(n==37||Ka&&n==66&&r=="c"){let i=n==37?u9(t,t.state.selection.from)=="ltr"?-1:1:-1;return c9(t,i,r)||jp(t,i)}else if(n==39||Ka&&n==70&&r=="c"){let i=n==39?u9(t,t.state.selection.from)=="ltr"?1:-1:1;return c9(t,i,r)||jp(t,i)}else{if(n==38||Ka&&n==80&&r=="c")return d9(t,-1,r)||jp(t,-1);if(n==40||Ka&&n==78&&r=="c")return ABe(t)||d9(t,1,r)||jp(t,1);if(r==(Ka?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Dj(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")||xf.fromSchema(t.state.schema),o=xJ(),c=o.createElement("div");c.appendChild(a.serializeFragment(r,{document:o}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=gJ[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let x=o.createElement(d[m]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.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:c,text:g,slice:e}}function hJ(t,e,n,r,i){let s=i.parent.type.spec.code,a,o;if(!n&&!e)return null;let c=!!e&&(r||s||!n);if(c){if(t.someProp("transformPastedText",g=>{e=g(e,s||r,t)}),s)return o=new kt(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=xf.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=RBe(n),Zb&&DBe(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")||e0.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!NBe.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)o=OBe(p9(o,+d[1],+d[2]),d[4]);else if(o=kt.maxOpen(kBe(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=p9(o,f,g)}return t.someProp("transformPasted",f=>{o=f(o,t,c)}),o}const NBe=/^(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 kBe(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 c=i.findWrapping(o.type),u;if(!c)return a=null;if(u=a.length&&s.length&&pJ(c,s,o,a[a.length-1],0))a[a.length-1]=u;else{a.length&&(a[a.length-1]=mJ(a[a.length-1],s.length));let d=fJ(o,c);a.push(d),i=i.matchType(d.type),s=c}}),a)return pt.from(a)}return t}function fJ(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,pt.from(t));return t}function pJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=pJ(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(fJ(n,t,i+1))))}}function mJ(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,mJ(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(pt.empty,!0);return t.copy(n.append(r))}function JP(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=JP(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 p9(t,e,n){return e<t.openStart&&(t=new kt(JP(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new kt(JP(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const gJ={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 m9=null;function xJ(){return m9||(m9=document.implementation.createHTMLDocument("title"))}let HN=null;function PBe(t){let e=window.trustedTypes;return e?(HN||(HN=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),HN.createHTML(t)):t}function RBe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=xJ().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&gJ[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=PBe(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function DBe(t){let e=t.querySelectorAll(ps?"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 OBe(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 c=n.nodes[r[o]];if(!c||c.hasRequiredAttrs())break;i=pt.from(c.create(r[o+1],i)),s++,a++}return new kt(i,s,a)}const Rs={},Ds={},jBe={touchstart:!0,touchmove:!0};class LBe{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 IBe(t){for(let e in Rs){let n=Rs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{FBe(t,r)&&!Oj(t,r)&&(t.editable||!(r.type in Ds))&&n(t,r)},jBe[e]?{passive:!0}:void 0)}Ps&&t.dom.addEventListener("input",()=>null),eR(t)}function Gu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function UBe(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 eR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Oj(t,r))})}function Oj(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function FBe(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 zBe(t,e){!Oj(t,e)&&Rs[e.type]&&(t.editable||!(e.type in Ds))&&Rs[e.type](t,e)}Ds.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!vJ(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(bc&&ps&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Fm&&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,dh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||CBe(t,n)?n.preventDefault():Gu(t,"key")};Ds.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ds.keypress=(t,e)=>{let n=e;if(vJ(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ka&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Kt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),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 JE(t){return{left:t.clientX,top:t.clientY}}function BBe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function jj(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 um(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 HBe(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ht.isSelectable(r)?(um(t,new Ht(n)),!0):!1}function $Be(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?(um(t,Ht.create(t.state.doc,i)),!0):!1}function VBe(t,e,n,r,i){return jj(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?$Be(t,n):HBe(t,n))}function GBe(t,e,n,r){return jj(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function WBe(t,e,n,r){return jj(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||qBe(t,n,r)}function qBe(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(um(t,Kt.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)um(t,Kt.create(r,o+1,o+1+a.content.size));else if(Ht.isSelectable(a))um(t,Ht.create(r,o));else continue;return!0}}function Lj(t){return Kw(t)}const bJ=Ka?"metaKey":"ctrlKey";Rs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Lj(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&BBe(n,t.input.lastClick)&&!n[bJ]&&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(JE(n));a&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new KBe(t,a,n,!!r)):(s=="doubleClick"?GBe:WBe)(t,a.pos,a.inside,n)?n.preventDefault():Gu(t,"pointer"))};class KBe{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[bJ],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,c=o?e.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&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&&ao&&!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)),Gu(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(()=>Ac(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(JE(e))),this.updateAllowDefault(e),this.allowDefault||!n?Gu(this.view,"pointer"):VBe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ps&&this.mightDrag&&!this.mightDrag.node.isAtom||ps&&!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)?(um(this.view,un.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Gu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Gu(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)}}Rs.touchstart=t=>{t.input.lastTouch=Date.now(),Lj(t),Gu(t,"pointer")};Rs.touchmove=t=>{t.input.lastTouch=Date.now(),Gu(t,"pointer")};Rs.contextmenu=t=>Lj(t);function vJ(t,e){return t.composing?!0:Ps&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const XBe=bc?5e3:-1;Ds.compositionstart=Ds.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Kt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Kw(t,!0),t.markCursor=null;else if(Kw(t,!e.selection.empty),ao&&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}yJ(t,XBe)};Ds.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++,yJ(t,20))};function yJ(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Kw(t),e))}function _J(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=ZBe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function YBe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Hze(e.focusNode,e.focusOffset),r=$ze(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 Kw(t,e=!1){if(!(bc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),_J(t),e||t.docView&&t.docView.dirty){let n=Pj(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 QBe(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 rb=Zs&&ed<15||Fm&&Kze<604;Rs.copy=Ds.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=rb?null:n.clipboardData,a=r.content(),{dom:o,text:c}=Dj(t,a);s?(n.preventDefault(),s.clearData(),s.setData("text/html",o.innerHTML),s.setData("text/plain",c)):QBe(t,o),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function JBe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function e6e(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?ib(t,r.value,null,i,e):ib(t,r.textContent,r.innerHTML,i,e)},50)}function ib(t,e,n,r,i){let s=hJ(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,s||kt.empty)))return!0;if(!s)return!1;let a=JBe(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 wJ(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," "):""}Ds.paste=(t,e)=>{let n=e;if(t.composing&&!bc)return;let r=rb?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ib(t,wJ(r),r.getData("text/html"),i,n)?n.preventDefault():e6e(t,n)};class SJ{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const t6e=Ka?"altKey":"ctrlKey";function EJ(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[t6e]}Rs.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(JE(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:c,text:u,slice:d}=Dj(t,o);(!n.dataTransfer.files.length||!ps||YQ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(rb?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",rb||n.dataTransfer.setData("text/plain",u),t.dragging=new SJ(d,EJ(t,n),a)};Rs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ds.dragover=Ds.dragenter=(t,e)=>e.preventDefault();Ds.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(JE(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=hJ(t,wJ(n.dataTransfer),rb?null:n.dataTransfer.getData("text/html"),!1,s);let o=!!(r&&EJ(t,n));if(t.someProp("handleDrop",x=>x(t,n,a||kt.empty,o))){n.preventDefault();return}if(!a)return;n.preventDefault();let c=a?NQ(t.state.doc,s.pos,a):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(o){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=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(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,v,b,E)=>x=E),u.setSelection(Rj(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Rs.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())&&Ac(t)},20))};Rs.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)};Rs.beforeinput=(t,e)=>{if(ps&&bc&&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,dh(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 Ds)Rs[t]=Ds[t];function sb(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Xw{constructor(e,n){this.toDOM=e,this.spec=n||Oh,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 As(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xw&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&sb(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nd{constructor(e,n){this.attrs=e,this.spec=n||Oh}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 As(s,a,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof nd&&sb(this.attrs,e.attrs)&&sb(this.spec,e.spec)}static is(e){return e.type instanceof nd}destroy(){}}class Ij{constructor(e,n){this.attrs=e,this.spec=n||Oh}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 As(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 Ij&&sb(this.attrs,e.attrs)&&sb(this.spec,e.spec)}destroy(){}}class As{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new As(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 As(e,e,new Xw(n,r))}static inline(e,n,r,i){return new As(e,n,new nd(r,i))}static node(e,n,r,i){return new As(e,n,new Ij(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof nd}get widget(){return this.type instanceof Xw}}const Bp=[],Oh={};class vr{constructor(e,n){this.local=e.length?e:Bp,this.children=n.length?n:Bp}static create(e,n){return n.length?Yw(n,e,0,Oh):hs}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==hs||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Oh)}mapInner(e,n,r,i,s){let a;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(e,r,i);c&&c.type.valid(n,c)?(a||(a=[])).push(c):s.onRemove&&s.onRemove(this.local[o].spec)}return this.children.length?n6e(this.children,a||[],e,n,r,i,s):a?new vr(a.sort(jh),Bp):hs}add(e,n){return n.length?this==hs?vr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((o,c)=>{let u=c+r,d;if(d=AJ(n,o,u)){for(i||(i=this.children.slice());s<i.length&&i[s]<c;)s+=3;i[s]==c?i[s+2]=i[s+2].addInner(o,d,u+1):i.splice(s,0,c,c+o.nodeSize,Yw(d,o,u+1,Oh)),s+=3}});let a=MJ(s?TJ(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(jh):this.local,i||this.children)}remove(e){return e.length==0||this==hs?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,c=r[s+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>o&&f.to<c&&(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!=hs?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):hs}forChild(e,n){if(this==hs)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 c=this.local[o];if(c.from<a&&c.to>s&&c.type instanceof nd){let u=Math.max(s,c.from)-s,d=Math.min(a,c.to)-s;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let o=new vr(i.sort(jh),Bp);return r?new Iu([o,r]):o}return r||hs}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 Uj(this.localsInner(e))}localsInner(e){if(this==hs)return Bp;if(e.inlineContent||!this.local.some(nd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof nd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}vr.empty=new vr([],[]);vr.removeOverlap=Uj;const hs=vr.empty;class Iu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Oh));return Iu.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!=hs&&(s instanceof Iu?r=r.concat(s.members):r.push(s))}return Iu.from(r)}eq(e){if(!(e instanceof Iu)||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?Uj(r?n:n.sort(jh)):Bp}static from(e){switch(e.length){case 0:return hs;case 1:return e[0];default:return new Iu(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 n6e(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 c=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){c=!0,o[u+1]=-1;continue}let d=n.map(t[u]+s),f=d-i;if(f<0||f>=r.content.size){c=!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!=hs?(o[u]=f,o[u+1]=m,o[u+2]=b):(o[u+1]=-2,c=!0)}else c=!0}if(c){let u=r6e(o,t,e,n,i,s,a),d=Yw(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(jh),o)}function MJ(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 As(i.from+e,i.to+e,i.type))}return n}function r6e(t,e,n,r,i,s,a){function o(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):a.onRemove&&a.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)o(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&o(t[c+2],e[c]+s+1);return n}function AJ(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 TJ(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Yw(t,e,n,r){let i=[],s=!1;e.forEach((o,c)=>{let u=AJ(t,o,c+n);if(u){s=!0;let d=Yw(u,o,n+c+1,r);d!=hs&&i.push(c,c+o.nodeSize,d)}});let a=MJ(s?TJ(t):t,-n).sort(jh);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):hs}function jh(t,e){return t.from-e.from||t.to-e.to}function Uj(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),g9(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),g9(e,i,r.copy(s.from,r.to)));break}}}return e}function g9(t,e,n){for(;e<t.length&&jh(n,t[e])>0;)e++;t.splice(e,0,n)}function $N(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=hs&&e.push(r)}),t.cursorWrapper&&e.push(vr.create(t.state.doc,[t.cursorWrapper.deco])),Iu.from(e)}const i6e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},s6e=Zs&&ed<=11;class a6e{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 o6e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new a6e,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]);Zs&&ed<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),s6e&&(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,i6e)),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(l9(this.view)){if(this.suppressingSelectionUpdates)return Ac(this.view);if(Zs&&ed<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&of(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=Um(s))n.add(s);for(let s=e.anchorNode;s;s=Um(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)&&l9(e)&&!this.ignoreSelectionChange(r),s=-1,a=-1,o=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);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(ao&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let m=g.parentNode;m&&m.nodeName=="LI"&&(!f||u6e(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&&ZE(r)&&(u=Pj(e))&&u.eq(un.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ac(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),l6e(e)),this.handleDOMChange(s,a,o,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ac(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(Zs&&ed<=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?es(i)+1:0,o=r.localPosFromDOM(e.target,a,-1),c=s&&s.parentNode==e.target?es(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:o,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let x9=new WeakMap,b9=!1;function l6e(t){if(!x9.has(t)&&(x9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ao,b9)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."),b9=!0}}function v9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return of(a.node,a.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function c6e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return v9(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?v9(t,n):null}function u6e(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 d6e(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:a,to:o}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],ZE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ps&&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")||e0.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:h6e,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 h6e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ps&&/^(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||Ps&&/^(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 f6e=/^(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 p6e(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=Pj(t,N);if(I&&!t.state.selection.eq(I)){if(ps&&bc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,dh(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 c=t.state.selection,u=d6e(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=x6e(f.content,u.doc.content,u.from,g,m);if(x&&t.input.domChangeCount++,(Fm&&t.input.lastIOSEnter>Date.now()-225||bc)&&i.some(N=>N.nodeType==1&&!f6e.test(N.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",N=>N(t,dh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof Kt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let N=y9(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 Kt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Zs&&ed<=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((Fm&&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,dh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&g6e(d,x.start,x.endA,y,v)&&t.someProp("handleKeyDown",N=>N(t,dh(8,"Backspace")))){bc&&ps&&t.domObserver.suppressSelectionUpdates();return}ps&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),bc&&!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,dh(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=y9(t,I.doc,u.sel);C&&!(ps&&t.composing&&C.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==S||C.head==I.mapping.map(A)-1)||Zs&&C.empty&&C.head==S)&&I.setSelection(C)}return s&&I.setMeta("composition",s),I.scrollIntoView()},k;if(E)if(y.pos==v.pos){Zs&&ed<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ac(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=m6e(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 y9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Rj(t,e.resolve(n.anchor),e.resolve(n.head))}function m6e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,a,o,c;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",c=d=>d.mark(o.addToSet(d.marks));else if(i.length==0&&s.length==1)o=s[0],a="remove",c=d=>d.mark(o.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(pt.from(u).eq(t))return{mark:o,type:a}}function g6e(t,e,n,r,i){if(n-e<=i.pos-r.pos||VN(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(VN(s,!0,!0));return!a.parent.isTextblock||a.pos>n||VN(a,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(a.parent.content)}function VN(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 x6e(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 c=Math.max(0,s-Math.min(a,o));r-=a+c-s}if(a<s&&t.size<e.size){let c=r<=s&&r>=a?s-r:0;s-=c,s&&s<e.size&&_9(e.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-a),a=s}else if(o<s){let c=r<=s&&r>=o?s-r:0;s-=c,s&&s<t.size&&_9(t.textBetween(s-1,s+1))&&(s+=c?1:-1),a=s+(a-o),o=s}return{start:s,endA:a,endB:o}}function _9(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 CJ{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 LBe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(A9),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=E9(this),S9(this),this.nodeViews=M9(this),this.docView=n9(this.state.doc,w9(this),$N(this),this.dom,this),this.domObserver=new o6e(this,(r,i,s,a)=>p6e(this,r,i,s,a)),this.domObserver.start(),IBe(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&&eR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(A9),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&&(_J(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=M9(this);v6e(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&eR(this),this.editable=E9(this),S9(this);let c=$N(this),u=w9(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,c);(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&&(Zs||ps)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&b6e(i.selection,e.selection);if(f){let x=ps?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=YBe(this)),(s||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=n9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_Be(this))?Ac(this,m):(cJ(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&&Qze(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&&YV(this,n.getBoundingClientRect(),e)}else YV(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 SJ(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(Zs){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&&Jze(this.dom),Ac(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 iBe(this,e)}coordsAtPos(e,n=1){return tJ(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 cBe(this,n||this.state,e)}pasteHTML(e,n){return ib(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ib(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Dj(this,e)}destroy(){this.docView&&(UBe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$N(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,zze())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return zBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ps&&this.root.nodeType===11&&Gze(this.dom.ownerDocument)==this.dom&&c6e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}CJ.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function w9(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"),[As.node(0,t.state.doc.content.size,e)]}function S9(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:As.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function E9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function b6e(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 M9(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 v6e(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 A9(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 md={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:"'"},Zw={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},y6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),_6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ts=0;ts<10;ts++)md[48+ts]=md[96+ts]=String(ts);for(var ts=1;ts<=24;ts++)md[ts+111]="F"+ts;for(var ts=65;ts<=90;ts++)md[ts]=String.fromCharCode(ts+32),Zw[ts]=String.fromCharCode(ts);for(var GN in md)Zw.hasOwnProperty(GN)||(Zw[GN]=md[GN]);function w6e(t){var e=y6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||_6e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Zw:md)[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 S6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),E6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function M6e(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 c=e[o];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))S6e?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),a&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function A6e(t){let e=Object.create(null);for(let n in t)e[M6e(n)]=t[n];return e}function WN(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 T6e(t){return new Mr({props:{handleKeyDown:NJ(t)}})}function NJ(t){let e=A6e(t);return function(n,r){let i=w6e(r),s,a=e[WN(i,r)];if(a&&a(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let o=e[WN(i,r,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(E6e&&r.ctrlKey&&r.altKey)&&(s=md[r.keyCode])&&s!=i){let o=e[WN(s,r)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var C6e=Object.defineProperty,Fj=(t,e)=>{for(var n in e)C6e(t,n,{get:e[n],enumerable:!0})};function eM(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 tM=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,c=t||i.tr,u=()=>(!o&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),a.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const y=this.buildProps(c,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,c])=>[o,(...u)=>c(...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:eM({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,c])=>[o,(...u)=>c(...u)(a)]))}};return a}},kJ={};Fj(kJ,{blur:()=>N6e,clearContent:()=>k6e,clearNodes:()=>P6e,command:()=>R6e,createParagraphNear:()=>D6e,cut:()=>O6e,deleteCurrentNode:()=>j6e,deleteNode:()=>L6e,deleteRange:()=>I6e,deleteSelection:()=>U6e,enter:()=>F6e,exitCode:()=>z6e,extendMarkRange:()=>B6e,first:()=>H6e,focus:()=>V6e,forEach:()=>G6e,insertContent:()=>W6e,insertContentAt:()=>X6e,joinBackward:()=>Q6e,joinDown:()=>Z6e,joinForward:()=>J6e,joinItemBackward:()=>e8e,joinItemForward:()=>t8e,joinTextblockBackward:()=>n8e,joinTextblockForward:()=>r8e,joinUp:()=>Y6e,keyboardShortcut:()=>s8e,lift:()=>a8e,liftEmptyBlock:()=>o8e,liftListItem:()=>l8e,newlineInCode:()=>c8e,resetAttributes:()=>u8e,scrollIntoView:()=>d8e,selectAll:()=>h8e,selectNodeBackward:()=>f8e,selectNodeForward:()=>p8e,selectParentNode:()=>m8e,selectTextblockEnd:()=>g8e,selectTextblockStart:()=>x8e,setContent:()=>b8e,setMark:()=>L8e,setMeta:()=>I8e,setNode:()=>U8e,setNodeSelection:()=>F8e,setTextDirection:()=>z8e,setTextSelection:()=>B8e,sinkListItem:()=>H8e,splitBlock:()=>$8e,splitListItem:()=>V8e,toggleList:()=>G8e,toggleMark:()=>W8e,toggleNode:()=>q8e,toggleWrap:()=>K8e,undoInputRule:()=>X8e,unsetAllMarks:()=>Y8e,unsetMark:()=>Z8e,unsetTextDirection:()=>Q8e,updateAttributes:()=>J8e,wrapIn:()=>eHe,wrapInList:()=>tHe});var N6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),k6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),P6e=()=>({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,c)=>{if(o.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+o.nodeSize)),m=f.blockRange(g);if(!m)return;const x=hg(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},R6e=t=>e=>t(e),D6e=()=>({state:t,dispatch:e})=>GQ(t,e),O6e=(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 Kt(r.doc.resolve(Math.max(a-1,0)))),!0},j6e=()=>({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),c=i.after(s);t.delete(o,c).scrollIntoView()}return!0}return!1};function ii(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 L6e=t=>({tr:e,state:n,dispatch:r})=>{const i=ii(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 c=s.before(a),u=s.after(a);e.delete(c,u).scrollIntoView()}return!0}return!1},I6e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},U6e=()=>({state:t,dispatch:e})=>Mj(t,e),F6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),z6e=()=>({state:t,dispatch:e})=>Mze(t,e);function zj(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Qw(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:zj(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function PJ(t,e,n={}){return t.find(r=>r.type===e&&Qw(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function T9(t,e,n={}){return!!PJ(t,e,n)}function Bj(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),!PJ([...i.node.marks],e,n)))return;let a=i.index,o=t.start()+i.offset,c=a+1,u=o+i.node.nodeSize;for(;a>0&&T9([...t.parent.child(a-1).marks],e,n);)a-=1,o-=t.parent.child(a).nodeSize;for(;c<t.parent.childCount&&T9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:o,to:u}}function Bc(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 B6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Bc(t,r.schema),{doc:a,selection:o}=n,{$from:c,from:u,to:d}=o;if(i){const f=Bj(c,s,e);if(f&&f.from<=u&&f.to>=d){const g=Kt.create(a,f.from,f.to);n.setSelection(g)}}return!0},H6e=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 RJ(t){return t instanceof Kt}function vh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function DJ(t,e=null){if(!e)return null;const n=un.atStart(t),r=un.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?Kt.create(t,vh(0,i,s),vh(t.content.size,i,s)):Kt.create(t,vh(e,i,s),vh(e,i,s))}function $6e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Hj(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var V6e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const a=()=>{(Hj()||$6e())&&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&&!RJ(n.state.selection))return a(),!0;const o=DJ(i.doc,t)||n.state.selection,c=n.state.selection.eq(o);return s&&(c||i.setSelection(o),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),a()),!0},G6e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),W6e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),OJ=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&&OJ(r)}return t};function U_(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 OJ(n)}function ab(t,e,n){if(t instanceof Ju||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),ab("",e,n)}if(i){if(n.errorOnInvalidContent){let a=!1,o="";const c=new bQ({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?e0.fromSchema(c).parseSlice(U_(t),n.parseOptions):e0.fromSchema(c).parse(U_(t),n.parseOptions),n.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const s=e0.fromSchema(e);return n.slice?s.parseSlice(U_(t),n.parseOptions).content:s.parse(U_(t),n.parseOptions)}return ab("",e,n)}function q6e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ji||i instanceof Ii))return;const s=t.mapping.maps[r];let a=0;s.forEach((o,c,u,d)=>{a===0&&(a=d)}),t.setSelection(un.near(t.doc.resolve(a),n))}var K6e=t=>!("type"in t),X6e=(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 c=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{ab(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(v){c(v)}try{o=ab(e,s.schema,{parseOptions:u,errorOnInvalidContent:(a=n.errorOnInvalidContent)!=null?a:s.options.enableContentCheck})}catch(v){return c(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((K6e(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&&q6e(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},Y6e=()=>({state:t,dispatch:e})=>wze(t,e),Z6e=()=>({state:t,dispatch:e})=>Sze(t,e),Q6e=()=>({state:t,dispatch:e})=>UQ(t,e),J6e=()=>({state:t,dispatch:e})=>HQ(t,e),e8e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=KE(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},t8e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=KE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},n8e=()=>({state:t,dispatch:e})=>yze(t,e),r8e=()=>({state:t,dispatch:e})=>_ze(t,e);function jJ(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function i8e(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 c=e[o];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))Hj()||jJ()?a=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),a&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var s8e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=i8e(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}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,o))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function gd(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,a=e?ii(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 c=i-r,u=o.filter(f=>a?a.name===f.node.type.name:!0).filter(f=>Qw(f.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var a8e=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?Eze(n,r):!1},o8e=()=>({state:t,dispatch:e})=>WQ(t,e),l8e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Lze(r)(e,n)},c8e=()=>({state:t,dispatch:e})=>VQ(t,e);function nM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function C9(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 u8e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=nM(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=ii(t,r.schema)),o==="mark"&&(a=Bc(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{s&&s===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,C9(d.attrs,e))),a&&d.marks.length&&d.marks.forEach(g=>{a===g.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,a.create(C9(g.attrs,e))))})})}),c},d8e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),h8e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ea(t.doc);t.setSelection(n)}return!0},f8e=()=>({state:t,dispatch:e})=>zQ(t,e),p8e=()=>({state:t,dispatch:e})=>$Q(t,e),m8e=()=>({state:t,dispatch:e})=>Cze(t,e),g8e=()=>({state:t,dispatch:e})=>Pze(t,e),x8e=()=>({state:t,dispatch:e})=>kze(t,e);function tR(t,e,n={},r={}){return ab(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var b8e=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:a,commands:o})=>{const{doc:c}=s;if(r.preserveWhitespace!=="full"){const u=tR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return a&&s.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return a&&s.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function LJ(t,e){const n=Bc(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,c=>{a.push(...c.marks)});const o=a.find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function IJ(t,e){const n=new OQ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function v8e(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 y8e(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function _8e(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 rM(t){return e=>_8e(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 $j(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Bt(e,"addExtensions",n);return r?[e,...$j(r())]:e}).flat(10)}function Vj(t,e){const n=xf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function UJ(t){return typeof t=="function"}function Fn(t,e=void 0,...n){return UJ(t)?e?t.bind(e)(...n):t(...n):t}function w8e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function zm(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 FJ(t){const e=[],{nodeExtensions:n,markExtensions:r}=zm(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},c=Bt(a,"addGlobalAttributes",o);if(!c)return;c().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},c=Bt(a,"addAttributes",o);if(!c)return;const u=c();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 Dr(...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(" "):[],c=r[i]?r[i].split(" "):[],u=o.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const o=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,g]=d.split(":").map(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 Jw(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)=>Dr(n,r),{})}function S8e(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function N9(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):S8e(n.getAttribute(a.name));return o==null?s:{...s,[a.name]:o}},{});return{...r,...i}}}}function k9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&w8e(n)?!1:n!=null))}function P9(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 E8e(t,e){var n;const r=FJ(t),{nodeExtensions:i,markExtensions:s}=zm(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=k9({...g,content:Fn(Bt(u,"content",f)),marks:Fn(Bt(u,"marks",f)),group:Fn(Bt(u,"group",f)),inline:Fn(Bt(u,"inline",f)),atom:Fn(Bt(u,"atom",f)),selectable:Fn(Bt(u,"selectable",f)),draggable:Fn(Bt(u,"draggable",f)),code:Fn(Bt(u,"code",f)),whitespace:Fn(Bt(u,"whitespace",f)),linebreakReplacement:Fn(Bt(u,"linebreakReplacement",f)),defining:Fn(Bt(u,"defining",f)),isolating:Fn(Bt(u,"isolating",f)),attrs:Object.fromEntries(d.map(P9))}),x=Fn(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(b=>N9(b,d)));const y=Bt(u,"renderHTML",f);y&&(m.toDOM=b=>y({node:b,HTMLAttributes:Jw(b,d)}));const v=Bt(u,"renderText",f);return v&&(m.toText=v),[u.name,m]})),c=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=k9({...g,inclusive:Fn(Bt(u,"inclusive",f)),excludes:Fn(Bt(u,"excludes",f)),group:Fn(Bt(u,"group",f)),spanning:Fn(Bt(u,"spanning",f)),code:Fn(Bt(u,"code",f)),attrs:Object.fromEntries(d.map(P9))}),x=Fn(Bt(u,"parseHTML",f));x&&(m.parseDOM=x.map(v=>N9(v,d)));const y=Bt(u,"renderHTML",f);return y&&(m.toDOM=v=>y({mark:v,HTMLAttributes:Jw(v,d)})),[u.name,m]}));return new bQ({topNode:a,nodes:o,marks:c})}function M8e(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Gj(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 zJ(t){const e=Gj($j(t)),n=M8e(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 BJ(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
- `,textSerializers:a={}}=n||{};let o="";return t.nodesBetween(r,i,(c,u,d,f)=>{var g;c.isBlock&&u>r&&(o+=s);const m=a?.[c.type.name];if(m)return d&&(o+=m({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(o+=(g=c?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),o}function A8e(t,e){const n={from:0,to:t.content.size};return BJ(t,n,e)}function HJ(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function T8e(t,e){const n=ii(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 $J(t,e){const n=nM(typeof e=="string"?e:e.name,t.schema);return n==="node"?T8e(t,e):n==="mark"?LJ(t,e):{}}function C8e(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 N8e(t){const e=C8e(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 VJ(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const a=[];if(i.ranges.length)i.forEach((o,c)=>{a.push({from:o,to:c})});else{const{from:o,to:c}=n[s];if(o===void 0||c===void 0)return;a.push({from:o,to:c})}a.forEach(({from:o,to:c})=>{const u=e.slice(s).map(o,-1),d=e.slice(s).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),N8e(r)}function Wj(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),a=Bj(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 k8e=(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 qN(t,e){return e.nodes[t]||e.marks[t]||null}function x1(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 P8e=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,a,o)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{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 nR(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Bc(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>Qw(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 c=o.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>Qw(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(c>0?c+u:c)>=a}function R8e(t,e,n={}){if(!e)return gd(t,null,n)||nR(t,null,n);const r=nM(e,t.schema);return r==="node"?gd(t,e,n):r==="mark"?nR(t,e,n):!1}var D8e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=rM(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)},O8e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function R9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function D9(t,e){const{nodeExtensions:n}=zm(e),r=n.find(a=>a.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=Fn(Bt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function iM(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&&(iM(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function GJ(t){return t instanceof Ht}function j8e(t,e,n){var r;const{selection:i}=e;let s=null;if(RJ(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:c})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const 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 L8e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:a,ranges:o}=s,c=Bc(t,r.schema);if(i)if(a){const u=LJ(r,c);n.addStoredMark(c.create({...u,...e}))}else o.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,m)=>{const x=Math.max(m,d),y=Math.min(m+g.nodeSize,f);g.marks.find(b=>b.type===c)?g.marks.forEach(b=>{c===b.type&&n.addMark(x,y,c.create({...b.attrs,...e}))}):n.addMark(x,y,c.create(e))})});return j8e(r,n,c)},I8e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),U8e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=ii(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})=>qV(s,{...a,...e})(n)?!0:o.clearNodes()).command(({state:o})=>qV(s,{...a,...e})(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},F8e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=vh(t,0,r.content.size),s=Ht.create(r,i);e.setSelection(s)}return!0},z8e=(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,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},B8e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,a=Kt.atStart(r).from,o=Kt.atEnd(r).to,c=vh(i,a,o),u=vh(s,a,o),d=Kt.create(r,c,u);e.setSelection(d)}return!0},H8e=t=>({state:e,dispatch:n})=>{const r=ii(t,e.schema);return Fze(r)(e,n)};function O9(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 $8e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:a}=e,{$from:o,$to:c}=s,u=i.extensionManager.attributes,d=x1(u,o.node().type.name,o.node().attrs);if(s instanceof Ht&&s.node.isBlock)return!o.parentOffset||!Mc(a,o.pos)?!1:(r&&(t&&O9(n,i.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=o.depth===0?void 0:v8e(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=f&&g?[{type:g,attrs:d}]:void 0,x=Mc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!x&&Mc(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 Kt&&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&&O9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},V8e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var a;const o=ii(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==o)return!1;const g=s.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let b=pt.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let I=c.depth-E;I>=c.depth-3;I-=1)b=pt.from(c.node(I).copy(b));const S=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...x1(g,c.node().type.name,c.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=c.before(c.depth-(E-1));n.replace(k,c.after(-S),new kt(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(Kt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...x1(g,f.type.name,f.attrs),...e},y={...x1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const v=m?[{type:o,attrs:x},{type:m,attrs:y}]:[{type:o,attrs:x}];if(!Mc(n.doc,c.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(c.pos,2,v).scrollIntoView(),!A||!i)return!0;const T=A.filter(k=>S.includes(k.type.name));n.ensureMarks(T)}return!0},KN=(t,e)=>{const n=rM(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&&Sd(t.doc,n.pos)&&t.join(n.pos),!0},XN=(t,e)=>{const n=rM(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&&Sd(t.doc,r)&&t.join(r),!0},G8e=(t,e,n,r={})=>({editor:i,tr:s,state:a,dispatch:o,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,m=ii(t,a.schema),x=ii(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=rM(k=>D9(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(D9(T.node.type.name,f)&&m.validContent(T.node.content)&&o)return c().command(()=>(s.setNodeMarkup(T.pos,m),!0)).command(()=>KN(s,m)).command(()=>XN(s,m)).run()}return!n||!A||!o?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>KN(s,m)).command(()=>XN(s,m)).run():c().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(()=>KN(s,m)).command(()=>XN(s,m)).run()},W8e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,a=Bc(t,r.schema);return nR(r,a,e)?i.unsetMark(a,{extendEmptyMarkRange:s}):i.setMark(a,e)},q8e=(t,e,n={})=>({state:r,commands:i})=>{const s=ii(t,r.schema),a=ii(e,r.schema),o=gd(r,s,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),o?i.setNode(a,c):i.setNode(s,{...c,...n})},K8e=(t,e={})=>({state:n,commands:r})=>{const i=ii(t,n.schema);return gd(n,i,e)?r.lift(i):r.wrapIn(i,e)},X8e=()=>({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 c=o.steps.length-1;c>=0;c-=1)a.step(o.steps[c].invert(o.docs[c]));if(s.text){const c=a.doc.resolve(s.from).marks();a.replaceWith(s.from,s.to,t.schema.text(s.text,c))}else a.delete(s.from,s.to)}return!0}}return!1},Y8e=()=>({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,c=Bc(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===c))==null?void 0:s.attrs,y=Bj(u,c,x);y&&(g=y.from,m=y.to),n.removeMark(g,m,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},Q8e=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,c)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},J8e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,a=null;const o=nM(typeof t=="string"?t:t.name,r.schema);if(!o)return!1;o==="node"&&(s=ii(t,r.schema)),o==="mark"&&(a=Bc(t,r.schema));let c=!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&&(c=!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&&(c=!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&&(c=!0,i&&n.setNodeMarkup(b,void 0,{...v.attrs,...e})),a&&v.marks.length&&v.marks.forEach(E=>{if(a===E.type&&(c=!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}))}))}),c},eHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return Rze(i,e)(n,r)},tHe=(t,e={})=>({state:n,dispatch:r})=>{const i=ii(t,n.schema);return Dze(i,e)(n,r)},nHe=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={}}},sM=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},rHe=(t,e)=>{if(zj(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 F_(t){var e;const{editor:n,from:r,to:i,text:s,rules:a,plugin:o}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=P8e(u)+s;return a.forEach(g=>{if(d)return;const m=rHe(f,g.find);if(!m)return;const x=c.state.tr,y=eM({state:c.state,transaction:x}),v={from:r-(m[0].length-s.length),to:i},{commands:b,chain:E,can:S}=new tM({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}),c.dispatch(x),d=!0)}),d}function iHe(t){const{editor:e,rules:n}=t,r=new Mr({state:{init(){return null},apply(i,s,a){const o=i.getMeta(r);if(o)return o;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=Vj(pt.from(d),a.schema);const{from:f}=c,g=f+d.length;F_({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 F_({editor:e,from:s,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&F_({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?F_({editor:e,from:a.pos,to:a.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function sHe(t){return Object.prototype.toString.call(t).slice(8,-1)}function z_(t){return sHe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function WJ(t,e){const n={...t};return z_(t)&&z_(e)&&Object.keys(e).forEach(r=>{z_(e[r])&&z_(t[r])?n[r]=WJ(t[r],e[r]):n[r]=e[r]}),n}var qj=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{...Fn(Bt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Fn(Bt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>WJ(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}},Md=class qJ extends qj{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new qJ(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 c=a.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function aHe(t){return typeof t=="number"}var oHe=class{constructor(t){this.find=t.find,this.handler=t.handler}},lHe=(t,e,n)=>{if(zj(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 cHe(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:a,dropEvent:o}=t,{commands:c,chain:u,can:d}=new tM({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,"");lHe(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:c,chain:u,can:d,pasteEvent:a,dropEvent:o});f.push(q)})}),f.every(m=>m!==null)}var B_=null,uHe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function dHe(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 c=({state:d,from:f,to:g,rule:m,pasteEvt:x})=>{const y=d.tr,v=eM({state:d,transaction:y});if(!(!cHe({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 Mr({view(f){const g=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(B_=e)},m=()=>{B_&&(B_=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=B_;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=Vj(pt.from(T),m.schema);const{from:k}=b,N=k+T.length,I=uHe(T);return c({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(!(!aHe(S)||!A||S===A.b))return c({rule:d,state:m,from:S,to:A,pasteEvt:a})}}))}var aM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=zJ(t),this.schema=E8e(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:qN(e.name,this.schema)},r=Bt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Gj([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:qN(r.name,this.schema)},s=[],a=Bt(r,"addKeyboardShortcuts",i);let o={};if(r.type==="mark"&&Bt(r,"exitable",i)&&(o.ArrowRight=()=>Md.handleExit({editor:t,mark:r})),a){const g=Object.fromEntries(Object.entries(a()).map(([m,x])=>[m,()=>x({editor:t})]));o={...o,...g}}const c=T6e(o);s.push(c);const u=Bt(r,"addInputRules",i);if(R9(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const m=iHe({editor:t,rules:g}),x=Array.isArray(m)?m:[m];s.push(...x)}}const d=Bt(r,"addPasteRules",i);if(R9(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const m=dHe({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 FJ(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=zm(this.extensions);return Object.fromEntries(e.filter(n=>!!Bt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ii(n.name,this.schema)},s=Bt(n,"addNodeView",i);if(!s)return[];const a=s();if(!a)return[];const o=(c,u,d,f,g)=>{const m=Jw(c,r);return a({node:c,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}=zm(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:Bc(n.name,this.schema)},s=Bt(n,"addMarkView",i);if(!s)return[];const a=(o,c,u)=>{const d=Jw(o,r);return s()({mark:o,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{AHe(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:qN(e.name,this.schema)};e.type==="mark"&&((n=Fn(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),c=Bt(e,"onTransaction",r),u=Bt(e,"onFocus",r),d=Bt(e,"onBlur",r),f=Bt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),a&&this.editor.on("update",a),o&&this.editor.on("selectionUpdate",o),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};aM.resolve=zJ;aM.sort=Gj;aM.flatten=$j;var hHe={};Fj(hHe,{ClipboardTextSerializer:()=>XJ,Commands:()=>YJ,Delete:()=>ZJ,Drop:()=>QJ,Editable:()=>JJ,FocusEvents:()=>tee,Keymap:()=>nee,Paste:()=>ree,Tabindex:()=>iee,TextDirection:()=>see,focusEventsPluginKey:()=>eee});var Qn=class KJ extends qj{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new KJ(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},XJ=Qn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Mr({key:new Si("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)),c=HJ(n);return BJ(r,{from:a,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),YJ=Qn.create({name:"commands",addCommands(){return{...kJ}}}),ZJ=Qn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var a,o,c,u;if((u=(c=(o=(a=this.editor.options.coreExtensionOptions)==null?void 0:a.delete)==null?void 0:o.filterTransaction)==null?void 0:c.call(o,t))!=null?u:t.getMeta("y-sync$"))return;const d=IJ(t.before,[t,...e]);VJ(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 jo){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()}}),QJ=Qn.create({name:"drop",addProseMirrorPlugins(){return[new Mr({key:new Si("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),JJ=Qn.create({name:"editable",addProseMirrorPlugins(){return[new Mr({key:new Si("editable"),props:{editable:()=>this.editor.options.editable}})]}}),eee=new Si("focusEvents"),tee=Qn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Mr({key:eee,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}}}})]}}),nee=Qn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:o})=>{const{selection:c,doc:u}=o,{empty:d,$anchor:f}=c,{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:un.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 Hj()||jJ()?s:i},addProseMirrorPlugins(){return[new Mr({key:new Si("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,c=un.atStart(e.doc).from,u=un.atEnd(e.doc).to;if(s||!(a===c&&o===u)||!iM(n.doc))return;const g=n.tr,m=eM({state:n,transaction:g}),{commands:x}=new tM({editor:this.editor,state:m});if(x.clearNodes(),!!g.steps.length)return g}})]}}),ree=Qn.create({name:"paste",addProseMirrorPlugins(){return[new Mr({key:new Si("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),iee=Qn.create({name:"tabindex",addProseMirrorPlugins(){return[new Mr({key:new Si("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),see=Qn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=zm(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 Mr({key:new Si("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),fHe=class Hp{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 Hp(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 Hp(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 Hp(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 c=new Hp(o,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new Hp(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 c=a[o];if(s[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(a=>{r&&i.length>0||(a.node.type.name===e&&s.every(c=>n[c]===a.node.attrs[c])&&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)}},pHe=`.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 mHe(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 gHe=class extends nHe{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=DJ(e,this.options.autofocus);this.editorState=Yp.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=mHe(pHe,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=UJ(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?[JJ,XJ.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),YJ,tee,nee,iee,QJ,ree,ZJ,see.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 aM(r,this)}createCommandManager(){this.commandManager=new tM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=tR(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=tR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new CJ(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"),c=a?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:a}),c&&this.emit("blur",{editor:this,event:c.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 $J(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return R8e(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Vj(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return A8e(this.state.doc,{blockSeparator:e,textSerializers:{...HJ(this.schema),...n}})}get isEmpty(){return iM(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 fHe(e,this)}get $doc(){return this.$pos(0)}};function Bm(t){return new sM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Fn(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 c=o.search(/\S/),u=n.from+o.indexOf(a),d=u+a.length;if(Wj(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+c,u);const g=n.from+c+a.length;s.addMark(n.from+c,g,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function aee(t){return new sM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Fn(t.getAttributes,void 0,r)||{},{tr:s}=e,a=n.from;let o=n.to;const c=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,c)}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 rR(t){return new sM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=Fn(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function Hm(t){return new sM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=Fn(t.getAttributes,void 0,r)||{},a=e.tr.delete(n.from,n.to),c=a.doc.resolve(n.from).blockRange(),u=c&&Sj(c,t.type,s);if(!u)return null;if(a.wrap(c,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&&Sd(a.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&a.join(n.from-1)},undoable:t.undoable})}var xHe=t=>"touches"in t,bHe=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,c=a.clientY-this.startY;this.handleResize(o,c)},this.handleTouchMove=a=>{if(!this.isResizing||!this.activeHandle)return;const o=a.touches[0];if(!o)return;const c=o.clientX-this.startX,u=o.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const 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,xHe(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"),c=t.includes("top");return s?r=this.startWidth+e:a&&(r=this.startWidth-e),o?i=this.startHeight+n:c&&(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,c=e;return o<this.minSize.width&&(o=this.minSize.width,c=o/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,o=c*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&o>this.maxSize.width&&(o=this.maxSize.width,c=o/this.aspectRatio),(a=this.maxSize)!=null&&a.height&&c>this.maxSize.height&&(c=this.maxSize.height,o=c*this.aspectRatio),{width:o,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function vHe(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 yHe={};Fj(yHe,{createAtomBlockMarkdownSpec:()=>_He,createBlockMarkdownSpec:()=>wHe,createInlineMarkdownSpec:()=>MHe,parseAttributes:()=>Kj,parseIndentedBlocks:()=>iR,renderNestedMarkdownContent:()=>Yj,serializeAttributes:()=>Xj});function Kj(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 c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function Xj(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 _He(t){const{nodeName:e,name:n,parseAttributes:r=Kj,serializeAttributes:i=Xj,defaultAttributes:s={},requiredAttributes:a=[],allowedAttributes:o}=t,c=n||e,u=d=>{if(!o)return d;const f={};return o.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...s,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\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(`^:::${c}(?:\\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`:::${c}${m} :::`}}}function wHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Kj,serializeAttributes:s=Xj,defaultAttributes:a={},content:o="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const g={};return c.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 SHe(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 EHe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function MHe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=SHe,serializeAttributes:s=EHe,defaultAttributes:a={},selfClosing:o=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const m={};return c.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 iR(t,e,n){var r,i,s,a;const o=t.split(`
- `),c=[];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(c.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);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function Yj(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]),c=[`${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(`
- `);c.push(f)}}),c.join(`
- `)}function AHe(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,a=t;i.descendants((o,c)=>{const u=s.mapping.map(c),d=s.mapping.map(c)+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 ea=class oee extends qj{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new oee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function cf(t){return new oHe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=Fn(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:a}=e,o=r[r.length-1],c=r[0];let u=n.to;if(o){const d=c.search(/\S/),f=n.from+c.indexOf(o),g=f+o.length;if(Wj(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 YN,j9;function THe(){return j9||(j9=1,YN=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}),YN}var CHe=THe();const NHe=fo(CHe);var kHe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},PHe=({contentComponent:t})=>{const e=ER.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return l.jsx(l.Fragment,{children:Object.values(e)})};function RHe(){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]:sae.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 DHe=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=RHe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:kHe(e,this.editorContentRef),...n}),t?.contentComponent&&l.jsx(PHe,{contentComponent:t.contentComponent})]})}},OHe=M.forwardRef((t,e)=>{const n=mr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return mr.createElement(DHe,{key:n,innerRef:e,...t})}),jHe=mr.memo(OHe),LHe=typeof window<"u"?M.useLayoutEffect:M.useEffect,IHe=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 UHe(t){var e;const[n]=M.useState(()=>new IHe(t.editor)),r=sW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:NHe);return LHe(()=>n.watch(t.editor),[t.editor,n]),M.useDebugValue(r),r}var FHe=!1,sR=typeof window>"u",zHe=sR||!!(typeof window<"u"&&window.next),BHe=class lee{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?sR||zHe?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 gHe(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?lee.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 HHe(t={},e=[]){const n=M.useRef(t);n.current=t;const[r]=M.useState(()=>new BHe(n)),i=ER.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(i),M.useEffect(r.onRender(e)),UHe({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var $He=M.createContext({editor:null});$He.Consumer;var VHe=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),GHe=()=>M.useContext(VHe);mr.forwardRef((t,e)=>{const{onDragStart:n}=GHe(),r=t.as||"div";return l.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});mr.createContext({markViewContentRef:()=>{}});var eS=(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]},WHe=/^\s*>\s$/,qHe=ea.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return eS("blockquote",{...Dr(this.options.HTMLAttributes,t),children:eS("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(c=>c.trim()===""?n:`${n} ${c}`);r.push(o.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Hm({find:WHe,type:this.type})]}}),KHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,XHe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,YHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ZHe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,QHe=Md.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 eS("strong",{...Dr(this.options.HTMLAttributes,t),children:eS("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[Bm({find:KHe,type:this.type}),Bm({find:YHe,type:this.type})]},addPasteRules(){return[cf({find:XHe,type:this.type}),cf({find:ZHe,type:this.type})]}}),JHe=/(^|[^`])`([^`]+)`(?!`)$/,e$e=/(^|[^`])`([^`]+)`(?!`)/g,t$e=Md.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Dr(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[Bm({find:JHe,type:this.type})]},addPasteRules(){return[cf({find:e$e,type:this.type})]}}),ZN=4,n$e=/^```([a-z]+)?[\s\n]$/,r$e=/^~~~([a-z]+)?[\s\n]$/,i$e=ea.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ZN,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",Dr(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:ZN,{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:c})=>{const{from:u,to:d}=i,m=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>o+x).join(`
- `);return c.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:ZN,{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 c;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=((c=m[x].match(/^ */))==null?void 0:c[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(Kt.create(o.doc,A)),!0}):t.commands.command(({tr:o})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,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(c,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const 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(un.near(r.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[rR({find:n$e,type:this.type,getAttributes:t=>({language:t[1]})}),rR({find:r$e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Mr({key:new Si("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!n||!s)return!1;const{tr:a,schema:o}=t.state,c=o.text(n.replace(/\r\n?/g,`
- `));return a.replaceSelectionWith(this.type.create({language:s},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(Kt.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),s$e=ea.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),a$e=ea.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",Dr(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,c=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&a){const f=c.filter(g=>o.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),o$e=ea.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]}`,Dr(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=>rR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),l$e=ea.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Dr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!vHe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return GJ(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:c}=a.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?a.setSelection(Kt.create(a.doc,c.pos+1)):c.nodeAfter.isBlock?a.setSelection(Ht.create(a.doc,c.pos)):a.setSelection(Kt.create(a.doc,c.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(a.insert(u,f),a.setSelection(Kt.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[aee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),c$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,u$e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,d$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,h$e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,f$e=Md.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",Dr(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[Bm({find:c$e,type:this.type}),Bm({find:d$e,type:this.type})]},addPasteRules(){return[cf({find:u$e,type:this.type}),cf({find:h$e,type:this.type})]}});const p$e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",m$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",aR="numeric",oR="ascii",lR="alpha",i0="asciinumeric",$x="alphanumeric",cR="domain",cee="emoji",g$e="scheme",x$e="slashscheme",QN="whitespace";function b$e(t,e){return t in e||(e[t]=[]),e[t]}function yh(t,e,n){e[aR]&&(e[i0]=!0,e[$x]=!0),e[oR]&&(e[i0]=!0,e[lR]=!0),e[i0]&&(e[$x]=!0),e[lR]&&(e[$x]=!0),e[$x]&&(e[cR]=!0),e[cee]&&(e[cR]=!0);for(const r in e){const i=b$e(r,n);i.indexOf(t)<0&&i.push(t)}}function v$e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ws(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ws.groups={};Ws.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||Ws.groups;let i;return e&&e.j?i=e:(i=new Ws(e),n&&r&&yh(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||Ws.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 Ws,Object.assign(a.j,o.j),a.jr.push.apply(a.jr,o.jr),a.jd=o.jd,a.t=o.t):a=new Ws,s){if(r)if(a.t&&typeof a.t=="string"){const c=Object.assign(v$e(a.t,r),n);yh(s,c,r)}else n&&yh(s,n,r);a.t=s}return i.j[t]=a,a}};const an=(t,e,n,r,i)=>t.ta(e,n,r,i),Nr=(t,e,n,r,i)=>t.tr(e,n,r,i),L9=(t,e,n,r,i)=>t.ts(e,n,r,i),gt=(t,e,n,r,i)=>t.tt(e,n,r,i),ac="WORD",uR="UWORD",uee="ASCIINUMERICAL",dee="ALPHANUMERICAL",ob="LOCALHOST",dR="TLD",hR="UTLD",b1="SCHEME",$p="SLASH_SCHEME",Zj="NUM",fR="WS",Qj="NL",s0="OPENBRACE",a0="CLOSEBRACE",tS="OPENBRACKET",nS="CLOSEBRACKET",rS="OPENPAREN",iS="CLOSEPAREN",sS="OPENANGLEBRACKET",aS="CLOSEANGLEBRACKET",oS="FULLWIDTHLEFTPAREN",lS="FULLWIDTHRIGHTPAREN",cS="LEFTCORNERBRACKET",uS="RIGHTCORNERBRACKET",dS="LEFTWHITECORNERBRACKET",hS="RIGHTWHITECORNERBRACKET",fS="FULLWIDTHLESSTHAN",pS="FULLWIDTHGREATERTHAN",mS="AMPERSAND",gS="APOSTROPHE",xS="ASTERISK",Ru="AT",bS="BACKSLASH",vS="BACKTICK",yS="CARET",Uu="COLON",Jj="COMMA",_S="DOLLAR",Qo="DOT",wS="EQUALS",eL="EXCLAMATION",Ga="HYPHEN",o0="PERCENT",SS="PIPE",ES="PLUS",MS="POUND",l0="QUERY",tL="QUOTE",hee="FULLWIDTHMIDDLEDOT",nL="SEMI",Jo="SLASH",c0="TILDE",AS="UNDERSCORE",fee="EMOJI",TS="SYM";var pee=Object.freeze({__proto__:null,ALPHANUMERICAL:dee,AMPERSAND:mS,APOSTROPHE:gS,ASCIINUMERICAL:uee,ASTERISK:xS,AT:Ru,BACKSLASH:bS,BACKTICK:vS,CARET:yS,CLOSEANGLEBRACKET:aS,CLOSEBRACE:a0,CLOSEBRACKET:nS,CLOSEPAREN:iS,COLON:Uu,COMMA:Jj,DOLLAR:_S,DOT:Qo,EMOJI:fee,EQUALS:wS,EXCLAMATION:eL,FULLWIDTHGREATERTHAN:pS,FULLWIDTHLEFTPAREN:oS,FULLWIDTHLESSTHAN:fS,FULLWIDTHMIDDLEDOT:hee,FULLWIDTHRIGHTPAREN:lS,HYPHEN:Ga,LEFTCORNERBRACKET:cS,LEFTWHITECORNERBRACKET:dS,LOCALHOST:ob,NL:Qj,NUM:Zj,OPENANGLEBRACKET:sS,OPENBRACE:s0,OPENBRACKET:tS,OPENPAREN:rS,PERCENT:o0,PIPE:SS,PLUS:ES,POUND:MS,QUERY:l0,QUOTE:tL,RIGHTCORNERBRACKET:uS,RIGHTWHITECORNERBRACKET:hS,SCHEME:b1,SEMI:nL,SLASH:Jo,SLASH_SCHEME:$p,SYM:TS,TILDE:c0,TLD:dR,UNDERSCORE:AS,UTLD:hR,UWORD:uR,WORD:ac,WS:fR});const nc=/[a-z]/,kx=new RegExp("\\p{L}","u"),JN=new RegExp("\\p{Emoji}","u"),rc=/\d/,e3=/\s/,I9="\r",t3=`
- `,y$e="️",_$e="",n3="";let H_=null,$_=null;function w$e(t=[]){const e={};Ws.groups=e;const n=new Ws;H_==null&&(H_=U9(p$e)),$_==null&&($_=U9(m$e)),gt(n,"'",gS),gt(n,"{",s0),gt(n,"}",a0),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,"「",cS),gt(n,"」",uS),gt(n,"『",dS),gt(n,"』",hS),gt(n,"<",fS),gt(n,">",pS),gt(n,"&",mS),gt(n,"*",xS),gt(n,"@",Ru),gt(n,"`",vS),gt(n,"^",yS),gt(n,":",Uu),gt(n,",",Jj),gt(n,"$",_S),gt(n,".",Qo),gt(n,"=",wS),gt(n,"!",eL),gt(n,"-",Ga),gt(n,"%",o0),gt(n,"|",SS),gt(n,"+",ES),gt(n,"#",MS),gt(n,"?",l0),gt(n,'"',tL),gt(n,"/",Jo),gt(n,";",nL),gt(n,"~",c0),gt(n,"_",AS),gt(n,"\\",bS),gt(n,"・",hee);const r=Nr(n,rc,Zj,{[aR]:!0});Nr(r,rc,r);const i=Nr(r,nc,uee,{[i0]:!0}),s=Nr(r,kx,dee,{[$x]:!0}),a=Nr(n,nc,ac,{[oR]:!0});Nr(a,rc,i),Nr(a,nc,a),Nr(i,rc,i),Nr(i,nc,i);const o=Nr(n,kx,uR,{[lR]:!0});Nr(o,nc),Nr(o,rc,s),Nr(o,kx,o),Nr(s,rc,s),Nr(s,nc),Nr(s,kx,s);const c=gt(n,t3,Qj,{[QN]:!0}),u=gt(n,I9,fR,{[QN]:!0}),d=Nr(n,e3,fR,{[QN]:!0});gt(n,n3,d),gt(u,t3,c),gt(u,n3,d),Nr(u,e3,d),gt(d,I9),gt(d,t3),Nr(d,e3,d),gt(d,n3,d);const f=Nr(n,JN,fee,{[cee]:!0});gt(f,"#"),Nr(f,JN,f),gt(f,y$e,f);const g=gt(f,_$e);gt(g,"#"),Nr(g,JN,f);const m=[[nc,a],[rc,i]],x=[[nc,null],[kx,o],[rc,s]];for(let y=0;y<H_.length;y++)Mu(n,H_[y],dR,ac,m);for(let y=0;y<$_.length;y++)Mu(n,$_[y],hR,uR,x);yh(dR,{tld:!0,ascii:!0},e),yh(hR,{utld:!0,alpha:!0},e),Mu(n,"file",b1,ac,m),Mu(n,"mailto",b1,ac,m),Mu(n,"http",$p,ac,m),Mu(n,"https",$p,ac,m),Mu(n,"ftp",$p,ac,m),Mu(n,"ftps",$p,ac,m),yh(b1,{scheme:!0,ascii:!0},e),yh($p,{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]?{[g$e]:!0}:{[x$e]:!0};v.indexOf("-")>=0?E[cR]=!0:nc.test(v)?rc.test(v)?E[i0]=!0:E[oR]=!0:E[aR]=!0,L9(n,v,v,E)}return L9(n,"localhost",ob,{ascii:!0}),n.jd=new Ws(TS),{start:n,tokens:Object.assign({groups:e},pee)}}function mee(t,e){const n=S$e(e.replace(/[A-Z]/g,o=>o.toLowerCase())),r=n.length,i=[];let s=0,a=0;for(;a<r;){let o=t,c=null,u=0,d=null,f=-1,g=-1;for(;a<r&&(c=o.go(n[a]));)o=c,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 S$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 Mu(t,e,n,r,i){let s;const a=e.length;for(let o=0;o<a-1;o++){const c=e[o];t.j[c]?s=t.j[c]:(s=new Ws(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new Ws(n),s.jr=i.slice(),t.j[e[a-1]]=s,s}function U9(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 lb={defaultProtocol:"http",events:null,format:F9,formatHref:F9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function rL(t,e=null){let n=Object.assign({},lb);t&&(n=Object.assign(n,t instanceof rL?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}rL.prototype={o:lb,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]:lb[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 F9(t){return t}function gee(t,e){this.t="token",this.v=t,this.tk=e}gee.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=lb.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),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return a.href=r,o&&(a.class=o),c&&(a.target=c),u&&(a.rel=u),d&&Object.assign(a,d),{tagName:i,attributes:a,content:s,eventListeners:f}}};function oM(t,e){class n extends gee{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 z9=oM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),B9=oM("text"),E$e=oM("nl"),V_=oM("url",{isLink:!0,toHref(t=lb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ob&&t[1].t===Uu}}),Ha=t=>new Ws(t);function M$e({groups:t}){const e=t.domain.concat([mS,xS,Ru,bS,vS,yS,_S,wS,Ga,Zj,o0,SS,ES,MS,Jo,TS,c0,AS]),n=[gS,Uu,Jj,Qo,eL,o0,l0,tL,nL,sS,aS,s0,a0,nS,tS,rS,iS,oS,lS,cS,uS,dS,hS,fS,pS],r=[mS,gS,xS,bS,vS,yS,_S,wS,Ga,s0,a0,o0,SS,ES,MS,l0,Jo,TS,c0,AS],i=Ha(),s=gt(i,c0);an(s,r,s),an(s,t.domain,s);const a=Ha(),o=Ha(),c=Ha();an(i,t.domain,a),an(i,t.scheme,o),an(i,t.slashscheme,c),an(a,r,s),an(a,t.domain,a);const u=gt(a,Ru);gt(s,Ru,u),gt(o,Ru,u),gt(c,Ru,u);const d=gt(s,Qo);an(d,r,s),an(d,t.domain,s);const f=Ha();an(u,t.domain,f),an(f,t.domain,f);const g=gt(f,Qo);an(g,t.domain,f);const m=Ha(z9);an(g,t.tld,m),an(g,t.utld,m),gt(u,ob,m);const x=gt(f,Ga);gt(x,Ga,x),an(x,t.domain,f),an(m,t.domain,f),gt(m,Qo,g),gt(m,Ga,x);const y=gt(m,Uu);an(y,t.numeric,z9);const v=gt(a,Ga),b=gt(a,Qo);gt(v,Ga,v),an(v,t.domain,a),an(b,r,s),an(b,t.domain,a);const E=Ha(V_);an(b,t.tld,E),an(b,t.utld,E),an(E,t.domain,a),an(E,r,s),gt(E,Qo,b),gt(E,Ga,v),gt(E,Ru,u);const S=gt(E,Uu),A=Ha(V_);an(S,t.numeric,A);const T=Ha(V_),k=Ha();an(T,e,T),an(T,n,k),an(k,e,T),an(k,n,k),gt(E,Jo,T),gt(A,Jo,T);const N=gt(o,Uu),I=gt(c,Uu),C=gt(I,Jo),D=gt(C,Jo);an(o,t.domain,a),gt(o,Qo,b),gt(o,Ga,v),an(c,t.domain,a),gt(c,Qo,b),gt(c,Ga,v),an(N,t.domain,T),gt(N,Jo,T),gt(N,l0,T),an(D,t.domain,T),an(D,e,T),gt(D,Jo,T);const F=[[s0,a0],[tS,nS],[rS,iS],[sS,aS],[oS,lS],[cS,uS],[dS,hS],[fS,pS]];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=Ha(V_);an(W,e,K);const V=Ha();an(W,n),an(K,e,K),an(K,n,V),an(V,e,K),an(V,n,V),gt(K,R,T),gt(V,R,T)}return gt(i,ob,E),gt(i,Qj,E$e),{start:i,tokens:pee}}function A$e(t,e,n){let r=n.length,i=0,s=[],a=[];for(;i<r;){let o=t,c=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(c=o.go(n[i].t));)a.push(n[i++]);for(;i<r&&(u=c||o.go(n[i].t));)c=null,o=u,o.accepts()?(g=0,f=o):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(a.push(n[i]),i++);else{a.length>0&&(s.push(r3(B9,e,a)),a=[]),i-=g,d-=g;const m=f.t,x=n.slice(i-d,i);s.push(r3(m,e,x))}}return a.length>0&&s.push(r3(B9,e,a)),s}function r3(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 T$e=typeof console<"u"&&console&&console.warn||(()=>{}),C$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 N$e(){return Ws.groups={},cr.scanner=null,cr.parser=null,cr.tokenQueue=[],cr.pluginQueue=[],cr.customSchemes=[],cr.initialized=!1,cr}function H9(t,e=!1){if(cr.initialized&&T$e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${C$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 k$e(){cr.scanner=w$e(cr.customSchemes);for(let t=0;t<cr.tokenQueue.length;t++)cr.tokenQueue[t][1]({scanner:cr.scanner});cr.parser=M$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 iL(t){return cr.initialized||k$e(),A$e(cr.parser.start,t,mee(cr.scanner.start,t))}iL.scan=mee;function xee(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 rL(n),i=iL(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 sL="[\0- -\u2029 ]",P$e=new RegExp(sL),R$e=new RegExp(`${sL}$`),D$e=new RegExp(sL,"g");function O$e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function j$e(t){return new Mr({key:new Si("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=IJ(n.doc,[...e]);if(VJ(o).forEach(({newRange:u})=>{const d=y8e(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(!R$e.test(m))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const m=g.split(P$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=iL(x).map(b=>b.toObject(t.defaultProtocol));if(!O$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=>{Wj(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 L$e(t){return new Mr({key:new Si("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=$J(e.state,t.type.name),c=(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&&c?(window.open(c,u),!0):!1}}})}function I$e(t){return new Mr({key:new Si("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:a}=s,{empty:o}=a;if(o)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=xee(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function Jd(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(D$e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var bee=Md.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"){H9(t);return}H9(t.scheme,t.optionalSlashes)})},onDestroy(){N$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)=>!!Jd(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=>!!Jd(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=>!!Jd(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Dr(this.options.HTMLAttributes,t),0]:["a",Dr(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=>!!Jd(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=>!!Jd(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[cf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=xee(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:a=>!!Jd(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(j$e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Jd(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(L$e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(I$e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),U$e=bee,F$e=Object.defineProperty,z$e=(t,e)=>{for(var n in e)F$e(t,n,{get:e[n],enumerable:!0})},B$e="listItem",$9="textStyle",V9=/^\s*([-+*])\s$/,vee=ea.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",Dr(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(B$e,this.editor.getAttributes($9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Hm({find:V9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hm({find:V9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes($9),editor:this.editor})),[t]}}),yee=ea.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Dr(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)=>Yj(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)}}}),H$e={};z$e(H$e,{findListItemPos:()=>Jb,getNextListDepth:()=>aL,handleBackspace:()=>pR,handleDelete:()=>mR,hasListBefore:()=>_ee,hasListItemAfter:()=>$$e,hasListItemBefore:()=>wee,listItemHasSubList:()=>See,nextListIsDeeper:()=>Eee,nextListIsHigher:()=>Mee});var Jb=(t,e)=>{const{$from:n}=e.selection,r=ii(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}},aL=(t,e)=>{const n=Jb(t,e);if(!n)return!1;const[,r]=k8e(e,t,n.$pos.pos+4);return r},_ee=(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))},wee=(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)},See=(t,e,n)=>{if(!n)return!1;const r=ii(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},pR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!gd(t.state,e)&&_ee(t.state,e,n)){const{$anchor:o}=t.state.selection,c=t.state.doc.resolve(o.before()-1),u=[];c.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(c.start()+d.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!gd(t.state,e)||!O8e(t.state))return!1;const r=Jb(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=See(e,t.state,s);return wee(e,t.state)&&!a?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Eee=(t,e)=>{const n=aL(t,e),r=Jb(t,e);return!r||!n?!1:n>r.depth},Mee=(t,e)=>{const n=aL(t,e),r=Jb(t,e);return!r||!n?!1:n<r.depth},mR=(t,e)=>{if(!gd(t.state,e)||!D8e(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Eee(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Mee(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},$$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)},Aee=Qn.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&&mR(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&&mR(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&&pR(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&&pR(t,n,r)&&(e=!0)}),e}}}}),G9=/^(\s*)(\d+)\.\s+(.*)$/,V$e=/^\s/;function G$e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(G9);if(!s)break;const[,a,o,c]=s,u=a.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const m=t[f];if(m.match(G9))break;if(m.trim()==="")g.push(m),d+=`
- `,f+=1;else if(m.match(V$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 Tee(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(`
- `),c=((r=o[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=o.slice(1).join(`
- `).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=Tee(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 W$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 q$e="listItem",W9="textStyle",q9=/^(\d+)\.\s$/,Cee=ea.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",Dr(this.options.HTMLAttributes,n),0]:["ol",Dr(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?W$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]=G$e(i);if(s.length===0)return;const o=Tee(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(q$e,this.editor.getAttributes(W9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Hm({find:q9,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hm({find:q9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(W9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),K$e=/^\s*(\[([( |x])?\])\s$/,X$e=ea.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",Dr(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 Yj(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"),c=document.createElement("div"),u=d=>{var f,g;o.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),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,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Hm({find:K$e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Y$e=ea.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",Dr(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=iR(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,c)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:c}),customNestedParser:r},n);return a?[{type:"taskList",raw:a.raw,items:a.items}]:n.blockTokens(s)},i=iR(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()}}});Qn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(vee.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(yee.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Aee.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Cee.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(X$e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Y$e.configure(this.options.taskList)),t}});var Z$e=ea.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Dr(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()}}}),Q$e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,J$e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,eVe=Md.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",Dr(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[Bm({find:Q$e,type:this.type})]},addPasteRules(){return[cf({find:J$e,type:this.type})]}}),tVe=ea.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Nee=Md.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",Dr(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()}}}),nVe=Nee;function rVe(t={}){return new Mr({view(e){return new iVe(e,t)}})}class iVe{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 c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,m=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,d=f.top-c.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=NQ(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 Pr extends un{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Pr.valid(r)?new Pr(r):un.near(r)}content(){return kt.empty}eq(e){return e instanceof Pr&&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 Pr(e.resolve(n.pos))}getBookmark(){return new oL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!sVe(e)||!aVe(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&&Pr.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 c=e.doc.resolve(i);if(Pr.valid(c))return c}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(Pr.valid(o))return o}return null}}}Pr.prototype.visible=!1;Pr.findFrom=Pr.findGapCursorFrom;un.jsonID("gapcursor",Pr);class oL{constructor(e){this.pos=e}map(e){return new oL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Pr.valid(n)?new Pr(n):un.near(n)}}function kee(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function sVe(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||kee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function aVe(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||kee(i.type))return!0;if(i.inlineContent)return!1}}return!0}function oVe(){return new Mr({props:{decorations:dVe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Pr.valid(n)?new Pr(n):null},handleClick:cVe,handleKeyDown:lVe,handleDOMEvents:{beforeinput:uVe}}})}const lVe=NJ({ArrowLeft:G_("horiz",-1),ArrowRight:G_("horiz",1),ArrowUp:G_("vert",-1),ArrowDown:G_("vert",1)});function G_(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,c=a.empty;if(a instanceof Kt){if(!s.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=r.doc.resolve(e>0?o.after():o.before())}let u=Pr.findGapCursorFrom(o,e,c);return u?(i&&i(r.tr.setSelection(new Pr(u))),!0):!1}}function cVe(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Pr.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 Pr(r))),!0)}function uVe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Pr))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 kt(i,0,0));return s.setSelection(Kt.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function dVe(t){if(!(t.selection instanceof Pr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",vr.create(t.doc,[As.widget(t.selection.head,e,{key:"gapcursor"})])}var CS=200,Ui=function(){};Ui.prototype.append=function(e){return e.length?(e=Ui.from(e),!this.length&&e||e.length<CS&&this.leafAppend(e)||this.length<CS&&e.leafPrepend(this)||this.appendInner(e)):this};Ui.prototype.prepend=function(e){return e.length?Ui.from(e).append(this):this};Ui.prototype.appendInner=function(e){return new hVe(this,e)};Ui.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ui.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ui.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ui.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)};Ui.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};Ui.from=function(e){return e instanceof Ui?e:e&&e.length?new Pee(e):Ui.empty};var Pee=(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 c=s;c<a;c++)if(i(this.values[c],o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,a,o){for(var c=s-1;c>=a;c--)if(i(this.values[c],o+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=CS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=CS)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})(Ui);Ui.empty=new Pee([]);var hVe=(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})(Ui);const fVe=500;class Po{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,c,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 el(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 el(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,c=new Po(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:o}}addTransform(e,n,r,i){let s=[],a=this.eventCount,o=this.items,c=!i&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new el(e.mapping.maps[d],f,n),m;(m=c&&c.merge(g))&&(g=m,d?s.pop():o=o.slice(0,o.length-1)),s.push(g),n&&(a++,n=void 0),i||(c=g)}let u=a-r.depth;return u>mVe&&(o=pVe(o,u),a-=u),new Po(o.append(s),a)}remapping(e,n){let r=new tb;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 Po(this.items.append(e.map(n=>new el(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,a=e.steps.length,o=this.eventCount;this.items.forEach(g=>{g.selection&&o--},i);let c=n;this.items.forEach(g=>{let m=s.getMirror(--c);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(c+1,m));v&&o++,r.push(new el(x,y,v))}else r.push(new el(x))},i);let u=[];for(let g=n;g<a;g++)u.push(new el(s.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Po(d,o);return f.emptyItemCount()>fVe&&(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 c=a.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=a.selection&&a.selection.map(n.slice(r));d&&s++;let f=new el(u.invert(),c,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 Po(Ui.from(i.reverse()),s)}}Po.empty=new Po(Ui.empty,0);function pVe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class el{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new el(n.getMap().invert(),n,this.selection)}}}class Du{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const mVe=20;function gVe(t,e,n,r){let i=n.getMeta(Lh),s;if(i)return i.historyState;n.getMeta(vVe)&&(t=new Du(t.done,t.undone,null,0,-1));let a=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(a&&a.getMeta(Lh))return a.getMeta(Lh).redo?new Du(t.done.addTransform(n,void 0,r,v1(e)),t.undone,K9(n.mapping.maps),t.prevTime,t.prevComposition):new Du(t.done,t.undone.addTransform(n,void 0,r,v1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=t.prevTime==0||!a&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-r.newGroupDelay||!xVe(n,t.prevRanges)),u=a?i3(t.prevRanges,n.mapping):K9(n.mapping.maps);return new Du(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,v1(e)),Po.empty,u,n.time,o??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Du(t.done.rebased(n,s),t.undone.rebased(n,s),i3(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Du(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),i3(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function xVe(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 K9(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 i3(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 bVe(t,e,n){let r=v1(e),i=Lh.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),c=new Du(n?o:s.remaining,n?s.remaining:o,null,0,-1);return s.transform.setSelection(a).setMeta(Lh,{redo:n,historyState:c})}let s3=!1,X9=null;function v1(t){let e=t.plugins;if(X9!=e){s3=!1,X9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){s3=!0;break}}return s3}const Lh=new Si("history"),vVe=new Si("closeHistory");function yVe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Mr({key:Lh,state:{init(){return new Du(Po.empty,Po.empty,null,0,-1)},apply(e,n,r){return gVe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Dee:r=="historyRedo"?Oee:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Ree(t,e){return(n,r)=>{let i=Lh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=bVe(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const Dee=Ree(!1,!0),Oee=Ree(!0,!0);Qn.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 Mr({key:new Si("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const a=s-i,o=0,c=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(o,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),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,c=s-r,u=o-c,d=o;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var _Ve=Qn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[rVe(this.options)]}});Qn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Mr({key:new Si("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((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;a+=1});let o=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&a-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";s.push(As.node(u,u+c.nodeSize,{class:this.options.className}))}),vr.create(t,s)}}})]}});var wVe=Qn.create({name:"gapCursor",addProseMirrorPlugins(){return[oVe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Fn(Bt(t,"allowGapCursor",n)))!=null?e:null}}});Qn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Mr({key:new Si("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((a,o)=>{const c=r>=o&&r<=o+a.nodeSize,u=!a.isLeaf&&iM(a);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const f=As.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:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),vr.create(t,i)}}})]}});Qn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Mr({key:new Si("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||GJ(n.selection)||t.view.dragging?null:vr.create(n.doc,[As.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Y9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var SVe=Qn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Si(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Mr({key:e,appendTransaction:(i,s,a)=>{const{doc:o,tr:c,schema:u}=a,d=e.getState(a),f=o.content.size,g=u.nodes[n];if(d)return c.insert(f,g.create())},state:{init:(i,s)=>{const a=s.tr.doc.lastChild;return!Y9({node:a,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const a=i.doc.lastChild;return!Y9({node:a,types:r})}}})]}}),EVe=Qn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Dee(t,e),redo:()=>({state:t,dispatch:e})=>Oee(t,e)}},addProseMirrorPlugins(){return[yVe(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()}}}),MVe=Qn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(QHe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(qHe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(vee.configure(this.options.bulletList)),this.options.code!==!1&&i.push(t$e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(i$e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(s$e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(_Ve.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(wVe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(a$e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(o$e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(EVe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(l$e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(f$e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(yee.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Aee.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(bee.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Cee.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Z$e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(eVe.configure(this.options.strike)),this.options.text!==!1&&i.push(tVe.configure(this.options.text)),this.options.underline!==!1&&i.push(Nee.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(SVe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),AVe=MVe,TVe=Qn.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")}}}),CVe=TVe,NVe=20,jee=(t,e=0)=>{const n=[];return!t.children.length||e>NVe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...jee(r,e+1))}),n},kVe=t=>{if(!t.children.length)return;const e=jee(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}`)})},Lee=Md.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&kVe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Dr(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}}}}),PVe=Qn.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()}}}),Iee=Qn.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()}}}),RVe=Qn.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()}}}),DVe=Qn.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()}}}),OVe=Qn.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()}}});Qn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(PVe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Iee.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(RVe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(DVe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(OVe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Lee.configure(this.options.textStyle)),t}});var jVe=Iee,LVe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,IVe=ea.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",Dr(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:"",c=(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 c=new bHe({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=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",o.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[aee({find:LVe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),UVe=IVe;function Z9({content:t,onChange:e,placeholder:n}){const r=HHe({extensions:[AVe.configure({heading:!1,codeBlock:!1,code:!1}),nVe,U$e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),CVe.configure({types:["paragraph"]}),Lee,jVe,UVe.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:c,title:u})=>l.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:c}),s=()=>{const a=window.prompt("Enter URL:");a&&r.chain().focus().setLink({href:a}).run()};return l.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[l.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[l.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:l.jsx(eoe,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:l.jsx(Rle,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:l.jsx(Eue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:l.jsx(zR,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:l.jsx(l7,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:l.jsx(gue,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:l.jsx(hue,{className:"w-4 h-4"})}),l.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:l.jsx(pue,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),l.jsx(i,{onClick:s,isActive:r.isActive("link"),title:"Add Link",children:l.jsx(zS,{className:"w-4 h-4"})}),r.isActive("link")&&l.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:l.jsx(m7,{className:"w-4 h-4"})})]}),l.jsx(jHe,{editor:r})]})}function FVe({archiveId:t,archiveName:e,onClose:n}){const r=Mn(),[i,s]=M.useState(!1),[a,o]=M.useState(null),[c,u]=M.useState({}),{data:d,isLoading:f,error:g}=yt({queryKey:["archive-project-page",t],queryFn:()=>ke.getArchiveProjectPage(t)}),m=wt({mutationFn:T=>ke.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(c)},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 l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(to,{className:"w-5 h-5 text-bambu-green"}),l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&l.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[!i&&S&&l.jsxs(Le,{variant:"ghost",size:"sm",onClick:y,children:[l.jsx(S0,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),l.jsxs(Le,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[l.jsx(Ro,{className:"w-4 h-4 mr-1"}),"Save"]})]}),l.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&l.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!S&&l.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[l.jsx(to,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No project page data found in this 3MF file."}),l.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&S&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-4",children:[i?l.jsx("input",{type:"text",value:c.title||"",onChange:T=>u({...c,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&l.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),l.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(D3,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:c.designer||"",onChange:T=>u({...c,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(D3,{className:"w-4 h-4"}),l.jsx("span",{children:d.designer}),d.designer_user_id&&l.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:l.jsx(Aa,{className:"w-3 h-3"})})]}),d.creation_date&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(Zr,{className:"w-4 h-4"}),l.jsx("span",{children:d.creation_date})]}),i?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(to,{className:"w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:c.license||"",onChange:T=>u({...c,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[l.jsx(to,{className:"w-4 h-4"}),l.jsx("span",{children:d.license})]}),d.origin&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?l.jsx(Z9,{content:c.description||"",onChange:T=>u({...c,description:T}),placeholder:"Enter description..."}):l.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&l.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?l.jsxs("div",{className:"space-y-2",children:[l.jsx("input",{type:"text",value:c.profile_title||"",onChange:T=>u({...c,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),l.jsx(Z9,{content:c.profile_description||"",onChange:T=>u({...c,profile_description:T}),placeholder:"Profile description..."})]}):l.jsxs(l.Fragment,{children:[d.profile_title&&l.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&l.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&l.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[l.jsx(gb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),l.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((T,k)=>l.jsx("button",{onClick:()=>o(k),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:l.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[l.jsx(Aa,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),a!==null&&x[a]&&l.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,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:l.jsx(Bh,{className:"w-6 h-6 text-white"})}),l.jsx("img",{src:x[a].url,alt:x[a].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),l.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(x.length-1,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:l.jsx(df,{className:"w-6 h-6 text-white"})}),l.jsx("button",{onClick:()=>o(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:l.jsx(Wt,{className:"w-6 h-6 text-white"})}),l.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[a+1," / ",x.length]})]})]})}const zVe=[.25,.5,.75,1,1.5,2,3,4];function BVe({src:t,title:e,downloadFilename:n,onClose:r}){const i=M.useRef(null),[s,a]=M.useState(!0),[o,c]=M.useState(2),[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 l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:l.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Zp,{className:"w-5 h-5 text-bambu-green"}),e]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:E,children:[l.jsx(Ma,{className:"w-4 h-4"}),"Download"]}),l.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),l.jsxs("div",{className:"p-4",children:[l.jsx("video",{ref:i,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),l.jsxs("div",{className:"mt-4 space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:b(u)}),l.jsx("input",{type:"range",min:0,max:f||100,value:u,onChange:x,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-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`}),l.jsx("span",{className:"text-xs text-bambu-gray w-12",children:b(f)})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:l.jsx(Jce,{className:"w-5 h-5 text-bambu-gray"})}),l.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:s?l.jsx(yce,{className:"w-5 h-5 text-white"}):l.jsx(BS,{className:"w-5 h-5 text-white"})}),l.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:l.jsx(N1,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),l.jsx("div",{className:"flex gap-1",children:zVe.map(S=>l.jsxs("button",{onClick:()=>c(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 HVe({archiveId:t,archiveName:e,onClose:n}){const r=Mn(),{showToast:i}=si(),[s,a]=M.useState(null),[o,c]=M.useState("asap"),[u,d]=M.useState(""),[f,g]=M.useState(!1),[m,x]=M.useState(!1),{data:y}=yt({queryKey:["printers"],queryFn:()=>ke.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=wt({mutationFn:S=>ke.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 l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zr,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),l.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:e})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),"No printers configured"]}):l.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s||"",onChange:S=>a(S.target.value?Number(S.target.value):null),required:!0,children:[l.jsx("option",{value:"",children:"Select printer..."}),y?.map(S=>l.jsx("option",{value:S.id,children:S.name},S.id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_r,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[l.jsx(Zr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:E(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(bd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:v.isPending||!s||y?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function $Ve({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:()=>ke.compareArchives(t)});return l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:s=>s.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?l.jsxs("div",{className:"text-center py-12 text-red-400",children:[l.jsx(ti,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"Failed to load comparison"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?l.jsx(VVe,{comparison:n}):null}),l.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Le,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function VVe({comparison:t}){return l.jsxs("div",{className:"space-y-6",children:[l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>l.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[l.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),l.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),l.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>l.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[l.jsx("td",{className:"py-2 pr-4 text-sm",children:l.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&l.jsx(ti,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),l.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>l.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??l.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&l.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&l.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[l.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[l.jsx(ti,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),l.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>l.jsxs("li",{children:[l.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&l.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[l.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[l.jsx(zh,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[l.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),l.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?l.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>l.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[l.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",l.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):l.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):l.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:l.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function gR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Px(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Q9(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function GVe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s}){const a=Mn(),{showToast:o}=si(),c=y7(),[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,ee]=M.useState(null),Y=M.useRef(null),Q=wt({mutationFn:re=>ke.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=wt({mutationFn:()=>ke.deleteSource3mf(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),o("Source 3MF removed")},onError:re=>{o(re.message||"Failed to remove source 3MF","error")}}),z=wt({mutationFn:()=>ke.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")}}),J=wt({mutationFn:re=>ke.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")}}),se=wt({mutationFn:()=>ke.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),o("Archive deleted")},onError:()=>{o("Failed to delete archive","error")}}),me=wt({mutationFn:()=>ke.toggleFavorite(t.id),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),o(re.is_favorite?"Added to favorites":"Removed from favorites")}}),fe=wt({mutationFn:re=>ke.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(),ee({x:re.clientX,y:re.clientY})},Ee=[{label:"Print",icon:l.jsx(Ta,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"Schedule",icon:l.jsx(Zr,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"Open in Bambu Studio",icon:l.jsx(Aa,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",we=`${window.location.origin}${ke.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(we)}`}},{label:"View on MakerWorld",icon:l.jsx(v0,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:l.jsx(fm,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:l.jsx(Zp,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:l.jsx(zce,{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:l.jsx(WU,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const re=document.createElement("a");re.href=ke.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:l.jsx(ya,{className:"w-4 h-4"}),onClick:()=>Y.current?.click()},{label:"Remove Source 3MF",icon:l.jsx(Rn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:l.jsx(Ma,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=ke.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()}},{label:"Copy Download Link",icon:l.jsx(Hh,{className:"w-4 h-4"}),onClick:()=>{const re=`${window.location.origin}${ke.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(re).then(()=>{o("Link copied to clipboard")}).catch(()=>{o("Failed to copy link","error")})}},{label:"QR Code",icon:l.jsx(Dce,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:l.jsx(b0,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:l.jsx(to,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:l.jsx(xm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>me.mutate()},{label:"Edit",icon:l.jsx(rd,{className:"w-4 h-4"}),onClick:()=>v(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:l.jsx(qu,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:l.jsx(qu,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const re=[];if(t.project_id&&re.push({label:"Remove from Project",icon:l.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>fe.mutate(null)}),!s)re.push({label:"Loading...",icon:l.jsx(At,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const we=s.filter(Oe=>Oe.status==="active");we.length===0?re.push({label:"No projects available",icon:l.jsx(qu,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):we.forEach(Oe=>{re.push({label:Oe.name,icon:l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Oe.color||"#888"}}),onClick:()=>fe.mutate(Oe.id),disabled:t.project_id===Oe.id})})}return re})()},{label:n?"Deselect":"Select",icon:n?l.jsx(Vh,{className:"w-4 h-4"}):l.jsx(gm,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:l.jsx(Rn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return l.jsxs(Nt,{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&&l.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?l.jsx(Vh,{className:"w-5 h-5 text-bambu-green"}):l.jsx(gm,{className:"w-5 h-5 text-white"})}),l.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(gb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),c&&l.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation();const we=re.currentTarget.getBoundingClientRect();ee({x:we.left,y:we.bottom+4})},title:"Menu",children:l.jsx(i7,{className:"w-5 h-5 text-white"})}),l.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),me.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:l.jsx(xm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&l.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&l.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[l.jsx(Hh,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&l.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation();const we=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Oe=`${window.location.origin}${ke.getSource3mfForSlicer(t.id,we)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Oe)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:l.jsx(WU,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&l.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation(),E(!0)},title:"View timelapse",children:l.jsx(Zp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&l.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:re=>{re.stopPropagation(),D(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[l.jsx(b0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&l.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]})]}),l.jsxs(Rt,{className:"p-4 flex-1 flex flex-col",children:[l.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:e}),t.project_name&&l.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${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})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Px(t.print_time_seconds||0)}
- Actual: ${Px(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Px(t.actual_time_seconds)}`:`Estimated: ${Px(t.print_time_seconds||0)}`,children:[l.jsx(_r,{className:"w-3 h-3"}),Px(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&l.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx(w0,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&l.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[l.jsx($h,{className:"w-3 h-3"}),t.total_layers&&l.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&l.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&l.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[l.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((re,we)=>l.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},we))})]})]}),(t.tags||t.notes)&&l.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&l.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:l.jsx(u7,{className:"w-3 h-3"})}),t.tags?.split(",").map((re,we)=>l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},we))]}),l.jsx("div",{className:"flex-1"}),l.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[l.jsx("span",{children:Q9(t.created_at)}),l.jsx("span",{children:gR(t.file_size)})]}),l.jsxs("div",{className:"flex gap-1 mt-3",children:[l.jsxs(Le,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[l.jsx(Ta,{className:"w-3 h-3 flex-shrink-0"}),l.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",we=`${window.location.origin}${ke.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(we)}`},title:"Open in Bambu Studio",children:l.jsx(Aa,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:l.jsx(v0,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:l.jsx(fm,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=document.createElement("a");re.href=ke.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},title:"Download",children:l.jsx(Ma,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>v(!0),title:"Edit",children:l.jsx(rd,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:l.jsx(Rn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&l.jsx(mFe,{archive:t,onClose:()=>v(!1)}),u&&l.jsx(dFe,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&l.jsx(hFe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),m&&l.jsx(Qr,{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:()=>{se.mutate(),x(!1)},onCancel:()=>x(!1)}),W&&l.jsx(Qr,{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&&l.jsx(gFe,{x:V.x,y:V.y,items:Ee,onClose:()=>ee(null)}),b&&t.timelapse_path&&l.jsx(BVe,{src:ke.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&&l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),l.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),l.jsx("button",{onClick:()=>{A(!1),k([])},className:"text-gray-400 hover:text-white p-1",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(re=>l.jsxs("button",{onClick:()=>J.mutate(re.name),disabled:J.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[l.jsx(Zp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-white font-medium truncate",children:re.name}),l.jsxs("p",{className:"text-sm text-gray-400",children:[gR(re.size),re.mtime&&` • ${Q9(re.mtime)}`]})]})]},re.name))}),l.jsx("div",{className:"p-4 border-t border-gray-700",children:l.jsx(Le,{variant:"secondary",onClick:()=>{A(!1),k([])},className:"w-full",children:"Cancel"})})]})}),N&&l.jsx(SFe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),C&&t.photos&&t.photos.length>0&&l.jsx(EFe,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>D(!1),onDelete:async re=>{try{await ke.deleteArchivePhoto(t.id,re),a.invalidateQueries({queryKey:["archives"]}),o("Photo deleted")}catch{o("Failed to delete photo","error")}}}),F&&l.jsx(FVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),q&&l.jsx(HVe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),l.jsx("input",{ref:Y,type:"file",accept:".3mf",className:"hidden",onChange:re=>{const we=re.target.files?.[0];we&&Q.mutate(we),re.target.value=""}})]})}const WVe=[{id:"all",label:"All Archives",icon:l.jsx(fle,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:l.jsx(_r,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:l.jsx(Zr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:l.jsx(Zr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:l.jsx(xm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:l.jsx(lo,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:l.jsx(Hh,{className:"w-4 h-4"})}];function qVe(){const t=Mn(),{showToast:e}=si(),n=M.useRef(null),[r,i]=M.useState(""),[s,a]=M.useState(null),[o,c]=M.useState(null),[u,d]=M.useState(new Set),[f,g]=M.useState("or"),[m,x]=M.useState(!1),[y,v]=M.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[b,E]=M.useState(null),[S,A]=M.useState(!1),[T,k]=M.useState([]),[N,I]=M.useState(!1),[C,D]=M.useState(new Set),[F,j]=M.useState(!1),[q,R]=M.useState(!1),[W,K]=M.useState(!1),[V,ee]=M.useState("grid"),[Y,Q]=M.useState("date-desc"),[U,z]=M.useState("all"),[J,se]=M.useState(!1),[me,fe]=M.useState(!1),[xe,Ee]=M.useState(!1),{data:re,isLoading:we}=yt({queryKey:["archives",s],queryFn:()=>ke.getArchives(s||void 0)}),{data:Oe}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:he}=yt({queryKey:["projects"],queryFn:()=>ke.getProjects()}),ht=wt({mutationFn:async ue=>(await Promise.all(ue.map(Ve=>ke.deleteArchive(Ve))),ue.length),onSuccess:ue=>{t.invalidateQueries({queryKey:["archives"]}),D(new Set),e(`${ue} archive${ue!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});M.useEffect(()=>{localStorage.setItem("archiveHideFailed",y.toString())},[y]);const $=new Map(Oe?.map(ue=>[ue.id,ue.name])||[]),H=[...new Set(re?.flatMap(ue=>ue.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ne=[...new Set(re?.flatMap(ue=>ue.filament_color?.split(",")||[]).filter(Boolean)||[])],G=[...new Set(re?.flatMap(ue=>ue.tags?.split(",").map(Ve=>Ve.trim())||[]).filter(Boolean)||[])].sort(),Z=re?.filter(ue=>{const Ve=new Date,Ue=new Date(ue.created_at);let ae=!0;switch(U){case"recent":ae=Ve.getTime()-Ue.getTime()<1440*60*1e3;break;case"this-week":ae=Ve.getTime()-Ue.getTime()<10080*60*1e3;break;case"this-month":ae=Ue.getMonth()===Ve.getMonth()&&Ue.getFullYear()===Ve.getFullYear();break;case"favorites":ae=ue.is_favorite===!0;break;case"failed":ae=ue.status==="failed"||ue.status==="aborted";break;case"duplicates":ae=ue.duplicate_count>0;break}const Je=(ue.print_name||ue.filename).toLowerCase().includes(r.toLowerCase()),He=!o||ue.filament_type?.split(", ").includes(o),Ke=ue.filament_color?.split(",")||[],ct=u.size===0||(f==="or"?Ke.some(Ce=>u.has(Ce)):[...u].every(Ce=>Ke.includes(Ce))),de=U==="favorites"||!m||ue.is_favorite,Ye=U==="failed"||!y||ue.status!=="failed"&&ue.status!=="aborted",ge=ue.tags?.split(",").map(Ce=>Ce.trim())||[],Fe=!b||ge.includes(b);return ae&&Je&&He&&ct&&de&&Ye&&Fe}).sort((ue,Ve)=>{switch(Y){case"date-desc":return new Date(Ve.created_at).getTime()-new Date(ue.created_at).getTime();case"date-asc":return new Date(ue.created_at).getTime()-new Date(Ve.created_at).getTime();case"name-asc":return(ue.print_name||ue.filename).localeCompare(Ve.print_name||Ve.filename);case"name-desc":return(Ve.print_name||Ve.filename).localeCompare(ue.print_name||ue.filename);case"size-desc":return Ve.file_size-ue.file_size;case"size-asc":return ue.file_size-Ve.file_size;default:return 0}}),oe=F||C.size>0,Ne=ue=>{D(Ve=>{const Ue=new Set(Ve);return Ue.has(ue)?Ue.delete(ue):Ue.add(ue),Ue})},Pe=()=>{Z&&D(new Set(Z.map(ue=>ue.id)))},Se=()=>{D(new Set),j(!1)},B=ue=>{d(Ve=>{const Ue=new Set(Ve);return Ue.has(ue)?Ue.delete(ue):Ue.add(ue),Ue})},L=()=>{d(new Set)},te=()=>{i(""),a(null),c(null),x(!1),v(!1),E(null)},ve=r||s||o||m||y||b,_e=M.useCallback(ue=>{ue.preventDefault(),ue.dataTransfer.types.includes("Files")&&I(!0)},[]),be=M.useCallback(ue=>{ue.preventDefault(),ue.currentTarget===ue.target&&I(!1)},[]),nt=M.useCallback(ue=>{ue.preventDefault(),I(!1);const Ve=Array.from(ue.dataTransfer.files).filter(Ue=>Ue.name.endsWith(".3mf"));Ve.length>0?(k(Ve),A(!0)):ue.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Be=M.useCallback(ue=>{const Ve=ue.target;if(Ve.tagName==="INPUT"||Ve.tagName==="TEXTAREA"||Ve.isContentEditable){ue.key==="Escape"&&Ve.blur();return}switch(ue.key){case"/":ue.preventDefault(),n.current?.focus();break;case"u":case"U":!ue.metaKey&&!ue.ctrlKey&&(ue.preventDefault(),A(!0));break;case"Escape":oe&&Se();break}},[oe]);return M.useEffect(()=>(document.addEventListener("keydown",Be),()=>document.removeEventListener("keydown",Be)),[Be]),l.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:_e,onDragLeave:be,onDrop:nt,children:[N&&l.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:l.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[l.jsx(ya,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),l.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),l.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),oe&&l.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:Se,children:[l.jsx(Wt,{className:"w-4 h-4"}),"Close"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs("span",{className:"text-white font-medium",children:[C.size," selected"]}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:Pe,children:"Select All"}),l.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>K(!0),children:[l.jsx(M0,{className:"w-4 h-4"}),"Tags"]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>{const ue=Array.from(C);Promise.all(ue.map(Ve=>ke.toggleFavorite(Ve))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ue.length} archive${ue.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[l.jsx(xm,{className:"w-4 h-4"}),"Favorite"]}),l.jsxs(Le,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>R(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]}),l.jsxs("div",{className:"flex items-center justify-between mb-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),l.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:U,onChange:ue=>z(ue.target.value),children:WVe.map(ue=>l.jsx("option",{value:ue.id,children:ue.label},ue.id))})]}),l.jsxs("p",{className:"text-bambu-gray",children:[Z?.length||0," of ",re?.length||0," prints"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>se(!J),disabled:me,children:[me?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(T1,{className:"w-4 h-4"}),"Export"]}),J&&l.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{se(!1),fe(!0);try{const{blob:ue,filename:Ve}=await ke.exportArchives({format:"csv",printerId:s||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Ue=URL.createObjectURL(ue),ae=document.createElement("a");ae.href=Ue,ae.download=Ve,ae.click(),URL.revokeObjectURL(Ue),e("Export downloaded")}catch{e("Export failed","error")}finally{fe(!1)}},children:[l.jsx(to,{className:"w-4 h-4"}),"Export as CSV"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{se(!1),fe(!0);try{const{blob:ue,filename:Ve}=await ke.exportArchives({format:"xlsx",printerId:s||void 0,status:U==="failed"?"failed":void 0,search:r||void 0}),Ue=URL.createObjectURL(ue),ae=document.createElement("a");ae.href=Ue,ae.download=Ve,ae.click(),URL.revokeObjectURL(Ue),e("Export downloaded")}catch{e("Export failed","error")}finally{fe(!1)}},children:[l.jsx(T1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),C.size>=2&&C.size<=5&&l.jsxs(Le,{variant:"secondary",onClick:()=>Ee(!0),children:[l.jsx(Qp,{className:"w-4 h-4"}),"Compare (",C.size,")"]}),!oe&&l.jsxs(Le,{variant:"secondary",onClick:()=>j(!0),children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select"]}),l.jsxs(Le,{onClick:()=>A(!0),children:[l.jsx(ya,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),l.jsx(Nt,{className:"mb-6",children:l.jsxs(Rt,{className:"py-4",children:[l.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[l.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[l.jsx(id,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ue=>i(ue.target.value)})]}),l.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(IR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:s||"",onChange:ue=>a(ue.target.value?Number(ue.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),Oe?.map(ue=>l.jsx("option",{value:ue.id,children:ue.name},ue.id))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(w0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o||"",onChange:ue=>c(ue.target.value||null),children:[l.jsx("option",{value:"",children:"All Materials"}),H.map(ue=>l.jsx("option",{value:ue,children:ue},ue))]})]}),l.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:[l.jsx(xm,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),l.jsxs("button",{onClick:()=>v(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[l.jsx(lo,{className:"w-4 h-4 "}),l.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),G.length>0&&l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(M0,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:b||"",onChange:ue=>E(ue.target.value||null),children:[l.jsx("option",{value:"",children:"All Tags"}),G.map(ue=>l.jsx("option",{value:ue,children:ue},ue))]})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsx(Yae,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:Y,onChange:ue=>Q(ue.target.value),children:[l.jsx("option",{value:"date-desc",children:"Newest first"}),l.jsx("option",{value:"date-asc",children:"Oldest first"}),l.jsx("option",{value:"name-asc",children:"Name A-Z"}),l.jsx("option",{value:"name-desc",children:"Name Z-A"}),l.jsx("option",{value:"size-desc",children:"Largest first"}),l.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),l.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[l.jsx("button",{className:`p-2 ${V==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("grid"),title:"Grid view",children:l.jsx(o7,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${V==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("list"),title:"List view",children:l.jsx(zR,{className:"w-4 h-4"})}),l.jsx("button",{className:`p-2 ${V==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ee("calendar"),title:"Calendar view",children:l.jsx(coe,{className:"w-4 h-4"})})]})]}),ve&&l.jsxs(Le,{variant:"ghost",size:"sm",onClick:te,className:"text-bambu-gray hover:text-white",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Reset"]})]}),ne.length>0&&l.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&l.jsx("button",{onClick:()=>g(ue=>ue==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),l.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ne.map(ue=>l.jsx("button",{onClick:()=>B(ue),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ue)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ue},title:ue},ue))}),u.size>0&&l.jsxs("button",{onClick:L,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[l.jsx(Wt,{className:"w-3 h-3"}),"Clear"]})]})]})}),we?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):Z?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):V==="calendar"?l.jsx(Nt,{className:"p-6",children:l.jsx(wFe,{archives:Z||[],onArchiveClick:ue=>{i(ue.print_name||ue.filename),ee("grid")}})}):V==="grid"?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Z?.map(ue=>l.jsx(GVe,{archive:ue,printerName:ue.printer_id?$.get(ue.printer_id)||"Unknown":"No Printer",isSelected:C.has(ue.id),onSelect:Ne,selectionMode:oe,projects:he},ue.id))}):V==="list"?l.jsx(Nt,{children:l.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[l.jsx("div",{className:"col-span-1"}),l.jsx("div",{className:"col-span-4",children:"Name"}),l.jsx("div",{className:"col-span-2",children:"Printer"}),l.jsx("div",{className:"col-span-2",children:"Date"}),l.jsx("div",{className:"col-span-1",children:"Size"}),l.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),Z?.map(ue=>l.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${C.has(ue.id)?"bg-bambu-green/10":""}`,children:[l.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[oe&&l.jsx("button",{onClick:()=>Ne(ue.id),children:C.has(ue.id)?l.jsx(Vh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(gm,{className:"w-4 h-4 text-bambu-gray"})}),ue.thumbnail_path?l.jsx("img",{src:ke.getArchiveThumbnail(ue.id),alt:"",className:"w-10 h-10 object-cover rounded"}):l.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:l.jsx(gb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),l.jsxs("div",{className:"col-span-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white text-sm truncate",children:ue.print_name||ue.filename}),ue.timelapse_path&&l.jsx("span",{title:"Has timelapse",children:l.jsx(Zp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),ue.filament_type&&l.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:ue.filament_type}),ue.filament_color&&l.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:ue.filament_color.split(",").map((Ve,Ue)=>l.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Ve},title:Ve},Ue))})]})]}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:ue.printer_id?$.get(ue.printer_id)||"Unknown":"No Printer"}),l.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(ue.created_at).toLocaleDateString()}),l.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:gR(ue.file_size)}),l.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{const Ve=ue.print_name||ue.filename||"model",Ue=`${window.location.origin}${ke.getArchiveForSlicer(ue.id,Ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Ue)}`},title:"Open in Slicer",children:l.jsx(Aa,{className:"w-4 h-4"})}),ue.makerworld_url&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>window.open(ue.makerworld_url,"_blank"),title:"MakerWorld",children:l.jsx(v0,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{const Ve=document.createElement("a");Ve.href=ke.getArchiveDownload(ue.id),Ve.download=`${ue.print_name||ue.filename}.3mf`,Ve.click()},title:"Download",children:l.jsx(Ma,{className:"w-4 h-4"})})]})]},ue.id))]})}):null,S&&l.jsx(fFe,{onClose:()=>{A(!1),k([])},initialFiles:T}),q&&l.jsx(Qr,{title:"Delete Archives",message:`Are you sure you want to delete ${C.size} archive${C.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${C.size}`,variant:"danger",onConfirm:()=>{ht.mutate(Array.from(C)),R(!1)},onCancel:()=>R(!1)}),W&&l.jsx(xFe,{selectedIds:Array.from(C),existingTags:G,onClose:()=>K(!1)}),xe&&C.size>=2&&C.size<=5&&l.jsx($Ve,{archiveIds:Array.from(C),onClose:()=>{Ee(!1),D(new Set),j(!1)}})]})}function KVe(){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 lM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function lL(t){return"nodeType"in t}function ta(t){var e,n;return t?fg(t)?t:lL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function cL(t){const{Document:e}=ta(t);return t instanceof e}function ev(t){return fg(t)?!1:t instanceof ta(t).HTMLElement}function Uee(t){return t instanceof ta(t).SVGElement}function pg(t){return t?fg(t)?t.document:lL(t)?cL(t)?t:ev(t)||Uee(t)?t.ownerDocument:document:document:document}const yl=lM?M.useLayoutEffect:M.useEffect;function uL(t){const e=M.useRef(t);return yl(()=>{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 XVe(){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 cb(t,e){e===void 0&&(e=[t]);const n=M.useRef(t);return yl(()=>{n.current!==t&&(n.current=t)},e),n}function tv(t,e){const n=M.useRef();return M.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function NS(t){const e=uL(t),n=M.useRef(null),r=M.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function xR(t){const e=M.useRef();return M.useEffect(()=>{e.current=t},[t]),e.current}let a3={};function nv(t,e){return M.useMemo(()=>{if(e)return e;const n=a3[t]==null?0:a3[t]+1;return a3[t]=n,t+"-"+n},[t,e])}function Fee(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[c,u]of o){const d=s[c];d!=null&&(s[c]=d+t*u)}return s},{...e})}}const dm=Fee(1),ub=Fee(-1);function YVe(t){return"clientX"in t&&"clientY"in t}function dL(t){if(!t)return!1;const{KeyboardEvent:e}=ta(t.target);return e&&t instanceof e}function ZVe(t){if(!t)return!1;const{TouchEvent:e}=ta(t.target);return e&&t instanceof e}function bR(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 YVe(t)?{x:t.clientX,y:t.clientY}:null}const $m=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[$m.Translate.toString(t),$m.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),J9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function QVe(t){return t.matches(J9)?t:t.querySelector(J9)}const JVe={display:"none"};function e9e(t){let{id:e,value:n}=t;return mr.createElement("div",{id:e,style:JVe},n)}function t9e(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 n9e(){const[t,e]=M.useState("");return{announce:M.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const zee=M.createContext(null);function r9e(t){const e=M.useContext(zee);M.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function i9e(){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 s9e={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.
- `},a9e={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 o9e(t){let{announcements:e=a9e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=s9e}=t;const{announce:s,announcement:a}=n9e(),o=nv("DndLiveRegion"),[c,u]=M.useState(!1);if(M.useEffect(()=>{u(!0)},[]),r9e(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])),!c)return null;const d=mr.createElement(mr.Fragment,null,mr.createElement(e9e,{id:r,value:i.draggable}),mr.createElement(t9e,{id:o,announcement:a}));return n?hc.createPortal(d,n):d}var di;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(di||(di={}));function kS(){}function PS(t,e){return M.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Bee(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const zo=Object.freeze({x:0,y:0});function Hee(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function $ee(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function l9e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function eG(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 Vee(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function tG(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 Gee=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=tG(e,e.left,e.top),s=[];for(const a of r){const{id:o}=a,c=n.get(o);if(c){const u=Hee(tG(c),i);s.push({id:o,data:{droppableContainer:a,value:u}})}}return s.sort($ee)},c9e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=eG(e),s=[];for(const a of r){const{id:o}=a,c=n.get(o);if(c){const u=eG(c),d=i.reduce((g,m,x)=>g+Hee(u[x],m),0),f=Number((d/4).toFixed(4));s.push({id:o,data:{droppableContainer:a,value:f}})}}return s.sort($ee)};function u9e(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 c=e.width*e.height,u=t.width*t.height,d=a*o,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const d9e=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 c=u9e(o,e);c>0&&i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(l9e)};function h9e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Wee(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:zo}function f9e(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 p9e=f9e(1);function m9e(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 g9e(t,e,n){const r=m9e(e);if(!r)return t;const{scaleX:i,scaleY:s,x:a,y:o}=r,c=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:c+d,bottom:u+f,left:c}}const x9e={ignoreTransform:!1};function mg(t,e){e===void 0&&(e=x9e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ta(t).getComputedStyle(t);u&&(n=g9e(n,u,d))}const{top:r,left:i,width:s,height:a,bottom:o,right:c}=n;return{top:r,left:i,width:s,height:a,bottom:o,right:c}}function nG(t){return mg(t,{ignoreTransform:!0})}function b9e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function v9e(t,e){return e===void 0&&(e=ta(t).getComputedStyle(t)),e.position==="fixed"}function y9e(t,e){e===void 0&&(e=ta(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 cM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(cL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!ev(i)||Uee(i)||n.includes(i))return n;const s=ta(t).getComputedStyle(i);return i!==t&&y9e(i,s)&&n.push(i),v9e(i,s)?n:r(i.parentNode)}return t?r(t):n}function qee(t){const[e]=cM(t,1);return e??null}function o3(t){return!lM||!t?null:fg(t)?t:lL(t)?cL(t)||t===pg(t).scrollingElement?window:ev(t)?t:null:null}function Kee(t){return fg(t)?t.scrollX:t.scrollLeft}function Xee(t){return fg(t)?t.scrollY:t.scrollTop}function vR(t){return{x:Kee(t),y:Xee(t)}}var Oi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Oi||(Oi={}));function Yee(t){return!lM||!t?!1:t===document.scrollingElement}function Zee(t){const e={x:0,y:0},n=Yee(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 _9e={x:.2,y:.2};function w9e(t,e,n,r,i){let{top:s,left:a,right:o,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=_9e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=Zee(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=Oi.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(m.y=Oi.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!g&&o>=e.right-y.width?(m.x=Oi.Forward,x.x=r*Math.abs((e.right-y.width-o)/y.width)):!f&&a<=e.left+y.width&&(m.x=Oi.Backward,x.x=r*Math.abs((e.left+y.width-a)/y.width)),{direction:m,speed:x}}function S9e(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 Qee(t){return t.reduce((e,n)=>dm(e,vR(n)),zo)}function E9e(t){return t.reduce((e,n)=>e+Kee(n),0)}function M9e(t){return t.reduce((e,n)=>e+Xee(n),0)}function A9e(t,e){if(e===void 0&&(e=mg),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);qee(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const T9e=[["x",["left","right"],E9e],["y",["top","bottom"],M9e]];class hL{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=cM(n),i=Qee(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,o]of T9e)for(const c of a)Object.defineProperty(this,c,{get:()=>{const u=o(r),d=i[s]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class u0{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 C9e(t){const{EventTarget:e}=ta(t);return t instanceof e?t:pg(t)}function l3(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 Xa;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Xa||(Xa={}));function rG(t){t.preventDefault()}function N9e(t){t.stopPropagation()}var Sn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Sn||(Sn={}));const Jee={start:[Sn.Space,Sn.Enter],cancel:[Sn.Esc],end:[Sn.Space,Sn.Enter,Sn.Tab]},k9e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Sn.Right:return{...n,x:n.x+25};case Sn.Left:return{...n,x:n.x-25};case Sn.Down:return{...n,y:n.y+25};case Sn.Up:return{...n,y:n.y-25}}};class uM{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 u0(pg(n)),this.windowListeners=new u0(ta(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Xa.Resize,this.handleCancel),this.windowListeners.add(Xa.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Xa.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&A9e(r),n(zo)}handleKeyDown(e){if(dL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Jee,coordinateGetter:a=k9e,scrollBehavior:o="smooth"}=i,{code:c}=e;if(s.end.includes(c)){this.handleEnd(e);return}if(s.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:zo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=a(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=ub(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}=Zee(y),N=S9e(y),I={x:Math.min(v===Sn.Right?N.right-N.width/2:N.right,Math.max(v===Sn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(v===Sn.Down?N.bottom-N.height/2:N.bottom,Math.max(v===Sn.Down?N.top:N.top+N.height/2,f.y))},C=v===Sn.Right&&!E||v===Sn.Left&&!S,D=v===Sn.Down&&!A||v===Sn.Up&&!b;if(C&&I.x!==f.x){const F=y.scrollLeft+g.x,j=v===Sn.Right&&F<=T.x||v===Sn.Left&&F>=k.x;if(j&&!g.y){y.scrollTo({left:F,behavior:o});return}j?m.x=y.scrollLeft-F:m.x=v===Sn.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===Sn.Down&&F<=T.y||v===Sn.Up&&F>=k.y;if(j&&!g.x){y.scrollTo({top:F,behavior:o});return}j?m.y=y.scrollTop-F:m.y=v===Sn.Down?y.scrollTop-T.y:y.scrollTop-k.y,m.y&&y.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,dm(ub(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()}}uM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Jee,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 iG(t){return!!(t&&"distance"in t)}function sG(t){return!!(t&&"delay"in t)}class fL{constructor(e,n,r){var i;r===void 0&&(r=C9e(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=pg(a),this.documentListeners=new u0(this.document),this.listeners=new u0(r),this.windowListeners=new u0(ta(a)),this.initialCoordinates=(i=bR(s))!=null?i:zo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Xa.Resize,this.handleCancel),this.windowListeners.add(Xa.DragStart,rG),this.windowListeners.add(Xa.VisibilityChange,this.handleCancel),this.windowListeners.add(Xa.ContextMenu,rG),this.documentListeners.add(Xa.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(sG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(iG(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(Xa.Click,N9e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xa.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 c=(n=bR(e))!=null?n:zo,u=ub(i,c);if(!r&&o){if(iG(o)){if(o.tolerance!=null&&l3(u,o.tolerance))return this.handleCancel();if(l3(u,o.distance))return this.handleStart()}if(sG(o)&&l3(u,o.tolerance))return this.handleCancel();this.handlePending(o,u);return}e.cancelable&&e.preventDefault(),a(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Sn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const P9e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class dM extends fL{constructor(e){const{event:n}=e,r=pg(n.target);super(e,P9e,r)}}dM.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 R9e={move:{name:"mousemove"},end:{name:"mouseup"}};var yR;(function(t){t[t.RightClick=2]="RightClick"})(yR||(yR={}));class D9e extends fL{constructor(e){super(e,R9e,pg(e.event.target))}}D9e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===yR.RightClick?!1:(r?.({event:n}),!0)}}];const c3={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class O9e extends fL{constructor(e){super(e,c3)}static setup(){return window.addEventListener(c3.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(c3.move.name,e)};function e(){}}}O9e.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 d0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(d0||(d0={}));var RS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(RS||(RS={}));function j9e(t){let{acceleration:e,activator:n=d0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:a=5,order:o=RS.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const m=I9e({delta:f,disabled:!s}),[x,y]=XVe(),v=M.useRef({x:0,y:0}),b=M.useRef({x:0,y:0}),E=M.useMemo(()=>{switch(n){case d0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case d0.DraggableRect:return i}},[n,i,c]),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===RS.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}=w9e(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 L9e={x:{[Oi.Backward]:!1,[Oi.Forward]:!1},y:{[Oi.Backward]:!1,[Oi.Forward]:!1}};function I9e(t){let{delta:e,disabled:n}=t;const r=xR(e);return tv(i=>{if(n||!r||!i)return L9e;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Oi.Backward]:i.x[Oi.Backward]||s.x===-1,[Oi.Forward]:i.x[Oi.Forward]||s.x===1},y:{[Oi.Backward]:i.y[Oi.Backward]||s.y===-1,[Oi.Forward]:i.y[Oi.Forward]||s.y===1}}},[n,e,r])}function U9e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return tv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function F9e(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 db;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(db||(db={}));var _R;(function(t){t.Optimized="optimized"})(_R||(_R={}));const aG=new Map;function z9e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,a]=M.useState(null),{frequency:o,measure:c,strategy:u}=i,d=M.useRef(t),f=v(),g=cb(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=tv(b=>{if(f&&!n)return aG;if(!b||b===aG||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 hL(c(A),A):null;S.rect.current=T,T&&E.set(S.id,T)}return E}return b},[t,s,n,f,c]);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 db.Always:return!1;case db.BeforeDragging:return n;default:return!n}}}function ete(t,e){return tv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function B9e(t,e){return ete(t,e)}function H9e(t){let{callback:e,disabled:n}=t;const r=uL(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 hM(t){let{callback:e,disabled:n}=t;const r=uL(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 $9e(t){return new hL(mg(t),t)}function oG(t,e,n){e===void 0&&(e=$9e);const[r,i]=M.useState(null);function s(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const a=H9e({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){s();break}}}}),o=hM({callback:s});return yl(()=>{s(),t?(o?.observe(t),a?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),a?.disconnect())},[t]),r}function V9e(t){const e=ete(t);return Wee(t,e)}const lG=[];function G9e(t){const e=M.useRef(t),n=tv(r=>t?r&&r!==lG&&t&&e.current&&t.parentNode===e.current.parentNode?r:cM(t):lG,[t]);return M.useEffect(()=>{e.current=t},[t]),n}function W9e(t){const[e,n]=M.useState(null),r=M.useRef(t),i=M.useCallback(s=>{const a=o3(s.target);a&&n(o=>o?(o.set(a,vR(a)),new Map(o)):null)},[]);return M.useEffect(()=>{const s=r.current;if(t!==s){a(s);const o=t.map(c=>{const u=o3(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,vR(u)]):null}).filter(c=>c!=null);n(o.length?new Map(o):null),r.current=t}return()=>{a(t),a(s)};function a(o){o.forEach(c=>{const u=o3(c);u?.removeEventListener("scroll",i)})}},[i,t]),M.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,a)=>dm(s,a),zo):Qee(t):zo,[t,e])}function cG(t,e){e===void 0&&(e=[]);const n=M.useRef(null);return M.useEffect(()=>{n.current=null},e),M.useEffect(()=>{const r=t!==zo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?ub(t,n.current):zo}function q9e(t){M.useEffect(()=>{if(!lM)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 K9e(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 tte(t){return M.useMemo(()=>t?b9e(t):null,[t])}const uG=[];function X9e(t,e){e===void 0&&(e=mg);const[n]=t,r=tte(n?ta(n):null),[i,s]=M.useState(uG);function a(){s(()=>t.length?t.map(c=>Yee(c)?r:new hL(e(c),c)):uG)}const o=hM({callback:a});return yl(()=>{o?.disconnect(),a(),t.forEach(c=>o?.observe(c))},[t]),i}function Y9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return ev(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(ev(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),s=hM({callback:i}),a=M.useCallback(u=>{const d=Y9e(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[o,c]=NS(a);return M.useMemo(()=>({nodeRef:o,rect:n,setRef:c}),[n,o,c])}const Q9e=[{sensor:dM,options:{}},{sensor:uM,options:{}}],J9e={current:{}},y1={draggable:{measure:nG},droppable:{measure:nG,strategy:db.WhileDragging,frequency:_R.Optimized},dragOverlay:{measure:mg}};class h0 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 eGe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new h0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:kS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:y1,measureDroppableContainers:kS,windowRect:null,measuringScheduled:!1},tGe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:kS,draggableNodes:new Map,over:null,measureDroppableContainers:kS},fM=M.createContext(tGe),nte=M.createContext(eGe);function nGe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new h0}}}function rGe(t,e){switch(e.type){case di.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case di.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case di.DragEnd:case di.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case di.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new h0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case di.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,s=t.droppable.containers.get(n);if(!s||r!==s.key)return t;const a=new h0(t.droppable.containers);return a.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:a}}}case di.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new h0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function iGe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=M.useContext(fM),s=xR(r),a=xR(n?.id);return M.useEffect(()=>{if(!e&&!r&&s&&a!=null){if(!dL(s)||document.activeElement===s.target)return;const o=i.get(a);if(!o)return;const{activatorNode:c,node:u}=o;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=QVe(d);if(f){f.focus();break}}})}},[r,e,i,a,s]),null}function sGe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function aGe(t){return M.useMemo(()=>({draggable:{...y1.draggable,...t?.draggable},droppable:{...y1.droppable,...t?.droppable},dragOverlay:{...y1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function oGe(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;yl(()=>{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=Wee(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=qee(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,a,o,r,n])}const rte=M.createContext({...zo,scaleX:1,scaleY:1});var Ou;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ou||(Ou={}));const ite=M.memo(function(e){var n,r,i,s;let{id:a,accessibility:o,autoScroll:c=!0,children:u,sensors:d=Q9e,collisionDetection:f=d9e,measuring:g,modifiers:m,...x}=e;const y=M.useReducer(rGe,void 0,nGe),[v,b]=y,[E,S]=i9e(),[A,T]=M.useState(Ou.Uninitialized),k=A===Ou.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 Fe;return N!=null?{id:N,data:(Fe=F?.data)!=null?Fe:J9e,rect:j}:null},[N,F]),R=M.useRef(null),[W,K]=M.useState(null),[V,ee]=M.useState(null),Y=cb(x,Object.values(x)),Q=nv("DndDescribedBy",a),U=M.useMemo(()=>D.getEnabled(),[D]),z=aGe(g),{droppableRects:J,measureDroppableContainers:se,measuringScheduled:me}=z9e(U,{dragging:k,dependencies:[C.x,C.y],config:z.droppable}),fe=U9e(I,N),xe=M.useMemo(()=>V?bR(V):null,[V]),Ee=ge(),re=B9e(fe,z.draggable.measure);oGe({activeNode:N!=null?I.get(N):null,config:Ee.layoutShiftCompensation,initialRect:re,measure:z.draggable.measure});const we=oG(fe,z.draggable.measure,re),Oe=oG(fe?fe.parentElement:null),he=M.useRef({activatorEvent:null,active:null,activeNode:fe,collisionRect:null,collisions:null,droppableRects:J,draggableNodes:I,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ht=D.getNodeFor((n=he.current.over)==null?void 0:n.id),$=Z9e({measure:z.dragOverlay.measure}),H=(r=$.nodeRef.current)!=null?r:fe,ne=k?(i=$.rect)!=null?i:we:null,G=!!($.nodeRef.current&&$.rect),Z=V9e(G?null:we),oe=tte(H?ta(H):null),Ne=G9e(k?ht??fe:null),Pe=X9e(Ne),Se=sGe(m,{transform:{x:C.x-Z.x,y:C.y-Z.y,scaleX:1,scaleY:1},activatorEvent:V,active:q,activeNodeRect:we,containerNodeRect:Oe,draggingNodeRect:ne,over:he.current.over,overlayNodeRect:$.rect,scrollableAncestors:Ne,scrollableAncestorRects:Pe,windowRect:oe}),B=xe?dm(xe,C):null,L=W9e(Ne),te=cG(L),ve=cG(L,[we]),_e=dm(Se,te),be=ne?p9e(ne,Se):null,nt=q&&be?f({active:q,collisionRect:be,droppableRects:J,droppableContainers:U,pointerCoordinates:B}):null,Be=Vee(nt,"id"),[ue,Ve]=M.useState(null),Ue=G?Se:dm(Se,ve),ae=h9e(Ue,(s=ue?.rect)!=null?s:null,we),Je=M.useRef(null),He=M.useCallback((Fe,Ce)=>{let{sensor:ye,options:ce}=Ce;if(R.current==null)return;const at=I.get(R.current);if(!at)return;const xt=Fe.nativeEvent,St=new ye({active:R.current,activeNode:at,event:xt,options:ce,context:he,onAbort(jt){if(!I.get(jt))return;const{onDragAbort:jn}=Y.current,Ei={id:jt};jn?.(Ei),E({type:"onDragAbort",event:Ei})},onPending(jt,Vt,jn,Ei){if(!I.get(jt))return;const{onDragPending:Mi}=Y.current,zi={id:jt,constraint:Vt,initialCoordinates:jn,offset:Ei};Mi?.(zi),E({type:"onDragPending",event:zi})},onStart(jt){const Vt=R.current;if(Vt==null)return;const jn=I.get(Vt);if(!jn)return;const{onDragStart:Ei}=Y.current,ai={activatorEvent:xt,active:{id:Vt,data:jn.data,rect:j}};hc.unstable_batchedUpdates(()=>{Ei?.(ai),T(Ou.Initializing),b({type:di.DragStart,initialCoordinates:jt,active:Vt}),E({type:"onDragStart",event:ai}),K(Je.current),ee(xt)})},onMove(jt){b({type:di.DragMove,coordinates:jt})},onEnd:Qt(di.DragEnd),onCancel:Qt(di.DragCancel)});Je.current=St;function Qt(jt){return async function(){const{active:jn,collisions:Ei,over:ai,scrollAdjustedTranslate:Mi}=he.current;let zi=null;if(jn&&Mi){const{cancelDrop:rs}=Y.current;zi={activatorEvent:xt,active:jn,collisions:Ei,delta:Mi,over:ai},jt===di.DragEnd&&typeof rs=="function"&&await Promise.resolve(rs(zi))&&(jt=di.DragCancel)}R.current=null,hc.unstable_batchedUpdates(()=>{b({type:jt}),T(Ou.Uninitialized),Ve(null),K(null),ee(null),Je.current=null;const rs=jt===di.DragEnd?"onDragEnd":"onDragCancel";if(zi){const Hr=Y.current[rs];Hr?.(zi),E({type:rs,event:zi})}})}}},[I]),Ke=M.useCallback((Fe,Ce)=>(ye,ce)=>{const at=ye.nativeEvent,xt=I.get(ce);if(R.current!==null||!xt||at.dndKit||at.defaultPrevented)return;const St={active:xt};Fe(ye,Ce.options,St)===!0&&(at.dndKit={capturedBy:Ce.sensor},R.current=ce,He(ye,Ce))},[I,He]),ct=F9e(d,Ke);q9e(d),yl(()=>{we&&A===Ou.Initializing&&T(Ou.Initialized)},[we,A]),M.useEffect(()=>{const{onDragMove:Fe}=Y.current,{active:Ce,activatorEvent:ye,collisions:ce,over:at}=he.current;if(!Ce||!ye)return;const xt={active:Ce,activatorEvent:ye,collisions:ce,delta:{x:_e.x,y:_e.y},over:at};hc.unstable_batchedUpdates(()=>{Fe?.(xt),E({type:"onDragMove",event:xt})})},[_e.x,_e.y]),M.useEffect(()=>{const{active:Fe,activatorEvent:Ce,collisions:ye,droppableContainers:ce,scrollAdjustedTranslate:at}=he.current;if(!Fe||R.current==null||!Ce||!at)return;const{onDragOver:xt}=Y.current,St=ce.get(Be),Qt=St&&St.rect.current?{id:St.id,rect:St.rect.current,data:St.data,disabled:St.disabled}:null,jt={active:Fe,activatorEvent:Ce,collisions:ye,delta:{x:at.x,y:at.y},over:Qt};hc.unstable_batchedUpdates(()=>{Ve(Qt),xt?.(jt),E({type:"onDragOver",event:jt})})},[Be]),yl(()=>{he.current={activatorEvent:V,active:q,activeNode:fe,collisionRect:be,collisions:nt,droppableRects:J,draggableNodes:I,draggingNode:H,draggingNodeRect:ne,droppableContainers:D,over:ue,scrollableAncestors:Ne,scrollAdjustedTranslate:_e},j.current={initial:ne,translated:be}},[q,fe,nt,be,I,H,ne,J,D,ue,Ne,_e]),j9e({...Ee,delta:C,draggingRect:be,pointerCoordinates:B,scrollableAncestors:Ne,scrollableAncestorRects:Pe});const de=M.useMemo(()=>({active:q,activeNode:fe,activeNodeRect:we,activatorEvent:V,collisions:nt,containerNodeRect:Oe,dragOverlay:$,draggableNodes:I,droppableContainers:D,droppableRects:J,over:ue,measureDroppableContainers:se,scrollableAncestors:Ne,scrollableAncestorRects:Pe,measuringConfiguration:z,measuringScheduled:me,windowRect:oe}),[q,fe,we,V,nt,Oe,$,I,D,J,ue,se,Ne,Pe,z,me,oe]),Ye=M.useMemo(()=>({activatorEvent:V,activators:ct,active:q,activeNodeRect:we,ariaDescribedById:{draggable:Q},dispatch:b,draggableNodes:I,over:ue,measureDroppableContainers:se}),[V,ct,q,we,b,Q,I,ue,se]);return mr.createElement(zee.Provider,{value:S},mr.createElement(fM.Provider,{value:Ye},mr.createElement(nte.Provider,{value:de},mr.createElement(rte.Provider,{value:ae},u)),mr.createElement(iGe,{disabled:o?.restoreFocus===!1})),mr.createElement(o9e,{...o,hiddenTextDescribedById:Q}));function ge(){const Fe=W?.autoScrollEnabled===!1,Ce=typeof c=="object"?c.enabled===!1:c===!1,ye=k&&!Fe&&!Ce;return typeof c=="object"?{...c,enabled:ye}:{enabled:ye}}}),lGe=M.createContext(null),dG="button",cGe="Draggable";function uGe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=nv(cGe),{activators:a,activatorEvent:o,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=M.useContext(fM),{role:m=dG,roleDescription:x="draggable",tabIndex:y=0}=i??{},v=c?.id===e,b=M.useContext(v?rte:lGe),[E,S]=NS(),[A,T]=NS(),k=K9e(a,e),N=cb(n);yl(()=>(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===dG?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,y,v,x,d.draggable]);return{active:c,activatorEvent:o,activeNodeRect:u,attributes:I,isDragging:v,listeners:r?void 0:k,node:E,over:g,setNodeRef:S,setActivatorNodeRef:T,transform:b}}function dGe(){return M.useContext(nte)}const hGe="Droppable",fGe={timeout:25};function pGe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=nv(hGe),{active:a,dispatch:o,over:c,measureDroppableContainers:u}=M.useContext(fM),d=M.useRef({disabled:n}),f=M.useRef(!1),g=M.useRef(null),m=M.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:v}={...fGe,...i},b=cb(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=hM({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]=NS(A),N=cb(e);return M.useEffect(()=>{!S||!T.current||(S.disconnect(),f.current=!1,S.observe(T.current))},[T,S]),M.useEffect(()=>(o({type:di.RegisterDroppable,element:{id:r,key:s,disabled:n,node:T,rect:g,data:N}}),()=>o({type:di.UnregisterDroppable,key:s,id:r})),[r]),M.useEffect(()=>{n!==d.current.disabled&&(o({type:di.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,o]),{active:a,rect:g,isOver:c?.id===r,node:T,over:c,setNodeRef:k}}function pM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function mGe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function W_(t){return t!==null&&t>=0}function gGe(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 xGe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const pL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=pM(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}},q_={scaleX:1,scaleY:1},bGe=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,...q_}:null}const c=vGe(s,i,n);return i>n&&i<=a?{x:0,y:-o.height-c,...q_}:i<n&&i>=a?{x:0,y:o.height+c,...q_}:{x:0,y:0,...q_}};function vGe(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 ste="Sortable",ate=mr.createContext({activeIndex:-1,containerId:ste,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:pL,disabled:{draggable:!1,droppable:!1}});function ote(t){let{children:e,id:n,items:r,strategy:i=pL,disabled:s=!1}=t;const{active:a,dragOverlay:o,droppableRects:c,over:u,measureDroppableContainers:d}=dGe(),f=nv(ste,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=!gGe(m,b.current),S=v!==-1&&y===-1||E,A=xGe(s);yl(()=>{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:mGe(m,c),strategy:i}),[y,f,A.draggable,A.droppable,S,m,v,c,g,i]);return mr.createElement(ate.Provider,{value:T},e)}const yGe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return pM(n,r,i).indexOf(e)},_Ge=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:s,newIndex:a,previousItems:o,previousContainerId:c,transition:u}=t;return!u||!r||o!==s&&i===a?!1:n?!0:a!==i&&e===c},wGe={duration:200,easing:"ease"},lte="transform",SGe=$m.Transition.toString({property:lte,duration:0,easing:"linear"}),EGe={roleDescription:"sortable"};function MGe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,a]=M.useState(null),o=M.useRef(n);return yl(()=>{if(!e&&n!==o.current&&r.current){const c=i.current;if(c){const u=mg(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&a(d)}}n!==o.current&&(o.current=n)},[e,n,r,i]),M.useEffect(()=>{s&&a(null)},[s]),s}function cte(t){let{animateLayoutChanges:e=_Ge,attributes:n,disabled:r,data:i,getNewIndex:s=yGe,id:a,strategy:o,resizeObserverConfig:c,transition:u=wGe}=t;const{items:d,containerId:f,activeIndex:g,disabled:m,disableTransforms:x,sortedRects:y,overIndex:v,useDragOverlay:b,strategy:E}=M.useContext(ate),S=AGe(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}=pGe({id:a,data:T,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:F,activatorEvent:j,activeNodeRect:q,attributes:R,setNodeRef:W,listeners:K,isDragging:V,over:ee,setActivatorNodeRef:Y,transform:Q}=uGe({id:a,data:T,attributes:{...EGe,...n},disabled:S.draggable}),U=KVe(D,W),z=!!F,J=z&&!x&&W_(g)&&W_(v),se=!b&&V,me=se&&J?Q:null,xe=J?me??(o??E)({rects:y,activeNodeRect:q,activeIndex:g,overIndex:v,index:A}):null,Ee=W_(g)&&W_(v)?s({id:a,items:d,activeIndex:g,overIndex:v}):A,re=F?.id,we=M.useRef({activeId:re,items:d,newIndex:Ee,containerId:f}),Oe=d!==we.current.items,he=e({active:F,containerId:f,isDragging:V,isSorting:z,id:a,index:A,items:d,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:u,wasDragging:we.current.activeId!=null}),ht=MGe({disabled:!he,index:A,node:I,rect:N});return M.useEffect(()=>{z&&we.current.newIndex!==Ee&&(we.current.newIndex=Ee),f!==we.current.containerId&&(we.current.containerId=f),d!==we.current.items&&(we.current.items=d)},[z,Ee,f,d]),M.useEffect(()=>{if(re===we.current.activeId)return;if(re!=null&&we.current.activeId==null){we.current.activeId=re;return}const H=setTimeout(()=>{we.current.activeId=re},50);return()=>clearTimeout(H)},[re]),{active:F,activeIndex:g,attributes:R,data:T,rect:N,index:A,newIndex:Ee,items:d,isOver:C,isSorting:z,isDragging:V,listeners:K,node:I,overIndex:v,over:ee,setNodeRef:U,setActivatorNodeRef:Y,setDroppableNodeRef:D,setDraggableNodeRef:W,transform:ht??xe,transition:$()};function $(){if(ht||Oe&&we.current.newIndex===A)return SGe;if(!(se&&!dL(j)||!u)&&(z||he))return $m.Transition.toString({...u,property:lte})}}function AGe(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 DS(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 TGe=[Sn.Down,Sn.Right,Sn.Up,Sn.Left],ute=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:a,scrollableAncestors:o}}=e;if(TGe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case Sn.Down:r.top<g.top&&c.push(f);break;case Sn.Up:r.top>g.top&&c.push(f);break;case Sn.Left:r.left>g.left&&c.push(f);break;case Sn.Right:r.left<g.left&&c.push(f);break}});const u=c9e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Vee(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=cM(x).some((k,N)=>o[N]!==k),b=dte(f,g),E=CGe(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:ub(A,S)}}}};function dte(t,e){return!DS(t)||!DS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function CGe(t,e){return!DS(t)||!DS(e)||!dte(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function NGe({item:t,onClose:e}){const n=Mn(),{showToast:r}=si(),[i,s]=M.useState(t.printer_id),a=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,c]=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:()=>ke.getPrinters()});M.useEffect(()=>{const S=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e]);const v=wt({mutationFn:S=>ke.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 l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsx(Nt,{className:"w-full max-w-md",onClick:S=>S.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(rd,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),l.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),"No printers configured"]}):l.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:S=>s(Number(S.target.value)),required:!0,children:y?.map(S=>l.jsx("option",{value:S.id,children:S.name},S.id))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[l.jsx(_r,{className:"w-4 h-4"}),"ASAP (when idle)"]}),l.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[l.jsx(Zr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),l.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:S=>d(S.target.value),min:E(),required:!0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:S=>g(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:S=>x(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),l.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[l.jsx(bd,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsx(Le,{type:"submit",className:"flex-1",disabled:v.isPending||y?.length===0,children:v.isPending?"Saving...":"Save Changes"})]})]})]})})})}function hte(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 kGe(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 PGe({status:t}){const e={pending:{icon:_r,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:BS,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:fi,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:ga,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:N1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Wt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return l.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[l.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function u3({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:s,onRequeue:a}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=cte({id:t.id,disabled:t.status!=="pending"}),m={transform:$m.Transform.toString(d),transition:f},x=t.status==="printing",y=t.status==="pending",v=["completed","failed","skipped","cancelled"].includes(t.status);return l.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:l.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?l.jsx("div",{...o,...c,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:l.jsx(y0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?l.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):l.jsx("div",{className:"w-8"}),l.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?l.jsx("img",{src:ke.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:l.jsx($h,{className:"w-6 h-6"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),l.jsx(IS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:l.jsx(Aa,{className:"w-3.5 h-3.5"})})]}),l.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Ta,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(Fu,{className:"w-3.5 h-3.5"}),hte(t.print_time_seconds)]}),y&&l.jsxs("span",{className:"flex items-center gap-1.5",children:[l.jsx(_r,{className:"w-3.5 h-3.5"}),kGe(t.scheduled_time)]})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&l.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&l.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[l.jsx(bd,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&l.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[l.jsx(lo,{className:"w-3 h-3"}),t.error_message]})]}),l.jsx(PGe,{status:t.status}),l.jsxs("div",{className:"flex items-center gap-1",children:[x&&l.jsx(Le,{variant:"ghost",size:"sm",onClick:s,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Toe,{className:"w-4 h-4"})}),y&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:l.jsx(rd,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),v&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{variant:"ghost",size:"sm",onClick:a,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:l.jsx(Cs,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})})}function RGe(){const t=Mn(),{showToast:e}=si(),[n,r]=M.useState(null),[i,s]=M.useState(""),[a,o]=M.useState(!1),[c,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=Bee(PS(dM,{activationConstraint:{distance:8}}),PS(uM,{coordinateGetter:ute})),{data:T,isLoading:k}=yt({queryKey:["queue",n,i],queryFn:()=>ke.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:N}=yt({queryKey:["printers"],queryFn:()=>ke.getPrinters()}),I=wt({mutationFn:Y=>ke.cancelQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),C=wt({mutationFn:Y=>ke.removeFromQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),D=wt({mutationFn:Y=>ke.stopQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=wt({mutationFn:Y=>ke.reorderQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),j=wt({mutationFn:Y=>{const Q=new Date;return Q.setFullYear(Q.getFullYear()+1),ke.addToQueue({printer_id:Y.printer_id,archive_id:Y.archive_id,scheduled_time:Q.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=wt({mutationFn:async()=>{const Y=T?.filter(Q=>["completed","failed","skipped","cancelled"].includes(Q.status))||[];for(const Q of Y)await ke.removeFromQueue(Q.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")||[],Q=U=>{if(!U.scheduled_time)return 0;const z=new Date(U.scheduled_time).getTime(),J=Date.now()+4320*60*60*1e3;return z>J?0:z};return[...Y].sort((U,z)=>{let J;return v==="name"?J=(U.archive_name||"").localeCompare(z.archive_name||""):v==="printer"?J=(U.printer_name||"").localeCompare(z.printer_name||""):v==="time"?J=Q(U)-Q(z):J=U.position-z.position,E?J:-J})},[T,v,E]),W=T?.filter(Y=>Y.status==="printing")||[],K=M.useMemo(()=>[...T?.filter(Q=>["completed","failed","skipped","cancelled"].includes(Q.status))||[]].sort((Q,U)=>{let z;return g==="name"?z=(Q.archive_name||"").localeCompare(U.archive_name||""):g==="printer"?z=(Q.printer_name||"").localeCompare(U.printer_name||""):z=new Date(U.completed_at||U.created_at).getTime()-new Date(Q.completed_at||Q.created_at).getTime(),x?-z:z}),[T,g,x]),V=M.useMemo(()=>R.reduce((Y,Q)=>Y+(Q.print_time_seconds||0),0),[R]),ee=Y=>{const{active:Q,over:U}=Y;if(!U||Q.id===U.id)return;const z=R.findIndex(se=>se.id===Q.id),J=R.findIndex(se=>se.id===U.id);if(z!==-1&&J!==-1){const me=pM(R,z,J).map((fe,xe)=>({id:fe.id,position:xe+1}));F.mutate(me)}};return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsx("div",{className:"flex items-center justify-between mb-8",children:l.jsxs("div",{children:[l.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[l.jsx(l7,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),l.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[l.jsx(Nt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:l.jsx(BS,{className:"w-5 h-5 text-blue-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:l.jsx(_r,{className:"w-5 h-5 text-yellow-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:R.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:l.jsx(Fu,{className:"w-5 h-5 text-bambu-green"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:hte(V)}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),l.jsx(Nt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:l.jsx(Rt,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:l.jsx(fi,{className:"w-5 h-5 text-gray-400"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),l.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Y=>r(Y.target.value?Number(Y.target.value):null),children:[l.jsx("option",{value:"",children:"All Printers"}),N?.map(Y=>l.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),l.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:Y=>s(Y.target.value),children:[l.jsx("option",{value:"",children:"All Status"}),l.jsx("option",{value:"pending",children:"Pending"}),l.jsx("option",{value:"printing",children:"Printing"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"failed",children:"Failed"}),l.jsx("option",{value:"skipped",children:"Skipped"}),l.jsx("option",{value:"cancelled",children:"Cancelled"})]}),l.jsx("div",{className:"flex-1"}),K.length>0&&l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear History"]})]}),k?l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?l.jsxs(Nt,{className:"p-12 text-center border-dashed",children:[l.jsx(Zr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),l.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),l.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):l.jsxs("div",{className:"space-y-8",children:[W.length>0&&l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),l.jsx("div",{className:"space-y-3",children:W.map(Y=>l.jsx(u3,{item:Y,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>f({type:"stop",item:Y}),onRequeue:()=>{}},Y.id))})]}),R.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(_r,{className:"w-5 h-5 text-yellow-400"}),"Queued",l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",R.length," item",R.length!==1?"s":"",")"]}),l.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v,onChange:Y=>b(Y.target.value),children:[l.jsx("option",{value:"position",children:"Sort by Position"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"}),l.jsx("option",{value:"time",children:"Sort by Schedule"})]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>S(!E),title:E?"Ascending":"Descending",className:"px-2",children:E?l.jsx(hm,{className:"w-4 h-4"}):l.jsx(x0,{className:"w-4 h-4"})})]})]}),l.jsx(ite,{sensors:A,collisionDetection:Gee,onDragEnd:ee,children:l.jsx(ote,{items:R.map(Y=>Y.id),strategy:bGe,children:l.jsx("div",{className:"space-y-3",children:R.map((Y,Q)=>l.jsx(u3,{item:Y,position:Q+1,onEdit:()=>u(Y),onCancel:()=>f({type:"cancel",item:Y}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Y.id))})})})]}),K.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(fi,{className:"w-5 h-5 text-bambu-gray"}),"History",l.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:g,onChange:Y=>m(Y.target.value),children:[l.jsx("option",{value:"date",children:"Sort by Date"}),l.jsx("option",{value:"name",children:"Sort by Name"}),l.jsx("option",{value:"printer",children:"Sort by Printer"})]}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>y(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?l.jsx(hm,{className:"w-4 h-4"}):l.jsx(x0,{className:"w-4 h-4"})})]})]}),l.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((Y,Q)=>l.jsx(u3,{item:Y,position:Q+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Y}),onStop:()=>{},onRequeue:()=>j.mutate(Y)},Y.id))})]})]}),c&&l.jsx(NGe,{item:c,onClose:()=>u(null)}),d&&l.jsx(Qr,{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&&l.jsx(Qr,{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 DGe({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=M.useMemo(()=>{const c={};t.forEach(b=>{const E=b.split("T")[0];c[E]=(c[E]||0)+1});const u=new Date,d=new Date(u);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const f=[],g=[];let 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:c}},[t,e]),s=Math.max(1,...Object.values(i)),a=c=>{if(c===0)return"bg-bambu-dark";const u=c/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 l.jsxs("div",{className:"overflow-x-auto",children:[l.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:c,weekIndex:u},d)=>l.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(u-(r[d-1]?.weekIndex||0))*14-24}px`},children:c},d))}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((c,u)=>l.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:u%2===1?"visible":"hidden"},children:c},c))}),n.map((c,u)=>l.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=c.find(y=>y.getDay()===d);if(!f)return l.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 l.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))]}),l.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[l.jsx("span",{children:"Less"}),l.jsxs("div",{className:"flex gap-0.5",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),l.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),l.jsx("span",{children:"More"})]})]})}const K_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function OGe(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 jGe({archives:t,currency:e="$"}){const[n,r]=M.useState("30d"),i=M.useMemo(()=>{const g=OGe(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]),c=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 l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),l.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>l.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),l.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),l.jsx(n1,{width:"100%",height:250,children:l.jsxs(JTe,{data:u,children:[l.jsx("defs",{children:l.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[l.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),l.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),l.jsx(ww,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),l.jsx(Ew,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),l.jsx(Mw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),l.jsx(yY,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):l.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(n1,{width:160,height:160,children:l.jsxs(ZTe,{children:[l.jsx(VX,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((g,m)=>l.jsx($b,{fill:K_[m%K_.length]},`cell-${m}`))}),l.jsx(i1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),l.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((g,m)=>{const x=o.reduce((v,b)=>v+b.value,0),y=x>0?(g.value/x*100).toFixed(0):0;return l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:K_[m%K_.length]}}),l.jsx("span",{className:"text-white truncate flex-1",children:g.name}),l.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):l.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[l.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),l.jsx(n1,{width:"100%",height:200,children:l.jsxs(FTe,{data:c,children:[l.jsx(ww,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),l.jsx(Ew,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),l.jsx(Mw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),l.jsx(i1,{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"]}),l.jsx(bD,{}),l.jsx(YX,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function LGe({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:a}){const{attributes:o,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=cte({id:t}),m={transform:$m.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:l.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:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{...o,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:l.jsx(y0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),l.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("button",{onClick: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?l.jsx(uce,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):l.jsx(nce,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),l.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:l.jsx(LR,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),l.jsx("div",{className:"p-4",children:n})]})}function IGe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:s}){const a=()=>{const A={};return t.forEach(T=>{A[T.id]=T.defaultSize||4}),A},[o,c]=M.useState(()=>{const A=localStorage.getItem(e);if(A)try{const T=JSON.parse(A);return T.sizes||(T.sizes=a()),T}catch{}return{order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:a()}}),[u,d]=M.useState(!1);M.useEffect(()=>{const A=()=>d(T=>!T);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),M.useEffect(()=>{localStorage.setItem(e,JSON.stringify(o))},[o,e]),M.useEffect(()=>{const T=t.map(k=>k.id).filter(k=>!o.order.includes(k));T.length>0&&c(k=>({...k,order:[...k.order,...T]}))},[t,o.order]);const f=Bee(PS(dM,{activationConstraint:{distance:8}}),PS(uM,{coordinateGetter:ute})),g=A=>{const{active:T,over:k}=A;k&&T.id!==k.id&&c(N=>{const I=N.order.indexOf(T.id),C=N.order.indexOf(k.id);return{...N,order:pM(N.order,I,C)}})},m=A=>{c(T=>({...T,hidden:T.hidden.includes(A)?T.hidden.filter(k=>k!==A):[...T.hidden,A]}))},x=A=>{c(T=>{const k=T.sizes[A]||4,N=k===1?2:k===2?4:1;return{...T,sizes:{...T.sizes,[A]:N}}})},y=()=>{const A={order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:a()};c(A),i?.()},v=o.order.map(A=>t.find(T=>T.id===A)).filter(Boolean),b=v.filter(A=>!o.hidden.includes(A.id)),E=v.filter(A=>o.hidden.includes(A.id)),S=s?.({hiddenCount:E.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return l.jsxs("div",{className:"space-y-4",children:[S,!r&&!s&&l.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l.jsxs(Le,{variant:"secondary",size:"sm",onClick:y,children:[l.jsx(Xm,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[l.jsx(mm,{className:"w-4 h-4"}),E.length," Hidden"]})]}),u&&E.length>0&&l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(A=>l.jsxs("button",{onClick:()=>m(A.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[l.jsx(mm,{className:"w-3 h-3"}),A.title]},A.id))})]}),l.jsx(ite,{sensors:f,collisionDetection:Gee,onDragEnd:g,children:l.jsx(ote,{items:b.map(A=>A.id),strategy:pL,children:l.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(A=>l.jsx(LGe,{id:A.id,title:A.title,isHidden:o.hidden.includes(A.id),size:o.sizes[A.id]||2,onToggleVisibility:()=>m(A.id),onToggleSize:()=>x(A.id),children:A.component},A.id))})})}),b.length===0&&l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx("p",{children:"All widgets are hidden."}),l.jsx(Le,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function UGe({stats:t,currency:e}){return l.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:l.jsx(w0,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),l.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:l.jsx(_r,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:l.jsx(w0,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:l.jsx(C3,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:l.jsx(bm,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:l.jsx(C3,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),l.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function FGe({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),l.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ga,{className:"w-4 h-4 text-red-400"}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),l.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function zGe({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,a=(c=>c>=95&&c<=105?"#00ae42":c>105?"#3b82f6":"#f97316")(n),o=n-100;return l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-28 h-28",children:[l.jsxs("svg",{className:"w-full h-full -rotate-90",children:[l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),l.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:a,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),l.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[l.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),l.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),l.jsxs("div",{className:"space-y-2 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[l.jsx(d7,{className:"w-3 h-3"}),l.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&l.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([c,u])=>l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(c)||`Printer ${c}`}),l.jsxs("span",{className:`font-medium ${u>=95&&u<=105?"text-bambu-green":u>105?"text-blue-400":"text-orange-400"}`,children:[u.toFixed(0),"%"]})]},c))})]})]})}function BGe({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,r])=>r-n);return l.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-white",children:n}),l.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:l.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function HGe({printDates:t}){return l.jsx(DGe,{printDates:t,months:4})}function $Ge({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:l.jsx(Ta,{className:"w-4 h-4 text-bambu-green"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function VGe({archives:t,currency:e}){return!t||t.length===0?l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):l.jsx(jGe,{archives:t,currency:e})}function GGe(){const{data:t,isLoading:e}=yt({queryKey:["failureAnalysis"],queryFn:()=>ke.getFailureAnalysis({days:30})});if(e)return l.jsx("div",{className:"flex justify-center py-4",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!t||t.total_prints===0)return l.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const n=Object.entries(t.failures_by_reason).sort(([,r],[,i])=>i-r).slice(0,5);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ti,{className:`w-5 h-5 ${t.failure_rate>20?"text-red-400":t.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),l.jsxs("span",{className:"text-2xl font-bold text-white",children:[t.failure_rate.toFixed(1),"%"]}),l.jsx("span",{className:"text-sm text-bambu-gray",children:"failure rate"})]}),l.jsxs("div",{className:"text-sm text-bambu-gray",children:[t.failed_prints," / ",t.total_prints," prints failed"]})]}),n.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray font-medium",children:"Top Failure Reasons"}),n.map(([r,i])=>l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("span",{className:"text-white truncate max-w-[200px]",children:r||"Unknown"}),l.jsx("span",{className:"text-bambu-gray",children:i})]},r))]}),t.trend&&t.trend.length>=2&&l.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(f7,{className:`w-4 h-4 ${t.trend[t.trend.length-1].failure_rate<t.trend[t.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),l.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",t.trend[t.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]})}function WGe(){const{showToast:t}=si(),[e,n]=M.useState(!1),[r,i]=M.useState(!1),[s,a]=M.useState(0),[o,c]=M.useState(0);M.useEffect(()=>{const S=()=>{try{const T=localStorage.getItem("bambusy-dashboard-layout");if(T){const k=JSON.parse(T);c(k.hidden?.length||0)}}catch{c(0)}};S(),window.addEventListener("storage",S);const A=setInterval(S,500);return()=>{window.removeEventListener("storage",S),clearInterval(A)}},[s]);const{data:u,isLoading:d}=yt({queryKey:["archiveStats"],queryFn:ke.getArchiveStats}),{data:f}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:g}=yt({queryKey:["archives"],queryFn:()=>ke.getArchives(void 0,void 0,1e3,0)}),{data:m}=yt({queryKey:["settings"],queryFn:ke.getSettings}),x=async S=>{i(!1),n(!0);try{const{blob:A,filename:T}=await ke.exportStats({format:S,days:90}),k=URL.createObjectURL(A),N=document.createElement("a");N.href=k,N.download=T,N.click(),URL.revokeObjectURL(k),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},y=m?.currency||"$",v=new Map(f?.map(S=>[String(S.id),S.name])||[]),b=g?.map(S=>S.created_at)||[];if(d)return l.jsx("div",{className:"p-4 md:p-8",children:l.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:l.jsx(UGe,{stats:u,currency:y}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:l.jsx(FGe,{stats:u}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:l.jsx(zGe,{stats:u,printerMap:v}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:l.jsx(BGe,{stats:u}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:l.jsx(GGe,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:l.jsx(HGe,{printDates:b}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:l.jsx($Ge,{stats:u,printerMap:v}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:l.jsx(VGe,{archives:g||[],currency:y}),defaultSize:4}];return l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),l.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&l.jsxs(Le,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[l.jsx(mm,{className:"w-4 h-4"}),o," Hidden"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),a(S=>S+1),t("Layout reset")},children:[l.jsx(Xm,{className:"w-4 h-4"}),"Reset Layout"]}),l.jsxs("div",{className:"relative",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(T1,{className:"w-4 h-4"}),"Export Stats"]}),r&&l.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[l.jsx(to,{className:"w-4 h-4"}),"Export as CSV"]}),l.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[l.jsx(T1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),l.jsx(IGe,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},s)]})}function qGe({plug:t,onEdit:e}){const n=Mn(),[r,i]=M.useState(!1),[s,a]=M.useState(!1),[o,c]=M.useState(!1),[u,d]=M.useState(!1),{data:f,isLoading:g,refetch:m}=yt({queryKey:["smart-plug-status",t.id],queryFn:()=>ke.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),y=x?.find(k=>k.id===t.printer_id),v=wt({mutationFn:k=>ke.controlSmartPlug(t.id,k),onSuccess:()=>{m()}}),b=wt({mutationFn:k=>ke.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=wt({mutationFn:()=>ke.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),S=f?.state==="ON",A=f?.reachable??!1,T=v.isPending;return l.jsxs(l.Fragment,{children:[l.jsx(Nt,{className:"relative",children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${A?S?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:l.jsx(Jp,{className:`w-5 h-5 ${A?S?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),l.jsx("div",{className:"flex items-center gap-2",children:g?l.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?l.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[l.jsx(x7,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:S?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):l.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[l.jsx(GR,{className:"w-4 h-4"}),l.jsx("span",{children:"Offline"})]})})]}),y&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),l.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&l.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&l.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[l.jsx(wh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&l.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[l.jsx(Zr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),l.jsxs("div",{className:"flex gap-2 mb-3",children:[l.jsxs(Le,{size:"sm",variant:S?"primary":"secondary",disabled:!A||T,onClick:()=>a(!0),className:"flex-1",children:[T?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(bd,{className:"w-4 h-4"}),"On"]}),l.jsxs(Le,{size:"sm",variant:S?"secondary":"primary",disabled:!A||T,onClick:()=>c(!0),className:"flex-1",children:[T?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(HR,{className:"w-4 h-4"}),"Off"]})]}),l.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(HS,{className:"w-4 h-4"}),"Automation Settings"]}),l.jsx("span",{children:u?"-":"+"})]}),u&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.enabled,onChange:k=>b.mutate({enabled:k.target.checked}),className:"sr-only peer"}),l.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto On"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:k=>b.mutate({auto_on:k.target.checked}),className:"sr-only peer"}),l.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:k=>b.mutate({auto_off:k.target.checked}),className:"sr-only peer"}),l.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&l.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[l.jsx(_r,{className:"w-4 h-4"}),"Time"]}),l.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[l.jsx(Sh,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),l.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange: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"})]}):l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),l.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange: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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(BR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(Qr,{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&&l.jsx(Qr,{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&&l.jsx(Qr,{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"),c(!1)},onCancel:()=>c(!1)})]})}function KGe({plug:t,onClose:e}){const n=Mn(),r=!!t,[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.ip_address||""),[c,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:ke.getPrinters}),{data:W}=yt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs});M.useEffect(()=>{const z=J=>{J.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const K=wt({mutationFn:()=>ke.testSmartPlugConnection(a,c||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=wt({mutationFn:z=>ke.createSmartPlug(z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{b(z.message)}}),ee=wt({mutationFn:z=>ke.updateSmartPlug(t.id,z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{b(z.message)}}),Y=R?.filter(z=>!W?.some(se=>se.printer_id===z.id&&se.id!==t?.id)),Q=z=>{if(z.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!a.trim()){b("IP address is required");return}const J={name:i.trim(),ip_address:a.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:A?parseFloat(A):null,power_alert_low:k?parseFloat(k):null,schedule_enabled:I,schedule_on_time:D||null,schedule_off_time:j||null};r?ee.mutate(J):V.mutate(J)},U=V.isPending||ee.isPending;return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:z=>z.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Q,className:"p-6 space-y-4",children:[v&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value: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"}),l.jsxs(Le,{type:"button",variant:"secondary",onClick:()=>K.mutate(),disabled:!a.trim()||K.isPending,children:[K.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(x7,{className:"w-4 h-4"}),"Test"]})]})]}),x&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?l.jsxs(l.Fragment,{children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-medium",children:"Connected!"}),l.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx(GR,{className:"w-5 h-5"}),l.jsx("span",{children:"Connection failed"})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:i,onChange: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"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),l.jsx("input",{type:"text",value:c,onChange: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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),l.jsx("input",{type:"password",value:d,onChange: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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),l.jsxs("select",{value:g??"",onChange: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:[l.jsx("option",{value:"",children:"No printer (manual control only)"}),Y?.map(z=>l.jsx("option",{value:z.id,children:z.name},z.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(wh,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:E,onChange:z=>S(z.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),l.jsx("input",{type:"number",value:A,onChange: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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),l.jsx("input",{type:"number",value: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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-green"}),l.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:I,onChange:z=>C(z.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),I&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),l.jsx("input",{type:"time",value: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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),l.jsx("input",{type:"time",value: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"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:U,className:"flex-1",children:[U?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Pn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return l.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:l.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const XGe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function YGe({provider:t,onEdit:e}){const n=Mn(),[r,i]=M.useState(!1),[s,a]=M.useState(!1),[o,c]=M.useState(null),{data:u}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=wt({mutationFn:y=>ke.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=wt({mutationFn:()=>ke.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=wt({mutationFn:()=>ke.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return l.jsxs(l.Fragment,{children:[l.jsx(Nt,{className:"relative",children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:l.jsx(wh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),l.jsx("p",{className:"text-sm text-bambu-gray",children:XGe[t.provider_type]||t.provider_type})]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&l.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&l.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),l.jsx(Pn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),d&&l.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),l.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&l.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:l.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),l.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&l.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&l.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&l.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&l.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&l.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&l.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&l.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&l.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&l.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&l.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&l.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&l.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&l.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&l.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[l.jsx(C1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&l.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[l.jsx(Zr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),l.jsx("div",{className:"mb-3",children:l.jsxs(Le,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx($R,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&l.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?l.jsx(fi,{className:"w-4 h-4"}):l.jsx(ga,{className:"w-4 h-4"}),l.jsx("span",{children:o.message})]}),l.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:[l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(HS,{className:"w-4 h-4"}),"Event Settings"]}),s?l.jsx(US,{className:"w-4 h-4"}):l.jsx(uf,{className:"w-4 h-4"})]}),s&&l.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Enabled"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),l.jsx(Pn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Started"}),l.jsx(Pn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),l.jsx(Pn,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),l.jsx(Pn,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),l.jsx(Pn,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),l.jsx(Pn,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),l.jsx(Pn,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),l.jsx(Pn,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Pn,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),l.jsx(Pn,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>f.mutate({on_ams_ht_humidity_high:y})})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),l.jsx(Pn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>f.mutate({on_ams_ht_temperature_high:y})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(C1,{className:"w-4 h-4 text-purple-400"}),l.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),l.jsx(Pn,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Zr,{className:"w-4 h-4 text-emerald-400"}),l.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),l.jsx(Pn,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&l.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(_r,{className:"w-4 h-4 text-bambu-gray"}),l.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[l.jsx(BR,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&l.jsx(Qr,{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 hG=[{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=Mn(),r=!!t,[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.provider_type||"email"),[c,u]=M.useState(t?.printer_id||null),[d,f]=M.useState(t?.quiet_hours_enabled||!1),[g,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),[ee,Y]=M.useState(t?.on_filament_low??!1),[Q,U]=M.useState(t?.on_maintenance_due??!1),[z,J]=M.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([G,Z])=>[G,String(Z)])):{}),[se,me]=M.useState(null),[fe,xe]=M.useState(null),{data:Ee}=yt({queryKey:["printers"],queryFn:ke.getPrinters});M.useEffect(()=>{const G=Z=>{Z.key==="Escape"&&e()};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[e]);const re=wt({mutationFn:()=>ke.testNotificationConfig({provider_type:a,config:z}),onSuccess:G=>{me(G),xe(null)},onError:G=>{me({success:!1,message:G.message})}}),we=wt({mutationFn:G=>ke.createNotificationProvider(G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),Oe=wt({mutationFn:G=>ke.updateNotificationProvider(t.id,G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{xe(G.message)}}),he=G=>{if(G.preventDefault(),xe(null),!i.trim()){xe("Name is required");return}const Z=H(a);for(const Ne of Z)if(!z[Ne.key]?.trim()){xe(`${Ne.label} is required`);return}const oe={name:i.trim(),provider_type:a,config:z,printer_id:c,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:ee,on_maintenance_due:Q};r?Oe.mutate(oe):we.mutate(oe)},ht=we.isPending||Oe.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(Z=>Z.required),ne=$(a);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:G=>G.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:he,className:"p-6 space-y-4",children:[fe&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:fe}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value:i,onChange: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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),l.jsx("select",{value:a,onChange:G=>{o(G.target.value),J({}),me(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:hG.map(G=>l.jsx("option",{value:G.value,children:G.label},G.value))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:hG.find(G=>G.value===a)?.description})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ne.map(G=>l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[G.label," ",G.required&&"*"]}),G.type==="select"&&G.options?l.jsx("select",{value:z[G.key]||G.options[0]?.value||"",onChange:Z=>{J({...z,[G.key]:Z.target.value}),me(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(Z=>l.jsx("option",{value:Z.value,children:Z.label},Z.value))}):l.jsx("input",{type:G.type,value:z[G.key]||"",onChange:Z=>{J({...z,[G.key]:Z.target.value}),me(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))]}),l.jsx("div",{className:"flex gap-2",children:l.jsxs(Le,{type:"button",variant:"secondary",onClick:()=>{me(null),re.mutate()},disabled:re.isPending||!z[H(a)[0]?.key],className:"flex-1",children:[re.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx($R,{className:"w-4 h-4"}),"Test Configuration"]})}),se&&l.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${se.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:se.success?l.jsxs(l.Fragment,{children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsx("span",{children:se.message})]}):l.jsxs(l.Fragment,{children:[l.jsx(ga,{className:"w-5 h-5"}),l.jsx("span",{children:se.message})]})}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),l.jsxs("select",{value:c??"",onChange: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:[l.jsx("option",{value:"",children:"All printers"}),Ee?.map(G=>l.jsx("option",{value:G.id,children:G.name},G.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),l.jsx(Pn,{checked:d,onChange:f})]}),d&&l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),l.jsx("input",{type:"time",value:g,onChange: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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),l.jsx("input",{type:"time",value:x,onChange: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"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),l.jsx(Pn,{checked:v,onChange:b})]}),v&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),l.jsx("input",{type:"time",value:E,onChange: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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Start"}),l.jsx(Pn,{checked:A,onChange:T})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Complete"}),l.jsx(Pn,{checked:k,onChange:N})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Failed"}),l.jsx(Pn,{checked:I,onChange:C})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Stopped"}),l.jsx(Pn,{checked:D,onChange:F})]}),l.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-white",children:"Progress"}),l.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),l.jsx(Pn,{checked:j,onChange:q})]})]})]}),l.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[l.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Offline"}),l.jsx(Pn,{checked:R,onChange:W})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Error"}),l.jsx(Pn,{checked:K,onChange:V})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),l.jsx(Pn,{checked:ee,onChange:Y})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),l.jsx(Pn,{checked:Q,onChange:U})]})]})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:ht,className:"flex-1",children:[ht?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function QGe({template:t,onClose:e}){const n=Mn(),r=M.useRef(null),[i,s]=M.useState(t.title_template),[a,o]=M.useState(t.body_template),[c,u]=M.useState(null),[d,f]=M.useState(!0),{data:g}=yt({queryKey:["template-variables"],queryFn:ke.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:()=>ke.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=wt({mutationFn:T=>ke.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),b=wt({mutationFn:()=>ke.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 l.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),l.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:l.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),l.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),l.jsx("input",{type:"text",value:i,onChange:T=>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..."})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),l.jsx("textarea",{ref:r,value: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&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(T=>l.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:[l.jsx(pr,{className:"w-3 h-3"}),T]},T))}),l.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(mm,{className:"w-4 h-4"}),"Live Preview"]}),l.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&l.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),l.jsx("div",{className:"text-white font-medium",children:x.title})]}),l.jsxs("div",{children:[l.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),l.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):l.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[l.jsxs(Le,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(Xm,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsxs(Le,{onClick:E,disabled:v.isPending||!A,children:[v.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin mr-2"}):l.jsx(Ro,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const JGe={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"},e7e={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 t7e({onClose:t}){const e=Mn(),{showToast:n}=si(),[r,i]=M.useState(7),[s,a]=M.useState(null),[o,c]=M.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=yt({queryKey:["notification-logs",r,o],queryFn:()=>ke.getNotificationLogs({days:r,limit:100,success:o?!1:void 0})}),{data:m}=yt({queryKey:["notification-log-stats",r],queryFn:()=>ke.getNotificationLogStats(r)}),x=wt({mutationFn:()=>ke.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 l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(N3,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),m&&l.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:l.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[l.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",l.jsx("span",{className:"text-white font-medium",children:m.total})," notifications"]}),l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(fi,{className:"w-4 h-4"}),m.success_count," sent"]}),m.failure_count>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(ga,{className:"w-4 h-4"}),m.failure_count," failed"]})]})}),l.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[l.jsxs("select",{value:r,onChange: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:[l.jsx("option",{value:1,children:"Last 24 hours"}),l.jsx("option",{value:7,children:"Last 7 days"}),l.jsx("option",{value:30,children:"Last 30 days"}),l.jsx("option",{value:90,children:"Last 90 days"})]}),l.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:o,onChange:v=>c(v.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),l.jsx("div",{className:"flex-1"}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Cs,{className:"w-4 h-4"}),"Refresh"]}),l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Clear Old"]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(v=>l.jsx(n7e,{log:v,isExpanded:s===v.id,onToggle:()=>a(s===v.id?null:v.id),formatDate:y},v.id))}):l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(N3,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm",children:o?"No failed notifications":"No notifications logged"})]})})]})})}function n7e({log:t,isExpanded:e,onToggle:n,formatDate:r}){return l.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[l.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?l.jsx(fi,{className:"w-4 h-4 text-bambu-green shrink-0"}):l.jsx(ga,{className:"w-4 h-4 text-red-400 shrink-0"}),l.jsx("span",{className:`text-xs font-medium ${e7e[t.event_type]||"text-bambu-gray"}`,children:JGe[t.event_type]||t.event_type}),l.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&l.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),l.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?l.jsx(US,{className:"w-4 h-4 text-bambu-gray shrink-0"}):l.jsx(uf,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&l.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),l.jsx("p",{className:"text-sm text-white",children:t.title})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),l.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),l.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),l.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[l.jsxs("span",{children:["Provider: ",t.provider_type]}),l.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const X_=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:l.jsx(VR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:l.jsx(wh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:l.jsx(to,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:l.jsx(Jp,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:l.jsx(Ta,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:l.jsx(c7,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:l.jsx(sd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:l.jsx(_h,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"}];function r7e({onClose:t,onExport:e}){const{t:n}=Gm(),[r,i]=M.useState(()=>{const x={};return X_.forEach(y=>{x[y.id]=y.default}),x}),[s,a]=M.useState(!1),[o,c]=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={};X_.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};X_.forEach(y=>{x[y.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,m=async()=>{c(!0);try{await e({...r,access_codes:s&&r.printers})}finally{c(!1)}};return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o?void 0:t,children:l.jsx(Nt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:l.jsx(Ma,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[l.jsx("button",{onClick:d,disabled:o,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),l.jsx("span",{className:"text-bambu-gray",children:"|"}),l.jsx("button",{onClick:f,disabled:o,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),l.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${o?"opacity-50 pointer-events-none":""}`,children:X_.map(x=>l.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[l.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:o,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),l.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),l.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&l.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(_h,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[l.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),l.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&l.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(Vp,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),l.jsx(Pn,{checked:s,onChange:a})]}),s&&l.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx(ti,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),l.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:t,disabled:o,children:n("common.cancel",{defaultValue:"Cancel"})}),l.jsx(Le,{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?l.jsxs(l.Fragment,{children:[l.jsx(At,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):l.jsxs(l.Fragment,{children:[l.jsx(Ma,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const fG={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 i7e({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=M.useState("options"),[s,a]=M.useState(!1),[o,c]=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&&c(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 l.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:l.jsx(Nt,{className:"w-full max-w-lg",children:l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?l.jsx(fi,{className:"w-5 h-5"}):r==="result"&&!u?.success?l.jsx(ti,{className:"w-5 h-5"}):l.jsx(ya,{className:"w-5 h-5"})}),l.jsxs("div",{children:[l.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&l.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),r==="options"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("input",{ref:m,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),l.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?l.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[l.jsx(fi,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:o.name})]}):l.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[l.jsx(ya,{className:"w-8 h-8"}),l.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),l.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(ti,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[l.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),l.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[l.jsxs("li",{children:[l.jsx("strong",{children:"Printers"})," - matched by serial number"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),l.jsxs("li",{children:[l.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),l.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[s?l.jsx(Cs,{className:"w-4 h-4 text-orange-400"}):l.jsx(N1,{className:"w-4 h-4 text-bambu-gray"}),s?"Replace existing data":"Keep existing data"]}),l.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"})]}),l.jsx(Pn,{checked:s,onChange:a})]})}),s&&l.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:l.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[l.jsx(ti,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[l.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),l.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),l.jsxs(Le,{type:"button",onClick:y,disabled:!o,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[l.jsx(ya,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&l.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[l.jsx(At,{className:"w-12 h-12 text-bambu-green animate-spin"}),l.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[l.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:b}),l.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),l.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[l.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:E}),l.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,S])=>S>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),l.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,S])=>S>0).map(([S,A])=>l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:fG[S]||S}),l.jsx("span",{className:"text-bambu-green font-medium",children:A})]},S)),(u.files_restored||0)>0&&l.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[l.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),l.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,S])=>S>0)&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[l.jsx(N1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),l.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 l.jsxs("div",{children:[l.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:[l.jsxs("span",{className:"text-white flex items-center gap-2",children:[fG[S]||S,T.length>0&&(k?l.jsx(US,{className:"w-3 h-3"}):l.jsx(uf,{className:"w-3 h-3"}))]}),l.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),k&&T.length>0&&l.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((N,I)=>l.jsx("div",{children:N},I)),T.length>10&&l.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},S)})})]}),b===0&&E===0&&l.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),l.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:l.jsx(Le,{onClick:t,children:"Close"})})]})]})})})}async function s7e(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function a7e(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 o7e(){const t=Mn(),[e,n]=M.useState(!1),[r,i]=M.useState(""),[s,a]=M.useState("auto"),[o,c]=M.useState(!1),[u,d]=M.useState("all"),[f,g]=M.useState(!1),{data:m,isLoading:x}=yt({queryKey:["spoolman-settings"],queryFn:s7e}),{data:y,isLoading:v,refetch:b}=yt({queryKey:["spoolman-status"],queryFn:ke.getSpoolmanStatus,refetchInterval:3e4}),{data:E}=yt({queryKey:["printers"],queryFn:ke.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=wt({mutationFn:()=>a7e({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:s}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),A=wt({mutationFn:ke.connectSpoolman,onSuccess:()=>{b()}}),T=wt({mutationFn:ke.disconnectSpoolman,onSuccess:()=>{b()}}),k=wt({mutationFn:ke.syncAllPrintersAms,onSuccess:j=>{j.success}}),N=wt({mutationFn:j=>ke.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?l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(pm,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),l.jsx(Rt,{children:l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(pm,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),S.isPending&&l.jsx(At,{className:"w-4 h-4 text-bambu-green animate-spin"}),o&&l.jsx(zh,{className:"w-4 h-4 text-bambu-green"})]})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Enable Spoolman"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),l.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange: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"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),l.jsxs("select",{value: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:[l.jsx("option",{value:"auto",children:"Automatic"}),l.jsx("option",{value:"manual",children:"Manual Only"})]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:s==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&l.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?l.jsx(At,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?l.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[l.jsx(zh,{className:"w-4 h-4"}),"Connected"]}):l.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[l.jsx(Wt,{className:"w-4 h-4"}),"Disconnected"]})]}),l.jsx("div",{className:"flex gap-2",children:y?.connected?l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(zle,{className:"w-4 h-4"}),"Disconnect"]}):l.jsxs(Le,{size:"sm",onClick:()=>A.mutate(),disabled:A.isPending||!r,children:[A.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(P3,{className:"w-4 h-4"}),"Connect"]})})]}),A.isError&&l.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:A.error.message}),y?.connected&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsxs("select",{value:u,onChange: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:[l.jsx("option",{value:"all",children:"All Printers"}),E?.map(j=>l.jsx("option",{value:j.id,children:j.name},j.id))]}),l.jsx(uf,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:I,disabled:C,children:[C?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Cs,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&D&&l.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 l7e({link:t,onClose:e}){const n=Mn(),{theme:r}=xb(),i=!!t,s=M.useRef(null),[a,o]=M.useState(t?.name||""),[c,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?ke.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=wt({mutationFn:async F=>{const j=await ke.createExternalLink(F);return v?await ke.uploadExternalLinkIcon(j.id,v):j},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:F=>{S(F.message)}}),T=wt({mutationFn:async F=>{let j=await ke.updateExternalLink(t.id,F);return v?j=await ke.uploadExternalLinkIcon(t.id,v):!g&&t?.custom_icon&&(j=await ke.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(!c.trim()){S("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){S("URL must start with http:// or https://");return}const j={name:a.trim(),url:c.trim(),icon:d};i?T.mutate(j):A.mutate(j)},C=A.isPending||T.isPending,D=$S(d);return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:F=>F.stopPropagation(),children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?l.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):l.jsx(D,{className:"w-5 h-5"})}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),l.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:I,className:"p-6 space-y-4",children:[E&&l.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),l.jsx("input",{type:"text",value: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"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),l.jsx("input",{type:"text",value:c,onChange: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"})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),l.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),l.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:k}),g&&x?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),l.jsx("button",{type:"button",onClick:N,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:l.jsx(Rn,{className:"w-4 h-4"})})]}):l.jsxs(Le,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[l.jsx(ya,{className:"w-4 h-4"}),"Upload"]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&l.jsxs("div",{children:[l.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),l.jsx(Gue,{value:d,onChange:f})]})]}),l.jsxs("div",{className:"flex gap-3 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:C,className:"flex-1",children:[C?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ro,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function c7e(){const t=Mn(),[e,n]=M.useState(!1),[r,i]=M.useState(null),[s,a]=M.useState(null),[o,c]=M.useState(null),{data:u,isLoading:d}=yt({queryKey:["external-links"],queryFn:ke.getExternalLinks}),f=wt({mutationFn:E=>ke.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=wt({mutationFn:E=>ke.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(E,S)=>{c(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),c(null)},v=E=>{a(E)},b=()=>{s&&(f.mutate(s.id),a(null))};return l.jsxs(l.Fragment,{children:[l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(P3,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),l.jsxs(Le,{size:"sm",onClick:()=>n(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Link"]})]})}),l.jsxs(Rt,{children:[l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?l.jsx("div",{className:"space-y-2",children:u.map(E=>{const S=$S(E.icon);return l.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:[l.jsx(y0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),l.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:l.jsx(S,{className:"w-4 h-4"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-white font-medium truncate",children:E.name}),l.jsx(Aa,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),l.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),l.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[l.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:l.jsx(rd,{className:"w-4 h-4"})}),l.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:l.jsx(Rn,{className:"w-4 h-4"})})]})]},E.id)})}):l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(P3,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{children:"No external links configured"}),l.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&l.jsx(l7e,{link:r,onClose:()=>{n(!1),i(null)}}),s&&l.jsx(Qr,{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 u7e(){const t=Mn(),{t:e,i18n:n}=Gm(),{showToast:r,showPersistentToast:i,dismissToast:s}=si(),[a,o]=M.useState(null),[c,u]=M.useState(!1),[d,f]=M.useState(null),[g,m]=M.useState(!1),[x,y]=M.useState(null),[v,b]=M.useState(null),[E,S]=M.useState(!1),[A,T]=M.useState(_7()),[k,N]=M.useState("general"),[I,C]=M.useState(!1),[D,F]=M.useState(""),[j,q]=M.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[R,W]=M.useState(null),[K,V]=M.useState(null),[ee,Y]=M.useState(!1),[Q,U]=M.useState(!1),[z,J]=M.useState(null),[se,me]=M.useState(!1),[fe,xe]=M.useState(!1),[Ee,re]=M.useState(!1),[we,Oe]=M.useState(!1),he=ce=>{T(ce),Kue(ce)},ht=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:$,isLoading:H}=yt({queryKey:["settings"],queryFn:ke.getSettings}),{data:ne,isLoading:G}=yt({queryKey:["smart-plugs"],queryFn:ke.getSmartPlugs}),{data:Z,isLoading:oe}=yt({queryKey:["smart-plugs-energy",ne?.map(ce=>ce.id)],queryFn:async()=>{if(!ne||ne.length===0)return null;const ce=await Promise.all(ne.filter(Vt=>Vt.enabled).map(async Vt=>{try{const jn=await ke.getSmartPlugStatus(Vt.id);return{plug:Vt,status:jn}}catch{return{plug:Vt,status:null}}}));let at=0,xt=0,St=0,Qt=0,jt=0;for(const{status:Vt}of ce)Vt?.reachable&&Vt.energy&&(jt++,Vt.energy.power!=null&&(at+=Vt.energy.power),Vt.energy.today!=null&&(xt+=Vt.energy.today),Vt.energy.yesterday!=null&&(St+=Vt.energy.yesterday),Vt.energy.total!=null&&(Qt+=Vt.energy.total));return{totalPower:at,totalToday:xt,totalYesterday:St,totalLifetime:Qt,reachableCount:jt,totalPlugs:ne.filter(Vt=>Vt.enabled).length}},enabled:k==="plugs"&&!!ne&&ne.length>0,refetchInterval:k==="plugs"?1e4:!1}),{data:Ne,isLoading:Pe}=yt({queryKey:["notification-providers"],queryFn:ke.getNotificationProviders}),{data:Se,isLoading:B}=yt({queryKey:["api-keys"],queryFn:ke.getAPIKeys}),L=wt({mutationFn:ce=>ke.createAPIKey(ce),onSuccess:ce=>{W(ce.key||null),C(!1),F(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:ce=>{r(`Failed to create API key: ${ce.message}`,"error")}}),te=wt({mutationFn:ce=>ke.deleteAPIKey(ce),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:ce=>{r(`Failed to delete API key: ${ce.message}`,"error")}}),{data:ve}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:_e,isLoading:be}=yt({queryKey:["notification-templates"],queryFn:ke.getNotificationTemplates}),{data:nt}=yt({queryKey:["ffmpeg-status"],queryFn:ke.checkFfmpeg}),{data:Be}=yt({queryKey:["version"],queryFn:ke.getVersion}),{data:ue,refetch:Ve,isRefetching:Ue}=yt({queryKey:["updateCheck"],queryFn:ke.checkForUpdates,staleTime:300*1e3}),{data:ae,refetch:Je}=yt({queryKey:["updateStatus"],queryFn:ke.getUpdateStatus,refetchInterval:ce=>{const at=ce.state.data;return at?.status==="downloading"||at?.status==="installing"?1e3:!1}}),He=wt({mutationFn:ke.applyUpdate,onSuccess:()=>{Je()}}),[Ke,ct]=M.useState(null),de=wt({mutationFn:ke.testAllNotificationProviders,onSuccess:ce=>{ct(ce),t.invalidateQueries({queryKey:["notification-providers"]}),ce.failed===0?r(`All ${ce.tested} providers tested successfully!`,"success"):r(`${ce.success}/${ce.tested} providers succeeded`,ce.failed>0?"error":"success")},onError:ce=>{r(`Failed to test providers: ${ce.message}`,"error")}}),Ye=wt({mutationFn:async ce=>{if(!ne)return{success:0,failed:0};const at=ne.filter(St=>St.enabled),xt=await Promise.all(at.map(async St=>{try{return await ke.controlSmartPlug(St.id,ce),{success:!0}}catch{return{success:!1}}}));return{success:xt.filter(St=>St.success).length,failed:xt.filter(St=>!St.success).length}},onSuccess:(ce,at)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),ce.failed===0?r(`All ${ce.success} plugs turned ${at}`,"success"):r(`${ce.success} plugs turned ${at}, ${ce.failed} failed`,"error")},onError:ce=>{r(`Failed: ${ce.message}`,"error")}}),ge=M.useRef(null),Fe=M.useRef(!0);M.useEffect(()=>{$&&!a&&(o($),setTimeout(()=>{Fe.current=!1},100))},[$,a]);const Ce=wt({mutationFn:ke.updateSettings,onSuccess:ce=>{t.setQueryData(["settings"],ce),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:ce=>{r(`Failed to save: ${ce.message}`,"error")}});M.useEffect(()=>{if(!(Fe.current||!a||!$||!($.auto_archive!==a.auto_archive||$.save_thumbnails!==a.save_thumbnails||$.capture_finish_photo!==a.capture_finish_photo||$.default_filament_cost!==a.default_filament_cost||$.currency!==a.currency||$.energy_cost_per_kwh!==a.energy_cost_per_kwh||$.energy_tracking_mode!==a.energy_tracking_mode||$.check_updates!==a.check_updates||$.notification_language!==a.notification_language||$.telemetry_enabled!==a.telemetry_enabled||$.ams_humidity_good!==a.ams_humidity_good||$.ams_humidity_fair!==a.ams_humidity_fair||$.ams_temp_good!==a.ams_temp_good||$.ams_temp_fair!==a.ams_temp_fair||$.ams_history_retention_days!==a.ams_history_retention_days||$.date_format!==a.date_format||$.time_format!==a.time_format||$.default_printer_id!==a.default_printer_id)))return ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{Ce.mutate(a)},500),()=>{ge.current&&clearTimeout(ge.current)}},[a,$,Ce]);const ye=M.useCallback((ce,at)=>{o(xt=>xt?{...xt,[ce]:at}:null)},[]);return H||!a?l.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-8",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),l.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),l.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>N("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${k==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:"General"}),l.jsxs("button",{onClick:()=>N("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Jp,{className:"w-4 h-4"}),"Smart Plugs",ne&&ne.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ne.length})]}),l.jsxs("button",{onClick:()=>N("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(wh,{className:"w-4 h-4"}),"Notifications",Ne&&Ne.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ne.length})]}),l.jsxs("button",{onClick:()=>N("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${k==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(Vp,{className:"w-4 h-4"}),"API Keys",Se&&Se.length>0&&l.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Se.length})]})]}),k==="general"&&l.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[l.jsx(v0,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),l.jsx("select",{value:n.language,onChange:ce=>n.changeLanguage(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",children:TU.map(ce=>l.jsxs("option",{value:ce.code,children:[ce.nativeName," (",ce.name,")"]},ce.code))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),l.jsx("select",{value:A,onChange:ce=>he(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",children:A0.map(ce=>l.jsx("option",{value:ce.to,children:e(ce.labelKey)},ce.id))}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),l.jsxs("select",{value:a.date_format||"system",onChange:ce=>ye("date_format",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",children:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),l.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),l.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),l.jsxs("select",{value:a.time_format||"system",onChange:ce=>ye("time_format",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",children:[l.jsx("option",{value:"system",children:"System Default"}),l.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),l.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),l.jsxs("select",{value:a.default_printer_id??"",onChange:ce=>ye("default_printer_id",ce.target.value?Number(ce.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"No default (ask each time)"}),ve?.map(ce=>l.jsx("option",{value:ce.id,children:ce.name},ce.id))]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Sidebar order"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:ht,children:[l.jsx(Xm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Auto-archive prints"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:a.auto_archive,onChange:ce=>ye("auto_archive",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Save thumbnails"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:a.save_thumbnails,onChange:ce=>ye("save_thumbnails",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Capture finish photo"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:a.capture_finish_photo,onChange:ce=>ye("capture_finish_photo",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),a.capture_finish_photo&&nt&&!nt.installed&&l.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[l.jsx(ti,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"text-sm",children:[l.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),l.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",l.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:a.default_filament_cost,onChange:ce=>ye("default_filament_cost",parseFloat(ce.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),l.jsxs("select",{value:a.currency,onChange:ce=>ye("currency",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",children:[l.jsx("option",{value:"USD",children:"USD ($)"}),l.jsx("option",{value:"EUR",children:"EUR (€)"}),l.jsx("option",{value:"GBP",children:"GBP (£)"}),l.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),l.jsx("option",{value:"JPY",children:"JPY (¥)"}),l.jsx("option",{value:"CNY",children:"CNY (¥)"}),l.jsx("option",{value:"CAD",children:"CAD ($)"}),l.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),l.jsx("input",{type:"number",step:"0.01",min:"0",value:a.energy_cost_per_kwh,onChange:ce=>ye("energy_cost_per_kwh",parseFloat(ce.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),l.jsxs("select",{value:a.energy_tracking_mode||"total",onChange:ce=>ye("energy_tracking_mode",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",children:[l.jsx("option",{value:"print",children:"Prints Only"}),l.jsx("option",{value:"total",children:"Total Consumption"})]}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(r7,{className:"w-4 h-4 text-blue-400"}),l.jsx("span",{className:"font-medium",children:"Humidity"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:a.ams_humidity_good??40,onChange:ce=>ye("ams_humidity_good",parseInt(ce.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"0",max:"100",value:a.ams_humidity_fair??60,onChange:ce=>ye("ams_humidity_fair",parseInt(ce.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),l.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(Sh,{className:"w-4 h-4 text-orange-400"}),l.jsx("span",{className:"font-medium",children:"Temperature"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:a.ams_temp_good??28,onChange:ce=>ye("ams_temp_good",parseFloat(ce.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:a.ams_temp_fair??35,onChange:ce=>ye("ams_temp_fair",parseFloat(ce.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),l.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-2 text-white",children:[l.jsx(pm,{className:"w-4 h-4 text-purple-400"}),l.jsx("span",{className:"font-medium",children:"History Retention"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",min:"1",max:"365",value:a.ams_history_retention_days??30,onChange:ce=>ye("ams_history_retention_days",parseInt(ce.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),l.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]}),l.jsx(o7e,{})]}),l.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[l.jsx(c7e,{}),l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Check for updates"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:a.check_updates,onChange:ce=>ye("check_updates",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-white",children:e("settings.telemetry")}),l.jsxs("button",{onClick:()=>re(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[l.jsx(_0,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),l.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),l.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:a.telemetry_enabled,onChange:ce=>ye("telemetry_enabled",ce.target.checked),className:"sr-only peer"}),l.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),l.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Current version"}),l.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Be?.version||"..."]})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>Ve(),disabled:Ue,children:[Ue?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Cs,{className:"w-4 h-4"}),"Check now"]})]}),ue?.update_available?l.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:ue.release_name})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[ue.release_notes&&l.jsx("button",{onClick:()=>Oe(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),ue.release_url&&l.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:l.jsx(Aa,{className:"w-4 h-4"})})]})]}),ae?.status==="downloading"||ae?.status==="installing"?l.jsxs("div",{className:"mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[l.jsx(At,{className:"w-4 h-4 animate-spin"}),l.jsx("span",{children:ae.message})]}),l.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:l.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${ae.progress}%`}})})]}):ae?.status==="complete"?l.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:ae.message}):ae?.status==="error"?l.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:ae.error||ae.message}):l.jsxs(Le,{className:"mt-3",onClick:()=>He.mutate(),disabled:He.isPending,children:[He.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Ma,{className:"w-4 h-4"}),"Install Update"]})]}):ue?.error?l.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",ue.error]}):ue&&!ue.update_available?l.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),l.jsxs(Nt,{children:[l.jsx($s,{children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Backup Data"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>me(!0),children:[l.jsx(Ma,{className:"w-4 h-4"}),"Export"]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Restore Backup"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>xe(!0),children:[l.jsx(ya,{className:"w-4 h-4"}),"Restore"]})]}),l.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Clear"]})]})}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>U(!0),children:[l.jsx(Rn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),k==="plugs"&&l.jsxs("div",{className:"max-w-4xl",children:[l.jsxs("div",{className:"flex items-start justify-between mb-6",children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Jp,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[ne&&ne.filter(ce=>ce.enabled).length>1&&l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>J("on"),disabled:Ye.isPending,title:"Turn all plugs on",children:[Ye.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(bd,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),l.jsxs(Le,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>J("off"),disabled:Ye.isPending,title:"Turn all plugs off",children:[Ye.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(HR,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),l.jsxs(Le,{className:"whitespace-nowrap",onClick:()=>{f(null),u(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),ne&&ne.length>0&&l.jsxs(Nt,{className:"mb-6",children:[l.jsx($s,{children:l.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[l.jsx(bm,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",oe&&l.jsx(At,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),l.jsx(Rt,{children:Z?l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(bm,{className:"w-3 h-3"}),"Current Power"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Z.totalPower.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Z.reachableCount,"/",Z.totalPlugs," plugs online"]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(Zr,{className:"w-3 h-3"}),"Today"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Z.totalToday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),a&&a.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Z.totalToday*a.energy_cost_per_kwh).toFixed(2)," ",a.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(p7,{className:"w-3 h-3"}),"Yesterday"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Z.totalYesterday.toFixed(2),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),a&&a.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Z.totalYesterday*a.energy_cost_per_kwh).toFixed(2)," ",a.currency]})]}),l.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[l.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[l.jsx(C3,{className:"w-3 h-3"}),"Total"]}),l.jsxs("div",{className:"text-xl font-bold text-white",children:[Z.totalLifetime.toFixed(1),l.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),a&&a.energy_cost_per_kwh>0&&l.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Z.totalLifetime*a.energy_cost_per_kwh).toFixed(2)," ",a.currency]})]})]}):oe?null:l.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),G?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ne&&ne.length>0?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ne.map(ce=>l.jsx(qGe,{plug:ce,onEdit:at=>{f(at),u(!0)}},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Jp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),l.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),l.jsxs(Le,{onClick:()=>{f(null),u(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),k==="notifications"&&l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(wh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>S(!0),children:[l.jsx(N3,{className:"w-4 h-4"}),"Log"]}),Ne&&Ne.length>0&&l.jsxs(Le,{size:"sm",variant:"secondary",onClick:()=>{ct(null),de.mutate()},disabled:de.isPending,children:[de.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx($R,{className:"w-4 h-4"}),"Test All"]}),l.jsxs(Le,{size:"sm",onClick:()=>{y(null),m(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add"]})]})]}),l.jsx(Nt,{className:"mb-4",children:l.jsx(Rt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),l.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),l.jsx("select",{value:a.notification_language||"en",onChange:ce=>ye("notification_language",ce.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:TU.map(ce=>l.jsx("option",{value:ce.code,children:ce.nativeName},ce.code))})]})})}),Ke&&l.jsx(Nt,{className:"mb-4",children:l.jsxs(Rt,{className:"py-3",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),l.jsx("button",{onClick:()=>ct(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[l.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[l.jsx(fi,{className:"w-4 h-4"}),Ke.success," passed"]}),Ke.failed>0&&l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(ga,{className:"w-4 h-4"}),Ke.failed," failed"]})]}),Ke.results.filter(ce=>!ce.success).length>0&&l.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ke.results.filter(ce=>!ce.success).map(ce=>l.jsxs("div",{className:"text-xs text-red-400",children:[l.jsxs("span",{className:"font-medium",children:[ce.provider_name,":"]})," ",ce.message]},ce.provider_id))})]})}),Pe?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ne&&Ne.length>0?l.jsx("div",{className:"space-y-3",children:Ne.map(ce=>l.jsx(YGe,{provider:ce,onEdit:at=>{y(at),m(!0)}},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(wh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),l.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),l.jsxs(Le,{size:"sm",onClick:()=>{y(null),m(!0)},children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[l.jsx(to,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),l.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),be?l.jsx("div",{className:"flex justify-center py-8",children:l.jsx(At,{className:"w-6 h-6 text-bambu-green animate-spin"})}):_e&&_e.length>0?l.jsx("div",{className:"space-y-2",children:_e.map(ce=>l.jsx(Nt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>b(ce),children:l.jsx(Rt,{className:"py-2.5 px-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-white font-medium text-sm truncate",children:ce.name}),l.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:ce.title_template})]}),l.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:at=>{at.stopPropagation(),b(ce)},children:l.jsx(BR,{className:"w-4 h-4 text-bambu-gray"})})]})})},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-8",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(to,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),l.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),k==="apikeys"&&l.jsxs("div",{className:"max-w-3xl",children:[l.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[l.jsxs("div",{className:"flex-1",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Vp,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks. Use these keys to control your printers from automation tools like Home Assistant."})]}),l.jsxs(Le,{size:"sm",onClick:()=>C(!0),className:"flex-shrink-0",children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]})]}),R&&l.jsx(Nt,{className:"mb-6 border-bambu-green",children:l.jsx(Rt,{className:"py-4",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx(fi,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),l.jsxs("div",{className:"flex-1",children:[l.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),l.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),l.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[l.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:R}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(R);else{const ce=document.createElement("textarea");ce.value=R,ce.style.position="fixed",ce.style.left="-999999px",document.body.appendChild(ce),ce.select(),document.execCommand("copy"),document.body.removeChild(ce)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:l.jsx(Hh,{className:"w-4 h-4"})})]}),l.jsx(Le,{variant:"secondary",size:"sm",className:"mt-3",onClick:()=>W(null),children:"Dismiss"})]})]})})}),I&&l.jsxs(Nt,{className:"mb-6",children:[l.jsx($s,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),l.jsx("input",{type:"text",value:D,onChange:ce=>F(ce.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:j.can_read_status,onChange:ce=>q(at=>({...at,can_read_status:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Read Status"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:j.can_queue,onChange:ce=>q(at=>({...at,can_queue:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Manage Queue"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),l.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:j.can_control_printer,onChange:ce=>q(at=>({...at,can_control_printer:ce.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),l.jsxs("div",{children:[l.jsx("span",{className:"text-white",children:"Control Printer"}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.jsxs(Le,{onClick:()=>L.mutate({name:D||"Unnamed Key",...j}),disabled:L.isPending,children:[L.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(pr,{className:"w-4 h-4"}),"Create Key"]}),l.jsx(Le,{variant:"secondary",onClick:()=>C(!1),children:"Cancel"})]})]})]}),B?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Se&&Se.length>0?l.jsx("div",{className:"space-y-3",children:Se.map(ce=>l.jsx(Nt,{children:l.jsx(Rt,{className:"py-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Vp,{className:`w-5 h-5 ${ce.enabled?"text-bambu-green":"text-bambu-gray"}`}),l.jsxs("div",{children:[l.jsx("p",{className:"text-white font-medium",children:ce.name}),l.jsxs("p",{className:"text-xs text-bambu-gray",children:[ce.key_prefix,"••••••••",ce.last_used&&` · Last used: ${new Date(ce.last_used).toLocaleDateString()}`]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex gap-1 text-xs",children:[ce.can_read_status&&l.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),ce.can_queue&&l.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),ce.can_control_printer&&l.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),l.jsx(Le,{variant:"secondary",size:"sm",onClick:()=>V(ce.id),children:l.jsx(Rn,{className:"w-4 h-4 text-red-400"})})]})]})})},ce.id))}):l.jsx(Nt,{children:l.jsx(Rt,{className:"py-12",children:l.jsxs("div",{className:"text-center text-bambu-gray",children:[l.jsx(Vp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),l.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),l.jsxs(Le,{onClick:()=>C(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),l.jsxs(Nt,{className:"mt-6",children:[l.jsx($s,{children:l.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),l.jsxs(Rt,{className:"space-y-3 text-sm",children:[l.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",l.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),l.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-blue-400",children:"GET"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),l.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-green-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),l.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),l.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-orange-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),l.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),l.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[l.jsx("span",{className:"text-red-400",children:"POST"})," ",l.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),l.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),K!==null&&l.jsx(Qr,{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:()=>{te.mutate(K),V(null)},onCancel:()=>V(null)}),c&&l.jsx(KGe,{plug:d,onClose:()=>{u(!1),f(null)}}),g&&l.jsx(ZGe,{provider:x,onClose:()=>{m(!1),y(null)}}),v&&l.jsx(QGe,{template:v,onClose:()=>b(null)}),E&&l.jsx(t7e,{onClose:()=>S(!1)}),ee&&l.jsx(Qr,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{Y(!1);try{const ce=await ke.clearNotificationLogs(30);r(ce.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>Y(!1)}),Q&&l.jsx(Qr,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{U(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>U(!1)}),z&&l.jsx(Qr,{title:`Turn All Plugs ${z==="on"?"On":"Off"}`,message:`This will turn ${z==="on"?"ON":"OFF"} all ${ne?.filter(ce=>ce.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 ce=z;J(null),Ye.mutate(ce)},onCancel:()=>J(null)}),se&&l.jsx(r7e,{onClose:()=>me(!1),onExport:async ce=>{me(!1);const at="backup-progress",xt=ce.archives;xt&&i(at,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:St,filename:Qt}=await ke.exportBackup(ce);xt&&s(at);const jt=URL.createObjectURL(St),Vt=document.createElement("a");Vt.href=jt,Vt.download=Qt,Vt.click(),URL.revokeObjectURL(jt),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{xt&&s(at),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),fe&&l.jsx(i7e,{onClose:()=>xe(!1),onRestore:async(ce,at)=>await ke.importBackup(ce,at),onSuccess:()=>{t.invalidateQueries()}}),Ee&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>re(!1),children:l.jsxs(Nt,{className:"w-full max-w-lg",onClick:ce=>ce.stopPropagation(),children:[l.jsxs($s,{className:"flex flex-row items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(qce,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),l.jsx("button",{onClick:()=>re(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs(Rt,{className:"space-y-4",children:[l.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(fi,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoItem3")})]})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),l.jsxs("ul",{className:"space-y-2 text-sm",children:[l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(ga,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(ga,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(ga,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),l.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[l.jsx(ga,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),l.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),l.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),l.jsx(Le,{onClick:()=>re(!1),className:"w-full",children:e("common.close")})]})]})}),we&&ue?.release_notes&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Oe(!1),children:l.jsxs(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:ce=>ce.stopPropagation(),children:[l.jsxs($s,{className:"flex flex-row items-center justify-between shrink-0",children:[l.jsxs("div",{children:[l.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",ue.latest_version]}),ue.release_name&&ue.release_name!==ue.latest_version&&l.jsx("p",{className:"text-sm text-bambu-gray",children:ue.release_name})]}),l.jsx("button",{onClick:()=>Oe(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx(Rt,{className:"overflow-y-auto flex-1",children:l.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:ue.release_notes})}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[ue.release_url&&l.jsx("a",{href:ue.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:l.jsxs(Le,{variant:"secondary",className:"w-full",children:[l.jsx(Aa,{className:"w-4 h-4"}),"View on GitHub"]})}),l.jsx(Le,{onClick:()=>Oe(!1),className:"flex-1",children:"Close"})]})]})})]})}const fte=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},d7e=t=>t.startsWith("HH")?"HF":"S",h7e=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},wR=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 d3({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:a}){const o=d7e(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&s?s():e()};return l.jsxs("div",{className:"flex items-center gap-2",children:[r&&l.jsx("button",{onClick:s,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?l.jsx(Vh,{className:"w-4 h-4 text-bambu-green"}):l.jsx(gm,{className:"w-4 h-4"})}),l.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:fte(t.k_value)}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),a&&l.jsx("span",{title:"Has note",children:l.jsx(u7,{className:"w-3 h-3 text-yellow-500"})}),l.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",c]})]}),a&&l.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&&l.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:l.jsx(Hh,{className:"w-4 h-4"})})]})}function h3({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:a=null,onClose:o,onSave:c,onSaveNote:u}){const{showToast:d}=si(),[f,g]=M.useState(t?.name||""),[m,x]=M.useState(t?.k_value?fte(t.k_value):"0.020"),[y,v]=M.useState(t?.filament_id||""),[b,E]=M.useState(t?.nozzle_id?h7e(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 Q=new Map;for(const U of r)if(U.filament_id&&!Q.has(U.filament_id)){const z=wR(U.name||"");Q.set(U.filament_id,{id:U.filament_id,name:z||U.filament_id})}return Array.from(Q.values()).sort((U,z)=>U.name.localeCompare(z.name))},[r]),R=wt({mutationFn:Q=>(console.log("[KProfile] Calling API..."),ke.setKProfile(e,Q)),onSuccess:Q=>{if(console.log("[KProfile] Save success:",Q),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),c()},2500)},onError:Q=>{console.error("[KProfile] Save error:",Q),d(Q.message,"error"),I(!1)}}),W=wt({mutationFn:Q=>(console.log("[KProfile] Deleting profile..."),ke.deleteKProfile(e,Q)),onSuccess:Q=>{console.log("[KProfile] Delete success:",Q),d("K-profile deleted"),I(!0),setTimeout(()=>{I(!1),o()},4e3)},onError:Q=>{console.error("[KProfile] Delete error:",Q),d(Q.message,"error"),I(!1)}}),[K,V]=M.useState(!1),ee=()=>{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 Q=>{if(Q.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 se={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:",se),R.mutate(se);return}I(!0),D({current:1,total:T.length});const J=T.map(se=>({name:f,k_value:U,filament_id:y,nozzle_id:z,nozzle_diameter:S,extruder_id:se,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${J.length} profiles in batch:`,J);try{if(await ke.setKProfilesBatch(e,J),d(`K-profile saved to ${T.length} extruders`),u&&F){const se=`name_${f}_${y}`;u(se,F)}}catch(se){console.error("[KProfile] Failed to save batch:",se),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}),c()},3e3)};return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[l.jsxs(Nt,{className:"w-full max-w-md relative",children:[N&&l.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),l.jsx("p",{className:"text-white font-medium",children:C.total>1?`Saving to extruder ${C.current}/${C.total}...`:"Syncing with printer..."}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),l.jsxs(Rt,{className:"p-0",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),l.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:N,children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("form",{onSubmit:Y,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),l.jsx("input",{type:"text",value:f,onChange:Q=>g(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),l.jsx("input",{type:"text",inputMode:"decimal",value:m,onChange:Q=>{const U=Q.target.value;(U===""||/^\d*\.?\d*$/.test(U))&&x(U)},onBlur:Q=>{const U=parseFloat(Q.target.value);isNaN(U)||x((Math.trunc(U*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),l.jsxs("select",{value:y,onChange:Q=>{const U=Q.target.value;if(v(U),!t&&U&&!f){const z=q.find(J=>J.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:[l.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&l.jsx("option",{value:t.filament_id,children:q.find(Q=>Q.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Q=>l.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),!t&&q.length===0&&l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),l.jsxs("select",{value:b,onChange:Q=>{const U=Q.target.value;if(E(U),!t&&y&&!f){const z=q.find(J=>J.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:[l.jsx("option",{value:"HH00",children:"High Flow"}),l.jsx("option",{value:"HS00",children:"Standard"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),l.jsxs("select",{value:S,onChange:Q=>A(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?l.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):l.jsxs("div",{className:"flex gap-4",children:[l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:Q=>{Q.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"}),l.jsx("span",{className:"text-white",children:"Left"})]}),l.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[l.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:Q=>{Q.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"}),l.jsx("span",{className:"text-white",children:"Right"})]})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),l.jsx("textarea",{value:F,onChange:Q=>j(Q.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),l.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>V(!0),disabled:W.isPending||N,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"})}),l.jsx(Le,{type:"button",variant:"secondary",onClick:o,disabled:N,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{type:"submit",disabled:R.isPending||N,className:"flex-1",children:[R.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(UR,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:l.jsx(Nt,{className:"w-full max-w-sm",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(Rn,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>{V(!1),ee()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const Y_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function f7e(){const{showToast:t}=si(),[e,n]=M.useState(null),[r,i]=M.useState(()=>localStorage.getItem(Y_.NOZZLE_DIAMETER)||"0.4"),[s,a]=M.useState(null),[o,c]=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(Y_.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(Y_.NOZZLE_DIAMETER,r)},[r]),M.useEffect(()=>{localStorage.setItem(Y_.SORT_OPTION,b)},[b]);const{data:j,isLoading:q}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:R,isLoading:W,isFetching:K,error:V,refetch:ee}=yt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const G=await ke.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:()=>ke.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Q,refetch:U}=yt({queryKey:["kprofile-notes",e],queryFn:()=>ke.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),z=V?.message?.includes("not connected");M.useEffect(()=>{if(!e&&j&&j.length>0){const G=j.find(Z=>Z.is_active);G&&n(G.id)}},[e,j]),M.useEffect(()=>{if(e){const G=setTimeout(()=>{ee()},150);return()=>clearTimeout(G)}},[e,r]);const J=j?.filter(G=>G.is_active)||[],se=mr.useMemo(()=>R?.profiles?R.profiles.filter(Z=>{const oe=f.toLowerCase(),Ne=!oe||Z.name.toLowerCase().includes(oe)||Z.filament_id.toLowerCase().includes(oe),Pe=m==="all"||m==="left"&&Z.extruder_id===1||m==="right"&&Z.extruder_id===0,Se=y==="all"||y==="hf"&&Z.nozzle_id.startsWith("HH")||y==="s"&&Z.nozzle_id.startsWith("HS");return Ne&&Pe&&Se}).sort((Z,oe)=>{switch(b){case"k_value":return parseFloat(Z.k_value)-parseFloat(oe.k_value);case"filament":return wR(Z.name).localeCompare(wR(oe.name));case"name":default:return Z.name.localeCompare(oe.name)}}):[],[R?.profiles,f,m,y,b]),me=j?.find(G=>G.id===e),fe=me?.nozzle_count===2;M.useEffect(()=>{const G=Z=>{Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement||s||o||u||(Z.key==="r"||Z.key==="R"?(Z.preventDefault(),ee()):Z.key==="n"||Z.key==="N"?(Z.preventDefault(),c(!0)):Z.key==="Escape"&&S&&(Z.preventDefault(),A(!1),k(new Set)))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[s,o,u,S,ee]);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:me?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Pe=>({name:Pe.name,k_value:Pe.k_value,filament_id:Pe.filament_id,nozzle_id:Pe.nozzle_id,nozzle_diameter:Pe.nozzle_diameter,extruder_id:Pe.extruder_id}))},Z=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),oe=URL.createObjectURL(Z),Ne=document.createElement("a");Ne.href=oe,Ne.download=`kprofiles_${me?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ne),Ne.click(),document.body.removeChild(Ne),URL.revokeObjectURL(oe),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,me,r,t]),Ee=M.useCallback(()=>{const G=document.createElement("input");G.type="file",G.accept=".json",G.onchange=async Z=>{const oe=Z.target.files?.[0];if(oe)try{const Ne=await oe.text(),Pe=JSON.parse(Ne);if(!Pe.profiles||!Array.isArray(Pe.profiles)){t("Invalid file format","error");return}let Se=0;for(const B of Pe.profiles)if(!(!B.name||!B.k_value||!B.filament_id))try{await ke.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 ${Pe.profiles.length} profiles`),ee()}catch(Ne){console.error("Import error:",Ne),t("Failed to parse import file","error")}},G.click()},[e,r,t,ee]),re=M.useCallback(G=>{k(Z=>{const oe=new Set(Z);return oe.has(G)?oe.delete(G):oe.add(G),oe})},[]),we=M.useCallback(()=>{k(new Set(se.map(G=>F(G))))},[se,F]),Oe=M.useCallback(()=>{T.size!==0&&I(!0)},[T.size]),he=M.useCallback(async()=>{const G=se.filter(oe=>T.has(F(oe)));D(!0);let Z=0;for(const oe of G)try{await ke.deleteKProfile(e,{slot_id:oe.slot_id,extruder_id:oe.extruder_id,nozzle_id:oe.nozzle_id,nozzle_diameter:oe.nozzle_diameter,filament_id:oe.filament_id,setting_id:oe.setting_id}),Z++,await new Promise(Ne=>setTimeout(Ne,300))}catch(Ne){console.error("Failed to delete profile:",oe.name,Ne)}t(`Deleted ${Z} profiles`),D(!1),I(!1),A(!1),k(new Set),ee()},[e,T,se,t,ee,F]),ht=M.useCallback(G=>{const Z=[];return G.setting_id&&Z.push(G.setting_id),Z.push(`slot_${G.slot_id}_${G.filament_id}_${G.extruder_id}`),Z.push(`name_${G.name}_${G.filament_id}`),Z},[]),$=M.useCallback(async(G,Z)=>{if(e)try{await ke.setKProfileNote(e,G,Z),U()}catch(oe){console.error("Failed to save note:",oe),t("Failed to save note","error")}},[e,U,t]),H=M.useCallback(G=>{if(!Q?.notes)return{note:"",key:null};const Z=ht(G);for(const oe of Z)if(Q.notes[oe])return{note:Q.notes[oe],key:oe};return{note:"",key:null}},[Q,ht]),ne=M.useCallback(G=>H(G).note,[H]);return q?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(lo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):J.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(Ta,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),l.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):l.jsxs(l.Fragment,{children:[K&&!W&&l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[l.jsx(At,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),l.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[l.jsxs("div",{className:"flex-1 min-w-48",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),l.jsx("select",{value:e||"",onChange: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:J.map(G=>l.jsx("option",{value:G.id,children:G.name},G.id))})]}),l.jsxs("div",{className:"w-32",children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),l.jsxs("select",{value:r,onChange: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:[l.jsx("option",{value:"0.2",children:"0.2mm"}),l.jsx("option",{value:"0.4",children:"0.4mm"}),l.jsx("option",{value:"0.6",children:"0.6mm"}),l.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs(Le,{variant:"secondary",onClick:()=>ee(),disabled:K,children:[l.jsx(Cs,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Le,{onClick:()=>c(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[l.jsxs("div",{className:"flex-1 min-w-48 relative",children:[l.jsx(id,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:f,onChange: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"})]}),fe&&l.jsx("div",{className:"w-36",children:l.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:[l.jsx("option",{value:"all",children:"All Extruders"}),l.jsx("option",{value:"left",children:"Left Only"}),l.jsx("option",{value:"right",children:"Right Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{value: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:[l.jsx("option",{value:"all",children:"All Flow"}),l.jsx("option",{value:"hf",children:"HF Only"}),l.jsx("option",{value:"s",children:"S Only"})]})}),l.jsx("div",{className:"w-32",children:l.jsxs("select",{value:b,onChange: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:[l.jsx("option",{value:"name",children:"Sort: Name"}),l.jsx("option",{value:"k_value",children:"Sort: K-Value"}),l.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),l.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[l.jsxs(Le,{variant:"secondary",onClick:xe,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[l.jsx(Ma,{className:"w-4 h-4"}),"Export"]}),l.jsxs(Le,{variant:"secondary",onClick:Ee,title:"Import profiles from JSON",children:[l.jsx(ya,{className:"w-4 h-4"}),"Import"]}),l.jsx("div",{className:"flex-1"}),S?l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",onClick:we,title:"Select all visible profiles",children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select All"]}),l.jsxs(Le,{variant:"secondary",onClick:Oe,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[l.jsx(Wt,{className:"w-4 h-4"}),"Cancel"]})]}):l.jsxs(Le,{variant:"secondary",onClick:()=>A(!0),disabled:!se.length,title:"Enter selection mode for bulk delete",children:[l.jsx(Vh,{className:"w-4 h-4"}),"Select"]})]}),W?l.jsx("div",{className:"flex justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):z?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(GR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),l.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),l.jsxs(Le,{variant:"secondary",onClick:()=>ee(),children:[l.jsx(Cs,{className:"w-4 h-4"}),"Retry"]})]})}):se.length>0?fe?l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),l.jsx("div",{className:"space-y-1",children:se.filter(G=>G.extruder_id===1).map(G=>l.jsx(d3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ne(G)},F(G)))})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),l.jsx("div",{className:"space-y-1",children:se.filter(G=>G.extruder_id===0).map(G=>l.jsx(d3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ne(G)},F(G)))})]})]}):l.jsx("div",{className:"space-y-1",children:se.map(G=>l.jsx(d3,{profile:G,onEdit:()=>a(G),onCopy:()=>d(G),selectionMode:S,isSelected:T.has(F(G)),onToggleSelect:()=>re(F(G)),note:ne(G)},F(G)))}):f||m!=="all"||y!=="all"?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(id,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(UR,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),l.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),l.jsxs(Le,{onClick:()=>c(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),s&&e&&(()=>{const{note:G,key:Z}=H(s);return l.jsx(h3,{profile:s,printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:fe,initialNote:G,initialNoteKey:Z,onSaveNote:$,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),a(null),ee()},onSave:()=>{a(null),ee()}})})(),o&&e&&l.jsx(h3,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:fe,onSaveNote:$,onClose:()=>{c(!1),ee()},onSave:()=>{c(!1),ee()}}),u&&e&&l.jsx(h3,{printerId:e,nozzleDiameter:r,existingProfiles:Y?.profiles||R?.profiles,isDualNozzle:fe,onSaveNote:$,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),ee()},onSave:()=>{d(null),ee()}}),N&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-sm",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:l.jsx(Rn,{className:"w-5 h-5 text-red-500"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),l.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",l.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(Le,{variant:"secondary",onClick:()=>I(!1),disabled:C,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:he,disabled:C,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[C?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function mL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,s=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),a=s?(s[1]||s[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=o?o[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:a,layerHeight:c,filamentType:d}}function hb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function p7e(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 m7e({onSuccess:t}){const{showToast:e}=si(),[n,r]=M.useState("email"),[i,s]=M.useState(""),[a,o]=M.useState(""),[c,u]=M.useState(""),[d,f]=M.useState(""),[g,m]=M.useState("global"),x=wt({mutationFn:()=>ke.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=wt({mutationFn:()=>ke.cloudVerify(i,c),onSuccess:S=>{S.success?(e("Logged in successfully"),t()):e(S.message,"error")},onError:S=>e(S.message,"error")}),v=wt({mutationFn:()=>ke.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 l.jsx(Nt,{className:"max-w-md mx-auto",children:l.jsxs(Rt,{children:[l.jsxs("div",{className:"text-center mb-6",children:[l.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:l.jsx(FS,{className:"w-6 h-6 text-bambu-green"})}),l.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),l.jsxs("form",{onSubmit:b,className:"space-y-4",children:[n==="email"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),l.jsx("input",{type:"email",value:i,onChange: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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),l.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),l.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:[l.jsx("option",{value:"global",children:"Global"}),l.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),l.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),l.jsx("input",{type:"text",value:c,onChange: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"&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),l.jsx("textarea",{value:d,onChange: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})]}),l.jsxs("div",{className:"flex gap-2",children:[n==="code"&&l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),l.jsxs(Le,{type:"submit",disabled:E,className:"flex-1",children:[E?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(KU,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[l.jsx(Vp,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&l.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:l.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[l.jsx(KU,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Lp({label:t,value:e,options:n,onChange:r}){const[i,s]=M.useState(!1),a=n.find(o=>o.value===e);return l.jsxs("div",{className:"relative",children:[l.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:[l.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),l.jsx("span",{children:a?.label||"All"}),l.jsx(uf,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),l.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>l.jsxs("button",{onClick:()=>{r(o.value),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:[l.jsx("span",{children:o.label}),o.count!==void 0&&l.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function g7e(){const[t,e]=M.useState(!1);M.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?l.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:l.jsx(hm,{className:"w-5 h-5"})}):null}function f3({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:a}){const o=mL(t.name),c=hb(t.setting_id);return l.jsxs("div",{className:"flex items-center gap-2 group",children:[l.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:l.jsxs("div",{className:"flex items-center gap-2",children:[i&&s!==void 0&&l.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:s+1}),!i&&c&&l.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),l.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),o.filamentType&&t.type==="filament"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.filamentType}),o.layerHeight&&t.type==="process"&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.layerHeight}),o.printer&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:o.printer})]})}),l.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:l.jsx(Hh,{className:"w-4 h-4"})})]})}function SR(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+" "+SR(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)+": "+SR(a,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function x7e({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:s}=si(),a=Mn(),[o,c]=M.useState(!1),{data:u,isLoading:d}=yt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ke.getCloudSettingDetail(t.setting_id)}),f=wt({mutationFn:()=>ke.deleteCloudSetting(t.setting_id),onSuccess:()=>{s("Preset deleted"),a.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>s(x.message,"error")}),g=hb(t.setting_id),m=mL(t.name,u?.setting?.inherits);return l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:l.jsxs(Rt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&l.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[l.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),m.printer&&l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"•"}),l.jsx("span",{children:m.printer})]})]})]}),l.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?l.jsx("div",{className:"flex items-center justify-center py-16",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?l.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:SR(u)}):l.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),o?l.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[l.jsx(ti,{className:"w-5 h-5"}),l.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),l.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]}):l.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),l.jsxs(Le,{variant:"secondary",onClick:r,children:[l.jsx(Hh,{className:"w-4 h-4"}),"Duplicate"]}),g&&l.jsxs(l.Fragment,{children:[l.jsxs(Le,{variant:"secondary",onClick:i,disabled:d||!u,children:[l.jsx(rd,{className:"w-4 h-4"}),"Edit"]}),l.jsx(Le,{variant:"danger",onClick:()=>c(!0),children:l.jsx(Rn,{className:"w-4 h-4"})})]})]})})]})})})}function pte(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function mte(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function b7e({onClose:t,onApply:e}){const{showToast:n}=si(),[r,i]=M.useState(pte),[s,a]=M.useState("all"),[o,c]=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),mte(j)},T=j=>{const q=r.filter(R=>R.id!==j);A(q),E(null),n("Template deleted")},k=j=>{c(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),c(null),n("Template updated")}catch(j){v(j.message)}},I=()=>{c(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:jR,color:"text-amber-400"},print:{label:"Process",icon:HS,color:"text-blue-400"},printer:{label:"Printer",icon:Ta,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]),l.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&l.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:l.jsx(Nt,{className:"w-full max-w-md",children:l.jsxs(Rt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[l.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:l.jsx(ti,{className:"w-6 h-6 text-red-400"})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),l.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',l.jsx("span",{className:"font-medium",children:F.name}),'"?']}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>T(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[l.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),l.jsx(Nt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(E0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(j=>l.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))]}),l.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:S.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(E0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:"No templates yet"}),l.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):l.jsx("div",{className:"space-y-2",children:S.map(j=>{const q=D[j.type],R=q.icon;return o===j.id?l.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[l.jsx("input",{type:"text",value:u,onChange:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:f,onChange:W=>g(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"mb-3",children:[l.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),l.jsx("textarea",{value: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&&l.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{size:"sm",onClick:N,disabled:!u.trim(),children:[l.jsx(Ro,{className:"w-4 h-4"}),"Save"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:I,children:"Cancel"})]})]},j.id):l.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[l.jsx(R,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:j.name}),l.jsx("p",{className:"text-xs text-bambu-gray truncate",children:j.description})]}),l.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"]}),l.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?l.jsx(mm,{className:"w-4 h-4"}):l.jsx(LR,{className:"w-4 h-4"})}),l.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"}),l.jsx("button",{onClick:()=>k(j),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:l.jsx(rd,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>E(j.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:l.jsx(Rn,{className:"w-4 h-4"})})]},j.id)})})})]})})]})}function gte({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[s,a]=M.useState("changes"),[o,c]=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]),l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsx(Nt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:l.jsxs(Rt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[l.jsx(Qp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),l.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:l.jsx(Wt,{className:"w-5 h-5"})})]}),l.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),l.jsx("p",{className:"text-white font-medium truncate",children:r})]}),l.jsxs("div",{className:"text-center",children:[l.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),l.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),l.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[l.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[l.jsx(pr,{className:"w-3.5 h-3.5"}),f.added," added"]}),l.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[l.jsx(R3,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),l.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[l.jsx(T3,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),l.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[l.jsx(RA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsx(id,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:o,onChange:m=>c(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&&l.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[l.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"}),l.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"})]})]})]}),l.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?l.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[l.jsx(RA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),l.jsx("p",{children:s==="changes"?"No differences found":"No fields match the search"})]}):l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:l.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[l.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),l.jsx("th",{className:"text-left p-3 w-1/3",children:r}),l.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),l.jsx("tbody",{children:d.map(m=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[m.status],y={added:l.jsx(pr,{className:"w-3.5 h-3.5 text-green-400"}),removed:l.jsx(R3,{className:"w-3.5 h-3.5 text-red-400"}),changed:l.jsx(T3,{className:"w-3.5 h-3.5 text-amber-400"}),same:l.jsx(RA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[m.status];return l.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[l.jsx("td",{className:"p-3",children:l.jsxs("div",{className:"flex items-center gap-2",children:[y,l.jsx("span",{className:"text-sm text-white font-mono",children:m.key})]})}),l.jsx("td",{className:"p-3",children:l.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)})}),l.jsx("td",{className:"p-3",children:l.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 v7e({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=si(),i=Mn(),s=!!e?.setting_id,[a,o]=M.useState("common"),[c,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(pte),[K,V]=M.useState(!1),[ee,Y]=M.useState(""),[Q,U]=M.useState(""),[z,J]=M.useState(!0),[se,me]=M.useState(null),[fe,xe]=M.useState(!1),Ee=M.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),re=M.useMemo(()=>Ee.filter(ae=>hb(ae.setting_id)),[Ee]),{data:we}=yt({queryKey:["cloudFields",c],queryFn:()=>ke.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Oe}=yt({queryKey:["allPresetDetails",c,re.map(ae=>ae.setting_id).join(",")],queryFn:async()=>{const ae={};for(let He=0;He<re.length;He+=5){const Ke=re.slice(He,He+5);(await Promise.all(Ke.map(async de=>{try{const Ye=await ke.getCloudSettingDetail(de.setting_id);return{id:de.setting_id,detail:Ye}}catch{return null}}))).forEach(de=>{de&&(ae[de.id]=de.detail)})}return ae},enabled:re.length>0,staleTime:1e3*60*10}),{data:he,isLoading:ht}=yt({queryKey:["cloudSettingDetail",g],queryFn:()=>ke.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}[c]||[]).filter(Je=>!hb(Je.setting_id)).sort((Je,He)=>Je.name.localeCompare(He.name)),[n,c]);M.useEffect(()=>{if(!g)return;const ae=$.find(Je=>Je.setting_id===g);ae&&(y(ae.name),s||(b({inherits:ae.name}),S(JSON.stringify({inherits:ae.name},null,2))))},[g,$,s]);const H=M.useMemo(()=>{const ae=we?.fields||[],Je=new Set(ae.map(de=>de.key)),He=new Set,Ke=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Oe&&Object.values(Oe).forEach(de=>{de?.setting&&Object.keys(de.setting).forEach(Ye=>{!Je.has(Ye)&&!Ke.has(Ye)&&He.add(Ye)})}),Object.keys(v).forEach(de=>{!Je.has(de)&&!Ke.has(de)&&He.add(de)});const ct=Array.from(He).sort().map(de=>({key:de,label:de.replace(/_/g," ").replace(/\b\w/g,Ye=>Ye.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ae,...ct]},[we,Oe,v]),ne=H.filter(ae=>ae.label.toLowerCase().includes(k.toLowerCase())||ae.key.toLowerCase().includes(k.toLowerCase())),G=()=>{if(D.trim()){const ae=D.trim().toLowerCase().replace(/\s+/g,"_");Z(ae,""),F(""),q(!1),r(`Field "${ae}" added`)}},Z=(ae,Je)=>{b(He=>{const Ke={...He};return Je===""||Je===void 0?delete Ke[ae]:Ke[ae]=Je,Ke})},oe=ae=>{b(Je=>({...Je,...ae.settings})),me(ae.name),r("Template applied")},Ne=()=>{if(!ee.trim())return;const ae={...v};if(delete ae.inherits,Object.keys(ae).length===0){r("No overrides to save","error");return}const Je={id:Date.now().toString(),name:ee.trim(),description:Q.trim()||"Custom template",type:c,settings:ae,showInModal:z},He=[...R,Je];W(He),mte(He),V(!1),Y(""),U(""),J(!0),r("Template saved")},Pe=M.useMemo(()=>R.filter(ae=>ae.type===c&&ae.showInModal),[c,R]),Se=ae=>{S(ae);try{const Je=JSON.parse(ae);b(Je),T(null)}catch(Je){T(Je.message)}},B=ae=>{ae.preventDefault(),C(!1);const Je=ae.dataTransfer.files[0];if(Je&&Je.name.endsWith(".json")){const He=new FileReader;He.onload=Ke=>{try{const ct=Ke.target?.result,de=JSON.parse(ct),Ye=de.setting||de;b(ge=>({...ge,...Ye})),S(JSON.stringify({...v,...Ye},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},He.readAsText(Je)}},L=wt({mutationFn:()=>{const ae={...v},Je=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";ae[Je]=`"${d}"`;const He={type:c,name:d,base_id:g,setting:ae};return ke.createCloudSetting(He)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ae=>r(ae.message,"error")}),te=wt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return ke.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:ae=>r(ae.message,"error")}),ve=s?te:L,_e=he?.setting?.inherits,be=_e?$.find(ae=>ae.name===_e):void 0,{data:nt}=yt({queryKey:["cloudSettingDetail",be?.setting_id],queryFn:()=>ke.getCloudSettingDetail(be.setting_id),enabled:!!be?.setting_id}),Be=M.useMemo(()=>{const ae=nt?.setting||{},Je=he?.setting||{},He=g&&Oe?.[g]?.setting?Oe[g].setting:{};return{...ae,...Je,...He}},[g,he,nt,Oe]),ue=ae=>{if(ae==null)return"";if(Array.isArray(ae)){const Je=[...new Set(ae.map(He=>String(He)))];return Je.length===1?Je[0]:ae.join(", ")}return String(ae)},Ve=ae=>{const Je=v[ae.key],He=Be[ae.key],Ke=ue(He),ct=ht?"Loading...":Ke||"",de="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(ae.type==="boolean"){const Ye=Je==="1"||Je===void 0&&He==="1";return l.jsx("button",{type:"button",onClick:()=>Z(ae.key,Je==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ye?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:l.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ye?"translate-x-3.5":"translate-x-0.5"}`})})}return ae.type==="select"?l.jsxs("select",{value:Je||"",onChange:Ye=>Z(ae.key,Ye.target.value),className:de,children:[l.jsx("option",{value:"",children:ct}),ae.options?.map(Ye=>l.jsx("option",{value:Ye.value,children:Ye.label},Ye.value))]}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:ae.type==="number"?"number":"text",value:Je!==void 0?String(Je):"",onChange:Ye=>Z(ae.key,Ye.target.value),step:ae.step,min:ae.min,max:ae.max,placeholder:ct,className:de}),ae.unit&&l.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ae.unit})]})},Ue=M.useMemo(()=>he?.setting?he.setting:{},[he]);return l.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ae=>{ae.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:B,children:[fe&&g&&l.jsx(gte,{onClose:()=>xe(!1),leftPreset:Ue,rightPreset:v,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),l.jsx(Nt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:l.jsxs(Rt,{className:"p-0 flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:s?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[g&&l.jsxs("button",{onClick:()=>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:[l.jsx(Qp,{className:"w-4 h-4"}),"Compare"]}),l.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:l.jsx(Wt,{className:"w-5 h-5"})})]})]}),I&&l.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:l.jsxs("div",{className:"text-center",children:[l.jsx(ya,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),l.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),l.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),l.jsxs("select",{value:c,onChange:ae=>{u(ae.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:[l.jsx("option",{value:"filament",children:"Filament"}),l.jsx("option",{value:"print",children:"Process"}),l.jsx("option",{value:"printer",children:"Printer"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),l.jsxs("select",{value:g,onChange:ae=>m(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[l.jsx("option",{value:"",children:"Select base preset..."}),$.map(ae=>l.jsx("option",{value:ae.setting_id,children:ae.name},ae.setting_id))]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),l.jsx("input",{type:"text",value:d,onChange:ae=>f(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&l.jsx("div",{className:"text-xs text-bambu-gray",children:l.jsxs("p",{className:"flex items-center gap-1",children:[l.jsx(zh,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",l.jsx("span",{className:"text-white",children:x}),ht&&l.jsx(At,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[l.jsxs("button",{onClick:()=>o("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(XU,{className:"w-4 h-4"}),"Common"]}),l.jsxs("button",{onClick:()=>o("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(zR,{className:"w-4 h-4"}),"All Fields"]}),l.jsxs("button",{onClick:()=>o("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${a==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(n7,{className:"w-4 h-4"}),"JSON",A&&l.jsx(lo,{className:"w-3 h-3 text-red-400"})]}),l.jsx("div",{className:"flex-1"}),l.jsxs("button",{onClick:()=>{const ae={name:d,type:c,base_id:g,setting:v},Je=new Blob([JSON.stringify(ae,null,2)],{type:"application/json"}),He=URL.createObjectURL(Je),Ke=document.createElement("a");Ke.href=He,Ke.download=`${d||"preset"}.json`,document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),URL.revokeObjectURL(He),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[l.jsx(Ma,{className:"w-4 h-4"}),"Export"]}),l.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[l.jsx(ya,{className:"w-4 h-4"}),"Import"]}),l.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ae=>{const Je=ae.target.files?.[0];if(Je){const He=new FileReader;He.onload=Ke=>{try{const ct=JSON.parse(Ke.target?.result),de=ct.setting||ct;b(Ye=>({...Ye,...de})),r("File imported")}catch{r("Invalid JSON","error")}},He.readAsText(Je)}}})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[a==="common"&&l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(E0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(v).filter(ae=>ae!=="inherits").length>0&&l.jsxs("button",{onClick:()=>V(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[l.jsx(Ro,{className:"w-3 h-3"}),"Save as template"]})]}),K&&l.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[l.jsx("input",{type:"text",value:ee,onChange:ae=>Y(ae.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),l.jsx("input",{type:"text",value:Q,onChange:ae=>U(ae.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{size:"sm",onClick:Ne,disabled:!ee.trim(),children:[l.jsx(Ro,{className:"w-3 h-3"}),"Save"]}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),l.jsxs("button",{onClick:()=>J(!z),className:`flex items-center gap-1.5 text-xs transition-colors ${z?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[z?l.jsx(mm,{className:"w-3.5 h-3.5"}):l.jsx(LR,{className:"w-3.5 h-3.5"}),z?"Show in modals":"Hidden in modals"]})]})]}),se&&l.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[l.jsx(zh,{className:"w-4 h-4 text-bambu-green"}),l.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",l.jsx("span",{className:"font-medium",children:se})]}),l.jsx("button",{onClick:()=>me(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Pe.map(ae=>l.jsxs("button",{onClick:()=>oe(ae),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[l.jsx("p",{className:"text-sm font-medium text-white",children:ae.name}),l.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ae.description})]},ae.id)),Pe.length===0&&l.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),l.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),l.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:H.slice(0,10).map(ae=>l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:ae.label}),l.jsx("div",{className:"w-48",children:Ve(ae)})]},ae.key))})]}),Object.keys(v).length>1&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(v).filter(([ae])=>ae!=="inherits").map(([ae,Je])=>l.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ae,": ",String(Je).slice(0,20),l.jsx("button",{onClick:()=>Z(ae,void 0),className:"hover:text-white",children:l.jsx(Wt,{className:"w-3 h-3"})})]},ae))})]})]}),a==="fields"&&l.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),l.jsx("span",{className:"text-xs text-bambu-gray",children:Oe?`${H.length} fields`:"Loading..."})]}),l.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[l.jsx(id,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.jsx("input",{type:"text",value:k,onChange:ae=>N(ae.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[ne.filter(ae=>!(ae.key in v)).map(ae=>{const Je=Be[ae.key],He=ue(Je);return l.jsxs("div",{onClick:()=>{b(Ke=>({...Ke,[ae.key]:He||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"text-sm text-white truncate",children:ae.label}),l.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ae.key})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[He&&l.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:He,children:[He.slice(0,20),He.length>20?"...":""]}),l.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:l.jsx(pr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ae.key)}),ne.filter(ae=>!(ae.key in v)).length===0&&l.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:k?"No matching fields":"All fields added"})]}),l.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:j?l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"text",value:D,onChange:ae=>F(ae.target.value),onKeyDown:ae=>ae.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}),l.jsx(Le,{size:"sm",onClick:G,disabled:!D.trim(),children:l.jsx(pr,{className:"w-4 h-4"})}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>{q(!1),F("")},children:l.jsx(Wt,{className:"w-4 h-4"})})]}):l.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[l.jsx(pr,{className:"w-4 h-4"}),"Add custom field"]})})]}),l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[l.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),l.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(v).filter(ae=>ae!=="inherits").length," fields"]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(v).filter(([ae])=>ae!=="inherits").map(([ae,Je])=>{const He=H.find(Ke=>Ke.key===ae);return l.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium text-white",children:He?.label||ae}),l.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ae})]}),l.jsx("button",{onClick:()=>Z(ae,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Wt,{className:"w-4 h-4"})})]}),He?Ve(He):l.jsx("input",{type:"text",value:String(Je),onChange:Ke=>Z(ae,Ke.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},ae)}),Object.keys(v).filter(ae=>ae!=="inherits").length===0&&l.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[l.jsx(XU,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{className:"text-sm",children:"No overrides yet"}),l.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(v).filter(ae=>ae!=="inherits").length>0&&l.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:l.jsxs("button",{onClick:()=>{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:[l.jsx(Ro,{className:"w-4 h-4"}),"Save as template"]})})]})]}),a==="json"&&l.jsxs("div",{className:"space-y-2",children:[A&&l.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[l.jsx(lo,{className:"w-4 h-4"}),A]}),l.jsx("textarea",{value:E,onChange:ae=>Se(ae.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),l.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),l.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[l.jsx(Le,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),l.jsxs(Le,{onClick:()=>ve.mutate(),disabled:ve.isPending||!d.trim()||!s&&!g||!!A,className:"flex-1",children:[ve.isPending?l.jsx(At,{className:"w-4 h-4 animate-spin"}):s?l.jsx(Ro,{className:"w-4 h-4"}):l.jsx(pr,{className:"w-4 h-4"}),s?"Save":e?"Duplicate":"Create"]})]})]})})]})}function y7e({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[s,a]=M.useState(""),[o,c]=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,ee]=M.useState([null,null]),[Y,Q]=M.useState(!1),[U,z]=M.useState(null),J=Mn(),se=M.useMemo(()=>[...t.filament.map(ne=>({...ne,type:"filament"})),...t.printer.map(ne=>({...ne,type:"printer"})),...t.process.map(ne=>({...ne,type:"process"}))].map(ne=>({...ne,meta:mL(ne.name)})),[t]),me=M.useMemo(()=>{const H=new Set,ne=new Set,G=new Set;return se.forEach(Z=>{Z.meta.nozzle&&H.add(Z.meta.nozzle),Z.meta.filamentType&&ne.add(Z.meta.filamentType),Z.meta.layerHeight&&G.add(Z.meta.layerHeight)}),{printers:i.map(Z=>({id:Z.id.toString(),name:Z.name})),nozzles:Array.from(H).sort((Z,oe)=>parseFloat(Z)-parseFloat(oe)),filaments:Array.from(ne).sort(),layerHeights:Array.from(G).sort((Z,oe)=>parseFloat(Z)-parseFloat(oe))}},[se,i]),fe=M.useMemo(()=>f==="all"?null:i.find(ne=>ne.id.toString()===f)?.model||null,[f,i]),xe=M.useMemo(()=>se.filter(H=>o==="all"||H.type===o).filter(H=>{if(u==="all")return!0;const ne=hb(H.setting_id);return u==="custom"?ne:!ne}).filter(H=>{if(f==="all"||!fe)return!0;const ne=H.meta.printer?.toLowerCase()||"",G=fe.toLowerCase();return ne.includes(G)||G.includes(ne)}).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,ne)=>H.name.localeCompare(ne.name)),[se,o,u,f,fe,m,y,b,s]),Ee=H=>{if(W){const ne=V[0]?.setting_id===H.setting_id,G=V[1]?.setting_id===H.setting_id;if(ne)ee([V[1],null]);else if(G)ee([V[0],null]);else if(!V[0])ee([H,null]);else if(V[1]){if(V[0].type!==H.type)return;ee([V[0],H])}else{if(V[0].type!==H.type)return;ee([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},we=async H=>{try{const ne=await ke.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;D({type:G,name:H.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{}}),A(null)}catch(ne){console.error("Failed to fetch preset details for duplication:",ne)}},Oe=async H=>{try{J.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const ne=await ke.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;j({type:G,name:H.name,base_id:ne.base_id||"GFSA00",setting:ne.setting||{},setting_id:H.setting_id}),A(null)}catch(ne){console.error("Failed to fetch preset details for editing:",ne)}},he=()=>{c("all"),d("all"),g("all"),x("all"),v("all"),E("all"),a("")},ht=o!=="all"||u!=="all"||f!=="all"||m!=="all"||y!=="all"||b!=="all"||s!=="",$=t.filament.length+t.printer.length+t.process.length;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-4 mb-6",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(id,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),l.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"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(Le,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),ee([null,null])):K(!0)},children:[l.jsx(Qp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),l.jsxs(Le,{variant:"secondary",onClick:()=>I(!0),children:[l.jsx(E0,{className:"w-4 h-4"}),"Templates"]}),l.jsxs(Le,{variant:"secondary",onClick:n,disabled:r,children:[l.jsx(Cs,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),l.jsxs(Le,{onClick:()=>k(!0),children:[l.jsx(pr,{className:"w-4 h-4"}),"New Preset"]})]})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx(IR,{className:"w-4 h-4 text-bambu-gray"}),l.jsx(Lp,{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=>c(H)}),l.jsx(Lp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:H=>d(H)}),me.printers.length>0&&l.jsx(Lp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...me.printers.map(H=>({value:H.id,label:H.name}))],onChange:g}),me.nozzles.length>0&&l.jsx(Lp,{label:"Nozzle",value:m,options:[{value:"all",label:"All"},...me.nozzles.map(H=>({value:H,label:H}))],onChange:x}),me.filaments.length>0&&(o==="all"||o==="filament")&&l.jsx(Lp,{label:"Filament",value:y,options:[{value:"all",label:"All"},...me.filaments.map(H=>({value:H,label:H}))],onChange:v}),me.layerHeights.length>0&&(o==="all"||o==="process")&&l.jsx(Lp,{label:"Layer",value:b,options:[{value:"all",label:"All"},...me.layerHeights.map(H=>({value:H,label:H}))],onChange:E}),ht&&l.jsx("button",{onClick:he,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&l.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx(Qp,{className:"w-5 h-5 text-blue-400"}),l.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),l.jsx("span",{className:"text-bambu-gray",children:V[0]?`Select another ${V[0].type} preset`:"Click two presets of the same type to compare"})]}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${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"}),l.jsx(T3,{className:"w-4 h-4 text-bambu-gray"}),l.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]&&l.jsxs(Le,{size:"sm",onClick:async()=>{try{const[H,ne]=await Promise.all([ke.getCloudSettingDetail(V[0].setting_id),ke.getCloudSettingDetail(V[1].setting_id)]);z([H.setting||{},ne.setting||{}]),Q(!0)}catch{}},children:[l.jsx(Qp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),l.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(_r,{className:"w-3 h-3"}),"Last synced: ",p7e(e.toISOString())]}),l.jsxs("span",{children:["Showing ",xe.length," of ",$," presets"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),l.jsx("span",{children:"= My preset (editable)"})]})]}),xe.length===0?l.jsxs("div",{className:"text-center py-16",children:[l.jsx($h,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),l.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),ht&&l.jsx("button",{onClick:he,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(jR,{className:"w-4 h-4 text-amber-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="filament").length,")"]})]}),l.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=>l.jsx(f3,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>we(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&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(HS,{className:"w-4 h-4 text-blue-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="process").length,")"]})]}),l.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=>l.jsx(f3,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>we(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&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[l.jsx(Ta,{className:"w-4 h-4 text-purple-400"}),l.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),l.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",xe.filter(H=>H.type==="printer").length,")"]})]}),l.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=>l.jsx(f3,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>we(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&&l.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),S&&l.jsx(x7e,{setting:S,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>we(S),onEdit:()=>Oe(S)}),(T||C||F||q)&&l.jsx(v7e,{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&&l.jsx(b7e,{onClose:()=>I(!1),onApply:H=>{R({type:H.type,setting:H.settings}),I(!1)}}),Y&&U&&V[0]&&V[1]&&l.jsx(gte,{onClose:()=>{Q(!1),z(null)},leftPreset:U[0],rightPreset:U[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function _7e(){const t=Mn(),{showToast:e}=si(),[n,r]=M.useState("cloud"),[i,s]=M.useState(),{data:a,isLoading:o}=yt({queryKey:["cloudStatus"],queryFn:ke.getCloudStatus}),{data:c=[]}=yt({queryKey:["printers"],queryFn:ke.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=yt({queryKey:["cloudSettings"],queryFn:()=>ke.getCloudSettings(),enabled:!!a?.is_authenticated,retry:!1,staleTime:1e3*60*5});M.useEffect(()=>{g&&s(new Date(g))},[g]);const m=wt({mutationFn:ke.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?l.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):l.jsxs("div",{className:"p-6 lg:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),l.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),l.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[l.jsxs("button",{onClick:()=>r("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(FS,{className:"w-4 h-4"}),"Cloud Profiles"]}),l.jsxs("button",{onClick:()=>r("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[l.jsx(UR,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&l.jsxs(l.Fragment,{children:[a?.is_authenticated&&l.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),l.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",l.jsx("span",{className:"text-white",children:a.email})]})]}),l.jsxs(Le,{variant:"secondary",size:"sm",onClick:()=>m.mutate(),disabled:m.isPending,children:[l.jsx(Yle,{className:"w-4 h-4"}),"Logout"]})]}),a?.is_authenticated?d?l.jsx("div",{className:"flex items-center justify-center py-16",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?l.jsx(y7e,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):l.jsxs("div",{className:"text-center py-16",children:[l.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),l.jsx(Le,{onClick:()=>f(),children:"Retry"})]}):l.jsx(m7e,{onSuccess:x})]}),n==="kprofiles"&&l.jsx(f7e,{}),l.jsx(g7e,{})]})}const Vx={Droplet:jR,Flame:ule,Ruler:Ice,Sparkles:E0,Square:gm,Cable:ooe,Wrench:sd,Calendar:Zr,Timer:Fu,Cog:Ioe,Fan:Joe,Zap:bm,Wind:Oue,Thermometer:Sh,Layers:$h,Box:fm,Target:d7,RefreshCw:Cs,Settings:VR,Filter:IR,CircleDot:Moe};function f0(t){return t&&Vx[t]||sd}function Ip(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 p3(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 w7e({item:t,onPerform:e,onToggle:n}){const r=f0(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",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${Ip(Math.abs(f),"days")}`:t.is_warning?`Due in ${Ip(f,"days")}`:`${Ip(f,"days")} left`}else return t.is_due?`Overdue by ${Ip(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Ip(t.hours_until_due,"hours")}`:`${Ip(t.hours_until_due,"hours")} left`};return l.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[l.jsx(r,{className:`w-5 h-5 ${o()}`}),t.enabled&&(t.is_due||t.is_warning)&&l.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&l.jsx("span",{title:"Time-based interval",children:l.jsx(Zr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),l.jsx("div",{className:"mt-2 mb-1.5",children:l.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${a}%`}})})}),l.jsxs("div",{className:`text-xs flex items-center gap-1 ${o()}`,children:[t.is_due&&l.jsx(ti,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&l.jsx(_r,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&l.jsx(zh,{className:"w-3 h-3"}),d()]})]}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[l.jsx(Pn,{checked:t.enabled,onChange:f=>n(t.id,f)}),l.jsxs(Le,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[l.jsx(Xm,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function S7e({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,s]=M.useState(!0),[a,o]=M.useState(!1),[c,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(c);!isNaN(m)&&m>=0&&(r(t.printer_id,m),o(!1))};return l.jsxs(Nt,{className:"overflow-hidden",children:[l.jsxs("div",{className:"p-5",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),l.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&l.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[l.jsx(ti,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&l.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[l.jsx(_r,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&l.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[l.jsx(zh,{className:"w-3 h-3"}),"All good"]})]})]}),l.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?l.jsx(US,{className:"w-4 h-4"}):l.jsx(uf,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),l.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:l.jsx(Fu,{className:"w-4 h-4 text-bambu-gray"})}),a?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("input",{type:"number",value:c,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}),l.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),l.jsx(Le,{size:"sm",onClick:g,children:"Save"}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"Cancel"})]}):l.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),o(!0)},className:"group",children:[l.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.floor(t.total_print_hours)," hours",l.jsx(S0,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),l.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),l.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const m=f0(f.maintenance_type_icon);return l.jsx(m,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),l.jsxs("div",{children:[l.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),l.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&l.jsx(Rt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:l.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(m=>l.jsx(w7e,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function E7e({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s}){const[a,o]=M.useState(null),[c,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=J=>{N(J),C(J.name),F(J.default_interval_hours.toString()),q(J.interval_type||"hours"),W(J.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))},ee=(J,se,me)=>{const fe=parseFloat(c);if(!isNaN(fe)&&fe>0){const xe=Math.abs(fe-se)<.01?null:fe;n(J,{custom_interval_hours:xe,custom_interval_type:d!==me?d:null})}o(null)},Y=J=>{J.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))},Q=t?.map(J=>({printerId:J.printer_id,printerName:J.printer_name,items:J.maintenance_items.sort((se,me)=>se.maintenance_type_id-me.maintenance_type_id)})).sort((J,se)=>J.printerName.localeCompare(se.printerName))||[],U=e.filter(J=>J.is_system),z=e.filter(J=>!J.is_system);return l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsxs("div",{children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),l.jsxs(Le,{onClick:()=>m(!g),children:[l.jsx(pr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),g&&l.jsx(Nt,{className:"mb-6",children:l.jsx(Rt,{className:"py-4",children:l.jsxs("form",{onSubmit:Y,children:[l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[l.jsxs("div",{className:"lg:col-span-2",children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),l.jsx("input",{type:"text",value:x,onChange:J=>y(J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),l.jsxs("select",{value:E,onChange:J=>{S(J.target.value),J.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:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]})]}),l.jsxs("div",{children:[l.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",E==="days"?"days":"hours",")"]}),l.jsx("input",{type:"number",value:v,onChange:J=>b(J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),l.jsxs("div",{className:"mt-4 flex items-end justify-between",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),l.jsx("div",{className:"flex gap-1",children:Object.keys(Vx).map(J=>{const se=Vx[J];return l.jsx("button",{type:"button",onClick:()=>T(J),className:`p-2 rounded-lg transition-colors ${A===J?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:l.jsx(se,{className:"w-4 h-4"})},J)})})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),l.jsx(Le,{type:"submit",disabled:!x.trim(),children:"Add Type"})]})]})]})})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[U.map(J=>{const se=f0(J.icon),me=J.interval_type||"hours";return l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:l.jsx(se,{className:"w-5 h-5 text-bambu-gray"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-medium text-white truncate",children:J.name}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[me==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(Fu,{className:"w-3 h-3"}),p3(J.default_interval_hours,me)]})]})]})},J.id)}),z.map(J=>{const se=f0(J.icon),me=J.interval_type||"hours";return k?.id===J.id?l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:l.jsxs("div",{className:"space-y-3",children:[l.jsx("input",{type:"text",value: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}),l.jsxs("div",{className:"flex gap-2",children:[l.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:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.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"})]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Vx).map(xe=>{const Ee=Vx[xe];return l.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:l.jsx(Ee,{className:"w-3.5 h-3.5"})},xe)})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Le,{size:"sm",onClick:V,disabled:!I.trim(),children:"Save"}),l.jsx(Le,{size:"sm",variant:"secondary",onClick:()=>N(null),children:"Cancel"})]})]})},J.id):l.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:l.jsx(se,{className:"w-5 h-5 text-bambu-green"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-medium text-white truncate",children:J.name}),l.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),l.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[me==="days"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(Fu,{className:"w-3 h-3"}),p3(J.default_interval_hours,me)]})]}),l.jsx("button",{onClick:()=>K(J),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:l.jsx(S0,{className:"w-4 h-4"})}),l.jsx("button",{onClick:()=>{confirm(`Delete "${J.name}"?`)&&s(J.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:l.jsx(Rn,{className:"w-4 h-4"})})]})},J.id)})]})]}),Q.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),l.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),l.jsx("div",{className:"space-y-4",children:Q.map(J=>l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-4",children:[l.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:J.printerName}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:J.items.map(se=>{const me=f0(se.maintenance_type_icon),fe=e.find(Oe=>Oe.id===se.maintenance_type_id),xe=fe?.default_interval_hours||se.interval_hours,Ee=fe?.interval_type||"hours",re=se.interval_type||"hours",we=a===se.id;return l.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[l.jsx(me,{className:"w-4 h-4 text-bambu-gray shrink-0"}),l.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:se.maintenance_type_name}),we?l.jsxs("div",{className:"flex items-center gap-1",children:[d==="days"?l.jsx(Zr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):l.jsx(Fu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),l.jsxs("select",{value:d,onChange:Oe=>f(Oe.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[l.jsx("option",{value:"hours",children:"Print Hours"}),l.jsx("option",{value:"days",children:"Calendar Days"})]}),l.jsx("input",{type:"number",value:c,onChange:Oe=>u(Oe.target.value),onKeyDown:Oe=>{Oe.key==="Enter"&&ee(se.id,xe,Ee),Oe.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"}),l.jsx(Le,{size:"sm",onClick:()=>ee(se.id,xe,Ee),children:"OK"})]}):l.jsxs("button",{onClick:()=>{o(se.id),u(se.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"?l.jsx(Zr,{className:"w-3 h-3"}):l.jsx(Fu,{className:"w-3 h-3"}),p3(se.interval_hours,re),l.jsx(S0,{className:"w-3 h-3 text-bambu-gray"})]})]},se.id)})})]})},J.printerId))})]}),Q.length===0&&l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-12",children:[l.jsx(_r,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),l.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function M7e(){const t=Mn(),{showToast:e}=si(),[n,r]=M.useState("status"),{data:i,isLoading:s}=yt({queryKey:["maintenanceOverview"],queryFn:ke.getMaintenanceOverview}),{data:a}=yt({queryKey:["maintenanceTypes"],queryFn:ke.getMaintenanceTypes}),o=wt({mutationFn:({id:E,notes:S})=>ke.performMaintenance(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:E=>{e(E.message,"error")}}),c=wt({mutationFn:({id:E,data:S})=>ke.updateMaintenanceItem(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:E=>{e(E.message,"error")}}),u=wt({mutationFn:ke.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:E=>{e(E.message,"error")}}),d=wt({mutationFn:({id:E,data:S})=>ke.updateMaintenanceType(E,S),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:E=>{e(E.message,"error")}}),f=wt({mutationFn:ke.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:E=>{e(E.message,"error")}}),g=wt({mutationFn:({printerId:E,hours:S})=>ke.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)=>{c.mutate({id:E,data:{enabled:S}})},y=(E,S)=>{g.mutate({printerId:E,hours:S})};if(s)return l.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:l.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 l.jsxs("div",{className:"p-4 md:p-8",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),l.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?l.jsxs(l.Fragment,{children:[v>0&&l.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&b>0&&" · ",b>0&&l.jsxs("span",{className:"text-amber-400",children:[b," due soon"]}),v===0&&b===0&&l.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),l.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[l.jsx("button",{onClick:()=>r("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),l.jsx("button",{onClick:()=>r("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?l.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((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=>l.jsx(S7e,{overview:E,onPerform:m,onToggle:x,onSetHours:y},E.printer_id)):l.jsx(Nt,{children:l.jsxs(Rt,{className:"text-center py-16",children:[l.jsx(sd,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),l.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),l.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):l.jsx(E7e,{overview:i,types:a||[],onUpdateInterval:(E,S)=>c.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 pG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function A7e({project:t,onClose:e,onSave:n,isLoading:r}){const[i,s]=M.useState(t?.name||""),[a,o]=M.useState(t?.description||""),[c,u]=M.useState(t?.color||pG[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:c,target_count:d?parseInt(d,10):void 0,...t&&{status:g}})};return l.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:l.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[l.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:l.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),l.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),l.jsx("input",{type:"text",value:i,onChange: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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),l.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})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:pG.map(y=>l.jsx("button",{type:"button",onClick:()=>u(y),className:`w-8 h-8 rounded-full transition-transform ${c===y?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:y}},y))})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),l.jsx("input",{type:"number",value:d,onChange: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&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),l.jsxs("select",{value:g,onChange: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:[l.jsx("option",{value:"active",children:"Active"}),l.jsx("option",{value:"completed",children:"Completed"}),l.jsx("option",{value:"archived",children:"Archived"})]})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[l.jsx(Le,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),l.jsx(Le,{type:"submit",disabled:!i.trim()||r,children:r?l.jsx(At,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function T7e({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,s=t.status==="completed",a=t.status==="archived";return l.jsx(Nt,{className:"hover:border-bambu-gray/30 transition-colors cursor-pointer",onClick:e,children:l.jsxs(Rt,{className:"p-4",children:[l.jsxs("div",{className:"flex items-start justify-between mb-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:t.color||"#6b7280"}}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-medium text-white",children:t.name}),t.description&&l.jsx("p",{className:"text-sm text-bambu-gray/70 mt-0.5 line-clamp-1",children:t.description})]})]}),l.jsxs("div",{className:"flex items-center gap-1",onClick:o=>o.stopPropagation(),children:[s&&l.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded",children:"Completed"}),a&&l.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded",children:"Archived"}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:n,className:"p-1",children:l.jsx(S0,{className:"w-4 h-4"})}),l.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"p-1 text-red-400 hover:text-red-300",children:l.jsx(Rn,{className:"w-4 h-4"})})]})]}),t.target_count&&l.jsxs("div",{className:"mb-3",children:[l.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[l.jsxs("span",{children:[t.archive_count," / ",t.target_count," prints"]}),l.jsxs("span",{children:[i.toFixed(0),"%"]})]}),l.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.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&&l.jsx("div",{className:"mb-3",children:l.jsxs("div",{className:"flex gap-2",children:[t.archives.slice(0,5).map(o=>l.jsxs("a",{href:`/archives?search=${encodeURIComponent(o.print_name||"")}`,onClick:c=>c.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?l.jsx("img",{src:`/api/v1/archives/${o.id}/thumbnail`,alt:o.print_name||"",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:l.jsx(w0,{className:"w-6 h-6"})}),o.status==="failed"&&l.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:l.jsx("span",{className:"text-white text-xs font-bold",children:"✗"})})]},o.id)),t.archive_count>5&&l.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]})]})}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[l.jsxs("div",{className:"flex items-center gap-1",title:"Archives",children:[l.jsx(_h,{className:"w-4 h-4"}),l.jsx("span",{children:t.archive_count})]}),l.jsxs("div",{className:"flex items-center gap-1",title:"Queued",children:[l.jsx(Gle,{className:"w-4 h-4"}),l.jsx("span",{children:t.queue_count})]})]})]})})}function C7e(){const t=Mn(),{showToast:e}=si(),[n,r]=M.useState(!1),[i,s]=M.useState(),[a,o]=M.useState("active"),[c,u]=M.useState(null),{data:d,isLoading:f}=yt({queryKey:["projects",a==="all"?void 0:a],queryFn:()=>ke.getProjects(a==="all"?void 0:a)}),g=wt({mutationFn:A=>ke.createProject(A),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),e("Project created","success")},onError:A=>{e(A.message,"error")}}),m=wt({mutationFn:({id:A,data:T})=>ke.updateProject(A,T),onSuccess:()=>{t.invalidateQueries({queryKey:["projects"]}),r(!1),s(void 0),e("Project updated","success")},onError:A=>{e(A.message,"error")}}),x=wt({mutationFn:A=>ke.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=()=>{c!==null&&x.mutate(c)};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(qu,{className:"w-6 h-6 text-bambu-green"}),l.jsx("h1",{className:"text-2xl font-bold text-white",children:"Projects"})]}),l.jsxs(Le,{onClick:()=>r(!0),children:[l.jsx(pr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),l.jsx("div",{className:"flex gap-2",children:["active","completed","archived","all"].map(A=>l.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?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(At,{className:"w-8 h-8 animate-spin text-bambu-green"})}):d?.length===0?l.jsx(Nt,{children:l.jsxs(Rt,{className:"py-12 text-center",children:[l.jsx(qu,{className:"w-12 h-12 text-bambu-gray/50 mx-auto mb-4"}),l.jsx("p",{className:"text-bambu-gray",children:"No projects found"}),l.jsx("p",{className:"text-bambu-gray/70 text-sm mt-1",children:"Create a project to group related prints together"})]})}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:d?.map(A=>l.jsx(T7e,{project:A,onClick:()=>b(A),onEdit:()=>v(A),onDelete:()=>E(A.id)},A.id))}),c!==null&&l.jsx(Qr,{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&&l.jsx(A7e,{project:i,onClose:()=>{r(!1),s(void 0)},onSave:y,isLoading:g.isPending||m.isPending})]})}function N7e(){const{printerId:t}=LG(),e=parseInt(t||"0",10),[n,r]=M.useState("stream"),[i,s]=M.useState(!1),[a,o]=M.useState(!0),[c,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:()=>ke.getPrinter(e),enabled:e>0});M.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambuddy"}),[v]),M.useEffect(()=>{const C=`/api/v1/printers/${e}/camera/stop`,D=()=>{e>0&&navigator.sendBeacon(C)},F=()=>{document.visibilityState==="hidden"&&e>0&&navigator.sendBeacon(C)};return window.addEventListener("beforeunload",D),document.addEventListener("visibilitychange",F),()=>{window.removeEventListener("beforeunload",D),document.removeEventListener("visibilitychange",F),x.current&&(x.current.src=""),e>0&&navigator.sendBeacon(C)}},[e]),M.useEffect(()=>{if(a&&!d){const D=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(D)}},[n,a,c,d]),M.useEffect(()=>{const C=()=>{m(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",C),()=>document.removeEventListener("fullscreenchange",C)},[]);const b=()=>{s(!0),o(!1)},E=()=>{o(!1),s(!1)},S=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},A=C=>{n===C||d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),n==="stream"&&S(),setTimeout(()=>{r(C),u(Date.now()),f(!1)},100))},T=()=>{d||(f(!0),o(!0),s(!1),x.current&&(x.current.src=""),n==="stream"&&S(),setTimeout(()=>{u(Date.now()),f(!1)},100))},k=()=>{y.current&&(document.fullscreenElement?document.exitFullscreen():y.current.requestFullscreen())},N=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,I=a||d;return e?l.jsxs("div",{ref:y,className:"min-h-screen bg-black flex flex-col",children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[l.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[l.jsx(b0,{className:"w-4 h-4"}),v?.name||`Printer ${e}`]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[l.jsx("button",{onClick:()=>A("stream"),disabled:I,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),l.jsx("button",{onClick:()=>A("snapshot"),disabled:I,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),l.jsx("button",{onClick:T,disabled:I,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:l.jsx(Cs,{className:`w-4 h-4 text-bambu-gray ${I?"animate-spin":""}`})}),l.jsx("button",{onClick:k,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?l.jsx(hce,{className:"w-4 h-4 text-bambu-gray"}):l.jsx(ice,{className:"w-4 h-4 text-bambu-gray"})})]})]}),l.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:l.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(a||d)&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:l.jsxs("div",{className:"text-center",children:[l.jsx(Cs,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),i&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:l.jsxs("div",{className:"text-center p-4",children:[l.jsx(ti,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),l.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),l.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),l.jsx("button",{onClick:T,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),l.jsx("img",{ref:x,src:N,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:N?b:void 0,onLoad:N?E:void 0},c)]})})]}):l.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:l.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function k7e(){const{id:t}=LG(),{theme:e}=xb(),{data:n,isLoading:r,error:i}=yt({queryKey:["external-link",t],queryFn:()=>ke.getExternalLink(Number(t)),enabled:!!t});return r?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[l.jsx(ti,{className:"w-12 h-12"}),l.jsx("p",{children:"Link not found"})]}):l.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function Ur({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return l.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[l.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:l.jsx(t,{className:"w-5 h-5"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm text-bambu-gray",children:e}),l.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&l.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function mG({percent:t,color:e="bg-bambu-green"}){return l.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:l.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function eh({title:t,icon:e,children:n}){return l.jsxs(Nt,{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(e,{className:"w-5 h-5 text-bambu-green"}),l.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function P7e(){const{t}=Gm(),{data:e,isLoading:n,refetch:r,isFetching:i}=yt({queryKey:["systemInfo"],queryFn:ke.getSystemInfo,refetchInterval:3e4});if(n)return l.jsx("div",{className:"flex items-center justify-center h-64",children:l.jsx(At,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!e)return l.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const s=e.storage.disk_percent_used>90?"bg-red-500":e.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",a=e.memory.percent_used>90?"bg-red-500":e.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return l.jsxs("div",{className:"p-6 space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),l.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),l.jsxs("button",{onClick:()=>r(),disabled:i,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[l.jsx(Cs,{className:`w-4 h-4 ${i?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),l.jsx(eh,{title:t("system.application","Application"),icon:th,children:l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[l.jsx(Ur,{icon:th,label:t("system.version","Version"),value:`v${e.app.version}`}),l.jsx(Ur,{icon:_r,label:t("system.uptime","System Uptime"),value:e.system.uptime_formatted}),l.jsx(Ur,{icon:th,label:t("system.hostname","Hostname"),value:e.system.hostname})]})}),l.jsxs(eh,{title:t("system.database","Database"),icon:pm,children:[l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[l.jsx(Ur,{icon:_h,label:t("system.totalArchives","Total Archives"),value:e.database.archives}),l.jsx(Ur,{icon:Soe,label:t("system.completed","Completed"),value:e.database.archives_completed,color:"text-green-500"}),l.jsx(Ur,{icon:ga,label:t("system.failed","Failed"),value:e.database.archives_failed,color:"text-red-500"}),l.jsx(Ur,{icon:At,label:t("system.printing","Printing"),value:e.database.archives_printing,color:"text-yellow-500"})]}),l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsx(Ur,{icon:Ta,label:t("system.printers","Printers"),value:e.database.printers}),l.jsx(Ur,{icon:c7,label:t("system.filaments","Filaments"),value:e.database.filaments}),l.jsx(Ur,{icon:qu,label:t("system.projects","Projects"),value:e.database.projects}),l.jsx(Ur,{icon:Jp,label:t("system.smartPlugs","Smart Plugs"),value:e.database.smart_plugs})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[l.jsx(Ur,{icon:_r,label:t("system.totalPrintTime","Total Print Time"),value:e.database.total_print_time_formatted}),l.jsx(Ur,{icon:_h,label:t("system.totalFilament","Total Filament Used"),value:`${e.database.total_filament_kg} kg`,subValue:`${e.database.total_filament_grams.toLocaleString()} g`})]})]}),l.jsxs(eh,{title:t("system.connectedPrinters","Connected Printers"),icon:Ta,children:[l.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[l.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:e.printers.connected}),l.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:e.printers.total})})]}),e.printers.connected_list.length>0?l.jsx("div",{className:"space-y-2",children:e.printers.connected_list.map(o=>l.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),l.jsx("span",{className:"font-medium text-white",children:o.name})]}),l.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[l.jsx("span",{children:o.model}),l.jsx("span",{className:`px-2 py-0.5 rounded ${o.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":o.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:o.state})]})]},o.id))}):l.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),l.jsx(eh,{title:t("system.storage","Storage"),icon:FR,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),l.jsxs("span",{className:"text-white",children:[e.storage.disk_used_formatted," / ",e.storage.disk_total_formatted]})]}),l.jsx(mG,{percent:e.storage.disk_percent_used,color:s}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.storage.disk_free_formatted," ",t("system.free","free")," (",(100-e.storage.disk_percent_used).toFixed(1),"%)"]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsx(Ur,{icon:_h,label:t("system.archiveStorage","Archive Storage"),value:e.storage.archive_size_formatted}),l.jsx(Ur,{icon:pm,label:t("system.databaseSize","Database Size"),value:e.storage.database_size_formatted})]})]})}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsx(eh,{title:t("system.memory","Memory"),icon:ace,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{children:[l.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[l.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),l.jsxs("span",{className:"text-white",children:[e.memory.used_formatted," / ",e.memory.total_formatted]})]}),l.jsx(mG,{percent:e.memory.percent_used,color:a}),l.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.memory.available_formatted," ",t("system.available","available")]})]})})}),l.jsx(eh,{title:t("system.cpu","CPU"),icon:gy,children:l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsx(Ur,{icon:gy,label:t("system.cores","Cores"),value:e.cpu.count,subValue:`${e.cpu.count_logical} logical`}),l.jsx(Ur,{icon:gy,label:t("system.usage","Usage"),value:`${e.cpu.percent}%`})]})})})]}),l.jsx(eh,{title:t("system.systemDetails","System Details"),icon:th,children:l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.jsx(Ur,{icon:th,label:t("system.os","Operating System"),value:e.system.platform,subValue:e.system.platform_release}),l.jsx(Ur,{icon:gy,label:t("system.architecture","Architecture"),value:e.system.architecture}),l.jsx(Ur,{icon:th,label:t("system.python","Python"),value:e.system.python_version}),l.jsx(Ur,{icon:_r,label:t("system.bootTime","Boot Time"),value:new Date(e.system.boot_time).toLocaleString()})]})})]})}function R7e(){const t=M.useRef(null),e=M.useRef(null),n=Mn(),[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(c=>{switch(c.type){case"printer_status":c.printer_id!==void 0&&n.setQueryData(["printerStatus",c.printer_id],u=>{const d={...u,...c.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;case"archive_updated":n.invalidateQueries({queryKey:["archives"]});break}},[n]);M.useEffect(()=>(s(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[s]);const o=M.useCallback(c=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(c))},[]);return{isConnected:r,sendMessage:o}}const D7e=new Cae({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function O7e({children:t}){return R7e(),l.jsx(l.Fragment,{children:t})}function j7e(){return l.jsx(Hue,{children:l.jsx(Que,{children:l.jsx(Nae,{client:D7e,children:l.jsx(O7e,{children:l.jsx(Yse,{children:l.jsxs(Tse,{children:[l.jsx(fa,{path:"/camera/:printerId",element:l.jsx(N7e,{})}),l.jsxs(fa,{path:"/",element:l.jsx(Xue,{}),children:[l.jsx(fa,{index:!0,element:l.jsx(_Ce,{})}),l.jsx(fa,{path:"archives",element:l.jsx(qVe,{})}),l.jsx(fa,{path:"queue",element:l.jsx(RGe,{})}),l.jsx(fa,{path:"stats",element:l.jsx(WGe,{})}),l.jsx(fa,{path:"profiles",element:l.jsx(_7e,{})}),l.jsx(fa,{path:"maintenance",element:l.jsx(M7e,{})}),l.jsx(fa,{path:"projects",element:l.jsx(C7e,{})}),l.jsx(fa,{path:"settings",element:l.jsx(u7e,{})}),l.jsx(fa,{path:"system",element:l.jsx(P7e,{})}),l.jsx(fa,{path:"external/:id",element:l.jsx(k7e,{})})]})]})})})})})})}Pre.createRoot(document.getElementById("root")).render(l.jsx(M.StrictMode,{children:l.jsx(j7e,{})}));
|